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GAAKD,OAAOC,IAAM,CAAC,EAC1BD,OAAOC,GAAG8C,UArCQ,SAASC,GACzB,GAAKF,SAA0C,IAAZE,GAA4BA,GAA/D,CAKA,IAAIC,EAAY,CACdhC,MAAO,WACPiC,KAAMF,GAGRhD,OAAOe,UAAUI,KAAK8B,EAPtB,CAQF,EA0BAjD,OAAOC,GAAGkD,gBAzDc,SAAS/C,EAAMgD,EAAMtD,GAC3C,IAAKgD,EAGH,YAFA1B,QAAQC,KAAK,oCAKf,MAAM4B,EAAY,CAChBhC,MAAO,cACPqB,KAAM,CACJlC,KAAMA,EAAKiD,OACXnB,YAAqCkB,EAAKvD,cAC1CC,KAAMA,EAAOA,EAAKD,cAAgB,KAItCG,OAAOe,UAAUI,KAAK8B,EACxB,EAyCAjD,OAAOC,GAAGC,QAzBM,SAASK,EAAQD,EAASE,GACxC,GAAKsC,EAAL,CAMA,IAAIQ,EAAY,CACd,MAAS,UACT,YAAe,CACb,OAAU/C,EACV,SAAYD,EACZ,MAASE,IAIbR,OAAOe,UAAUI,KAAKmC,EAXtB,MAHElC,QAAQC,KAAK,mCAejB,CAQ2B,C","sources":["webpack://frontend-build-tools/./src/feature/hero/hero.js","webpack://frontend-build-tools/./src/foundation/tracking/tracking.js"],"sourcesContent":["import BaseFeature from 'foundation/base/base';\r\nimport { pushHeroTrackingEvent } from 'foundation/tracking/tracking';\r\n\r\nclass Hero extends BaseFeature {\r\n constructor(element) {\r\n super(element);\r\n this.element = element;\r\n this.init();\r\n }\r\n\r\n init() {\r\n let heroName;\r\n const text = this.element?.querySelector('.o-hero__text');\r\n if (text) {\r\n heroName = JSON.parse(text.getAttribute('data-settings'))?.trackingHeader;\r\n }\r\n const heroHasLink = this.element.querySelector('.js-hero-link');\r\n\r\n if (heroName) {\r\n pushHeroTrackingEvent('promoView', heroName);\r\n }\r\n\r\n if (heroHasLink && heroName) {\r\n heroHasLink.addEventListener('click', () => {\r\n pushHeroTrackingEvent('promoClick', heroName);\r\n });\r\n }\r\n }\r\n}\r\n\r\nexport default Hero;","export const onError = (errors, e) => {\r\n const concatErrors = Object.keys(errors).map((key) => {\r\n const error = errors[key];\r\n return `${key.toLowerCase()}_${error.type}`;\r\n }).join(',');\r\n\r\n if (typeof window.TC?.gaEvent === 'function') {\r\n window.TC?.gaEvent(e.target.name, 'error', concatErrors);\r\n }\r\n};\r\n\r\nexport const pushGaEvent = (category, action, label, value = '') => {\r\n const dataLayerAvailable = Array.isArray(window.dataLayer);\r\n\r\n if (!dataLayerAvailable) {\r\n console.warn('Tracking DataLayer not available');\r\n return;\r\n }\r\n\r\n var tracking = {\r\n event: 'gaEvent',\r\n eventSyntax: {\r\n action: action,\r\n category: category,\r\n value: value,\r\n label: label\r\n }\r\n };\r\n\r\n window.dataLayer.push(tracking);\r\n};\r\n\r\n// format string from e.g. 'Populære spil' to 'populaere_spil'\r\nexport var formatString = (str) => {\r\n str = str.replace(/\\s+/g, '_').toLowerCase();\r\n str = str.replace(/æ/g, 'ae');\r\n str = str.replace(/ø/g, 'oe');\r\n str = str.replace(/å/g, 'aa');\r\n return str;\r\n};\r\n\r\nexport const pushGaEventOnPageRedirect = (category, action, label) => {\r\n localStorage.setItem('localStorageGaEventTracking', JSON.stringify({\r\n category: category,\r\n action: action,\r\n label: label,\r\n }));\r\n};\r\n\r\nexport const getGaEventAfterPageRedirect = () => {\r\n var ls = localStorage.getItem('localStorageGaEventTracking');\r\n if (ls) {\r\n ls = JSON.parse(ls);\r\n if (ls.category !== null\r\n && ls.action !== null\r\n && ls.label !== null) {\r\n pushGaEvent(ls.category, ls.action, ls.label);\r\n }\r\n localStorage.removeItem('localStorageGaEventTracking');\r\n }\r\n};\r\n\r\nexport const pushGaEventVirtualPage = (name, virtualPath) => {\r\n const dataLayerAvailable = Array.isArray(window.dataLayer);\r\n\r\n if (!dataLayerAvailable) {\r\n console.warn('Tracking DataLayer not available');\r\n return;\r\n }\r\n\r\n var tracking = {\r\n event: 'virtualPage',\r\n page: {\r\n name: name,\r\n virtualPath: virtualPath\r\n }\r\n };\r\n\r\n window.dataLayer.push(tracking);\r\n};\r\n\r\nexport const pushGaEventVirtualPageOnPageRedirect = (name, virtualPath) => {\r\n let vp = '/virtualpath/' + virtualPath;\r\n localStorage.setItem('localStorageGaEventVirtualPageTracking', JSON.stringify({\r\n name: name,\r\n virtualPath: vp\r\n }));\r\n};\r\n\r\nexport const getGaEventVirtualPageAfterPageRedirect = () => {\r\n var ls = localStorage.getItem('localStorageGaEventVirtualPageTracking');\r\n if (ls) {\r\n ls = JSON.parse(ls);\r\n if (ls.name !== null\r\n && ls.virtualPath !== null) {\r\n pushGaEventVirtualPage(ls.name, ls.virtualPath);\r\n }\r\n localStorage.removeItem('localStorageGaEventVirtualPageTracking');\r\n }\r\n};\r\n\r\nexport const pushHeroTrackingEvent = (eventType, bannerName) => {\r\n const dataLayerAvailable = Array.isArray(window.dataLayer);\r\n\r\n if (!dataLayerAvailable) {\r\n console.warn('Tracking DataLayer not available');\r\n return;\r\n }\r\n\r\n var tracking = {\r\n event: eventType,\r\n ecommerce: {\r\n [eventType]: {\r\n promotions: [{\r\n name: 'tivo',\r\n position: 'hero_banner',\r\n creative: bannerName\r\n }]\r\n }\r\n }\r\n };\r\n\r\n window.dataLayer.push(tracking);\r\n};\r\n\r\nexport const initTracking = () => {\r\n const dataLayerAvailable = Array.isArray(window.dataLayer);\r\n\r\n const pushVirtualPage = function(name, path, type) {\r\n if (!dataLayerAvailable) {\r\n console.warn('Tracking DataLayer not available');\r\n // No reason to do any furhter if dataLayer is not available or method is called without an object\r\n return;\r\n }\r\n\r\n const pushEvent = {\r\n event: 'virtualPage',\r\n page: {\r\n name: name.trim(),\r\n virtualPath: '/virtualPath' + path ? path.toLowerCase() : '',\r\n type: type ? type.toLowerCase() : ''\r\n }\r\n };\r\n\r\n window.dataLayer.push(pushEvent);\r\n };\r\n\r\n const userEvent = function(userObj) {\r\n if (!dataLayerAvailable || (typeof userObj === 'undefined' && !userObj)) {\r\n // No reason to do any furhter if dataLayer is not available or method is called without an object\r\n return;\r\n }\r\n\r\n var pushEvent = {\r\n event: 'umPushed',\r\n user: userObj\r\n };\r\n\r\n window.dataLayer.push(pushEvent);\r\n };\r\n\r\n const gaEvent = function(action, category,label) {\r\n if (!dataLayerAvailable) {\r\n console.warn('Tracking DataLayer not available');\r\n // No reason to do any furhter if dataLayer is not available or method is called without an object\r\n return;\r\n }\r\n\r\n var trackData = {\r\n 'event': 'gaEvent',\r\n 'eventSyntax': {\r\n 'action': action,\r\n 'category': category,\r\n 'label': label\r\n }\r\n };\r\n\r\n window.dataLayer.push(trackData);\r\n };\r\n\r\n // Global bindings here\r\n\r\n // Make available on window (namespaced to not conflict with other scripts)\r\n window.TC = window.TC || {};\r\n window.TC.userEvent = userEvent;\r\n window.TC.pushVirtualPage = pushVirtualPage;\r\n window.TC.gaEvent = gaEvent;\r\n};"],"names":["Hero","BaseFeature","constructor","element","super","this","init","heroName","text","querySelector","JSON","parse","getAttribute","trackingHeader","heroHasLink","pushHeroTrackingEvent","addEventListener","onError","errors","e","concatErrors","Object","keys","map","key","error","toLowerCase","type","join","window","TC","gaEvent","target","name","pushGaEvent","category","action","label","value","arguments","length","undefined","Array","isArray","dataLayer","tracking","event","eventSyntax","push","console","warn","formatString","str","replace","pushGaEventOnPageRedirect","localStorage","setItem","stringify","getGaEventAfterPageRedirect","ls","getItem","removeItem","pushGaEventVirtualPageOnPageRedirect","virtualPath","vp","getGaEventVirtualPageAfterPageRedirect","pushGaEventVirtualPage","page","eventType","bannerName","ecommerce","promotions","position","creative","initTracking","dataLayerAvailable","userEvent","userObj","pushEvent","user","pushVirtualPage","path","trim","trackData"],"sourceRoot":""}