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