@blotoutio/edgetag-sdk-js 1.56.1 → 1.57.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.cjs.js +123 -39
- package/index.mjs +123 -39
- package/internal.d.ts +2 -0
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -507,6 +507,74 @@ const usStates = new Map([
|
|
|
507
507
|
['US-VI', 'Virgin Islands, U.S.'],
|
|
508
508
|
]);
|
|
509
509
|
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
|
510
|
+
/**
|
|
511
|
+
* ISO 3166-1 alpha-2 codes for EU member states (as of 2024)
|
|
512
|
+
*/
|
|
513
|
+
const EU_COUNTRY_CODES = new Set([
|
|
514
|
+
'AT', // Austria
|
|
515
|
+
'BE', // Belgium
|
|
516
|
+
'BG', // Bulgaria
|
|
517
|
+
'CY', // Cyprus
|
|
518
|
+
'CZ', // Czech Republic
|
|
519
|
+
'DE', // Germany
|
|
520
|
+
'DK', // Denmark
|
|
521
|
+
'EE', // Estonia
|
|
522
|
+
'ES', // Spain
|
|
523
|
+
'FI', // Finland
|
|
524
|
+
'FR', // France
|
|
525
|
+
'GR', // Greece
|
|
526
|
+
'HR', // Croatia
|
|
527
|
+
'HU', // Hungary
|
|
528
|
+
'IE', // Ireland
|
|
529
|
+
'IT', // Italy
|
|
530
|
+
'LT', // Lithuania
|
|
531
|
+
'LU', // Luxembourg
|
|
532
|
+
'LV', // Latvia
|
|
533
|
+
'MT', // Malta
|
|
534
|
+
'NL', // Netherlands
|
|
535
|
+
'PL', // Poland
|
|
536
|
+
'PT', // Portugal
|
|
537
|
+
'RO', // Romania
|
|
538
|
+
'SE', // Sweden
|
|
539
|
+
'SI', // Slovenia
|
|
540
|
+
'SK', // Slovakia
|
|
541
|
+
]);
|
|
542
|
+
/**
|
|
543
|
+
* Returns true if the request originates from the EU or the UK (GB).
|
|
544
|
+
* Cloudflare's isEUCountry flag excludes the UK post-Brexit, so GB is
|
|
545
|
+
* checked explicitly alongside the EU member set.
|
|
546
|
+
*
|
|
547
|
+
* Fails closed: when the country cannot be resolved, the request is treated
|
|
548
|
+
* as EU/UK. This is the safe default for the compliance-sensitive Grey Switch
|
|
549
|
+
* (an unknown visitor may be in the EU/UK, so it must not slip through when
|
|
550
|
+
* the EU/UK toggle is off).
|
|
551
|
+
*/
|
|
552
|
+
const isEuUkRegion = (country, isEURequest) => {
|
|
553
|
+
if (isEURequest) {
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
if (!country) {
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
const upper = country.toUpperCase();
|
|
560
|
+
return upper === 'GB' || EU_COUNTRY_CODES.has(upper);
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* Grey Switch fire rule, shared by the SDK and the CDN worker so both stay in
|
|
564
|
+
* sync. When Grey Switch is on, EdgeTag fires server-side events for
|
|
565
|
+
* non-consented users. The EU/UK toggle is off by default, which keeps EU/UK
|
|
566
|
+
* visitors on normal consent unless the merchant explicitly opts those regions
|
|
567
|
+
* in. Returns whether a server-side event should fire for a non-consented user.
|
|
568
|
+
*/
|
|
569
|
+
const greySwitchAllowsServerEvent = ({ greySwitch, greySwitchEuUk, country, isEURequest, }) => {
|
|
570
|
+
if (!greySwitch) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
if (greySwitchEuUk) {
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return !isEuUkRegion(country, isEURequest);
|
|
577
|
+
};
|
|
510
578
|
const parseCache = new Map();
|
|
511
579
|
const parseRegions = (regionString) => {
|
|
512
580
|
const include = new Set();
|
|
@@ -1224,7 +1292,7 @@ const generateEventId = (name) => {
|
|
|
1224
1292
|
time = perf.toFixed(4);
|
|
1225
1293
|
}
|
|
1226
1294
|
}
|
|
1227
|
-
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
1295
|
+
return `${encodeString(name).replace(/[^a-zA-Z0-9]/g, '')}-${generateUUID()}-${time}`;
|
|
1228
1296
|
};
|
|
1229
1297
|
|
|
1230
1298
|
const getCookieValue = (key) => {
|
|
@@ -1407,6 +1475,11 @@ const getSession = (key) => {
|
|
|
1407
1475
|
}
|
|
1408
1476
|
};
|
|
1409
1477
|
|
|
1478
|
+
const getIsNewCustomerFlag = async (getData) => {
|
|
1479
|
+
const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
|
|
1480
|
+
return isNewCustomer ? isNewCustomer === 'true' : undefined;
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1410
1483
|
const getUserId$1 = (destination) => {
|
|
1411
1484
|
const userId = getSetting(destination, 'userId');
|
|
1412
1485
|
if (userId) {
|
|
@@ -1465,7 +1538,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
1465
1538
|
referrer: getReferrer(destination),
|
|
1466
1539
|
search: getSearch(destination),
|
|
1467
1540
|
locale: getLocale(),
|
|
1468
|
-
sdkVersion: "1.
|
|
1541
|
+
sdkVersion: "1.57.1" ,
|
|
1469
1542
|
...(payload || {}),
|
|
1470
1543
|
};
|
|
1471
1544
|
let storage = {};
|
|
@@ -1668,6 +1741,7 @@ const runPluginHook = async (plugins, hookName, baseParams) => {
|
|
|
1668
1741
|
const payload = baseParams['payload'];
|
|
1669
1742
|
let currentEventName = payload['eventName'];
|
|
1670
1743
|
let currentData = payload['data'];
|
|
1744
|
+
let currentProviders = baseParams['providers'];
|
|
1671
1745
|
let skip = false;
|
|
1672
1746
|
for (const plugin of plugins) {
|
|
1673
1747
|
const hook = plugin.rules[hookName];
|
|
@@ -1693,6 +1767,9 @@ const runPluginHook = async (plugins, hookName, baseParams) => {
|
|
|
1693
1767
|
if ((_b = result === null || result === void 0 ? void 0 : result.payload) === null || _b === void 0 ? void 0 : _b.data) {
|
|
1694
1768
|
currentData = result.payload.data;
|
|
1695
1769
|
}
|
|
1770
|
+
if ((result === null || result === void 0 ? void 0 : result.providers) !== undefined) {
|
|
1771
|
+
currentProviders = result.providers;
|
|
1772
|
+
}
|
|
1696
1773
|
if (result === null || result === void 0 ? void 0 : result.additionalEvents) {
|
|
1697
1774
|
for (const evt of result.additionalEvents) {
|
|
1698
1775
|
handleTag(evt.eventName, evt.data, undefined, undefined);
|
|
@@ -1706,6 +1783,7 @@ const runPluginHook = async (plugins, hookName, baseParams) => {
|
|
|
1706
1783
|
return {
|
|
1707
1784
|
eventName: currentEventName,
|
|
1708
1785
|
data: currentData,
|
|
1786
|
+
providers: currentProviders,
|
|
1709
1787
|
skip,
|
|
1710
1788
|
};
|
|
1711
1789
|
};
|
|
@@ -1736,6 +1814,15 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1736
1814
|
const consentCategory = getConsentCategories(destination);
|
|
1737
1815
|
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1738
1816
|
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1817
|
+
// Grey Switch: when enabled, still send the event to the server for
|
|
1818
|
+
// non-consented users. Browser pixels remain gated by hasUserConsent below,
|
|
1819
|
+
// so nothing fires client-side.
|
|
1820
|
+
const greySwitchAllows = greySwitchAllowsServerEvent({
|
|
1821
|
+
greySwitch: getSetting(destination, 'greySwitch') || false,
|
|
1822
|
+
greySwitchEuUk: getSetting(destination, 'greySwitchEuUk') || false,
|
|
1823
|
+
country: requestCountry,
|
|
1824
|
+
isEURequest,
|
|
1825
|
+
});
|
|
1739
1826
|
const ip = getSetting(destination, 'ip') || null;
|
|
1740
1827
|
const userProperties = getSetting(destination, 'userProperties');
|
|
1741
1828
|
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
@@ -1756,23 +1843,29 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1756
1843
|
providers = rulesResult.updatedProviders;
|
|
1757
1844
|
}
|
|
1758
1845
|
const plugins = getPlugins(destination);
|
|
1846
|
+
const pluginSettings = {
|
|
1847
|
+
userId,
|
|
1848
|
+
sessionId,
|
|
1849
|
+
geoCountry: requestCountry,
|
|
1850
|
+
geoRegion: requestRegion,
|
|
1851
|
+
isEURequest,
|
|
1852
|
+
ip,
|
|
1853
|
+
consent: consentChannel,
|
|
1854
|
+
consentCategories: consentCategory,
|
|
1855
|
+
userProperties,
|
|
1856
|
+
};
|
|
1857
|
+
const pluginContext = getStandardPayload(destination);
|
|
1858
|
+
const pluginUtilities = {
|
|
1859
|
+
getIsNewCustomerFlag: () => getIsNewCustomerFlag(processGetData.bind(null, destination)),
|
|
1860
|
+
};
|
|
1759
1861
|
if (plugins.length > 0) {
|
|
1760
|
-
const
|
|
1761
|
-
userId,
|
|
1762
|
-
sessionId,
|
|
1763
|
-
geoCountry: requestCountry,
|
|
1764
|
-
geoRegion: requestRegion,
|
|
1765
|
-
isEURequest,
|
|
1766
|
-
ip,
|
|
1767
|
-
consent: consentChannel,
|
|
1768
|
-
consentCategories: consentCategory,
|
|
1769
|
-
userProperties,
|
|
1770
|
-
};
|
|
1771
|
-
const baseParams = {
|
|
1862
|
+
const rootResult = await runPluginHook(plugins, 'tagRoot', {
|
|
1772
1863
|
payload: { eventName: currentEventName, data, eventId },
|
|
1864
|
+
context: pluginContext,
|
|
1865
|
+
providers,
|
|
1773
1866
|
settings: pluginSettings,
|
|
1774
|
-
|
|
1775
|
-
|
|
1867
|
+
utilities: pluginUtilities,
|
|
1868
|
+
});
|
|
1776
1869
|
if (rootResult.skip) {
|
|
1777
1870
|
sendTag(destination, {
|
|
1778
1871
|
configuratorProcessed: true,
|
|
@@ -1785,6 +1878,10 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1785
1878
|
});
|
|
1786
1879
|
return;
|
|
1787
1880
|
}
|
|
1881
|
+
if (rootResult.providers !== undefined) {
|
|
1882
|
+
// eslint-disable-next-line no-param-reassign
|
|
1883
|
+
providers = rootResult.providers;
|
|
1884
|
+
}
|
|
1788
1885
|
currentEventName = rootResult.eventName;
|
|
1789
1886
|
// eslint-disable-next-line no-param-reassign
|
|
1790
1887
|
data = rootResult.data;
|
|
@@ -1808,18 +1905,10 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1808
1905
|
data: channelData,
|
|
1809
1906
|
eventId,
|
|
1810
1907
|
},
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
sessionId,
|
|
1814
|
-
geoCountry: requestCountry,
|
|
1815
|
-
geoRegion: requestRegion,
|
|
1816
|
-
isEURequest,
|
|
1817
|
-
ip,
|
|
1818
|
-
consent: consentChannel,
|
|
1819
|
-
consentCategories: consentCategory,
|
|
1820
|
-
userProperties,
|
|
1821
|
-
},
|
|
1908
|
+
context: pluginContext,
|
|
1909
|
+
settings: pluginSettings,
|
|
1822
1910
|
providerId: pkg.name,
|
|
1911
|
+
utilities: pluginUtilities,
|
|
1823
1912
|
});
|
|
1824
1913
|
if (channelResult.skip)
|
|
1825
1914
|
continue;
|
|
@@ -1851,18 +1940,10 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1851
1940
|
data: instanceData,
|
|
1852
1941
|
eventId,
|
|
1853
1942
|
},
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
sessionId,
|
|
1857
|
-
geoCountry: requestCountry,
|
|
1858
|
-
geoRegion: requestRegion,
|
|
1859
|
-
isEURequest,
|
|
1860
|
-
ip,
|
|
1861
|
-
consent: consentChannel,
|
|
1862
|
-
consentCategories: consentCategory,
|
|
1863
|
-
userProperties,
|
|
1864
|
-
},
|
|
1943
|
+
context: pluginContext,
|
|
1944
|
+
settings: pluginSettings,
|
|
1865
1945
|
providerId: pkg.name,
|
|
1946
|
+
utilities: pluginUtilities,
|
|
1866
1947
|
});
|
|
1867
1948
|
if (instanceResult.skip)
|
|
1868
1949
|
continue;
|
|
@@ -1898,7 +1979,8 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1898
1979
|
else {
|
|
1899
1980
|
logger.log('Browser events skipped by event rules, sending tag to server only');
|
|
1900
1981
|
}
|
|
1901
|
-
if (!hasAllowedManifestTags(configuredTags, userConsent, providers)
|
|
1982
|
+
if (!hasAllowedManifestTags(configuredTags, userConsent, providers) &&
|
|
1983
|
+
!greySwitchAllows) {
|
|
1902
1984
|
return;
|
|
1903
1985
|
}
|
|
1904
1986
|
sendTag(destination, {
|
|
@@ -2469,6 +2551,8 @@ const handleInit = (preferences) => {
|
|
|
2469
2551
|
storageId: result.storageId,
|
|
2470
2552
|
currency: result.currency,
|
|
2471
2553
|
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
2554
|
+
greySwitch: result.greySwitch,
|
|
2555
|
+
greySwitchEuUk: result.greySwitchEuUk,
|
|
2472
2556
|
geoCountry: result.geoCountry,
|
|
2473
2557
|
geoRegion: result.geoRegion,
|
|
2474
2558
|
isEURequest: result.isEURequest,
|
package/index.mjs
CHANGED
|
@@ -505,6 +505,74 @@ const usStates = new Map([
|
|
|
505
505
|
['US-VI', 'Virgin Islands, U.S.'],
|
|
506
506
|
]);
|
|
507
507
|
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
|
508
|
+
/**
|
|
509
|
+
* ISO 3166-1 alpha-2 codes for EU member states (as of 2024)
|
|
510
|
+
*/
|
|
511
|
+
const EU_COUNTRY_CODES = new Set([
|
|
512
|
+
'AT', // Austria
|
|
513
|
+
'BE', // Belgium
|
|
514
|
+
'BG', // Bulgaria
|
|
515
|
+
'CY', // Cyprus
|
|
516
|
+
'CZ', // Czech Republic
|
|
517
|
+
'DE', // Germany
|
|
518
|
+
'DK', // Denmark
|
|
519
|
+
'EE', // Estonia
|
|
520
|
+
'ES', // Spain
|
|
521
|
+
'FI', // Finland
|
|
522
|
+
'FR', // France
|
|
523
|
+
'GR', // Greece
|
|
524
|
+
'HR', // Croatia
|
|
525
|
+
'HU', // Hungary
|
|
526
|
+
'IE', // Ireland
|
|
527
|
+
'IT', // Italy
|
|
528
|
+
'LT', // Lithuania
|
|
529
|
+
'LU', // Luxembourg
|
|
530
|
+
'LV', // Latvia
|
|
531
|
+
'MT', // Malta
|
|
532
|
+
'NL', // Netherlands
|
|
533
|
+
'PL', // Poland
|
|
534
|
+
'PT', // Portugal
|
|
535
|
+
'RO', // Romania
|
|
536
|
+
'SE', // Sweden
|
|
537
|
+
'SI', // Slovenia
|
|
538
|
+
'SK', // Slovakia
|
|
539
|
+
]);
|
|
540
|
+
/**
|
|
541
|
+
* Returns true if the request originates from the EU or the UK (GB).
|
|
542
|
+
* Cloudflare's isEUCountry flag excludes the UK post-Brexit, so GB is
|
|
543
|
+
* checked explicitly alongside the EU member set.
|
|
544
|
+
*
|
|
545
|
+
* Fails closed: when the country cannot be resolved, the request is treated
|
|
546
|
+
* as EU/UK. This is the safe default for the compliance-sensitive Grey Switch
|
|
547
|
+
* (an unknown visitor may be in the EU/UK, so it must not slip through when
|
|
548
|
+
* the EU/UK toggle is off).
|
|
549
|
+
*/
|
|
550
|
+
const isEuUkRegion = (country, isEURequest) => {
|
|
551
|
+
if (isEURequest) {
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
if (!country) {
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
const upper = country.toUpperCase();
|
|
558
|
+
return upper === 'GB' || EU_COUNTRY_CODES.has(upper);
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* Grey Switch fire rule, shared by the SDK and the CDN worker so both stay in
|
|
562
|
+
* sync. When Grey Switch is on, EdgeTag fires server-side events for
|
|
563
|
+
* non-consented users. The EU/UK toggle is off by default, which keeps EU/UK
|
|
564
|
+
* visitors on normal consent unless the merchant explicitly opts those regions
|
|
565
|
+
* in. Returns whether a server-side event should fire for a non-consented user.
|
|
566
|
+
*/
|
|
567
|
+
const greySwitchAllowsServerEvent = ({ greySwitch, greySwitchEuUk, country, isEURequest, }) => {
|
|
568
|
+
if (!greySwitch) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
if (greySwitchEuUk) {
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
return !isEuUkRegion(country, isEURequest);
|
|
575
|
+
};
|
|
508
576
|
const parseCache = new Map();
|
|
509
577
|
const parseRegions = (regionString) => {
|
|
510
578
|
const include = new Set();
|
|
@@ -1222,7 +1290,7 @@ const generateEventId = (name) => {
|
|
|
1222
1290
|
time = perf.toFixed(4);
|
|
1223
1291
|
}
|
|
1224
1292
|
}
|
|
1225
|
-
return `${encodeString(name)}-${generateUUID()}-${time}`;
|
|
1293
|
+
return `${encodeString(name).replace(/[^a-zA-Z0-9]/g, '')}-${generateUUID()}-${time}`;
|
|
1226
1294
|
};
|
|
1227
1295
|
|
|
1228
1296
|
const getCookieValue = (key) => {
|
|
@@ -1405,6 +1473,11 @@ const getSession = (key) => {
|
|
|
1405
1473
|
}
|
|
1406
1474
|
};
|
|
1407
1475
|
|
|
1476
|
+
const getIsNewCustomerFlag = async (getData) => {
|
|
1477
|
+
const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
|
|
1478
|
+
return isNewCustomer ? isNewCustomer === 'true' : undefined;
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1408
1481
|
const getUserId$1 = (destination) => {
|
|
1409
1482
|
const userId = getSetting(destination, 'userId');
|
|
1410
1483
|
if (userId) {
|
|
@@ -1463,7 +1536,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
1463
1536
|
referrer: getReferrer(destination),
|
|
1464
1537
|
search: getSearch(destination),
|
|
1465
1538
|
locale: getLocale(),
|
|
1466
|
-
sdkVersion: "1.
|
|
1539
|
+
sdkVersion: "1.57.1" ,
|
|
1467
1540
|
...(payload || {}),
|
|
1468
1541
|
};
|
|
1469
1542
|
let storage = {};
|
|
@@ -1666,6 +1739,7 @@ const runPluginHook = async (plugins, hookName, baseParams) => {
|
|
|
1666
1739
|
const payload = baseParams['payload'];
|
|
1667
1740
|
let currentEventName = payload['eventName'];
|
|
1668
1741
|
let currentData = payload['data'];
|
|
1742
|
+
let currentProviders = baseParams['providers'];
|
|
1669
1743
|
let skip = false;
|
|
1670
1744
|
for (const plugin of plugins) {
|
|
1671
1745
|
const hook = plugin.rules[hookName];
|
|
@@ -1691,6 +1765,9 @@ const runPluginHook = async (plugins, hookName, baseParams) => {
|
|
|
1691
1765
|
if ((_b = result === null || result === void 0 ? void 0 : result.payload) === null || _b === void 0 ? void 0 : _b.data) {
|
|
1692
1766
|
currentData = result.payload.data;
|
|
1693
1767
|
}
|
|
1768
|
+
if ((result === null || result === void 0 ? void 0 : result.providers) !== undefined) {
|
|
1769
|
+
currentProviders = result.providers;
|
|
1770
|
+
}
|
|
1694
1771
|
if (result === null || result === void 0 ? void 0 : result.additionalEvents) {
|
|
1695
1772
|
for (const evt of result.additionalEvents) {
|
|
1696
1773
|
handleTag(evt.eventName, evt.data, undefined, undefined);
|
|
@@ -1704,6 +1781,7 @@ const runPluginHook = async (plugins, hookName, baseParams) => {
|
|
|
1704
1781
|
return {
|
|
1705
1782
|
eventName: currentEventName,
|
|
1706
1783
|
data: currentData,
|
|
1784
|
+
providers: currentProviders,
|
|
1707
1785
|
skip,
|
|
1708
1786
|
};
|
|
1709
1787
|
};
|
|
@@ -1734,6 +1812,15 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1734
1812
|
const consentCategory = getConsentCategories(destination);
|
|
1735
1813
|
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1736
1814
|
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1815
|
+
// Grey Switch: when enabled, still send the event to the server for
|
|
1816
|
+
// non-consented users. Browser pixels remain gated by hasUserConsent below,
|
|
1817
|
+
// so nothing fires client-side.
|
|
1818
|
+
const greySwitchAllows = greySwitchAllowsServerEvent({
|
|
1819
|
+
greySwitch: getSetting(destination, 'greySwitch') || false,
|
|
1820
|
+
greySwitchEuUk: getSetting(destination, 'greySwitchEuUk') || false,
|
|
1821
|
+
country: requestCountry,
|
|
1822
|
+
isEURequest,
|
|
1823
|
+
});
|
|
1737
1824
|
const ip = getSetting(destination, 'ip') || null;
|
|
1738
1825
|
const userProperties = getSetting(destination, 'userProperties');
|
|
1739
1826
|
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
@@ -1754,23 +1841,29 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1754
1841
|
providers = rulesResult.updatedProviders;
|
|
1755
1842
|
}
|
|
1756
1843
|
const plugins = getPlugins(destination);
|
|
1844
|
+
const pluginSettings = {
|
|
1845
|
+
userId,
|
|
1846
|
+
sessionId,
|
|
1847
|
+
geoCountry: requestCountry,
|
|
1848
|
+
geoRegion: requestRegion,
|
|
1849
|
+
isEURequest,
|
|
1850
|
+
ip,
|
|
1851
|
+
consent: consentChannel,
|
|
1852
|
+
consentCategories: consentCategory,
|
|
1853
|
+
userProperties,
|
|
1854
|
+
};
|
|
1855
|
+
const pluginContext = getStandardPayload(destination);
|
|
1856
|
+
const pluginUtilities = {
|
|
1857
|
+
getIsNewCustomerFlag: () => getIsNewCustomerFlag(processGetData.bind(null, destination)),
|
|
1858
|
+
};
|
|
1757
1859
|
if (plugins.length > 0) {
|
|
1758
|
-
const
|
|
1759
|
-
userId,
|
|
1760
|
-
sessionId,
|
|
1761
|
-
geoCountry: requestCountry,
|
|
1762
|
-
geoRegion: requestRegion,
|
|
1763
|
-
isEURequest,
|
|
1764
|
-
ip,
|
|
1765
|
-
consent: consentChannel,
|
|
1766
|
-
consentCategories: consentCategory,
|
|
1767
|
-
userProperties,
|
|
1768
|
-
};
|
|
1769
|
-
const baseParams = {
|
|
1860
|
+
const rootResult = await runPluginHook(plugins, 'tagRoot', {
|
|
1770
1861
|
payload: { eventName: currentEventName, data, eventId },
|
|
1862
|
+
context: pluginContext,
|
|
1863
|
+
providers,
|
|
1771
1864
|
settings: pluginSettings,
|
|
1772
|
-
|
|
1773
|
-
|
|
1865
|
+
utilities: pluginUtilities,
|
|
1866
|
+
});
|
|
1774
1867
|
if (rootResult.skip) {
|
|
1775
1868
|
sendTag(destination, {
|
|
1776
1869
|
configuratorProcessed: true,
|
|
@@ -1783,6 +1876,10 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1783
1876
|
});
|
|
1784
1877
|
return;
|
|
1785
1878
|
}
|
|
1879
|
+
if (rootResult.providers !== undefined) {
|
|
1880
|
+
// eslint-disable-next-line no-param-reassign
|
|
1881
|
+
providers = rootResult.providers;
|
|
1882
|
+
}
|
|
1786
1883
|
currentEventName = rootResult.eventName;
|
|
1787
1884
|
// eslint-disable-next-line no-param-reassign
|
|
1788
1885
|
data = rootResult.data;
|
|
@@ -1806,18 +1903,10 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1806
1903
|
data: channelData,
|
|
1807
1904
|
eventId,
|
|
1808
1905
|
},
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
sessionId,
|
|
1812
|
-
geoCountry: requestCountry,
|
|
1813
|
-
geoRegion: requestRegion,
|
|
1814
|
-
isEURequest,
|
|
1815
|
-
ip,
|
|
1816
|
-
consent: consentChannel,
|
|
1817
|
-
consentCategories: consentCategory,
|
|
1818
|
-
userProperties,
|
|
1819
|
-
},
|
|
1906
|
+
context: pluginContext,
|
|
1907
|
+
settings: pluginSettings,
|
|
1820
1908
|
providerId: pkg.name,
|
|
1909
|
+
utilities: pluginUtilities,
|
|
1821
1910
|
});
|
|
1822
1911
|
if (channelResult.skip)
|
|
1823
1912
|
continue;
|
|
@@ -1849,18 +1938,10 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1849
1938
|
data: instanceData,
|
|
1850
1939
|
eventId,
|
|
1851
1940
|
},
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
sessionId,
|
|
1855
|
-
geoCountry: requestCountry,
|
|
1856
|
-
geoRegion: requestRegion,
|
|
1857
|
-
isEURequest,
|
|
1858
|
-
ip,
|
|
1859
|
-
consent: consentChannel,
|
|
1860
|
-
consentCategories: consentCategory,
|
|
1861
|
-
userProperties,
|
|
1862
|
-
},
|
|
1941
|
+
context: pluginContext,
|
|
1942
|
+
settings: pluginSettings,
|
|
1863
1943
|
providerId: pkg.name,
|
|
1944
|
+
utilities: pluginUtilities,
|
|
1864
1945
|
});
|
|
1865
1946
|
if (instanceResult.skip)
|
|
1866
1947
|
continue;
|
|
@@ -1896,7 +1977,8 @@ const processTag = async (destination, eventName, data = {}, providers, options)
|
|
|
1896
1977
|
else {
|
|
1897
1978
|
logger.log('Browser events skipped by event rules, sending tag to server only');
|
|
1898
1979
|
}
|
|
1899
|
-
if (!hasAllowedManifestTags(configuredTags, userConsent, providers)
|
|
1980
|
+
if (!hasAllowedManifestTags(configuredTags, userConsent, providers) &&
|
|
1981
|
+
!greySwitchAllows) {
|
|
1900
1982
|
return;
|
|
1901
1983
|
}
|
|
1902
1984
|
sendTag(destination, {
|
|
@@ -2467,6 +2549,8 @@ const handleInit = (preferences) => {
|
|
|
2467
2549
|
storageId: result.storageId,
|
|
2468
2550
|
currency: result.currency,
|
|
2469
2551
|
skipZeroPurchaseEvent: result.skipZeroPurchaseEvent,
|
|
2552
|
+
greySwitch: result.greySwitch,
|
|
2553
|
+
greySwitchEuUk: result.greySwitchEuUk,
|
|
2470
2554
|
geoCountry: result.geoCountry,
|
|
2471
2555
|
geoRegion: result.geoRegion,
|
|
2472
2556
|
isEURequest: result.isEURequest,
|
package/internal.d.ts
CHANGED