@blotoutio/edgetag-sdk-js 0.68.2 → 0.69.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 +131 -128
- package/index.mjs +131 -128
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -280,21 +280,87 @@ const cookieKey = 'tag_user_id';
|
|
|
280
280
|
const fallbackSessionKey = 'fallback_tag_user_id';
|
|
281
281
|
const storageIdKey = 'storageId';
|
|
282
282
|
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
return
|
|
283
|
+
const encodeString = (name) => {
|
|
284
|
+
if (typeof btoa === 'undefined') {
|
|
285
|
+
return Buffer.from(name).toString('base64');
|
|
286
|
+
}
|
|
287
|
+
return btoa(name);
|
|
288
|
+
};
|
|
289
|
+
const getBasicRandomNumber = () => {
|
|
290
|
+
return parseInt((Math.random() * 10000000000).toString(), 10);
|
|
291
|
+
};
|
|
292
|
+
const generateUUID = () => {
|
|
293
|
+
let id = '';
|
|
294
|
+
try {
|
|
295
|
+
id = crypto.randomUUID();
|
|
296
|
+
if (!id) {
|
|
297
|
+
const array = new Uint32Array(20);
|
|
298
|
+
const numbers = crypto.getRandomValues(array);
|
|
299
|
+
for (let i = 0; i < 5; i++) {
|
|
300
|
+
const y = i * 3;
|
|
301
|
+
if (i !== 0) {
|
|
302
|
+
id += '-';
|
|
303
|
+
}
|
|
304
|
+
const sum = numbers[y + 1] + numbers[y + 2] + numbers[y + 3];
|
|
305
|
+
id += sum.toString();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
286
308
|
}
|
|
287
|
-
|
|
288
|
-
|
|
309
|
+
catch {
|
|
310
|
+
id = `${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}`;
|
|
311
|
+
console.log('[EdgeTag] Crypto module not found');
|
|
289
312
|
}
|
|
313
|
+
return id;
|
|
314
|
+
};
|
|
315
|
+
const generateEventId = (name) => {
|
|
316
|
+
let time = Date.now().toString();
|
|
317
|
+
if (typeof performance !== 'undefined' &&
|
|
318
|
+
typeof performance.now === 'function') {
|
|
319
|
+
const perf = performance.now();
|
|
320
|
+
if (perf) {
|
|
321
|
+
time = perf.toFixed(4);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const getCookieValue = (key) => {
|
|
328
|
+
var _a;
|
|
290
329
|
try {
|
|
291
|
-
|
|
330
|
+
if (!document || !document.cookie) {
|
|
331
|
+
return '';
|
|
332
|
+
}
|
|
333
|
+
const cookies = parseCookies(document.cookie);
|
|
334
|
+
return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
|
|
292
335
|
}
|
|
293
336
|
catch {
|
|
294
|
-
return
|
|
337
|
+
return '';
|
|
295
338
|
}
|
|
296
339
|
};
|
|
297
|
-
const
|
|
340
|
+
const parseCookies = (cookie) => {
|
|
341
|
+
return Object.fromEntries(cookie
|
|
342
|
+
.split(/;\s+/)
|
|
343
|
+
.map((r) => r.split('=').map((str) => str.trim()))
|
|
344
|
+
.map(([cookieKey, ...cookieValues]) => {
|
|
345
|
+
const cookieValue = cookieValues.join('=');
|
|
346
|
+
if (!cookieKey) {
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
349
|
+
let decodedValue = '';
|
|
350
|
+
if (cookieValue) {
|
|
351
|
+
try {
|
|
352
|
+
decodedValue = decodeURIComponent(cookieValue);
|
|
353
|
+
}
|
|
354
|
+
catch (e) {
|
|
355
|
+
console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
|
|
356
|
+
decodedValue = cookieValue;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return [cookieKey, decodedValue];
|
|
360
|
+
}));
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const canLog = () => {
|
|
298
364
|
try {
|
|
299
365
|
return localStorage.getItem('edgeTagDebug') === '1';
|
|
300
366
|
}
|
|
@@ -302,14 +368,28 @@ const allowLog = () => {
|
|
|
302
368
|
return false;
|
|
303
369
|
}
|
|
304
370
|
};
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
371
|
+
const prefix = `[EdgeTag]`;
|
|
372
|
+
const logger = {
|
|
373
|
+
log: (...args) => {
|
|
374
|
+
if (canLog()) {
|
|
375
|
+
console.log(prefix, ...args);
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
error: (...args) => {
|
|
379
|
+
if (canLog()) {
|
|
380
|
+
console.error(prefix, ...args);
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
info: (...args) => {
|
|
384
|
+
if (canLog()) {
|
|
385
|
+
console.info(prefix, ...args);
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
trace: (...args) => {
|
|
389
|
+
if (canLog()) {
|
|
390
|
+
console.trace(prefix, ...args);
|
|
391
|
+
}
|
|
392
|
+
},
|
|
313
393
|
};
|
|
314
394
|
|
|
315
395
|
const initKey = `${keyPrefix}StoreMultiple`;
|
|
@@ -379,7 +459,7 @@ const saveLocal = (value, key) => {
|
|
|
379
459
|
localStorage.setItem(key, JSON.stringify(value));
|
|
380
460
|
}
|
|
381
461
|
catch {
|
|
382
|
-
log('Local storage not supported.');
|
|
462
|
+
logger.log('Local storage not supported.');
|
|
383
463
|
}
|
|
384
464
|
};
|
|
385
465
|
const getLocal = (key) => {
|
|
@@ -405,7 +485,7 @@ const saveSession = (value, key) => {
|
|
|
405
485
|
sessionStorage.setItem(key, JSON.stringify(value));
|
|
406
486
|
}
|
|
407
487
|
catch {
|
|
408
|
-
log('Session storage not supported.');
|
|
488
|
+
logger.log('Session storage not supported.');
|
|
409
489
|
}
|
|
410
490
|
};
|
|
411
491
|
const getSession = (key) => {
|
|
@@ -424,86 +504,6 @@ const getSession = (key) => {
|
|
|
424
504
|
}
|
|
425
505
|
};
|
|
426
506
|
|
|
427
|
-
const encodeString = (name) => {
|
|
428
|
-
if (typeof btoa === 'undefined') {
|
|
429
|
-
return Buffer.from(name).toString('base64');
|
|
430
|
-
}
|
|
431
|
-
return btoa(name);
|
|
432
|
-
};
|
|
433
|
-
const getBasicRandomNumber = () => {
|
|
434
|
-
return parseInt((Math.random() * 10000000000).toString(), 10);
|
|
435
|
-
};
|
|
436
|
-
const generateUUID = () => {
|
|
437
|
-
let id = '';
|
|
438
|
-
try {
|
|
439
|
-
id = crypto.randomUUID();
|
|
440
|
-
if (!id) {
|
|
441
|
-
const array = new Uint32Array(20);
|
|
442
|
-
const numbers = crypto.getRandomValues(array);
|
|
443
|
-
for (let i = 0; i < 5; i++) {
|
|
444
|
-
const y = i * 3;
|
|
445
|
-
if (i !== 0) {
|
|
446
|
-
id += '-';
|
|
447
|
-
}
|
|
448
|
-
const sum = numbers[y + 1] + numbers[y + 2] + numbers[y + 3];
|
|
449
|
-
id += sum.toString();
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
catch {
|
|
454
|
-
id = `${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}`;
|
|
455
|
-
console.log('[EdgeTag] Crypto module not found');
|
|
456
|
-
}
|
|
457
|
-
return id;
|
|
458
|
-
};
|
|
459
|
-
const generateEventId = (name) => {
|
|
460
|
-
let time = Date.now().toString();
|
|
461
|
-
if (typeof performance !== 'undefined' &&
|
|
462
|
-
typeof performance.now === 'function') {
|
|
463
|
-
const perf = performance.now();
|
|
464
|
-
if (perf) {
|
|
465
|
-
time = perf.toFixed(4);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
const getCookieValue = (key) => {
|
|
472
|
-
var _a;
|
|
473
|
-
try {
|
|
474
|
-
if (!document || !document.cookie) {
|
|
475
|
-
return '';
|
|
476
|
-
}
|
|
477
|
-
const cookies = parseCookies(document.cookie);
|
|
478
|
-
return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
|
|
479
|
-
}
|
|
480
|
-
catch {
|
|
481
|
-
return '';
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
const parseCookies = (cookie) => {
|
|
485
|
-
return Object.fromEntries(cookie
|
|
486
|
-
.split(/;\s+/)
|
|
487
|
-
.map((r) => r.split('=').map((str) => str.trim()))
|
|
488
|
-
.map(([cookieKey, ...cookieValues]) => {
|
|
489
|
-
const cookieValue = cookieValues.join('=');
|
|
490
|
-
if (!cookieKey) {
|
|
491
|
-
return [];
|
|
492
|
-
}
|
|
493
|
-
let decodedValue = '';
|
|
494
|
-
if (cookieValue) {
|
|
495
|
-
try {
|
|
496
|
-
decodedValue = decodeURIComponent(cookieValue);
|
|
497
|
-
}
|
|
498
|
-
catch (e) {
|
|
499
|
-
console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
|
|
500
|
-
decodedValue = cookieValue;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return [cookieKey, decodedValue];
|
|
504
|
-
}));
|
|
505
|
-
};
|
|
506
|
-
|
|
507
507
|
const getUserId$1 = (destination) => {
|
|
508
508
|
const userId = getSetting(destination, 'userId');
|
|
509
509
|
if (userId) {
|
|
@@ -517,7 +517,7 @@ const handleGetUserId = (options) => {
|
|
|
517
517
|
}
|
|
518
518
|
const instances = getInstances();
|
|
519
519
|
if (instances.length > 1) {
|
|
520
|
-
error('Multiple instances detected! Please provide a destination.');
|
|
520
|
+
logger.error('Multiple instances detected! Please provide a destination.');
|
|
521
521
|
return '';
|
|
522
522
|
}
|
|
523
523
|
return getUserId$1(instances[0]);
|
|
@@ -562,7 +562,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
562
562
|
referrer: getReferrer(destination),
|
|
563
563
|
search: getSearch(destination),
|
|
564
564
|
locale: getLocale(),
|
|
565
|
-
sdkVersion: "0.
|
|
565
|
+
sdkVersion: "0.69.0" ,
|
|
566
566
|
...(payload || {}),
|
|
567
567
|
};
|
|
568
568
|
let storage = {};
|
|
@@ -611,7 +611,7 @@ async function getRequest(url, options) {
|
|
|
611
611
|
|
|
612
612
|
const generateUrl = (destination, path) => {
|
|
613
613
|
if (!destination) {
|
|
614
|
-
log('URL is not valid');
|
|
614
|
+
logger.log('URL is not valid');
|
|
615
615
|
return '';
|
|
616
616
|
}
|
|
617
617
|
return `${destination}${path}`;
|
|
@@ -664,7 +664,7 @@ const processStubs = (destination) => {
|
|
|
664
664
|
});
|
|
665
665
|
}
|
|
666
666
|
catch (e) {
|
|
667
|
-
error(e);
|
|
667
|
+
logger.error(e);
|
|
668
668
|
}
|
|
669
669
|
};
|
|
670
670
|
const addStub = (destination, stub) => {
|
|
@@ -712,7 +712,7 @@ const sendTag = (destination, { eventName, eventId, data, providerData, provider
|
|
|
712
712
|
if (providers) {
|
|
713
713
|
payload.providers = providers;
|
|
714
714
|
}
|
|
715
|
-
postRequest(getTagURL(destination, eventName, options), payload, options).catch(error);
|
|
715
|
+
postRequest(getTagURL(destination, eventName, options), payload, options).catch(logger.error);
|
|
716
716
|
};
|
|
717
717
|
const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
718
718
|
var _a, _b;
|
|
@@ -738,7 +738,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
738
738
|
continue;
|
|
739
739
|
}
|
|
740
740
|
if (!configuredTags.has(pkg.name)) {
|
|
741
|
-
log(`Provider ${pkg.name} is not in allow list`);
|
|
741
|
+
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
742
742
|
continue;
|
|
743
743
|
}
|
|
744
744
|
const variables = getProviderVariables(destination, pkg.name);
|
|
@@ -746,11 +746,11 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
746
746
|
const executionContext = new Map();
|
|
747
747
|
for (const variable of variables) {
|
|
748
748
|
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
749
|
-
log(`Provider instance is not allowed (${pkg.name}: ${variable.tagName})`);
|
|
749
|
+
logger.log(`Provider instance is not allowed (${pkg.name}: ${variable.tagName})`);
|
|
750
750
|
continue;
|
|
751
751
|
}
|
|
752
752
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
753
|
-
log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
753
|
+
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
754
754
|
continue;
|
|
755
755
|
}
|
|
756
756
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
@@ -808,11 +808,11 @@ const processGetData = (destination, keys, callback) => {
|
|
|
808
808
|
.then((result) => {
|
|
809
809
|
callback((result === null || result === void 0 ? void 0 : result.result) || {});
|
|
810
810
|
})
|
|
811
|
-
.catch(error);
|
|
811
|
+
.catch(logger.error);
|
|
812
812
|
};
|
|
813
813
|
const handleGetData = (keys, callback, options) => {
|
|
814
814
|
if (!keys || keys.length === 0) {
|
|
815
|
-
error('Provide keys for get data API.');
|
|
815
|
+
logger.error('Provide keys for get data API.');
|
|
816
816
|
return;
|
|
817
817
|
}
|
|
818
818
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -821,7 +821,7 @@ const handleGetData = (keys, callback, options) => {
|
|
|
821
821
|
}
|
|
822
822
|
const instances = getInstances();
|
|
823
823
|
if (instances.length > 1) {
|
|
824
|
-
error('Multiple instances found! Please provide destination.');
|
|
824
|
+
logger.error('Multiple instances found! Please provide destination.');
|
|
825
825
|
callback({});
|
|
826
826
|
return;
|
|
827
827
|
}
|
|
@@ -839,17 +839,17 @@ const processData = (destination, data, providers, options) => {
|
|
|
839
839
|
continue;
|
|
840
840
|
}
|
|
841
841
|
if (!configuredTags.has(pkg.name)) {
|
|
842
|
-
log(`Provider ${pkg.name} is not in allow list`);
|
|
842
|
+
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
843
843
|
continue;
|
|
844
844
|
}
|
|
845
845
|
const variables = getProviderVariables(destination, pkg.name);
|
|
846
846
|
for (const variable of variables) {
|
|
847
847
|
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
848
|
-
log(`Data not allowed for ${pkg.name} (${variable.tagName})`);
|
|
848
|
+
logger.log(`Data not allowed for ${pkg.name} (${variable.tagName})`);
|
|
849
849
|
continue;
|
|
850
850
|
}
|
|
851
851
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
852
|
-
log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
852
|
+
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
853
853
|
continue;
|
|
854
854
|
}
|
|
855
855
|
pkg.user({
|
|
@@ -859,11 +859,11 @@ const processData = (destination, data, providers, options) => {
|
|
|
859
859
|
});
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
postRequest(getDataURL(destination), { data, providers }, options).catch(error);
|
|
862
|
+
postRequest(getDataURL(destination), { data, providers }, options).catch(logger.error);
|
|
863
863
|
};
|
|
864
864
|
const handleData = (data, providers, options) => {
|
|
865
865
|
if (!data || Object.keys(data).length === 0) {
|
|
866
|
-
error('Provide data for data API.');
|
|
866
|
+
logger.error('Provide data for data API.');
|
|
867
867
|
return;
|
|
868
868
|
}
|
|
869
869
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -907,7 +907,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
907
907
|
};
|
|
908
908
|
saveConsent(destination, consent);
|
|
909
909
|
if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
|
|
910
|
-
postRequest(getConsentURL(destination), payload).catch(error);
|
|
910
|
+
postRequest(getConsentURL(destination), payload).catch(logger.error);
|
|
911
911
|
}
|
|
912
912
|
const userId = getUserId$1(destination);
|
|
913
913
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
@@ -938,6 +938,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
938
938
|
keyName: `${keyPrefix}Store`,
|
|
939
939
|
executionContext,
|
|
940
940
|
session: null,
|
|
941
|
+
destination,
|
|
941
942
|
});
|
|
942
943
|
}
|
|
943
944
|
}
|
|
@@ -970,7 +971,7 @@ const setPreferences = (preferences) => {
|
|
|
970
971
|
return null;
|
|
971
972
|
}
|
|
972
973
|
if (!preferences.edgeURL) {
|
|
973
|
-
error('Please provide URL for EdgeTag');
|
|
974
|
+
logger.error('Please provide URL for EdgeTag');
|
|
974
975
|
return null;
|
|
975
976
|
}
|
|
976
977
|
const providersPackages = {};
|
|
@@ -1011,7 +1012,7 @@ const saveDataToEdge = (destination, key, value, provider) => {
|
|
|
1011
1012
|
updatedValue = JSON.stringify(value);
|
|
1012
1013
|
}
|
|
1013
1014
|
catch {
|
|
1014
|
-
log('Error stringify value.');
|
|
1015
|
+
logger.log('Error stringify value.');
|
|
1015
1016
|
return;
|
|
1016
1017
|
}
|
|
1017
1018
|
}
|
|
@@ -1106,6 +1107,7 @@ const handleCapture = (destination, provider, params, capture) => {
|
|
|
1106
1107
|
});
|
|
1107
1108
|
};
|
|
1108
1109
|
|
|
1110
|
+
const keyName = `${keyPrefix}Store`;
|
|
1109
1111
|
const handleManifest = (destination, response) => {
|
|
1110
1112
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1111
1113
|
const userId = getUserId$1(destination);
|
|
@@ -1137,8 +1139,9 @@ const handleManifest = (destination, response) => {
|
|
|
1137
1139
|
sendTag: sendTag.bind(null, destination),
|
|
1138
1140
|
sendEdgeData: processData.bind(null, destination),
|
|
1139
1141
|
getEdgeData: processGetData.bind(null, destination),
|
|
1140
|
-
keyName
|
|
1142
|
+
keyName,
|
|
1141
1143
|
executionContext,
|
|
1144
|
+
destination,
|
|
1142
1145
|
});
|
|
1143
1146
|
}
|
|
1144
1147
|
}
|
|
@@ -1199,7 +1202,7 @@ const handleInit = (preferences) => {
|
|
|
1199
1202
|
.then((result) => {
|
|
1200
1203
|
var _a;
|
|
1201
1204
|
if (!result) {
|
|
1202
|
-
error('Initialization failed');
|
|
1205
|
+
logger.error('Initialization failed');
|
|
1203
1206
|
return;
|
|
1204
1207
|
}
|
|
1205
1208
|
if (result.isNewUser && result.consent) {
|
|
@@ -1242,7 +1245,7 @@ const handleInit = (preferences) => {
|
|
|
1242
1245
|
// do nothing
|
|
1243
1246
|
}
|
|
1244
1247
|
})
|
|
1245
|
-
.catch(error);
|
|
1248
|
+
.catch(logger.error);
|
|
1246
1249
|
};
|
|
1247
1250
|
|
|
1248
1251
|
const processUser = (destination, key, value, providers, options) => {
|
|
@@ -1258,17 +1261,17 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1258
1261
|
continue;
|
|
1259
1262
|
}
|
|
1260
1263
|
if (!configuredTags.has(pkg.name)) {
|
|
1261
|
-
log(`Provider ${pkg.name} is not in allow list`);
|
|
1264
|
+
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
1262
1265
|
continue;
|
|
1263
1266
|
}
|
|
1264
1267
|
const variables = getProviderVariables(destination, pkg.name);
|
|
1265
1268
|
for (const variable of variables) {
|
|
1266
1269
|
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
1267
|
-
log(`User not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1270
|
+
logger.log(`User not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1268
1271
|
continue;
|
|
1269
1272
|
}
|
|
1270
1273
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
1271
|
-
log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1274
|
+
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1272
1275
|
continue;
|
|
1273
1276
|
}
|
|
1274
1277
|
pkg.user({
|
|
@@ -1282,11 +1285,11 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1282
1285
|
key,
|
|
1283
1286
|
value,
|
|
1284
1287
|
providers,
|
|
1285
|
-
}, options).catch(error);
|
|
1288
|
+
}, options).catch(logger.error);
|
|
1286
1289
|
};
|
|
1287
1290
|
const handleUser = (key, value, providers, options) => {
|
|
1288
1291
|
if (!key || !value) {
|
|
1289
|
-
error('Key or Value is missing in user API.');
|
|
1292
|
+
logger.error('Key or Value is missing in user API.');
|
|
1290
1293
|
return;
|
|
1291
1294
|
}
|
|
1292
1295
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -1303,7 +1306,7 @@ const processKeys = (destination, callback) => {
|
|
|
1303
1306
|
.then((result) => {
|
|
1304
1307
|
callback((result === null || result === void 0 ? void 0 : result.result) || []);
|
|
1305
1308
|
})
|
|
1306
|
-
.catch(error);
|
|
1309
|
+
.catch(logger.error);
|
|
1307
1310
|
};
|
|
1308
1311
|
const handleKeys = (callback, options) => {
|
|
1309
1312
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -1312,7 +1315,7 @@ const handleKeys = (callback, options) => {
|
|
|
1312
1315
|
}
|
|
1313
1316
|
const instances = getInstances();
|
|
1314
1317
|
if (instances.length > 1) {
|
|
1315
|
-
error('Multiple instances found! Please provide destination.');
|
|
1318
|
+
logger.error('Multiple instances found! Please provide destination.');
|
|
1316
1319
|
callback([]);
|
|
1317
1320
|
return;
|
|
1318
1321
|
}
|
|
@@ -1355,7 +1358,7 @@ const handleIsNewUser = (options) => {
|
|
|
1355
1358
|
}
|
|
1356
1359
|
const instances = getInstances();
|
|
1357
1360
|
if (instances.length > 1) {
|
|
1358
|
-
error('Multiple instances found! Please provide destination.');
|
|
1361
|
+
logger.error('Multiple instances found! Please provide destination.');
|
|
1359
1362
|
return undefined;
|
|
1360
1363
|
}
|
|
1361
1364
|
return getSetting(instances[0], 'isNewUser');
|
package/index.mjs
CHANGED
|
@@ -278,21 +278,87 @@ const cookieKey = 'tag_user_id';
|
|
|
278
278
|
const fallbackSessionKey = 'fallback_tag_user_id';
|
|
279
279
|
const storageIdKey = 'storageId';
|
|
280
280
|
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
return
|
|
281
|
+
const encodeString = (name) => {
|
|
282
|
+
if (typeof btoa === 'undefined') {
|
|
283
|
+
return Buffer.from(name).toString('base64');
|
|
284
|
+
}
|
|
285
|
+
return btoa(name);
|
|
286
|
+
};
|
|
287
|
+
const getBasicRandomNumber = () => {
|
|
288
|
+
return parseInt((Math.random() * 10000000000).toString(), 10);
|
|
289
|
+
};
|
|
290
|
+
const generateUUID = () => {
|
|
291
|
+
let id = '';
|
|
292
|
+
try {
|
|
293
|
+
id = crypto.randomUUID();
|
|
294
|
+
if (!id) {
|
|
295
|
+
const array = new Uint32Array(20);
|
|
296
|
+
const numbers = crypto.getRandomValues(array);
|
|
297
|
+
for (let i = 0; i < 5; i++) {
|
|
298
|
+
const y = i * 3;
|
|
299
|
+
if (i !== 0) {
|
|
300
|
+
id += '-';
|
|
301
|
+
}
|
|
302
|
+
const sum = numbers[y + 1] + numbers[y + 2] + numbers[y + 3];
|
|
303
|
+
id += sum.toString();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
284
306
|
}
|
|
285
|
-
|
|
286
|
-
|
|
307
|
+
catch {
|
|
308
|
+
id = `${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}`;
|
|
309
|
+
console.log('[EdgeTag] Crypto module not found');
|
|
287
310
|
}
|
|
311
|
+
return id;
|
|
312
|
+
};
|
|
313
|
+
const generateEventId = (name) => {
|
|
314
|
+
let time = Date.now().toString();
|
|
315
|
+
if (typeof performance !== 'undefined' &&
|
|
316
|
+
typeof performance.now === 'function') {
|
|
317
|
+
const perf = performance.now();
|
|
318
|
+
if (perf) {
|
|
319
|
+
time = perf.toFixed(4);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const getCookieValue = (key) => {
|
|
326
|
+
var _a;
|
|
288
327
|
try {
|
|
289
|
-
|
|
328
|
+
if (!document || !document.cookie) {
|
|
329
|
+
return '';
|
|
330
|
+
}
|
|
331
|
+
const cookies = parseCookies(document.cookie);
|
|
332
|
+
return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
|
|
290
333
|
}
|
|
291
334
|
catch {
|
|
292
|
-
return
|
|
335
|
+
return '';
|
|
293
336
|
}
|
|
294
337
|
};
|
|
295
|
-
const
|
|
338
|
+
const parseCookies = (cookie) => {
|
|
339
|
+
return Object.fromEntries(cookie
|
|
340
|
+
.split(/;\s+/)
|
|
341
|
+
.map((r) => r.split('=').map((str) => str.trim()))
|
|
342
|
+
.map(([cookieKey, ...cookieValues]) => {
|
|
343
|
+
const cookieValue = cookieValues.join('=');
|
|
344
|
+
if (!cookieKey) {
|
|
345
|
+
return [];
|
|
346
|
+
}
|
|
347
|
+
let decodedValue = '';
|
|
348
|
+
if (cookieValue) {
|
|
349
|
+
try {
|
|
350
|
+
decodedValue = decodeURIComponent(cookieValue);
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
|
|
354
|
+
decodedValue = cookieValue;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return [cookieKey, decodedValue];
|
|
358
|
+
}));
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const canLog = () => {
|
|
296
362
|
try {
|
|
297
363
|
return localStorage.getItem('edgeTagDebug') === '1';
|
|
298
364
|
}
|
|
@@ -300,14 +366,28 @@ const allowLog = () => {
|
|
|
300
366
|
return false;
|
|
301
367
|
}
|
|
302
368
|
};
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
369
|
+
const prefix = `[EdgeTag]`;
|
|
370
|
+
const logger = {
|
|
371
|
+
log: (...args) => {
|
|
372
|
+
if (canLog()) {
|
|
373
|
+
console.log(prefix, ...args);
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
error: (...args) => {
|
|
377
|
+
if (canLog()) {
|
|
378
|
+
console.error(prefix, ...args);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
info: (...args) => {
|
|
382
|
+
if (canLog()) {
|
|
383
|
+
console.info(prefix, ...args);
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
trace: (...args) => {
|
|
387
|
+
if (canLog()) {
|
|
388
|
+
console.trace(prefix, ...args);
|
|
389
|
+
}
|
|
390
|
+
},
|
|
311
391
|
};
|
|
312
392
|
|
|
313
393
|
const initKey = `${keyPrefix}StoreMultiple`;
|
|
@@ -377,7 +457,7 @@ const saveLocal = (value, key) => {
|
|
|
377
457
|
localStorage.setItem(key, JSON.stringify(value));
|
|
378
458
|
}
|
|
379
459
|
catch {
|
|
380
|
-
log('Local storage not supported.');
|
|
460
|
+
logger.log('Local storage not supported.');
|
|
381
461
|
}
|
|
382
462
|
};
|
|
383
463
|
const getLocal = (key) => {
|
|
@@ -403,7 +483,7 @@ const saveSession = (value, key) => {
|
|
|
403
483
|
sessionStorage.setItem(key, JSON.stringify(value));
|
|
404
484
|
}
|
|
405
485
|
catch {
|
|
406
|
-
log('Session storage not supported.');
|
|
486
|
+
logger.log('Session storage not supported.');
|
|
407
487
|
}
|
|
408
488
|
};
|
|
409
489
|
const getSession = (key) => {
|
|
@@ -422,86 +502,6 @@ const getSession = (key) => {
|
|
|
422
502
|
}
|
|
423
503
|
};
|
|
424
504
|
|
|
425
|
-
const encodeString = (name) => {
|
|
426
|
-
if (typeof btoa === 'undefined') {
|
|
427
|
-
return Buffer.from(name).toString('base64');
|
|
428
|
-
}
|
|
429
|
-
return btoa(name);
|
|
430
|
-
};
|
|
431
|
-
const getBasicRandomNumber = () => {
|
|
432
|
-
return parseInt((Math.random() * 10000000000).toString(), 10);
|
|
433
|
-
};
|
|
434
|
-
const generateUUID = () => {
|
|
435
|
-
let id = '';
|
|
436
|
-
try {
|
|
437
|
-
id = crypto.randomUUID();
|
|
438
|
-
if (!id) {
|
|
439
|
-
const array = new Uint32Array(20);
|
|
440
|
-
const numbers = crypto.getRandomValues(array);
|
|
441
|
-
for (let i = 0; i < 5; i++) {
|
|
442
|
-
const y = i * 3;
|
|
443
|
-
if (i !== 0) {
|
|
444
|
-
id += '-';
|
|
445
|
-
}
|
|
446
|
-
const sum = numbers[y + 1] + numbers[y + 2] + numbers[y + 3];
|
|
447
|
-
id += sum.toString();
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
catch {
|
|
452
|
-
id = `${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}-${getBasicRandomNumber()}`;
|
|
453
|
-
console.log('[EdgeTag] Crypto module not found');
|
|
454
|
-
}
|
|
455
|
-
return id;
|
|
456
|
-
};
|
|
457
|
-
const generateEventId = (name) => {
|
|
458
|
-
let time = Date.now().toString();
|
|
459
|
-
if (typeof performance !== 'undefined' &&
|
|
460
|
-
typeof performance.now === 'function') {
|
|
461
|
-
const perf = performance.now();
|
|
462
|
-
if (perf) {
|
|
463
|
-
time = perf.toFixed(4);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
const getCookieValue = (key) => {
|
|
470
|
-
var _a;
|
|
471
|
-
try {
|
|
472
|
-
if (!document || !document.cookie) {
|
|
473
|
-
return '';
|
|
474
|
-
}
|
|
475
|
-
const cookies = parseCookies(document.cookie);
|
|
476
|
-
return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
|
|
477
|
-
}
|
|
478
|
-
catch {
|
|
479
|
-
return '';
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
const parseCookies = (cookie) => {
|
|
483
|
-
return Object.fromEntries(cookie
|
|
484
|
-
.split(/;\s+/)
|
|
485
|
-
.map((r) => r.split('=').map((str) => str.trim()))
|
|
486
|
-
.map(([cookieKey, ...cookieValues]) => {
|
|
487
|
-
const cookieValue = cookieValues.join('=');
|
|
488
|
-
if (!cookieKey) {
|
|
489
|
-
return [];
|
|
490
|
-
}
|
|
491
|
-
let decodedValue = '';
|
|
492
|
-
if (cookieValue) {
|
|
493
|
-
try {
|
|
494
|
-
decodedValue = decodeURIComponent(cookieValue);
|
|
495
|
-
}
|
|
496
|
-
catch (e) {
|
|
497
|
-
console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
|
|
498
|
-
decodedValue = cookieValue;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return [cookieKey, decodedValue];
|
|
502
|
-
}));
|
|
503
|
-
};
|
|
504
|
-
|
|
505
505
|
const getUserId$1 = (destination) => {
|
|
506
506
|
const userId = getSetting(destination, 'userId');
|
|
507
507
|
if (userId) {
|
|
@@ -515,7 +515,7 @@ const handleGetUserId = (options) => {
|
|
|
515
515
|
}
|
|
516
516
|
const instances = getInstances();
|
|
517
517
|
if (instances.length > 1) {
|
|
518
|
-
error('Multiple instances detected! Please provide a destination.');
|
|
518
|
+
logger.error('Multiple instances detected! Please provide a destination.');
|
|
519
519
|
return '';
|
|
520
520
|
}
|
|
521
521
|
return getUserId$1(instances[0]);
|
|
@@ -560,7 +560,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
560
560
|
referrer: getReferrer(destination),
|
|
561
561
|
search: getSearch(destination),
|
|
562
562
|
locale: getLocale(),
|
|
563
|
-
sdkVersion: "0.
|
|
563
|
+
sdkVersion: "0.69.0" ,
|
|
564
564
|
...(payload || {}),
|
|
565
565
|
};
|
|
566
566
|
let storage = {};
|
|
@@ -609,7 +609,7 @@ async function getRequest(url, options) {
|
|
|
609
609
|
|
|
610
610
|
const generateUrl = (destination, path) => {
|
|
611
611
|
if (!destination) {
|
|
612
|
-
log('URL is not valid');
|
|
612
|
+
logger.log('URL is not valid');
|
|
613
613
|
return '';
|
|
614
614
|
}
|
|
615
615
|
return `${destination}${path}`;
|
|
@@ -662,7 +662,7 @@ const processStubs = (destination) => {
|
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
664
|
catch (e) {
|
|
665
|
-
error(e);
|
|
665
|
+
logger.error(e);
|
|
666
666
|
}
|
|
667
667
|
};
|
|
668
668
|
const addStub = (destination, stub) => {
|
|
@@ -710,7 +710,7 @@ const sendTag = (destination, { eventName, eventId, data, providerData, provider
|
|
|
710
710
|
if (providers) {
|
|
711
711
|
payload.providers = providers;
|
|
712
712
|
}
|
|
713
|
-
postRequest(getTagURL(destination, eventName, options), payload, options).catch(error);
|
|
713
|
+
postRequest(getTagURL(destination, eventName, options), payload, options).catch(logger.error);
|
|
714
714
|
};
|
|
715
715
|
const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
716
716
|
var _a, _b;
|
|
@@ -736,7 +736,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
736
736
|
continue;
|
|
737
737
|
}
|
|
738
738
|
if (!configuredTags.has(pkg.name)) {
|
|
739
|
-
log(`Provider ${pkg.name} is not in allow list`);
|
|
739
|
+
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
740
740
|
continue;
|
|
741
741
|
}
|
|
742
742
|
const variables = getProviderVariables(destination, pkg.name);
|
|
@@ -744,11 +744,11 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
744
744
|
const executionContext = new Map();
|
|
745
745
|
for (const variable of variables) {
|
|
746
746
|
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
747
|
-
log(`Provider instance is not allowed (${pkg.name}: ${variable.tagName})`);
|
|
747
|
+
logger.log(`Provider instance is not allowed (${pkg.name}: ${variable.tagName})`);
|
|
748
748
|
continue;
|
|
749
749
|
}
|
|
750
750
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
751
|
-
log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
751
|
+
logger.log(`Consent is missing (${pkg.name}: ${variable.tagName})`);
|
|
752
752
|
continue;
|
|
753
753
|
}
|
|
754
754
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
@@ -806,11 +806,11 @@ const processGetData = (destination, keys, callback) => {
|
|
|
806
806
|
.then((result) => {
|
|
807
807
|
callback((result === null || result === void 0 ? void 0 : result.result) || {});
|
|
808
808
|
})
|
|
809
|
-
.catch(error);
|
|
809
|
+
.catch(logger.error);
|
|
810
810
|
};
|
|
811
811
|
const handleGetData = (keys, callback, options) => {
|
|
812
812
|
if (!keys || keys.length === 0) {
|
|
813
|
-
error('Provide keys for get data API.');
|
|
813
|
+
logger.error('Provide keys for get data API.');
|
|
814
814
|
return;
|
|
815
815
|
}
|
|
816
816
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -819,7 +819,7 @@ const handleGetData = (keys, callback, options) => {
|
|
|
819
819
|
}
|
|
820
820
|
const instances = getInstances();
|
|
821
821
|
if (instances.length > 1) {
|
|
822
|
-
error('Multiple instances found! Please provide destination.');
|
|
822
|
+
logger.error('Multiple instances found! Please provide destination.');
|
|
823
823
|
callback({});
|
|
824
824
|
return;
|
|
825
825
|
}
|
|
@@ -837,17 +837,17 @@ const processData = (destination, data, providers, options) => {
|
|
|
837
837
|
continue;
|
|
838
838
|
}
|
|
839
839
|
if (!configuredTags.has(pkg.name)) {
|
|
840
|
-
log(`Provider ${pkg.name} is not in allow list`);
|
|
840
|
+
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
841
841
|
continue;
|
|
842
842
|
}
|
|
843
843
|
const variables = getProviderVariables(destination, pkg.name);
|
|
844
844
|
for (const variable of variables) {
|
|
845
845
|
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
846
|
-
log(`Data not allowed for ${pkg.name} (${variable.tagName})`);
|
|
846
|
+
logger.log(`Data not allowed for ${pkg.name} (${variable.tagName})`);
|
|
847
847
|
continue;
|
|
848
848
|
}
|
|
849
849
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
850
|
-
log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
850
|
+
logger.log(`Consent is missing for ${pkg.name} (${variable.tagName})`);
|
|
851
851
|
continue;
|
|
852
852
|
}
|
|
853
853
|
pkg.user({
|
|
@@ -857,11 +857,11 @@ const processData = (destination, data, providers, options) => {
|
|
|
857
857
|
});
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
|
-
postRequest(getDataURL(destination), { data, providers }, options).catch(error);
|
|
860
|
+
postRequest(getDataURL(destination), { data, providers }, options).catch(logger.error);
|
|
861
861
|
};
|
|
862
862
|
const handleData = (data, providers, options) => {
|
|
863
863
|
if (!data || Object.keys(data).length === 0) {
|
|
864
|
-
error('Provide data for data API.');
|
|
864
|
+
logger.error('Provide data for data API.');
|
|
865
865
|
return;
|
|
866
866
|
}
|
|
867
867
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -905,7 +905,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
905
905
|
};
|
|
906
906
|
saveConsent(destination, consent);
|
|
907
907
|
if (!(options === null || options === void 0 ? void 0 : options.localSave)) {
|
|
908
|
-
postRequest(getConsentURL(destination), payload).catch(error);
|
|
908
|
+
postRequest(getConsentURL(destination), payload).catch(logger.error);
|
|
909
909
|
}
|
|
910
910
|
const userId = getUserId$1(destination);
|
|
911
911
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
@@ -936,6 +936,7 @@ const processConsent = (destination, consent, options) => {
|
|
|
936
936
|
keyName: `${keyPrefix}Store`,
|
|
937
937
|
executionContext,
|
|
938
938
|
session: null,
|
|
939
|
+
destination,
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
942
|
}
|
|
@@ -968,7 +969,7 @@ const setPreferences = (preferences) => {
|
|
|
968
969
|
return null;
|
|
969
970
|
}
|
|
970
971
|
if (!preferences.edgeURL) {
|
|
971
|
-
error('Please provide URL for EdgeTag');
|
|
972
|
+
logger.error('Please provide URL for EdgeTag');
|
|
972
973
|
return null;
|
|
973
974
|
}
|
|
974
975
|
const providersPackages = {};
|
|
@@ -1009,7 +1010,7 @@ const saveDataToEdge = (destination, key, value, provider) => {
|
|
|
1009
1010
|
updatedValue = JSON.stringify(value);
|
|
1010
1011
|
}
|
|
1011
1012
|
catch {
|
|
1012
|
-
log('Error stringify value.');
|
|
1013
|
+
logger.log('Error stringify value.');
|
|
1013
1014
|
return;
|
|
1014
1015
|
}
|
|
1015
1016
|
}
|
|
@@ -1104,6 +1105,7 @@ const handleCapture = (destination, provider, params, capture) => {
|
|
|
1104
1105
|
});
|
|
1105
1106
|
};
|
|
1106
1107
|
|
|
1108
|
+
const keyName = `${keyPrefix}Store`;
|
|
1107
1109
|
const handleManifest = (destination, response) => {
|
|
1108
1110
|
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1109
1111
|
const userId = getUserId$1(destination);
|
|
@@ -1135,8 +1137,9 @@ const handleManifest = (destination, response) => {
|
|
|
1135
1137
|
sendTag: sendTag.bind(null, destination),
|
|
1136
1138
|
sendEdgeData: processData.bind(null, destination),
|
|
1137
1139
|
getEdgeData: processGetData.bind(null, destination),
|
|
1138
|
-
keyName
|
|
1140
|
+
keyName,
|
|
1139
1141
|
executionContext,
|
|
1142
|
+
destination,
|
|
1140
1143
|
});
|
|
1141
1144
|
}
|
|
1142
1145
|
}
|
|
@@ -1197,7 +1200,7 @@ const handleInit = (preferences) => {
|
|
|
1197
1200
|
.then((result) => {
|
|
1198
1201
|
var _a;
|
|
1199
1202
|
if (!result) {
|
|
1200
|
-
error('Initialization failed');
|
|
1203
|
+
logger.error('Initialization failed');
|
|
1201
1204
|
return;
|
|
1202
1205
|
}
|
|
1203
1206
|
if (result.isNewUser && result.consent) {
|
|
@@ -1240,7 +1243,7 @@ const handleInit = (preferences) => {
|
|
|
1240
1243
|
// do nothing
|
|
1241
1244
|
}
|
|
1242
1245
|
})
|
|
1243
|
-
.catch(error);
|
|
1246
|
+
.catch(logger.error);
|
|
1244
1247
|
};
|
|
1245
1248
|
|
|
1246
1249
|
const processUser = (destination, key, value, providers, options) => {
|
|
@@ -1256,17 +1259,17 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1256
1259
|
continue;
|
|
1257
1260
|
}
|
|
1258
1261
|
if (!configuredTags.has(pkg.name)) {
|
|
1259
|
-
log(`Provider ${pkg.name} is not in allow list`);
|
|
1262
|
+
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
1260
1263
|
continue;
|
|
1261
1264
|
}
|
|
1262
1265
|
const variables = getProviderVariables(destination, pkg.name);
|
|
1263
1266
|
for (const variable of variables) {
|
|
1264
1267
|
if (!isProviderInstanceAllowed(providers, pkg.name, variable.tagName)) {
|
|
1265
|
-
log(`User not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1268
|
+
logger.log(`User not allowed for ${pkg.name} (${variable.tagName})`);
|
|
1266
1269
|
continue;
|
|
1267
1270
|
}
|
|
1268
1271
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
1269
|
-
log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1272
|
+
logger.log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1270
1273
|
continue;
|
|
1271
1274
|
}
|
|
1272
1275
|
pkg.user({
|
|
@@ -1280,11 +1283,11 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1280
1283
|
key,
|
|
1281
1284
|
value,
|
|
1282
1285
|
providers,
|
|
1283
|
-
}, options).catch(error);
|
|
1286
|
+
}, options).catch(logger.error);
|
|
1284
1287
|
};
|
|
1285
1288
|
const handleUser = (key, value, providers, options) => {
|
|
1286
1289
|
if (!key || !value) {
|
|
1287
|
-
error('Key or Value is missing in user API.');
|
|
1290
|
+
logger.error('Key or Value is missing in user API.');
|
|
1288
1291
|
return;
|
|
1289
1292
|
}
|
|
1290
1293
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -1301,7 +1304,7 @@ const processKeys = (destination, callback) => {
|
|
|
1301
1304
|
.then((result) => {
|
|
1302
1305
|
callback((result === null || result === void 0 ? void 0 : result.result) || []);
|
|
1303
1306
|
})
|
|
1304
|
-
.catch(error);
|
|
1307
|
+
.catch(logger.error);
|
|
1305
1308
|
};
|
|
1306
1309
|
const handleKeys = (callback, options) => {
|
|
1307
1310
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
@@ -1310,7 +1313,7 @@ const handleKeys = (callback, options) => {
|
|
|
1310
1313
|
}
|
|
1311
1314
|
const instances = getInstances();
|
|
1312
1315
|
if (instances.length > 1) {
|
|
1313
|
-
error('Multiple instances found! Please provide destination.');
|
|
1316
|
+
logger.error('Multiple instances found! Please provide destination.');
|
|
1314
1317
|
callback([]);
|
|
1315
1318
|
return;
|
|
1316
1319
|
}
|
|
@@ -1353,7 +1356,7 @@ const handleIsNewUser = (options) => {
|
|
|
1353
1356
|
}
|
|
1354
1357
|
const instances = getInstances();
|
|
1355
1358
|
if (instances.length > 1) {
|
|
1356
|
-
error('Multiple instances found! Please provide destination.');
|
|
1359
|
+
logger.error('Multiple instances found! Please provide destination.');
|
|
1357
1360
|
return undefined;
|
|
1358
1361
|
}
|
|
1359
1362
|
return getSetting(instances[0], 'isNewUser');
|