@blotoutio/edgetag-sdk-js 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.cjs +28 -11
- package/index.esm.js +28 -11
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -89,7 +89,18 @@ const getMessage = (error) => {
|
|
|
89
89
|
return error;
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
+
const allowLog = () => {
|
|
93
|
+
try {
|
|
94
|
+
return localStorage.getItem('edgeTagDebug') === '1';
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
92
100
|
const log = (data) => {
|
|
101
|
+
if (!allowLog()) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
93
104
|
console.log('[EdgeTag]', getMessage(data));
|
|
94
105
|
};
|
|
95
106
|
const error = (data) => {
|
|
@@ -323,7 +334,7 @@ const getStandardPayload = (payload) => {
|
|
|
323
334
|
referrer: getReferrer(),
|
|
324
335
|
search: getSearch(),
|
|
325
336
|
locale: getLocale(),
|
|
326
|
-
sdkVersion: "0.26.
|
|
337
|
+
sdkVersion: "0.26.4" ,
|
|
327
338
|
...(payload || {}),
|
|
328
339
|
};
|
|
329
340
|
let storage = {};
|
|
@@ -432,7 +443,7 @@ const getConsent = () => {
|
|
|
432
443
|
};
|
|
433
444
|
|
|
434
445
|
const isBool = (v) => typeof v == 'boolean';
|
|
435
|
-
const isRecord = (v) => !!v && typeof v == 'object';
|
|
446
|
+
const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
|
|
436
447
|
/**
|
|
437
448
|
* This function validates user consent for a given provider and tag name.
|
|
438
449
|
* It should be used in conjunction with `UserConsent`, not `ProvidersConfig`.
|
|
@@ -466,22 +477,25 @@ const isProviderInstanceAllowed = (providersConfig, provider, tagName) => {
|
|
|
466
477
|
if (!isRecord(providersConfig)) {
|
|
467
478
|
return true;
|
|
468
479
|
}
|
|
469
|
-
let allowed = isBool(providersConfig.all) ? providersConfig.all : true;
|
|
470
480
|
if (provider in providersConfig) {
|
|
471
481
|
const providerSpecific = providersConfig[provider];
|
|
472
482
|
if (isBool(providerSpecific)) {
|
|
473
|
-
|
|
483
|
+
return providerSpecific;
|
|
474
484
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
allowed = providerSpecific.all;
|
|
478
|
-
}
|
|
485
|
+
if (isRecord(providerSpecific)) {
|
|
486
|
+
const tagKeys = Object.keys(providerSpecific).filter((k) => k != 'all');
|
|
479
487
|
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
480
|
-
|
|
488
|
+
return providerSpecific[tagName];
|
|
481
489
|
}
|
|
490
|
+
return isBool(providerSpecific.all)
|
|
491
|
+
? providerSpecific.all
|
|
492
|
+
: tagKeys.length == 0;
|
|
482
493
|
}
|
|
483
494
|
}
|
|
484
|
-
|
|
495
|
+
const providerKeys = Object.keys(providersConfig).filter((k) => k != 'all');
|
|
496
|
+
return isBool(providersConfig.all)
|
|
497
|
+
? providersConfig.all
|
|
498
|
+
: providerKeys.length == 0;
|
|
485
499
|
};
|
|
486
500
|
|
|
487
501
|
const upsert = (map, key, update, createDefault) => {
|
|
@@ -600,6 +614,7 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
600
614
|
continue;
|
|
601
615
|
}
|
|
602
616
|
if (!configuredTags.has(pkg.name)) {
|
|
617
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
603
618
|
continue;
|
|
604
619
|
}
|
|
605
620
|
const variables = getProviderVariables(pkg.name);
|
|
@@ -666,6 +681,7 @@ const handleData = (data, providers, options) => {
|
|
|
666
681
|
continue;
|
|
667
682
|
}
|
|
668
683
|
if (!configuredTags.has(pkg.name)) {
|
|
684
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
669
685
|
continue;
|
|
670
686
|
}
|
|
671
687
|
const variables = getProviderVariables(pkg.name);
|
|
@@ -834,7 +850,7 @@ const handleInit = (preferences) => {
|
|
|
834
850
|
getRequest(url.href)
|
|
835
851
|
.then((result) => {
|
|
836
852
|
if (!result) {
|
|
837
|
-
|
|
853
|
+
error('Initialization failed');
|
|
838
854
|
return;
|
|
839
855
|
}
|
|
840
856
|
if (result.userId) {
|
|
@@ -866,6 +882,7 @@ const handleUser = (key, value, providers, options) => {
|
|
|
866
882
|
continue;
|
|
867
883
|
}
|
|
868
884
|
if (!configuredTags.has(pkg.name)) {
|
|
885
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
869
886
|
continue;
|
|
870
887
|
}
|
|
871
888
|
const variables = getProviderVariables(pkg.name);
|
package/index.esm.js
CHANGED
|
@@ -87,7 +87,18 @@ const getMessage = (error) => {
|
|
|
87
87
|
return error;
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
+
const allowLog = () => {
|
|
91
|
+
try {
|
|
92
|
+
return localStorage.getItem('edgeTagDebug') === '1';
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
90
98
|
const log = (data) => {
|
|
99
|
+
if (!allowLog()) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
91
102
|
console.log('[EdgeTag]', getMessage(data));
|
|
92
103
|
};
|
|
93
104
|
const error = (data) => {
|
|
@@ -321,7 +332,7 @@ const getStandardPayload = (payload) => {
|
|
|
321
332
|
referrer: getReferrer(),
|
|
322
333
|
search: getSearch(),
|
|
323
334
|
locale: getLocale(),
|
|
324
|
-
sdkVersion: "0.26.
|
|
335
|
+
sdkVersion: "0.26.4" ,
|
|
325
336
|
...(payload || {}),
|
|
326
337
|
};
|
|
327
338
|
let storage = {};
|
|
@@ -430,7 +441,7 @@ const getConsent = () => {
|
|
|
430
441
|
};
|
|
431
442
|
|
|
432
443
|
const isBool = (v) => typeof v == 'boolean';
|
|
433
|
-
const isRecord = (v) => !!v && typeof v == 'object';
|
|
444
|
+
const isRecord = (v) => !!v && typeof v == 'object' && !Array.isArray(v);
|
|
434
445
|
/**
|
|
435
446
|
* This function validates user consent for a given provider and tag name.
|
|
436
447
|
* It should be used in conjunction with `UserConsent`, not `ProvidersConfig`.
|
|
@@ -464,22 +475,25 @@ const isProviderInstanceAllowed = (providersConfig, provider, tagName) => {
|
|
|
464
475
|
if (!isRecord(providersConfig)) {
|
|
465
476
|
return true;
|
|
466
477
|
}
|
|
467
|
-
let allowed = isBool(providersConfig.all) ? providersConfig.all : true;
|
|
468
478
|
if (provider in providersConfig) {
|
|
469
479
|
const providerSpecific = providersConfig[provider];
|
|
470
480
|
if (isBool(providerSpecific)) {
|
|
471
|
-
|
|
481
|
+
return providerSpecific;
|
|
472
482
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
allowed = providerSpecific.all;
|
|
476
|
-
}
|
|
483
|
+
if (isRecord(providerSpecific)) {
|
|
484
|
+
const tagKeys = Object.keys(providerSpecific).filter((k) => k != 'all');
|
|
477
485
|
if (tagName in providerSpecific && isBool(providerSpecific[tagName])) {
|
|
478
|
-
|
|
486
|
+
return providerSpecific[tagName];
|
|
479
487
|
}
|
|
488
|
+
return isBool(providerSpecific.all)
|
|
489
|
+
? providerSpecific.all
|
|
490
|
+
: tagKeys.length == 0;
|
|
480
491
|
}
|
|
481
492
|
}
|
|
482
|
-
|
|
493
|
+
const providerKeys = Object.keys(providersConfig).filter((k) => k != 'all');
|
|
494
|
+
return isBool(providersConfig.all)
|
|
495
|
+
? providersConfig.all
|
|
496
|
+
: providerKeys.length == 0;
|
|
483
497
|
};
|
|
484
498
|
|
|
485
499
|
const upsert = (map, key, update, createDefault) => {
|
|
@@ -598,6 +612,7 @@ const handleTag = (eventName, data = {}, providers, options) => {
|
|
|
598
612
|
continue;
|
|
599
613
|
}
|
|
600
614
|
if (!configuredTags.has(pkg.name)) {
|
|
615
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
601
616
|
continue;
|
|
602
617
|
}
|
|
603
618
|
const variables = getProviderVariables(pkg.name);
|
|
@@ -664,6 +679,7 @@ const handleData = (data, providers, options) => {
|
|
|
664
679
|
continue;
|
|
665
680
|
}
|
|
666
681
|
if (!configuredTags.has(pkg.name)) {
|
|
682
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
667
683
|
continue;
|
|
668
684
|
}
|
|
669
685
|
const variables = getProviderVariables(pkg.name);
|
|
@@ -832,7 +848,7 @@ const handleInit = (preferences) => {
|
|
|
832
848
|
getRequest(url.href)
|
|
833
849
|
.then((result) => {
|
|
834
850
|
if (!result) {
|
|
835
|
-
|
|
851
|
+
error('Initialization failed');
|
|
836
852
|
return;
|
|
837
853
|
}
|
|
838
854
|
if (result.userId) {
|
|
@@ -864,6 +880,7 @@ const handleUser = (key, value, providers, options) => {
|
|
|
864
880
|
continue;
|
|
865
881
|
}
|
|
866
882
|
if (!configuredTags.has(pkg.name)) {
|
|
883
|
+
log(`Provider ${pkg.name} is not in allow list`);
|
|
867
884
|
continue;
|
|
868
885
|
}
|
|
869
886
|
const variables = getProviderVariables(pkg.name);
|