@blotoutio/edgetag-sdk-browser 0.26.2 → 0.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +28 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -90,7 +90,18 @@
|
|
|
90
90
|
return error;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
const allowLog = () => {
|
|
94
|
+
try {
|
|
95
|
+
return localStorage.getItem('edgeTagDebug') === '1';
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
93
101
|
const log = (data) => {
|
|
102
|
+
if (!allowLog()) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
94
105
|
console.log('[EdgeTag]', getMessage(data));
|
|
95
106
|
};
|
|
96
107
|
const error = (data) => {
|
|
@@ -324,7 +335,7 @@
|
|
|
324
335
|
referrer: getReferrer(),
|
|
325
336
|
search: getSearch(),
|
|
326
337
|
locale: getLocale(),
|
|
327
|
-
sdkVersion: "0.26.
|
|
338
|
+
sdkVersion: "0.26.4" ,
|
|
328
339
|
...(payload || {}),
|
|
329
340
|
};
|
|
330
341
|
let storage = {};
|
|
@@ -433,7 +444,7 @@
|
|
|
433
444
|
};
|
|
434
445
|
|
|
435
446
|
const isBool = (v) => typeof v == 'boolean';
|
|
436
|
-
const isRecord = (v) => !!v && typeof v == 'object';
|
|
447
|
+
const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
|
|
437
448
|
/**
|
|
438
449
|
* This function validates user consent for a given provider and tag name.
|
|
439
450
|
* It should be used in conjunction with `UserConsent`, not `ProvidersConfig`.
|
|
@@ -467,22 +478,25 @@
|
|
|
467
478
|
if (!isRecord(providersConfig)) {
|
|
468
479
|
return true;
|
|
469
480
|
}
|
|
470
|
-
let allowed = isBool(providersConfig.all) ? providersConfig.all : true;
|
|
471
481
|
if (provider in providersConfig) {
|
|
472
482
|
const providerSpecific = providersConfig[provider];
|
|
473
483
|
if (isBool(providerSpecific)) {
|
|
474
|
-
|
|
484
|
+
return providerSpecific;
|
|
475
485
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
allowed = providerSpecific.all;
|
|
479
|
-
}
|
|
486
|
+
if (isRecord(providerSpecific)) {
|
|
487
|
+
const tagKeys = Object.keys(providerSpecific).filter((k) => k != 'all');
|
|
480
488
|
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
481
|
-
|
|
489
|
+
return providerSpecific[tagName];
|
|
482
490
|
}
|
|
491
|
+
return isBool(providerSpecific.all)
|
|
492
|
+
? providerSpecific.all
|
|
493
|
+
: tagKeys.length == 0;
|
|
483
494
|
}
|
|
484
495
|
}
|
|
485
|
-
|
|
496
|
+
const providerKeys = Object.keys(providersConfig).filter((k) => k != 'all');
|
|
497
|
+
return isBool(providersConfig.all)
|
|
498
|
+
? providersConfig.all
|
|
499
|
+
: providerKeys.length == 0;
|
|
486
500
|
};
|
|
487
501
|
|
|
488
502
|
const upsert = (map, key, update, createDefault) => {
|
|
@@ -601,6 +615,7 @@
|
|
|
601
615
|
continue;
|
|
602
616
|
}
|
|
603
617
|
if (!configuredTags.has(pkg.name)) {
|
|
618
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
604
619
|
continue;
|
|
605
620
|
}
|
|
606
621
|
const variables = getProviderVariables(pkg.name);
|
|
@@ -667,6 +682,7 @@
|
|
|
667
682
|
continue;
|
|
668
683
|
}
|
|
669
684
|
if (!configuredTags.has(pkg.name)) {
|
|
685
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
670
686
|
continue;
|
|
671
687
|
}
|
|
672
688
|
const variables = getProviderVariables(pkg.name);
|
|
@@ -835,7 +851,7 @@
|
|
|
835
851
|
getRequest(url.href)
|
|
836
852
|
.then((result) => {
|
|
837
853
|
if (!result) {
|
|
838
|
-
|
|
854
|
+
error('Initialization failed');
|
|
839
855
|
return;
|
|
840
856
|
}
|
|
841
857
|
if (result.userId) {
|
|
@@ -867,6 +883,7 @@
|
|
|
867
883
|
continue;
|
|
868
884
|
}
|
|
869
885
|
if (!configuredTags.has(pkg.name)) {
|
|
886
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
870
887
|
continue;
|
|
871
888
|
}
|
|
872
889
|
const variables = getProviderVariables(pkg.name);
|