@blotoutio/edgetag-sdk-browser 1.49.2 → 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.
Files changed (2) hide show
  1. package/index.js +19 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1311,7 +1311,7 @@
1311
1311
  referrer: getReferrer(destination),
1312
1312
  search: getSearch(destination),
1313
1313
  locale: getLocale(),
1314
- sdkVersion: "1.49.2" ,
1314
+ sdkVersion: "1.50.0" ,
1315
1315
  ...(payload || {}),
1316
1316
  };
1317
1317
  let storage = {};
@@ -2187,15 +2187,17 @@
2187
2187
  };
2188
2188
 
2189
2189
  const mapData = (data) => async (callback) => {
2190
- try {
2191
- await callback(data);
2192
- }
2193
- catch (err) {
2194
- console.error(err);
2195
- }
2190
+ await callback(data);
2196
2191
  };
2197
2192
  const callbacks = new Set();
2198
2193
  const resolved = new Set();
2194
+ const logErrors = (ps) => {
2195
+ for (const p of ps) {
2196
+ if (p.status === 'rejected') {
2197
+ console.error('ready callback error:', p.reason);
2198
+ }
2199
+ }
2200
+ };
2199
2201
  const onReady = async (data) => {
2200
2202
  const callbackData = {
2201
2203
  destination: data.destination,
@@ -2212,11 +2214,11 @@
2212
2214
  isEURequest: data.isEURequest,
2213
2215
  };
2214
2216
  resolved.add(callbackData);
2215
- await Promise.all([...callbacks].map(mapData(callbackData)));
2217
+ await Promise.allSettled([...callbacks].map(mapData(callbackData))).then(logErrors);
2216
2218
  };
2217
2219
  const handleReady = async (callback) => {
2218
2220
  callbacks.add(callback);
2219
- await Promise.all([...resolved.values()].map((data) => mapData(data)(callback)));
2221
+ await Promise.allSettled([...resolved.values()].map((data) => mapData(data)(callback))).then(logErrors);
2220
2222
  };
2221
2223
 
2222
2224
  const handleInit = (preferences) => {
@@ -2319,14 +2321,17 @@
2319
2321
  savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
2320
2322
  }
2321
2323
  handleManifest(preferences.edgeURL, result);
2324
+ const detail = getInitData(preferences.edgeURL, result);
2322
2325
  try {
2323
- const detail = getInitData(preferences.edgeURL, result);
2324
- window.dispatchEvent(new CustomEvent('edgetag-initialized', { detail }));
2325
- onReady(detail);
2326
+ if (typeof window !== 'undefined' &&
2327
+ typeof CustomEvent !== 'undefined') {
2328
+ window.dispatchEvent(new CustomEvent('edgetag-initialized', { detail }));
2329
+ }
2326
2330
  }
2327
- catch {
2328
- // do nothing
2331
+ catch (e) {
2332
+ logger.error(e);
2329
2333
  }
2334
+ onReady(detail);
2330
2335
  })
2331
2336
  .catch(logger.error);
2332
2337
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-browser",
3
- "version": "1.49.2",
3
+ "version": "1.50.0",
4
4
  "description": "Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",