@blotoutio/edgetag-sdk-js 1.36.0 → 1.36.1

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 (3) hide show
  1. package/index.cjs.js +14 -7
  2. package/index.mjs +14 -7
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -808,6 +808,13 @@ const evaluateEventRules = (rules, payload, providers, userData = {}) => {
808
808
  };
809
809
  };
810
810
 
811
+ /** This function will create a deep copy using JSON stringify/parse
812
+ * that will also remove all methods from the incoming objects. Use
813
+ * this function when cloning user-provided objects since structuredClone
814
+ * will throw an error if given an object with functions.
815
+ */
816
+ const jsonClone = (json) => JSON.parse(JSON.stringify(json));
817
+
811
818
  // eslint-disable-next-line @nx/enforce-module-boundaries
812
819
  const getGlobalSettings = () => {
813
820
  var _a;
@@ -1264,7 +1271,7 @@ const getStandardPayload = (destination, payload) => {
1264
1271
  referrer: getReferrer(destination),
1265
1272
  search: getSearch(destination),
1266
1273
  locale: getLocale(),
1267
- sdkVersion: "1.36.0" ,
1274
+ sdkVersion: "1.36.1" ,
1268
1275
  ...(payload || {}),
1269
1276
  };
1270
1277
  let storage = {};
@@ -1482,11 +1489,11 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1482
1489
  if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
1483
1490
  return;
1484
1491
  }
1485
- const originalData = structuredClone(data);
1486
- const originalProviders = structuredClone(providers);
1492
+ const originalData = jsonClone(data);
1493
+ const originalProviders = jsonClone(providers);
1487
1494
  const rules = (getSetting(destination, 'configuratorSetting') ||
1488
1495
  []);
1489
- const rulesResult = evaluateEventRules(rules, structuredClone({ eventName, data }), providers !== null && providers !== void 0 ? providers : undefined, userProperties || {});
1496
+ const rulesResult = evaluateEventRules(rules, jsonClone({ eventName, data }), providers !== null && providers !== void 0 ? providers : undefined, userProperties || {});
1490
1497
  if (!rulesResult.skipEvent) {
1491
1498
  if (rulesResult.updatedPayload) {
1492
1499
  // eslint-disable-next-line no-param-reassign
@@ -1497,7 +1504,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1497
1504
  providers = rulesResult.updatedProviders;
1498
1505
  }
1499
1506
  if (!rulesResult.skipBrowserEvent) {
1500
- const conversion = preparePayloadWithConversion(JSON.parse(JSON.stringify(data)), getSetting(destination, 'currency'));
1507
+ const conversion = preparePayloadWithConversion(jsonClone(data), getSetting(destination, 'currency'));
1501
1508
  for (const pkg of providerPackages) {
1502
1509
  if (!pkg || !pkg.name || !pkg.tag) {
1503
1510
  continue;
@@ -1531,7 +1538,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1531
1538
  sessionId,
1532
1539
  eventName,
1533
1540
  eventId,
1534
- data: JSON.parse(JSON.stringify(payload)),
1541
+ data: jsonClone(payload),
1535
1542
  sendTag: sendTag.bind(null, destination),
1536
1543
  getEdgeData: processGetData.bind(null, destination),
1537
1544
  manifestVariables: variable.variableSet,
@@ -1563,7 +1570,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1563
1570
  }
1564
1571
  const additionalEvents = rulesResult.additionalEvents || [];
1565
1572
  for (const additionalEventName of additionalEvents) {
1566
- handleTag(additionalEventName, structuredClone(originalData || {}), originalProviders, options);
1573
+ handleTag(additionalEventName, jsonClone(originalData || {}), originalProviders, options);
1567
1574
  }
1568
1575
  };
1569
1576
  const handleTag = (eventName, data = {}, providers, options) => {
package/index.mjs CHANGED
@@ -806,6 +806,13 @@ const evaluateEventRules = (rules, payload, providers, userData = {}) => {
806
806
  };
807
807
  };
808
808
 
809
+ /** This function will create a deep copy using JSON stringify/parse
810
+ * that will also remove all methods from the incoming objects. Use
811
+ * this function when cloning user-provided objects since structuredClone
812
+ * will throw an error if given an object with functions.
813
+ */
814
+ const jsonClone = (json) => JSON.parse(JSON.stringify(json));
815
+
809
816
  // eslint-disable-next-line @nx/enforce-module-boundaries
810
817
  const getGlobalSettings = () => {
811
818
  var _a;
@@ -1262,7 +1269,7 @@ const getStandardPayload = (destination, payload) => {
1262
1269
  referrer: getReferrer(destination),
1263
1270
  search: getSearch(destination),
1264
1271
  locale: getLocale(),
1265
- sdkVersion: "1.36.0" ,
1272
+ sdkVersion: "1.36.1" ,
1266
1273
  ...(payload || {}),
1267
1274
  };
1268
1275
  let storage = {};
@@ -1480,11 +1487,11 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1480
1487
  if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
1481
1488
  return;
1482
1489
  }
1483
- const originalData = structuredClone(data);
1484
- const originalProviders = structuredClone(providers);
1490
+ const originalData = jsonClone(data);
1491
+ const originalProviders = jsonClone(providers);
1485
1492
  const rules = (getSetting(destination, 'configuratorSetting') ||
1486
1493
  []);
1487
- const rulesResult = evaluateEventRules(rules, structuredClone({ eventName, data }), providers !== null && providers !== void 0 ? providers : undefined, userProperties || {});
1494
+ const rulesResult = evaluateEventRules(rules, jsonClone({ eventName, data }), providers !== null && providers !== void 0 ? providers : undefined, userProperties || {});
1488
1495
  if (!rulesResult.skipEvent) {
1489
1496
  if (rulesResult.updatedPayload) {
1490
1497
  // eslint-disable-next-line no-param-reassign
@@ -1495,7 +1502,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1495
1502
  providers = rulesResult.updatedProviders;
1496
1503
  }
1497
1504
  if (!rulesResult.skipBrowserEvent) {
1498
- const conversion = preparePayloadWithConversion(JSON.parse(JSON.stringify(data)), getSetting(destination, 'currency'));
1505
+ const conversion = preparePayloadWithConversion(jsonClone(data), getSetting(destination, 'currency'));
1499
1506
  for (const pkg of providerPackages) {
1500
1507
  if (!pkg || !pkg.name || !pkg.tag) {
1501
1508
  continue;
@@ -1529,7 +1536,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1529
1536
  sessionId,
1530
1537
  eventName,
1531
1538
  eventId,
1532
- data: JSON.parse(JSON.stringify(payload)),
1539
+ data: jsonClone(payload),
1533
1540
  sendTag: sendTag.bind(null, destination),
1534
1541
  getEdgeData: processGetData.bind(null, destination),
1535
1542
  manifestVariables: variable.variableSet,
@@ -1561,7 +1568,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
1561
1568
  }
1562
1569
  const additionalEvents = rulesResult.additionalEvents || [];
1563
1570
  for (const additionalEventName of additionalEvents) {
1564
- handleTag(additionalEventName, structuredClone(originalData || {}), originalProviders, options);
1571
+ handleTag(additionalEventName, jsonClone(originalData || {}), originalProviders, options);
1565
1572
  }
1566
1573
  };
1567
1574
  const handleTag = (eventName, data = {}, providers, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "1.36.0",
3
+ "version": "1.36.1",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",