{"version":3,"sources":["webpack://Armis/webpack/bootstrap","webpack://Armis/./src/helpers.js","webpack://Armis/./src/geolocation.js","webpack://Armis/./src/deprecatedAct.js","webpack://Armis/./src/armisStorage.js","webpack://Armis/./src/main.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","object","property","prototype","hasOwnProperty","p","s","readQueryString","match","pl","search","decode","decodeURIComponent","replace","query","arguments","length","undefined","window","location","substring","urlParams","exec","readAnchorString","hash","encodeQueryData","data","ret","push","encodeURIComponent","join","inNodeJs","_helpers","lat","lon","acc","position","defaultOnSuccess","pos","coords","latitude","longitude","accuracy","defaultOnError","err","console","log","code","message","1","2","3","findGeolocation","onSuccess","onError","navigator","geolocation","getCurrentPosition","timeout","maximumAge","getLat","getLon","getAcc","_clear","_geolocation","sendAct","tagId","wId","aId","pId","newURL","href","ulatParam","geo","ulonParam","uaccParam","ckEnabledParam","cookieEnabled","aIdParam","pIdParam","params","req","XMLHttpRequest","open","__ACT_SERVER_URL__","setRequestHeader","withCredentials","send","geoloc","sendActReb","delay","setTimeout","KEY_NAME","ttl","_getTtl","storageAvailable","storage","localStorage","x","setItem","removeItem","e","DOMException","_exists","getItem","_expireOutOfDate","_hasExpired","_invalidate","createdAt","Date","_read","getTime","read","updatedAt","armclid","JSON","parse","create","stringify","update","assign","_setTtl","ttlInMs","helper","act","sendEvent","opts","newOpts","nbSec","cke","aid","pid","tid","url","wid","oid","oId","acid","acId","shopKey","anchorParams","findClickId","pv9nw","pv","srxob","stesj","accid","accId","did","dId","didtype","dIdType","ramt","rAmt","aucid","aucId","constr","version","__VERSION__"],"mappings":";sBACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,GAAA,EACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EA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Content":[" \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\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 = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","/**\n * Read the query string of the current browser window.\n * @param {string|null} queryString - query string to decode (use the query string of the browser by default\n * @returns {Object} keys are the query parameters name\n */\nfunction readQueryString(queryString = window.location.search.substring(1)) {\n let match;\n const pl = /\\+/g, // Regex for replacing addition symbol with a space\n search = /([^&=]+)=?([^&]*)/g,\n decode = function (s) {\n return decodeURIComponent(s.replace(pl, \" \"));\n },\n query = queryString;\n\n const urlParams = {};\n while (match = search.exec(query)) {\n urlParams[decode(match[1])] = decode(match[2]);\n }\n return urlParams;\n}\n\n/**\n * Read the anchor string of the current browser window.\n * @param {string|null} anchorString - anchor string to decode (use the anchor string of the browser by default\n * @returns {Object} keys are the anchor parameters name\n */\nfunction readAnchorString(anchorString = window.location.hash.substring(1)) {\n let match;\n const pl = /\\+/g, // Regex for replacing addition symbol with a space\n search = /([^&=]+)=?([^&]*)/g,\n decode = function (s) {\n return decodeURIComponent(s.replace(pl, \" \"));\n },\n query = anchorString;\n\n const urlParams = {};\n while (match = search.exec(query)) {\n urlParams[decode(match[1])] = decode(match[2]);\n }\n return urlParams;\n}\n\n/**\n * Build a query string using the given object\n * @param {Object} data\n * @return {string} a query string which looks like 'toto=titi&foo=bar'\n */\nfunction encodeQueryData(data) {\n let ret = [];\n for (let d in data) {\n const value = data[d];\n if (value) {\n ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(value));\n }\n }\n return ret.join('&');\n}\n\n/**\n * Test whether it is running in node JS or in the browser\n * @return {boolean} true if in node JS\n */\nfunction inNodeJs(){\n return typeof module !== 'undefined' && module.exports;\n}\n\nexport {readQueryString, readAnchorString, encodeQueryData, inNodeJs}\n","import {inNodeJs} from \"./helpers\";\n\nlet lat = null;\nlet lon = null;\nlet acc = null;\nlet position = null;\n\n/**\n * @callback geolocationSuccess\n * @param {Object} position - position of the geolocation\n * @param {Object} position.coords\n * @param {number} position.coords.latitude\n * @param {number} position.coords.longitude\n * @param {number} position.coords.altitude\n * @param {number} position.coords.accuracy\n * @param {number} position.coords.altitudeAccuracy\n * @param {number} position.coords.heading\n * @param {number} position.coords.speed\n * @param {Date} timestamp - date at which the location was retrieved\n */\n/**\n * @callback geolocationError\n * @param {number} code - error code\n * @param {string} message - error message\n */\n/**\n * Try to find the current geolocation of the user\n * @param {geolocationSuccess|null} onSuccess - success handler\n * @param {geolocationError|null} onError - error handler\n */\nfunction findGeolocation(onSuccess, onError) {\n if (!onSuccess) {\n onSuccess = defaultOnSuccess;\n }\n if (!onError) {\n onError = defaultOnError;\n }\n if (!navigator.geolocation) {\n onError(2, \"Geolocation not available in browser\");\n return;\n }\n if (position) {\n onSuccess(position);\n return;\n }\n\n const geoOptions = {\n timeout: 10 * 1000, // 10 seconds\n maximumAge: 30 * 1000, // 30 seconds\n };\n\n navigator.geolocation.getCurrentPosition((position) => {\n defaultOnSuccess(position);\n onSuccess(position);\n }, onError, geoOptions);\n}\n\nfunction defaultOnSuccess(pos) {\n position = pos;\n lat = pos.coords.latitude;\n lon = pos.coords.longitude;\n acc = pos.coords.accuracy;\n}\n\nfunction defaultOnError(err) {\n const errors = {\n 1: \"permission denied\",\n 2: \"position unavailable\",\n 3: \"time out\"\n };\n\n if (!inNodeJs()) {\n console.log(\"geolocation not available, reason code: %d, msg: %s\", err.code, err.message || errors[err.code] || \"Unknown error\");\n }\n}\n\n/**\n * Get the latitude of the geo location\n * @return {number|null}\n */\nfunction getLat() {\n return lat;\n}\n\n/**\n * Get the longitude of the geo location\n * @return {number|null}\n */\nfunction getLon() {\n return lon;\n}\n\n/**\n * Get the accuracy of the geo location in meters\n * @return {number|null}\n */\nfunction getAcc() {\n return acc;\n}\n\n/**\n * internal function used for test purpose\n * @private\n */\nfunction _clear() {\n lat = lon = acc = position = null;\n}\n\nexport default {findGeolocation, getLat, getLon, getAcc, _clear}\n","/*global __ACT_SERVER_URL__*/\nimport geo from './geolocation';\n\n/**\n * @deprecated use {@link Armis.sendEvent()} instead\n * @param {number} tagId - tag id to send\n * @param {number} wId - website id\n * @param {number} delay - delay before sending again an event\n * @param {string|null} [pId] - product id\n */\nfunction sendActReb(tagId, wId, delay, pId) {\n sendAct(tagId, wId, null, pId);\n setTimeout(() => {\n sendAct(tagId * 10 + 1, wId, null, pId);\n }, delay * 1000);\n}\n\n/**\n * @deprecated use {@link Armis.sendEvent()} instead\n * @param {number} tagId - tag id to send\n * @param {number} wId - website id\n * @param {string|null} [aId] - appnexus id\n * @param {string|null} [pId] - product id\n */\nfunction sendAct(tagId, wId, aId, pId) {\n const newURL = window.location.href;\n\n let ulatParam = geo.getLat() != null ? \"&lat=\" + geo.getLat() : \"\";\n\n let ulonParam = geo.getLon() != null ? \"&lon=\" + geo.getLon() : \"\";\n\n let uaccParam = geo.getAcc() != null ? \"&acc=\" + geo.getAcc() : \"\";\n\n let ckEnabledParam = navigator.cookieEnabled ? \"&cke=1\" : \"&cke=0\";\n\n let aIdParam = typeof aId !== 'undefined' ? \"&aid=\" + aId : \"\";\n\n let pIdParam = typeof pId !== 'undefined' ? \"&pid=\" + pId : \"\";\n\n const params = \"tid=\" + tagId + \"&url=\" + encodeURIComponent(newURL) + \"&wid=\" + wId + ulatParam + ulonParam + uaccParam + ckEnabledParam + aIdParam + pIdParam;\n\n const req = new XMLHttpRequest();\n req.open(\"POST\", __ACT_SERVER_URL__ + \"/tag/event\", true);\n req.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n req.withCredentials = true;\n req.send(params);\n}\n\n/**\n *\n * @deprecated use
Armis.sendEvent({geolocation: true})instead\n */\nfunction geoloc() {\n const success = () => {\n sendAct(999, 0);\n };\n\n geo.findGeolocation(success, null);\n}\n\nexport {geoloc, sendAct, sendActReb}\n","const KEY_NAME = \"AVRRmZiS\";\n\n// 2 hours in ms\nlet ttl = 2 * 60 * 60 * 1000;\n\n/**\n * The default ttl is 2 hours.\n * @return {number} the current ttl in ms for the data in the storage\n * @private\n */\nfunction _getTtl() {\n return ttl;\n}\n\n/**\n * Set the ttl for the data in the storage\n * @param ttlInMs - the new ttl in milliseconds\n * @private\n */\nfunction _setTtl(ttlInMs) {\n ttl = ttlInMs;\n}\n\n/**\n * Check if local storage is available\n * @returns {boolean} true if available\n */\nfunction storageAvailable() {\n const storage = window.localStorage,\n x = '__storage_test__';\n try {\n storage.setItem(x, x);\n storage.removeItem(x);\n return true;\n }\n catch (e) {\n return e instanceof DOMException && (\n // everything except Firefox\n e.code === 22 ||\n // Firefox\n e.code === 1014 ||\n // test name field too, because code might not be present\n // everything except Firefox\n e.name === 'QuotaExceededError' ||\n // Firefox\n e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&\n // acknowledge QuotaExceededError only if there's something already stored\n storage.length !== 0;\n }\n}\n\n/**\n * Check if there is Armis data stored in the local storage\n * @returns {boolean} true if there is already some data\n * @private\n */\nfunction _exists() {\n if (!storageAvailable()) {\n return false;\n }\n return window.localStorage.getItem(KEY_NAME) !== null;\n}\n\n/**\n * Create Armis data in the local storage\n * @param armclid click id\n */\nfunction create(armclid) {\n if (!storageAvailable()) {\n return;\n }\n if (_exists() && read().armclid === armclid) {\n return;\n }\n _expireOutOfDate();\n window.localStorage.setItem(KEY_NAME, JSON.stringify({\n createdAt: new Date(),\n updatedAt: new Date(),\n armclid,\n }));\n}\n\n/**\n * Expire the data if is out of date\n * @return {boolean} true if it has expired the data\n * @private\n */\nfunction _expireOutOfDate() {\n if (!_exists()) {\n return true;\n }\n if (_hasExpired()) {\n _invalidate();\n return true;\n }\n return false;\n}\n\n/**\n * Check if the Armis data has expired\n * @return {boolean} true if it is expired\n * @private\n */\nfunction _hasExpired() {\n if (!_exists()) {\n return true;\n }\n const createdAt = new Date(_read().createdAt);\n const ttl = _getTtl();\n return new Date().getTime() > createdAt.getTime() + ttl;\n}\n\n/**\n * Update Armis data with the current date\n */\nfunction update() {\n if (!storageAvailable()) {\n return;\n }\n const expired = _expireOutOfDate();\n if (!expired) {\n window.localStorage.setItem(KEY_NAME,\n JSON.stringify(Object.assign(read(), {\n updatedAt: new Date()\n })));\n }\n}\n\n/**\n * @typedef {Object} ArmisData\n * @property {Date|null} createdAt - creation date of the data\n * @property {Date|null} updatedAt - last update date of the data\n * @property {string|null} armclid - last registered click id\n */\n\n/**\n * Read Armis data in the local storage\n * @returns {ArmisData} Armis data stored in local storage\n */\nfunction read() {\n if (!storageAvailable()) {\n return _emptyValue();\n }\n const expired = _expireOutOfDate();\n if (expired) {\n return _emptyValue();\n }\n return _read();\n}\n\nfunction _read() {\n return JSON.parse(window.localStorage.getItem(KEY_NAME));\n}\n\nfunction _emptyValue() {\n return {createdAt: null, updatedAt: null, armclid: null};\n}\n\n/**\n * Delete the current Armis data\n * @private\n */\nfunction _invalidate() {\n if (!storageAvailable()) {\n return;\n }\n window.localStorage.removeItem(KEY_NAME);\n}\n\nexport default {create, read, update, _hasExpired, _exists, _invalidate, _expireOutOfDate, _setTtl, _getTtl}\n","/*global __VERSION__, __ACT_SERVER_URL__*/\n/**\n * @license\n * Armis tag\n *\n * Copyright 2016-present, Armis\n * All rights reserved\n *\n * This source code is proprietary software.\n */\nimport storage from './armisStorage';\nimport geo from './geolocation';\nimport * as helper from './helpers';\nimport * as act from './deprecatedAct';\n\n/**\n * @deprecated use {@link sendEvent()} instead\n * @param {number} tagId - tag id to send\n * @param {number} wId - website id\n * @param {number} delay - delay before sending again an event\n * @param {string|null} [pId] - product id\n */\nfunction sendActReb(tagId, wId, delay, pId) {\n act.sendActReb(tagId, wId, delay, pId);\n}\n\n/**\n * @deprecated use {@link sendEvent()} instead\n * @param {number} tagId - tag id to send\n * @param {number} wId - website id\n * @param {string|null} [aId] - appnexus id\n * @param {string|null} [pId] - product id\n */\nfunction sendAct(tagId, wId, aId, pId) {\n act.sendAct(tagId, wId, aId, pId);\n}\n\n/**\n *\n * @deprecated use
sendEvent({geolocation: true})instead\n */\nfunction geoloc() {\n act.geoloc();\n}\n\n/**\n * Main function to send an event to Armis.\n * @param {Object} opts - options to pass to the tag\n * @param {number} opts.tagId - tag id\n * @param {number|null} [opts.wId] - website id\n * @param {number|null} [opts.oId] - operation id\n * @param {number|null} [opts.acId] - ads campaign id\n * @param {number|null} [opts.accId] - account id\n * @param {string|null} [opts.shopKey] - client shop reference\n * @param {string|null} [opts.aId] - appnexus id\n * @param {string[]|null} [opts.pId] - product ids (can be 1 pid, or multiple pid in an array)\n * @param {number|null} [opts.nbSec] - number of second before sending a new event\n * @param {boolean|null} [opts.geolocation] - if true, send an event with geo-location data\n * @param {number|null} [opts.lat] - latitude of geolocation\n * @param {number|null} [opts.lon] - longitude of geolocation\n * @param {number|null} [opts.acc] - accuracy of geolocation (in meters)\n * @param {string|null} [opts.armclid] - click id\n * @param {boolean|null} [opts.pv9nw] - is the event a preview (1 for yes, 0 for no)\n * @param {string|null} [opts.srxob] - platform source of the event, used for ads\n * @param {number|null} [opts.stesj] - strategy id, used for ads\n * @param {string|null} [opts.dId] - Device id\n * @param {number|null} [opts.dIdType] - Device id type\n * @param {number|null} [opts.rAmt] - Revenue\n * @param {string|null} [opts.aucId] - Auction id\n * @param {string|null} [opts.constr] - Consent string to be GRPD compliant\n */\nfunction sendEvent(opts) {\n if (opts.geolocation) {\n geo.findGeolocation((position) => {\n const newOpts = Object.assign({}, opts, {\n lat: position.coords.latitude,\n lon: position.coords.longitude,\n acc: position.coords.accuracy,\n tagId: 999,\n });\n delete newOpts.geolocation;\n delete newOpts.nbSec;\n sendEvent(newOpts);\n }, null);\n }\n\n if (opts.nbSec) {\n setTimeout(() => {\n const newOpts = Object.assign({}, opts, {tagId: opts.tagId * 10 + 1});\n delete newOpts.nbSec;\n delete newOpts.geolocation;\n sendEvent(newOpts);\n }, opts.nbSec * 1000);\n }\n\n const req = new XMLHttpRequest();\n req.open(\"POST\", __ACT_SERVER_URL__ + \"/tag/event\", true);\n req.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n req.withCredentials = true;\n const params = helper.encodeQueryData({\n lat: opts.lat || geo.getLat(),\n lon: opts.lon || geo.getLon(),\n acc: opts.acc || geo.getAcc(),\n cke: navigator.cookieEnabled ? 1 : 0,\n aid: opts.aId,\n pid: opts.pId,\n tid: opts.tagId,\n url: window.location.href,\n wid: opts.wId,\n oid: opts.oId,\n acid: opts.acId,\n shopKey: opts.shopKey,\n armclid: opts.armclid || findClickId(),\n pv9nw: opts.pv9nw || opts.pv,\n srxob: opts.srxob,\n stesj: opts.stesj,\n accid: opts.accId,\n did: opts.dId,\n didtype: opts.dIdType,\n ramt: opts.rAmt,\n aucid: opts.aucId,\n constr: opts.constr\n });\n req.send(params);\n}\n\nfunction findClickId() {\n const params = helper.readQueryString();\n const anchorParams = helper.readAnchorString();\n\n if (params.armclid) {\n storage.create(params.armclid);\n return params.armclid;\n } else if (anchorParams.armclid) {\n storage.create(anchorParams.armclid);\n return anchorParams.armclid;\n }\n storage.update();\n return storage.read().armclid;\n}\n\nfunction version() {\n return __VERSION__;\n}\n\nexport {sendAct, sendActReb, geoloc, sendEvent, version}\n"],"sourceRoot":""}