{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./app/frontend/lib/tracking/trackGtm.js","webpack:///./app/frontend/lib/railsFetch.js","webpack:///./.yarn/cache/object-to-formdata-npm-4.5.1-dfa68cf863-506b228bf4.zip/node_modules/object-to-formdata/src/index.js","webpack:///./app/frontend/lib/containsSubstring.js","webpack:///./app/frontend/lib/tracking/trackingEventQueue.js","webpack:///./app/frontend/packs/ua-tracking.js","webpack:///./app/frontend/lib/tracking/trackingEventProcessor.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","transformPayload","payload","detail","eventName","GtmTracker","constructor","_defineProperty","e","pathName","window","location","pathname","event","dataLayer","push","handleResponse","response","ok","status","json","headers","indexOf","then","errorJSON","railsFetchStatusCode","Promise","reject","railsFetchError","handleNetworkErrors","message","getAuthToken","_document$querySelect","document","querySelector","content","getAuthParam","_document$querySelect2","jsonContentType","middlewares","useMiddleware","middleware","async","railsFetch","url","method","data","contentType","authenticityToken","accept","options","credentials","isJson","containsSubstring","body","JSON","stringify","fetch","isUndefined","undefined","isObject","isArray","Array","isBlob","isReactNative","uri","size","type","slice","initCfg","serialize","obj","cfg","fd","pre","FormData","indices","nullsAsUndefineds","booleansAsIntegers","allowEmptyArrays","noAttributesWithArrayNotation","noFilesWithArrayNotation","dotsForObjectNotation","getParts","append","isBoolean","length","forEach","index","lastModifiedDate","lastModified","isFile","Date","isDate","keys","prop","lastIndexOf","substring","toISOString","string","toLowerCase","includes","trackingEventQueue","maxBatchSize","processQueue","queue","eventPayload","eventTime","toUTCString","clear","empty","trailheadTrackEventListener","trackerFns","requireTrackerFn","Error","add","attachEventListener","addEventListener","tracker","trackTrailheadEvent","trailheadEventProcessor","pageEvent","this","shouldSendBeacon","sendEvents","navigator","sendBeacon","visibilityState","gtmTracker","track"],"mappings":"aACE,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EAKH,EAGkC,CACnC,MAAMgH,EAA0B,ICxBlC,MACElH,aAAY,aAAEiG,EAJW,GAI2B,CAAC,GAAGhG,EAAA,qBAsBzC,EAAGkH,aAAc,CAAC,KAC1BA,EAEMC,KAAKC,iBAAiBF,IAC/BC,KAAKE,aAFLF,KAAKE,YAGP,IACDrH,EAAA,cASQC,IACPkH,KAAKjB,MAAM1F,KAAKP,EAAE,IArClBkH,KAAKjB,MAAQH,EAAmB,CAC9BE,aAAckB,KAAKlB,aACnBD,iBAEFmB,KAAKN,qBACP,CAEAA,sBACEnF,SAASoF,iBAAiB,oBAAoB,KAC5CK,KAAKlB,aAAa,CAAEiB,UAAW,kBAAmB,IAEpD/G,OAAO2G,iBAAiB,YAAY,KAClCK,KAAKlB,aAAa,CAAEiB,UAAW,YAAa,GAEhD,CAEAG,aACEC,UAAUC,WArBY,sBAqBkBJ,KAAKjB,MAAMvG,WACnDwH,KAAKjB,MAAMI,OACb,CAUAc,iBAAiBF,GACf,OAAkB,aAAdA,GAGgC,WAA7BxF,SAAS8F,mBAFNL,KAAKjB,MAAMK,OAGvB,GDXMkB,EAAa,IAAI3H,IAEvB0G,EADiB,CAACS,EAAwBS,MAAOD,EAAWC,QACtBd,KACxC,CAEeJ,W","file":"js/ua-tracking-d538f4e05afd2d4fa662.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/packs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 874);\n","/* eslint-disable no-undef */\nfunction pushToDataLayer(payload) {\n if (typeof window.dataLayer === 'undefined') {\n window.dataLayer = [];\n }\n window.dataLayer.push(payload);\n}\n\nexport function transformPayload(payload) {\n return {\n detail: {\n eventName: 'eventTracker',\n payload,\n },\n };\n}\n\nexport default class GtmTracker {\n track = (e) => {\n const pathName = window.location.pathname;\n\n pushToDataLayer({\n event: e.detail.eventName,\n payload: {\n ...e.detail.payload,\n pathName,\n },\n });\n };\n}\n","import containsSubstring from 'lib/containsSubstring';\n\n// Handle any non 2xx responses by halting the chain with a rejected promise with the parsed\n// JSON errors. In case the response isn't JSON, return a generic error code.\nfunction handleResponse(response) {\n if (response.ok) {\n // HTTP status codes from 200-299, return a promise that resolves\n // with the result of parsing the body text as JSON.\n\n // Return an empty value if the response is 204 No Content\n if (response.status === 204) {\n return;\n }\n\n return response.json();\n }\n\n // Return a promise that is rejected with JSON error messages:\n if (response.headers.get('Content-Type').indexOf('json') !== -1) {\n return response.json()\n .then((errorJSON) => {\n // When we recieve a timeout from Heroku it comes back as a HTTP status\n // code 503. We want to persist the code so we can note it downstream.\n if (typeof(errorJSON) === 'object') {\n errorJSON.railsFetchStatusCode = response.status; // eslint-disable-line no-param-reassign\n }\n return Promise.reject(errorJSON);\n }, () => Promise.reject({railsFetchStatusCode: response.status}));\n }\n\n // Things like a Rails 500 error that can't be parsed as JSON\n return Promise.reject({\n railsFetchError: `Application error code ${response.status}`\n });\n}\n\n// The fetch Web API will only consider failed fetches if there was a network-level error.\n// Ie. 404 and 500 aren't considered as failed fetch requests. Therefore we should handle\n// network-level errors gracefully.\nfunction handleNetworkErrors(response) {\n return Promise.reject({railsFetchError: response.message});\n}\n\nexport function getAuthToken() {\n return document.querySelector('meta[name=\"csrf-token\"]')?.content;\n}\n\nexport function getAuthParam() {\n return document.querySelector('meta[name=\"csrf-param\"]')?.content;\n}\n\n// Generic method to interact with the backend server.\n// Returns: Promise.\n// * If the request is successful (HTTP codes 200-299), the consumer code can work with the JSON\n// response via `.then((json) => { ... })`.\n// * If the request is unsuccessful, the consumer code handle API errors via\n// `.catch((apiError) => { ... })`.\n// * In case of a network-level error, or a non-json response, the consumer code can also catch\n// the promise, and expect an object with a `railsFetchError` key with the reason for the error\n// via `.catch((apiError) => { apiError.railsFetchError })`.\nexport const jsonContentType = 'application/json; charset=utf-8';\n\nlet middlewares = [];\n\nexport function resetMiddlewares() {\n middlewares.length = [];\n}\n\n// Because Webpack chunks use JSONP,\n// this module gets re-executed when imported by a chunk,\n// so we need to reference a global variable on the window :/\nif (typeof window !== 'undefined') {\n const key = '__railsFetchMiddlewares__';\n if (window[key]) {\n middlewares = window[key];\n } else {\n window[key] = middlewares;\n }\n}\n\n/**\n * @callback RailsFetch~middlewareHandler\n * @param {string} url\n * @param {RequestInit} options\n * @return {[string, RequestInit]}\n */\n/**\n * @param {RailsFetch~middlewareHandler} middleware\n * @example\n * async function someMiddleware(url, options) {\n * // validate your path\n * if (url.match(/foobar/)) {\n * return [url, {\n * ...options,\n * headers: {\n * ...options.headers,\n * 'Authorization': `Bearer ${await getToken()}`\n * }\n * }];\n * } else {\n * return [url, options]\n * }\n * }\n * useMiddleware(someMiddleware);\n */\nexport function useMiddleware(middleware) {\n middlewares.push(middleware);\n}\n\nexport default async function railsFetch({\n url,\n method = 'get',\n data,\n contentType = jsonContentType,\n authenticityToken = getAuthToken(),\n accept = 'application/json'\n}) {\n let options = {\n method,\n credentials: 'same-origin',\n headers: {\n 'Accept': accept,\n 'X-CSRF-Token': authenticityToken\n }\n };\n\n if (contentType) {\n options.headers['Content-Type'] = contentType;\n }\n\n if (data) {\n const isJson = contentType && containsSubstring('application/json', contentType);\n options.body = isJson ? JSON.stringify(data) : data;\n }\n\n for (const middleware of middlewares) {\n // eslint-disable-next-line no-param-reassign\n [url, options] = await middleware(url, options);\n }\n\n return fetch(url, options).then(handleResponse, handleNetworkErrors);\n}\n","function isUndefined(value) {\n return value === undefined;\n}\n\nfunction isNull(value) {\n return value === null;\n}\n\nfunction isBoolean(value) {\n return typeof value === 'boolean';\n}\n\nfunction isObject(value) {\n return value === Object(value);\n}\n\nfunction isArray(value) {\n return Array.isArray(value);\n}\n\nfunction isDate(value) {\n return value instanceof Date;\n}\n\nfunction isBlob(value, isReactNative) {\n return isReactNative\n ? isObject(value) && !isUndefined(value.uri)\n : isObject(value) &&\n typeof value.size === 'number' &&\n typeof value.type === 'string' &&\n typeof value.slice === 'function';\n}\n\nfunction isFile(value, isReactNative) {\n return (\n isBlob(value, isReactNative) &&\n typeof value.name === 'string' &&\n (isObject(value.lastModifiedDate) || typeof value.lastModified === 'number')\n );\n}\n\nfunction initCfg(value) {\n return isUndefined(value) ? false : value;\n}\n\nfunction serialize(obj, cfg, fd, pre) {\n cfg = cfg || {};\n fd = fd || new FormData();\n\n cfg.indices = initCfg(cfg.indices);\n cfg.nullsAsUndefineds = initCfg(cfg.nullsAsUndefineds);\n cfg.booleansAsIntegers = initCfg(cfg.booleansAsIntegers);\n cfg.allowEmptyArrays = initCfg(cfg.allowEmptyArrays);\n cfg.noAttributesWithArrayNotation = initCfg(\n cfg.noAttributesWithArrayNotation,\n );\n cfg.noFilesWithArrayNotation = initCfg(cfg.noFilesWithArrayNotation);\n cfg.dotsForObjectNotation = initCfg(cfg.dotsForObjectNotation);\n\n const isReactNative = typeof fd.getParts === 'function';\n\n if (isUndefined(obj)) {\n return fd;\n } else if (isNull(obj)) {\n if (!cfg.nullsAsUndefineds) {\n fd.append(pre, '');\n }\n } else if (isBoolean(obj)) {\n if (cfg.booleansAsIntegers) {\n fd.append(pre, obj ? 1 : 0);\n } else {\n fd.append(pre, obj);\n }\n } else if (isArray(obj)) {\n if (obj.length) {\n obj.forEach((value, index) => {\n let key = pre + '[' + (cfg.indices ? index : '') + ']';\n\n if (\n cfg.noAttributesWithArrayNotation ||\n (cfg.noFilesWithArrayNotation && isFile(value, isReactNative))\n ) {\n key = pre;\n }\n\n serialize(value, cfg, fd, key);\n });\n } else if (cfg.allowEmptyArrays) {\n fd.append(cfg.noAttributesWithArrayNotation ? pre : pre + '[]', '');\n }\n } else if (isDate(obj)) {\n fd.append(pre, obj.toISOString());\n } else if (isObject(obj) && !isBlob(obj, isReactNative)) {\n Object.keys(obj).forEach((prop) => {\n const value = obj[prop];\n\n if (isArray(value)) {\n while (prop.length > 2 && prop.lastIndexOf('[]') === prop.length - 2) {\n prop = prop.substring(0, prop.length - 2);\n }\n }\n\n const key = pre\n ? cfg.dotsForObjectNotation\n ? pre + '.' + prop\n : pre + '[' + prop + ']'\n : prop;\n\n serialize(value, cfg, fd, key);\n });\n } else {\n fd.append(pre, obj);\n }\n\n return fd;\n}\n\nmodule.exports = {\n serialize,\n};\n","/**\n * Performs a case-insenstive check if string contains substring\n * @param {string} substring - string that might be contained\n * @param {string} string - string that might contain substring\n * @return {boolean}\n */\nexport default function containsSubstring(substring, string) {\n return string.toLowerCase().includes(substring.toLowerCase());\n}\n","import { serialize } from 'object-to-formdata';\nimport { getAuthParam, getAuthToken } from '../../lib/railsFetch';\n\nconst trackingEventQueue = ({ maxBatchSize, processQueue }) => {\n let queue = [];\n\n function getPathName() {\n return window.location.pathname;\n }\n\n const eventPayload = (e) => {\n const pathName = getPathName();\n const eventTime = new Date().toUTCString();\n\n return {\n eventName: e.detail.eventName,\n payload: {\n ...e.detail.payload,\n pathName,\n eventTime,\n },\n };\n };\n\n const push = (e) => {\n queue.push(eventPayload(e));\n\n if (length() >= maxBatchSize) {\n processQueue();\n }\n };\n\n function payload() {\n const data = {};\n data[getAuthParam()] = getAuthToken();\n data.payload = queue;\n return serialize(data);\n }\n\n const clear = () => {\n queue = [];\n };\n\n const empty = () => queue.length === 0;\n\n const length = () => queue.length;\n\n return {\n clear,\n empty,\n length,\n payload,\n push,\n };\n};\n\nexport default trackingEventQueue;\n","import GtmTracker from '../lib/tracking/trackGtm';\nimport TrackingEventProcessor from '../lib/tracking/trackingEventProcessor';\n\nconst trailheadTrackEventListener = (trackerFns = []) => {\n const requireTrackerFn = () => {\n throw new Error('No tracker function passed');\n };\n\n if (trackerFns.length === 0) {\n requireTrackerFn();\n }\n\n const trackTrailheadEvent = (e) => {\n trackerFns.forEach((tracker) => tracker(e));\n };\n\n const attachEventListener = () => {\n document.addEventListener('trailhead_track', (e) => {\n trackTrailheadEvent(e);\n });\n };\n\n return {\n add: attachEventListener,\n };\n};\n\nif (process.env.NODE_ENV !== 'test') {\n const trailheadEventProcessor = new TrackingEventProcessor();\n const gtmTracker = new GtmTracker();\n const trackers = [trailheadEventProcessor.track, gtmTracker.track];\n trailheadTrackEventListener(trackers).add();\n}\n\nexport default trailheadTrackEventListener;\n","import trackingEventQueue from './trackingEventQueue';\nconst DEFAULT_BATCH_SIZE = 1;\nconst ACTIVITY_ENDPOINT = '/trailhead/activity';\n\nclass TrackingEventProcessor {\n constructor({ maxBatchSize = DEFAULT_BATCH_SIZE } = {}) {\n this.queue = trackingEventQueue({\n processQueue: this.processQueue,\n maxBatchSize,\n });\n this.attachEventListener();\n }\n\n attachEventListener() {\n document.addEventListener('visibilitychange', () => {\n this.processQueue({ pageEvent: 'pageVisibility' });\n });\n window.addEventListener('pagehide', () => {\n this.processQueue({ pageEvent: 'pageHide' });\n });\n }\n\n sendEvents() {\n navigator.sendBeacon(ACTIVITY_ENDPOINT, this.queue.payload());\n this.queue.clear();\n }\n\n processQueue = ({ pageEvent } = {}) => {\n if (!pageEvent) {\n this.sendEvents();\n } else if (this.shouldSendBeacon(pageEvent)) {\n this.sendEvents();\n }\n };\n\n shouldSendBeacon(pageEvent) {\n if (pageEvent === 'pageHide') {\n return !this.queue.empty();\n }\n return document.visibilityState === 'hidden' && !this.queue.empty();\n }\n\n track = (e) => {\n this.queue.push(e);\n };\n}\n\nexport default TrackingEventProcessor;\n"],"sourceRoot":""}