@blotoutio/edgetag-sdk-js 0.36.1 → 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.cjs.js +32 -1
- package/index.mjs +32 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -70,6 +70,33 @@ const getPageTitle = () => {
|
|
|
70
70
|
return '';
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
+
const areEqual = (a, b) => {
|
|
74
|
+
if (typeof a !== typeof b ||
|
|
75
|
+
Array.isArray(a) !== Array.isArray(b) ||
|
|
76
|
+
isNaN(a) !== isNaN(b)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (typeof a !== 'object' || a === null) {
|
|
80
|
+
return a === b;
|
|
81
|
+
}
|
|
82
|
+
const as = Object.keys(a);
|
|
83
|
+
const bs = Object.keys(b);
|
|
84
|
+
if (as.length !== bs.length)
|
|
85
|
+
return false;
|
|
86
|
+
for (const key of as) {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
if (!(key in b)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
if (!areEqual(a[key], b[key])) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
};
|
|
73
100
|
|
|
74
101
|
const tagStorage = 'edgeTag';
|
|
75
102
|
const consentKey = 'consent';
|
|
@@ -335,7 +362,7 @@ const getStandardPayload = (payload) => {
|
|
|
335
362
|
referrer: getReferrer(),
|
|
336
363
|
search: getSearch(),
|
|
337
364
|
locale: getLocale(),
|
|
338
|
-
sdkVersion: "0.36.
|
|
365
|
+
sdkVersion: "0.36.2" ,
|
|
339
366
|
...(payload || {}),
|
|
340
367
|
};
|
|
341
368
|
let storage = {};
|
|
@@ -723,6 +750,10 @@ const saveConsent = (consent) => {
|
|
|
723
750
|
savePerKey('local', tagStorage, consent, consentKey);
|
|
724
751
|
};
|
|
725
752
|
const handleConsent = (consent, options) => {
|
|
753
|
+
const existingConsent = getConsent$1();
|
|
754
|
+
if (areEqual(existingConsent, consent)) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
726
757
|
const payload = {
|
|
727
758
|
consentString: consent,
|
|
728
759
|
};
|
package/index.mjs
CHANGED
|
@@ -68,6 +68,33 @@ const getPageTitle = () => {
|
|
|
68
68
|
return '';
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
+
const areEqual = (a, b) => {
|
|
72
|
+
if (typeof a !== typeof b ||
|
|
73
|
+
Array.isArray(a) !== Array.isArray(b) ||
|
|
74
|
+
isNaN(a) !== isNaN(b)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (typeof a !== 'object' || a === null) {
|
|
78
|
+
return a === b;
|
|
79
|
+
}
|
|
80
|
+
const as = Object.keys(a);
|
|
81
|
+
const bs = Object.keys(b);
|
|
82
|
+
if (as.length !== bs.length)
|
|
83
|
+
return false;
|
|
84
|
+
for (const key of as) {
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
if (!(key in b)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
if (!areEqual(a[key], b[key])) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
71
98
|
|
|
72
99
|
const tagStorage = 'edgeTag';
|
|
73
100
|
const consentKey = 'consent';
|
|
@@ -333,7 +360,7 @@ const getStandardPayload = (payload) => {
|
|
|
333
360
|
referrer: getReferrer(),
|
|
334
361
|
search: getSearch(),
|
|
335
362
|
locale: getLocale(),
|
|
336
|
-
sdkVersion: "0.36.
|
|
363
|
+
sdkVersion: "0.36.2" ,
|
|
337
364
|
...(payload || {}),
|
|
338
365
|
};
|
|
339
366
|
let storage = {};
|
|
@@ -721,6 +748,10 @@ const saveConsent = (consent) => {
|
|
|
721
748
|
savePerKey('local', tagStorage, consent, consentKey);
|
|
722
749
|
};
|
|
723
750
|
const handleConsent = (consent, options) => {
|
|
751
|
+
const existingConsent = getConsent$1();
|
|
752
|
+
if (areEqual(existingConsent, consent)) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
724
755
|
const payload = {
|
|
725
756
|
consentString: consent,
|
|
726
757
|
};
|