@blotoutio/edgetag-sdk-js 0.71.0 → 0.72.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 +309 -2
- package/index.mjs +309 -2
- package/internal.d.ts +3 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -140,6 +140,283 @@ const isZeroPurchaseEvent = (payload) => {
|
|
|
140
140
|
return value === 0;
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* ISO-3166 2-leter country codes and their names
|
|
145
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
146
|
+
*/
|
|
147
|
+
const isoCountries = new Map([
|
|
148
|
+
['AD', 'Andorra'],
|
|
149
|
+
['AE', 'United Arab Emirates'],
|
|
150
|
+
['AF', 'Afghanistan'],
|
|
151
|
+
['AG', 'Antigua and Barbuda'],
|
|
152
|
+
['AI', 'Anguilla'],
|
|
153
|
+
['AL', 'Albania'],
|
|
154
|
+
['AM', 'Armenia'],
|
|
155
|
+
['AO', 'Angola'],
|
|
156
|
+
['AQ', 'Antarctica'],
|
|
157
|
+
['AR', 'Argentina'],
|
|
158
|
+
['AS', 'American Samoa'],
|
|
159
|
+
['AT', 'Austria'],
|
|
160
|
+
['AU', 'Australia'],
|
|
161
|
+
['AW', 'Aruba'],
|
|
162
|
+
['AX', 'Åland Islands'],
|
|
163
|
+
['AZ', 'Azerbaijan'],
|
|
164
|
+
['BA', 'Bosnia and Herzegovina'],
|
|
165
|
+
['BB', 'Barbados'],
|
|
166
|
+
['BD', 'Bangladesh'],
|
|
167
|
+
['BE', 'Belgium'],
|
|
168
|
+
['BF', 'Burkina Faso'],
|
|
169
|
+
['BG', 'Bulgaria'],
|
|
170
|
+
['BH', 'Bahrain'],
|
|
171
|
+
['BI', 'Burundi'],
|
|
172
|
+
['BJ', 'Benin'],
|
|
173
|
+
['BL', 'Saint Barthélemy'],
|
|
174
|
+
['BM', 'Bermuda'],
|
|
175
|
+
['BN', 'Brunei Darussalam'],
|
|
176
|
+
['BO', 'Bolivia, Plurinational State of'],
|
|
177
|
+
['BQ', 'Bonaire, Sint Eustatius and Saba'],
|
|
178
|
+
['BR', 'Brazil'],
|
|
179
|
+
['BS', 'Bahamas'],
|
|
180
|
+
['BT', 'Bhutan'],
|
|
181
|
+
['BV', 'Bouvet Island'],
|
|
182
|
+
['BW', 'Botswana'],
|
|
183
|
+
['BY', 'Belarus'],
|
|
184
|
+
['BZ', 'Belize'],
|
|
185
|
+
['CA', 'Canada'],
|
|
186
|
+
['CC', 'Cocos (Keeling) Islands'],
|
|
187
|
+
['CD', 'Congo, Democratic Republic of the'],
|
|
188
|
+
['CF', 'Central African Republic'],
|
|
189
|
+
['CG', 'Congo'],
|
|
190
|
+
['CH', 'Switzerland'],
|
|
191
|
+
['CI', "Côte d'Ivoire"],
|
|
192
|
+
['CK', 'Cook Islands'],
|
|
193
|
+
['CL', 'Chile'],
|
|
194
|
+
['CM', 'Cameroon'],
|
|
195
|
+
['CN', 'China'],
|
|
196
|
+
['CO', 'Colombia'],
|
|
197
|
+
['CR', 'Costa Rica'],
|
|
198
|
+
['CU', 'Cuba'],
|
|
199
|
+
['CV', 'Cabo Verde'],
|
|
200
|
+
['CW', 'Curaçao'],
|
|
201
|
+
['CX', 'Christmas Island'],
|
|
202
|
+
['CY', 'Cyprus'],
|
|
203
|
+
['CZ', 'Czechia'],
|
|
204
|
+
['DE', 'Germany'],
|
|
205
|
+
['DJ', 'Djibouti'],
|
|
206
|
+
['DK', 'Denmark'],
|
|
207
|
+
['DM', 'Dominica'],
|
|
208
|
+
['DO', 'Dominican Republic'],
|
|
209
|
+
['DZ', 'Algeria'],
|
|
210
|
+
['EC', 'Ecuador'],
|
|
211
|
+
['EE', 'Estonia'],
|
|
212
|
+
['EG', 'Egypt'],
|
|
213
|
+
['EH', 'Western Sahara'],
|
|
214
|
+
['ER', 'Eritrea'],
|
|
215
|
+
['ES', 'Spain'],
|
|
216
|
+
['ET', 'Ethiopia'],
|
|
217
|
+
['EU', 'European Union'],
|
|
218
|
+
['FI', 'Finland'],
|
|
219
|
+
['FJ', 'Fiji'],
|
|
220
|
+
['FK', 'Falkland Islands (Malvinas)'],
|
|
221
|
+
['FM', 'Micronesia, Federated States of'],
|
|
222
|
+
['FO', 'Faroe Islands'],
|
|
223
|
+
['FR', 'France'],
|
|
224
|
+
['GA', 'Gabon'],
|
|
225
|
+
['GB', 'United Kingdom of Great Britain and Northern Ireland'],
|
|
226
|
+
['GD', 'Grenada'],
|
|
227
|
+
['GE', 'Georgia'],
|
|
228
|
+
['GF', 'French Guiana'],
|
|
229
|
+
['GG', 'Guernsey'],
|
|
230
|
+
['GH', 'Ghana'],
|
|
231
|
+
['GI', 'Gibraltar'],
|
|
232
|
+
['GL', 'Greenland'],
|
|
233
|
+
['GM', 'Gambia'],
|
|
234
|
+
['GN', 'Guinea'],
|
|
235
|
+
['GP', 'Guadeloupe'],
|
|
236
|
+
['GQ', 'Equatorial Guinea'],
|
|
237
|
+
['GR', 'Greece'],
|
|
238
|
+
['GS', 'South Georgia and the South Sandwich Islands'],
|
|
239
|
+
['GT', 'Guatemala'],
|
|
240
|
+
['GU', 'Guam'],
|
|
241
|
+
['GW', 'Guinea-Bissau'],
|
|
242
|
+
['GY', 'Guyana'],
|
|
243
|
+
['HK', 'Hong Kong'],
|
|
244
|
+
['HM', 'Heard Island and McDonald Islands'],
|
|
245
|
+
['HN', 'Honduras'],
|
|
246
|
+
['HR', 'Croatia'],
|
|
247
|
+
['HT', 'Haiti'],
|
|
248
|
+
['HU', 'Hungary'],
|
|
249
|
+
['ID', 'Indonesia'],
|
|
250
|
+
['IE', 'Ireland'],
|
|
251
|
+
['IL', 'Israel'],
|
|
252
|
+
['IM', 'Isle of Man'],
|
|
253
|
+
['IN', 'India'],
|
|
254
|
+
['IO', 'British Indian Ocean Territory'],
|
|
255
|
+
['IQ', 'Iraq'],
|
|
256
|
+
['IR', 'Iran, Islamic Republic of'],
|
|
257
|
+
['IS', 'Iceland'],
|
|
258
|
+
['IT', 'Italy'],
|
|
259
|
+
['JE', 'Jersey'],
|
|
260
|
+
['JM', 'Jamaica'],
|
|
261
|
+
['JO', 'Jordan'],
|
|
262
|
+
['JP', 'Japan'],
|
|
263
|
+
['KE', 'Kenya'],
|
|
264
|
+
['KG', 'Kyrgyzstan'],
|
|
265
|
+
['KH', 'Cambodia'],
|
|
266
|
+
['KI', 'Kiribati'],
|
|
267
|
+
['KM', 'Comoros'],
|
|
268
|
+
['KN', 'Saint Kitts and Nevis'],
|
|
269
|
+
['KP', "Korea, Democratic People's Republic of"],
|
|
270
|
+
['KR', 'Korea, Republic of'],
|
|
271
|
+
['KW', 'Kuwait'],
|
|
272
|
+
['KY', 'Cayman Islands'],
|
|
273
|
+
['KZ', 'Kazakhstan'],
|
|
274
|
+
['LA', "Lao People's Democratic Republic"],
|
|
275
|
+
['LB', 'Lebanon'],
|
|
276
|
+
['LC', 'Saint Lucia'],
|
|
277
|
+
['LI', 'Liechtenstein'],
|
|
278
|
+
['LK', 'Sri Lanka'],
|
|
279
|
+
['LR', 'Liberia'],
|
|
280
|
+
['LS', 'Lesotho'],
|
|
281
|
+
['LT', 'Lithuania'],
|
|
282
|
+
['LU', 'Luxembourg'],
|
|
283
|
+
['LV', 'Latvia'],
|
|
284
|
+
['LY', 'Libya'],
|
|
285
|
+
['MA', 'Morocco'],
|
|
286
|
+
['MC', 'Monaco'],
|
|
287
|
+
['MD', 'Moldova, Republic of'],
|
|
288
|
+
['ME', 'Montenegro'],
|
|
289
|
+
['MF', 'Saint Martin (French part)'],
|
|
290
|
+
['MG', 'Madagascar'],
|
|
291
|
+
['MH', 'Marshall Islands'],
|
|
292
|
+
['MK', 'North Macedonia'],
|
|
293
|
+
['ML', 'Mali'],
|
|
294
|
+
['MM', 'Myanmar'],
|
|
295
|
+
['MN', 'Mongolia'],
|
|
296
|
+
['MO', 'Macao'],
|
|
297
|
+
['MP', 'Northern Mariana Islands'],
|
|
298
|
+
['MQ', 'Martinique'],
|
|
299
|
+
['MR', 'Mauritania'],
|
|
300
|
+
['MS', 'Montserrat'],
|
|
301
|
+
['MT', 'Malta'],
|
|
302
|
+
['MU', 'Mauritius'],
|
|
303
|
+
['MV', 'Maldives'],
|
|
304
|
+
['MW', 'Malawi'],
|
|
305
|
+
['MX', 'Mexico'],
|
|
306
|
+
['MY', 'Malaysia'],
|
|
307
|
+
['MZ', 'Mozambique'],
|
|
308
|
+
['NA', 'Namibia'],
|
|
309
|
+
['NC', 'New Caledonia'],
|
|
310
|
+
['NE', 'Niger'],
|
|
311
|
+
['NF', 'Norfolk Island'],
|
|
312
|
+
['NG', 'Nigeria'],
|
|
313
|
+
['NI', 'Nicaragua'],
|
|
314
|
+
['NL', 'Netherlands, Kingdom of the'],
|
|
315
|
+
['NO', 'Norway'],
|
|
316
|
+
['NP', 'Nepal'],
|
|
317
|
+
['NR', 'Nauru'],
|
|
318
|
+
['NU', 'Niue'],
|
|
319
|
+
['NZ', 'New Zealand'],
|
|
320
|
+
['OM', 'Oman'],
|
|
321
|
+
['PA', 'Panama'],
|
|
322
|
+
['PE', 'Peru'],
|
|
323
|
+
['PF', 'French Polynesia'],
|
|
324
|
+
['PG', 'Papua New Guinea'],
|
|
325
|
+
['PH', 'Philippines'],
|
|
326
|
+
['PK', 'Pakistan'],
|
|
327
|
+
['PL', 'Poland'],
|
|
328
|
+
['PM', 'Saint Pierre and Miquelon'],
|
|
329
|
+
['PN', 'Pitcairn'],
|
|
330
|
+
['PR', 'Puerto Rico'],
|
|
331
|
+
['PS', 'Palestine, State of'],
|
|
332
|
+
['PT', 'Portugal'],
|
|
333
|
+
['PW', 'Palau'],
|
|
334
|
+
['PY', 'Paraguay'],
|
|
335
|
+
['QA', 'Qatar'],
|
|
336
|
+
['RE', 'Réunion'],
|
|
337
|
+
['RO', 'Romania'],
|
|
338
|
+
['RS', 'Serbia'],
|
|
339
|
+
['RU', 'Russian Federation'],
|
|
340
|
+
['RW', 'Rwanda'],
|
|
341
|
+
['SA', 'Saudi Arabia'],
|
|
342
|
+
['SB', 'Solomon Islands'],
|
|
343
|
+
['SC', 'Seychelles'],
|
|
344
|
+
['SD', 'Sudan'],
|
|
345
|
+
['SE', 'Sweden'],
|
|
346
|
+
['SG', 'Singapore'],
|
|
347
|
+
['SH', 'Saint Helena, Ascension and Tristan da Cunha'],
|
|
348
|
+
['SI', 'Slovenia'],
|
|
349
|
+
['SJ', 'Svalbard and Jan Mayen'],
|
|
350
|
+
['SK', 'Slovakia'],
|
|
351
|
+
['SL', 'Sierra Leone'],
|
|
352
|
+
['SM', 'San Marino'],
|
|
353
|
+
['SN', 'Senegal'],
|
|
354
|
+
['SO', 'Somalia'],
|
|
355
|
+
['SR', 'Suriname'],
|
|
356
|
+
['SS', 'South Sudan'],
|
|
357
|
+
['ST', 'Sao Tome and Principe'],
|
|
358
|
+
['SV', 'El Salvador'],
|
|
359
|
+
['SX', 'Sint Maarten (Dutch part)'],
|
|
360
|
+
['SY', 'Syrian Arab Republic'],
|
|
361
|
+
['SZ', 'Eswatini'],
|
|
362
|
+
['TC', 'Turks and Caicos Islands'],
|
|
363
|
+
['TD', 'Chad'],
|
|
364
|
+
['TF', 'French Southern Territories'],
|
|
365
|
+
['TG', 'Togo'],
|
|
366
|
+
['TH', 'Thailand'],
|
|
367
|
+
['TJ', 'Tajikistan'],
|
|
368
|
+
['TK', 'Tokelau'],
|
|
369
|
+
['TL', 'Timor-Leste'],
|
|
370
|
+
['TM', 'Turkmenistan'],
|
|
371
|
+
['TN', 'Tunisia'],
|
|
372
|
+
['TO', 'Tonga'],
|
|
373
|
+
['TR', 'Türkiye'],
|
|
374
|
+
['TT', 'Trinidad and Tobago'],
|
|
375
|
+
['TV', 'Tuvalu'],
|
|
376
|
+
['TW', 'Taiwan, Province of China'],
|
|
377
|
+
['TZ', 'Tanzania, United Republic of'],
|
|
378
|
+
['UA', 'Ukraine'],
|
|
379
|
+
['UG', 'Uganda'],
|
|
380
|
+
['UK', 'United Kingdom'],
|
|
381
|
+
['UM', 'United States Minor Outlying Islands'],
|
|
382
|
+
['US', 'United States of America'],
|
|
383
|
+
['UY', 'Uruguay'],
|
|
384
|
+
['UZ', 'Uzbekistan'],
|
|
385
|
+
['VA', 'Holy See'],
|
|
386
|
+
['VC', 'Saint Vincent and the Grenadines'],
|
|
387
|
+
['VE', 'Venezuela, Bolivarian Republic of'],
|
|
388
|
+
['VG', 'Virgin Islands (British)'],
|
|
389
|
+
['VI', 'Virgin Islands (U.S.)'],
|
|
390
|
+
['VN', 'Viet Nam'],
|
|
391
|
+
['VU', 'Vanuatu'],
|
|
392
|
+
['WF', 'Wallis and Futuna'],
|
|
393
|
+
['WS', 'Samoa'],
|
|
394
|
+
['YE', 'Yemen'],
|
|
395
|
+
['YT', 'Mayotte'],
|
|
396
|
+
['ZA', 'South Africa'],
|
|
397
|
+
['ZM', 'Zambia'],
|
|
398
|
+
['ZW', 'Zimbabwe'],
|
|
399
|
+
]);
|
|
400
|
+
new Set(isoCountries.keys());
|
|
401
|
+
const parseCache = new Map();
|
|
402
|
+
const doesGeoRequestMatchList = (requestRegion, isEUCountry, geoRegions) => {
|
|
403
|
+
if (!requestRegion || !geoRegions) {
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
let parsedRegions = parseCache.get(geoRegions);
|
|
407
|
+
if (!parsedRegions) {
|
|
408
|
+
parsedRegions = new Set((geoRegions !== null && geoRegions !== void 0 ? geoRegions : '').split(','));
|
|
409
|
+
parseCache.set(geoRegions, parsedRegions);
|
|
410
|
+
}
|
|
411
|
+
if (parsedRegions.size == 0) {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
if (isEUCountry && parsedRegions.has('EU')) {
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
return parsedRegions.has(requestRegion);
|
|
418
|
+
};
|
|
419
|
+
|
|
143
420
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
144
421
|
let edgeTagSettings;
|
|
145
422
|
const initSettings = (destination, options) => {
|
|
@@ -152,6 +429,8 @@ const initSettings = (destination, options) => {
|
|
|
152
429
|
stubs: [],
|
|
153
430
|
browserPackages: [],
|
|
154
431
|
channels: new Map(),
|
|
432
|
+
geoRegion: null,
|
|
433
|
+
isEURequest: false,
|
|
155
434
|
...options,
|
|
156
435
|
};
|
|
157
436
|
};
|
|
@@ -190,6 +469,7 @@ const getProviderVariables = (destination, packageId) => {
|
|
|
190
469
|
.filter((pkg) => pkg.package === packageId)
|
|
191
470
|
.map((pkg) => ({
|
|
192
471
|
tagName: pkg.tagName,
|
|
472
|
+
geoRegions: pkg.geoRegions || null,
|
|
193
473
|
variableSet: pkg.variables || {},
|
|
194
474
|
})) || []);
|
|
195
475
|
};
|
|
@@ -571,7 +851,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
571
851
|
referrer: getReferrer(destination),
|
|
572
852
|
search: getSearch(destination),
|
|
573
853
|
locale: getLocale(),
|
|
574
|
-
sdkVersion: "0.
|
|
854
|
+
sdkVersion: "0.72.0" ,
|
|
575
855
|
...(payload || {}),
|
|
576
856
|
};
|
|
577
857
|
let storage = {};
|
|
@@ -739,6 +1019,8 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
739
1019
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
740
1020
|
const configuredTags = getSetting(destination, 'channels');
|
|
741
1021
|
const skipZeroPurchaseEvent = getSetting(destination, 'skipZeroPurchaseEvent') || false;
|
|
1022
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1023
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
742
1024
|
const userId = getUserId$1(destination);
|
|
743
1025
|
const providerData = {};
|
|
744
1026
|
const consent = getConsent$1(destination);
|
|
@@ -766,6 +1048,10 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
766
1048
|
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
767
1049
|
continue;
|
|
768
1050
|
}
|
|
1051
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1052
|
+
logger.log('GEO request region does not match the filter, skiping');
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
769
1055
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
770
1056
|
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(pkg.name))
|
|
771
1057
|
? conversion.payload
|
|
@@ -847,6 +1133,8 @@ const processData = (destination, data, providers, options) => {
|
|
|
847
1133
|
const configuredTags = getSetting(destination, 'channels');
|
|
848
1134
|
const userId = getUserId$1(destination);
|
|
849
1135
|
const consent = getConsent$1(destination);
|
|
1136
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1137
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
850
1138
|
for (const pkg of providerPackages) {
|
|
851
1139
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
852
1140
|
continue;
|
|
@@ -865,6 +1153,10 @@ const processData = (destination, data, providers, options) => {
|
|
|
865
1153
|
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
866
1154
|
continue;
|
|
867
1155
|
}
|
|
1156
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1157
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
868
1160
|
pkg.user({
|
|
869
1161
|
userId,
|
|
870
1162
|
data,
|
|
@@ -925,6 +1217,8 @@ const processConsent = (destination, consent, options) => {
|
|
|
925
1217
|
const userId = getUserId$1(destination);
|
|
926
1218
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
927
1219
|
const executionContext = new Map();
|
|
1220
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1221
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
928
1222
|
/* Calling Init for all provider instances based on consent check */
|
|
929
1223
|
for (const pkg of providerPackages) {
|
|
930
1224
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
@@ -936,6 +1230,9 @@ const processConsent = (destination, consent, options) => {
|
|
|
936
1230
|
if (!hasConsent) {
|
|
937
1231
|
continue;
|
|
938
1232
|
}
|
|
1233
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
939
1236
|
pkg.init({
|
|
940
1237
|
userId,
|
|
941
1238
|
isNewUser: false,
|
|
@@ -944,6 +1241,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
944
1241
|
tagName: variable.tagName,
|
|
945
1242
|
variables: variable.variableSet,
|
|
946
1243
|
package: pkg.name,
|
|
1244
|
+
geoRegions: variable.geoRegions,
|
|
947
1245
|
},
|
|
948
1246
|
sendTag: sendTag.bind(null, destination),
|
|
949
1247
|
sendEdgeData: processData.bind(null, destination),
|
|
@@ -1142,7 +1440,8 @@ const handleManifest = (destination, response) => {
|
|
|
1142
1440
|
if (pkg && pkg.name && pkg.init) {
|
|
1143
1441
|
/* this defines if the consent is given for a specific instance of a provider */
|
|
1144
1442
|
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
1145
|
-
if (hasConsent
|
|
1443
|
+
if (hasConsent &&
|
|
1444
|
+
doesGeoRequestMatchList(response.geoRegion, response.isEURequest, provider.geoRegions)) {
|
|
1146
1445
|
pkg.init({
|
|
1147
1446
|
userId,
|
|
1148
1447
|
isNewUser: !!response.isNewUser,
|
|
@@ -1238,6 +1537,8 @@ const handleInit = (preferences) => {
|
|
|
1238
1537
|
storageId: result.storageId,
|
|
1239
1538
|
currency: result.currency,
|
|
1240
1539
|
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
1540
|
+
geoRegion: result.geoRegion,
|
|
1541
|
+
isEURequest: result.isEURequest,
|
|
1241
1542
|
});
|
|
1242
1543
|
if (result.storageId != null) {
|
|
1243
1544
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
@@ -1270,6 +1571,8 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1270
1571
|
const configuredTags = getSetting(destination, 'channels');
|
|
1271
1572
|
const consent = getConsent$1(destination);
|
|
1272
1573
|
const userId = getUserId$1(destination);
|
|
1574
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1575
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1273
1576
|
for (const pkg of providerPackages) {
|
|
1274
1577
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1275
1578
|
continue;
|
|
@@ -1288,6 +1591,10 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1288
1591
|
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1289
1592
|
continue;
|
|
1290
1593
|
}
|
|
1594
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1595
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1291
1598
|
pkg.user({
|
|
1292
1599
|
userId,
|
|
1293
1600
|
data: { [key]: value },
|
package/index.mjs
CHANGED
|
@@ -138,6 +138,283 @@ const isZeroPurchaseEvent = (payload) => {
|
|
|
138
138
|
return value === 0;
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* ISO-3166 2-leter country codes and their names
|
|
143
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
144
|
+
*/
|
|
145
|
+
const isoCountries = new Map([
|
|
146
|
+
['AD', 'Andorra'],
|
|
147
|
+
['AE', 'United Arab Emirates'],
|
|
148
|
+
['AF', 'Afghanistan'],
|
|
149
|
+
['AG', 'Antigua and Barbuda'],
|
|
150
|
+
['AI', 'Anguilla'],
|
|
151
|
+
['AL', 'Albania'],
|
|
152
|
+
['AM', 'Armenia'],
|
|
153
|
+
['AO', 'Angola'],
|
|
154
|
+
['AQ', 'Antarctica'],
|
|
155
|
+
['AR', 'Argentina'],
|
|
156
|
+
['AS', 'American Samoa'],
|
|
157
|
+
['AT', 'Austria'],
|
|
158
|
+
['AU', 'Australia'],
|
|
159
|
+
['AW', 'Aruba'],
|
|
160
|
+
['AX', 'Åland Islands'],
|
|
161
|
+
['AZ', 'Azerbaijan'],
|
|
162
|
+
['BA', 'Bosnia and Herzegovina'],
|
|
163
|
+
['BB', 'Barbados'],
|
|
164
|
+
['BD', 'Bangladesh'],
|
|
165
|
+
['BE', 'Belgium'],
|
|
166
|
+
['BF', 'Burkina Faso'],
|
|
167
|
+
['BG', 'Bulgaria'],
|
|
168
|
+
['BH', 'Bahrain'],
|
|
169
|
+
['BI', 'Burundi'],
|
|
170
|
+
['BJ', 'Benin'],
|
|
171
|
+
['BL', 'Saint Barthélemy'],
|
|
172
|
+
['BM', 'Bermuda'],
|
|
173
|
+
['BN', 'Brunei Darussalam'],
|
|
174
|
+
['BO', 'Bolivia, Plurinational State of'],
|
|
175
|
+
['BQ', 'Bonaire, Sint Eustatius and Saba'],
|
|
176
|
+
['BR', 'Brazil'],
|
|
177
|
+
['BS', 'Bahamas'],
|
|
178
|
+
['BT', 'Bhutan'],
|
|
179
|
+
['BV', 'Bouvet Island'],
|
|
180
|
+
['BW', 'Botswana'],
|
|
181
|
+
['BY', 'Belarus'],
|
|
182
|
+
['BZ', 'Belize'],
|
|
183
|
+
['CA', 'Canada'],
|
|
184
|
+
['CC', 'Cocos (Keeling) Islands'],
|
|
185
|
+
['CD', 'Congo, Democratic Republic of the'],
|
|
186
|
+
['CF', 'Central African Republic'],
|
|
187
|
+
['CG', 'Congo'],
|
|
188
|
+
['CH', 'Switzerland'],
|
|
189
|
+
['CI', "Côte d'Ivoire"],
|
|
190
|
+
['CK', 'Cook Islands'],
|
|
191
|
+
['CL', 'Chile'],
|
|
192
|
+
['CM', 'Cameroon'],
|
|
193
|
+
['CN', 'China'],
|
|
194
|
+
['CO', 'Colombia'],
|
|
195
|
+
['CR', 'Costa Rica'],
|
|
196
|
+
['CU', 'Cuba'],
|
|
197
|
+
['CV', 'Cabo Verde'],
|
|
198
|
+
['CW', 'Curaçao'],
|
|
199
|
+
['CX', 'Christmas Island'],
|
|
200
|
+
['CY', 'Cyprus'],
|
|
201
|
+
['CZ', 'Czechia'],
|
|
202
|
+
['DE', 'Germany'],
|
|
203
|
+
['DJ', 'Djibouti'],
|
|
204
|
+
['DK', 'Denmark'],
|
|
205
|
+
['DM', 'Dominica'],
|
|
206
|
+
['DO', 'Dominican Republic'],
|
|
207
|
+
['DZ', 'Algeria'],
|
|
208
|
+
['EC', 'Ecuador'],
|
|
209
|
+
['EE', 'Estonia'],
|
|
210
|
+
['EG', 'Egypt'],
|
|
211
|
+
['EH', 'Western Sahara'],
|
|
212
|
+
['ER', 'Eritrea'],
|
|
213
|
+
['ES', 'Spain'],
|
|
214
|
+
['ET', 'Ethiopia'],
|
|
215
|
+
['EU', 'European Union'],
|
|
216
|
+
['FI', 'Finland'],
|
|
217
|
+
['FJ', 'Fiji'],
|
|
218
|
+
['FK', 'Falkland Islands (Malvinas)'],
|
|
219
|
+
['FM', 'Micronesia, Federated States of'],
|
|
220
|
+
['FO', 'Faroe Islands'],
|
|
221
|
+
['FR', 'France'],
|
|
222
|
+
['GA', 'Gabon'],
|
|
223
|
+
['GB', 'United Kingdom of Great Britain and Northern Ireland'],
|
|
224
|
+
['GD', 'Grenada'],
|
|
225
|
+
['GE', 'Georgia'],
|
|
226
|
+
['GF', 'French Guiana'],
|
|
227
|
+
['GG', 'Guernsey'],
|
|
228
|
+
['GH', 'Ghana'],
|
|
229
|
+
['GI', 'Gibraltar'],
|
|
230
|
+
['GL', 'Greenland'],
|
|
231
|
+
['GM', 'Gambia'],
|
|
232
|
+
['GN', 'Guinea'],
|
|
233
|
+
['GP', 'Guadeloupe'],
|
|
234
|
+
['GQ', 'Equatorial Guinea'],
|
|
235
|
+
['GR', 'Greece'],
|
|
236
|
+
['GS', 'South Georgia and the South Sandwich Islands'],
|
|
237
|
+
['GT', 'Guatemala'],
|
|
238
|
+
['GU', 'Guam'],
|
|
239
|
+
['GW', 'Guinea-Bissau'],
|
|
240
|
+
['GY', 'Guyana'],
|
|
241
|
+
['HK', 'Hong Kong'],
|
|
242
|
+
['HM', 'Heard Island and McDonald Islands'],
|
|
243
|
+
['HN', 'Honduras'],
|
|
244
|
+
['HR', 'Croatia'],
|
|
245
|
+
['HT', 'Haiti'],
|
|
246
|
+
['HU', 'Hungary'],
|
|
247
|
+
['ID', 'Indonesia'],
|
|
248
|
+
['IE', 'Ireland'],
|
|
249
|
+
['IL', 'Israel'],
|
|
250
|
+
['IM', 'Isle of Man'],
|
|
251
|
+
['IN', 'India'],
|
|
252
|
+
['IO', 'British Indian Ocean Territory'],
|
|
253
|
+
['IQ', 'Iraq'],
|
|
254
|
+
['IR', 'Iran, Islamic Republic of'],
|
|
255
|
+
['IS', 'Iceland'],
|
|
256
|
+
['IT', 'Italy'],
|
|
257
|
+
['JE', 'Jersey'],
|
|
258
|
+
['JM', 'Jamaica'],
|
|
259
|
+
['JO', 'Jordan'],
|
|
260
|
+
['JP', 'Japan'],
|
|
261
|
+
['KE', 'Kenya'],
|
|
262
|
+
['KG', 'Kyrgyzstan'],
|
|
263
|
+
['KH', 'Cambodia'],
|
|
264
|
+
['KI', 'Kiribati'],
|
|
265
|
+
['KM', 'Comoros'],
|
|
266
|
+
['KN', 'Saint Kitts and Nevis'],
|
|
267
|
+
['KP', "Korea, Democratic People's Republic of"],
|
|
268
|
+
['KR', 'Korea, Republic of'],
|
|
269
|
+
['KW', 'Kuwait'],
|
|
270
|
+
['KY', 'Cayman Islands'],
|
|
271
|
+
['KZ', 'Kazakhstan'],
|
|
272
|
+
['LA', "Lao People's Democratic Republic"],
|
|
273
|
+
['LB', 'Lebanon'],
|
|
274
|
+
['LC', 'Saint Lucia'],
|
|
275
|
+
['LI', 'Liechtenstein'],
|
|
276
|
+
['LK', 'Sri Lanka'],
|
|
277
|
+
['LR', 'Liberia'],
|
|
278
|
+
['LS', 'Lesotho'],
|
|
279
|
+
['LT', 'Lithuania'],
|
|
280
|
+
['LU', 'Luxembourg'],
|
|
281
|
+
['LV', 'Latvia'],
|
|
282
|
+
['LY', 'Libya'],
|
|
283
|
+
['MA', 'Morocco'],
|
|
284
|
+
['MC', 'Monaco'],
|
|
285
|
+
['MD', 'Moldova, Republic of'],
|
|
286
|
+
['ME', 'Montenegro'],
|
|
287
|
+
['MF', 'Saint Martin (French part)'],
|
|
288
|
+
['MG', 'Madagascar'],
|
|
289
|
+
['MH', 'Marshall Islands'],
|
|
290
|
+
['MK', 'North Macedonia'],
|
|
291
|
+
['ML', 'Mali'],
|
|
292
|
+
['MM', 'Myanmar'],
|
|
293
|
+
['MN', 'Mongolia'],
|
|
294
|
+
['MO', 'Macao'],
|
|
295
|
+
['MP', 'Northern Mariana Islands'],
|
|
296
|
+
['MQ', 'Martinique'],
|
|
297
|
+
['MR', 'Mauritania'],
|
|
298
|
+
['MS', 'Montserrat'],
|
|
299
|
+
['MT', 'Malta'],
|
|
300
|
+
['MU', 'Mauritius'],
|
|
301
|
+
['MV', 'Maldives'],
|
|
302
|
+
['MW', 'Malawi'],
|
|
303
|
+
['MX', 'Mexico'],
|
|
304
|
+
['MY', 'Malaysia'],
|
|
305
|
+
['MZ', 'Mozambique'],
|
|
306
|
+
['NA', 'Namibia'],
|
|
307
|
+
['NC', 'New Caledonia'],
|
|
308
|
+
['NE', 'Niger'],
|
|
309
|
+
['NF', 'Norfolk Island'],
|
|
310
|
+
['NG', 'Nigeria'],
|
|
311
|
+
['NI', 'Nicaragua'],
|
|
312
|
+
['NL', 'Netherlands, Kingdom of the'],
|
|
313
|
+
['NO', 'Norway'],
|
|
314
|
+
['NP', 'Nepal'],
|
|
315
|
+
['NR', 'Nauru'],
|
|
316
|
+
['NU', 'Niue'],
|
|
317
|
+
['NZ', 'New Zealand'],
|
|
318
|
+
['OM', 'Oman'],
|
|
319
|
+
['PA', 'Panama'],
|
|
320
|
+
['PE', 'Peru'],
|
|
321
|
+
['PF', 'French Polynesia'],
|
|
322
|
+
['PG', 'Papua New Guinea'],
|
|
323
|
+
['PH', 'Philippines'],
|
|
324
|
+
['PK', 'Pakistan'],
|
|
325
|
+
['PL', 'Poland'],
|
|
326
|
+
['PM', 'Saint Pierre and Miquelon'],
|
|
327
|
+
['PN', 'Pitcairn'],
|
|
328
|
+
['PR', 'Puerto Rico'],
|
|
329
|
+
['PS', 'Palestine, State of'],
|
|
330
|
+
['PT', 'Portugal'],
|
|
331
|
+
['PW', 'Palau'],
|
|
332
|
+
['PY', 'Paraguay'],
|
|
333
|
+
['QA', 'Qatar'],
|
|
334
|
+
['RE', 'Réunion'],
|
|
335
|
+
['RO', 'Romania'],
|
|
336
|
+
['RS', 'Serbia'],
|
|
337
|
+
['RU', 'Russian Federation'],
|
|
338
|
+
['RW', 'Rwanda'],
|
|
339
|
+
['SA', 'Saudi Arabia'],
|
|
340
|
+
['SB', 'Solomon Islands'],
|
|
341
|
+
['SC', 'Seychelles'],
|
|
342
|
+
['SD', 'Sudan'],
|
|
343
|
+
['SE', 'Sweden'],
|
|
344
|
+
['SG', 'Singapore'],
|
|
345
|
+
['SH', 'Saint Helena, Ascension and Tristan da Cunha'],
|
|
346
|
+
['SI', 'Slovenia'],
|
|
347
|
+
['SJ', 'Svalbard and Jan Mayen'],
|
|
348
|
+
['SK', 'Slovakia'],
|
|
349
|
+
['SL', 'Sierra Leone'],
|
|
350
|
+
['SM', 'San Marino'],
|
|
351
|
+
['SN', 'Senegal'],
|
|
352
|
+
['SO', 'Somalia'],
|
|
353
|
+
['SR', 'Suriname'],
|
|
354
|
+
['SS', 'South Sudan'],
|
|
355
|
+
['ST', 'Sao Tome and Principe'],
|
|
356
|
+
['SV', 'El Salvador'],
|
|
357
|
+
['SX', 'Sint Maarten (Dutch part)'],
|
|
358
|
+
['SY', 'Syrian Arab Republic'],
|
|
359
|
+
['SZ', 'Eswatini'],
|
|
360
|
+
['TC', 'Turks and Caicos Islands'],
|
|
361
|
+
['TD', 'Chad'],
|
|
362
|
+
['TF', 'French Southern Territories'],
|
|
363
|
+
['TG', 'Togo'],
|
|
364
|
+
['TH', 'Thailand'],
|
|
365
|
+
['TJ', 'Tajikistan'],
|
|
366
|
+
['TK', 'Tokelau'],
|
|
367
|
+
['TL', 'Timor-Leste'],
|
|
368
|
+
['TM', 'Turkmenistan'],
|
|
369
|
+
['TN', 'Tunisia'],
|
|
370
|
+
['TO', 'Tonga'],
|
|
371
|
+
['TR', 'Türkiye'],
|
|
372
|
+
['TT', 'Trinidad and Tobago'],
|
|
373
|
+
['TV', 'Tuvalu'],
|
|
374
|
+
['TW', 'Taiwan, Province of China'],
|
|
375
|
+
['TZ', 'Tanzania, United Republic of'],
|
|
376
|
+
['UA', 'Ukraine'],
|
|
377
|
+
['UG', 'Uganda'],
|
|
378
|
+
['UK', 'United Kingdom'],
|
|
379
|
+
['UM', 'United States Minor Outlying Islands'],
|
|
380
|
+
['US', 'United States of America'],
|
|
381
|
+
['UY', 'Uruguay'],
|
|
382
|
+
['UZ', 'Uzbekistan'],
|
|
383
|
+
['VA', 'Holy See'],
|
|
384
|
+
['VC', 'Saint Vincent and the Grenadines'],
|
|
385
|
+
['VE', 'Venezuela, Bolivarian Republic of'],
|
|
386
|
+
['VG', 'Virgin Islands (British)'],
|
|
387
|
+
['VI', 'Virgin Islands (U.S.)'],
|
|
388
|
+
['VN', 'Viet Nam'],
|
|
389
|
+
['VU', 'Vanuatu'],
|
|
390
|
+
['WF', 'Wallis and Futuna'],
|
|
391
|
+
['WS', 'Samoa'],
|
|
392
|
+
['YE', 'Yemen'],
|
|
393
|
+
['YT', 'Mayotte'],
|
|
394
|
+
['ZA', 'South Africa'],
|
|
395
|
+
['ZM', 'Zambia'],
|
|
396
|
+
['ZW', 'Zimbabwe'],
|
|
397
|
+
]);
|
|
398
|
+
new Set(isoCountries.keys());
|
|
399
|
+
const parseCache = new Map();
|
|
400
|
+
const doesGeoRequestMatchList = (requestRegion, isEUCountry, geoRegions) => {
|
|
401
|
+
if (!requestRegion || !geoRegions) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
let parsedRegions = parseCache.get(geoRegions);
|
|
405
|
+
if (!parsedRegions) {
|
|
406
|
+
parsedRegions = new Set((geoRegions !== null && geoRegions !== void 0 ? geoRegions : '').split(','));
|
|
407
|
+
parseCache.set(geoRegions, parsedRegions);
|
|
408
|
+
}
|
|
409
|
+
if (parsedRegions.size == 0) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
if (isEUCountry && parsedRegions.has('EU')) {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
return parsedRegions.has(requestRegion);
|
|
416
|
+
};
|
|
417
|
+
|
|
141
418
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
142
419
|
let edgeTagSettings;
|
|
143
420
|
const initSettings = (destination, options) => {
|
|
@@ -150,6 +427,8 @@ const initSettings = (destination, options) => {
|
|
|
150
427
|
stubs: [],
|
|
151
428
|
browserPackages: [],
|
|
152
429
|
channels: new Map(),
|
|
430
|
+
geoRegion: null,
|
|
431
|
+
isEURequest: false,
|
|
153
432
|
...options,
|
|
154
433
|
};
|
|
155
434
|
};
|
|
@@ -188,6 +467,7 @@ const getProviderVariables = (destination, packageId) => {
|
|
|
188
467
|
.filter((pkg) => pkg.package === packageId)
|
|
189
468
|
.map((pkg) => ({
|
|
190
469
|
tagName: pkg.tagName,
|
|
470
|
+
geoRegions: pkg.geoRegions || null,
|
|
191
471
|
variableSet: pkg.variables || {},
|
|
192
472
|
})) || []);
|
|
193
473
|
};
|
|
@@ -569,7 +849,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
569
849
|
referrer: getReferrer(destination),
|
|
570
850
|
search: getSearch(destination),
|
|
571
851
|
locale: getLocale(),
|
|
572
|
-
sdkVersion: "0.
|
|
852
|
+
sdkVersion: "0.72.0" ,
|
|
573
853
|
...(payload || {}),
|
|
574
854
|
};
|
|
575
855
|
let storage = {};
|
|
@@ -737,6 +1017,8 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
737
1017
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
738
1018
|
const configuredTags = getSetting(destination, 'channels');
|
|
739
1019
|
const skipZeroPurchaseEvent = getSetting(destination, 'skipZeroPurchaseEvent') || false;
|
|
1020
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1021
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
740
1022
|
const userId = getUserId$1(destination);
|
|
741
1023
|
const providerData = {};
|
|
742
1024
|
const consent = getConsent$1(destination);
|
|
@@ -764,6 +1046,10 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
764
1046
|
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
765
1047
|
continue;
|
|
766
1048
|
}
|
|
1049
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1050
|
+
logger.log('GEO request region does not match the filter, skiping');
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
767
1053
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
768
1054
|
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(pkg.name))
|
|
769
1055
|
? conversion.payload
|
|
@@ -845,6 +1131,8 @@ const processData = (destination, data, providers, options) => {
|
|
|
845
1131
|
const configuredTags = getSetting(destination, 'channels');
|
|
846
1132
|
const userId = getUserId$1(destination);
|
|
847
1133
|
const consent = getConsent$1(destination);
|
|
1134
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1135
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
848
1136
|
for (const pkg of providerPackages) {
|
|
849
1137
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
850
1138
|
continue;
|
|
@@ -863,6 +1151,10 @@ const processData = (destination, data, providers, options) => {
|
|
|
863
1151
|
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
864
1152
|
continue;
|
|
865
1153
|
}
|
|
1154
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1155
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
866
1158
|
pkg.user({
|
|
867
1159
|
userId,
|
|
868
1160
|
data,
|
|
@@ -923,6 +1215,8 @@ const processConsent = (destination, consent, options) => {
|
|
|
923
1215
|
const userId = getUserId$1(destination);
|
|
924
1216
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
925
1217
|
const executionContext = new Map();
|
|
1218
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1219
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
926
1220
|
/* Calling Init for all provider instances based on consent check */
|
|
927
1221
|
for (const pkg of providerPackages) {
|
|
928
1222
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
@@ -934,6 +1228,9 @@ const processConsent = (destination, consent, options) => {
|
|
|
934
1228
|
if (!hasConsent) {
|
|
935
1229
|
continue;
|
|
936
1230
|
}
|
|
1231
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
937
1234
|
pkg.init({
|
|
938
1235
|
userId,
|
|
939
1236
|
isNewUser: false,
|
|
@@ -942,6 +1239,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
942
1239
|
tagName: variable.tagName,
|
|
943
1240
|
variables: variable.variableSet,
|
|
944
1241
|
package: pkg.name,
|
|
1242
|
+
geoRegions: variable.geoRegions,
|
|
945
1243
|
},
|
|
946
1244
|
sendTag: sendTag.bind(null, destination),
|
|
947
1245
|
sendEdgeData: processData.bind(null, destination),
|
|
@@ -1140,7 +1438,8 @@ const handleManifest = (destination, response) => {
|
|
|
1140
1438
|
if (pkg && pkg.name && pkg.init) {
|
|
1141
1439
|
/* this defines if the consent is given for a specific instance of a provider */
|
|
1142
1440
|
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
1143
|
-
if (hasConsent
|
|
1441
|
+
if (hasConsent &&
|
|
1442
|
+
doesGeoRequestMatchList(response.geoRegion, response.isEURequest, provider.geoRegions)) {
|
|
1144
1443
|
pkg.init({
|
|
1145
1444
|
userId,
|
|
1146
1445
|
isNewUser: !!response.isNewUser,
|
|
@@ -1236,6 +1535,8 @@ const handleInit = (preferences) => {
|
|
|
1236
1535
|
storageId: result.storageId,
|
|
1237
1536
|
currency: result.currency,
|
|
1238
1537
|
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
1538
|
+
geoRegion: result.geoRegion,
|
|
1539
|
+
isEURequest: result.isEURequest,
|
|
1239
1540
|
});
|
|
1240
1541
|
if (result.storageId != null) {
|
|
1241
1542
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
@@ -1268,6 +1569,8 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1268
1569
|
const configuredTags = getSetting(destination, 'channels');
|
|
1269
1570
|
const consent = getConsent$1(destination);
|
|
1270
1571
|
const userId = getUserId$1(destination);
|
|
1572
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1573
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1271
1574
|
for (const pkg of providerPackages) {
|
|
1272
1575
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1273
1576
|
continue;
|
|
@@ -1286,6 +1589,10 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1286
1589
|
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1287
1590
|
continue;
|
|
1288
1591
|
}
|
|
1592
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1593
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1289
1596
|
pkg.user({
|
|
1290
1597
|
userId,
|
|
1291
1598
|
data: { [key]: value },
|
package/internal.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ProvidersConfig,
|
|
5
5
|
UserConsent,
|
|
6
6
|
} from '@blotoutio/cdn/types'
|
|
7
|
-
import { UserKey, Data } from './index'
|
|
7
|
+
import { UserKey, Data, Manifest } from './index'
|
|
8
8
|
|
|
9
9
|
type Navigator = {
|
|
10
10
|
userAgent: string
|
|
@@ -61,4 +61,6 @@ type InitResponse = {
|
|
|
61
61
|
rates: { from: string; to: string; value: number }[]
|
|
62
62
|
}
|
|
63
63
|
skipZeroPurchaseEvent?: boolean
|
|
64
|
+
geoRegion: string | null
|
|
65
|
+
isEURequest: boolean
|
|
64
66
|
}
|