@blotoutio/edgetag-sdk-js 0.36.1 → 0.37.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 +36 -4
- package/index.mjs +36 -4
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -26,7 +26,8 @@ const getReferrer = () => {
|
|
|
26
26
|
let referrer = '';
|
|
27
27
|
try {
|
|
28
28
|
const referrerUrl = new URL(document.referrer);
|
|
29
|
-
|
|
29
|
+
const pageUrl = new URL(getPageUrl());
|
|
30
|
+
if (referrerUrl.host !== pageUrl.host) {
|
|
30
31
|
referrer = referrerUrl.href;
|
|
31
32
|
}
|
|
32
33
|
return referrer;
|
|
@@ -48,7 +49,7 @@ const getPageUrl = () => {
|
|
|
48
49
|
};
|
|
49
50
|
const getSearch = () => {
|
|
50
51
|
try {
|
|
51
|
-
return
|
|
52
|
+
return new URL(getPageUrl()).search;
|
|
52
53
|
}
|
|
53
54
|
catch {
|
|
54
55
|
return '';
|
|
@@ -70,6 +71,33 @@ const getPageTitle = () => {
|
|
|
70
71
|
return '';
|
|
71
72
|
}
|
|
72
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
|
+
};
|
|
73
101
|
|
|
74
102
|
const tagStorage = 'edgeTag';
|
|
75
103
|
const consentKey = 'consent';
|
|
@@ -335,7 +363,7 @@ const getStandardPayload = (payload) => {
|
|
|
335
363
|
referrer: getReferrer(),
|
|
336
364
|
search: getSearch(),
|
|
337
365
|
locale: getLocale(),
|
|
338
|
-
sdkVersion: "0.
|
|
366
|
+
sdkVersion: "0.37.0" ,
|
|
339
367
|
...(payload || {}),
|
|
340
368
|
};
|
|
341
369
|
let storage = {};
|
|
@@ -723,6 +751,10 @@ const saveConsent = (consent) => {
|
|
|
723
751
|
savePerKey('local', tagStorage, consent, consentKey);
|
|
724
752
|
};
|
|
725
753
|
const handleConsent = (consent, options) => {
|
|
754
|
+
const existingConsent = getConsent$1();
|
|
755
|
+
if (areEqual(existingConsent, consent)) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
726
758
|
const payload = {
|
|
727
759
|
consentString: consent,
|
|
728
760
|
};
|
|
@@ -807,7 +839,7 @@ const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
|
807
839
|
catch {
|
|
808
840
|
return;
|
|
809
841
|
}
|
|
810
|
-
const params = new URLSearchParams(
|
|
842
|
+
const params = new URLSearchParams(getSearch());
|
|
811
843
|
if (!params || !params.get(key)) {
|
|
812
844
|
return;
|
|
813
845
|
}
|
package/index.mjs
CHANGED
|
@@ -24,7 +24,8 @@ const getReferrer = () => {
|
|
|
24
24
|
let referrer = '';
|
|
25
25
|
try {
|
|
26
26
|
const referrerUrl = new URL(document.referrer);
|
|
27
|
-
|
|
27
|
+
const pageUrl = new URL(getPageUrl());
|
|
28
|
+
if (referrerUrl.host !== pageUrl.host) {
|
|
28
29
|
referrer = referrerUrl.href;
|
|
29
30
|
}
|
|
30
31
|
return referrer;
|
|
@@ -46,7 +47,7 @@ const getPageUrl = () => {
|
|
|
46
47
|
};
|
|
47
48
|
const getSearch = () => {
|
|
48
49
|
try {
|
|
49
|
-
return
|
|
50
|
+
return new URL(getPageUrl()).search;
|
|
50
51
|
}
|
|
51
52
|
catch {
|
|
52
53
|
return '';
|
|
@@ -68,6 +69,33 @@ const getPageTitle = () => {
|
|
|
68
69
|
return '';
|
|
69
70
|
}
|
|
70
71
|
};
|
|
72
|
+
const areEqual = (a, b) => {
|
|
73
|
+
if (typeof a !== typeof b ||
|
|
74
|
+
Array.isArray(a) !== Array.isArray(b) ||
|
|
75
|
+
isNaN(a) !== isNaN(b)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (typeof a !== 'object' || a === null) {
|
|
79
|
+
return a === b;
|
|
80
|
+
}
|
|
81
|
+
const as = Object.keys(a);
|
|
82
|
+
const bs = Object.keys(b);
|
|
83
|
+
if (as.length !== bs.length)
|
|
84
|
+
return false;
|
|
85
|
+
for (const key of as) {
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
if (!(key in b)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
if (!areEqual(a[key], b[key])) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
};
|
|
71
99
|
|
|
72
100
|
const tagStorage = 'edgeTag';
|
|
73
101
|
const consentKey = 'consent';
|
|
@@ -333,7 +361,7 @@ const getStandardPayload = (payload) => {
|
|
|
333
361
|
referrer: getReferrer(),
|
|
334
362
|
search: getSearch(),
|
|
335
363
|
locale: getLocale(),
|
|
336
|
-
sdkVersion: "0.
|
|
364
|
+
sdkVersion: "0.37.0" ,
|
|
337
365
|
...(payload || {}),
|
|
338
366
|
};
|
|
339
367
|
let storage = {};
|
|
@@ -721,6 +749,10 @@ const saveConsent = (consent) => {
|
|
|
721
749
|
savePerKey('local', tagStorage, consent, consentKey);
|
|
722
750
|
};
|
|
723
751
|
const handleConsent = (consent, options) => {
|
|
752
|
+
const existingConsent = getConsent$1();
|
|
753
|
+
if (areEqual(existingConsent, consent)) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
724
756
|
const payload = {
|
|
725
757
|
consentString: consent,
|
|
726
758
|
};
|
|
@@ -805,7 +837,7 @@ const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
|
805
837
|
catch {
|
|
806
838
|
return;
|
|
807
839
|
}
|
|
808
|
-
const params = new URLSearchParams(
|
|
840
|
+
const params = new URLSearchParams(getSearch());
|
|
809
841
|
if (!params || !params.get(key)) {
|
|
810
842
|
return;
|
|
811
843
|
}
|