@blaze-cms/plugin-gtm-fe 0.146.0-node18-core-styles-tooltips.45 → 0.146.0-node18-core-styles-tooltips.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib-es/GoogleTagManager/GTMFactory.js +55 -0
  3. package/lib-es/GoogleTagManager/GTMFactory.js.map +1 -0
  4. package/lib-es/GoogleTagManager/GTMRender.js +72 -0
  5. package/lib-es/GoogleTagManager/GTMRender.js.map +1 -0
  6. package/lib-es/GoogleTagManager/index.js +3 -0
  7. package/lib-es/GoogleTagManager/index.js.map +1 -0
  8. package/lib-es/GoogleTagManagerEvent/GTMClickEvent.js +55 -0
  9. package/lib-es/GoogleTagManagerEvent/GTMClickEvent.js.map +1 -0
  10. package/lib-es/GoogleTagManagerEvent/GTMClickEvents.js +32 -0
  11. package/lib-es/GoogleTagManagerEvent/GTMClickEvents.js.map +1 -0
  12. package/lib-es/GoogleTagManagerEvent/GTMEvent.js +38 -0
  13. package/lib-es/GoogleTagManagerEvent/GTMEvent.js.map +1 -0
  14. package/lib-es/GoogleTagManagerEvent/GTMEventFactory.js +92 -0
  15. package/lib-es/GoogleTagManagerEvent/GTMEventFactory.js.map +1 -0
  16. package/lib-es/GoogleTagManagerEvent/GTMEventRender.js +81 -0
  17. package/lib-es/GoogleTagManagerEvent/GTMEventRender.js.map +1 -0
  18. package/lib-es/GoogleTagManagerEvent/GTMEventSwitch.js +40 -0
  19. package/lib-es/GoogleTagManagerEvent/GTMEventSwitch.js.map +1 -0
  20. package/lib-es/GoogleTagManagerEvent/index.js +3 -0
  21. package/lib-es/GoogleTagManagerEvent/index.js.map +1 -0
  22. package/lib-es/constants.js +28 -0
  23. package/lib-es/constants.js.map +1 -0
  24. package/lib-es/helpers/build-and-push-web-vitals.js +24 -0
  25. package/lib-es/helpers/build-and-push-web-vitals.js.map +1 -0
  26. package/lib-es/helpers/build-data-layer.js +34 -0
  27. package/lib-es/helpers/build-data-layer.js.map +1 -0
  28. package/lib-es/helpers/build-nested-event.js +69 -0
  29. package/lib-es/helpers/build-nested-event.js.map +1 -0
  30. package/lib-es/helpers/build-props-to-display-array.js +5 -0
  31. package/lib-es/helpers/build-props-to-display-array.js.map +1 -0
  32. package/lib-es/helpers/build-user-layer.js +45 -0
  33. package/lib-es/helpers/build-user-layer.js.map +1 -0
  34. package/lib-es/helpers/build-user-query-props.js +25 -0
  35. package/lib-es/helpers/build-user-query-props.js.map +1 -0
  36. package/lib-es/helpers/filter-gtm-events.js +14 -0
  37. package/lib-es/helpers/filter-gtm-events.js.map +1 -0
  38. package/lib-es/helpers/get-ids-to-use.js +8 -0
  39. package/lib-es/helpers/get-ids-to-use.js.map +1 -0
  40. package/lib-es/helpers/get-render-props.js +25 -0
  41. package/lib-es/helpers/get-render-props.js.map +1 -0
  42. package/lib-es/helpers/index.js +11 -0
  43. package/lib-es/helpers/index.js.map +1 -0
  44. package/lib-es/helpers/push-to-data-layer.js +9 -0
  45. package/lib-es/helpers/push-to-data-layer.js.map +1 -0
  46. package/lib-es/helpers/reset-data-layer.js +17 -0
  47. package/lib-es/helpers/reset-data-layer.js.map +1 -0
  48. package/lib-es/index.js +21 -0
  49. package/lib-es/index.js.map +1 -0
  50. package/package.json +8 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.146.0-node18-core-styles-tooltips.46](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.45...v0.146.0-node18-core-styles-tooltips.46) (2026-01-16)
7
+
8
+ **Note:** Version bump only for package @blaze-cms/plugin-gtm-fe
9
+
10
+
11
+
12
+
13
+
6
14
  # [0.146.0-node18-core-styles-tooltips.45](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.44...v0.146.0-node18-core-styles-tooltips.45) (2026-01-15)
7
15
 
8
16
  **Note:** Version bump only for package @blaze-cms/plugin-gtm-fe
@@ -0,0 +1,55 @@
1
+ import React, { useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useQuery } from '@apollo/client';
4
+ import { getSingleEntitySchema, buildPropsQuery } from '@blaze-cms/react-page-builder';
5
+ import { MainContext } from '@blaze-cms/nextjs-components';
6
+ import GTMRender from './GTMRender';
7
+ import { getRenderProps, buildPropsToDisplayArray } from '../helpers';
8
+ const GTMFactory = ({
9
+ propsToDisplay,
10
+ userPropsToDisplay,
11
+ parent,
12
+ gtmWebVitals
13
+ }) => {
14
+ const {
15
+ isPreview
16
+ } = useContext(MainContext);
17
+ const {
18
+ data,
19
+ error,
20
+ loading
21
+ } = useQuery(getSingleEntitySchema, {
22
+ variables: {
23
+ id: parent.itemEntity
24
+ }
25
+ });
26
+ if (typeof window === 'undefined') return null;
27
+ if (loading || error || !data) return null;
28
+ const propsToDisplayArr = buildPropsToDisplayArray(propsToDisplay);
29
+ const extraProps = buildPropsQuery(data, propsToDisplayArr) || '';
30
+ const {
31
+ action,
32
+ actionKey
33
+ } = getRenderProps(extraProps, isPreview, data);
34
+ return /*#__PURE__*/React.createElement(GTMRender, {
35
+ action: action,
36
+ actionKey: actionKey,
37
+ userPropsToDisplay: userPropsToDisplay,
38
+ propsToDisplay: propsToDisplay,
39
+ parentId: parent.itemId,
40
+ webVitals: gtmWebVitals
41
+ });
42
+ };
43
+ GTMFactory.propTypes = {
44
+ propsToDisplay: PropTypes.array,
45
+ userPropsToDisplay: PropTypes.array,
46
+ parent: PropTypes.object.isRequired,
47
+ gtmWebVitals: PropTypes.bool
48
+ };
49
+ GTMFactory.defaultProps = {
50
+ propsToDisplay: [],
51
+ userPropsToDisplay: [],
52
+ gtmWebVitals: false
53
+ };
54
+ export default GTMFactory;
55
+ //# sourceMappingURL=GTMFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMFactory.js","names":["React","useContext","PropTypes","useQuery","getSingleEntitySchema","buildPropsQuery","MainContext","GTMRender","getRenderProps","buildPropsToDisplayArray","GTMFactory","propsToDisplay","userPropsToDisplay","parent","gtmWebVitals","isPreview","data","error","loading","variables","id","itemEntity","window","propsToDisplayArr","extraProps","action","actionKey","createElement","parentId","itemId","webVitals","propTypes","array","object","isRequired","bool","defaultProps"],"sources":["../../src/GoogleTagManager/GTMFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { getSingleEntitySchema, buildPropsQuery } from '@blaze-cms/react-page-builder';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport GTMRender from './GTMRender';\nimport { getRenderProps, buildPropsToDisplayArray } from '../helpers';\n\nconst GTMFactory = ({ propsToDisplay, userPropsToDisplay, parent, gtmWebVitals }) => {\n const { isPreview } = useContext(MainContext);\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: parent.itemEntity }\n });\n\n if (typeof window === 'undefined') return null;\n if (loading || error || !data) return null;\n\n const propsToDisplayArr = buildPropsToDisplayArray(propsToDisplay);\n const extraProps = buildPropsQuery(data, propsToDisplayArr) || '';\n const { action, actionKey } = getRenderProps(extraProps, isPreview, data);\n\n return (\n <GTMRender\n action={action}\n actionKey={actionKey}\n userPropsToDisplay={userPropsToDisplay}\n propsToDisplay={propsToDisplay}\n parentId={parent.itemId}\n webVitals={gtmWebVitals}\n />\n );\n};\n\nGTMFactory.propTypes = {\n propsToDisplay: PropTypes.array,\n userPropsToDisplay: PropTypes.array,\n parent: PropTypes.object.isRequired,\n gtmWebVitals: PropTypes.bool\n};\n\nGTMFactory.defaultProps = {\n propsToDisplay: [],\n userPropsToDisplay: [],\n gtmWebVitals: false\n};\n\nexport default GTMFactory;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,gBAAgB;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AK;EACnCnB,MAAM,EAAEX,SAAS,CAAC+B,MAAM,CAACC,UAAU;EACnCpB,YAAY,EAAEZ,SAAS,CAACiC;AAC1B,CAAC;AAEDzB,UAAU,CAAC0B,YAAY,GAAG;EACxBzB,cAAc,EAAE,EAAE;EAClBC,kBAAkB,EAAE,EAAE;EACtBE,YAAY,EAAE;AAChB,CAAC;AAED,eAAeJ,UAAU","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { useState } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { useQuery } from '@apollo/client';
7
+ import { withRouter } from 'next/router';
8
+ import { getCurrentUser } from '@blaze-cms/react-page-builder';
9
+ import { buildDataLayer, buildAndPushWebVitals, pushToDataLayer, buildUserQueryProps, buildUserLayer } from '../helpers';
10
+ const GTMRender = ({
11
+ router,
12
+ action,
13
+ propsToDisplay,
14
+ parentId,
15
+ webVitals,
16
+ userPropsToDisplay
17
+ }) => {
18
+ const {
19
+ asPath
20
+ } = router;
21
+ const [currentLocation, setCurrentLocation] = useState({
22
+ url: '',
23
+ shouldPushLayer: false
24
+ });
25
+ const {
26
+ data,
27
+ error,
28
+ loading
29
+ } = useQuery(action, {
30
+ variables: {
31
+ id: parentId
32
+ }
33
+ });
34
+ const hasUserProps = userPropsToDisplay && userPropsToDisplay.length;
35
+ const userProps = hasUserProps ? buildUserQueryProps(userPropsToDisplay) : '';
36
+ const {
37
+ data: userData,
38
+ loading: userLoading
39
+ } = useQuery(getCurrentUser(userProps), {
40
+ variables: {},
41
+ skip: !hasUserProps
42
+ });
43
+ if (loading || userLoading || !data || !data.entityData) return null;
44
+ if (data.entityData.id !== parentId) return null;
45
+ if (error) return error.message;
46
+ if (currentLocation.url !== asPath) setCurrentLocation({
47
+ url: asPath,
48
+ shouldPushLayer: true
49
+ });
50
+ if (!currentLocation.shouldPushLayer) return null;
51
+ const {
52
+ entityData
53
+ } = data;
54
+ const dataLayerObject = buildDataLayer(entityData, propsToDisplay, currentLocation.url);
55
+ const userLayerObject = buildUserLayer(userData, userPropsToDisplay);
56
+ const extendedDataLayer = _objectSpread(_objectSpread({}, dataLayerObject), userLayerObject);
57
+ if (webVitals) buildAndPushWebVitals();
58
+ pushToDataLayer(extendedDataLayer, true);
59
+ setCurrentLocation(_objectSpread(_objectSpread({}, currentLocation), {}, {
60
+ shouldPushLayer: false
61
+ }));
62
+ return null;
63
+ };
64
+ GTMRender.propTypes = {
65
+ userPropsToDisplay: PropTypes.array.isRequired,
66
+ action: PropTypes.object.isRequired,
67
+ propsToDisplay: PropTypes.array.isRequired,
68
+ parentId: PropTypes.string.isRequired,
69
+ webVitals: PropTypes.bool.isRequired
70
+ };
71
+ export default withRouter(GTMRender);
72
+ //# sourceMappingURL=GTMRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMRender.js","names":["useState","PropTypes","useQuery","withRouter","getCurrentUser","buildDataLayer","buildAndPushWebVitals","pushToDataLayer","buildUserQueryProps","buildUserLayer","GTMRender","router","action","propsToDisplay","parentId","webVitals","userPropsToDisplay","asPath","currentLocation","setCurrentLocation","url","shouldPushLayer","data","error","loading","variables","id","hasUserProps","length","userProps","userData","userLoading","skip","entityData","message","dataLayerObject","userLayerObject","extendedDataLayer","_objectSpread","propTypes","array","isRequired","object","string","bool"],"sources":["../../src/GoogleTagManager/GTMRender.js"],"sourcesContent":["import { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { withRouter } from 'next/router';\nimport { getCurrentUser } from '@blaze-cms/react-page-builder';\nimport {\n buildDataLayer,\n buildAndPushWebVitals,\n pushToDataLayer,\n buildUserQueryProps,\n buildUserLayer\n} from '../helpers';\n\nconst GTMRender = ({ router, action, propsToDisplay, parentId, webVitals, userPropsToDisplay }) => {\n const { asPath } = router;\n const [currentLocation, setCurrentLocation] = useState({ url: '', shouldPushLayer: false });\n\n const { data, error, loading } = useQuery(action, {\n variables: { id: parentId }\n });\n const hasUserProps = userPropsToDisplay && userPropsToDisplay.length;\n const userProps = hasUserProps ? buildUserQueryProps(userPropsToDisplay) : '';\n const { data: userData, loading: userLoading } = useQuery(getCurrentUser(userProps), {\n variables: {},\n skip: !hasUserProps\n });\n\n if (loading || userLoading || !data || !data.entityData) return null;\n if (data.entityData.id !== parentId) return null;\n if (error) return error.message;\n if (currentLocation.url !== asPath) setCurrentLocation({ url: asPath, shouldPushLayer: true });\n if (!currentLocation.shouldPushLayer) return null;\n\n const { entityData } = data;\n const dataLayerObject = buildDataLayer(entityData, propsToDisplay, currentLocation.url);\n const userLayerObject = buildUserLayer(userData, userPropsToDisplay);\n const extendedDataLayer = { ...dataLayerObject, ...userLayerObject };\n\n if (webVitals) buildAndPushWebVitals();\n pushToDataLayer(extendedDataLayer, true);\n setCurrentLocation({ ...currentLocation, shouldPushLayer: false });\n\n return null;\n};\n\nGTMRender.propTypes = {\n userPropsToDisplay: PropTypes.array.isRequired,\n action: PropTypes.object.isRequired,\n propsToDisplay: PropTypes.array.isRequired,\n parentId: PropTypes.string.isRequired,\n webVitals: PropTypes.bool.isRequired\n};\n\nexport default withRouter(GTMRender);\n"],"mappings":";;;AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ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AKH,MAAM,EAAEE,kBAAkB,CAAC;IAAEC,GAAG,EAAEH,MAAM;IAAEI,eAAe,EAAE;EAAK,CAAC,CAAC;EAC9F,IAAI,CAACH,eAAe,CAACG,eAAe,EAAE,OAAO,IAAI;EAEjD,MAAM;IAAEY;EAAW,CAAC,GAAGX,IAAI;EAC3B,MAAMa,eAAe,GAAG9B,cAAc,CAAC4B,UAAU,EAAEpB,cAAc,EAAEK,eAAe,CAACE,GAAG,CAAC;EACvF,MAAMgB,eAAe,GAAG3B,cAAc,CAACqB,QAAQ,EAAEd,kBAAkB,CAAC;EACpE,MAAMqB,iBAAiB,GAAAC,aAAA,CAAAA,aAAA,KAAQH,eAAe,GAAKC,eAAe,CAAE;EAEpE,IAAIrB,SAAS,EAAET,qBAAqB,CAAC,CAAC;EACtCC,eAAe,CAAC8B,iBAAiB,EAAE,IAAI,CAAC;EACxClB,kBAAkB,CAAAmB,aAAA,CAAAA,aAAA,KAAMpB,eAAe;IAAEG,eAAe,EAAE;EAAK,EAAE,CAAC;EAElE,OAAO,IAAI;AACb,CAAC;AAEDX,SAAS,CAAC6B,SAAS,GAAG;EACpBvB,kBAAkB,EAAEf,SAAS,CAACuC,KAAK,CAACC,UAAU;EAC9C7B,MAAM,EAAEX,SAAS,CAACyC,MAAM,CAACD,UAAU;EACnC5B,cAAc,EAAEZ,SAAS,CAACuC,KAAK,CAACC,UAAU;EAC1C3B,QAAQ,EAAEb,SAAS,CAAC0C,MAAM,CAACF,UAAU;EACrC1B,SAAS,EAAEd,SAAS,CAAC2C,IAAI,CAACH;AAC5B,CAAC;AAED,eAAetC,UAAU,CAACO,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import GTMFactory from './GTMFactory';
2
+ export default GTMFactory;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["GTMFactory"],"sources":["../../src/GoogleTagManager/index.js"],"sourcesContent":["import GTMFactory from './GTMFactory';\n\nexport default GTMFactory;\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,cAAc;AAErC,eAAeA,UAAU","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { useQuery } from '@apollo/client';
7
+ import { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';
8
+ import { getCurrentUser } from '@blaze-cms/react-page-builder';
9
+ import GTMEvent from './GTMEvent';
10
+ import { buildDataLayer, buildNestedEvent, buildUserQueryProps, buildUserLayer } from '../helpers';
11
+ const GTMClickEvent = ({
12
+ event,
13
+ componentProps,
14
+ parentComponent
15
+ }) => {
16
+ const {
17
+ eventTrigger,
18
+ propsToDisplay,
19
+ userPropsToDisplay,
20
+ eventEcommerce
21
+ } = event;
22
+ const {
23
+ id: userId
24
+ } = checkIfLoggedIn();
25
+ const userProps = userId ? buildUserQueryProps(userPropsToDisplay) : '';
26
+ const {
27
+ data: userData,
28
+ loading
29
+ } = useQuery(getCurrentUser(userProps), {
30
+ variables: {
31
+ id: userId
32
+ },
33
+ skip: !userId
34
+ });
35
+ if (loading) return null;
36
+ const dataLayerProps = buildDataLayer(componentProps, propsToDisplay);
37
+ const dataLayerObject = buildNestedEvent(eventEcommerce, event, dataLayerProps, parentComponent);
38
+ const userLayerObject = buildUserLayer(userData, userPropsToDisplay);
39
+ const extendedDataLayer = _objectSpread(_objectSpread({}, dataLayerObject), userLayerObject);
40
+ return /*#__PURE__*/React.createElement(GTMEvent, {
41
+ dataLayerObject: extendedDataLayer,
42
+ eventTrigger: eventTrigger
43
+ });
44
+ };
45
+ GTMClickEvent.propTypes = {
46
+ event: PropTypes.object.isRequired,
47
+ componentProps: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
48
+ parentComponent: PropTypes.object
49
+ };
50
+ GTMClickEvent.defaultProps = {
51
+ componentProps: {},
52
+ parentComponent: {}
53
+ };
54
+ export default GTMClickEvent;
55
+ //# sourceMappingURL=GTMClickEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMClickEvent.js","names":["React","PropTypes","useQuery","checkIfLoggedIn","getCurrentUser","GTMEvent","buildDataLayer","buildNestedEvent","buildUserQueryProps","buildUserLayer","GTMClickEvent","event","componentProps","parentComponent","eventTrigger","propsToDisplay","userPropsToDisplay","eventEcommerce","id","userId","userProps","data","userData","loading","variables","skip","dataLayerProps","dataLayerObject","userLayerObject","extendedDataLayer","_objectSpread","createElement","propTypes","object","isRequired","oneOfType","array","defaultProps"],"sources":["../../src/GoogleTagManagerEvent/GTMClickEvent.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { checkIfLoggedIn } from '@blaze-cms/core-auth-ui';\nimport { getCurrentUser } from '@blaze-cms/react-page-builder';\n\nimport GTMEvent from './GTMEvent';\nimport { buildDataLayer, buildNestedEvent, buildUserQueryProps, buildUserLayer } from '../helpers';\n\nconst GTMClickEvent = ({ event, componentProps, parentComponent }) => {\n const { eventTrigger, propsToDisplay, userPropsToDisplay, eventEcommerce } = event;\n const { id: userId } = checkIfLoggedIn();\n const userProps = userId ? buildUserQueryProps(userPropsToDisplay) : '';\n const { data: userData, loading } = useQuery(getCurrentUser(userProps), {\n variables: { id: userId },\n skip: !userId\n });\n if (loading) return null;\n const dataLayerProps = buildDataLayer(componentProps, propsToDisplay);\n const dataLayerObject = buildNestedEvent(eventEcommerce, event, dataLayerProps, parentComponent);\n const userLayerObject = buildUserLayer(userData, userPropsToDisplay);\n\n const extendedDataLayer = { ...dataLayerObject, ...userLayerObject };\n\n return <GTMEvent dataLayerObject={extendedDataLayer} eventTrigger={eventTrigger} />;\n};\n\nGTMClickEvent.propTypes = {\n event: PropTypes.object.isRequired,\n componentProps: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\n parentComponent: PropTypes.object\n};\n\nGTMClickEvent.defaultProps = {\n componentProps: {},\n parentComponent: {}\n};\n\nexport default GTMClickEvent;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,cAAc,QAAQ,+BAA+B;AAE9D,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,QAAQ,YAAY;AAElG,MAAMC,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC,cAAc;EAAEC;AAAgB,CAAC,KAAK;EACpE,MAAM;IAAEC,YAAY;IAAEC,cAAc;IAAEC,kBAAkB;IAAEC;EAAe,CAAC,GAAGN,KAAK;EAClF,MAAM;IAAEO,EAAE,EAAEC;EAAO,CAAC,GAAGhB,eAAe,CAAC,CAAC;EACxC,MAAMiB,SAAS,GAAGD,MAAM,GAAGX,mBAAmB,CAACQ,kBAAkB,CAAC,GAAG,EAAE;EACvE,MAAM;IAAEK,IAAI,EAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGrB,QAAQ,CAACE,cAAc,CAACgB,SAAS,CAAC,EAAE;IACtEI,SAAS,EAAE;MAAEN,EAAE,EAAEC;IAAO,CAAC;IACzBM,IAAI,EAAE,CAACN;EACT,CAAC,CAAC;EACF,IAAII,OAAO,EAAE,OAAO,IAAI;EACxB,MAAMG,cAAc,GAAGpB,cAAc,CAACM,cAAc,EAAEG,cAAc,CAAC;EACrE,MAAMY,eAAe,GAAGpB,gBAAgB,CAACU,cAAc,EAAEN,KAAK,EAAEe,cAAc,EAAEb,eAAe,CAAC;EAChG,MAAMe,eAAe,GAAGnB,cAAc,CAACa,QAAQ,EAAEN,kBAAkB,CAAC;EAEpE,MAAMa,iBAAiB,GAAAC,aAAA,CAAAA,aAAA,KAAQH,eAAe,GAAKC,eAAe,CAAE;EAEpE,oBAAO5B,KAAA,CAAA+B,aAAA,CAAC1B,QAAQ;IAACsB,eAAe,EAAEE,iBAAkB;IAACf,YAAY,EAAEA;EAAa,CAAE,CAAC;AACrF,CAAC;AAEDJ,aAAa,CAACsB,SAAS,GAAG;EACxBrB,KAAK,EAAEV,SAAS,CAACgC,MAAM,CAACC,UAAU;EAClCtB,cAAc,EAAEX,SAAS,CAACkC,SAAS,CAAC,CAAClC,SAAS,CAACgC,MAAM,EAAEhC,SAAS,CAACmC,KAAK,CAAC,CAAC;EACxEvB,eAAe,EAAEZ,SAAS,CAACgC;AAC7B,CAAC;AAEDvB,aAAa,CAAC2B,YAAY,GAAG;EAC3BzB,cAAc,EAAE,CAAC,CAAC;EAClBC,eAAe,EAAE,CAAC;AACpB,CAAC;AAED,eAAeH,aAAa","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import GTMClickEvent from './GTMClickEvent';
5
+ const GTMClickEvents = ({
6
+ gtmEvents,
7
+ componentProps,
8
+ parentComponent
9
+ }) => gtmEvents.map((event, index) => {
10
+ const {
11
+ eventName
12
+ } = event;
13
+ const dynamicKey = [eventName, index].join('-');
14
+ return /*#__PURE__*/React.createElement(GTMClickEvent, _extends({
15
+ key: dynamicKey,
16
+ event: event,
17
+ componentProps: componentProps,
18
+ parentComponent: parentComponent
19
+ }, event));
20
+ });
21
+ GTMClickEvents.propTypes = {
22
+ gtmEvents: PropTypes.array,
23
+ componentProps: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
24
+ parentComponent: PropTypes.object
25
+ };
26
+ GTMClickEvents.defaultProps = {
27
+ gtmEvents: [],
28
+ componentProps: {},
29
+ parentComponent: {}
30
+ };
31
+ export default GTMClickEvents;
32
+ //# sourceMappingURL=GTMClickEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMClickEvents.js","names":["React","PropTypes","GTMClickEvent","GTMClickEvents","gtmEvents","componentProps","parentComponent","map","event","index","eventName","dynamicKey","join","createElement","_extends","key","propTypes","array","oneOfType","object","defaultProps"],"sources":["../../src/GoogleTagManagerEvent/GTMClickEvents.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport GTMClickEvent from './GTMClickEvent';\n\nconst GTMClickEvents = ({ gtmEvents, componentProps, parentComponent }) =>\n gtmEvents.map((event, index) => {\n const { eventName } = event;\n const dynamicKey = [eventName, index].join('-');\n\n return (\n <GTMClickEvent\n key={dynamicKey}\n event={event}\n componentProps={componentProps}\n parentComponent={parentComponent}\n {...event}\n />\n );\n });\n\nGTMClickEvents.propTypes = {\n gtmEvents: PropTypes.array,\n componentProps: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\n parentComponent: PropTypes.object\n};\n\nGTMClickEvents.defaultProps = {\n gtmEvents: [],\n componentProps: {},\n parentComponent: {}\n};\n\nexport default GTMClickEvents;\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,aAAa,MAAM,iBAAiB;AAE3C,MAAMC,cAAc,GAAGA,CAAC;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAgB,CAAC,KACpEF,SAAS,CAACG,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAK;EAC9B,MAAM;IAAEC;EAAU,CAAC,GAAGF,KAAK;EAC3B,MAAMG,UAAU,GAAG,CAACD,SAAS,EAAED,KAAK,CAAC,CAACG,IAAI,CAAC,GAAG,CAAC;EAE/C,oBACEZ,KAAA,CAAAa,aAAA,CAACX,aAAa,EAAAY,QAAA;IACZC,GAAG,EAAEJ,UAAW;IAChBH,KAAK,EAAEA,KAAM;IACbH,cAAc,EAAEA,cAAe;IAC/BC,eAAe,EAAEA;EAAgB,GAC7BE,KAAK,CACV,CAAC;AAEN,CAAC,CAAC;AAEJL,cAAc,CAACa,SAAS,GAAG;EACzBZ,SAAS,EAAEH,SAAS,CAACgB,KAAK;EAC1BZ,cAAc,EAAEJ,SAAS,CAACiB,SAAS,CAAC,CAACjB,SAAS,CAACkB,MAAM,EAAElB,SAAS,CAACgB,KAAK,CAAC,CAAC;EACxEX,eAAe,EAAEL,SAAS,CAACkB;AAC7B,CAAC;AAEDhB,cAAc,CAACiB,YAAY,GAAG;EAC5BhB,SAAS,EAAE,EAAE;EACbC,cAAc,EAAE,CAAC,CAAC;EAClBC,eAAe,EAAE,CAAC;AACpB,CAAC;AAED,eAAeH,cAAc","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Waypoint } from 'react-waypoint';
4
+ import { pushToDataLayer } from '../helpers';
5
+ import { IN_VIEW, ON_SUCCESS } from '../constants';
6
+ const GTMEvent = ({
7
+ dataLayerObject,
8
+ eventTrigger,
9
+ currentLocation,
10
+ handleOnSuccess
11
+ }) => {
12
+ const [shouldPushLayer, setShouldPushLayer] = useState(false);
13
+ const isViewEvent = eventTrigger === IN_VIEW;
14
+ const isOnSuccess = eventTrigger === ON_SUCCESS && !!handleOnSuccess;
15
+ useEffect(() => {
16
+ setShouldPushLayer(true);
17
+ }, [currentLocation]);
18
+ const pushDataLayer = () => {
19
+ pushToDataLayer(dataLayerObject);
20
+ setShouldPushLayer(false);
21
+ if (isOnSuccess) handleOnSuccess();
22
+ };
23
+ if (!isViewEvent && shouldPushLayer) {
24
+ pushDataLayer();
25
+ return null;
26
+ }
27
+ return isViewEvent && shouldPushLayer ? /*#__PURE__*/React.createElement(Waypoint, {
28
+ onEnter: pushDataLayer
29
+ }) : null;
30
+ };
31
+ GTMEvent.propTypes = {
32
+ handleOnSuccess: PropTypes.func.isRequired,
33
+ dataLayerObject: PropTypes.object.isRequired,
34
+ eventTrigger: PropTypes.string.isRequired,
35
+ currentLocation: PropTypes.string.isRequired
36
+ };
37
+ export default GTMEvent;
38
+ //# sourceMappingURL=GTMEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMEvent.js","names":["React","useState","useEffect","PropTypes","Waypoint","pushToDataLayer","IN_VIEW","ON_SUCCESS","GTMEvent","dataLayerObject","eventTrigger","currentLocation","handleOnSuccess","shouldPushLayer","setShouldPushLayer","isViewEvent","isOnSuccess","pushDataLayer","createElement","onEnter","propTypes","func","isRequired","object","string"],"sources":["../../src/GoogleTagManagerEvent/GTMEvent.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { Waypoint } from 'react-waypoint';\nimport { pushToDataLayer } from '../helpers';\nimport { IN_VIEW, ON_SUCCESS } from '../constants';\n\nconst GTMEvent = ({ dataLayerObject, eventTrigger, currentLocation, handleOnSuccess }) => {\n const [shouldPushLayer, setShouldPushLayer] = useState(false);\n const isViewEvent = eventTrigger === IN_VIEW;\n const isOnSuccess = eventTrigger === ON_SUCCESS && !!handleOnSuccess;\n\n useEffect(() => {\n setShouldPushLayer(true);\n }, [currentLocation]);\n\n const pushDataLayer = () => {\n pushToDataLayer(dataLayerObject);\n setShouldPushLayer(false);\n if (isOnSuccess) handleOnSuccess();\n };\n\n if (!isViewEvent && shouldPushLayer) {\n pushDataLayer();\n return null;\n }\n\n return isViewEvent && shouldPushLayer ? <Waypoint onEnter={pushDataLayer} /> : null;\n};\n\nGTMEvent.propTypes = {\n handleOnSuccess: PropTypes.func.isRequired,\n dataLayerObject: PropTypes.object.isRequired,\n eventTrigger: PropTypes.string.isRequired,\n currentLocation: PropTypes.string.isRequired\n};\n\nexport default GTMEvent;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,eAAe,QAAQ,YAAY;AAC5C,SAASC,OAAO,EAAEC,UAAU,QAAQ,cAAc;AAElD,MAAMC,QAAQ,GAAGA,CAAC;EAAEC,eAAe;EAAEC,YAAY;EAAEC,eAAe;EAAEC;AAAgB,CAAC,KAAK;EACxF,MAAM,CAACC,eAAe,EAAEC,kBAAkB,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EAC7D,MAAMc,WAAW,GAAGL,YAAY,KAAKJ,OAAO;EAC5C,MAAMU,WAAW,GAAGN,YAAY,KAAKH,UAAU,IAAI,CAAC,CAACK,eAAe;EAEpEV,SAAS,CAAC,MAAM;IACdY,kBAAkB,CAAC,IAAI,CAAC;EAC1B,CAAC,EAAE,CAACH,eAAe,CAAC,CAAC;EAErB,MAAMM,aAAa,GAAGA,CAAA,KAAM;IAC1BZ,eAAe,CAACI,eAAe,CAAC;IAChCK,kBAAkB,CAAC,KAAK,CAAC;IACzB,IAAIE,WAAW,EAAEJ,eAAe,CAAC,CAAC;EACpC,CAAC;EAED,IAAI,CAACG,WAAW,IAAIF,eAAe,EAAE;IACnCI,aAAa,CAAC,CAAC;IACf,OAAO,IAAI;EACb;EAEA,OAAOF,WAAW,IAAIF,eAAe,gBAAGb,KAAA,CAAAkB,aAAA,CAACd,QAAQ;IAACe,OAAO,EAAEF;EAAc,CAAE,CAAC,GAAG,IAAI;AACrF,CAAC;AAEDT,QAAQ,CAACY,SAAS,GAAG;EACnBR,eAAe,EAAET,SAAS,CAACkB,IAAI,CAACC,UAAU;EAC1Cb,eAAe,EAAEN,SAAS,CAACoB,MAAM,CAACD,UAAU;EAC5CZ,YAAY,EAAEP,SAAS,CAACqB,MAAM,CAACF,UAAU;EACzCX,eAAe,EAAER,SAAS,CAACqB,MAAM,CAACF;AACpC,CAAC;AAED,eAAed,QAAQ","ignoreList":[]}
@@ -0,0 +1,92 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["propsToDisplay"];
4
+ import React, { useContext } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { useQuery } from '@apollo/client';
7
+ import { getSingleEntitySchema, buildPropsQuery } from '@blaze-cms/react-page-builder';
8
+ import { MainContext } from '@blaze-cms/nextjs-components';
9
+ import GTMEventRender from './GTMEventRender';
10
+ import { getRenderProps, getIdsToUse, buildPropsToDisplayArray } from '../helpers';
11
+ import { GTM_EVENT_FACTORY } from '../constants';
12
+ const GTMEventFactory = ({
13
+ parent,
14
+ gtmEvents,
15
+ parentData,
16
+ clickId,
17
+ parentComponent
18
+ }) => {
19
+ const {
20
+ isPreview
21
+ } = useContext(MainContext);
22
+ const [{
23
+ itemEntity = parent.itemEntity
24
+ } = {}] = parentData || [];
25
+ const {
26
+ data,
27
+ error,
28
+ loading
29
+ } = useQuery(getSingleEntitySchema, {
30
+ variables: {
31
+ id: itemEntity
32
+ }
33
+ });
34
+ if (loading || error || !data) return null;
35
+ return gtmEvents.map((_ref, i) => {
36
+ let {
37
+ propsToDisplay
38
+ } = _ref,
39
+ eventProps = _objectWithoutProperties(_ref, _excluded);
40
+ const hasNoPropsToDisplay = !propsToDisplay || !propsToDisplay.length;
41
+ const propsToDisplayArr = buildPropsToDisplayArray(propsToDisplay);
42
+ const extraProps = hasNoPropsToDisplay ? '' : buildPropsQuery(data, propsToDisplayArr);
43
+ const shouldUseParentData = !clickId && parentData && parentData.length;
44
+ const itemIdToUse = clickId || parent.itemId;
45
+ const itemId = shouldUseParentData ? getIdsToUse(parentData) : itemIdToUse;
46
+ const shouldUseMultiQuery = Array.isArray(itemId);
47
+ const {
48
+ action,
49
+ actionKey
50
+ } = getRenderProps(extraProps, isPreview, data, shouldUseMultiQuery);
51
+ const dynamicKey = `${GTM_EVENT_FACTORY}${i}`;
52
+ const queryVariables = shouldUseMultiQuery ? {
53
+ variables: {
54
+ where: {
55
+ id: {
56
+ _in: itemId
57
+ }
58
+ }
59
+ },
60
+ skip: hasNoPropsToDisplay
61
+ } : {
62
+ variables: {
63
+ id: itemId
64
+ },
65
+ skip: hasNoPropsToDisplay
66
+ };
67
+ return /*#__PURE__*/React.createElement(GTMEventRender, _extends({
68
+ key: dynamicKey,
69
+ action: action,
70
+ actionKey: actionKey,
71
+ propsToDisplay: propsToDisplay,
72
+ id: itemId,
73
+ queryVariables: queryVariables,
74
+ parentComponent: parentComponent
75
+ }, eventProps));
76
+ });
77
+ };
78
+ GTMEventFactory.propTypes = {
79
+ parent: PropTypes.object.isRequired,
80
+ clickId: PropTypes.string,
81
+ gtmEvents: PropTypes.array,
82
+ parentData: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
83
+ parentComponent: PropTypes.object
84
+ };
85
+ GTMEventFactory.defaultProps = {
86
+ clickId: null,
87
+ gtmEvents: [],
88
+ parentData: null,
89
+ parentComponent: {}
90
+ };
91
+ export default GTMEventFactory;
92
+ //# sourceMappingURL=GTMEventFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMEventFactory.js","names":["React","useContext","PropTypes","useQuery","getSingleEntitySchema","buildPropsQuery","MainContext","GTMEventRender","getRenderProps","getIdsToUse","buildPropsToDisplayArray","GTM_EVENT_FACTORY","GTMEventFactory","parent","gtmEvents","parentData","clickId","parentComponent","isPreview","itemEntity","data","error","loading","variables","id","map","_ref","i","propsToDisplay","eventProps","_objectWithoutProperties","_excluded","hasNoPropsToDisplay","length","propsToDisplayArr","extraProps","shouldUseParentData","itemIdToUse","itemId","shouldUseMultiQuery","Array","isArray","action","actionKey","dynamicKey","queryVariables","where","_in","skip","createElement","_extends","key","propTypes","object","isRequired","string","array","oneOfType","defaultProps"],"sources":["../../src/GoogleTagManagerEvent/GTMEventFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { getSingleEntitySchema, buildPropsQuery } from '@blaze-cms/react-page-builder';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport GTMEventRender from './GTMEventRender';\nimport { getRenderProps, getIdsToUse, buildPropsToDisplayArray } from '../helpers';\nimport { GTM_EVENT_FACTORY } from '../constants';\n\nconst GTMEventFactory = ({ parent, gtmEvents, parentData, clickId, parentComponent }) => {\n const { isPreview } = useContext(MainContext);\n const [{ itemEntity = parent.itemEntity } = {}] = parentData || [];\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: itemEntity }\n });\n\n if (loading || error || !data) return null;\n\n return gtmEvents.map(({ propsToDisplay, ...eventProps }, i) => {\n const hasNoPropsToDisplay = !propsToDisplay || !propsToDisplay.length;\n const propsToDisplayArr = buildPropsToDisplayArray(propsToDisplay);\n const extraProps = hasNoPropsToDisplay ? '' : buildPropsQuery(data, propsToDisplayArr);\n const shouldUseParentData = !clickId && parentData && parentData.length;\n const itemIdToUse = clickId || parent.itemId;\n const itemId = shouldUseParentData ? getIdsToUse(parentData) : itemIdToUse;\n const shouldUseMultiQuery = Array.isArray(itemId);\n const { action, actionKey } = getRenderProps(extraProps, isPreview, data, shouldUseMultiQuery);\n const dynamicKey = `${GTM_EVENT_FACTORY}${i}`;\n const queryVariables = shouldUseMultiQuery\n ? {\n variables: { where: { id: { _in: itemId } } },\n skip: hasNoPropsToDisplay\n }\n : {\n variables: { id: itemId },\n skip: hasNoPropsToDisplay\n };\n\n return (\n <GTMEventRender\n key={dynamicKey}\n action={action}\n actionKey={actionKey}\n propsToDisplay={propsToDisplay}\n id={itemId}\n queryVariables={queryVariables}\n parentComponent={parentComponent}\n {...eventProps}\n />\n );\n });\n};\n\nGTMEventFactory.propTypes = {\n parent: PropTypes.object.isRequired,\n clickId: PropTypes.string,\n gtmEvents: PropTypes.array,\n parentData: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\n parentComponent: PropTypes.object\n};\n\nGTMEventFactory.defaultProps = {\n clickId: null,\n gtmEvents: [],\n parentData: null,\n parentComponent: {}\n};\n\nexport default GTMEventFactory;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,qBAAqB,EAAEC,eAAe,QAAQ,+BAA+B;AACtF,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,SAASC,cAAc,EAAEC,WAAW,EAAEC,wBAAwB,QAAQ,YAAY;AAClF,SAASC,iBAAiB,QAAQ,cAAc;AAEhD,MAAMC,eAAe,GAAGA,CAAC;EAAEC,MAAM;EAAEC,SAAS;EAAEC,UAAU;EAAEC,OAAO;EAAEC;AAAgB,CAAC,KAAK;EACvF,MAAM;IAAEC;EAAU,CAAC,GAAGjB,UAAU,CAACK,WAAW,CAAC;EAC7C,MAAM,CAAC;IAAEa,UAAU,GAAGN,MAAM,CAACM;EAAW,CAAC,GAAG,CAAC,CAAC,CAAC,GAAGJ,UAAU,IAAI,EAAE;EAClE,MAAM;IAAEK,IAAI;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGnB,QAAQ,CAACC,qBAAqB,EAAE;IAC/DmB,SAAS,EAAE;MAAEC,EAAE,EAAEL;IAAW;EAC9B,CAAC,CAAC;EAEF,IAAIG,OAAO,IAAID,KAAK,IAAI,CAACD,IAAI,EAAE,OAAO,IAAI;EAE1C,OAAON,SAAS,CAACW,GAAG,CAAC,CAAAC,IAAA,EAAoCC,CAAC,KAAK;IAAA,IAAzC;QAAEC;MAA8B,CAAC,GAAAF,IAAA;MAAZG,UAAU,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK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,UAAU,CACf,CAAC;EAEN,CAAC,CAAC;AACJ,CAAC;AAEDjB,eAAe,CAACwC,SAAS,GAAG;EAC1BvC,MAAM,EAAEX,SAAS,CAACmD,MAAM,CAACC,UAAU;EACnCtC,OAAO,EAAEd,SAAS,CAACqD,MAAM;EACzBzC,SAAS,EAAEZ,SAAS,CAACsD,KAAK;EAC1BzC,UAAU,EAAEb,SAAS,CAACuD,SAAS,CAAC,CAACvD,SAAS,CAACmD,MAAM,EAAEnD,SAAS,CAACsD,KAAK,CAAC,CAAC;EACpEvC,eAAe,EAAEf,SAAS,CAACmD;AAC7B,CAAC;AAEDzC,eAAe,CAAC8C,YAAY,GAAG;EAC7B1C,OAAO,EAAE,IAAI;EACbF,SAAS,EAAE,EAAE;EACbC,UAAU,EAAE,IAAI;EAChBE,eAAe,EAAE,CAAC;AACpB,CAAC;AAED,eAAeL,eAAe","ignoreList":[]}
@@ -0,0 +1,81 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["router", "action", "actionKey", "queryVariables", "parentComponent", "userPropsToDisplay", "handleOnSuccess"];
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import React, { useState } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { useQuery } from '@apollo/client';
9
+ import { getCurrentUser } from '@blaze-cms/react-page-builder';
10
+ import { withRouter } from 'next/router';
11
+ import GTMEvent from './GTMEvent';
12
+ import { buildDataLayer, buildNestedEvent, buildUserQueryProps, buildUserLayer } from '../helpers';
13
+ const GTMEventRender = _ref => {
14
+ let {
15
+ router,
16
+ action,
17
+ actionKey,
18
+ queryVariables,
19
+ parentComponent,
20
+ userPropsToDisplay,
21
+ handleOnSuccess
22
+ } = _ref,
23
+ eventProps = _objectWithoutProperties(_ref, _excluded);
24
+ const {
25
+ asPath
26
+ } = router;
27
+ const [currentLocation, setCurrentLocation] = useState('');
28
+ const {
29
+ data = {},
30
+ error,
31
+ loading
32
+ } = useQuery(action, queryVariables);
33
+ const hasUserProps = userPropsToDisplay && userPropsToDisplay.length;
34
+ const userProps = hasUserProps ? buildUserQueryProps(userPropsToDisplay) : '';
35
+ const {
36
+ data: userData,
37
+ loading: userLoading
38
+ } = useQuery(getCurrentUser(userProps), {
39
+ variables: {},
40
+ skip: !hasUserProps
41
+ });
42
+ if (loading || userLoading || error) return null;
43
+ const gtmData = data.entityData || data[actionKey];
44
+ if (currentLocation !== asPath) {
45
+ setCurrentLocation(asPath);
46
+ return null;
47
+ }
48
+ const {
49
+ eventTrigger,
50
+ propsToDisplay,
51
+ eventEcommerce
52
+ } = eventProps;
53
+ const dataLayerProps = buildDataLayer(gtmData, propsToDisplay);
54
+ const dataLayerObject = buildNestedEvent(eventEcommerce, eventProps, dataLayerProps, parentComponent);
55
+ const userLayerObject = buildUserLayer(userData, userPropsToDisplay);
56
+ const extendedDataLayer = _objectSpread(_objectSpread({}, dataLayerObject), userLayerObject);
57
+ return /*#__PURE__*/React.createElement(GTMEvent, {
58
+ dataLayerObject: extendedDataLayer,
59
+ eventTrigger: eventTrigger,
60
+ currentLocation: currentLocation,
61
+ handleOnSuccess: handleOnSuccess
62
+ });
63
+ };
64
+ GTMEventRender.propTypes = {
65
+ userPropsToDisplay: PropTypes.array,
66
+ router: PropTypes.object.isRequired,
67
+ action: PropTypes.object.isRequired,
68
+ actionKey: PropTypes.string.isRequired,
69
+ queryVariables: PropTypes.object.isRequired,
70
+ parentComponent: PropTypes.object.isRequired,
71
+ handleOnSuccess: PropTypes.func
72
+ };
73
+ GTMEventRender.defaultProps = {
74
+ userPropsToDisplay: [],
75
+ handleOnSuccess: () => {}
76
+ };
77
+ GTMEventRender.defaultProps = {
78
+ userPropsToDisplay: []
79
+ };
80
+ export default withRouter(GTMEventRender);
81
+ //# sourceMappingURL=GTMEventRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMEventRender.js","names":["React","useState","PropTypes","useQuery","getCurrentUser","withRouter","GTMEvent","buildDataLayer","buildNestedEvent","buildUserQueryProps","buildUserLayer","GTMEventRender","_ref","router","action","actionKey","queryVariables","parentComponent","userPropsToDisplay","handleOnSuccess","eventProps","_objectWithoutProperties","_excluded","asPath","currentLocation","setCurrentLocation","data","error","loading","hasUserProps","length","userProps","userData","userLoading","variables","skip","gtmData","entityData","eventTrigger","propsToDisplay","eventEcommerce","dataLayerProps","dataLayerObject","userLayerObject","extendedDataLayer","_objectSpread","createElement","propTypes","array","object","isRequired","string","func","defaultProps"],"sources":["../../src/GoogleTagManagerEvent/GTMEventRender.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery } from '@apollo/client';\nimport { getCurrentUser } from '@blaze-cms/react-page-builder';\nimport { withRouter } from 'next/router';\nimport GTMEvent from './GTMEvent';\nimport { buildDataLayer, buildNestedEvent, buildUserQueryProps, buildUserLayer } from '../helpers';\n\nconst GTMEventRender = ({\n router,\n action,\n actionKey,\n queryVariables,\n parentComponent,\n userPropsToDisplay,\n handleOnSuccess,\n ...eventProps\n}) => {\n const { asPath } = router;\n const [currentLocation, setCurrentLocation] = useState('');\n const { data = {}, error, loading } = useQuery(action, queryVariables);\n const hasUserProps = userPropsToDisplay && userPropsToDisplay.length;\n const userProps = hasUserProps ? buildUserQueryProps(userPropsToDisplay) : '';\n const { data: userData, loading: userLoading } = useQuery(getCurrentUser(userProps), {\n variables: {},\n skip: !hasUserProps\n });\n\n if (loading || userLoading || error) return null;\n const gtmData = data.entityData || data[actionKey];\n\n if (currentLocation !== asPath) {\n setCurrentLocation(asPath);\n return null;\n }\n\n const { eventTrigger, propsToDisplay, eventEcommerce } = eventProps;\n const dataLayerProps = buildDataLayer(gtmData, propsToDisplay);\n\n const dataLayerObject = buildNestedEvent(\n eventEcommerce,\n eventProps,\n dataLayerProps,\n parentComponent\n );\n const userLayerObject = buildUserLayer(userData, userPropsToDisplay);\n const extendedDataLayer = { ...dataLayerObject, ...userLayerObject };\n\n return (\n <GTMEvent\n dataLayerObject={extendedDataLayer}\n eventTrigger={eventTrigger}\n currentLocation={currentLocation}\n handleOnSuccess={handleOnSuccess}\n />\n );\n};\n\nGTMEventRender.propTypes = {\n userPropsToDisplay: PropTypes.array,\n router: PropTypes.object.isRequired,\n action: PropTypes.object.isRequired,\n actionKey: PropTypes.string.isRequired,\n queryVariables: PropTypes.object.isRequired,\n parentComponent: PropTypes.object.isRequired,\n handleOnSuccess: PropTypes.func\n};\n\nGTMEventRender.defaultProps = {\n userPropsToDisplay: [],\n handleOnSuccess: () => {}\n};\n\nGTMEventRender.defaultProps = {\n userPropsToDisplay: []\n};\n\nexport default withRouter(GTMEventRender);\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,QAAQ,YAAY;AAElG,MAAMC,cAAc,GAAGC,IAAA,IASjB;EAAA,IATkB;MACtBC,MAAM;MACNC,MAAM;MACNC,SAAS;MACTC,cAAc;MACdC,eAAe;M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,CAAC;EACpE,MAAM0B,iBAAiB,GAAAC,aAAA,CAAAA,aAAA,KAAQH,eAAe,GAAKC,eAAe,CAAE;EAEpE,oBACE3C,KAAA,CAAA8C,aAAA,CAACxC,QAAQ;IACPoC,eAAe,EAAEE,iBAAkB;IACnCN,YAAY,EAAEA,YAAa;IAC3Bd,eAAe,EAAEA,eAAgB;IACjCL,eAAe,EAAEA;EAAgB,CAClC,CAAC;AAEN,CAAC;AAEDR,cAAc,CAACoC,SAAS,GAAG;EACzB7B,kBAAkB,EAAEhB,SAAS,CAAC8C,KAAK;EACnCnC,MAAM,EAAEX,SAAS,CAAC+C,MAAM,CAACC,UAAU;EACnCpC,MAAM,EAAEZ,SAAS,CAAC+C,MAAM,CAACC,UAAU;EACnCnC,SAAS,EAAEb,SAAS,CAACiD,MAAM,CAACD,UAAU;EACtClC,cAAc,EAAEd,SAAS,CAAC+C,MAAM,CAACC,UAAU;EAC3CjC,eAAe,EAAEf,SAAS,CAAC+C,MAAM,CAACC,UAAU;EAC5C/B,eAAe,EAAEjB,SAAS,CAACkD;AAC7B,CAAC;AAEDzC,cAAc,CAAC0C,YAAY,GAAG;EAC5BnC,kBAAkB,EAAE,EAAE;EACtBC,eAAe,EAAEA,CAAA,KAAM,CAAC;AAC1B,CAAC;AAEDR,cAAc,CAAC0C,YAAY,GAAG;EAC5BnC,kBAAkB,EAAE;AACtB,CAAC;AAED,eAAeb,UAAU,CAACM,cAAc,CAAC","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["gtmEvents", "clickState", "clickId"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import GTMClickEvents from './GTMClickEvents';
7
+ import GTMEventFactory from './GTMEventFactory';
8
+ import { filterGtmEvents } from '../helpers';
9
+ const GTMEventSwitch = _ref => {
10
+ let {
11
+ gtmEvents,
12
+ clickState,
13
+ clickId
14
+ } = _ref,
15
+ props = _objectWithoutProperties(_ref, _excluded);
16
+ if (typeof window === 'undefined' || !gtmEvents.length) return null;
17
+ const {
18
+ clickEvents,
19
+ regularEvents
20
+ } = filterGtmEvents(gtmEvents);
21
+ const GTMClickFactory = clickId ? GTMEventFactory : GTMClickEvents;
22
+ return clickState ? /*#__PURE__*/React.createElement(GTMClickFactory, _extends({
23
+ gtmEvents: clickEvents,
24
+ clickId: clickId
25
+ }, props)) : /*#__PURE__*/React.createElement(GTMEventFactory, _extends({
26
+ gtmEvents: regularEvents
27
+ }, props));
28
+ };
29
+ GTMEventSwitch.propTypes = {
30
+ clickId: PropTypes.string,
31
+ gtmEvents: PropTypes.array,
32
+ clickState: PropTypes.bool
33
+ };
34
+ GTMEventSwitch.defaultProps = {
35
+ clickId: null,
36
+ gtmEvents: [],
37
+ clickState: false
38
+ };
39
+ export default GTMEventSwitch;
40
+ //# sourceMappingURL=GTMEventSwitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GTMEventSwitch.js","names":["React","PropTypes","GTMClickEvents","GTMEventFactory","filterGtmEvents","GTMEventSwitch","_ref","gtmEvents","clickState","clickId","props","_objectWithoutProperties","_excluded","window","length","clickEvents","regularEvents","GTMClickFactory","createElement","_extends","propTypes","string","array","bool","defaultProps"],"sources":["../../src/GoogleTagManagerEvent/GTMEventSwitch.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport GTMClickEvents from './GTMClickEvents';\nimport GTMEventFactory from './GTMEventFactory';\nimport { filterGtmEvents } from '../helpers';\n\nconst GTMEventSwitch = ({ gtmEvents, clickState, clickId, ...props }) => {\n if (typeof window === 'undefined' || !gtmEvents.length) return null;\n const { clickEvents, regularEvents } = filterGtmEvents(gtmEvents);\n const GTMClickFactory = clickId ? GTMEventFactory : GTMClickEvents;\n\n return clickState ? (\n <GTMClickFactory gtmEvents={clickEvents} clickId={clickId} {...props} />\n ) : (\n <GTMEventFactory gtmEvents={regularEvents} {...props} />\n );\n};\n\nGTMEventSwitch.propTypes = {\n clickId: PropTypes.string,\n gtmEvents: PropTypes.array,\n clickState: PropTypes.bool\n};\n\nGTMEventSwitch.defaultProps = {\n clickId: null,\n gtmEvents: [],\n clickState: false\n};\n\nexport default GTMEventSwitch;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,SAASC,eAAe,QAAQ,YAAY;AAE5C,MAAMC,cAAc,GAAGC,IAAA,IAAkD;EAAA,IAAjD;MAAEC,SAAS;MAAEC,UAAU;MAAEC;IAAkB,CAAC,GAAAH,IAAA;IAAPI,KAAK,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAChE,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,CAACN,SAAS,CAACO,MAAM,EAAE,OAAO,IAAI;EACnE,MAAM;IAAEC,WAAW;IAAEC;EAAc,CAAC,GAAGZ,eAAe,CAACG,SAAS,CAAC;EACjE,MAAMU,eAAe,GAAGR,OAAO,GAAGN,eAAe,GAAGD,cAAc;EAElE,OAAOM,UAAU,gBACfR,KAAA,CAAAkB,aAAA,CAACD,eAAe,EAAAE,QAAA;IAACZ,SAAS,EAAEQ,WAAY;IAACN,OAAO,EAAEA;EAAQ,GAAKC,KAAK,CAAG,CAAC,gBAExEV,KAAA,CAAAkB,aAAA,CAACf,eAAe,EAAAgB,QAAA;IAACZ,SAAS,EAAES;EAAc,GAAKN,KAAK,CAAG,CACxD;AACH,CAAC;AAEDL,cAAc,CAACe,SAAS,GAAG;EACzBX,OAAO,EAAER,SAAS,CAACoB,MAAM;EACzBd,SAAS,EAAEN,SAAS,CAACqB,KAAK;EAC1Bd,UAAU,EAAEP,SAAS,CAACsB;AACxB,CAAC;AAEDlB,cAAc,CAACmB,YAAY,GAAG;EAC5Bf,OAAO,EAAE,IAAI;EACbF,SAAS,EAAE,EAAE;EACbC,UAAU,EAAE;AACd,CAAC;AAED,eAAeH,cAAc","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import GTMEventSwitch from './GTMEventSwitch';
2
+ export default GTMEventSwitch;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["GTMEventSwitch"],"sources":["../../src/GoogleTagManagerEvent/index.js"],"sourcesContent":["import GTMEventSwitch from './GTMEventSwitch';\n\nexport default GTMEventSwitch;\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAE7C,eAAeA,cAAc","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ const EVENT = 'event';
2
+ const ON_LOAD = 'onLoad';
3
+ const ON_CLICK = 'onClick';
4
+ const IN_VIEW = 'inView';
5
+ const ON_SUCCESS = 'onSuccess';
6
+ const PAGE_VIEW = 'pageView';
7
+ const ECOMMERCE = 'ecommerce';
8
+ const GTM_PROPS = [{
9
+ key: 'eventAction'
10
+ }, {
11
+ key: 'eventLabel'
12
+ }, {
13
+ key: 'eventCategory'
14
+ }, {
15
+ key: 'eventName',
16
+ label: 'event'
17
+ }];
18
+ const GTM_EVENT_NAMES = {
19
+ productImpresion: 'impressions',
20
+ productDetailImpression: 'detail',
21
+ productClick: 'click',
22
+ promotionClick: 'promotionClick'
23
+ };
24
+ const GTM_EVENT_FACTORY = 'GtmEventFactory';
25
+ const PLUGIN_NAME = 'gtm-fe';
26
+ const PRODUCTS = 'products';
27
+ export { PLUGIN_NAME, EVENT, ECOMMERCE, GTM_PROPS, GTM_EVENT_NAMES, GTM_EVENT_FACTORY, ON_CLICK, IN_VIEW, ON_SUCCESS, ON_LOAD, PRODUCTS, PAGE_VIEW };
28
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["EVENT","ON_LOAD","ON_CLICK","IN_VIEW","ON_SUCCESS","PAGE_VIEW","ECOMMERCE","GTM_PROPS","key","label","GTM_EVENT_NAMES","productImpresion","productDetailImpression","productClick","promotionClick","GTM_EVENT_FACTORY","PLUGIN_NAME","PRODUCTS"],"sources":["../src/constants.js"],"sourcesContent":["const EVENT = 'event';\nconst ON_LOAD = 'onLoad';\nconst ON_CLICK = 'onClick';\nconst IN_VIEW = 'inView';\nconst ON_SUCCESS = 'onSuccess';\nconst PAGE_VIEW = 'pageView';\nconst ECOMMERCE = 'ecommerce';\nconst GTM_PROPS = [\n { key: 'eventAction' },\n { key: 'eventLabel' },\n { key: 'eventCategory' },\n { key: 'eventName', label: 'event' }\n];\nconst GTM_EVENT_NAMES = {\n productImpresion: 'impressions',\n productDetailImpression: 'detail',\n productClick: 'click',\n promotionClick: 'promotionClick'\n};\n\nconst GTM_EVENT_FACTORY = 'GtmEventFactory';\nconst PLUGIN_NAME = 'gtm-fe';\nconst PRODUCTS = 'products';\n\nexport {\n PLUGIN_NAME,\n EVENT,\n ECOMMERCE,\n GTM_PROPS,\n GTM_EVENT_NAMES,\n GTM_EVENT_FACTORY,\n ON_CLICK,\n IN_VIEW,\n ON_SUCCESS,\n ON_LOAD,\n PRODUCTS,\n PAGE_VIEW\n};\n"],"mappings":"AAAA,MAAMA,KAAK,GAAG,OAAO;AACrB,MAAMC,OAAO,GAAG,QAAQ;AACxB,MAAMC,QAAQ,GAAG,SAAS;AAC1B,MAAMC,OAAO,GAAG,QAAQ;AACxB,MAAMC,UAAU,GAAG,WAAW;AAC9B,MAAMC,SAAS,GAAG,UAAU;AAC5B,MAAMC,SAAS,GAAG,WAAW;AAC7B,MAAMC,SAAS,GAAG,CAChB;EAAEC,GAAG,EAAE;AAAc,CAAC,EACtB;EAAEA,GAAG,EAAE;AAAa,CAAC,EACrB;EAAEA,GAAG,EAAE;AAAgB,CAAC,EACxB;EAAEA,GAAG,EAAE,WAAW;EAAEC,KAAK,EAAE;AAAQ,CAAC,CACrC;AACD,MAAMC,eAAe,GAAG;EACtBC,gBAAgB,EAAE,aAAa;EAC/BC,uBAAuB,EAAE,QAAQ;EACjCC,YAAY,EAAE,OAAO;EACrBC,cAAc,EAAE;AAClB,CAAC;AAED,MAAMC,iBAAiB,GAAG,iBAAiB;AAC3C,MAAMC,WAAW,GAAG,QAAQ;AAC5B,MAAMC,QAAQ,GAAG,UAAU;AAE3B,SACED,WAAW,EACXhB,KAAK,EACLM,SAAS,EACTC,SAAS,EACTG,eAAe,EACfK,iBAAiB,EACjBb,QAAQ,EACRC,OAAO,EACPC,UAAU,EACVH,OAAO,EACPgB,QAAQ,EACRZ,SAAS","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import { getCLS, getFID, getLCP } from 'web-vitals';
2
+ import pushToDataLayer from './push-to-data-layer';
3
+ const buildAndPushWebVitals = () => {
4
+ getCLS(reportHandler);
5
+ getFID(reportHandler);
6
+ getLCP(reportHandler);
7
+ };
8
+ const reportHandler = ({
9
+ name,
10
+ delta,
11
+ id
12
+ }) => {
13
+ const metrics = {
14
+ event: 'web-vitals',
15
+ event_category: 'Web Vitals',
16
+ event_action: name,
17
+ event_value: Math.round(name === 'CLS' ? delta * 1000 : delta),
18
+ event_label: id,
19
+ nonInteraction: true
20
+ };
21
+ pushToDataLayer(metrics);
22
+ };
23
+ export default buildAndPushWebVitals;
24
+ //# sourceMappingURL=build-and-push-web-vitals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-and-push-web-vitals.js","names":["getCLS","getFID","getLCP","pushToDataLayer","buildAndPushWebVitals","reportHandler","name","delta","id","metrics","event","event_category","event_action","event_value","Math","round","event_label","nonInteraction"],"sources":["../../src/helpers/build-and-push-web-vitals.js"],"sourcesContent":["import { getCLS, getFID, getLCP } from 'web-vitals';\nimport pushToDataLayer from './push-to-data-layer';\n\nconst buildAndPushWebVitals = () => {\n getCLS(reportHandler);\n getFID(reportHandler);\n getLCP(reportHandler);\n};\n\nconst reportHandler = ({ name, delta, id }) => {\n const metrics = {\n event: 'web-vitals',\n event_category: 'Web Vitals',\n event_action: name,\n event_value: Math.round(name === 'CLS' ? delta * 1000 : delta),\n event_label: id,\n nonInteraction: true\n };\n\n pushToDataLayer(metrics);\n};\n\nexport default buildAndPushWebVitals;\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,MAAM,EAAEC,MAAM,QAAQ,YAAY;AACnD,OAAOC,eAAe,MAAM,sBAAsB;AAElD,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EAClCJ,MAAM,CAACK,aAAa,CAAC;EACrBJ,MAAM,CAACI,aAAa,CAAC;EACrBH,MAAM,CAACG,aAAa,CAAC;AACvB,CAAC;AAED,MAAMA,aAAa,GAAGA,CAAC;EAAEC,IAAI;EAAEC,KAAK;EAAEC;AAAG,CAAC,KAAK;EAC7C,MAAMC,OAAO,GAAG;IACdC,KAAK,EAAE,YAAY;IACnBC,cAAc,EAAE,YAAY;IAC5BC,YAAY,EAAEN,IAAI;IAClBO,WAAW,EAAEC,IAAI,CAACC,KAAK,CAACT,IAAI,KAAK,KAAK,GAAGC,KAAK,GAAG,IAAI,GAAGA,KAAK,CAAC;IAC9DS,WAAW,EAAER,EAAE;IACfS,cAAc,EAAE;EAClB,CAAC;EAEDd,eAAe,CAACM,OAAO,CAAC;AAC1B,CAAC;AAED,eAAeL,qBAAqB","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ const getFinalValue = (data, name) => {
5
+ if (name.includes('.')) {
6
+ const [relationName, fieldName] = name.split('.');
7
+ if (Array.isArray(data[relationName])) {
8
+ return data[relationName].reduce((str, element, index) => `${str}${index ? ',' : ''}${element[fieldName]}`, '');
9
+ }
10
+ return data[relationName] ? data[relationName][fieldName] : data[fieldName] || '';
11
+ }
12
+ return data[name];
13
+ };
14
+ const buildProps = (props, data) => props.reduce((acc, {
15
+ label: key,
16
+ propertiesToDisplay: [name],
17
+ staticMetric
18
+ }) => {
19
+ if (key && (staticMetric || name)) {
20
+ acc[key] = staticMetric || getFinalValue(data, name);
21
+ }
22
+ return acc;
23
+ }, {});
24
+ const buildDataLayerProps = (props, data) => Array.isArray(data) ? data.map(currentData => buildProps(props, currentData)) : buildProps(props, data);
25
+ const buildDataLayer = (data, propsToDisplay, url) => {
26
+ if (!propsToDisplay || !propsToDisplay.length) return null;
27
+ const propsToDisplayValues = buildDataLayerProps(propsToDisplay, data);
28
+ return url ? _objectSpread({
29
+ event: 'pageView',
30
+ url
31
+ }, propsToDisplayValues) : propsToDisplayValues;
32
+ };
33
+ export default buildDataLayer;
34
+ //# sourceMappingURL=build-data-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-data-layer.js","names":["getFinalValue","data","name","includes","relationName","fieldName","split","Array","isArray","reduce","str","element","index","buildProps","props","acc","label","key","propertiesToDisplay","staticMetric","buildDataLayerProps","map","currentData","buildDataLayer","propsToDisplay","url","length","propsToDisplayValues","_objectSpread","event"],"sources":["../../src/helpers/build-data-layer.js"],"sourcesContent":["const getFinalValue = (data, name) => {\n if (name.includes('.')) {\n const [relationName, fieldName] = name.split('.');\n if (Array.isArray(data[relationName])) {\n return data[relationName].reduce(\n (str, element, index) => `${str}${index ? ',' : ''}${element[fieldName]}`,\n ''\n );\n }\n\n return data[relationName] ? data[relationName][fieldName] : data[fieldName] || '';\n }\n return data[name];\n};\n\nconst buildProps = (props, data) =>\n props.reduce((acc, { label: key, propertiesToDisplay: [name], staticMetric }) => {\n if (key && (staticMetric || name)) {\n acc[key] = staticMetric || getFinalValue(data, name);\n }\n\n return acc;\n }, {});\n\nconst buildDataLayerProps = (props, data) =>\n Array.isArray(data)\n ? data.map(currentData => buildProps(props, currentData))\n : buildProps(props, data);\n\nconst buildDataLayer = (data, propsToDisplay, url) => {\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = buildDataLayerProps(propsToDisplay, data);\n\n return url\n ? {\n event: 'pageView',\n url,\n ...propsToDisplayValues\n }\n : propsToDisplayValues;\n};\n\nexport default buildDataLayer;\n"],"mappings":";;;AAAA,MAAMA,aAAa,GAAGA,CAACC,IAAI,EAAEC,IAAI,KAAK;EACpC,IAAIA,IAAI,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;IACtB,MAAM,CAACC,YAAY,EAAEC,SAAS,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,GAAG,CAAC;IACjD,IAAIC,KAAK,CAACC,OAAO,CAACP,IAAI,CAACG,YAAY,CAAC,CAAC,EAAE;MACrC,OAAOH,IAAI,CAACG,YAAY,CAAC,CAACK,MAAM,CAC9B,CAACC,GAAG,EAAEC,OAAO,EAAEC,KAAK,KAAK,GAAGF,GAAG,GAAGE,KAAK,GAAG,GAAG,GAAG,EAAE,GAAGD,OAAO,CAACN,SAAS,CAAC,EAAE,EACzE,EACF,CAAC;IACH;IAEA,OAAOJ,IAAI,CAACG,YAAY,CAAC,GAAGH,IAAI,CAACG,YAAY,CAAC,CAACC,SAAS,CAAC,GAAGJ,IAAI,CAACI,SAAS,CAAC,IAAI,EAAE;EACnF;EACA,OAAOJ,IAAI,CAACC,IAAI,CAAC;AACnB,CAAC;AAED,MAAMW,UAAU,GAAGA,CAACC,KAAK,EAAEb,IAAI,KAC7Ba,KAAK,CAACL,MAAM,CAAC,CAACM,GAAG,EAAE;EAAEC,KAAK,EAAEC,GAAG;EAAEC,mBAAmB,EAAE,CAAChB,IAAI,CAAC;EAAEiB;AAAa,CAAC,KAAK;EAC/E,IAAIF,GAAG,KAAKE,YAAY,IAAIjB,IAAI,CAAC,EAAE;IACjCa,GAAG,CAACE,GAAG,CAAC,GAAGE,YAAY,IAAInB,aAAa,CAACC,IAAI,EAAEC,IAAI,CAAC;EACtD;EAEA,OAAOa,GAAG;AACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AAER,MAAMK,mBAAmB,GAAGA,CAACN,KAAK,EAAEb,IAAI,KACtCM,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,GACfA,IAAI,CAACoB,GAAG,CAACC,WAAW,IAAIT,UAAU,CAACC,KAAK,EAAEQ,WAAW,CAAC,CAAC,GACvDT,UAAU,CAACC,KAAK,EAAEb,IAAI,CAAC;AAE7B,MAAMsB,cAAc,GAAGA,CAACtB,IAAI,EAAEuB,cAAc,EAAEC,GAAG,KAAK;EACpD,IAAI,CAACD,cAAc,IAAI,CAACA,cAAc,CAACE,MAAM,EAAE,OAAO,IAAI;EAC1D,MAAMC,oBAAoB,GAAGP,mBAAmB,CAACI,cAAc,EAAEvB,IAAI,CAAC;EAEtE,OAAOwB,GAAG,GAAAG,aAAA;IAEJC,KAAK,EAAE,UAAU;IACjBJ;EAAG,GACAE,oBAAoB,IAEzBA,oBAAoB;AAC1B,CAAC;AAED,eAAeJ,cAAc","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { GTM_EVENT_NAMES, GTM_PROPS, EVENT, ECOMMERCE, PRODUCTS, ON_CLICK } from '../constants';
5
+ const buildNestedEvent = (ecommerce, propsObject, props, parentComponent) => {
6
+ const {
7
+ productDetailImpression,
8
+ productClick
9
+ } = GTM_EVENT_NAMES;
10
+ const {
11
+ eventAction,
12
+ eventTrigger
13
+ } = propsObject;
14
+ const {
15
+ name
16
+ } = parentComponent;
17
+ const gtmActionLabel = GTM_EVENT_NAMES[eventAction];
18
+ const isClickEvent = eventTrigger === ON_CLICK || gtmActionLabel === productClick;
19
+ const actionField = {
20
+ list: name
21
+ };
22
+ const hasMultipleItems = Array.isArray(props);
23
+ if (!ecommerce) {
24
+ const basicEventObject = {};
25
+ GTM_PROPS.forEach(({
26
+ key,
27
+ label
28
+ }) => {
29
+ const gtmValue = propsObject[key];
30
+ const gtmKey = label || key;
31
+ if (gtmValue) basicEventObject[gtmKey] = gtmValue;
32
+ });
33
+ const parsedProps = hasMultipleItems ? {
34
+ items: props
35
+ } : props;
36
+ return _objectSpread(_objectSpread({}, basicEventObject), parsedProps);
37
+ }
38
+ if (!gtmActionLabel) return {
39
+ [EVENT]: eventAction,
40
+ [ECOMMERCE]: props
41
+ };
42
+ if (gtmActionLabel === productDetailImpression || gtmActionLabel === productClick) {
43
+ const parsedProducts = hasMultipleItems ? props : [props];
44
+ const eventObject = isClickEvent ? {
45
+ [PRODUCTS]: parsedProducts,
46
+ actionField
47
+ } : {
48
+ [PRODUCTS]: parsedProducts
49
+ };
50
+ return {
51
+ [EVENT]: eventAction,
52
+ [ECOMMERCE]: {
53
+ [gtmActionLabel]: eventObject
54
+ }
55
+ };
56
+ }
57
+ const ecommerceObject = isClickEvent ? {
58
+ [gtmActionLabel]: props,
59
+ actionField
60
+ } : {
61
+ [gtmActionLabel]: props
62
+ };
63
+ return {
64
+ [EVENT]: eventAction,
65
+ [ECOMMERCE]: ecommerceObject
66
+ };
67
+ };
68
+ export default buildNestedEvent;
69
+ //# sourceMappingURL=build-nested-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-nested-event.js","names":["GTM_EVENT_NAMES","GTM_PROPS","EVENT","ECOMMERCE","PRODUCTS","ON_CLICK","buildNestedEvent","ecommerce","propsObject","props","parentComponent","productDetailImpression","productClick","eventAction","eventTrigger","name","gtmActionLabel","isClickEvent","actionField","list","hasMultipleItems","Array","isArray","basicEventObject","forEach","key","label","gtmValue","gtmKey","parsedProps","items","_objectSpread","parsedProducts","eventObject","ecommerceObject"],"sources":["../../src/helpers/build-nested-event.js"],"sourcesContent":["import { GTM_EVENT_NAMES, GTM_PROPS, EVENT, ECOMMERCE, PRODUCTS, ON_CLICK } from '../constants';\n\nconst buildNestedEvent = (ecommerce, propsObject, props, parentComponent) => {\n const { productDetailImpression, productClick } = GTM_EVENT_NAMES;\n const { eventAction, eventTrigger } = propsObject;\n const { name } = parentComponent;\n const gtmActionLabel = GTM_EVENT_NAMES[eventAction];\n const isClickEvent = eventTrigger === ON_CLICK || gtmActionLabel === productClick;\n const actionField = { list: name };\n const hasMultipleItems = Array.isArray(props);\n\n if (!ecommerce) {\n const basicEventObject = {};\n GTM_PROPS.forEach(({ key, label }) => {\n const gtmValue = propsObject[key];\n const gtmKey = label || key;\n if (gtmValue) basicEventObject[gtmKey] = gtmValue;\n });\n const parsedProps = hasMultipleItems ? { items: props } : props;\n\n return { ...basicEventObject, ...parsedProps };\n }\n\n if (!gtmActionLabel) return { [EVENT]: eventAction, [ECOMMERCE]: props };\n if (gtmActionLabel === productDetailImpression || gtmActionLabel === productClick) {\n const parsedProducts = hasMultipleItems ? props : [props];\n const eventObject = isClickEvent\n ? { [PRODUCTS]: parsedProducts, actionField }\n : { [PRODUCTS]: parsedProducts };\n return {\n [EVENT]: eventAction,\n [ECOMMERCE]: { [gtmActionLabel]: eventObject }\n };\n }\n\n const ecommerceObject = isClickEvent\n ? { [gtmActionLabel]: props, actionField }\n : { [gtmActionLabel]: props };\n return { [EVENT]: eventAction, [ECOMMERCE]: ecommerceObject };\n};\n\nexport default buildNestedEvent;\n"],"mappings":";;;AAAA,SAASA,eAAe,EAAEC,SAAS,EAAEC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AAE/F,MAAMC,gBAAgB,GAAGA,CAACC,SAAS,EAAEC,WAAW,EAAEC,KAAK,EAAEC,eAAe,KAAK;EAC3E,MAAM;IAAEC,uBAAuB;IAAEC;EAAa,CAAC,GAAGZ,eAAe;EACjE,MAAM;IAAEa,WAAW;IAAEC;EAAa,CAAC,GAAGN,WAAW;EACjD,MAAM;IAAEO;EAAK,CAAC,GAAGL,eAAe;EAChC,MAAMM,cAAc,GAAGhB,eAAe,CAACa,WAAW,CAAC;EACnD,MAAMI,YAAY,GAAGH,YAAY,KAAKT,QAAQ,IAAIW,cAAc,KAAKJ,YAAY;EACjF,MAAMM,WAAW,GAAG;IAAEC,IAAI,EAAEJ;EAAK,CAAC;EAClC,MAAMK,gBAAgB,GAAGC,KAAK,CAACC,OAAO,CAACb,KAAK,CAAC;EAE7C,IAAI,CAACF,SAAS,EAAE;IACd,MAAMgB,gBAAgB,GAAG,CAAC,CAAC;IAC3BtB,SAAS,CAACuB,OAAO,CAAC,CAAC;MAAEC,GAAG;MAAEC;IAAM,CAAC,KAAK;MACpC,MAAMC,QAAQ,GAAGnB,WAAW,CAACiB,GAAG,CAAC;MACjC,MAAMG,MAAM,GAAGF,KAAK,IAAID,GAAG;MAC3B,IAAIE,QAAQ,EAAEJ,gBAAgB,CAACK,MAAM,CAAC,GAAGD,QAAQ;IACnD,CAAC,CAAC;IACF,MAAME,WAAW,GAAGT,gBAAgB,GAAG;MAAEU,KAAK,EAAErB;IAAM,CAAC,GAAGA,KAAK;IAE/D,OAAAsB,aAAA,CAAAA,aAAA,KAAYR,gBAAgB,GAAKM,WAAW;EAC9C;EAEA,IAAI,CAACb,cAAc,EAAE,OAAO;IAAE,CAACd,KAAK,GAAGW,WAAW;IAAE,CAACV,SAAS,GAAGM;EAAM,CAAC;EACxE,IAAIO,cAAc,KAAKL,uBAAuB,IAAIK,cAAc,KAAKJ,YAAY,EAAE;IACjF,MAAMoB,cAAc,GAAGZ,gBAAgB,GAAGX,KAAK,GAAG,CAACA,KAAK,CAAC;IACzD,MAAMwB,WAAW,GAAGhB,YAAY,GAC5B;MAAE,CAACb,QAAQ,GAAG4B,cAAc;MAAEd;IAAY,CAAC,GAC3C;MAAE,CAACd,QAAQ,GAAG4B;IAAe,CAAC;IAClC,OAAO;MACL,CAAC9B,KAAK,GAAGW,WAAW;MACpB,CAACV,SAAS,GAAG;QAAE,CAACa,cAAc,GAAGiB;MAAY;IAC/C,CAAC;EACH;EAEA,MAAMC,eAAe,GAAGjB,YAAY,GAChC;IAAE,CAACD,cAAc,GAAGP,KAAK;IAAES;EAAY,CAAC,GACxC;IAAE,CAACF,cAAc,GAAGP;EAAM,CAAC;EAC/B,OAAO;IAAE,CAACP,KAAK,GAAGW,WAAW;IAAE,CAACV,SAAS,GAAG+B;EAAgB,CAAC;AAC/D,CAAC;AAED,eAAe5B,gBAAgB","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ function buildPropsToDisplayArray(propsToDisplay = []) {
2
+ return propsToDisplay.map(prop => !!prop && !!prop.propertiesToDisplay && prop.propertiesToDisplay[0]).filter(Boolean);
3
+ }
4
+ export default buildPropsToDisplayArray;
5
+ //# sourceMappingURL=build-props-to-display-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-props-to-display-array.js","names":["buildPropsToDisplayArray","propsToDisplay","map","prop","propertiesToDisplay","filter","Boolean"],"sources":["../../src/helpers/build-props-to-display-array.js"],"sourcesContent":["function buildPropsToDisplayArray(propsToDisplay = []) {\n return propsToDisplay\n .map(prop => !!prop && !!prop.propertiesToDisplay && prop.propertiesToDisplay[0])\n .filter(Boolean);\n}\n\nexport default buildPropsToDisplayArray;\n"],"mappings":"AAAA,SAASA,wBAAwBA,CAACC,cAAc,GAAG,EAAE,EAAE;EACrD,OAAOA,cAAc,CAClBC,GAAG,CAACC,IAAI,IAAI,CAAC,CAACA,IAAI,IAAI,CAAC,CAACA,IAAI,CAACC,mBAAmB,IAAID,IAAI,CAACC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAChFC,MAAM,CAACC,OAAO,CAAC;AACpB;AAEA,eAAeN,wBAAwB","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ const getValue = (propertiesToDisplay, getUser) => {
2
+ const [baseProp, nestedProp] = propertiesToDisplay[0].split('.');
3
+ const baseValue = getUser[baseProp];
4
+ const isArray = Array.isArray(baseValue);
5
+ if (nestedProp && baseValue) {
6
+ let nestedValue;
7
+ if (isArray) {
8
+ nestedValue = baseValue.length ? baseValue.map(nested => nested ? nested[nestedProp] : '').join(', ') : '';
9
+ } else {
10
+ nestedValue = baseValue[nestedProp];
11
+ }
12
+ return nestedValue || '';
13
+ }
14
+ return baseValue || '';
15
+ };
16
+ const checkAndSetProps = (userPropsToDisplay, getUser) => {
17
+ const userDataLayer = {};
18
+ userPropsToDisplay.forEach(prop => {
19
+ const {
20
+ propertiesToDisplay,
21
+ label,
22
+ staticMetric
23
+ } = prop;
24
+ if (staticMetric) {
25
+ userDataLayer[label] = staticMetric;
26
+ return;
27
+ }
28
+ if (!propertiesToDisplay[0]) return;
29
+ const value = getValue(propertiesToDisplay, getUser);
30
+ userDataLayer[label] = value;
31
+ });
32
+ return userDataLayer;
33
+ };
34
+ const buildUserLayer = (userData, userPropsToDisplay) => {
35
+ if (!userData || !userData.getUser) return {};
36
+ const {
37
+ getUser
38
+ } = userData;
39
+ const userDataLayer = checkAndSetProps(userPropsToDisplay, getUser);
40
+ return {
41
+ user: userDataLayer
42
+ };
43
+ };
44
+ export default buildUserLayer;
45
+ //# sourceMappingURL=build-user-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-user-layer.js","names":["getValue","propertiesToDisplay","getUser","baseProp","nestedProp","split","baseValue","isArray","Array","nestedValue","length","map","nested","join","checkAndSetProps","userPropsToDisplay","userDataLayer","forEach","prop","label","staticMetric","value","buildUserLayer","userData","user"],"sources":["../../src/helpers/build-user-layer.js"],"sourcesContent":["const getValue = (propertiesToDisplay, getUser) => {\n const [baseProp, nestedProp] = propertiesToDisplay[0].split('.');\n const baseValue = getUser[baseProp];\n const isArray = Array.isArray(baseValue);\n if (nestedProp && baseValue) {\n let nestedValue;\n if (isArray) {\n nestedValue = baseValue.length\n ? baseValue.map(nested => (nested ? nested[nestedProp] : '')).join(', ')\n : '';\n } else {\n nestedValue = baseValue[nestedProp];\n }\n return nestedValue || '';\n }\n return baseValue || '';\n};\n\nconst checkAndSetProps = (userPropsToDisplay, getUser) => {\n const userDataLayer = {};\n userPropsToDisplay.forEach(prop => {\n const { propertiesToDisplay, label, staticMetric } = prop;\n if (staticMetric) {\n userDataLayer[label] = staticMetric;\n return;\n }\n if (!propertiesToDisplay[0]) return;\n const value = getValue(propertiesToDisplay, getUser);\n userDataLayer[label] = value;\n });\n\n return userDataLayer;\n};\n\nconst buildUserLayer = (userData, userPropsToDisplay) => {\n if (!userData || !userData.getUser) return {};\n const { getUser } = userData;\n\n const userDataLayer = checkAndSetProps(userPropsToDisplay, getUser);\n\n return { user: userDataLayer };\n};\n\nexport default buildUserLayer;\n"],"mappings":"AAAA,MAAMA,QAAQ,GAAGA,CAACC,mBAAmB,EAAEC,OAAO,KAAK;EACjD,MAAM,CAACC,QAAQ,EAAEC,UAAU,CAAC,GAAGH,mBAAmB,CAAC,CAAC,CAAC,CAACI,KAAK,CAAC,GAAG,CAAC;EAChE,MAAMC,SAAS,GAAGJ,OAAO,CAACC,QAAQ,CAAC;EACnC,MAAMI,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACD,SAAS,CAAC;EACxC,IAAIF,UAAU,IAAIE,SAAS,EAAE;IAC3B,IA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@@ -0,0 +1,25 @@
1
+ const buildUserQueryProps = userProps => {
2
+ if (!userProps || !userProps.length) return '';
3
+ const basicProps = [];
4
+ const nestedProps = {};
5
+ userProps.forEach(({
6
+ propertiesToDisplay
7
+ }) => {
8
+ const [propKey] = propertiesToDisplay;
9
+ if (!propKey || propKey === 'id') return;
10
+ if (propKey.indexOf('.') !== -1) {
11
+ const [baseProp, nestedProp] = propKey.split('.');
12
+ if (nestedProps[baseProp]) nestedProps[baseProp].push(nestedProp);else nestedProps[baseProp] = [nestedProp];
13
+ } else basicProps.push(propKey);
14
+ });
15
+ Object.keys(nestedProps).forEach(nestedKey => {
16
+ const nested = nestedProps[nestedKey];
17
+ basicProps.push(nestedKey);
18
+ basicProps.push('{');
19
+ nested.forEach(prop => basicProps.push(prop));
20
+ basicProps.push('}');
21
+ });
22
+ return basicProps.join(' ');
23
+ };
24
+ export default buildUserQueryProps;
25
+ //# sourceMappingURL=build-user-query-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-user-query-props.js","names":["buildUserQueryProps","userProps","length","basicProps","nestedProps","forEach","propertiesToDisplay","propKey","indexOf","baseProp","nestedProp","split","push","Object","keys","nestedKey","nested","prop","join"],"sources":["../../src/helpers/build-user-query-props.js"],"sourcesContent":["const buildUserQueryProps = userProps => {\n if (!userProps || !userProps.length) return '';\n const basicProps = [];\n const nestedProps = {};\n userProps.forEach(({ propertiesToDisplay }) => {\n const [propKey] = propertiesToDisplay;\n if (!propKey || propKey === 'id') return;\n if (propKey.indexOf('.') !== -1) {\n const [baseProp, nestedProp] = propKey.split('.');\n if (nestedProps[baseProp]) nestedProps[baseProp].push(nestedProp);\n else nestedProps[baseProp] = [nestedProp];\n } else basicProps.push(propKey);\n });\n\n Object.keys(nestedProps).forEach(nestedKey => {\n const nested = nestedProps[nestedKey];\n basicProps.push(nestedKey);\n basicProps.push('{');\n nested.forEach(prop => basicProps.push(prop));\n basicProps.push('}');\n });\n\n return basicProps.join(' ');\n};\n\nexport default bu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}
@@ -0,0 +1,14 @@
1
+ import { ON_CLICK } from '../constants';
2
+ const filterGtmEvents = gtmEvents => {
3
+ const clickEvents = [];
4
+ const regularEvents = [];
5
+ gtmEvents.forEach(event => {
6
+ event.eventTrigger && event.eventTrigger === ON_CLICK ? clickEvents.push(event) : regularEvents.push(event);
7
+ });
8
+ return {
9
+ clickEvents,
10
+ regularEvents
11
+ };
12
+ };
13
+ export default filterGtmEvents;
14
+ //# sourceMappingURL=filter-gtm-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-gtm-events.js","names":["ON_CLICK","filterGtmEvents","gtmEvents","clickEvents","regularEvents","forEach","event","eventTrigger","push"],"sources":["../../src/helpers/filter-gtm-events.js"],"sourcesContent":["import { ON_CLICK } from '../constants';\n\nconst filterGtmEvents = gtmEvents => {\n const clickEvents = [];\n const regularEvents = [];\n gtmEvents.forEach(event => {\n event.eventTrigger && event.eventTrigger === ON_CLICK\n ? clickEvents.push(event)\n : regularEvents.push(event);\n });\n\n return { clickEvents, regularEvents };\n};\n\nexport default filterGtmEvents;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,MAAMC,eAAe,GAAGC,SAAS,IAAI;EACnC,MAAMC,WAAW,GAAG,EAAE;EACtB,MAAMC,aAAa,GAAG,EAAE;EACxBF,SAAS,CAACG,OAAO,CAACC,KAAK,IAAI;IACzBA,KAAK,CAACC,YAAY,IAAID,KAAK,CAACC,YAAY,KAAKP,QAAQ,GACjDG,WAAW,CAACK,IAAI,CAACF,KAAK,CAAC,GACvBF,aAAa,CAACI,IAAI,CAACF,KAAK,CAAC;EAC/B,CAAC,CAAC;EAEF,OAAO;IAAEH,WAAW;IAAEC;EAAc,CAAC;AACvC,CAAC;AAED,eAAeH,eAAe","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ const getIdsToUse = parentData => {
2
+ if (!parentData || !parentData.length) return [];
3
+ return parentData.map(({
4
+ id
5
+ }) => id);
6
+ };
7
+ export default getIdsToUse;
8
+ //# sourceMappingURL=get-ids-to-use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-ids-to-use.js","names":["getIdsToUse","parentData","length","map","id"],"sources":["../../src/helpers/get-ids-to-use.js"],"sourcesContent":["const getIdsToUse = parentData => {\n if (!parentData || !parentData.length) return [];\n\n return parentData.map(({ id }) => id);\n};\n\nexport default getIdsToUse;\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGC,UAAU,IAAI;EAChC,IAAI,CAACA,UAAU,IAAI,CAACA,UAAU,CAACC,MAAM,EAAE,OAAO,EAAE;EAEhD,OAAOD,UAAU,CAACE,GAAG,CAAC,CAAC;IAAEC;EAAG,CAAC,KAAKA,EAAE,CAAC;AACvC,CAAC;AAED,eAAeJ,WAAW","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { generateSingleItemQuery, generateMultiItemQuery } from '@blaze-cms/react-page-builder';
2
+ const getRenderProps = (extraProps, isPreview, data, useMultiQuery) => {
3
+ const {
4
+ getEntitySchema
5
+ } = data;
6
+ const {
7
+ actions: {
8
+ get,
9
+ getPublished,
10
+ getAll,
11
+ getAllPublished
12
+ }
13
+ } = getEntitySchema;
14
+ const queryToUse = useMultiQuery ? generateMultiItemQuery : generateSingleItemQuery;
15
+ const singleActionKey = isPreview ? get : getPublished || get;
16
+ const multiActionKey = isPreview ? getAll : getAllPublished || getAll;
17
+ const actionKey = useMultiQuery ? multiActionKey : singleActionKey;
18
+ const action = queryToUse(actionKey, extraProps);
19
+ return {
20
+ action,
21
+ actionKey
22
+ };
23
+ };
24
+ export default getRenderProps;
25
+ //# sourceMappingURL=get-render-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-render-props.js","names":["generateSingleItemQuery","generateMultiItemQuery","getRenderProps","extraProps","isPreview","data","useMultiQuery","getEntitySchema","actions","get","getPublished","getAll","getAllPublished","queryToUse","singleActionKey","multiActionKey","actionKey","action"],"sources":["../../src/helpers/get-render-props.js"],"sourcesContent":["import { generateSingleItemQuery, generateMultiItemQuery } from '@blaze-cms/react-page-builder';\n\nconst getRenderProps = (extraProps, isPreview, data, useMultiQuery) => {\n const { getEntitySchema } = data;\n const {\n actions: { get, getPublished, getAll, getAllPublished }\n } = getEntitySchema;\n const queryToUse = useMultiQuery ? generateMultiItemQuery : generateSingleItemQuery;\n const singleActionKey = isPreview ? get : getPublished || get;\n const multiActionKey = isPreview ? getAll : getAllPublished || getAll;\n const actionKey = useMultiQuery ? multiActionKey : singleActionKey;\n const action = queryToUse(actionKey, extraProps);\n\n return { action, actionKey };\n};\n\nexport default getRenderProps;\n"],"mappings":"AAAA,SAASA,uBAAuB,EAAEC,sBAAsB,QAAQ,+BAA+B;AAE/F,MAAMC,cAAc,GAAGA,CAACC,UAAU,EAAEC,SAAS,EAAEC,IAAI,EAAEC,aAAa,KAAK;EACrE,MAAM;IAAEC;EAAgB,CAAC,GAAGF,IAAI;EAChC,MAAM;IACJG,OAAO,EAAE;MAAEC,GAAG;MAAEC,YAAY;MAAEC,MAAM;MAAEC;IAAgB;EACxD,CAAC,GAAGL,eAAe;EACnB,MAAMM,UAAU,GAAGP,aAAa,GAAGL,sBAAsB,GAAGD,uBAAuB;EACnF,MAAMc,eAAe,GAAGV,SAAS,GAAGK,GAAG,GAAGC,YAAY,IAAID,GAAG;EAC7D,MAAMM,cAAc,GAAGX,SAAS,GAAGO,MAAM,GAAGC,eAAe,IAAID,MAAM;EACrE,MAAMK,SAAS,GAAGV,aAAa,GAAGS,cAAc,GAAGD,eAAe;EAClE,MAAMG,MAAM,GAAGJ,UAAU,CAACG,SAAS,EAAEb,UAAU,CAAC;EAEhD,OAAO;IAAEc,MAAM;IAAED;EAAU,CAAC;AAC9B,CAAC;AAED,eAAed,cAAc","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ export { default as buildDataLayer } from './build-data-layer';
2
+ export { default as pushToDataLayer } from './push-to-data-layer';
3
+ export { default as buildNestedEvent } from './build-nested-event';
4
+ export { default as getRenderProps } from './get-render-props';
5
+ export { default as getIdsToUse } from './get-ids-to-use';
6
+ export { default as buildPropsToDisplayArray } from './build-props-to-display-array';
7
+ export { default as buildAndPushWebVitals } from './build-and-push-web-vitals';
8
+ export { default as filterGtmEvents } from './filter-gtm-events';
9
+ export { default as buildUserQueryProps } from './build-user-query-props';
10
+ export { default as buildUserLayer } from './build-user-layer';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["default","buildDataLayer","pushToDataLayer","buildNestedEvent","getRenderProps","getIdsToUse","buildPropsToDisplayArray","buildAndPushWebVitals","filterGtmEvents","buildUserQueryProps","buildUserLayer"],"sources":["../../src/helpers/index.js"],"sourcesContent":["export { default as buildDataLayer } from './build-data-layer';\nexport { default as pushToDataLayer } from './push-to-data-layer';\nexport { default as buildNestedEvent } from './build-nested-event';\nexport { default as getRenderProps } from './get-render-props';\nexport { default as getIdsToUse } from './get-ids-to-use';\nexport { default as buildPropsToDisplayArray } from './build-props-to-display-array';\nexport { default as buildAndPushWebVitals } from './build-and-push-web-vitals';\nexport { default as filterGtmEvents } from './filter-gtm-events';\nexport { default as buildUserQueryProps } from './build-user-query-props';\nexport { default as buildUserLayer } from './build-user-layer';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,cAAc,QAAQ,oBAAoB;AAC9D,SAASD,OAAO,IAAIE,eAAe,QAAQ,sBAAsB;AACjE,SAASF,OAAO,IAAIG,gBAAgB,QAAQ,sBAAsB;AAClE,SAASH,OAAO,IAAII,cAAc,QAAQ,oBAAoB;AAC9D,SAASJ,OAAO,IAAIK,WAAW,QAAQ,kBAAkB;AACzD,SAASL,OAAO,IAAIM,wBAAwB,QAAQ,gCAAgC;AACpF,SAASN,OAAO,IAAIO,qBAAqB,QAAQ,6BAA6B;AAC9E,SAASP,OAAO,IAAIQ,eAAe,QAAQ,qBAAqB;AAChE,SAASR,OAAO,IAAIS,mBAAmB,QAAQ,0BAA0B;AACzE,SAAST,OAAO,IAAIU,cAAc,QAAQ,oBAAoB","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import resetDataLayer from './reset-data-layer';
2
+ const pushToDataLayer = (dataLayer, isPageView) => {
3
+ if (dataLayer && window.dataLayer) {
4
+ if (isPageView) resetDataLayer();
5
+ window.dataLayer.push(dataLayer);
6
+ }
7
+ };
8
+ export default pushToDataLayer;
9
+ //# sourceMappingURL=push-to-data-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-to-data-layer.js","names":["resetDataLayer","pushToDataLayer","dataLayer","isPageView","window","push"],"sources":["../../src/helpers/push-to-data-layer.js"],"sourcesContent":["import resetDataLayer from './reset-data-layer';\n\nconst pushToDataLayer = (dataLayer, isPageView) => {\n if (dataLayer && window.dataLayer) {\n if (isPageView) resetDataLayer();\n window.dataLayer.push(dataLayer);\n }\n};\n\nexport default pushToDataLayer;\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,oBAAoB;AAE/C,MAAMC,eAAe,GAAGA,CAACC,SAAS,EAAEC,UAAU,KAAK;EACjD,IAAID,SAAS,IAAIE,MAAM,CAACF,SAAS,EAAE;IACjC,IAAIC,UAAU,EAAEH,cAAc,CAAC,CAAC;IAChCI,MAAM,CAACF,SAAS,CAACG,IAAI,CAACH,SAAS,CAAC;EAClC;AACF,CAAC;AAED,eAAeD,eAAe","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import { PAGE_VIEW } from '../constants';
2
+ const resetDataLayer = () => {
3
+ if (!shouldReset()) return false;
4
+ window.dataLayer.length = 0;
5
+ const gtmIdRegex = /GTM-/i;
6
+ const keys = Object.keys(window.google_tag_manager);
7
+ const GTMkeys = keys.filter(key => gtmIdRegex.test(key) && window.google_tag_manager[key].dataLayer);
8
+ GTMkeys.forEach(GTMkey => window.google_tag_manager[GTMkey].dataLayer.reset());
9
+ return true;
10
+ };
11
+ function shouldReset() {
12
+ return window.google_tag_manager && window.dataLayer && window.dataLayer.find(({
13
+ event
14
+ }) => event === PAGE_VIEW);
15
+ }
16
+ export default resetDataLayer;
17
+ //# sourceMappingURL=reset-data-layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset-data-layer.js","names":["PAGE_VIEW","resetDataLayer","shouldReset","window","dataLayer","length","gtmIdRegex","keys","Object","google_tag_manager","GTMkeys","filter","key","test","forEach","GTMkey","reset","find","event"],"sources":["../../src/helpers/reset-data-layer.js"],"sourcesContent":["import { PAGE_VIEW } from '../constants';\n\nconst resetDataLayer = () => {\n if (!shouldReset()) return false;\n\n window.dataLayer.length = 0;\n const gtmIdRegex = /GTM-/i;\n const keys = Object.keys(window.google_tag_manager);\n const GTMkeys = keys.filter(\n key => gtmIdRegex.test(key) && window.google_tag_manager[key].dataLayer\n );\n GTMkeys.forEach(GTMkey => window.google_tag_manager[GTMkey].dataLayer.reset());\n\n return true;\n};\n\nfunction shouldReset() {\n return (\n window.google_tag_manager &&\n window.dataLayer &&\n window.dataLayer.find(({ event }) => event === PAGE_VIEW)\n );\n}\n\nexport default resetDataLayer;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC3B,IAAI,CAACC,WAAW,CAAC,CAAC,EAAE,OAAO,KAAK;EAEhCC,MAAM,CAACC,SAAS,CAACC,MAAM,GAAG,CAAC;EAC3B,MAAMC,UAAU,GAAG,OAAO;EAC1B,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACJ,MAAM,CAACM,kBAAkB,CAAC;EACnD,MAAMC,OAAO,GAAGH,IAAI,CAACI,MAAM,CACzBC,GAAG,IAAIN,UAAU,CAACO,IAAI,CAACD,GAAG,CAAC,IAAIT,MAAM,CAACM,kBAAkB,CAACG,GAAG,CAAC,CAACR,SAChE,CAAC;EACDM,OAAO,CAACI,OAAO,CAACC,MAAM,IAAIZ,MAAM,CAACM,kBAAkB,CAACM,MAAM,CAAC,CAACX,SAAS,CAACY,KAAK,CAAC,CAAC,CAAC;EAE9E,OAAO,IAAI;AACb,CAAC;AAED,SAASd,WAAWA,CAAA,EAAG;EACrB,OACEC,MAAM,CAACM,kBAAkB,IACzBN,MAAM,CAACC,SAAS,IAChBD,MAAM,CAACC,SAAS,CAACa,IAAI,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAKA,KAAK,KAAKlB,SAAS,CAAC;AAE7D;AAEA,eAAeC,cAAc","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ import dynamic from 'next/dynamic';
2
+ import pkg from '../package.json';
3
+ import { PLUGIN_NAME } from './constants';
4
+ export default async function load(app) {
5
+ app.events.once('load:custom:page-builder:component', addComponent => {
6
+ addComponent({
7
+ key: 'gtm',
8
+ component: dynamic(() => import(/* webpackChunkName: "blazePbGoogleTagManager" */'./GoogleTagManager'))
9
+ });
10
+ addComponent({
11
+ key: 'gtm-events',
12
+ component: dynamic(() => import(/* webpackChunkName: "blazePbGoogleTagManagerEvent" */'./GoogleTagManagerEvent'))
13
+ });
14
+ });
15
+ return {
16
+ name: PLUGIN_NAME,
17
+ version: pkg.version
18
+ };
19
+ }
20
+ load.pluginName = PLUGIN_NAME;
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["dynamic","pkg","PLUGIN_NAME","load","app","events","once","addComponent","key","component","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import dynamic from 'next/dynamic';\n\nimport pkg from '../package.json';\nimport { PLUGIN_NAME } from './constants';\n\nexport default async function load(app) {\n app.events.once('load:custom:page-builder:component', addComponent => {\n addComponent({\n key: 'gtm',\n component: dynamic(\n () => import(/* webpackChunkName: \"blazePbGoogleTagManager\" */ './GoogleTagManager')\n )\n });\n addComponent({\n key: 'gtm-events',\n component: dynamic(\n () =>\n import(/* webpackChunkName: \"blazePbGoogleTagManagerEvent\" */ './GoogleTagManagerEvent')\n )\n });\n });\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,cAAc;AAElC,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,WAAW,QAAQ,aAAa;AAEzC,eAAe,eAAeC,IAAIA,CAACC,GAAG,EAAE;EACtCA,GAAG,CAACC,MAAM,CAACC,IAAI,CAAC,oCAAoC,EAAEC,YAAY,IAAI;IACpEA,YAAY,CAAC;MACXC,GAAG,EAAE,KAAK;MACVC,SAAS,EAAET,OAAO,CAChB,MAAM,MAAM,CAAC,iDAAkD,oBAAoB,CACrF;IACF,CAAC,CAAC;IACFO,YAAY,CAAC;MACXC,GAAG,EAAE,YAAY;MACjBC,SAAS,EAAET,OAAO,CAChB,MACE,MAAM,CAAC,sDAAuD,yBAAyB,CAC3F;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLU,IAAI,EAAER,WAAW;IACjBS,OAAO,EAAEV,GAAG,CAACU;EACf,CAAC;AACH;AAEAR,IAAI,CAACS,UAAU,GAAGV,WAAW","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/plugin-gtm-fe",
3
- "version": "0.146.0-node18-core-styles-tooltips.45",
3
+ "version": "0.146.0-node18-core-styles-tooltips.46",
4
4
  "description": "Blaze GTM plugin fe",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,16 +27,16 @@
27
27
  },
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
- "@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.38",
31
- "@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.45",
32
- "@blaze-cms/react-page-builder": "0.146.0-node18-core-styles-tooltips.45",
33
- "@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.3",
30
+ "@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.46",
31
+ "@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.46",
32
+ "@blaze-cms/react-page-builder": "0.146.0-node18-core-styles-tooltips.46",
33
+ "@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.46",
34
34
  "core-js": "^3.2.1",
35
35
  "regenerator-runtime": "^0.13.3",
36
36
  "web-vitals": "^0.2.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@blaze-cms/core-ui": "0.146.0-node18-core-styles-tooltips.38"
39
+ "@blaze-cms/core-ui": "0.146.0-node18-core-styles-tooltips.46"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "next": "14.1.0"
@@ -44,5 +44,6 @@
44
44
  "eslintIgnore": [
45
45
  "lib/*",
46
46
  "lib-es/*"
47
- ]
47
+ ],
48
+ "gitHead": "424c3c1f446e3cfa3a50106bdb98f4f5eeaed800"
48
49
  }