@blotoutio/providers-google-analytics-4-sdk 1.36.0 → 1.36.2

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.
package/index.cjs.js CHANGED
@@ -112,6 +112,18 @@ new Set([
112
112
  ...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
113
113
  ]);
114
114
 
115
+ function tryParse(json, fallbackValue) {
116
+ try {
117
+ if (json) {
118
+ return JSON.parse(json);
119
+ }
120
+ }
121
+ catch {
122
+ /* do nothing */
123
+ }
124
+ return fallbackValue;
125
+ }
126
+
115
127
  /**
116
128
  * ISO-3166 2-leter country codes and their names
117
129
  * @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
@@ -434,6 +446,13 @@ const usStates = new Map([
434
446
  ]);
435
447
  new Set([...isoCountries.keys(), ...usStates.keys()]);
436
448
 
449
+ /** This function will create a deep copy using JSON stringify/parse
450
+ * that will also remove all methods from the incoming objects. Use
451
+ * this function when cloning user-provided objects since structuredClone
452
+ * will throw an error if given an object with functions.
453
+ */
454
+ const jsonClone = (json) => tryParse(JSON.stringify(json), undefined);
455
+
437
456
  // eslint-disable-next-line @nx/enforce-module-boundaries
438
457
  const getGoogleConsentFromCategories = (categories) => {
439
458
  const analyticsConsent = isCategoryConsented(categories, 'analytics');
@@ -710,7 +729,7 @@ const handleTag = ({ data = {}, eventName, eventId, manifestVariables, }) => {
710
729
  if (manifestVariables['debug'] === '1') {
711
730
  eventData['debug_mode'] = true;
712
731
  }
713
- const rawData = structuredClone(data !== null && data !== void 0 ? data : {});
732
+ const rawData = jsonClone(data !== null && data !== void 0 ? data : {});
714
733
  if ('items' in eventData) {
715
734
  delete rawData['contents'];
716
735
  }
@@ -776,7 +795,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
776
795
  }
777
796
  return {
778
797
  loaded: isLoaded,
779
- sdkVersion: "1.36.0" ,
798
+ sdkVersion: "1.36.2" ,
780
799
  };
781
800
  };
782
801
 
package/index.js CHANGED
@@ -113,6 +113,18 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
113
113
  ...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
114
114
  ]);
115
115
 
116
+ function tryParse(json, fallbackValue) {
117
+ try {
118
+ if (json) {
119
+ return JSON.parse(json);
120
+ }
121
+ }
122
+ catch {
123
+ /* do nothing */
124
+ }
125
+ return fallbackValue;
126
+ }
127
+
116
128
  /**
117
129
  * ISO-3166 2-leter country codes and their names
118
130
  * @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
@@ -435,6 +447,13 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
435
447
  ]);
436
448
  new Set([...isoCountries.keys(), ...usStates.keys()]);
437
449
 
450
+ /** This function will create a deep copy using JSON stringify/parse
451
+ * that will also remove all methods from the incoming objects. Use
452
+ * this function when cloning user-provided objects since structuredClone
453
+ * will throw an error if given an object with functions.
454
+ */
455
+ const jsonClone = (json) => tryParse(JSON.stringify(json), undefined);
456
+
438
457
  // eslint-disable-next-line @nx/enforce-module-boundaries
439
458
  const getGoogleConsentFromCategories = (categories) => {
440
459
  const analyticsConsent = isCategoryConsented(categories, 'analytics');
@@ -711,7 +730,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
711
730
  if (manifestVariables['debug'] === '1') {
712
731
  eventData['debug_mode'] = true;
713
732
  }
714
- const rawData = structuredClone(data !== null && data !== void 0 ? data : {});
733
+ const rawData = jsonClone(data !== null && data !== void 0 ? data : {});
715
734
  if ('items' in eventData) {
716
735
  delete rawData['contents'];
717
736
  }
@@ -777,7 +796,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
777
796
  }
778
797
  return {
779
798
  loaded: isLoaded,
780
- sdkVersion: "1.36.0" ,
799
+ sdkVersion: "1.36.2" ,
781
800
  };
782
801
  };
783
802
 
package/index.mjs CHANGED
@@ -110,6 +110,18 @@ new Set([
110
110
  ...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
111
111
  ]);
112
112
 
113
+ function tryParse(json, fallbackValue) {
114
+ try {
115
+ if (json) {
116
+ return JSON.parse(json);
117
+ }
118
+ }
119
+ catch {
120
+ /* do nothing */
121
+ }
122
+ return fallbackValue;
123
+ }
124
+
113
125
  /**
114
126
  * ISO-3166 2-leter country codes and their names
115
127
  * @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
@@ -432,6 +444,13 @@ const usStates = new Map([
432
444
  ]);
433
445
  new Set([...isoCountries.keys(), ...usStates.keys()]);
434
446
 
447
+ /** This function will create a deep copy using JSON stringify/parse
448
+ * that will also remove all methods from the incoming objects. Use
449
+ * this function when cloning user-provided objects since structuredClone
450
+ * will throw an error if given an object with functions.
451
+ */
452
+ const jsonClone = (json) => tryParse(JSON.stringify(json), undefined);
453
+
435
454
  // eslint-disable-next-line @nx/enforce-module-boundaries
436
455
  const getGoogleConsentFromCategories = (categories) => {
437
456
  const analyticsConsent = isCategoryConsented(categories, 'analytics');
@@ -708,7 +727,7 @@ const handleTag = ({ data = {}, eventName, eventId, manifestVariables, }) => {
708
727
  if (manifestVariables['debug'] === '1') {
709
728
  eventData['debug_mode'] = true;
710
729
  }
711
- const rawData = structuredClone(data !== null && data !== void 0 ? data : {});
730
+ const rawData = jsonClone(data !== null && data !== void 0 ? data : {});
712
731
  if ('items' in eventData) {
713
732
  delete rawData['contents'];
714
733
  }
@@ -774,7 +793,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
774
793
  }
775
794
  return {
776
795
  loaded: isLoaded,
777
- sdkVersion: "1.36.0" ,
796
+ sdkVersion: "1.36.2" ,
778
797
  };
779
798
  };
780
799
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-analytics-4-sdk",
3
- "version": "1.36.0",
3
+ "version": "1.36.2",
4
4
  "description": "Google Analytics 4 Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",