@blotoutio/edgetag-sdk-browser 1.56.0 → 1.57.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 +41 -37
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1408,6 +1408,11 @@
1408
1408
  }
1409
1409
  };
1410
1410
 
1411
+ const getIsNewCustomerFlag = async (getData) => {
1412
+ const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
1413
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
1414
+ };
1415
+
1411
1416
  const getUserId$1 = (destination) => {
1412
1417
  const userId = getSetting(destination, 'userId');
1413
1418
  if (userId) {
@@ -1466,7 +1471,7 @@
1466
1471
  referrer: getReferrer(destination),
1467
1472
  search: getSearch(destination),
1468
1473
  locale: getLocale(),
1469
- sdkVersion: "1.56.0" ,
1474
+ sdkVersion: "1.57.0" ,
1470
1475
  ...(payload || {}),
1471
1476
  };
1472
1477
  let storage = {};
@@ -1669,6 +1674,7 @@
1669
1674
  const payload = baseParams['payload'];
1670
1675
  let currentEventName = payload['eventName'];
1671
1676
  let currentData = payload['data'];
1677
+ let currentProviders = baseParams['providers'];
1672
1678
  let skip = false;
1673
1679
  for (const plugin of plugins) {
1674
1680
  const hook = plugin.rules[hookName];
@@ -1694,6 +1700,9 @@
1694
1700
  if ((_b = result === null || result === void 0 ? void 0 : result.payload) === null || _b === void 0 ? void 0 : _b.data) {
1695
1701
  currentData = result.payload.data;
1696
1702
  }
1703
+ if ((result === null || result === void 0 ? void 0 : result.providers) !== undefined) {
1704
+ currentProviders = result.providers;
1705
+ }
1697
1706
  if (result === null || result === void 0 ? void 0 : result.additionalEvents) {
1698
1707
  for (const evt of result.additionalEvents) {
1699
1708
  handleTag(evt.eventName, evt.data, undefined, undefined);
@@ -1707,6 +1716,7 @@
1707
1716
  return {
1708
1717
  eventName: currentEventName,
1709
1718
  data: currentData,
1719
+ providers: currentProviders,
1710
1720
  skip,
1711
1721
  };
1712
1722
  };
@@ -1757,23 +1767,29 @@
1757
1767
  providers = rulesResult.updatedProviders;
1758
1768
  }
1759
1769
  const plugins = getPlugins(destination);
1770
+ const pluginSettings = {
1771
+ userId,
1772
+ sessionId,
1773
+ geoCountry: requestCountry,
1774
+ geoRegion: requestRegion,
1775
+ isEURequest,
1776
+ ip,
1777
+ consent: consentChannel,
1778
+ consentCategories: consentCategory,
1779
+ userProperties,
1780
+ };
1781
+ const pluginContext = getStandardPayload(destination);
1782
+ const pluginUtilities = {
1783
+ getIsNewCustomerFlag: () => getIsNewCustomerFlag(processGetData.bind(null, destination)),
1784
+ };
1760
1785
  if (plugins.length > 0) {
1761
- const pluginSettings = {
1762
- userId,
1763
- sessionId,
1764
- geoCountry: requestCountry,
1765
- geoRegion: requestRegion,
1766
- isEURequest,
1767
- ip,
1768
- consent: consentChannel,
1769
- consentCategories: consentCategory,
1770
- userProperties,
1771
- };
1772
- const baseParams = {
1786
+ const rootResult = await runPluginHook(plugins, 'tagRoot', {
1773
1787
  payload: { eventName: currentEventName, data, eventId },
1788
+ context: pluginContext,
1789
+ providers,
1774
1790
  settings: pluginSettings,
1775
- };
1776
- const rootResult = await runPluginHook(plugins, 'tagRoot', baseParams);
1791
+ utilities: pluginUtilities,
1792
+ });
1777
1793
  if (rootResult.skip) {
1778
1794
  sendTag(destination, {
1779
1795
  configuratorProcessed: true,
@@ -1786,6 +1802,10 @@
1786
1802
  });
1787
1803
  return;
1788
1804
  }
1805
+ if (rootResult.providers !== undefined) {
1806
+ // eslint-disable-next-line no-param-reassign
1807
+ providers = rootResult.providers;
1808
+ }
1789
1809
  currentEventName = rootResult.eventName;
1790
1810
  // eslint-disable-next-line no-param-reassign
1791
1811
  data = rootResult.data;
@@ -1809,18 +1829,10 @@
1809
1829
  data: channelData,
1810
1830
  eventId,
1811
1831
  },
1812
- settings: {
1813
- userId,
1814
- sessionId,
1815
- geoCountry: requestCountry,
1816
- geoRegion: requestRegion,
1817
- isEURequest,
1818
- ip,
1819
- consent: consentChannel,
1820
- consentCategories: consentCategory,
1821
- userProperties,
1822
- },
1832
+ context: pluginContext,
1833
+ settings: pluginSettings,
1823
1834
  providerId: pkg.name,
1835
+ utilities: pluginUtilities,
1824
1836
  });
1825
1837
  if (channelResult.skip)
1826
1838
  continue;
@@ -1852,18 +1864,10 @@
1852
1864
  data: instanceData,
1853
1865
  eventId,
1854
1866
  },
1855
- settings: {
1856
- userId,
1857
- sessionId,
1858
- geoCountry: requestCountry,
1859
- geoRegion: requestRegion,
1860
- isEURequest,
1861
- ip,
1862
- consent: consentChannel,
1863
- consentCategories: consentCategory,
1864
- userProperties,
1865
- },
1867
+ context: pluginContext,
1868
+ settings: pluginSettings,
1866
1869
  providerId: pkg.name,
1870
+ utilities: pluginUtilities,
1867
1871
  });
1868
1872
  if (instanceResult.skip)
1869
1873
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-browser",
3
- "version": "1.56.0",
3
+ "version": "1.57.0",
4
4
  "description": "Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",