@blotoutio/edgetag-sdk-browser 1.35.0 → 1.35.1
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 +105 -31
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -665,6 +665,15 @@
|
|
|
665
665
|
}
|
|
666
666
|
return true;
|
|
667
667
|
};
|
|
668
|
+
const getInitData = (edgeURL, manifestResult) => ({
|
|
669
|
+
destination: edgeURL,
|
|
670
|
+
userId: manifestResult.userId,
|
|
671
|
+
isNewUser: manifestResult.isNewUser,
|
|
672
|
+
consent: manifestResult.consent,
|
|
673
|
+
consentCategories: manifestResult.consentCategories,
|
|
674
|
+
consentSetting: manifestResult.consentSetting,
|
|
675
|
+
session: manifestResult.session,
|
|
676
|
+
});
|
|
668
677
|
|
|
669
678
|
const tagStorage = 'edgeTag';
|
|
670
679
|
const consentKey = 'consent';
|
|
@@ -956,7 +965,7 @@
|
|
|
956
965
|
referrer: getReferrer(destination),
|
|
957
966
|
search: getSearch(destination),
|
|
958
967
|
locale: getLocale(),
|
|
959
|
-
sdkVersion: "1.35.
|
|
968
|
+
sdkVersion: "1.35.1" ,
|
|
960
969
|
...(payload || {}),
|
|
961
970
|
};
|
|
962
971
|
let storage = {};
|
|
@@ -1623,6 +1632,17 @@
|
|
|
1623
1632
|
setSetting(destination, {
|
|
1624
1633
|
initialized: true,
|
|
1625
1634
|
});
|
|
1635
|
+
// we fire this event to process the initial consent settings before firing
|
|
1636
|
+
// the rest of the stubs. this will provide the ability to enqueue the consent
|
|
1637
|
+
// call before the rest of the events so that consent is applied correctly for
|
|
1638
|
+
// queued events.
|
|
1639
|
+
try {
|
|
1640
|
+
const detail = getInitData(destination, response);
|
|
1641
|
+
window.dispatchEvent(new CustomEvent('edgetag-boot', { detail }));
|
|
1642
|
+
}
|
|
1643
|
+
catch {
|
|
1644
|
+
// do nothing
|
|
1645
|
+
}
|
|
1626
1646
|
processStubs(destination);
|
|
1627
1647
|
};
|
|
1628
1648
|
|
|
@@ -1753,18 +1773,8 @@
|
|
|
1753
1773
|
}
|
|
1754
1774
|
handleManifest(preferences.edgeURL, result);
|
|
1755
1775
|
try {
|
|
1756
|
-
const detail =
|
|
1757
|
-
|
|
1758
|
-
userId: result.userId,
|
|
1759
|
-
isNewUser: result.isNewUser,
|
|
1760
|
-
consent: result.consent,
|
|
1761
|
-
consentCategories: result.consentCategories,
|
|
1762
|
-
consentSetting: result.consentSetting,
|
|
1763
|
-
session: result.session,
|
|
1764
|
-
};
|
|
1765
|
-
window.dispatchEvent(new CustomEvent('edgetag-initialized', {
|
|
1766
|
-
detail,
|
|
1767
|
-
}));
|
|
1776
|
+
const detail = getInitData(preferences.edgeURL, result);
|
|
1777
|
+
window.dispatchEvent(new CustomEvent('edgetag-initialized', { detail }));
|
|
1768
1778
|
onReady(detail);
|
|
1769
1779
|
}
|
|
1770
1780
|
catch {
|
|
@@ -2054,6 +2064,21 @@
|
|
|
2054
2064
|
});
|
|
2055
2065
|
};
|
|
2056
2066
|
|
|
2067
|
+
const addConsentToDestination = (destination, consent) => {
|
|
2068
|
+
if (!window.edgetag.destinations[destination]) {
|
|
2069
|
+
window.edgetag.destinations[destination] = {};
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
if (!window.edgetag.destinations[destination].consents) {
|
|
2073
|
+
window.edgetag.destinations[destination].consents = [];
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
window.edgetag.destinations[destination].consents.push({
|
|
2077
|
+
name: 'consent',
|
|
2078
|
+
arguments: consent,
|
|
2079
|
+
});
|
|
2080
|
+
};
|
|
2081
|
+
|
|
2057
2082
|
const handleInit = (args) => {
|
|
2058
2083
|
if (!args?.length) {
|
|
2059
2084
|
console.error('EdgeTag SDK: Init event is missing arguments');
|
|
@@ -2072,26 +2097,38 @@
|
|
|
2072
2097
|
}
|
|
2073
2098
|
|
|
2074
2099
|
const tags = [];
|
|
2100
|
+
const consents = [];
|
|
2101
|
+
|
|
2102
|
+
window.edgetag.destinations['all'] =
|
|
2103
|
+
window.edgetag.destinations['all'] || {};
|
|
2104
|
+
|
|
2105
|
+
if (!window.edgetag.destinations['all'].resolvedInits?.has(destination)) {
|
|
2106
|
+
if (window.edgetag.destinations?.['all']?.tags) {
|
|
2107
|
+
const destinationTags = window.edgetag.destinations['all'].tags.map(
|
|
2108
|
+
(tag) => {
|
|
2109
|
+
const newTag = structuredClone(tag);
|
|
2110
|
+
newTag['arguments'][3] = { ...newTag['arguments'][3], destination };
|
|
2111
|
+
return newTag
|
|
2112
|
+
}
|
|
2113
|
+
);
|
|
2114
|
+
tags.push(...destinationTags);
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
if (window.edgetag.destinations?.['all']?.consents) {
|
|
2118
|
+
const destinationConsents = window.edgetag.destinations[
|
|
2119
|
+
'all'
|
|
2120
|
+
].consents.map((consent) => {
|
|
2121
|
+
const newConsent = structuredClone(consent);
|
|
2122
|
+
newConsent.arguments[2] = { ...newConsent.arguments[2], destination };
|
|
2123
|
+
return newConsent
|
|
2124
|
+
});
|
|
2125
|
+
consents.push(...destinationConsents);
|
|
2126
|
+
}
|
|
2075
2127
|
|
|
2076
|
-
if (
|
|
2077
|
-
window.edgetag.destinations?.['all']?.tags &&
|
|
2078
|
-
!window.edgetag.destinations['all']?.resolvedInits?.has(destination)
|
|
2079
|
-
) {
|
|
2080
|
-
const destinationTags = window.edgetag.destinations['all'].tags.map(
|
|
2081
|
-
(tag) => {
|
|
2082
|
-
const newTag = structuredClone(tag);
|
|
2083
|
-
newTag['arguments'][3] = {
|
|
2084
|
-
...newTag['arguments'][3],
|
|
2085
|
-
destination,
|
|
2086
|
-
};
|
|
2087
|
-
|
|
2088
|
-
return newTag
|
|
2089
|
-
}
|
|
2090
|
-
);
|
|
2091
|
-
tags.push(...destinationTags);
|
|
2092
2128
|
if (!window.edgetag.destinations['all'].resolvedInits) {
|
|
2093
2129
|
window.edgetag.destinations['all'].resolvedInits = new Set();
|
|
2094
2130
|
}
|
|
2131
|
+
|
|
2095
2132
|
window.edgetag.destinations['all'].resolvedInits.add(destination);
|
|
2096
2133
|
}
|
|
2097
2134
|
|
|
@@ -2100,8 +2137,13 @@
|
|
|
2100
2137
|
window.edgetag.destinations[destination].tags = [];
|
|
2101
2138
|
}
|
|
2102
2139
|
|
|
2103
|
-
if (
|
|
2104
|
-
|
|
2140
|
+
if (window.edgetag.destinations[destination].consents) {
|
|
2141
|
+
consents.push(...window.edgetag.destinations[destination].consents);
|
|
2142
|
+
window.edgetag.destinations[destination].consents = [];
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
if (consents.length + tags.length > 0) {
|
|
2146
|
+
args[0]['afterManifestEvents'] = [...consents, ...tags];
|
|
2105
2147
|
}
|
|
2106
2148
|
|
|
2107
2149
|
library.init(...args);
|
|
@@ -2188,6 +2230,7 @@
|
|
|
2188
2230
|
|
|
2189
2231
|
const inits = [];
|
|
2190
2232
|
const tags = [];
|
|
2233
|
+
const consents = [];
|
|
2191
2234
|
const otherStubs = [];
|
|
2192
2235
|
|
|
2193
2236
|
stubs.forEach((stub) => {
|
|
@@ -2211,6 +2254,11 @@
|
|
|
2211
2254
|
return
|
|
2212
2255
|
}
|
|
2213
2256
|
|
|
2257
|
+
if (name === 'consent') {
|
|
2258
|
+
consents.push(args);
|
|
2259
|
+
return
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2214
2262
|
if (name === 'tag') {
|
|
2215
2263
|
tags.push(args);
|
|
2216
2264
|
return
|
|
@@ -2232,6 +2280,7 @@
|
|
|
2232
2280
|
if (!window.edgetag.destinations['all']) {
|
|
2233
2281
|
window.edgetag.destinations['all'] = {
|
|
2234
2282
|
tags: [],
|
|
2283
|
+
consents: [],
|
|
2235
2284
|
resolvedInits: new Set(),
|
|
2236
2285
|
};
|
|
2237
2286
|
}
|
|
@@ -2242,6 +2291,31 @@
|
|
|
2242
2291
|
});
|
|
2243
2292
|
});
|
|
2244
2293
|
|
|
2294
|
+
consents.forEach((consent) => {
|
|
2295
|
+
const destination = getTagDestination(consent);
|
|
2296
|
+
if (destination) {
|
|
2297
|
+
addConsentToDestination(destination, consent);
|
|
2298
|
+
return
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
if (!window.edgetag.destinations['all']) {
|
|
2302
|
+
window.edgetag.destinations['all'] = {
|
|
2303
|
+
tags: [],
|
|
2304
|
+
consents: [],
|
|
2305
|
+
resolvedInits: new Set(),
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
if (!window.edgetag.destinations['all'].consents) {
|
|
2310
|
+
window.edgetag.destinations['all'].consents = [];
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
window.edgetag.destinations['all'].consents.push({
|
|
2314
|
+
name: 'consent',
|
|
2315
|
+
arguments: consent,
|
|
2316
|
+
});
|
|
2317
|
+
});
|
|
2318
|
+
|
|
2245
2319
|
inits.forEach((init) => {
|
|
2246
2320
|
window.edgetag.stubs.push(['init', ...init]);
|
|
2247
2321
|
});
|