@blotoutio/edgetag-sdk-browser 1.21.0 → 1.21.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 +70 -27
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,24 +24,42 @@
|
|
|
24
24
|
* It should be used in conjunction with `UserConsent`, not `ProvidersConfig`.
|
|
25
25
|
*/
|
|
26
26
|
const hasUserConsent = (consent, provider, tagName) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if ('all' in providerSpecific && isBool(providerSpecific.all)) {
|
|
38
|
-
allowed = providerSpecific.all;
|
|
27
|
+
var _a, _b;
|
|
28
|
+
let allowed = false;
|
|
29
|
+
if (isRecord(consent.consentChannel)) {
|
|
30
|
+
allowed = isBool(consent.consentChannel.all)
|
|
31
|
+
? consent.consentChannel.all
|
|
32
|
+
: false;
|
|
33
|
+
if (provider in consent.consentChannel) {
|
|
34
|
+
const providerSpecific = consent.consentChannel[provider];
|
|
35
|
+
if (isBool(providerSpecific)) {
|
|
36
|
+
allowed = providerSpecific;
|
|
39
37
|
}
|
|
40
|
-
if (
|
|
41
|
-
|
|
38
|
+
else if (isRecord(providerSpecific)) {
|
|
39
|
+
if ('all' in providerSpecific && isBool(providerSpecific.all)) {
|
|
40
|
+
allowed = providerSpecific.all;
|
|
41
|
+
}
|
|
42
|
+
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
43
|
+
allowed = providerSpecific[tagName];
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
|
48
|
+
if (allowed) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (isRecord(consent.consentCategory) &&
|
|
52
|
+
isRecord((_a = consent.consentSettings) === null || _a === void 0 ? void 0 : _a.channels)) {
|
|
53
|
+
allowed = isBool(consent.consentCategory.all)
|
|
54
|
+
? consent.consentCategory.all
|
|
55
|
+
: false;
|
|
56
|
+
const category = (_b = Object.entries(consent.consentSettings.channels).find(([, value]) => {
|
|
57
|
+
return value.includes(provider);
|
|
58
|
+
})) === null || _b === void 0 ? void 0 : _b[0];
|
|
59
|
+
if (category && consent.consentCategory[category]) {
|
|
60
|
+
allowed = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
45
63
|
return allowed;
|
|
46
64
|
};
|
|
47
65
|
/**
|
|
@@ -502,6 +520,10 @@
|
|
|
502
520
|
geoCountry: null,
|
|
503
521
|
geoRegion: null,
|
|
504
522
|
isEURequest: false,
|
|
523
|
+
consentSetting: {
|
|
524
|
+
enabled: false,
|
|
525
|
+
channels: {},
|
|
526
|
+
},
|
|
505
527
|
...options,
|
|
506
528
|
};
|
|
507
529
|
};
|
|
@@ -927,7 +949,7 @@
|
|
|
927
949
|
referrer: getReferrer(destination),
|
|
928
950
|
search: getSearch(destination),
|
|
929
951
|
locale: getLocale(),
|
|
930
|
-
sdkVersion: "1.21.
|
|
952
|
+
sdkVersion: "1.21.2" ,
|
|
931
953
|
...(payload || {}),
|
|
932
954
|
};
|
|
933
955
|
let storage = {};
|
|
@@ -1133,7 +1155,10 @@
|
|
|
1133
1155
|
const sessionId = getSetting(destination, 'sessionId');
|
|
1134
1156
|
const userId = getUserId$1(destination);
|
|
1135
1157
|
const providerData = {};
|
|
1136
|
-
const
|
|
1158
|
+
const consentChannel = getConsent$1(destination);
|
|
1159
|
+
const consentCategory = getConsentCategories(destination);
|
|
1160
|
+
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1161
|
+
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1137
1162
|
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
1138
1163
|
return;
|
|
1139
1164
|
}
|
|
@@ -1154,7 +1179,7 @@
|
|
|
1154
1179
|
logger.log(`Provider instance is not allowed (${pkg.name}: ${variable.tagName})`);
|
|
1155
1180
|
continue;
|
|
1156
1181
|
}
|
|
1157
|
-
if (!hasUserConsent(
|
|
1182
|
+
if (!hasUserConsent(userConsent, pkg.name, variable.tagName)) {
|
|
1158
1183
|
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
1159
1184
|
continue;
|
|
1160
1185
|
}
|
|
@@ -1181,7 +1206,7 @@
|
|
|
1181
1206
|
}
|
|
1182
1207
|
providerData[pkg.name] = result;
|
|
1183
1208
|
}
|
|
1184
|
-
if (!hasAllowedManifestTags(configuredTags,
|
|
1209
|
+
if (!hasAllowedManifestTags(configuredTags, userConsent, providers)) {
|
|
1185
1210
|
return;
|
|
1186
1211
|
}
|
|
1187
1212
|
sendTag(destination, {
|
|
@@ -1219,10 +1244,13 @@
|
|
|
1219
1244
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1220
1245
|
const configuredTags = getSetting(destination, 'channels');
|
|
1221
1246
|
const userId = getUserId$1(destination);
|
|
1222
|
-
const consent = getConsent$1(destination);
|
|
1223
1247
|
const requestCountry = getSetting(destination, 'geoCountry') || null;
|
|
1224
1248
|
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1225
1249
|
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1250
|
+
const consentChannel = getConsent$1(destination);
|
|
1251
|
+
const consentCategory = getConsentCategories(destination);
|
|
1252
|
+
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1253
|
+
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1226
1254
|
for (const pkg of providerPackages) {
|
|
1227
1255
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
1228
1256
|
continue;
|
|
@@ -1237,7 +1265,7 @@
|
|
|
1237
1265
|
logger.log(`Data not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1238
1266
|
continue;
|
|
1239
1267
|
}
|
|
1240
|
-
if (!hasUserConsent(
|
|
1268
|
+
if (!hasUserConsent(userConsent, pkg.name, variable.tagName)) {
|
|
1241
1269
|
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
1242
1270
|
continue;
|
|
1243
1271
|
}
|
|
@@ -1313,6 +1341,7 @@
|
|
|
1313
1341
|
const requestCountry = getSetting(destination, 'geoCountry') || null;
|
|
1314
1342
|
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1315
1343
|
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1344
|
+
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1316
1345
|
/* Calling Init for all provider instances based on consent check */
|
|
1317
1346
|
for (const pkg of providerPackages) {
|
|
1318
1347
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
@@ -1320,7 +1349,11 @@
|
|
|
1320
1349
|
}
|
|
1321
1350
|
const variables = getProviderVariables(destination, pkg.name);
|
|
1322
1351
|
for (const variable of variables) {
|
|
1323
|
-
const hasConsent = hasUserConsent(
|
|
1352
|
+
const hasConsent = hasUserConsent({
|
|
1353
|
+
consentChannel: consent,
|
|
1354
|
+
consentCategory: consentCategories,
|
|
1355
|
+
consentSettings,
|
|
1356
|
+
}, pkg.name, variable.tagName);
|
|
1324
1357
|
if (!hasConsent) {
|
|
1325
1358
|
continue;
|
|
1326
1359
|
}
|
|
@@ -1347,6 +1380,7 @@
|
|
|
1347
1380
|
consentData: {
|
|
1348
1381
|
consent,
|
|
1349
1382
|
categories: { ...consentCategories, necessary: true },
|
|
1383
|
+
consentSettings,
|
|
1350
1384
|
},
|
|
1351
1385
|
});
|
|
1352
1386
|
}
|
|
@@ -1376,6 +1410,7 @@
|
|
|
1376
1410
|
...consentCategories,
|
|
1377
1411
|
necessary: true,
|
|
1378
1412
|
},
|
|
1413
|
+
consentSettings,
|
|
1379
1414
|
},
|
|
1380
1415
|
variables,
|
|
1381
1416
|
});
|
|
@@ -1530,6 +1565,10 @@
|
|
|
1530
1565
|
const userId = getUserId$1(destination);
|
|
1531
1566
|
const executionContext = new Map();
|
|
1532
1567
|
const manifest = response.result;
|
|
1568
|
+
const consentChannel = getConsent$1(destination);
|
|
1569
|
+
const consentCategory = getConsentCategories(destination);
|
|
1570
|
+
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1571
|
+
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1533
1572
|
manifest.forEach((provider) => {
|
|
1534
1573
|
addChannel(destination, provider.package, provider.tagName);
|
|
1535
1574
|
const pkg = providerPackages.find((pkg) => pkg.name === provider.package);
|
|
@@ -1544,8 +1583,7 @@
|
|
|
1544
1583
|
});
|
|
1545
1584
|
}
|
|
1546
1585
|
if (pkg && pkg.name && pkg.init) {
|
|
1547
|
-
|
|
1548
|
-
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
1586
|
+
const hasConsent = hasUserConsent(userConsent, pkg.name, provider.tagName);
|
|
1549
1587
|
if (hasConsent &&
|
|
1550
1588
|
doesGeoRequestMatchList(response.geoCountry, response.geoRegion, response.isEURequest, provider.geoRegions)) {
|
|
1551
1589
|
pkg.init({
|
|
@@ -1563,6 +1601,7 @@
|
|
|
1563
1601
|
consentData: {
|
|
1564
1602
|
consent: response.consent,
|
|
1565
1603
|
categories: response.consentCategories,
|
|
1604
|
+
consentSettings: response.consentSetting,
|
|
1566
1605
|
},
|
|
1567
1606
|
});
|
|
1568
1607
|
}
|
|
@@ -1691,6 +1730,7 @@
|
|
|
1691
1730
|
geoCountry: result.geoCountry,
|
|
1692
1731
|
geoRegion: result.geoRegion,
|
|
1693
1732
|
isEURequest: result.isEURequest,
|
|
1733
|
+
consentSetting: result.consentSetting,
|
|
1694
1734
|
});
|
|
1695
1735
|
if (result.storageId != null) {
|
|
1696
1736
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
@@ -1723,11 +1763,14 @@
|
|
|
1723
1763
|
});
|
|
1724
1764
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1725
1765
|
const configuredTags = getSetting(destination, 'channels');
|
|
1726
|
-
const consent = getConsent$1(destination);
|
|
1727
1766
|
const userId = getUserId$1(destination);
|
|
1728
1767
|
const requestCountry = getSetting(destination, 'geoCountry') || null;
|
|
1729
1768
|
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1730
1769
|
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1770
|
+
const consentChannel = getConsent$1(destination);
|
|
1771
|
+
const consentCategory = getConsentCategories(destination);
|
|
1772
|
+
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1773
|
+
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1731
1774
|
for (const pkg of providerPackages) {
|
|
1732
1775
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1733
1776
|
continue;
|
|
@@ -1742,7 +1785,7 @@
|
|
|
1742
1785
|
logger.log(`User not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1743
1786
|
continue;
|
|
1744
1787
|
}
|
|
1745
|
-
if (!hasUserConsent(
|
|
1788
|
+
if (!hasUserConsent(userConsent, pkg.name, variable.tagName)) {
|
|
1746
1789
|
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1747
1790
|
continue;
|
|
1748
1791
|
}
|
|
@@ -1865,8 +1908,8 @@
|
|
|
1865
1908
|
const tag = (name, data, providers, options) => {
|
|
1866
1909
|
handleTag(name, data, providers, options);
|
|
1867
1910
|
};
|
|
1868
|
-
const consent = (
|
|
1869
|
-
handleConsent(
|
|
1911
|
+
const consent = (consentChannels, consentCategories, options) => {
|
|
1912
|
+
handleConsent(consentChannels, consentCategories, options);
|
|
1870
1913
|
};
|
|
1871
1914
|
const user = (key, value, providers, options) => {
|
|
1872
1915
|
handleUser(key, value, providers, options);
|