@sumup/collector
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -15,2 +15,3 @@ /** | ||
*/ | ||
export declare const usePageViewTrigger: () => (() => void); | ||
import { DispatchFn } from '../../types'; | ||
export declare const usePageViewTrigger: () => DispatchFn; |
@@ -1,2 +0,2 @@ | ||
import*as e from"react";var t=e.createContext({app:void 0,view:void 0,elementTree:[]});function n(n){var r=n.name,a=n.onDispatch,i=n.children,o=e.useMemo((function(){return{app:r,dispatch:a,elementTree:[]}}),[r,a]);return e.createElement(t.Provider,{value:o},i)} | ||
import*as e from"react";var t=e.createContext({app:void 0,view:void 0,elementTree:[]});function r(r){var n=r.name,a=r.onDispatch,c=r.children,o=e.useMemo((function(){return{app:n,dispatch:a,elementTree:[]}}),[n,a]);return e.createElement(t.Provider,{value:o},c)} | ||
/*! ***************************************************************************** | ||
@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var r,a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,i=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return o}function o(e,t){for(var n=0,r=t.length,a=e.length;n<r;n++,a++)e[a]=t[n];return e}function u(n){var r=n.name,i=n.children,o=e.useContext(t),u=e.useMemo((function(){return a(a({},o),{view:r})}),[o,r]);return e.createElement(t.Provider,{value:u},i)}function c(n){var r=n.name,u=n.label,c=n.children,l=e.useContext(t),v=u?r+"|"+u:r,s=e.useMemo((function(){return a(a({},l),{elementTree:o(o([],i(l.elementTree)),[v])})}),[l,v]);return e.createElement(t.Provider,{value:s},c)}function l(n){var r=e.useContext(t),a=r.dispatch,i=r.app,o=r.view,u=r.elementTree;return e.useCallback((function(e){var t=e.component,r=e.label,c=e.customParameters;return a&&a({app:i,view:o,elementTree:u,event:n,component:t,label:r,timestamp:Date.now(),customParameters:c})}),[i,a,u,n,o])}!function(e){e.click="click",e.view="view",e.load="load",e.pageView="page-view",e.pageReactivated="page-reactivated",e.submit="submit",e.browserBack="browser-back",e.sectionExpanded="section-expanded"}(r||(r={}));var v=function(){return l(r.click)},s=function(){return l(r.submit)},f=function(){var t=l(r.pageView);return e.useCallback((function(){return t({})}),[t])};function m(t,n){void 0===n&&(n=!0);var r,a,o=i(e.useState(n),2),u=o[0],c=o[1],l=(r=u,a=e.useRef(r),e.useEffect((function(){a.current=r}),[r]),a.current);e.useEffect((function(){var e=function(){c(!document.hidden)};return document.addEventListener("visibilitychange",e),function(){document.removeEventListener("visibilitychange",e)}}),[]),l!==u&&t(u)}function d(e){var t=l(r.pageReactivated);m((function(e){return e&&t({})}),e)}var p=function(){return l(r.sectionExpanded)};function b(e,t){var n=e.reduce((function(e,t){var n=t.customParameters||{};return a(a({},e),n)}),{}),r=Object.keys(n).reduce((function(e,t){var n;return a(a({},e),((n={})[t]=void 0,n))}),{});return a(a({},t),{customParameters:a(a({},r),t.customParameters),_clear:!0})}export{c as TrackingElement,n as TrackingRoot,u as TrackingView,b as getFlushedPayload,v as useClickTrigger,d as usePageActiveTrigger,f as usePageViewTrigger,p as useSectionExpandedTrigger,s as useSubmitTrigger}; | ||
***************************************************************************** */var n,a=function(){return(a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function c(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,c=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=c.next()).done;)o.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return o}function o(e,t,r){if(r||2===arguments.length)for(var n,a=0,c=t.length;a<c;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}function i(r){var n=r.name,c=r.children,o=e.useContext(t),i=e.useMemo((function(){return a(a({},o),{view:n})}),[o,n]);return e.createElement(t.Provider,{value:i},c)}function u(r){var n=r.name,i=r.label,u=r.children,l=e.useContext(t),s=i?"".concat(n,"|").concat(i):n,v=e.useMemo((function(){return a(a({},l),{elementTree:o(o([],c(l.elementTree),!1),[s],!1)})}),[l,s]);return e.createElement(t.Provider,{value:v},u)}function l(r){var n=e.useContext(t),a=n.dispatch,c=n.app,o=n.view,i=n.elementTree;return e.useCallback((function(e){var t=e.component,n=e.label,u=e.customParameters;return a&&a({app:c,view:o,elementTree:i,event:r,component:t,label:n,timestamp:Date.now(),customParameters:u})}),[c,a,i,r,o])}!function(e){e.click="click",e.view="view",e.load="load",e.pageView="page-view",e.pageReactivated="page-reactivated",e.submit="submit",e.browserBack="browser-back",e.sectionExpanded="section-expanded"}(n||(n={}));var s=function(){return l(n.click)},v=function(){return l(n.submit)},f=function(){var t=l(n.pageView);return e.useCallback((function(e){var r=(e||{}).customParameters;return t({customParameters:r})}),[t])};function m(t,r){void 0===r&&(r=!0);var n,a,o=c(e.useState(r),2),i=o[0],u=o[1],l=(n=i,a=e.useRef(n),e.useEffect((function(){a.current=n}),[n]),a.current);e.useEffect((function(){var e=function(){u(!document.hidden)};return document.addEventListener("visibilitychange",e),function(){document.removeEventListener("visibilitychange",e)}}),[]),l!==i&&t(i)}function p(e){var t=l(n.pageReactivated);m((function(e){return e&&t({})}),e)}var d=function(){return l(n.sectionExpanded)};function b(e,t){var r=e.reduce((function(e,t){var r=t.customParameters||{};return a(a({},e),r)}),{}),n=Object.keys(r).reduce((function(e,t){var r;return a(a({},e),((r={})[t]=void 0,r))}),{});return a(a({},t),{customParameters:a(a({},n),t.customParameters),_clear:!0})}export{u as TrackingElement,r as TrackingRoot,i as TrackingView,b as getFlushedPayload,s as useClickTrigger,p as usePageActiveTrigger,f as usePageViewTrigger,d as useSectionExpandedTrigger,v as useSubmitTrigger}; |
@@ -16,2 +16,2 @@ "use strict";function e(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=t.createContext({app:void 0,view:void 0,elementTree:[]}); | ||
***************************************************************************** */ | ||
var n,i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)u.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return u}function u(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e}function o(e){var n=t.useContext(r),i=n.dispatch,a=n.app,u=n.view,o=n.elementTree;return t.useCallback((function(t){var r=t.component,n=t.label,c=t.customParameters;return i&&i({app:a,view:u,elementTree:o,event:e,component:r,label:n,timestamp:Date.now(),customParameters:c})}),[a,i,o,e,u])}!function(e){e.click="click",e.view="view",e.load="load",e.pageView="page-view",e.pageReactivated="page-reactivated",e.submit="submit",e.browserBack="browser-back",e.sectionExpanded="section-expanded"}(n||(n={}));function c(e,r){void 0===r&&(r=!0);var n,i,u=a(t.useState(r),2),o=u[0],c=u[1],s=(n=o,i=t.useRef(n),t.useEffect((function(){i.current=n}),[n]),i.current);t.useEffect((function(){var e=function(){c(!document.hidden)};return document.addEventListener("visibilitychange",e),function(){document.removeEventListener("visibilitychange",e)}}),[]),s!==o&&e(o)}exports.TrackingElement=function(e){var n=e.name,o=e.label,c=e.children,s=t.useContext(r),l=o?n+"|"+o:n,f=t.useMemo((function(){return i(i({},s),{elementTree:u(u([],a(s.elementTree)),[l])})}),[s,l]);return t.createElement(r.Provider,{value:f},c)},exports.TrackingRoot=function(e){var n=e.name,i=e.onDispatch,a=e.children,u=t.useMemo((function(){return{app:n,dispatch:i,elementTree:[]}}),[n,i]);return t.createElement(r.Provider,{value:u},a)},exports.TrackingView=function(e){var n=e.name,a=e.children,u=t.useContext(r),o=t.useMemo((function(){return i(i({},u),{view:n})}),[u,n]);return t.createElement(r.Provider,{value:o},a)},exports.getFlushedPayload=function(e,t){var r=e.reduce((function(e,t){var r=t.customParameters||{};return i(i({},e),r)}),{}),n=Object.keys(r).reduce((function(e,t){var r;return i(i({},e),((r={})[t]=void 0,r))}),{});return i(i({},t),{customParameters:i(i({},n),t.customParameters),_clear:!0})},exports.useClickTrigger=function(){return o(n.click)},exports.usePageActiveTrigger=function(e){var t=o(n.pageReactivated);c((function(e){return e&&t({})}),e)},exports.usePageViewTrigger=function(){var e=o(n.pageView);return t.useCallback((function(){return e({})}),[e])},exports.useSectionExpandedTrigger=function(){return o(n.sectionExpanded)},exports.useSubmitTrigger=function(){return o(n.submit)}; | ||
var n,a=function(){return(a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,o=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)c.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return c}function c(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}function i(e){var n=t.useContext(r),a=n.dispatch,o=n.app,c=n.view,i=n.elementTree;return t.useCallback((function(t){var r=t.component,n=t.label,u=t.customParameters;return a&&a({app:o,view:c,elementTree:i,event:e,component:r,label:n,timestamp:Date.now(),customParameters:u})}),[o,a,i,e,c])}!function(e){e.click="click",e.view="view",e.load="load",e.pageView="page-view",e.pageReactivated="page-reactivated",e.submit="submit",e.browserBack="browser-back",e.sectionExpanded="section-expanded"}(n||(n={}));function u(e,r){void 0===r&&(r=!0);var n,a,c=o(t.useState(r),2),i=c[0],u=c[1],s=(n=i,a=t.useRef(n),t.useEffect((function(){a.current=n}),[n]),a.current);t.useEffect((function(){var e=function(){u(!document.hidden)};return document.addEventListener("visibilitychange",e),function(){document.removeEventListener("visibilitychange",e)}}),[]),s!==i&&e(i)}exports.TrackingElement=function(e){var n=e.name,i=e.label,u=e.children,s=t.useContext(r),l=i?"".concat(n,"|").concat(i):n,f=t.useMemo((function(){return a(a({},s),{elementTree:c(c([],o(s.elementTree),!1),[l],!1)})}),[s,l]);return t.createElement(r.Provider,{value:f},u)},exports.TrackingRoot=function(e){var n=e.name,a=e.onDispatch,o=e.children,c=t.useMemo((function(){return{app:n,dispatch:a,elementTree:[]}}),[n,a]);return t.createElement(r.Provider,{value:c},o)},exports.TrackingView=function(e){var n=e.name,o=e.children,c=t.useContext(r),i=t.useMemo((function(){return a(a({},c),{view:n})}),[c,n]);return t.createElement(r.Provider,{value:i},o)},exports.getFlushedPayload=function(e,t){var r=e.reduce((function(e,t){var r=t.customParameters||{};return a(a({},e),r)}),{}),n=Object.keys(r).reduce((function(e,t){var r;return a(a({},e),((r={})[t]=void 0,r))}),{});return a(a({},t),{customParameters:a(a({},n),t.customParameters),_clear:!0})},exports.useClickTrigger=function(){return i(n.click)},exports.usePageActiveTrigger=function(e){var t=i(n.pageReactivated);u((function(e){return e&&t({})}),e)},exports.usePageViewTrigger=function(){var e=i(n.pageView);return t.useCallback((function(t){var r=(t||{}).customParameters;return e({customParameters:r})}),[e])},exports.useSectionExpandedTrigger=function(){return i(n.sectionExpanded)},exports.useSubmitTrigger=function(){return i(n.submit)}; |
{ | ||
"name": "@sumup/collector", | ||
"sideEffects": false, | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"main": "build/index.js", | ||
@@ -30,8 +30,8 @@ "module": "build/index.es.js", | ||
"@sumup/foundry": "^4.0.1", | ||
"@testing-library/jest-dom": "^5.14.1", | ||
"@testing-library/react": "^12.1.0", | ||
"@testing-library/jest-dom": "^5.15.1", | ||
"@testing-library/react": "^12.1.2", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@types/jest": "^27.0.1", | ||
"@types/react": "^17.0.20", | ||
"@types/react-dom": "^17.0.9", | ||
"@types/jest": "^27.0.3", | ||
"@types/react": "^17.0.37", | ||
"@types/react-dom": "^17.0.11", | ||
"cz-conventional-changelog": "3.3.0", | ||
@@ -42,9 +42,9 @@ "jest": "^26.6.3", | ||
"react-test-renderer": "^17.0.2", | ||
"rollup": "^2.56.3", | ||
"rollup": "^2.60.1", | ||
"rollup-plugin-peer-deps-external": "^2.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"rollup-plugin-typescript2": "^0.31.1", | ||
"ts-jest": "^26.5.6", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.3" | ||
"typescript": "^4.5.2" | ||
}, | ||
@@ -51,0 +51,0 @@ "peerDependencies": { |
@@ -42,3 +42,3 @@ <div align="center"> | ||
TrackingElement, | ||
useClickTrigger | ||
useClickTrigger, | ||
} from '@sumup/collector'; | ||
@@ -255,3 +255,3 @@ | ||
customParameters?: { | ||
[key: string]: any | ||
[key: string]: any, | ||
}; | ||
@@ -281,2 +281,3 @@ event: 'click'; // Added internally by the hook | ||
``` | ||
### useSectionExpandedTrigger | ||
@@ -293,3 +294,3 @@ | ||
customParameters?: { | ||
[key: string]: any | ||
[key: string]: any, | ||
}; | ||
@@ -331,3 +332,3 @@ event: 'section-expanded'; // Added internally by the hook | ||
customParameters?: { | ||
[key: string]: any | ||
[key: string]: any, | ||
}; | ||
@@ -366,2 +367,5 @@ event: 'submit'; // Added internally by the hook | ||
view: string; | ||
customParameters?: { | ||
[key: string]: any | ||
}; | ||
event: 'page-view'; // Added internally by the hook | ||
@@ -381,3 +385,3 @@ timestamp: number; // Added internally by the library when the dispatch function is called | ||
TrackingView, | ||
usePageViewTrigger | ||
usePageViewTrigger, | ||
} from '@sumup/collector'; | ||
@@ -460,4 +464,4 @@ | ||
- [Fernando Fleury](mailto:fernando.fleury@sumup.com) | ||
- [Shih Yen Hwang](mailto:shih.yen.hwang@sumup.com) | ||
- [Connor Bär](mailto:connor.baer@sumup.com) | ||
- [SumUp Web Chapter](mailto:webchapter@sumup.com) | ||
@@ -464,0 +468,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65318
735
468