@blotoutio/edgetag-sdk-browser 1.58.1 → 1.59.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 +230 -157
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -508,77 +508,6 @@
|
|
|
508
508
|
['US-VI', 'Virgin Islands, U.S.'],
|
|
509
509
|
]);
|
|
510
510
|
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
|
511
|
-
/**
|
|
512
|
-
* ISO 3166-1 alpha-2 codes for EU member states (as of 2024)
|
|
513
|
-
*/
|
|
514
|
-
const EU_COUNTRY_CODES = new Set([
|
|
515
|
-
'AT', // Austria
|
|
516
|
-
'BE', // Belgium
|
|
517
|
-
'BG', // Bulgaria
|
|
518
|
-
'CY', // Cyprus
|
|
519
|
-
'CZ', // Czech Republic
|
|
520
|
-
'DE', // Germany
|
|
521
|
-
'DK', // Denmark
|
|
522
|
-
'EE', // Estonia
|
|
523
|
-
'ES', // Spain
|
|
524
|
-
'FI', // Finland
|
|
525
|
-
'FR', // France
|
|
526
|
-
'GR', // Greece
|
|
527
|
-
'HR', // Croatia
|
|
528
|
-
'HU', // Hungary
|
|
529
|
-
'IE', // Ireland
|
|
530
|
-
'IT', // Italy
|
|
531
|
-
'LT', // Lithuania
|
|
532
|
-
'LU', // Luxembourg
|
|
533
|
-
'LV', // Latvia
|
|
534
|
-
'MT', // Malta
|
|
535
|
-
'NL', // Netherlands
|
|
536
|
-
'PL', // Poland
|
|
537
|
-
'PT', // Portugal
|
|
538
|
-
'RO', // Romania
|
|
539
|
-
'SE', // Sweden
|
|
540
|
-
'SI', // Slovenia
|
|
541
|
-
'SK', // Slovakia
|
|
542
|
-
]);
|
|
543
|
-
/**
|
|
544
|
-
* Returns true if the request originates from the EU or the UK (GB).
|
|
545
|
-
* Cloudflare's isEUCountry flag excludes the UK post-Brexit, so GB is
|
|
546
|
-
* checked explicitly alongside the EU member set.
|
|
547
|
-
*
|
|
548
|
-
* Fails closed: when the country cannot be resolved, the request is treated
|
|
549
|
-
* as EU/UK. This is the safe default for the compliance-sensitive Grey Switch
|
|
550
|
-
* (an unknown visitor may be in the EU/UK, so it must not slip through when
|
|
551
|
-
* the EU/UK toggle is off).
|
|
552
|
-
*/
|
|
553
|
-
const isEuUkRegion = (country, isEURequest) => {
|
|
554
|
-
if (isEURequest) {
|
|
555
|
-
return true;
|
|
556
|
-
}
|
|
557
|
-
if (!country) {
|
|
558
|
-
return true;
|
|
559
|
-
}
|
|
560
|
-
const upper = country.toUpperCase();
|
|
561
|
-
return upper === 'GB' || EU_COUNTRY_CODES.has(upper);
|
|
562
|
-
};
|
|
563
|
-
/**
|
|
564
|
-
* Grey Switch fire rule, shared by the SDK and the CDN worker so both stay in
|
|
565
|
-
* sync. When Grey Switch is on, EdgeTag fires server-side events for
|
|
566
|
-
* non-consented users. The EU/UK toggle is off by default, which keeps EU/UK
|
|
567
|
-
* visitors on normal consent unless the merchant explicitly opts those regions
|
|
568
|
-
* in. Returns whether a server-side event should fire for a non-consented user.
|
|
569
|
-
*/
|
|
570
|
-
const greySwitchAllowsServerEvent = ({ greySwitch, greySwitchEuUk, country, isEURequest, isGPC, }) => {
|
|
571
|
-
if (isGPC) {
|
|
572
|
-
return false;
|
|
573
|
-
}
|
|
574
|
-
if (!greySwitch) {
|
|
575
|
-
return false;
|
|
576
|
-
}
|
|
577
|
-
if (greySwitchEuUk) {
|
|
578
|
-
return true;
|
|
579
|
-
}
|
|
580
|
-
return !isEuUkRegion(country, isEURequest);
|
|
581
|
-
};
|
|
582
511
|
const parseCache = new Map();
|
|
583
512
|
const parseRegions = (regionString) => {
|
|
584
513
|
const include = new Set();
|
|
@@ -1542,7 +1471,7 @@
|
|
|
1542
1471
|
referrer: getReferrer(destination),
|
|
1543
1472
|
search: getSearch(destination),
|
|
1544
1473
|
locale: getLocale(),
|
|
1545
|
-
sdkVersion: "1.
|
|
1474
|
+
sdkVersion: "1.59.1" ,
|
|
1546
1475
|
...(payload || {}),
|
|
1547
1476
|
};
|
|
1548
1477
|
let storage = {};
|
|
@@ -1730,6 +1659,72 @@
|
|
|
1730
1659
|
}
|
|
1731
1660
|
postRequest(getTagURL(destination, eventName, options), payload, options).catch(logger.error);
|
|
1732
1661
|
};
|
|
1662
|
+
// Scope (scripts/providers allow-lists) is delivered per plugin via /init, keyed
|
|
1663
|
+
// by the plugin's identity `${providerId}||${name}` (which is carried in the
|
|
1664
|
+
// plugin object's `name`). A missing scope means the plugin is global.
|
|
1665
|
+
//
|
|
1666
|
+
// Mirrors the edge getAllowedPlugins per-item logic: at instance level the
|
|
1667
|
+
// scripts allow-list wins, otherwise fall back to the providers allow-list.
|
|
1668
|
+
const isPluginAllowed = (scope, providerId, instanceName) => {
|
|
1669
|
+
if (!scope) {
|
|
1670
|
+
return true;
|
|
1671
|
+
}
|
|
1672
|
+
if (instanceName && scope.scripts.length > 0) {
|
|
1673
|
+
return scope.scripts.includes(`${providerId}||${instanceName}`);
|
|
1674
|
+
}
|
|
1675
|
+
return scope.providers.length === 0 || scope.providers.includes(providerId);
|
|
1676
|
+
};
|
|
1677
|
+
// Mirrors the edge processPluginsRoot skip scope: a global plugin (no scope)
|
|
1678
|
+
// skips every browser instance (null), a scoped plugin skips only the instances
|
|
1679
|
+
// its scripts/providers allow-lists resolve to.
|
|
1680
|
+
const getScopedPluginSkipKeys = (scope, configuredTags) => {
|
|
1681
|
+
if (!scope || (scope.scripts.length === 0 && scope.providers.length === 0)) {
|
|
1682
|
+
return null;
|
|
1683
|
+
}
|
|
1684
|
+
const result = new Set();
|
|
1685
|
+
for (const script of scope.scripts) {
|
|
1686
|
+
result.add(script);
|
|
1687
|
+
}
|
|
1688
|
+
for (const providerId of scope.providers) {
|
|
1689
|
+
const instances = configuredTags.get(providerId);
|
|
1690
|
+
if (!instances)
|
|
1691
|
+
continue;
|
|
1692
|
+
for (const instanceName of instances) {
|
|
1693
|
+
result.add(`${providerId}||${instanceName}`);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
return result;
|
|
1697
|
+
};
|
|
1698
|
+
// Mirrors the edge getProviderLimits: an additional event emitted by a scoped
|
|
1699
|
+
// plugin is restricted to that plugin's channels/instances; a global plugin
|
|
1700
|
+
// imposes no restriction (undefined).
|
|
1701
|
+
const getPluginProviderLimits = (scope) => {
|
|
1702
|
+
if (!scope || (scope.scripts.length === 0 && scope.providers.length === 0)) {
|
|
1703
|
+
return undefined;
|
|
1704
|
+
}
|
|
1705
|
+
const limited = {};
|
|
1706
|
+
for (const script of scope.scripts) {
|
|
1707
|
+
const separator = script.indexOf('||');
|
|
1708
|
+
if (separator === -1) {
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
const provider = script.slice(0, separator);
|
|
1712
|
+
const instance = script.slice(separator + 2);
|
|
1713
|
+
const existing = limited[provider];
|
|
1714
|
+
if (existing && existing !== true) {
|
|
1715
|
+
existing[instance] = true;
|
|
1716
|
+
}
|
|
1717
|
+
else {
|
|
1718
|
+
limited[provider] = { [instance]: true };
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
for (const provider of scope.providers) {
|
|
1722
|
+
if (!(provider in limited)) {
|
|
1723
|
+
limited[provider] = true;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return limited;
|
|
1727
|
+
};
|
|
1733
1728
|
const getPlugins = (destination) => {
|
|
1734
1729
|
var _a, _b, _c;
|
|
1735
1730
|
try {
|
|
@@ -1740,7 +1735,19 @@
|
|
|
1740
1735
|
return [];
|
|
1741
1736
|
}
|
|
1742
1737
|
};
|
|
1743
|
-
|
|
1738
|
+
// Dispatches a plugin's additional events. Mirrors the edge: each event is
|
|
1739
|
+
// stamped with the emitting plugin (so it cannot reprocess itself) and limited
|
|
1740
|
+
// to that plugin's scope.
|
|
1741
|
+
const dispatchAdditionalEvents = (plugin, pluginScopes, events) => {
|
|
1742
|
+
const providerLimits = getPluginProviderLimits(pluginScopes === null || pluginScopes === void 0 ? void 0 : pluginScopes[plugin.name]);
|
|
1743
|
+
for (const evt of events) {
|
|
1744
|
+
handleTag(evt.eventName, evt.data, providerLimits, undefined, plugin.name);
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
// Runs a channel/instance hook chain. The emitting plugin is excluded by the
|
|
1748
|
+
// caller's allow-list filter; additional events fire before any skip is applied
|
|
1749
|
+
// (matching the edge), and a skip is reported without mutating the final tag.
|
|
1750
|
+
const runPluginHook = async (plugins, hookName, pluginScopes, baseParams) => {
|
|
1744
1751
|
var _a, _b;
|
|
1745
1752
|
const payload = baseParams['payload'];
|
|
1746
1753
|
let currentEventName = payload['eventName'];
|
|
@@ -1761,6 +1768,9 @@
|
|
|
1761
1768
|
},
|
|
1762
1769
|
variables: plugin.variables || {},
|
|
1763
1770
|
});
|
|
1771
|
+
if (result === null || result === void 0 ? void 0 : result.additionalEvents) {
|
|
1772
|
+
dispatchAdditionalEvents(plugin, pluginScopes, result.additionalEvents);
|
|
1773
|
+
}
|
|
1764
1774
|
if (result === null || result === void 0 ? void 0 : result.skipEvent) {
|
|
1765
1775
|
skip = true;
|
|
1766
1776
|
break;
|
|
@@ -1774,24 +1784,87 @@
|
|
|
1774
1784
|
if ((result === null || result === void 0 ? void 0 : result.providers) !== undefined) {
|
|
1775
1785
|
currentProviders = result.providers;
|
|
1776
1786
|
}
|
|
1787
|
+
}
|
|
1788
|
+
catch (e) {
|
|
1789
|
+
logger.error(`Plugin ${plugin.name} ${hookName} error: ${e}`);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
return {
|
|
1793
|
+
eventName: currentEventName,
|
|
1794
|
+
data: currentData,
|
|
1795
|
+
providers: currentProviders,
|
|
1796
|
+
skip,
|
|
1797
|
+
};
|
|
1798
|
+
};
|
|
1799
|
+
// Root hooks mirror the edge processPluginsRoot: every plugin runs (except the
|
|
1800
|
+
// one that emitted this event), additional events are dispatched before any
|
|
1801
|
+
// skip is applied, and skips are scoped — a global plugin marks every browser
|
|
1802
|
+
// instance, a scoped one only its resolved instances. The skip is a marker:
|
|
1803
|
+
// channel/instance hooks still run and only the final tag is suppressed.
|
|
1804
|
+
const runRootPluginHooks = async (plugins, baseParams, pluginScopes, configuredTags, pluginSource) => {
|
|
1805
|
+
var _a, _b;
|
|
1806
|
+
const payload = baseParams['payload'];
|
|
1807
|
+
let currentEventName = payload['eventName'];
|
|
1808
|
+
let currentData = payload['data'];
|
|
1809
|
+
let currentProviders = baseParams['providers'];
|
|
1810
|
+
const skippedInstances = new Set();
|
|
1811
|
+
for (const plugin of plugins) {
|
|
1812
|
+
if (plugin.name === pluginSource)
|
|
1813
|
+
continue;
|
|
1814
|
+
const hook = plugin.rules.tagRoot;
|
|
1815
|
+
if (!hook)
|
|
1816
|
+
continue;
|
|
1817
|
+
try {
|
|
1818
|
+
const result = await hook({
|
|
1819
|
+
...baseParams,
|
|
1820
|
+
payload: {
|
|
1821
|
+
...payload,
|
|
1822
|
+
eventName: currentEventName,
|
|
1823
|
+
data: jsonClone(currentData),
|
|
1824
|
+
},
|
|
1825
|
+
variables: plugin.variables || {},
|
|
1826
|
+
});
|
|
1777
1827
|
if (result === null || result === void 0 ? void 0 : result.additionalEvents) {
|
|
1778
|
-
|
|
1779
|
-
|
|
1828
|
+
dispatchAdditionalEvents(plugin, pluginScopes, result.additionalEvents);
|
|
1829
|
+
}
|
|
1830
|
+
if (result === null || result === void 0 ? void 0 : result.skipEvent) {
|
|
1831
|
+
const scopeSkipKeys = getScopedPluginSkipKeys(pluginScopes === null || pluginScopes === void 0 ? void 0 : pluginScopes[plugin.name], configuredTags);
|
|
1832
|
+
if (scopeSkipKeys === null) {
|
|
1833
|
+
// Global plugin: skip every configured browser instance.
|
|
1834
|
+
for (const [provider, instances] of configuredTags) {
|
|
1835
|
+
for (const instanceName of instances) {
|
|
1836
|
+
skippedInstances.add(`${provider}||${instanceName}`);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1780
1839
|
}
|
|
1840
|
+
else {
|
|
1841
|
+
for (const key of scopeSkipKeys) {
|
|
1842
|
+
skippedInstances.add(key);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if ((_a = result === null || result === void 0 ? void 0 : result.payload) === null || _a === void 0 ? void 0 : _a.eventName) {
|
|
1847
|
+
currentEventName = result.payload.eventName;
|
|
1848
|
+
}
|
|
1849
|
+
if ((_b = result === null || result === void 0 ? void 0 : result.payload) === null || _b === void 0 ? void 0 : _b.data) {
|
|
1850
|
+
currentData = result.payload.data;
|
|
1851
|
+
}
|
|
1852
|
+
if ((result === null || result === void 0 ? void 0 : result.providers) !== undefined) {
|
|
1853
|
+
currentProviders = result.providers;
|
|
1781
1854
|
}
|
|
1782
1855
|
}
|
|
1783
1856
|
catch (e) {
|
|
1784
|
-
logger.error(`Plugin ${plugin.name}
|
|
1857
|
+
logger.error(`Plugin ${plugin.name} tagRoot error: ${e}`);
|
|
1785
1858
|
}
|
|
1786
1859
|
}
|
|
1787
1860
|
return {
|
|
1788
1861
|
eventName: currentEventName,
|
|
1789
1862
|
data: currentData,
|
|
1790
1863
|
providers: currentProviders,
|
|
1791
|
-
|
|
1864
|
+
skippedInstances,
|
|
1792
1865
|
};
|
|
1793
1866
|
};
|
|
1794
|
-
const processTag = async (destination, eventName, data = {}, providers, options) => {
|
|
1867
|
+
const processTag = async (destination, eventName, data = {}, providers, options, pluginSource) => {
|
|
1795
1868
|
var _a, _b;
|
|
1796
1869
|
let currentEventName = eventName;
|
|
1797
1870
|
if (!getSetting(destination, 'initialized')) {
|
|
@@ -1818,15 +1891,6 @@
|
|
|
1818
1891
|
const consentCategory = getConsentCategories(destination);
|
|
1819
1892
|
const consentSettings = getSetting(destination, 'consentSetting');
|
|
1820
1893
|
const userConsent = { consentChannel, consentCategory, consentSettings };
|
|
1821
|
-
// Grey Switch: when enabled, still send the event to the server for
|
|
1822
|
-
// non-consented users. Browser pixels remain gated by hasUserConsent below,
|
|
1823
|
-
// so nothing fires client-side.
|
|
1824
|
-
const greySwitchAllows = greySwitchAllowsServerEvent({
|
|
1825
|
-
greySwitch: getSetting(destination, 'greySwitch') || false,
|
|
1826
|
-
greySwitchEuUk: getSetting(destination, 'greySwitchEuUk') || false,
|
|
1827
|
-
country: requestCountry,
|
|
1828
|
-
isEURequest,
|
|
1829
|
-
});
|
|
1830
1894
|
const ip = getSetting(destination, 'ip') || null;
|
|
1831
1895
|
const userProperties = getSetting(destination, 'userProperties');
|
|
1832
1896
|
if (skipZeroPurchaseEvent && isZeroPurchaseEvent({ eventName, data })) {
|
|
@@ -1847,6 +1911,7 @@
|
|
|
1847
1911
|
providers = rulesResult.updatedProviders;
|
|
1848
1912
|
}
|
|
1849
1913
|
const plugins = getPlugins(destination);
|
|
1914
|
+
const pluginScopes = getSetting(destination, 'pluginScopes');
|
|
1850
1915
|
const pluginSettings = {
|
|
1851
1916
|
userId,
|
|
1852
1917
|
sessionId,
|
|
@@ -1862,26 +1927,15 @@
|
|
|
1862
1927
|
const pluginUtilities = {
|
|
1863
1928
|
getIsNewCustomerFlag: () => getIsNewCustomerFlag(processGetData.bind(null, destination)),
|
|
1864
1929
|
};
|
|
1930
|
+
let rootSkippedInstances = new Set();
|
|
1865
1931
|
if (plugins.length > 0) {
|
|
1866
|
-
const rootResult = await
|
|
1932
|
+
const rootResult = await runRootPluginHooks(plugins, {
|
|
1867
1933
|
payload: { eventName: currentEventName, data, eventId },
|
|
1868
1934
|
context: pluginContext,
|
|
1869
1935
|
providers,
|
|
1870
1936
|
settings: pluginSettings,
|
|
1871
1937
|
utilities: pluginUtilities,
|
|
1872
|
-
});
|
|
1873
|
-
if (rootResult.skip) {
|
|
1874
|
-
sendTag(destination, {
|
|
1875
|
-
configuratorProcessed: true,
|
|
1876
|
-
eventName: currentEventName,
|
|
1877
|
-
eventId,
|
|
1878
|
-
data,
|
|
1879
|
-
providerData: {},
|
|
1880
|
-
providers,
|
|
1881
|
-
options,
|
|
1882
|
-
});
|
|
1883
|
-
return;
|
|
1884
|
-
}
|
|
1938
|
+
}, pluginScopes, configuredTags, pluginSource);
|
|
1885
1939
|
if (rootResult.providers !== undefined) {
|
|
1886
1940
|
// eslint-disable-next-line no-param-reassign
|
|
1887
1941
|
providers = rootResult.providers;
|
|
@@ -1889,6 +1943,7 @@
|
|
|
1889
1943
|
currentEventName = rootResult.eventName;
|
|
1890
1944
|
// eslint-disable-next-line no-param-reassign
|
|
1891
1945
|
data = rootResult.data;
|
|
1946
|
+
rootSkippedInstances = rootResult.skippedInstances;
|
|
1892
1947
|
}
|
|
1893
1948
|
if (!rulesResult.skipBrowserEvent) {
|
|
1894
1949
|
const currencySettings = getSetting(destination, 'currency');
|
|
@@ -1900,69 +1955,96 @@
|
|
|
1900
1955
|
logger.log(`Provider ${pkg.name} is not in allow list`);
|
|
1901
1956
|
continue;
|
|
1902
1957
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
providerId: pkg.name,
|
|
1915
|
-
utilities: pluginUtilities,
|
|
1958
|
+
const providerId = pkg.name;
|
|
1959
|
+
const variables = getProviderVariables(destination, pkg.name);
|
|
1960
|
+
// Per-instance state, mirroring the edge PluginData array: each instance
|
|
1961
|
+
// carries its own payload and skip marker (seeded from the root skip
|
|
1962
|
+
// scope). A skip never short-circuits the hooks — only the final tag.
|
|
1963
|
+
const instanceStates = new Map();
|
|
1964
|
+
for (const variable of variables) {
|
|
1965
|
+
instanceStates.set(variable.tagName, {
|
|
1966
|
+
eventName: currentEventName,
|
|
1967
|
+
data,
|
|
1968
|
+
skipped: rootSkippedInstances.has(`${providerId}||${variable.tagName}`),
|
|
1916
1969
|
});
|
|
1917
|
-
if (channelResult.skip)
|
|
1918
|
-
continue;
|
|
1919
|
-
providerEventName = channelResult.eventName;
|
|
1920
|
-
channelData = channelResult.data;
|
|
1921
1970
|
}
|
|
1922
|
-
|
|
1971
|
+
// Channel phase (processPluginsChannel): tagChannel runs once per
|
|
1972
|
+
// instance, regardless of skip/consent/geo, so its side effects and
|
|
1973
|
+
// additional events still fire on skipped instances.
|
|
1974
|
+
const channelPlugins = plugins.filter((plugin) => plugin.name !== pluginSource &&
|
|
1975
|
+
isPluginAllowed(pluginScopes === null || pluginScopes === void 0 ? void 0 : pluginScopes[plugin.name], providerId, null));
|
|
1976
|
+
if (channelPlugins.length > 0) {
|
|
1977
|
+
for (const variable of variables) {
|
|
1978
|
+
const state = instanceStates.get(variable.tagName);
|
|
1979
|
+
const channelResult = await runPluginHook(channelPlugins, 'tagChannel', pluginScopes, {
|
|
1980
|
+
payload: {
|
|
1981
|
+
eventName: state.eventName,
|
|
1982
|
+
data: state.data,
|
|
1983
|
+
eventId,
|
|
1984
|
+
},
|
|
1985
|
+
context: pluginContext,
|
|
1986
|
+
settings: pluginSettings,
|
|
1987
|
+
providerId,
|
|
1988
|
+
utilities: pluginUtilities,
|
|
1989
|
+
});
|
|
1990
|
+
if (channelResult.skip) {
|
|
1991
|
+
state.skipped = true;
|
|
1992
|
+
}
|
|
1993
|
+
state.eventName = channelResult.eventName;
|
|
1994
|
+
state.data = channelResult.data;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
// Instance phase (processPluginsInstance + tag send): consent/geo gate,
|
|
1998
|
+
// run tagInstance, then suppress only the final tag when skipped.
|
|
1923
1999
|
const result = {};
|
|
1924
2000
|
const executionContext = new Map();
|
|
1925
2001
|
for (const variable of variables) {
|
|
1926
|
-
|
|
1927
|
-
|
|
2002
|
+
const state = instanceStates.get(variable.tagName);
|
|
2003
|
+
if (!isProviderInstanceAllowed(providers, providerId, variable.tagName)) {
|
|
2004
|
+
logger.log(`Provider instance is not allowed (${providerId}: ${variable.tagName})`);
|
|
1928
2005
|
continue;
|
|
1929
2006
|
}
|
|
1930
|
-
if (!hasUserConsent(userConsent,
|
|
1931
|
-
logger.log(`Consent is missing (${
|
|
2007
|
+
if (!hasUserConsent(userConsent, providerId, variable.tagName)) {
|
|
2008
|
+
logger.log(`Consent is missing (${providerId}: ${variable.tagName})`);
|
|
1932
2009
|
continue;
|
|
1933
2010
|
}
|
|
1934
2011
|
if (!doesGeoRequestMatchList(requestCountry, requestRegion, isEURequest, variable.geoRegions)) {
|
|
1935
2012
|
logger.log('GEO request region does not match the filter, skipping');
|
|
1936
2013
|
continue;
|
|
1937
2014
|
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
if (
|
|
1941
|
-
const instanceResult = await runPluginHook(
|
|
2015
|
+
const instancePlugins = plugins.filter((plugin) => plugin.name !== pluginSource &&
|
|
2016
|
+
isPluginAllowed(pluginScopes === null || pluginScopes === void 0 ? void 0 : pluginScopes[plugin.name], providerId, variable.tagName));
|
|
2017
|
+
if (instancePlugins.length > 0) {
|
|
2018
|
+
const instanceResult = await runPluginHook(instancePlugins, 'tagInstance', pluginScopes, {
|
|
1942
2019
|
payload: {
|
|
1943
|
-
eventName:
|
|
1944
|
-
data:
|
|
2020
|
+
eventName: state.eventName,
|
|
2021
|
+
data: state.data,
|
|
1945
2022
|
eventId,
|
|
1946
2023
|
},
|
|
1947
2024
|
context: pluginContext,
|
|
1948
2025
|
settings: pluginSettings,
|
|
1949
|
-
providerId
|
|
2026
|
+
providerId,
|
|
1950
2027
|
utilities: pluginUtilities,
|
|
1951
2028
|
});
|
|
1952
|
-
if (instanceResult.skip)
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2029
|
+
if (instanceResult.skip) {
|
|
2030
|
+
state.skipped = true;
|
|
2031
|
+
}
|
|
2032
|
+
state.eventName = instanceResult.eventName;
|
|
2033
|
+
state.data = instanceResult.data;
|
|
2034
|
+
}
|
|
2035
|
+
if (state.skipped) {
|
|
2036
|
+
logger.log(`Skipping event due to plugin condition (${providerId}: ${variable.tagName})`);
|
|
2037
|
+
continue;
|
|
1956
2038
|
}
|
|
1957
|
-
const conversion = preparePayloadWithConversion(jsonClone(
|
|
2039
|
+
const conversion = preparePayloadWithConversion(jsonClone(state.data), currencySettings);
|
|
1958
2040
|
const payload = ((_a = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _a === void 0 ? void 0 : _a.length) === 0 ||
|
|
1959
|
-
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(
|
|
2041
|
+
((_b = conversion === null || conversion === void 0 ? void 0 : conversion.providers) === null || _b === void 0 ? void 0 : _b.includes(providerId))
|
|
1960
2042
|
? conversion.payload
|
|
1961
|
-
:
|
|
2043
|
+
: state.data;
|
|
1962
2044
|
result[variable.tagName] = pkg.tag({
|
|
1963
2045
|
userId,
|
|
1964
2046
|
sessionId,
|
|
1965
|
-
eventName:
|
|
2047
|
+
eventName: state.eventName,
|
|
1966
2048
|
eventId,
|
|
1967
2049
|
data: jsonClone(payload),
|
|
1968
2050
|
sendTag: sendTag.bind(null, destination),
|
|
@@ -1977,16 +2059,17 @@
|
|
|
1977
2059
|
pageUrl: getPageUrl(destination),
|
|
1978
2060
|
});
|
|
1979
2061
|
}
|
|
1980
|
-
|
|
2062
|
+
if (Object.keys(result).length > 0) {
|
|
2063
|
+
providerData[providerId] = result;
|
|
2064
|
+
}
|
|
1981
2065
|
}
|
|
1982
2066
|
}
|
|
1983
2067
|
else {
|
|
1984
2068
|
logger.log('Browser events skipped by event rules, sending tag to server only');
|
|
1985
2069
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
}
|
|
2070
|
+
// The server event is always forwarded to EdgeTag regardless of consent or
|
|
2071
|
+
// provider config; the CDN re-runs this logic server-side. Browser tags are
|
|
2072
|
+
// still individually gated by consent/geo/provider above.
|
|
1990
2073
|
sendTag(destination, {
|
|
1991
2074
|
configuratorProcessed: true,
|
|
1992
2075
|
eventName: currentEventName,
|
|
@@ -2005,26 +2088,15 @@
|
|
|
2005
2088
|
handleTag(additionalEventName, jsonClone(originalData || {}), originalProviders, options);
|
|
2006
2089
|
}
|
|
2007
2090
|
};
|
|
2008
|
-
const handleTag = (eventName, data = {}, providers, options) => {
|
|
2091
|
+
const handleTag = (eventName, data = {}, providers, options, pluginSource) => {
|
|
2009
2092
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
|
2010
|
-
processTag(options.destination, eventName, data, providers, options).catch(logger.error);
|
|
2093
|
+
processTag(options.destination, eventName, data, providers, options, pluginSource).catch(logger.error);
|
|
2011
2094
|
return;
|
|
2012
2095
|
}
|
|
2013
2096
|
getInstances().forEach((instance) => {
|
|
2014
|
-
processTag(instance, eventName, data, providers, options).catch(logger.error);
|
|
2097
|
+
processTag(instance, eventName, data, providers, options, pluginSource).catch(logger.error);
|
|
2015
2098
|
});
|
|
2016
2099
|
};
|
|
2017
|
-
const hasAllowedManifestTags = (tags, consent, providersConfig) => {
|
|
2018
|
-
for (const [pkg, tagNames] of tags) {
|
|
2019
|
-
for (const tagName of tagNames) {
|
|
2020
|
-
if (hasUserConsent(consent, pkg, tagName) &&
|
|
2021
|
-
isProviderInstanceAllowed(providersConfig, pkg, tagName)) {
|
|
2022
|
-
return true;
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
}
|
|
2026
|
-
return false;
|
|
2027
|
-
};
|
|
2028
2100
|
|
|
2029
2101
|
const processData = (destination, data, providers, options) => {
|
|
2030
2102
|
saveKV(destination, data);
|
|
@@ -2564,6 +2636,7 @@
|
|
|
2564
2636
|
configuratorSetting: result.configuratorSetting,
|
|
2565
2637
|
userProperties: result.userProperties,
|
|
2566
2638
|
ip: result.ip,
|
|
2639
|
+
pluginScopes: result.pluginScopes,
|
|
2567
2640
|
});
|
|
2568
2641
|
if (result.storageId != null) {
|
|
2569
2642
|
savePerKey(preferences.edgeURL, 'local', tagStorage, result.storageId, storageIdKey);
|