@blotoutio/edgetag-sdk-js 1.36.1 → 1.37.0
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 +35 -2
- package/index.mjs +35 -2
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -131,6 +131,18 @@ new Set([
|
|
|
131
131
|
...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'),
|
|
132
132
|
]);
|
|
133
133
|
|
|
134
|
+
function tryParse(json, fallbackValue) {
|
|
135
|
+
try {
|
|
136
|
+
if (json) {
|
|
137
|
+
return JSON.parse(json);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
/* do nothing */
|
|
142
|
+
}
|
|
143
|
+
return fallbackValue;
|
|
144
|
+
}
|
|
145
|
+
|
|
134
146
|
const isZeroPurchaseEvent = (payload) => {
|
|
135
147
|
var _a;
|
|
136
148
|
if (payload.eventName != 'Purchase') {
|
|
@@ -813,7 +825,7 @@ const evaluateEventRules = (rules, payload, providers, userData = {}) => {
|
|
|
813
825
|
* this function when cloning user-provided objects since structuredClone
|
|
814
826
|
* will throw an error if given an object with functions.
|
|
815
827
|
*/
|
|
816
|
-
const jsonClone = (json) =>
|
|
828
|
+
const jsonClone = (json) => tryParse(JSON.stringify(json), undefined);
|
|
817
829
|
|
|
818
830
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
819
831
|
const getGlobalSettings = () => {
|
|
@@ -980,6 +992,25 @@ const getInitData = (edgeURL, manifestResult) => ({
|
|
|
980
992
|
consentSetting: manifestResult.consentSetting,
|
|
981
993
|
session: manifestResult.session,
|
|
982
994
|
});
|
|
995
|
+
const updateUserProperties = (destination, data) => {
|
|
996
|
+
const configuratorSetting = getSetting(destination, 'configuratorSetting');
|
|
997
|
+
if (configuratorSetting === null || configuratorSetting === void 0 ? void 0 : configuratorSetting.length) {
|
|
998
|
+
const latestUserProperties = {};
|
|
999
|
+
if (data['email']) {
|
|
1000
|
+
latestUserProperties['hasEmail'] = true;
|
|
1001
|
+
}
|
|
1002
|
+
if (data['phone']) {
|
|
1003
|
+
latestUserProperties['hasPhone'] = true;
|
|
1004
|
+
}
|
|
1005
|
+
if (typeof data['isNewCustomer'] === 'string') {
|
|
1006
|
+
latestUserProperties['isNewCustomer'] = data['isNewCustomer'] === 'true';
|
|
1007
|
+
}
|
|
1008
|
+
const userProperties = getSetting(destination, 'userProperties');
|
|
1009
|
+
setSetting(destination, {
|
|
1010
|
+
userProperties: { ...userProperties, ...latestUserProperties },
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
983
1014
|
|
|
984
1015
|
const tagStorage = 'edgeTag';
|
|
985
1016
|
const consentKey = 'consent';
|
|
@@ -1271,7 +1302,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
1271
1302
|
referrer: getReferrer(destination),
|
|
1272
1303
|
search: getSearch(destination),
|
|
1273
1304
|
locale: getLocale(),
|
|
1274
|
-
sdkVersion: "1.
|
|
1305
|
+
sdkVersion: "1.37.0" ,
|
|
1275
1306
|
...(payload || {}),
|
|
1276
1307
|
};
|
|
1277
1308
|
let storage = {};
|
|
@@ -1596,6 +1627,7 @@ const hasAllowedManifestTags = (tags, consent, providersConfig) => {
|
|
|
1596
1627
|
|
|
1597
1628
|
const processData = (destination, data, providers, options) => {
|
|
1598
1629
|
saveKV(destination, data);
|
|
1630
|
+
updateUserProperties(destination, data);
|
|
1599
1631
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1600
1632
|
const configuredTags = getSetting(destination, 'channels');
|
|
1601
1633
|
const userId = getUserId$1(destination);
|
|
@@ -2126,6 +2158,7 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
2126
2158
|
saveKV(destination, {
|
|
2127
2159
|
[key]: value,
|
|
2128
2160
|
});
|
|
2161
|
+
updateUserProperties(destination, { [key]: value });
|
|
2129
2162
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
2130
2163
|
const configuredTags = getSetting(destination, 'channels');
|
|
2131
2164
|
const userId = getUserId$1(destination);
|
package/index.mjs
CHANGED
|
@@ -129,6 +129,18 @@ new Set([
|
|
|
129
129
|
...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'),
|
|
130
130
|
]);
|
|
131
131
|
|
|
132
|
+
function tryParse(json, fallbackValue) {
|
|
133
|
+
try {
|
|
134
|
+
if (json) {
|
|
135
|
+
return JSON.parse(json);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
/* do nothing */
|
|
140
|
+
}
|
|
141
|
+
return fallbackValue;
|
|
142
|
+
}
|
|
143
|
+
|
|
132
144
|
const isZeroPurchaseEvent = (payload) => {
|
|
133
145
|
var _a;
|
|
134
146
|
if (payload.eventName != 'Purchase') {
|
|
@@ -811,7 +823,7 @@ const evaluateEventRules = (rules, payload, providers, userData = {}) => {
|
|
|
811
823
|
* this function when cloning user-provided objects since structuredClone
|
|
812
824
|
* will throw an error if given an object with functions.
|
|
813
825
|
*/
|
|
814
|
-
const jsonClone = (json) =>
|
|
826
|
+
const jsonClone = (json) => tryParse(JSON.stringify(json), undefined);
|
|
815
827
|
|
|
816
828
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
817
829
|
const getGlobalSettings = () => {
|
|
@@ -978,6 +990,25 @@ const getInitData = (edgeURL, manifestResult) => ({
|
|
|
978
990
|
consentSetting: manifestResult.consentSetting,
|
|
979
991
|
session: manifestResult.session,
|
|
980
992
|
});
|
|
993
|
+
const updateUserProperties = (destination, data) => {
|
|
994
|
+
const configuratorSetting = getSetting(destination, 'configuratorSetting');
|
|
995
|
+
if (configuratorSetting === null || configuratorSetting === void 0 ? void 0 : configuratorSetting.length) {
|
|
996
|
+
const latestUserProperties = {};
|
|
997
|
+
if (data['email']) {
|
|
998
|
+
latestUserProperties['hasEmail'] = true;
|
|
999
|
+
}
|
|
1000
|
+
if (data['phone']) {
|
|
1001
|
+
latestUserProperties['hasPhone'] = true;
|
|
1002
|
+
}
|
|
1003
|
+
if (typeof data['isNewCustomer'] === 'string') {
|
|
1004
|
+
latestUserProperties['isNewCustomer'] = data['isNewCustomer'] === 'true';
|
|
1005
|
+
}
|
|
1006
|
+
const userProperties = getSetting(destination, 'userProperties');
|
|
1007
|
+
setSetting(destination, {
|
|
1008
|
+
userProperties: { ...userProperties, ...latestUserProperties },
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
981
1012
|
|
|
982
1013
|
const tagStorage = 'edgeTag';
|
|
983
1014
|
const consentKey = 'consent';
|
|
@@ -1269,7 +1300,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
1269
1300
|
referrer: getReferrer(destination),
|
|
1270
1301
|
search: getSearch(destination),
|
|
1271
1302
|
locale: getLocale(),
|
|
1272
|
-
sdkVersion: "1.
|
|
1303
|
+
sdkVersion: "1.37.0" ,
|
|
1273
1304
|
...(payload || {}),
|
|
1274
1305
|
};
|
|
1275
1306
|
let storage = {};
|
|
@@ -1594,6 +1625,7 @@ const hasAllowedManifestTags = (tags, consent, providersConfig) => {
|
|
|
1594
1625
|
|
|
1595
1626
|
const processData = (destination, data, providers, options) => {
|
|
1596
1627
|
saveKV(destination, data);
|
|
1628
|
+
updateUserProperties(destination, data);
|
|
1597
1629
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1598
1630
|
const configuredTags = getSetting(destination, 'channels');
|
|
1599
1631
|
const userId = getUserId$1(destination);
|
|
@@ -2124,6 +2156,7 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
2124
2156
|
saveKV(destination, {
|
|
2125
2157
|
[key]: value,
|
|
2126
2158
|
});
|
|
2159
|
+
updateUserProperties(destination, { [key]: value });
|
|
2127
2160
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
2128
2161
|
const configuredTags = getSetting(destination, 'channels');
|
|
2129
2162
|
const userId = getUserId$1(destination);
|