{"version":3,"sources":["webpack:///./cartridges/app_accelerator_core/cartridge/client/default/js/modules/module.tracking-layer.js"],"names":["DATA_LAYER","DEBUG_MODE","ENTER_VIEWPORT_GROUP","TrackingLayer","options","arguments","length","undefined","_classCallCheck","callbackOnElements","call","setPosition","elements","setElement","_createClass","key","value","el","index","setAttribute","getAttribute","JSON","parse","trackingLayer","Array","isArray","forEach","setHandler","bind","e","handler","eventTracking","eventList","events","nodeName","trim","split","currentEvent","window","addEventListener","setTimeout","document","activeElement","HTMLIFrameElement","delegate","matches","scrollMonitor","create","one","enterViewportGroup","getInViewportItems","body","evt","target","removeAttribute","groupID","clearTimeout","enterViewportTimeout","push","childrenNodeList","getPropertyValue","propertyReference","matchingContext","closest","indexOf","contextType","replace","concat","childrenDataArray","querySelectorAll","currentEl","querySelector","hasAttribute","promoName","promoPosition","pid","pos","textContent","selectedOptions","SFRA","Resources","getTrackObject","sourceObject","trackObject","_typeof","hrefURL","hrefTarget","retrieveAsyncData","asyncParams","asyncURL","manualRedirect","metaKey","preventDefault","Urls","GTMEventView","trackEvent","promotions","filter","promo","update","updateData","pushData","trackMethod","then","open","location","getAsyncObject","currentIndex","setAsyncURLParams","Promise","resolve","$","get","response","objectAssign","triggerEvent","publishEvent","url","pageData","getPageActionData","appendParamsToURL","eventType","event","reqPath","action","qString","queryString","search","substring","eventParams","stringify","targetObject","console","log","trackMethodName","Deferred","promise","runTrackingMethod","safeTrackMethod","slice","apply","error","hasOwnProperty","dataLayers","currentLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAA0C;AACA;AAC2B;AACX;AACiB;AAE3E,IACIA,UAAU,GAAG,WAAW;EACxBC,UAAU,GAAG,KAAK;EAClBC,oBAAoB,GAAG,CAAC,CAAC;;AAE7B;AACA;AACA;AAFA,IAIqBC,aAAa;EAC9B,SAAAA,cAAA,EAA0B;IAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAA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AE0C,YAAY,CAAC;UAC5D,CAAC,CAAC;QACN,CAAC,MAAM;UACH7I,aAAa,CAACuI,eAAe,CAACpC,WAAW,EAAEnB,WAAW,CAAC;QAC3D;MACJ,CAAC,MAAM;QACHhF,aAAa,CAACuI,eAAe,CAACpC,WAAW,EAAEP,UAAU,EAAEZ,WAAW,CAAC;MACvE;MAEA,IAAIlF,UAAU,EAAE;QACZmI,OAAO,CAACC,GAAG,CAAClD,WAAW,CAAC;MAC5B;MAEA,OAAO4B,CAAC,CAACwB,QAAQ,CAAC,CAAC,CAACzB,OAAO,CAAC3B,WAAW,CAAC,CAACqD,OAAO,CAAC,CAAC;IACtD;EAAC;AAAA","file":"module-tracking-layer.js","sourcesContent":["import Promise from 'es6-promise-promise';\nimport scrollMonitor from 'scrollmonitor';\nimport {publishEvent, getPageActionData} from '../helpers/utilities';\nimport {appendParamsToURL} from '../helpers/urlUtilities';\nimport {callbackOnElements, objectAssign} from '@borngroup/born-utilities';\n\nconst\n DATA_LAYER = 'dataLayer',\n DEBUG_MODE = false,\n ENTER_VIEWPORT_GROUP = {};\n\n/**\n * Sets up event tracking on specific element. Uses the 'data-tracking' attribute to determine what to track.\n */\n\nexport default class TrackingLayer {\n constructor(options = {}) {\n callbackOnElements.call(this, '[data-tracking-position]', this.setPosition);\n callbackOnElements.call(this, options.elements, this.setElement);\n }\n\n setPosition(el, index) {\n el.setAttribute('data-tracking-position', index + 1);\n }\n\n /**\n * Sets up individual elements that have the data-tracking property\n * @param {[type]} el [description]\n */\n setElement(el) {\n //If a 'data-tracking' is present, then those properties will be used instead.\n try {\n let options = el.getAttribute('data-tracking') ? JSON.parse(el.getAttribute('data-tracking')) : {};\n el.trackingLayer = {};\n\n if (Array.isArray(options)) {\n options.forEach(this.setHandler.bind(this, el));\n } else {\n this.setHandler(el, options);\n }\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Adds a tracking handler to the passed element\n * @param {[Object]} options:\n * el: [Node]\n * events: [String] Event to listen to.\n * trackEvent: [String] Name of the data layer object on which this event will be tracked.\n * trackObject: [Object] Key value pairs to be reported back to the tracking layer.\n * trackHandler: [String] Optional. Handler for the event.\n */\n setHandler(el, options) {\n let handler = this.eventTracking,\n eventList = options.events;\n\n if (!eventList) {\n if (el.nodeName === 'INPUT' || el.nodeName === 'SELECT' || el.nodeName === 'TEXTAREA') {\n eventList = 'change';\n } else {\n eventList = 'click';\n }\n }\n\n eventList = eventList.trim().split(/(?:,| )+/);\n\n //Attach a listener for each passed event.\n eventList.forEach(function(currentEvent) {\n if (currentEvent === 'pageload') {\n //If `DATA_LAYER` is available, run immediately, otherwise wait until resources are loaded.\n if (window[DATA_LAYER]) {\n handler.call(this, el, options);\n } else {\n window.addEventListener('load', handler.bind(this, el, options));\n }\n\n } else if (currentEvent === 'iframeclick') {\n //Very hacky way to track a click on an iframe.\n //Checks if when on window blur the target is an iframe that matches either the tracked element or the delegated element.\n window.addEventListener('blur', function() {\n //Forces browsers to run this immediately instead of deferring it.\n window.setTimeout(function() {\n if (document.activeElement instanceof HTMLIFrameElement && (document.activeElement === el || (options.delegate && document.activeElement.matches(options.delegate))) ) {\n handler.call(this, el, options);\n }\n }.bind(this), 0);\n }.bind(this));\n } else if (currentEvent === 'enterViewport') {\n scrollMonitor.create(el, -200).one(currentEvent, function() {\n if (options.enterViewportGroup) {\n this.getInViewportItems(el, options, options.enterViewportGroup);\n } else {\n handler.call(this, el, options);\n }\n }.bind(this));\n } else {\n //Run delegated event from the body to allow for DOM insertions to also work.\n if (options.delegate) {\n document.body.addEventListener(currentEvent, function(evt) {\n if (evt.target.matches(options.delegate)) {\n handler.call(this, evt.target, options);\n }\n }.bind(this));\n } else {\n el.addEventListener(currentEvent, handler.bind(this, el, options));\n }\n }\n }.bind(this));\n\n el.removeAttribute('data-tracking');\n }\n\n /**\n * Generates an array with related \"in viewport\" items that need to be pushed together whenever they enter the viewport.\n * A slight timeout is added to allow JS to collect however many items are now in view when the user stops scrolling.\n */\n getInViewportItems(el, options, groupID) {\n window.clearTimeout(this.enterViewportTimeout);\n\n ENTER_VIEWPORT_GROUP[groupID] = ENTER_VIEWPORT_GROUP[groupID] || [];\n\n ENTER_VIEWPORT_GROUP[groupID].push(el);\n\n this.enterViewportTimeout = window.setTimeout(function() {\n options.childrenNodeList = ENTER_VIEWPORT_GROUP[groupID];\n\n this.eventTracking(el, options);\n\n //Clear the current group after tracking data has been processed.\n ENTER_VIEWPORT_GROUP[groupID] = [];\n }.bind(this), 100);\n }\n\n /**\n * Determines what to push as the value for a given property name.\n * First checks for properties, attributes, and Resources then, if all fails, returns the string\n */\n getPropertyValue(el, propertyReference, options) {\n //Grab a specific context based on the closest element.\n if (propertyReference === '--context') {\n let matchingContext = el.closest('[data-tracking-context]');\n\n if (matchingContext) {\n return matchingContext.getAttribute('data-tracking-context');\n }\n } else if (propertyReference.indexOf('--context-') !== -1) {\n let contextType = propertyReference.replace('--context-', ''),\n matchingContext = el.closest(`[data-${contextType}]`);\n\n if (matchingContext) {\n return matchingContext.getAttribute(`data-${contextType}`);\n }\n } else if (propertyReference === '--childrenData') {\n let childrenDataArray = [],\n childrenNodeList = options.childrenNodeList || el.querySelectorAll('[data-tracking-id]');\n\n [].forEach.call(childrenNodeList, function(currentEl) {\n //Attempt to find a child element with the right attributes, otherwise default to the current element.\n currentEl = currentEl.querySelector('[data-content-component], [data-product-tile]') || currentEl;\n\n if (currentEl.hasAttribute('data-content-component')) {\n childrenDataArray.push({\n promoName: currentEl.getAttribute('data-tracking-id'),\n promoPosition: currentEl.getAttribute('data-tracking-position'),\n });\n } else if (currentEl.hasAttribute('data-product-tile')) {\n childrenDataArray.push({\n pid: currentEl.getAttribute('data-tracking-id'),\n pos: currentEl.getAttribute('data-tracking-position'),\n });\n }\n });\n\n if (childrenDataArray.length) {\n return childrenDataArray;\n }\n } else if (propertyReference === '--content') {\n return el.textContent.trim();\n } else if (propertyReference === '--dropdownDisplayValue') {\n return el.selectedOptions[0].textContent.trim();\n }\n\n return el[propertyReference] || el.getAttribute(propertyReference) || window.SFRA.Resources[propertyReference] || propertyReference;\n }\n\n /**\n * Loops through the properties defined in trackObject and gets their real values by calling getPropertyValue;\n * @param {[HTMLElement]} el [description]\n * @param {[Object]} trackObject [description]\n * @return {[Object]} [description]\n */\n getTrackObject(el, sourceObject, options) {\n let trackObject = {};\n\n if (typeof sourceObject === 'object') {\n for (let key in sourceObject) {\n trackObject[key] = this.getPropertyValue(el, sourceObject[key], options);\n }\n }\n\n return trackObject;\n }\n\n /**\n * Default tracking method. Just pushes back a report value to the Data Layer\n * @param {[String | Boolean]} options.trackObject [property, attribute, or string to report]\n * @param {[String]} options.trackProperty [Data Layer variable to report to]\n * @param {[String]} options.trackEvent [Name of the layer object to attach the variable to. ex: \"interactions\", \"event\", etc.]\n */\n eventTracking(el, options, evt) {\n //The \"data-disable-redirect\" attribute can be set on an anchor element.\n //This attribute goes along functionalities like modal triggers, which should not redirect the user.\n //Use `evt.target.getAttribute('href')` instead of `evt.target.href` to avoid incorrectly processing an SVG target.\n let hrefURL = evt && evt.target && evt.target.getAttribute('href') && !evt.target.hasAttribute('data-disable-redirect') ? evt.target.getAttribute('href') : null,\n hrefTarget = evt && evt.target && evt.target.getAttribute('target'),\n trackObject = this.getTrackObject(el, options.trackObject, options),\n retrieveAsyncData = options.asyncParams || options.asyncURL,\n manualRedirect = hrefURL && !evt.metaKey && retrieveAsyncData;\n\n //Stops anchor clicks within a given data-tracking container if it should retrireve server data.\n if (manualRedirect) {\n evt.preventDefault();\n }\n\n //Set the appropriate properties in the `trackObject`, which is later used to request server data.\n if (retrieveAsyncData) {\n trackObject.asyncURL = options.asyncURL || window.SFRA.Urls.GTMEventView;\n trackObject.asyncParams = this.getTrackObject(el, options.asyncParams, options);\n }\n\n if (trackObject && trackObject.asyncParams && options.trackEvent === 'eePromoView') {\n // check if the promo name is null\n let promotions = trackObject.asyncParams.promotions;\n if (promotions && Array.isArray(promotions) && promotions.length > 0) {\n promotions = promotions.filter(promo => {\n return promo.promoName !== 'null';\n })\n }\n\n if (!promotions || promotions.length === 0 || !Array.isArray(promotions)) {\n return null;\n }\n trackObject.asyncParams.promotions = promotions;\n }\n\n if (trackObject && trackObject.asyncParams && options.trackEvent === 'eePromoClick') {\n // check if the promo name is null\n let promoName = trackObject.asyncParams.promoName && trackObject.asyncParams.promoName !== 'null' && trackObject.asyncParams.promoName !== 'undefined' ? trackObject.asyncParams.promoName : null;\n if (!promoName) {\n return null;\n }\n }\n\n if (options.update) {\n TrackingLayer.updateData(options.update, trackObject);\n } else {\n TrackingLayer.pushData(options.trackEvent, trackObject, options.trackMethod).then(function() {\n //After server data has been retrieved, redirect the user to the target anchor's URL.\n if (manualRedirect) {\n if (hrefTarget === '_blank') {\n window.open(hrefURL, '_blank', 'noopener,noreferrer');\n } else {\n window.location = hrefURL;\n }\n }\n });\n }\n }\n\n /**\n * Loops through a list of URLs to load additional data for the data-layer.\n * @param {[type]} trackObject [description]\n * @param {[type]} index [description]\n * @return {[type]} [description]\n */\n static getAsyncObject(trackEvent, trackObject, index) {\n let currentIndex = index || 0,\n isArray = Array.isArray(trackObject.asyncURL),\n asyncURL = isArray ? trackObject.asyncURL[currentIndex] : trackObject.asyncURL;\n\n asyncURL = TrackingLayer.setAsyncURLParams(trackEvent, trackObject, asyncURL);\n\n return Promise.resolve($.get(asyncURL)).then(function(response) {\n objectAssign(response, trackObject);\n\n currentIndex++;\n\n if (isArray && trackObject.asyncURL[currentIndex]) {\n return TrackingLayer.getAsyncObject(trackEvent, response, currentIndex);\n } else {\n delete response.asyncURL;\n delete response.asyncParams;\n }\n\n return response;\n });\n }\n\n /**\n * Triggers tracking for `elements` with the \"action.done\" event.\n * @param {[HTMLElement]} el\n */\n static triggerEvent(elements) {\n callbackOnElements(elements, function(currentEl) {\n publishEvent('actiondone', false, currentEl);\n });\n }\n\n /**\n * Attaches necessary URL parameters for the backend to return the desired tracking data from the current event.\n */\n static setAsyncURLParams(trackEvent, trackObject, url) {\n let pageData = getPageActionData() || {};\n\n return appendParamsToURL(\n url,\n {\n eventType: trackObject.event || trackEvent,\n reqPath: (trackObject.reqPath || pageData.action),\n qString: (trackObject.qString || pageData.queryString || window.location.search.substring(1)),\n eventParams: trackObject.asyncParams ? JSON.stringify(trackObject.asyncParams) : ''\n }\n );\n }\n\n static updateData(targetObject, trackObject, trackMethod) {\n if (window[DATA_LAYER] && window[targetObject]) {\n objectAssign(window[targetObject], trackObject);\n\n trackMethod = trackMethod && window[DATA_LAYER][trackMethod] ? trackMethod : 'view';\n\n if (window[DATA_LAYER][trackMethod]) {\n window[DATA_LAYER][trackMethod](window[targetObject]);\n }\n\n if (DEBUG_MODE) {\n console.log(trackObject);\n }\n }\n }\n\n static pushData(trackEvent, trackObject, trackMethodName = 'push') {\n if (!window[DATA_LAYER] || !trackEvent) {\n return $.Deferred().resolve({}).promise();\n }\n\n if (typeof trackObject === 'object' && (trackObject.asyncURL || trackObject.asyncParams)) {\n trackObject.asyncURL = trackObject.asyncURL || window.SFRA.Urls.GTMEventView;\n\n return TrackingLayer.getAsyncObject(trackEvent, trackObject).then(function(response) {\n return TrackingLayer.runTrackingMethod(trackEvent, response, trackMethodName);\n });\n }\n\n return TrackingLayer.runTrackingMethod(trackEvent, trackObject, trackMethodName);\n }\n\n /**\n * Provide a safe fallback in case user has AdBlockers enabled.\n * This is necessary since some of the events require collecting data before redirecting the user, and the redirection happens in the JS.\n * @return {[type]} [description]\n */\n static safeTrackMethod(trackMethod) {\n let options = [].slice.call(arguments, 1);\n\n try {\n trackMethod.apply(this, options);\n } catch (e) {\n console.error(e);\n }\n }\n\n static runTrackingMethod(trackEvent, trackObject, trackMethodName = 'push') {\n let trackMethod = window[DATA_LAYER][trackMethodName] || window[DATA_LAYER];\n\n if (typeof trackObject === 'object') {\n trackObject.event = trackObject.hasOwnProperty('trackEvent') ? trackObject['trackEvent'] : trackEvent;\n\n if (trackObject.dataLayers && trackObject.dataLayers.length) {\n trackObject.dataLayers.forEach(function(currentLayer) {\n TrackingLayer.safeTrackMethod(trackMethod, currentLayer);\n });\n } else {\n TrackingLayer.safeTrackMethod(trackMethod, trackObject);\n }\n } else {\n TrackingLayer.safeTrackMethod(trackMethod, trackEvent, trackObject);\n }\n\n if (DEBUG_MODE) {\n console.log(trackObject);\n }\n\n return $.Deferred().resolve(trackObject).promise();\n }\n}\n"],"sourceRoot":""}