@blotoutio/edgetag-sdk-js 0.70.1 → 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 +323 -2
- package/index.d.ts +1 -0
- package/index.mjs +323 -2
- package/internal.d.ts +4 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -131,6 +131,292 @@ 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
|
+
const isZeroPurchaseEvent = (payload) => {
|
|
135
|
+
var _a;
|
|
136
|
+
if (payload.eventName != 'Purchase') {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const value = parseFloat((_a = payload.data) === null || _a === void 0 ? void 0 : _a.value);
|
|
140
|
+
return value === 0;
|
|
141
|
+
};
|
|
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
|
+
|
|
134
420
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
135
421
|
let edgeTagSettings;
|
|
136
422
|
const initSettings = (destination, options) => {
|
|
@@ -143,6 +429,8 @@ const initSettings = (destination, options) => {
|
|
|
143
429
|
stubs: [],
|
|
144
430
|
browserPackages: [],
|
|
145
431
|
channels: new Map(),
|
|
432
|
+
geoRegion: null,
|
|
433
|
+
isEURequest: false,
|
|
146
434
|
...options,
|
|
147
435
|
};
|
|
148
436
|
};
|
|
@@ -181,6 +469,7 @@ const getProviderVariables = (destination, packageId) => {
|
|
|
181
469
|
.filter((pkg) => pkg.package === packageId)
|
|
182
470
|
.map((pkg) => ({
|
|
183
471
|
tagName: pkg.tagName,
|
|
472
|
+
geoRegions: pkg.geoRegions || null,
|
|
184
473
|
variableSet: pkg.variables || {},
|
|
185
474
|
})) || []);
|
|
186
475
|
};
|
|
@@ -562,7 +851,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
562
851
|
referrer: getReferrer(destination),
|
|
563
852
|
search: getSearch(destination),
|
|
564
853
|
locale: getLocale(),
|
|
565
|
-
sdkVersion: "0.
|
|
854
|
+
sdkVersion: "0.72.0" ,
|
|
566
855
|
...(payload || {}),
|
|
567
856
|
};
|
|
568
857
|
let storage = {};
|
|
@@ -729,9 +1018,15 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
729
1018
|
}
|
|
730
1019
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
731
1020
|
const configuredTags = getSetting(destination, 'channels');
|
|
1021
|
+
const skipZeroPurchaseEvent = getSetting(destination, 'skipZeroPurchaseEvent') || false;
|
|
1022
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1023
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
732
1024
|
const userId = getUserId$1(destination);
|
|
733
1025
|
const providerData = {};
|
|
734
1026
|
const consent = getConsent$1(destination);
|
|
1027
|
+
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
735
1030
|
const conversion = preparePayloadWithConversion(JSON.parse(JSON.stringify(data)), getSetting(destination, 'currency'));
|
|
736
1031
|
for (const pkg of providerPackages) {
|
|
737
1032
|
if (!pkg || !pkg.name || !pkg.tag) {
|
|
@@ -753,6 +1048,10 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
753
1048
|
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
754
1049
|
continue;
|
|
755
1050
|
}
|
|
1051
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1052
|
+
logger.log('GEO request region does not match the filter, skiping');
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
756
1055
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
757
1056
|
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(pkg.name))
|
|
758
1057
|
? conversion.payload
|
|
@@ -834,6 +1133,8 @@ const processData = (destination, data, providers, options) => {
|
|
|
834
1133
|
const configuredTags = getSetting(destination, 'channels');
|
|
835
1134
|
const userId = getUserId$1(destination);
|
|
836
1135
|
const consent = getConsent$1(destination);
|
|
1136
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1137
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
837
1138
|
for (const pkg of providerPackages) {
|
|
838
1139
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
839
1140
|
continue;
|
|
@@ -852,6 +1153,10 @@ const processData = (destination, data, providers, options) => {
|
|
|
852
1153
|
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
853
1154
|
continue;
|
|
854
1155
|
}
|
|
1156
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1157
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
855
1160
|
pkg.user({
|
|
856
1161
|
userId,
|
|
857
1162
|
data,
|
|
@@ -912,6 +1217,8 @@ const processConsent = (destination, consent, options) => {
|
|
|
912
1217
|
const userId = getUserId$1(destination);
|
|
913
1218
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
914
1219
|
const executionContext = new Map();
|
|
1220
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1221
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
915
1222
|
/* Calling Init for all provider instances based on consent check */
|
|
916
1223
|
for (const pkg of providerPackages) {
|
|
917
1224
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
@@ -923,6 +1230,9 @@ const processConsent = (destination, consent, options) => {
|
|
|
923
1230
|
if (!hasConsent) {
|
|
924
1231
|
continue;
|
|
925
1232
|
}
|
|
1233
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1234
|
+
continue;
|
|
1235
|
+
}
|
|
926
1236
|
pkg.init({
|
|
927
1237
|
userId,
|
|
928
1238
|
isNewUser: false,
|
|
@@ -931,6 +1241,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
931
1241
|
tagName: variable.tagName,
|
|
932
1242
|
variables: variable.variableSet,
|
|
933
1243
|
package: pkg.name,
|
|
1244
|
+
geoRegions: variable.geoRegions,
|
|
934
1245
|
},
|
|
935
1246
|
sendTag: sendTag.bind(null, destination),
|
|
936
1247
|
sendEdgeData: processData.bind(null, destination),
|
|
@@ -1129,7 +1440,8 @@ const handleManifest = (destination, response) => {
|
|
|
1129
1440
|
if (pkg && pkg.name && pkg.init) {
|
|
1130
1441
|
/* this defines if the consent is given for a specific instance of a provider */
|
|
1131
1442
|
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
1132
|
-
if (hasConsent
|
|
1443
|
+
if (hasConsent &&
|
|
1444
|
+
doesGeoRequestMatchList(response.geoRegion, response.isEURequest, provider.geoRegions)) {
|
|
1133
1445
|
pkg.init({
|
|
1134
1446
|
userId,
|
|
1135
1447
|
isNewUser: !!response.isNewUser,
|
|
@@ -1224,6 +1536,9 @@ const handleInit = (preferences) => {
|
|
|
1224
1536
|
browserPackages: Object.values(providers),
|
|
1225
1537
|
storageId: result.storageId,
|
|
1226
1538
|
currency: result.currency,
|
|
1539
|
+
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
1540
|
+
geoRegion: result.geoRegion,
|
|
1541
|
+
isEURequest: result.isEURequest,
|
|
1227
1542
|
});
|
|
1228
1543
|
if (result.storageId != null) {
|
|
1229
1544
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
@@ -1256,6 +1571,8 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1256
1571
|
const configuredTags = getSetting(destination, 'channels');
|
|
1257
1572
|
const consent = getConsent$1(destination);
|
|
1258
1573
|
const userId = getUserId$1(destination);
|
|
1574
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1575
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1259
1576
|
for (const pkg of providerPackages) {
|
|
1260
1577
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1261
1578
|
continue;
|
|
@@ -1274,6 +1591,10 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1274
1591
|
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1275
1592
|
continue;
|
|
1276
1593
|
}
|
|
1594
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1595
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1277
1598
|
pkg.user({
|
|
1278
1599
|
userId,
|
|
1279
1600
|
data: { [key]: value },
|
package/index.d.ts
CHANGED
package/index.mjs
CHANGED
|
@@ -129,6 +129,292 @@ 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
|
+
const isZeroPurchaseEvent = (payload) => {
|
|
133
|
+
var _a;
|
|
134
|
+
if (payload.eventName != 'Purchase') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const value = parseFloat((_a = payload.data) === null || _a === void 0 ? void 0 : _a.value);
|
|
138
|
+
return value === 0;
|
|
139
|
+
};
|
|
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
|
+
|
|
132
418
|
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
133
419
|
let edgeTagSettings;
|
|
134
420
|
const initSettings = (destination, options) => {
|
|
@@ -141,6 +427,8 @@ const initSettings = (destination, options) => {
|
|
|
141
427
|
stubs: [],
|
|
142
428
|
browserPackages: [],
|
|
143
429
|
channels: new Map(),
|
|
430
|
+
geoRegion: null,
|
|
431
|
+
isEURequest: false,
|
|
144
432
|
...options,
|
|
145
433
|
};
|
|
146
434
|
};
|
|
@@ -179,6 +467,7 @@ const getProviderVariables = (destination, packageId) => {
|
|
|
179
467
|
.filter((pkg) => pkg.package === packageId)
|
|
180
468
|
.map((pkg) => ({
|
|
181
469
|
tagName: pkg.tagName,
|
|
470
|
+
geoRegions: pkg.geoRegions || null,
|
|
182
471
|
variableSet: pkg.variables || {},
|
|
183
472
|
})) || []);
|
|
184
473
|
};
|
|
@@ -560,7 +849,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
560
849
|
referrer: getReferrer(destination),
|
|
561
850
|
search: getSearch(destination),
|
|
562
851
|
locale: getLocale(),
|
|
563
|
-
sdkVersion: "0.
|
|
852
|
+
sdkVersion: "0.72.0" ,
|
|
564
853
|
...(payload || {}),
|
|
565
854
|
};
|
|
566
855
|
let storage = {};
|
|
@@ -727,9 +1016,15 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
727
1016
|
}
|
|
728
1017
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
729
1018
|
const configuredTags = getSetting(destination, 'channels');
|
|
1019
|
+
const skipZeroPurchaseEvent = getSetting(destination, 'skipZeroPurchaseEvent') || false;
|
|
1020
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1021
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
730
1022
|
const userId = getUserId$1(destination);
|
|
731
1023
|
const providerData = {};
|
|
732
1024
|
const consent = getConsent$1(destination);
|
|
1025
|
+
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
733
1028
|
const conversion = preparePayloadWithConversion(JSON.parse(JSON.stringify(data)), getSetting(destination, 'currency'));
|
|
734
1029
|
for (const pkg of providerPackages) {
|
|
735
1030
|
if (!pkg || !pkg.name || !pkg.tag) {
|
|
@@ -751,6 +1046,10 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
751
1046
|
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
752
1047
|
continue;
|
|
753
1048
|
}
|
|
1049
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1050
|
+
logger.log('GEO request region does not match the filter, skiping');
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
754
1053
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
755
1054
|
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(pkg.name))
|
|
756
1055
|
? conversion.payload
|
|
@@ -832,6 +1131,8 @@ const processData = (destination, data, providers, options) => {
|
|
|
832
1131
|
const configuredTags = getSetting(destination, 'channels');
|
|
833
1132
|
const userId = getUserId$1(destination);
|
|
834
1133
|
const consent = getConsent$1(destination);
|
|
1134
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1135
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
835
1136
|
for (const pkg of providerPackages) {
|
|
836
1137
|
if (!pkg || !pkg.user || !pkg.name) {
|
|
837
1138
|
continue;
|
|
@@ -850,6 +1151,10 @@ const processData = (destination, data, providers, options) => {
|
|
|
850
1151
|
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
851
1152
|
continue;
|
|
852
1153
|
}
|
|
1154
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1155
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
853
1158
|
pkg.user({
|
|
854
1159
|
userId,
|
|
855
1160
|
data,
|
|
@@ -910,6 +1215,8 @@ const processConsent = (destination, consent, options) => {
|
|
|
910
1215
|
const userId = getUserId$1(destination);
|
|
911
1216
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
912
1217
|
const executionContext = new Map();
|
|
1218
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1219
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
913
1220
|
/* Calling Init for all provider instances based on consent check */
|
|
914
1221
|
for (const pkg of providerPackages) {
|
|
915
1222
|
if (!pkg || !pkg.name || !pkg.init) {
|
|
@@ -921,6 +1228,9 @@ const processConsent = (destination, consent, options) => {
|
|
|
921
1228
|
if (!hasConsent) {
|
|
922
1229
|
continue;
|
|
923
1230
|
}
|
|
1231
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
924
1234
|
pkg.init({
|
|
925
1235
|
userId,
|
|
926
1236
|
isNewUser: false,
|
|
@@ -929,6 +1239,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
929
1239
|
tagName: variable.tagName,
|
|
930
1240
|
variables: variable.variableSet,
|
|
931
1241
|
package: pkg.name,
|
|
1242
|
+
geoRegions: variable.geoRegions,
|
|
932
1243
|
},
|
|
933
1244
|
sendTag: sendTag.bind(null, destination),
|
|
934
1245
|
sendEdgeData: processData.bind(null, destination),
|
|
@@ -1127,7 +1438,8 @@ const handleManifest = (destination, response) => {
|
|
|
1127
1438
|
if (pkg && pkg.name && pkg.init) {
|
|
1128
1439
|
/* this defines if the consent is given for a specific instance of a provider */
|
|
1129
1440
|
const hasConsent = hasUserConsent(getSetting(destination, 'consent'), pkg.name, provider.tagName);
|
|
1130
|
-
if (hasConsent
|
|
1441
|
+
if (hasConsent &&
|
|
1442
|
+
doesGeoRequestMatchList(response.geoRegion, response.isEURequest, provider.geoRegions)) {
|
|
1131
1443
|
pkg.init({
|
|
1132
1444
|
userId,
|
|
1133
1445
|
isNewUser: !!response.isNewUser,
|
|
@@ -1222,6 +1534,9 @@ const handleInit = (preferences) => {
|
|
|
1222
1534
|
browserPackages: Object.values(providers),
|
|
1223
1535
|
storageId: result.storageId,
|
|
1224
1536
|
currency: result.currency,
|
|
1537
|
+
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
1538
|
+
geoRegion: result.geoRegion,
|
|
1539
|
+
isEURequest: result.isEURequest,
|
|
1225
1540
|
});
|
|
1226
1541
|
if (result.storageId != null) {
|
|
1227
1542
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
@@ -1254,6 +1569,8 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1254
1569
|
const configuredTags = getSetting(destination, 'channels');
|
|
1255
1570
|
const consent = getConsent$1(destination);
|
|
1256
1571
|
const userId = getUserId$1(destination);
|
|
1572
|
+
const requestRegion = getSetting(destination, 'geoRegion') || null;
|
|
1573
|
+
const isEURequest = getSetting(destination, 'isEURequest') || false;
|
|
1257
1574
|
for (const pkg of providerPackages) {
|
|
1258
1575
|
if (!pkg || !pkg.name || !pkg.user) {
|
|
1259
1576
|
continue;
|
|
@@ -1272,6 +1589,10 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1272
1589
|
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1273
1590
|
continue;
|
|
1274
1591
|
}
|
|
1592
|
+
if (!doesGeoRequestMatchList(requestRegion, isEURequest, variable.geoRegions)) {
|
|
1593
|
+
logger.log(`GEO request region does not match list, skipping`);
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1275
1596
|
pkg.user({
|
|
1276
1597
|
userId,
|
|
1277
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
|
|
@@ -60,4 +60,7 @@ type InitResponse = {
|
|
|
60
60
|
providers: string[]
|
|
61
61
|
rates: { from: string; to: string; value: number }[]
|
|
62
62
|
}
|
|
63
|
+
skipZeroPurchaseEvent?: boolean
|
|
64
|
+
geoRegion: string | null
|
|
65
|
+
isEURequest: boolean
|
|
63
66
|
}
|