@blotoutio/edgetag-sdk-js 1.49.3 → 1.50.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 +19 -14
- package/index.mjs +19 -14
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -1310,7 +1310,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
1310
1310
|
referrer: getReferrer(destination),
|
|
1311
1311
|
search: getSearch(destination),
|
|
1312
1312
|
locale: getLocale(),
|
|
1313
|
-
sdkVersion: "1.
|
|
1313
|
+
sdkVersion: "1.50.0" ,
|
|
1314
1314
|
...(payload || {}),
|
|
1315
1315
|
};
|
|
1316
1316
|
let storage = {};
|
|
@@ -2186,15 +2186,17 @@ const handleManifest = (destination, response) => {
|
|
|
2186
2186
|
};
|
|
2187
2187
|
|
|
2188
2188
|
const mapData = (data) => async (callback) => {
|
|
2189
|
-
|
|
2190
|
-
await callback(data);
|
|
2191
|
-
}
|
|
2192
|
-
catch (err) {
|
|
2193
|
-
console.error(err);
|
|
2194
|
-
}
|
|
2189
|
+
await callback(data);
|
|
2195
2190
|
};
|
|
2196
2191
|
const callbacks = new Set();
|
|
2197
2192
|
const resolved = new Set();
|
|
2193
|
+
const logErrors = (ps) => {
|
|
2194
|
+
for (const p of ps) {
|
|
2195
|
+
if (p.status === 'rejected') {
|
|
2196
|
+
console.error('ready callback error:', p.reason);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2198
2200
|
const onReady = async (data) => {
|
|
2199
2201
|
const callbackData = {
|
|
2200
2202
|
destination: data.destination,
|
|
@@ -2211,11 +2213,11 @@ const onReady = async (data) => {
|
|
|
2211
2213
|
isEURequest: data.isEURequest,
|
|
2212
2214
|
};
|
|
2213
2215
|
resolved.add(callbackData);
|
|
2214
|
-
await Promise.
|
|
2216
|
+
await Promise.allSettled([...callbacks].map(mapData(callbackData))).then(logErrors);
|
|
2215
2217
|
};
|
|
2216
2218
|
const handleReady = async (callback) => {
|
|
2217
2219
|
callbacks.add(callback);
|
|
2218
|
-
await Promise.
|
|
2220
|
+
await Promise.allSettled([...resolved.values()].map((data) => mapData(data)(callback))).then(logErrors);
|
|
2219
2221
|
};
|
|
2220
2222
|
|
|
2221
2223
|
const handleInit = (preferences) => {
|
|
@@ -2318,14 +2320,17 @@ const handleInit = (preferences) => {
|
|
|
2318
2320
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
2319
2321
|
}
|
|
2320
2322
|
handleManifest(preferences.edgeURL, result);
|
|
2323
|
+
const detail = getInitData(preferences.edgeURL, result);
|
|
2321
2324
|
try {
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
+
if (typeof window !== 'undefined' &&
|
|
2326
|
+
typeof CustomEvent !== 'undefined') {
|
|
2327
|
+
window.dispatchEvent(new CustomEvent('edgetag-initialized', { detail }));
|
|
2328
|
+
}
|
|
2325
2329
|
}
|
|
2326
|
-
catch {
|
|
2327
|
-
|
|
2330
|
+
catch (e) {
|
|
2331
|
+
logger.error(e);
|
|
2328
2332
|
}
|
|
2333
|
+
onReady(detail);
|
|
2329
2334
|
})
|
|
2330
2335
|
.catch(logger.error);
|
|
2331
2336
|
};
|
package/index.mjs
CHANGED
|
@@ -1308,7 +1308,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
1308
1308
|
referrer: getReferrer(destination),
|
|
1309
1309
|
search: getSearch(destination),
|
|
1310
1310
|
locale: getLocale(),
|
|
1311
|
-
sdkVersion: "1.
|
|
1311
|
+
sdkVersion: "1.50.0" ,
|
|
1312
1312
|
...(payload || {}),
|
|
1313
1313
|
};
|
|
1314
1314
|
let storage = {};
|
|
@@ -2184,15 +2184,17 @@ const handleManifest = (destination, response) => {
|
|
|
2184
2184
|
};
|
|
2185
2185
|
|
|
2186
2186
|
const mapData = (data) => async (callback) => {
|
|
2187
|
-
|
|
2188
|
-
await callback(data);
|
|
2189
|
-
}
|
|
2190
|
-
catch (err) {
|
|
2191
|
-
console.error(err);
|
|
2192
|
-
}
|
|
2187
|
+
await callback(data);
|
|
2193
2188
|
};
|
|
2194
2189
|
const callbacks = new Set();
|
|
2195
2190
|
const resolved = new Set();
|
|
2191
|
+
const logErrors = (ps) => {
|
|
2192
|
+
for (const p of ps) {
|
|
2193
|
+
if (p.status === 'rejected') {
|
|
2194
|
+
console.error('ready callback error:', p.reason);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2196
2198
|
const onReady = async (data) => {
|
|
2197
2199
|
const callbackData = {
|
|
2198
2200
|
destination: data.destination,
|
|
@@ -2209,11 +2211,11 @@ const onReady = async (data) => {
|
|
|
2209
2211
|
isEURequest: data.isEURequest,
|
|
2210
2212
|
};
|
|
2211
2213
|
resolved.add(callbackData);
|
|
2212
|
-
await Promise.
|
|
2214
|
+
await Promise.allSettled([...callbacks].map(mapData(callbackData))).then(logErrors);
|
|
2213
2215
|
};
|
|
2214
2216
|
const handleReady = async (callback) => {
|
|
2215
2217
|
callbacks.add(callback);
|
|
2216
|
-
await Promise.
|
|
2218
|
+
await Promise.allSettled([...resolved.values()].map((data) => mapData(data)(callback))).then(logErrors);
|
|
2217
2219
|
};
|
|
2218
2220
|
|
|
2219
2221
|
const handleInit = (preferences) => {
|
|
@@ -2316,14 +2318,17 @@ const handleInit = (preferences) => {
|
|
|
2316
2318
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|
|
2317
2319
|
}
|
|
2318
2320
|
handleManifest(preferences.edgeURL, result);
|
|
2321
|
+
const detail = getInitData(preferences.edgeURL, result);
|
|
2319
2322
|
try {
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
+
if (typeof window !== 'undefined' &&
|
|
2324
|
+
typeof CustomEvent !== 'undefined') {
|
|
2325
|
+
window.dispatchEvent(new CustomEvent('edgetag-initialized', { detail }));
|
|
2326
|
+
}
|
|
2323
2327
|
}
|
|
2324
|
-
catch {
|
|
2325
|
-
|
|
2328
|
+
catch (e) {
|
|
2329
|
+
logger.error(e);
|
|
2326
2330
|
}
|
|
2331
|
+
onReady(detail);
|
|
2327
2332
|
})
|
|
2328
2333
|
.catch(logger.error);
|
|
2329
2334
|
};
|