@blotoutio/edgetag-sdk-browser 0.36.0 → 0.36.2
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 +46 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -71,6 +71,33 @@
|
|
|
71
71
|
return '';
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
+
const areEqual = (a, b) => {
|
|
75
|
+
if (typeof a !== typeof b ||
|
|
76
|
+
Array.isArray(a) !== Array.isArray(b) ||
|
|
77
|
+
isNaN(a) !== isNaN(b)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (typeof a !== 'object' || a === null) {
|
|
81
|
+
return a === b;
|
|
82
|
+
}
|
|
83
|
+
const as = Object.keys(a);
|
|
84
|
+
const bs = Object.keys(b);
|
|
85
|
+
if (as.length !== bs.length)
|
|
86
|
+
return false;
|
|
87
|
+
for (const key of as) {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
if (!(key in b)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
if (!areEqual(a[key], b[key])) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
};
|
|
74
101
|
|
|
75
102
|
const tagStorage = 'edgeTag';
|
|
76
103
|
const consentKey = 'consent';
|
|
@@ -336,7 +363,7 @@
|
|
|
336
363
|
referrer: getReferrer(),
|
|
337
364
|
search: getSearch(),
|
|
338
365
|
locale: getLocale(),
|
|
339
|
-
sdkVersion: "0.36.
|
|
366
|
+
sdkVersion: "0.36.2" ,
|
|
340
367
|
...(payload || {}),
|
|
341
368
|
};
|
|
342
369
|
let storage = {};
|
|
@@ -724,6 +751,10 @@
|
|
|
724
751
|
savePerKey('local', tagStorage, consent, consentKey);
|
|
725
752
|
};
|
|
726
753
|
const handleConsent = (consent, options) => {
|
|
754
|
+
const existingConsent = getConsent$1();
|
|
755
|
+
if (areEqual(existingConsent, consent)) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
727
758
|
const payload = {
|
|
728
759
|
consentString: consent,
|
|
729
760
|
};
|
|
@@ -902,18 +933,20 @@
|
|
|
902
933
|
}
|
|
903
934
|
});
|
|
904
935
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
936
|
+
if (pkg && pkg.name && pkg.init) {
|
|
937
|
+
/* this defines if the consent is given for a specific instance of a provider */
|
|
938
|
+
const hasConsent = hasUserConsent(consent, pkg.name, provider.tagName);
|
|
939
|
+
if (hasConsent) {
|
|
940
|
+
pkg.init({
|
|
941
|
+
userId,
|
|
942
|
+
manifest: provider,
|
|
943
|
+
sendTag,
|
|
944
|
+
sendEdgeData: handleData,
|
|
945
|
+
getEdgeData: handleGetData,
|
|
946
|
+
keyName: `${keyPrefix}Store`,
|
|
947
|
+
executionContext,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
917
950
|
}
|
|
918
951
|
});
|
|
919
952
|
setInitialized();
|