@blotoutio/edgetag-sdk-browser 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.js +26 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -132,6 +132,18 @@
|
|
|
132
132
|
...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'),
|
|
133
133
|
]);
|
|
134
134
|
|
|
135
|
+
function tryParse(json, fallbackValue) {
|
|
136
|
+
try {
|
|
137
|
+
if (json) {
|
|
138
|
+
return JSON.parse(json);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
/* do nothing */
|
|
143
|
+
}
|
|
144
|
+
return fallbackValue;
|
|
145
|
+
}
|
|
146
|
+
|
|
135
147
|
const isZeroPurchaseEvent = (payload) => {
|
|
136
148
|
var _a;
|
|
137
149
|
if (payload.eventName != 'Purchase') {
|
|
@@ -809,6 +821,13 @@
|
|
|
809
821
|
};
|
|
810
822
|
};
|
|
811
823
|
|
|
824
|
+
/** This function will create a deep copy using JSON stringify/parse
|
|
825
|
+
* that will also remove all methods from the incoming objects. Use
|
|
826
|
+
* this function when cloning user-provided objects since structuredClone
|
|
827
|
+
* will throw an error if given an object with functions.
|
|
828
|
+
*/
|
|
829
|
+
const jsonClone = (json) => tryParse(JSON.stringify(json), undefined);
|
|
830
|
+
|
|
812
831
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
813
832
|
const getGlobalSettings = () => {
|
|
814
833
|
var _a;
|
|
@@ -1265,7 +1284,7 @@
|
|
|
1265
1284
|
referrer: getReferrer(destination),
|
|
1266
1285
|
search: getSearch(destination),
|
|
1267
1286
|
locale: getLocale(),
|
|
1268
|
-
sdkVersion: "1.36.
|
|
1287
|
+
sdkVersion: "1.36.2" ,
|
|
1269
1288
|
...(payload || {}),
|
|
1270
1289
|
};
|
|
1271
1290
|
let storage = {};
|
|
@@ -1483,11 +1502,11 @@
|
|
|
1483
1502
|
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
1484
1503
|
return;
|
|
1485
1504
|
}
|
|
1486
|
-
const originalData =
|
|
1487
|
-
const originalProviders =
|
|
1505
|
+
const originalData = jsonClone(data);
|
|
1506
|
+
const originalProviders = jsonClone(providers);
|
|
1488
1507
|
const rules = (getSetting(destination, 'configuratorSetting') ||
|
|
1489
1508
|
[]);
|
|
1490
|
-
const rulesResult = evaluateEventRules(rules,
|
|
1509
|
+
const rulesResult = evaluateEventRules(rules, jsonClone({ eventName, data }), providers !== null && providers !== void 0 ? providers : undefined, userProperties || {});
|
|
1491
1510
|
if (!rulesResult.skipEvent) {
|
|
1492
1511
|
if (rulesResult.updatedPayload) {
|
|
1493
1512
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1498,7 +1517,7 @@
|
|
|
1498
1517
|
providers = rulesResult.updatedProviders;
|
|
1499
1518
|
}
|
|
1500
1519
|
if (!rulesResult.skipBrowserEvent) {
|
|
1501
|
-
const conversion = preparePayloadWithConversion(
|
|
1520
|
+
const conversion = preparePayloadWithConversion(jsonClone(data), getSetting(destination, 'currency'));
|
|
1502
1521
|
for (const pkg of providerPackages) {
|
|
1503
1522
|
if (!pkg || !pkg.name || !pkg.tag) {
|
|
1504
1523
|
continue;
|
|
@@ -1532,7 +1551,7 @@
|
|
|
1532
1551
|
sessionId,
|
|
1533
1552
|
eventName,
|
|
1534
1553
|
eventId,
|
|
1535
|
-
data:
|
|
1554
|
+
data: jsonClone(payload),
|
|
1536
1555
|
sendTag: sendTag.bind(null, destination),
|
|
1537
1556
|
getEdgeData: processGetData.bind(null, destination),
|
|
1538
1557
|
manifestVariables: variable.variableSet,
|
|
@@ -1564,7 +1583,7 @@
|
|
|
1564
1583
|
}
|
|
1565
1584
|
const additionalEvents = rulesResult.additionalEvents || [];
|
|
1566
1585
|
for (const additionalEventName of additionalEvents) {
|
|
1567
|
-
handleTag(additionalEventName,
|
|
1586
|
+
handleTag(additionalEventName, jsonClone(originalData || {}), originalProviders, options);
|
|
1568
1587
|
}
|
|
1569
1588
|
};
|
|
1570
1589
|
const handleTag = (eventName, data = {}, providers, options) => {
|