diff --git a/src/index.js b/src/index.js index eb912e5..3a9a027 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,7 @@ -const callInWindow = require("callInWindow"); -const injectScript = require("injectScript"); const setDefaultConsentState = require("setDefaultConsentState"); const updateConsentState = require("updateConsentState"); -const createQueue = require("createQueue"); - -const dataLayerPush = createQueue("dataLayer"); - +const callInWindow = require("callInWindow"); +const injectScript = require("injectScript"); /* * Because we can't rely on Fides.js to be initialized or even loaded before the GTM container, we use * the GTM events to update the consent state. If Fides.js runs before this, it will push the events to @@ -62,9 +58,6 @@ const CONSENT_MAP = { security_storage: ["essential"], }; -const isFidesEvent = data.event.indexOf("Fides") > -1; -const isFidesConsentModeEvent = data.event.indexOf("FidesConsentMode") > -1; -const isNonConsentModeFidesEvent = isFidesEvent && !isFidesConsentModeEvent; if (data.event === "gtm.init_consent") { // The default Consent Initialization trigger fired @@ -102,9 +95,9 @@ if (data.event === "gtm.init_consent") { data.gtmOnSuccess(); }, data.gtmOnFailure - ); - } -} else if (isNonConsentModeFidesEvent) { + ); + } +} else if (data.event.indexOf("Fides") > -1) { // This update only has an effect when Fides.consent contains privacy notice keys updateGTMConsent(data.fides.consent, data.event); } @@ -119,8 +112,6 @@ return data.gtmOnSuccess(); function updateGTMConsent(fidesConsent, event) { const gtmConsent = {}; - const fidesConsentModeEvent = "FidesConsentMode" + event.split("Fides")[1]; - for (const key in CONSENT_MAP) { const values = []; for (const value of CONSENT_MAP[key]) { @@ -134,10 +125,4 @@ function updateGTMConsent(fidesConsent, event) { updateConsentState(gtmConsent); - // Push an event to the dataLayer that represents the updated consent mode state - // This event will contain the latest consent update state and can be used as a trigger event - dataLayerPush({ - Fides: data.fides.consent, - event: fidesConsentModeEvent, - }); -} +} \ No newline at end of file diff --git a/template.tpl b/template.tpl index 18d65d3..36b3ee3 100644 --- a/template.tpl +++ b/template.tpl @@ -562,14 +562,10 @@ ___WEB_PERMISSIONS___ ___SANDBOXED_JS_FOR_WEB_TEMPLATE___ -const callInWindow = require("callInWindow"); -const injectScript = require("injectScript"); const setDefaultConsentState = require("setDefaultConsentState"); const updateConsentState = require("updateConsentState"); -const createQueue = require("createQueue"); - -const dataLayerPush = createQueue("dataLayer"); - +const callInWindow = require("callInWindow"); +const injectScript = require("injectScript"); /* * Because we can't rely on Fides.js to be initialized or even loaded before the GTM container, we use * the GTM events to update the consent state. If Fides.js runs before this, it will push the events to @@ -626,9 +622,6 @@ const CONSENT_MAP = { security_storage: ["essential"], }; -const isFidesEvent = data.event.indexOf("Fides") > -1; -const isFidesConsentModeEvent = data.event.indexOf("FidesConsentMode") > -1; -const isNonConsentModeFidesEvent = isFidesEvent && !isFidesConsentModeEvent; if (data.event === "gtm.init_consent") { // The default Consent Initialization trigger fired @@ -666,9 +659,9 @@ if (data.event === "gtm.init_consent") { data.gtmOnSuccess(); }, data.gtmOnFailure - ); - } -} else if (isNonConsentModeFidesEvent) { + ); + } +} else if (data.event.indexOf("Fides") > -1) { // This update only has an effect when Fides.consent contains privacy notice keys updateGTMConsent(data.fides.consent, data.event); } @@ -683,8 +676,6 @@ return data.gtmOnSuccess(); function updateGTMConsent(fidesConsent, event) { const gtmConsent = {}; - const fidesConsentModeEvent = "FidesConsentMode" + event.split("Fides")[1]; - for (const key in CONSENT_MAP) { const values = []; for (const value of CONSENT_MAP[key]) { @@ -698,12 +689,6 @@ function updateGTMConsent(fidesConsent, event) { updateConsentState(gtmConsent); - // Push an event to the dataLayer that represents the updated consent mode state - // This event will contain the latest consent update state and can be used as a trigger event - dataLayerPush({ - Fides: data.fides.consent, - event: fidesConsentModeEvent, - }); } ___TESTS___