@blotoutio/edgetag-sdk-browser 0.71.0 → 1.0.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.js +357 -36
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -43,25 +43,6 @@
|
|
|
43
43
|
}
|
|
44
44
|
return allowed;
|
|
45
45
|
};
|
|
46
|
-
/**
|
|
47
|
-
* This function validates user consent for a given provider type, not based on tagName.
|
|
48
|
-
*/
|
|
49
|
-
const hasUserConsentForProvider = (consent, provider) => {
|
|
50
|
-
if (!isRecord(consent)) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
let allowed = isBool(consent.all) ? consent.all : false;
|
|
54
|
-
if (provider in consent) {
|
|
55
|
-
const providerSpecific = consent[provider];
|
|
56
|
-
if (isBool(providerSpecific)) {
|
|
57
|
-
allowed = providerSpecific;
|
|
58
|
-
}
|
|
59
|
-
else if (isRecord(providerSpecific)) {
|
|
60
|
-
return Object.keys(providerSpecific).some((instance) => providerSpecific[instance] === true);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return allowed;
|
|
64
|
-
};
|
|
65
46
|
/**
|
|
66
47
|
* This function validates provider allowance for a given provider and tag name.
|
|
67
48
|
* It should not be used to validate `UserConsent`.
|
|
@@ -141,6 +122,283 @@
|
|
|
141
122
|
return value === 0;
|
|
142
123
|
};
|
|
143
124
|
|
|
125
|
+
/**
|
|
126
|
+
* ISO-3166 2-leter country codes and their names
|
|
127
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
128
|
+
*/
|
|
129
|
+
const isoCountries = new Map([
|
|
130
|
+
['AD', 'Andorra'],
|
|
131
|
+
['AE', 'United Arab Emirates'],
|
|
132
|
+
['AF', 'Afghanistan'],
|
|
133
|
+
['AG', 'Antigua and Barbuda'],
|
|
134
|
+
['AI', 'Anguilla'],
|
|
135
|
+
['AL', 'Albania'],
|
|
136
|
+
['AM', 'Armenia'],
|
|
137
|
+
['AO', 'Angola'],
|
|
138
|
+
['AQ', 'Antarctica'],
|
|
139
|
+
['AR', 'Argentina'],
|
|
140
|
+
['AS', 'American Samoa'],
|
|
141
|
+
['AT', 'Austria'],
|
|
142
|
+
['AU', 'Australia'],
|
|
143
|
+
['AW', 'Aruba'],
|
|
144
|
+
['AX', 'Åland Islands'],
|
|
145
|
+
['AZ', 'Azerbaijan'],
|
|
146
|
+
['BA', 'Bosnia and Herzegovina'],
|
|
147
|
+
['BB', 'Barbados'],
|
|
148
|
+
['BD', 'Bangladesh'],
|
|
149
|
+
['BE', 'Belgium'],
|
|
150
|
+
['BF', 'Burkina Faso'],
|
|
151
|
+
['BG', 'Bulgaria'],
|
|
152
|
+
['BH', 'Bahrain'],
|
|
153
|
+
['BI', 'Burundi'],
|
|
154
|
+
['BJ', 'Benin'],
|
|
155
|
+
['BL', 'Saint Barthélemy'],
|
|
156
|
+
['BM', 'Bermuda'],
|
|
157
|
+
['BN', 'Brunei Darussalam'],
|
|
158
|
+
['BO', 'Bolivia, Plurinational State of'],
|
|
159
|
+
['BQ', 'Bonaire, Sint Eustatius and Saba'],
|
|
160
|
+
['BR', 'Brazil'],
|
|
161
|
+
['BS', 'Bahamas'],
|
|
162
|
+
['BT', 'Bhutan'],
|
|
163
|
+
['BV', 'Bouvet Island'],
|
|
164
|
+
['BW', 'Botswana'],
|
|
165
|
+
['BY', 'Belarus'],
|
|
166
|
+
['BZ', 'Belize'],
|
|
167
|
+
['CA', 'Canada'],
|
|
168
|
+
['CC', 'Cocos (Keeling) Islands'],
|
|
169
|
+
['CD', 'Congo, Democratic Republic of the'],
|
|
170
|
+
['CF', 'Central African Republic'],
|
|
171
|
+
['CG', 'Congo'],
|
|
172
|
+
['CH', 'Switzerland'],
|
|
173
|
+
['CI', "Côte d'Ivoire"],
|
|
174
|
+
['CK', 'Cook Islands'],
|
|
175
|
+
['CL', 'Chile'],
|
|
176
|
+
['CM', 'Cameroon'],
|
|
177
|
+
['CN', 'China'],
|
|
178
|
+
['CO', 'Colombia'],
|
|
179
|
+
['CR', 'Costa Rica'],
|
|
180
|
+
['CU', 'Cuba'],
|
|
181
|
+
['CV', 'Cabo Verde'],
|
|
182
|
+
['CW', 'Curaçao'],
|
|
183
|
+
['CX', 'Christmas Island'],
|
|
184
|
+
['CY', 'Cyprus'],
|
|
185
|
+
['CZ', 'Czechia'],
|
|
186
|
+
['DE', 'Germany'],
|
|
187
|
+
['DJ', 'Djibouti'],
|
|
188
|
+
['DK', 'Denmark'],
|
|
189
|
+
['DM', 'Dominica'],
|
|
190
|
+
['DO', 'Dominican Republic'],
|
|
191
|
+
['DZ', 'Algeria'],
|
|
192
|
+
['EC', 'Ecuador'],
|
|
193
|
+
['EE', 'Estonia'],
|
|
194
|
+
['EG', 'Egypt'],
|
|
195
|
+
['EH', 'Western Sahara'],
|
|
196
|
+
['ER', 'Eritrea'],
|
|
197
|
+
['ES', 'Spain'],
|
|
198
|
+
['ET', 'Ethiopia'],
|
|
199
|
+
['EU', 'European Union'],
|
|
200
|
+
['FI', 'Finland'],
|
|
201
|
+
['FJ', 'Fiji'],
|
|
202
|
+
['FK', 'Falkland Islands (Malvinas)'],
|
|
203
|
+
['FM', 'Micronesia, Federated States of'],
|
|
204
|
+
['FO', 'Faroe Islands'],
|
|
205
|
+
['FR', 'France'],
|
|
206
|
+
['GA', 'Gabon'],
|
|
207
|
+
['GB', 'United Kingdom of Great Britain and Northern Ireland'],
|
|
208
|
+
['GD', 'Grenada'],
|
|
209
|
+
['GE', 'Georgia'],
|
|
210
|
+
['GF', 'French Guiana'],
|
|
211
|
+
['GG', 'Guernsey'],
|
|
212
|
+
['GH', 'Ghana'],
|
|
213
|
+
['GI', 'Gibraltar'],
|
|
214
|
+
['GL', 'Greenland'],
|
|
215
|
+
['GM', 'Gambia'],
|
|
216
|
+
['GN', 'Guinea'],
|
|
217
|
+
['GP', 'Guadeloupe'],
|
|
218
|
+
['GQ', 'Equatorial Guinea'],
|
|
219
|
+
['GR', 'Greece'],
|
|
220
|
+
['GS', 'South Georgia and the South Sandwich Islands'],
|
|
221
|
+
['GT', 'Guatemala'],
|
|
222
|
+
['GU', 'Guam'],
|
|
223
|
+
['GW', 'Guinea-Bissau'],
|
|
224
|
+
['GY', 'Guyana'],
|
|
225
|
+
['HK', 'Hong Kong'],
|
|
226
|
+
['HM', 'Heard Island and McDonald Islands'],
|
|
227
|
+
['HN', 'Honduras'],
|
|
228
|
+
['HR', 'Croatia'],
|
|
229
|
+
['HT', 'Haiti'],
|
|
230
|
+
['HU', 'Hungary'],
|
|
231
|
+
['ID', 'Indonesia'],
|
|
232
|
+
['IE', 'Ireland'],
|
|
233
|
+
['IL', 'Israel'],
|
|
234
|
+
['IM', 'Isle of Man'],
|
|
235
|
+
['IN', 'India'],
|
|
236
|
+
['IO', 'British Indian Ocean Territory'],
|
|
237
|
+
['IQ', 'Iraq'],
|
|
238
|
+
['IR', 'Iran, Islamic Republic of'],
|
|
239
|
+
['IS', 'Iceland'],
|
|
240
|
+
['IT', 'Italy'],
|
|
241
|
+
['JE', 'Jersey'],
|
|
242
|
+
['JM', 'Jamaica'],
|
|
243
|
+
['JO', 'Jordan'],
|
|
244
|
+
['JP', 'Japan'],
|
|
245
|
+
['KE', 'Kenya'],
|
|
246
|
+
['KG', 'Kyrgyzstan'],
|
|
247
|
+
['KH', 'Cambodia'],
|
|
248
|
+
['KI', 'Kiribati'],
|
|
249
|
+
['KM', 'Comoros'],
|
|
250
|
+
['KN', 'Saint Kitts and Nevis'],
|
|
251
|
+
['KP', "Korea, Democratic People's Republic of"],
|
|
252
|
+
['KR', 'Korea, Republic of'],
|
|
253
|
+
['KW', 'Kuwait'],
|
|
254
|
+
['KY', 'Cayman Islands'],
|
|
255
|
+
['KZ', 'Kazakhstan'],
|
|
256
|
+
['LA', "Lao People's Democratic Republic"],
|
|
257
|
+
['LB', 'Lebanon'],
|
|
258
|
+
['LC', 'Saint Lucia'],
|
|
259
|
+
['LI', 'Liechtenstein'],
|
|
260
|
+
['LK', 'Sri Lanka'],
|
|
261
|
+
['LR', 'Liberia'],
|
|
262
|
+
['LS', 'Lesotho'],
|
|
263
|
+
['LT', 'Lithuania'],
|
|
264
|
+
['LU', 'Luxembourg'],
|
|
265
|
+
['LV', 'Latvia'],
|
|
266
|
+
['LY', 'Libya'],
|
|
267
|
+
['MA', 'Morocco'],
|
|
268
|
+
['MC', 'Monaco'],
|
|
269
|
+
['MD', 'Moldova, Republic of'],
|
|
270
|
+
['ME', 'Montenegro'],
|
|
271
|
+
['MF', 'Saint Martin (French part)'],
|
|
272
|
+
['MG', 'Madagascar'],
|
|
273
|
+
['MH', 'Marshall Islands'],
|
|
274
|
+
['MK', 'North Macedonia'],
|
|
275
|
+
['ML', 'Mali'],
|
|
276
|
+
['MM', 'Myanmar'],
|
|
277
|
+
['MN', 'Mongolia'],
|
|
278
|
+
['MO', 'Macao'],
|
|
279
|
+
['MP', 'Northern Mariana Islands'],
|
|
280
|
+
['MQ', 'Martinique'],
|
|
281
|
+
['MR', 'Mauritania'],
|
|
282
|
+
['MS', 'Montserrat'],
|
|
283
|
+
['MT', 'Malta'],
|
|
284
|
+
['MU', 'Mauritius'],
|
|
285
|
+
['MV', 'Maldives'],
|
|
286
|
+
['MW', 'Malawi'],
|
|
287
|
+
['MX', 'Mexico'],
|
|
288
|
+
['MY', 'Malaysia'],
|
|
289
|
+
['MZ', 'Mozambique'],
|
|
290
|
+
['NA', 'Namibia'],
|
|
291
|
+
['NC', 'New Caledonia'],
|
|
292
|
+
['NE', 'Niger'],
|
|
293
|
+
['NF', 'Norfolk Island'],
|
|
294
|
+
['NG', 'Nigeria'],
|
|
295
|
+
['NI', 'Nicaragua'],
|
|
296
|
+
['NL', 'Netherlands, Kingdom of the'],
|
|
297
|
+
['NO', 'Norway'],
|
|
298
|
+
['NP', 'Nepal'],
|
|
299
|
+
['NR', 'Nauru'],
|
|
300
|
+
['NU', 'Niue'],
|
|
301
|
+
['NZ', 'New Zealand'],
|
|
302
|
+
['OM', 'Oman'],
|
|
303
|
+
['PA', 'Panama'],
|
|
304
|
+
['PE', 'Peru'],
|
|
305
|
+
['PF', 'French Polynesia'],
|
|
306
|
+
['PG', 'Papua New Guinea'],
|
|
307
|
+
['PH', 'Philippines'],
|
|
308
|
+
['PK', 'Pakistan'],
|
|
309
|
+
['PL', 'Poland'],
|
|
310
|
+
['PM', 'Saint Pierre and Miquelon'],
|
|
311
|
+
['PN', 'Pitcairn'],
|
|
312
|
+
['PR', 'Puerto Rico'],
|
|
313
|
+
['PS', 'Palestine, State of'],
|
|
314
|
+
['PT', 'Portugal'],
|
|
315
|
+
['PW', 'Palau'],
|
|
316
|
+
['PY', 'Paraguay'],
|
|
317
|
+
['QA', 'Qatar'],
|
|
318
|
+
['RE', 'Réunion'],
|
|
319
|
+
['RO', 'Romania'],
|
|
320
|
+
['RS', 'Serbia'],
|
|
321
|
+
['RU', 'Russian Federation'],
|
|
322
|
+
['RW', 'Rwanda'],
|
|
323
|
+
['SA', 'Saudi Arabia'],
|
|
324
|
+
['SB', 'Solomon Islands'],
|
|
325
|
+
['SC', 'Seychelles'],
|
|
326
|
+
['SD', 'Sudan'],
|
|
327
|
+
['SE', 'Sweden'],
|
|
328
|
+
['SG', 'Singapore'],
|
|
329
|
+
['SH', 'Saint Helena, Ascension and Tristan da Cunha'],
|
|
330
|
+
['SI', 'Slovenia'],
|
|
331
|
+
['SJ', 'Svalbard and Jan Mayen'],
|
|
332
|
+
['SK', 'Slovakia'],
|
|
333
|
+
['SL', 'Sierra Leone'],
|
|
334
|
+
['SM', 'San Marino'],
|
|
335
|
+
['SN', 'Senegal'],
|
|
336
|
+
['SO', 'Somalia'],
|
|
337
|
+
['SR', 'Suriname'],
|
|
338
|
+
['SS', 'South Sudan'],
|
|
339
|
+
['ST', 'Sao Tome and Principe'],
|
|
340
|
+
['SV', 'El Salvador'],
|
|
341
|
+
['SX', 'Sint Maarten (Dutch part)'],
|
|
342
|
+
['SY', 'Syrian Arab Republic'],
|
|
343
|
+
['SZ', 'Eswatini'],
|
|
344
|
+
['TC', 'Turks and Caicos Islands'],
|
|
345
|
+
['TD', 'Chad'],
|
|
346
|
+
['TF', 'French Southern Territories'],
|
|
347
|
+
['TG', 'Togo'],
|
|
348
|
+
['TH', 'Thailand'],
|
|
349
|
+
['TJ', 'Tajikistan'],
|
|
350
|
+
['TK', 'Tokelau'],
|
|
351
|
+
['TL', 'Timor-Leste'],
|
|
352
|
+
['TM', 'Turkmenistan'],
|
|
353
|
+
['TN', 'Tunisia'],
|
|
354
|
+
['TO', 'Tonga'],
|
|
355
|
+
['TR', 'Türkiye'],
|
|
356
|
+
['TT', 'Trinidad and Tobago'],
|
|
357
|
+
['TV', 'Tuvalu'],
|
|
358
|
+
['TW', 'Taiwan, Province of China'],
|
|
359
|
+
['TZ', 'Tanzania, United Republic of'],
|
|
360
|
+
['UA', 'Ukraine'],
|
|
361
|
+
['UG', 'Uganda'],
|
|
362
|
+
['UK', 'United Kingdom'],
|
|
363
|
+
['UM', 'United States Minor Outlying Islands'],
|
|
364
|
+
['US', 'United States of America'],
|
|
365
|
+
['UY', 'Uruguay'],
|
|
366
|
+
['UZ', 'Uzbekistan'],
|
|
367
|
+
['VA', 'Holy See'],
|
|
368
|
+
['VC', 'Saint Vincent and the Grenadines'],
|
|
369
|
+
['VE', 'Venezuela, Bolivarian Republic of'],
|
|
370
|
+
['VG', 'Virgin Islands (British)'],
|
|
371
|
+
['VI', 'Virgin Islands (U.S.)'],
|
|
372
|
+
['VN', 'Viet Nam'],
|
|
373
|
+
['VU', 'Vanuatu'],
|
|
374
|
+
['WF', 'Wallis and Futuna'],
|
|
375
|
+
['WS', 'Samoa'],
|
|
376
|
+
['YE', 'Yemen'],
|
|
377
|
+
['YT', 'Mayotte'],
|
|
378
|
+
['ZA', 'South Africa'],
|
|
379
|
+
['ZM', 'Zambia'],
|
|
380
|
+
['ZW', 'Zimbabwe'],
|
|
381
|
+
]);
|
|
382
|
+
new Set(isoCountries.keys());
|
|
383
|
+
const parseCache = new Map();
|
|
384
|
+
const doesGeoRequestMatchList = (requestRegion, isEUCountry, geoRegions) => {
|
|
385
|
+
if (!requestRegion || !geoRegions) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
let parsedRegions = parseCache.get(geoRegions);
|
|
389
|
+
if (!parsedRegions) {
|
|
390
|
+
parsedRegions = new Set((geoRegions !== null && geoRegions !== void 0 ? geoRegions : '').split(','));
|
|
391
|
+
parseCache.set(geoRegions, parsedRegions);
|
|
392
|
+
}
|
|
393
|
+
if (parsedRegions.size == 0) {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
if (isEUCountry && parsedRegions.has('EU')) {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
return parsedRegions.has(requestRegion);
|
|
400
|
+
};
|
|
401
|
+
|
|
144
402
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
145
403
|
let edgeTagSettings;
|
|
146
404
|
const initSettings = (destination, options) => {
|
|
@@ -153,6 +411,8 @@
|
|
|
153
411
|
stubs: [],
|
|
154
412
|
browserPackages: [],
|
|
155
413
|
channels: new Map(),
|
|
414
|
+
geoRegion: null,
|
|
415
|
+
isEURequest: false,
|
|
156
416
|
...options,
|
|
157
417
|
};
|
|
158
418
|
};
|
|
@@ -191,6 +451,7 @@
|
|
|
191
451
|
.filter((pkg) => pkg.package === packageId)
|
|
192
452
|
.map((pkg) => ({
|
|
193
453
|
tagName: pkg.tagName,
|
|
454
|
+
geoRegions: pkg.geoRegions || null,
|
|
194
455
|
variableSet: pkg.variables || {},
|
|
195
456
|
})) || []);
|
|
196
457
|
};
|
|
@@ -285,6 +546,7 @@
|
|
|
285
546
|
|
|
286
547
|
const tagStorage = 'edgeTag';
|
|
287
548
|
const consentKey = 'consent';
|
|
549
|
+
const consentCategoriesKey = 'consentCategories';
|
|
288
550
|
const keyPrefix = `_worker`;
|
|
289
551
|
const cookieKey = 'tag_user_id';
|
|
290
552
|
const fallbackSessionKey = 'fallback_tag_user_id';
|
|
@@ -572,7 +834,7 @@
|
|
|
572
834
|
referrer: getReferrer(destination),
|
|
573
835
|
search: getSearch(destination),
|
|
574
836
|
locale: getLocale(),
|
|
575
|
-
sdkVersion: "0.
|
|
837
|
+
sdkVersion: "1.0.0" ,
|
|
576
838
|
...(payload || {}),
|
|
577
839
|
};
|
|
578
840
|
let storage = {};
|
|
@@ -662,6 +924,13 @@
|
|
|
662
924
|
}
|
|
663
925
|
return getSetting(destination, 'consent');
|
|
664
926
|
};
|
|
927
|
+
const getConsentCategories = (destination) => {
|
|
928
|
+
const storageConsentCategories = getDataPerKey(destination, 'local', tagStorage, consentCategoriesKey);
|
|
929
|
+
if (storageConsentCategories) {
|
|
930
|
+
return storageConsentCategories;
|
|
931
|
+
}
|
|
932
|
+
return getSetting(destination, 'consentCategories');
|
|
933
|
+
};
|
|
665
934
|
|
|
666
935
|
const processStubs = (destination) => {
|
|
667
936
|
try {
|
|
@@ -740,6 +1009,8 @@
|
|
|
740
1009
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
741
1010
|
const configuredTags = getSetting(destination, 'channels');
|
|
742
1011
|
const skipZeroPurchaseEvent = getSetting(destination, 'skipZeroPurchaseEvent') || false;
|
|
1012
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1013
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
743
1014
|
const userId = getUserId$1(destination);
|
|
744
1015
|
const providerData = {};
|
|
745
1016
|
const consent = getConsent$1(destination);
|
|
@@ -767,6 +1038,10 @@
|
|
|
767
1038
|
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
768
1039
|
continue;
|
|
769
1040
|
}
|
|
1041
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1042
|
+
logger.log('GEO request region does not match the filter, skiping');
|
|
1043
|
+
continue;
|
|
1044
|
+
}
|
|
770
1045
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
771
1046
|
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(pkg.name))
|
|
772
1047
|
? conversion.payload
|
|
@@ -848,6 +1123,8 @@
|
|
|
848
1123
|
const configuredTags = getSetting(destination, 'channels');
|
|
849
1124
|
const userId = getUserId$1(destination);
|
|
850
1125
|
const consent = getConsent$1(destination);
|
|
1126
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1127
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
851
1128
|
for (const pkg of providerPackages) {
|
|
852
1129
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
853
1130
|
continue;
|
|
@@ -866,6 +1143,10 @@
|
|
|
866
1143
|
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
867
1144
|
continue;
|
|
868
1145
|
}
|
|
1146
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1147
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
869
1150
|
pkg.user({
|
|
870
1151
|
userId,
|
|
871
1152
|
data,
|
|
@@ -889,43 +1170,50 @@
|
|
|
889
1170
|
});
|
|
890
1171
|
};
|
|
891
1172
|
|
|
892
|
-
const handleConsent = (consent, options) => {
|
|
1173
|
+
const handleConsent = (consent, consentCategories, options) => {
|
|
893
1174
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
894
|
-
processConsent(options.destination, consent, options);
|
|
1175
|
+
processConsent(options.destination, consent, consentCategories, options);
|
|
895
1176
|
return;
|
|
896
1177
|
}
|
|
897
1178
|
getInstances().forEach((destination) => {
|
|
898
|
-
processConsent(destination, consent, options);
|
|
1179
|
+
processConsent(destination, consent, consentCategories, options);
|
|
899
1180
|
});
|
|
900
1181
|
};
|
|
901
|
-
const saveConsent = (destination, consent) => {
|
|
1182
|
+
const saveConsent = (destination, consent, consentCategories) => {
|
|
902
1183
|
setSetting(destination, {
|
|
903
1184
|
consent,
|
|
1185
|
+
consentCategories,
|
|
904
1186
|
});
|
|
905
1187
|
savePerKey(destination, 'local', tagStorage, consent, consentKey);
|
|
1188
|
+
savePerKey(destination, 'local', tagStorage, consentCategories, consentCategoriesKey);
|
|
906
1189
|
};
|
|
907
|
-
const processConsent = (destination, consent, options) => {
|
|
1190
|
+
const processConsent = (destination, consent, consentCategories, options) => {
|
|
908
1191
|
const existingConsent = getConsent$1(destination);
|
|
909
|
-
|
|
1192
|
+
const existingConsentCategories = getConsentCategories(destination);
|
|
1193
|
+
if (areEqual(existingConsent, consent) &&
|
|
1194
|
+
areEqual(existingConsentCategories, consentCategories)) {
|
|
910
1195
|
return;
|
|
911
1196
|
}
|
|
912
1197
|
if (!getSetting(destination, 'initialized')) {
|
|
913
1198
|
addStub(destination, {
|
|
914
1199
|
name: 'consent',
|
|
915
|
-
arguments: [consent, options],
|
|
1200
|
+
arguments: [consent, consentCategories, options],
|
|
916
1201
|
});
|
|
917
1202
|
return;
|
|
918
1203
|
}
|
|
919
1204
|
const payload = {
|
|
920
1205
|
consentString: consent,
|
|
1206
|
+
consentCategories: { ...consentCategories, necessary: true },
|
|
921
1207
|
};
|
|
922
|
-
saveConsent(destination, consent);
|
|
1208
|
+
saveConsent(destination, consent, consentCategories);
|
|
923
1209
|
if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
|
|
924
1210
|
postRequest(getConsentURL(destination), payload).catch(logger.error);
|
|
925
1211
|
}
|
|
926
1212
|
const userId = getUserId$1(destination);
|
|
927
1213
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
928
1214
|
const executionContext = new Map();
|
|
1215
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1216
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
929
1217
|
/* Calling Init for all provider instances based on consent check */
|
|
930
1218
|
for (const pkg of providerPackages) {
|
|
931
1219
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
@@ -937,6 +1225,9 @@
|
|
|
937
1225
|
if (!hasConsent) {
|
|
938
1226
|
continue;
|
|
939
1227
|
}
|
|
1228
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
940
1231
|
pkg.init({
|
|
941
1232
|
userId,
|
|
942
1233
|
isNewUser: false,
|
|
@@ -945,6 +1236,7 @@
|
|
|
945
1236
|
tagName: variable.tagName,
|
|
946
1237
|
variables: variable.variableSet,
|
|
947
1238
|
package: pkg.name,
|
|
1239
|
+
geoRegions: variable.geoRegions,
|
|
948
1240
|
},
|
|
949
1241
|
sendTag: sendTag.bind(null, destination),
|
|
950
1242
|
sendEdgeData: processData.bind(null, destination),
|
|
@@ -953,6 +1245,10 @@
|
|
|
953
1245
|
executionContext,
|
|
954
1246
|
session: null,
|
|
955
1247
|
destination,
|
|
1248
|
+
consentData: {
|
|
1249
|
+
consent,
|
|
1250
|
+
categories: { ...consentCategories, necessary: true },
|
|
1251
|
+
},
|
|
956
1252
|
});
|
|
957
1253
|
}
|
|
958
1254
|
}
|
|
@@ -973,9 +1269,17 @@
|
|
|
973
1269
|
if (!pkg || !pkg.name || !pkg.consent) {
|
|
974
1270
|
continue;
|
|
975
1271
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1272
|
+
const variables = getProviderVariables(destination, pkg.name);
|
|
1273
|
+
pkg.consent({
|
|
1274
|
+
consentData: {
|
|
1275
|
+
consent,
|
|
1276
|
+
categories: {
|
|
1277
|
+
...consentCategories,
|
|
1278
|
+
necessary: true,
|
|
1279
|
+
},
|
|
1280
|
+
},
|
|
1281
|
+
variables,
|
|
1282
|
+
});
|
|
979
1283
|
}
|
|
980
1284
|
};
|
|
981
1285
|
|
|
@@ -1143,7 +1447,8 @@
|
|
|
1143
1447
|
if (pkg && pkg.name && pkg.init) {
|
|
1144
1448
|
/* this defines if the consent is given for a specific instance of a provider */
|
|
1145
1449
|
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
1146
|
-
if (hasConsent
|
|
1450
|
+
if (hasConsent &&
|
|
1451
|
+
doesGeoRequestMatchList(response.geoRegion, response.isEURequest, provider.geoRegions)) {
|
|
1147
1452
|
pkg.init({
|
|
1148
1453
|
userId,
|
|
1149
1454
|
isNewUser: !!response.isNewUser,
|
|
@@ -1156,6 +1461,10 @@
|
|
|
1156
1461
|
keyName,
|
|
1157
1462
|
executionContext,
|
|
1158
1463
|
destination,
|
|
1464
|
+
consentData: {
|
|
1465
|
+
consent: response.consent,
|
|
1466
|
+
categories: response.consentCategories,
|
|
1467
|
+
},
|
|
1159
1468
|
});
|
|
1160
1469
|
}
|
|
1161
1470
|
}
|
|
@@ -1199,7 +1508,11 @@
|
|
|
1199
1508
|
const url = new URL(getInitURL(preferences.edgeURL));
|
|
1200
1509
|
if (preferences.disableConsentCheck) {
|
|
1201
1510
|
url.searchParams.set('consentDisabled', 'true');
|
|
1202
|
-
saveConsent(preferences.edgeURL, {
|
|
1511
|
+
saveConsent(preferences.edgeURL, {
|
|
1512
|
+
all: true,
|
|
1513
|
+
}, {
|
|
1514
|
+
all: true,
|
|
1515
|
+
});
|
|
1203
1516
|
}
|
|
1204
1517
|
if (preferences.userId) {
|
|
1205
1518
|
setSetting(preferences.edgeURL, { userId: preferences.userId });
|
|
@@ -1220,7 +1533,7 @@
|
|
|
1220
1533
|
return;
|
|
1221
1534
|
}
|
|
1222
1535
|
if (result.isNewUser && result.consent) {
|
|
1223
|
-
saveConsent(preferences.edgeURL, result.consent);
|
|
1536
|
+
saveConsent(preferences.edgeURL, result.consent, result.consentCategories);
|
|
1224
1537
|
}
|
|
1225
1538
|
const providers = {};
|
|
1226
1539
|
(_a = result.result) === null || _a === void 0 ? void 0 : _a.forEach((pkg) => {
|
|
@@ -1239,6 +1552,8 @@
|
|
|
1239
1552
|
storageId: result.storageId,
|
|
1240
1553
|
currency: result.currency,
|
|
1241
1554
|
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
1555
|
+
geoRegion: result.geoRegion,
|
|
1556
|
+
isEURequest: result.isEURequest,
|
|
1242
1557
|
});
|
|
1243
1558
|
if (result.storageId != null) {
|
|
1244
1559
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
@@ -1271,6 +1586,8 @@
|
|
|
1271
1586
|
const configuredTags = getSetting(destination, 'channels');
|
|
1272
1587
|
const consent = getConsent$1(destination);
|
|
1273
1588
|
const userId = getUserId$1(destination);
|
|
1589
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1590
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1274
1591
|
for (const pkg of providerPackages) {
|
|
1275
1592
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1276
1593
|
continue;
|
|
@@ -1289,6 +1606,10 @@
|
|
|
1289
1606
|
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1290
1607
|
continue;
|
|
1291
1608
|
}
|
|
1609
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1610
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1611
|
+
continue;
|
|
1612
|
+
}
|
|
1292
1613
|
pkg.user({
|
|
1293
1614
|
userId,
|
|
1294
1615
|
data: { [key]: value },
|
|
@@ -1404,8 +1725,8 @@
|
|
|
1404
1725
|
const tag = (name, data, providers, options) => {
|
|
1405
1726
|
handleTag(name, data, providers, options);
|
|
1406
1727
|
};
|
|
1407
|
-
const consent = (value, options) => {
|
|
1408
|
-
handleConsent(value, options);
|
|
1728
|
+
const consent = (value, consentCategories, options) => {
|
|
1729
|
+
handleConsent(value, consentCategories, options);
|
|
1409
1730
|
};
|
|
1410
1731
|
const user = (key, value, providers, options) => {
|
|
1411
1732
|
handleUser(key, value, providers, options);
|