blob: 6c02a0d754b9ac6a2d238ab4268187dc025564f3 [file] [log] [blame]
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./index.js":
/*!******************!*\
!*** ./index.js ***!
\******************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var flagon_userale__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flagon-userale */ \"./node_modules/flagon-userale/build/userale-2.2.0.js\");\n/* harmony import */ var flagon_userale__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flagon_userale__WEBPACK_IMPORTED_MODULE_0__);\n// Licensed to the Apache Software Foundation (ASF) under one or more\n// contributor license agreements. See the NOTICE file distributed with\n// this work for additional information regarding copyright ownership.\n// The ASF licenses this file to You under the Apache License, Version 2.0\n// (the \"License\"); you may not use this file except in compliance with\n// the License. You may obtain a copy of the License at\n// http://www.apache.org/licenses/LICENSE-2.0\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n\n\n//or use require\n//const userale = require('flagon-userale');\n\n\n/** Options API\n *\n * the 'options' API allows you to dynamically change UserALE.js params and set meta data values\n * pass in variables or properties into the options object, such as from sessionStorage or localStorage\n * NOTE1: if you are using userale in a package bundler, you will need to set options via this API, including\n * \"url\" to tell userale where to send your logs!\n * NOTE2: logDetails is set to true (default:false), this will log key strokes, inputs, and change events\n * (be careful of your form data and auth workflows!)\n */\nconst changeMe = \"me\";\nflagon_userale__WEBPACK_IMPORTED_MODULE_0__.options({\n 'userId': changeMe,\n 'url': 'http://localhost:8000/',\n 'version': '2.2.0',\n 'logDetails': true,\n 'toolName': 'Apache UserALE.js Example (Custom)',\n 'logCountThreshold': '1',\n 'transmitInterval': '1000'\n});\n\n/**Filter API\n\n /**the 'filter' API allows you to eliminate logs you don't want\n * use as a global filter and add classes of events or log types to eliminate\n * or use in block scope to surgically eliminate logs from specific elements from an event handler\n * The filter below reduces logs to capture click, change, select, scroll and submit events on index.html\n * Note that for surgical filters, you may need to clear or reset back to a global filter callback\n * the same is true for the 'map' API. See examples below:\n */\nflagon_userale__WEBPACK_IMPORTED_MODULE_0__.filter(function (log) {\n var type_array = ['mouseup', 'mouseover', 'mousedown', 'keydown', 'dblclick', 'blur', 'focus', 'input', 'wheel', 'scroll'];\n var logType_array = ['interval'];\n return !type_array.includes(log.type) && !logType_array.includes(log.logType);\n});\n\n/**Log Mapping API\n *\n * the 'map' API allows you to add or modify new fields to your logs\n * this example works with the \"Click Me!\" button at the top of index.html\n */\ndocument.addEventListener('click', function(e){\n if (e.target.innerHTML === 'Click Me!') {\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.map(function (log) {\n return Object.assign({}, log, { logType: 'custom', customLabel: 'map & packageLog Example' });\n });\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.packageLog(e, flagon_userale__WEBPACK_IMPORTED_MODULE_0__.details(flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options(),e.type));\n /**you'll want to reset the map callback function, or set a conditional (e.g., return log), else\n * the callback may be applied to other events of the same class (e.g., click) */\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.map();\n } else {\n return false\n }\n});\n\n/** Alternate Log Mapping API Example\n * Build a global mapping function with conditional logic to modify logs for similar events\n * this example works with the \"Click Me!\" button at the top of index.html\n * Also, note that specifying log as a return will keep the scope of this callback limited to only the events you want\n */\n//userale.map(function (log, e) {\n// var targetsForLabels = [\"button#test_button\"];\n// if (targetsForLabels.includes(log.target)) {\n// return Object.assign({}, log, { customLabel: e.target.innerHTML });\n// } else {\n// return log;\n// }\n//});\n\n/**'Log' API and Custom Log Functions\n *\n * the 'log' API generate custom events and add them to the log queue\n * pass in any keys:values for fully customized logs\n * utilize 'options' and other functions to streamline populating custom logs\n * type 'log' into the 'API Test Field' to see this custom log sent to our example server\n */\ndocument.addEventListener('change', function(e) {\n if (e.target.value === 'log') {\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.log({\n target: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.getSelector(e.target),\n path: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.buildPath(e),\n clientTime: Date.now(),\n type: e.type,\n logType: 'custom',\n userAction: false,\n details: {'foo': 'bar', 'bar': 'foo'},\n customField1: 'I can make this log look like anything I want',\n customField2: 'foo',\n userId: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options().userId,\n toolVersion: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options().version,\n toolName: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options().toolName,\n useraleVersion: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options().useraleVersion,\n sessionID: flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options().sessionID,\n customLabel: \"Custom Log Example\"\n });\n }\n});\n\n/**you can also use UserALE.js' own packaging function for HTML events to strive for standardization\n * type 'packageLog into the 'API Test Field' to see this custom log sent to our example server\n */\ndocument.addEventListener('change', function(e){\n if (e.target.value === 'packageLog') {\n /**You can then use the 'Mapping' API function to modify custom logs created with the packageLog function*/\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.map(function (log) {\n var targetsForLabels = ['change'];\n if (targetsForLabels.includes(log.type)) {\n return Object.assign({}, log, { logType: 'custom', customLabel: 'packageLog Example' });\n } else {\n return log;\n }\n });\n /**You can also use the details function to package additional log meta data, or add custom details*/\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.packageLog(e, flagon_userale__WEBPACK_IMPORTED_MODULE_0__.details(flagon_userale__WEBPACK_IMPORTED_MODULE_0__.options(),e.type));\n } else {\n return false\n }\n});\n\n/**you can also just add boilerplate UserALE.js meta data to custom logs with the packageCustomLog function\n * type 'packageCustomLog into the 'API Test Field' to see this custom log sent to our example server\n */\ndocument.addEventListener('change', function(e) {\n if (e.target.value === 'packageCustomLog') {\n flagon_userale__WEBPACK_IMPORTED_MODULE_0__.packageCustomLog({\n customLabel: 'packageCustomLog Example',\n customField1: 'foo',\n customField2: 'bar'},\n function(){return {'foo': 'bar', 'bar': 'foo'}},\n true\n );\n } else {\n return false\n }\n});\n\n//# sourceURL=webpack://flagon-userale-example/./index.js?");
/***/ }),
/***/ "./node_modules/flagon-userale/build/userale-2.2.0.js":
/*!************************************************************!*\
!*** ./node_modules/flagon-userale/build/userale-2.2.0.js ***!
\************************************************************/
/***/ (function(__unused_webpack_module, exports) {
eval("/**\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * @preserved\n */\n\n(function (global, factory) {\n true ? factory(exports) :\n 0;\n}(this, (function (exports) { 'use strict';\n\n function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function _typeof(obj) {\n return typeof obj;\n };\n } else {\n _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n }\n\n var version$1 = \"2.2.0\";\n\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the 'License'); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an 'AS IS' BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n var sessionId = null;\n /**\n * Extracts the initial configuration settings from the\n * currently executing script tag.\n * @return {Object} The extracted configuration object\n */\n\n function getInitialSettings() {\n var settings = {};\n\n if (sessionId === null) {\n sessionId = getSessionId('userAleSessionId', 'session_' + String(Date.now()));\n }\n\n var script = document.currentScript || function () {\n var scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n }();\n\n var get = script ? script.getAttribute.bind(script) : function () {\n return null;\n };\n settings.autostart = get('data-autostart') === 'false' ? false : true;\n settings.url = get('data-url') || 'http://localhost:8000';\n settings.transmitInterval = +get('data-interval') || 5000;\n settings.logCountThreshold = +get('data-threshold') || 5;\n settings.userId = get('data-user') || null;\n settings.version = get('data-version') || null;\n settings.logDetails = get('data-log-details') === 'true' ? true : false;\n settings.resolution = +get('data-resolution') || 500;\n settings.toolName = get('data-tool') || null;\n settings.userFromParams = get('data-user-from-params') || null;\n settings.time = timeStampScale(document.createEvent('CustomEvent'));\n settings.sessionID = get('data-session') || sessionId;\n settings.authHeader = get('data-auth') || null;\n settings.custIndex = get('data-index') || null;\n return settings;\n }\n /**\n * defines sessionId, stores it in sessionStorage, checks to see if there is a sessionId in\n * storage when script is started. This prevents events like 'submit', which refresh page data\n * from refreshing the current user session\n *\n */\n\n function getSessionId(sessionKey, value) {\n if (window.sessionStorage.getItem(sessionKey) === null) {\n window.sessionStorage.setItem(sessionKey, JSON.stringify(value));\n return value;\n }\n\n return JSON.parse(window.sessionStorage.getItem(sessionKey));\n }\n /**\n * Creates a function to normalize the timestamp of the provided event.\n * @param {Object} e An event containing a timeStamp property.\n * @return {timeStampScale~tsScaler} The timestamp normalizing function.\n */\n\n function timeStampScale(e) {\n var tsScaler;\n\n if (e.timeStamp && e.timeStamp > 0) {\n var delta = Date.now() - e.timeStamp;\n /**\n * Returns a timestamp depending on various browser quirks.\n * @param {?Number} ts A timestamp to use for normalization.\n * @return {Number} A normalized timestamp.\n */\n\n if (delta < 0) {\n tsScaler = function tsScaler() {\n return e.timeStamp / 1000;\n };\n } else if (delta > e.timeStamp) {\n var navStart = performance.timing.navigationStart;\n\n tsScaler = function tsScaler(ts) {\n return ts + navStart;\n };\n } else {\n tsScaler = function tsScaler(ts) {\n return ts;\n };\n }\n } else {\n tsScaler = function tsScaler() {\n return Date.now();\n };\n }\n\n return tsScaler;\n }\n\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /**\n * Shallow merges the first argument with the second.\n * Retrieves/updates the userid if userFromParams is provided.\n * @param {Object} config Current configuration object to be merged into.\n * @param {Object} newConfig Configuration object to merge into the current config.\n */\n function configure(config, newConfig) {\n Object.keys(newConfig).forEach(function (option) {\n if (option === 'userFromParams') {\n var userId = getUserIdFromParams(newConfig[option]);\n\n if (userId) {\n config.userId = userId;\n }\n }\n\n config[option] = newConfig[option];\n });\n }\n /**\n * Attempts to extract the userid from the query parameters of the URL.\n * @param {string} param The name of the query parameter containing the userid.\n * @return {string|null} The extracted/decoded userid, or null if none is found.\n */\n\n function getUserIdFromParams(param) {\n var userField = param;\n var regex = new RegExp('[?&]' + userField + '(=([^&#]*)|&|#|$)');\n var results = window.location.href.match(regex);\n\n if (results && results[2]) {\n return decodeURIComponent(results[2].replace(/\\+/g, ' '));\n } else {\n return null;\n }\n }\n\n var __spreadArrays = ( false) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };\n var BrowserInfo = /** @class */ (function () {\n function BrowserInfo(name, version, os) {\n this.name = name;\n this.version = version;\n this.os = os;\n this.type = 'browser';\n }\n return BrowserInfo;\n }());\n var NodeInfo = /** @class */ (function () {\n function NodeInfo(version) {\n this.version = version;\n this.type = 'node';\n this.name = 'node';\n this.os = process.platform;\n }\n return NodeInfo;\n }());\n var SearchBotDeviceInfo = /** @class */ (function () {\n function SearchBotDeviceInfo(name, version, os, bot) {\n this.name = name;\n this.version = version;\n this.os = os;\n this.bot = bot;\n this.type = 'bot-device';\n }\n return SearchBotDeviceInfo;\n }());\n var BotInfo = /** @class */ (function () {\n function BotInfo() {\n this.type = 'bot';\n this.bot = true; // NOTE: deprecated test name instead\n this.name = 'bot';\n this.version = null;\n this.os = null;\n }\n return BotInfo;\n }());\n var ReactNativeInfo = /** @class */ (function () {\n function ReactNativeInfo() {\n this.type = 'react-native';\n this.name = 'react-native';\n this.version = null;\n this.os = null;\n }\n return ReactNativeInfo;\n }());\n // tslint:disable-next-line:max-line-length\n var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/;\n var SEARCHBOT_OS_REGEX = /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\\ Jeeves\\/Teoma|ia_archiver)/;\n var REQUIRED_VERSION_PARTS = 3;\n var userAgentRules = [\n ['aol', /AOLShield\\/([0-9\\._]+)/],\n ['edge', /Edge\\/([0-9\\._]+)/],\n ['edge-ios', /EdgiOS\\/([0-9\\._]+)/],\n ['yandexbrowser', /YaBrowser\\/([0-9\\._]+)/],\n ['kakaotalk', /KAKAOTALK\\s([0-9\\.]+)/],\n ['samsung', /SamsungBrowser\\/([0-9\\.]+)/],\n ['silk', /\\bSilk\\/([0-9._-]+)\\b/],\n ['miui', /MiuiBrowser\\/([0-9\\.]+)$/],\n ['beaker', /BeakerBrowser\\/([0-9\\.]+)/],\n ['edge-chromium', /EdgA?\\/([0-9\\.]+)/],\n [\n 'chromium-webview',\n /(?!Chrom.*OPR)wv\\).*Chrom(?:e|ium)\\/([0-9\\.]+)(:?\\s|$)/,\n ],\n ['chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\\/([0-9\\.]+)(:?\\s|$)/],\n ['phantomjs', /PhantomJS\\/([0-9\\.]+)(:?\\s|$)/],\n ['crios', /CriOS\\/([0-9\\.]+)(:?\\s|$)/],\n ['firefox', /Firefox\\/([0-9\\.]+)(?:\\s|$)/],\n ['fxios', /FxiOS\\/([0-9\\.]+)/],\n ['opera-mini', /Opera Mini.*Version\\/([0-9\\.]+)/],\n ['opera', /Opera\\/([0-9\\.]+)(?:\\s|$)/],\n ['opera', /OPR\\/([0-9\\.]+)(:?\\s|$)/],\n ['ie', /Trident\\/7\\.0.*rv\\:([0-9\\.]+).*\\).*Gecko$/],\n ['ie', /MSIE\\s([0-9\\.]+);.*Trident\\/[4-7].0/],\n ['ie', /MSIE\\s(7\\.0)/],\n ['bb10', /BB10;\\sTouch.*Version\\/([0-9\\.]+)/],\n ['android', /Android\\s([0-9\\.]+)/],\n ['ios', /Version\\/([0-9\\._]+).*Mobile.*Safari.*/],\n ['safari', /Version\\/([0-9\\._]+).*Safari/],\n ['facebook', /FBAV\\/([0-9\\.]+)/],\n ['instagram', /Instagram\\s([0-9\\.]+)/],\n ['ios-webview', /AppleWebKit\\/([0-9\\.]+).*Mobile/],\n ['ios-webview', /AppleWebKit\\/([0-9\\.]+).*Gecko\\)$/],\n ['searchbot', SEARCHBOX_UA_REGEX],\n ];\n var operatingSystemRules = [\n ['iOS', /iP(hone|od|ad)/],\n ['Android OS', /Android/],\n ['BlackBerry OS', /BlackBerry|BB10/],\n ['Windows Mobile', /IEMobile/],\n ['Amazon OS', /Kindle/],\n ['Windows 3.11', /Win16/],\n ['Windows 95', /(Windows 95)|(Win95)|(Windows_95)/],\n ['Windows 98', /(Windows 98)|(Win98)/],\n ['Windows 2000', /(Windows NT 5.0)|(Windows 2000)/],\n ['Windows XP', /(Windows NT 5.1)|(Windows XP)/],\n ['Windows Server 2003', /(Windows NT 5.2)/],\n ['Windows Vista', /(Windows NT 6.0)/],\n ['Windows 7', /(Windows NT 6.1)/],\n ['Windows 8', /(Windows NT 6.2)/],\n ['Windows 8.1', /(Windows NT 6.3)/],\n ['Windows 10', /(Windows NT 10.0)/],\n ['Windows ME', /Windows ME/],\n ['Open BSD', /OpenBSD/],\n ['Sun OS', /SunOS/],\n ['Chrome OS', /CrOS/],\n ['Linux', /(Linux)|(X11)/],\n ['Mac OS', /(Mac_PowerPC)|(Macintosh)/],\n ['QNX', /QNX/],\n ['BeOS', /BeOS/],\n ['OS/2', /OS\\/2/],\n ];\n function detect(userAgent) {\n if (!!userAgent) {\n return parseUserAgent(userAgent);\n }\n if (typeof document === 'undefined' &&\n typeof navigator !== 'undefined' &&\n navigator.product === 'ReactNative') {\n return new ReactNativeInfo();\n }\n if (typeof navigator !== 'undefined') {\n return parseUserAgent(navigator.userAgent);\n }\n return getNodeVersion();\n }\n function matchUserAgent(ua) {\n // opted for using reduce here rather than Array#first with a regex.test call\n // this is primarily because using the reduce we only perform the regex\n // execution once rather than once for the test and for the exec again below\n // probably something that needs to be benchmarked though\n return (ua !== '' &&\n userAgentRules.reduce(function (matched, _a) {\n var browser = _a[0], regex = _a[1];\n if (matched) {\n return matched;\n }\n var uaMatch = regex.exec(ua);\n return !!uaMatch && [browser, uaMatch];\n }, false));\n }\n function parseUserAgent(ua) {\n var matchedRule = matchUserAgent(ua);\n if (!matchedRule) {\n return null;\n }\n var name = matchedRule[0], match = matchedRule[1];\n if (name === 'searchbot') {\n return new BotInfo();\n }\n var versionParts = match[1] && match[1].split(/[._]/).slice(0, 3);\n if (versionParts) {\n if (versionParts.length < REQUIRED_VERSION_PARTS) {\n versionParts = __spreadArrays(versionParts, createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length));\n }\n }\n else {\n versionParts = [];\n }\n var version = versionParts.join('.');\n var os = detectOS(ua);\n var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua);\n if (searchBotMatch && searchBotMatch[1]) {\n return new SearchBotDeviceInfo(name, version, os, searchBotMatch[1]);\n }\n return new BrowserInfo(name, version, os);\n }\n function detectOS(ua) {\n for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) {\n var _a = operatingSystemRules[ii], os = _a[0], regex = _a[1];\n var match = regex.exec(ua);\n if (match) {\n return os;\n }\n }\n return null;\n }\n function getNodeVersion() {\n var isNode = typeof process !== 'undefined' && process.version;\n return isNode ? new NodeInfo(process.version.slice(1)) : null;\n }\n function createVersionParts(count) {\n var output = [];\n for (var ii = 0; ii < count; ii++) {\n output.push('0');\n }\n return output;\n }\n\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n var browser = detect();\n var logs$1;\n var config$1; // Interval Logging Globals\n\n var intervalID;\n var intervalType;\n var intervalPath;\n var intervalTimer;\n var intervalCounter;\n var intervalLog;\n var filterHandler = null;\n var mapHandler = null;\n /**\n * Assigns a handler to filter logs out of the queue.\n * @param {Function} callback The handler to invoke when logging.\n */\n\n function setLogFilter(callback) {\n filterHandler = callback;\n }\n /**\n * Assigns a handler to transform logs from their default structure.\n * @param {Function} callback The handler to invoke when logging.\n */\n\n function setLogMapper(callback) {\n mapHandler = callback;\n }\n /**\n * Assigns the config and log container to be used by the logging functions.\n * @param {Array} newLogs Log container.\n * @param {Object} newConfig Configuration to use while logging.\n */\n\n function initPackager(newLogs, newConfig) {\n logs$1 = newLogs;\n config$1 = newConfig;\n filterHandler = null;\n mapHandler = null;\n intervalID = null;\n intervalType = null;\n intervalPath = null;\n intervalTimer = null;\n intervalCounter = 0;\n intervalLog = null;\n }\n /**\n * Transforms the provided HTML event into a log and appends it to the log queue.\n * @param {Object} e The event to be logged.\n * @param {Function} detailFcn The function to extract additional log parameters from the event.\n * @return {boolean} Whether the event was logged.\n */\n\n function packageLog(e, detailFcn) {\n if (!config$1.on) {\n return false;\n }\n\n var details = null;\n\n if (detailFcn) {\n details = detailFcn(e);\n }\n\n var timeFields = extractTimeFields(e.timeStamp && e.timeStamp > 0 ? config$1.time(e.timeStamp) : Date.now());\n var log = {\n 'target': getSelector(e.target),\n 'path': buildPath(e),\n 'pageUrl': window.location.href,\n 'pageTitle': document.title,\n 'pageReferrer': document.referrer,\n 'browser': detectBrowser(),\n 'clientTime': timeFields.milli,\n 'microTime': timeFields.micro,\n 'location': getLocation(e),\n 'scrnRes': getSreenRes(),\n 'type': e.type,\n 'logType': 'raw',\n 'userAction': true,\n 'details': details,\n 'userId': config$1.userId,\n 'toolVersion': config$1.version,\n 'toolName': config$1.toolName,\n 'useraleVersion': config$1.useraleVersion,\n 'sessionID': config$1.sessionID\n };\n\n if (typeof filterHandler === 'function' && !filterHandler(log)) {\n return false;\n }\n\n if (typeof mapHandler === 'function') {\n log = mapHandler(log, e);\n }\n\n logs$1.push(log);\n return true;\n }\n /**\n * Packages the provided customLog to include standard meta data and appends it to the log queue.\n * @param {Object} customLog The behavior to be logged.\n * @param {Function} detailFcn The function to extract additional log parameters from the event.\n * @param {boolean} userAction Indicates user behavior (true) or system behavior (false)\n * @return {boolean} Whether the event was logged.\n */\n\n function packageCustomLog(customLog, detailFcn, userAction) {\n if (!config$1.on) {\n return false;\n }\n\n var details = null;\n\n if (detailFcn) {\n details = detailFcn();\n }\n\n var metaData = {\n 'pageUrl': window.location.href,\n 'pageTitle': document.title,\n 'pageReferrer': document.referrer,\n 'browser': detectBrowser(),\n 'clientTime': Date.now(),\n 'scrnRes': getSreenRes(),\n 'logType': 'custom',\n 'userAction': userAction,\n 'details': details,\n 'userId': config$1.userId,\n 'toolVersion': config$1.version,\n 'toolName': config$1.toolName,\n 'useraleVersion': config$1.useraleVersion,\n 'sessionID': config$1.sessionID\n };\n var log = Object.assign(metaData, customLog);\n\n if (typeof filterHandler === 'function' && !filterHandler(log)) {\n return false;\n }\n\n if (typeof mapHandler === 'function') {\n log = mapHandler(log);\n }\n\n logs$1.push(log);\n return true;\n }\n /**\n * Extract the millisecond and microsecond portions of a timestamp.\n * @param {Number} timeStamp The timestamp to split into millisecond and microsecond fields.\n * @return {Object} An object containing the millisecond\n * and microsecond portions of the timestamp.\n */\n\n function extractTimeFields(timeStamp) {\n return {\n milli: Math.floor(timeStamp),\n micro: Number((timeStamp % 1).toFixed(3))\n };\n }\n /**\n * Track intervals and gather details about it.\n * @param {Object} e\n * @return boolean\n */\n\n function packageIntervalLog(e) {\n var target = getSelector(e.target);\n var path = buildPath(e);\n var type = e.type;\n var timestamp = Math.floor(e.timeStamp && e.timeStamp > 0 ? config$1.time(e.timeStamp) : Date.now()); // Init - this should only happen once on initialization\n\n if (intervalID == null) {\n intervalID = target;\n intervalType = type;\n intervalPath = path;\n intervalTimer = timestamp;\n intervalCounter = 0;\n }\n\n if (intervalID !== target || intervalType !== type) {\n // When to create log? On transition end\n // @todo Possible for intervalLog to not be pushed in the event the interval never ends...\n intervalLog = {\n 'target': intervalID,\n 'path': intervalPath,\n 'pageUrl': window.location.href,\n 'pageTitle': document.title,\n 'pageReferrer': document.referrer,\n 'browser': detectBrowser(),\n 'count': intervalCounter,\n 'duration': timestamp - intervalTimer,\n // microseconds\n 'startTime': intervalTimer,\n 'endTime': timestamp,\n 'type': intervalType,\n 'logType': 'interval',\n 'targetChange': intervalID !== target,\n 'typeChange': intervalType !== type,\n 'userAction': false,\n 'userId': config$1.userId,\n 'toolVersion': config$1.version,\n 'toolName': config$1.toolName,\n 'useraleVersion': config$1.useraleVersion,\n 'sessionID': config$1.sessionID\n };\n\n if (typeof filterHandler === 'function' && !filterHandler(intervalLog)) {\n return false;\n }\n\n if (typeof mapHandler === 'function') {\n intervalLog = mapHandler(intervalLog, e);\n }\n\n logs$1.push(intervalLog); // Reset\n\n intervalID = target;\n intervalType = type;\n intervalPath = path;\n intervalTimer = timestamp;\n intervalCounter = 0;\n } // Interval is still occuring, just update counter\n\n\n if (intervalID == target && intervalType == type) {\n intervalCounter = intervalCounter + 1;\n }\n\n return true;\n }\n /**\n * Extracts coordinate information from the event\n * depending on a few browser quirks.\n * @param {Object} e The event to extract coordinate information from.\n * @return {Object} An object containing nullable x and y coordinates for the event.\n */\n\n function getLocation(e) {\n if (e.pageX != null) {\n return {\n 'x': e.pageX,\n 'y': e.pageY\n };\n } else if (e.clientX != null) {\n return {\n 'x': document.documentElement.scrollLeft + e.clientX,\n 'y': document.documentElement.scrollTop + e.clientY\n };\n } else {\n return {\n 'x': null,\n 'y': null\n };\n }\n }\n /**\n * Extracts innerWidth and innerHeight to provide estimates of screen resolution\n * @return {Object} An object containing the innerWidth and InnerHeight\n */\n\n function getSreenRes() {\n return {\n 'width': window.innerWidth,\n 'height': window.innerHeight\n };\n }\n /**\n * Builds a string CSS selector from the provided element\n * @param {HTMLElement} ele The element from which the selector is built.\n * @return {string} The CSS selector for the element, or Unknown if it can't be determined.\n */\n\n function getSelector(ele) {\n if (ele.localName) {\n return ele.localName + (ele.id ? '#' + ele.id : '') + (ele.className ? '.' + ele.className : '');\n } else if (ele.nodeName) {\n return ele.nodeName + (ele.id ? '#' + ele.id : '') + (ele.className ? '.' + ele.className : '');\n } else if (ele && ele.document && ele.location && ele.alert && ele.setInterval) {\n return \"Window\";\n } else {\n return \"Unknown\";\n }\n }\n /**\n * Builds an array of elements from the provided event target, to the root element.\n * @param {Object} e Event from which the path should be built.\n * @return {HTMLElement[]} Array of elements, starting at the event target, ending at the root element.\n */\n\n function buildPath(e) {\n var path = [];\n\n if (e.path) {\n path = e.path;\n } else {\n var ele = e.target;\n\n while (ele) {\n path.push(ele);\n ele = ele.parentElement;\n }\n }\n\n return selectorizePath(path);\n }\n /**\n * Builds a CSS selector path from the provided list of elements.\n * @param {HTMLElement[]} path Array of HTMLElements from which the path should be built.\n * @return {string[]} Array of string CSS selectors.\n */\n\n function selectorizePath(path) {\n var i = 0;\n var pathEle;\n var pathSelectors = [];\n\n while (pathEle = path[i]) {\n pathSelectors.push(getSelector(pathEle));\n ++i;\n }\n\n return pathSelectors;\n }\n function detectBrowser() {\n return {\n 'browser': browser ? browser.name : '',\n 'version': browser ? browser.version : ''\n };\n }\n\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n var events;\n var bufferBools;\n var bufferedEvents; //@todo: Investigate drag events and their behavior\n\n var intervalEvents = ['click', 'focus', 'blur', 'input', 'change', 'mouseover', 'submit'];\n var refreshEvents;\n var windowEvents = ['load', 'blur', 'focus'];\n /**\n * Maps an event to an object containing useful information.\n * @param {Object} e Event to extract data from\n */\n\n function extractMouseEvent(e) {\n return {\n 'clicks': e.detail,\n 'ctrl': e.ctrlKey,\n 'alt': e.altKey,\n 'shift': e.shiftKey,\n 'meta': e.metaKey // 'text' : e.target.innerHTML\n\n };\n }\n /**\n * Defines the way information is extracted from various events.\n * Also defines which events we will listen to.\n * @param {Object} config Configuration object to read from.\n */\n\n function defineDetails(config) {\n // Events list\n // Keys are event types\n // Values are functions that return details object if applicable\n events = {\n 'click': extractMouseEvent,\n 'dblclick': extractMouseEvent,\n 'mousedown': extractMouseEvent,\n 'mouseup': extractMouseEvent,\n 'focus': null,\n 'blur': null,\n 'input': config.logDetails ? function (e) {\n return {\n 'value': e.target.value\n };\n } : null,\n 'change': config.logDetails ? function (e) {\n return {\n 'value': e.target.value\n };\n } : null,\n 'dragstart': null,\n 'dragend': null,\n 'drag': null,\n 'drop': null,\n 'keydown': config.logDetails ? function (e) {\n return {\n 'key': e.keyCode,\n 'ctrl': e.ctrlKey,\n 'alt': e.altKey,\n 'shift': e.shiftKey,\n 'meta': e.metaKey\n };\n } : null,\n 'mouseover': null\n };\n bufferBools = {};\n bufferedEvents = {\n 'wheel': function wheel(e) {\n return {\n 'x': e.deltaX,\n 'y': e.deltaY,\n 'z': e.deltaZ\n };\n },\n 'scroll': function scroll() {\n return {\n 'x': window.scrollX,\n 'y': window.scrollY\n };\n },\n 'resize': function resize() {\n return {\n 'width': window.outerWidth,\n 'height': window.outerHeight\n };\n }\n };\n refreshEvents = {\n 'submit': null\n };\n }\n /**\n * Defines the way information is extracted from various events.\n * Also defines which events we will listen to.\n * @param {Object} options UserALE.js Configuration object to read from.\n * @param {string} type of html event (e.g., 'click', 'mouseover', etc.), such as passed to addEventListener methods.\n */\n\n function defineCustomDetails(options, type) {\n // Events list\n // Keys are event types\n // Values are functions that return details object if applicable\n var eventType = {\n 'click': extractMouseEvent,\n 'dblclick': extractMouseEvent,\n 'mousedown': extractMouseEvent,\n 'mouseup': extractMouseEvent,\n 'focus': null,\n 'blur': null,\n 'input': options.logDetails ? function (e) {\n return {\n 'value': e.target.value\n };\n } : null,\n 'change': options.logDetails ? function (e) {\n return {\n 'value': e.target.value\n };\n } : null,\n 'dragstart': null,\n 'dragend': null,\n 'drag': null,\n 'drop': null,\n 'keydown': options.logDetails ? function (e) {\n return {\n 'key': e.keyCode,\n 'ctrl': e.ctrlKey,\n 'alt': e.altKey,\n 'shift': e.shiftKey,\n 'meta': e.metaKey\n };\n } : null,\n 'mouseover': null,\n 'wheel': function wheel(e) {\n return {\n 'x': e.deltaX,\n 'y': e.deltaY,\n 'z': e.deltaZ\n };\n },\n 'scroll': function scroll() {\n return {\n 'x': window.scrollX,\n 'y': window.scrollY\n };\n },\n 'resize': function resize() {\n return {\n 'width': window.outerWidth,\n 'height': window.outerHeight\n };\n },\n 'submit': null\n };\n return eventType[type];\n }\n /**\n * Hooks the event handlers for each event type of interest.\n * @param {Object} config Configuration object to use.\n * @return {boolean} Whether the operation succeeded\n */\n\n function attachHandlers(config) {\n defineDetails(config);\n Object.keys(events).forEach(function (ev) {\n document.addEventListener(ev, function (e) {\n packageLog(e, events[ev]);\n }, true);\n });\n intervalEvents.forEach(function (ev) {\n document.addEventListener(ev, function (e) {\n packageIntervalLog(e);\n }, true);\n });\n Object.keys(bufferedEvents).forEach(function (ev) {\n bufferBools[ev] = true;\n window.addEventListener(ev, function (e) {\n if (bufferBools[ev]) {\n bufferBools[ev] = false;\n packageLog(e, bufferedEvents[ev]);\n setTimeout(function () {\n bufferBools[ev] = true;\n }, config.resolution);\n }\n }, true);\n });\n Object.keys(refreshEvents).forEach(function (ev) {\n document.addEventListener(ev, function (e) {\n packageLog(e, events[ev]);\n }, true);\n });\n windowEvents.forEach(function (ev) {\n window.addEventListener(ev, function (e) {\n packageLog(e, function () {\n return {\n 'window': true\n };\n });\n }, true);\n });\n return true;\n }\n\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n var sendIntervalId = null;\n /**\n * Initializes the log queue processors.\n * @param {Array} logs Array of logs to append to.\n * @param {Object} config Configuration object to use when logging.\n */\n\n function initSender(logs, config) {\n if (sendIntervalId !== null) {\n clearInterval(sendIntervalId);\n }\n\n sendIntervalId = sendOnInterval(logs, config);\n sendOnClose(logs, config);\n }\n /**\n * Checks the provided log array on an interval, flushing the logs\n * if the queue has reached the threshold specified by the provided config.\n * @param {Array} logs Array of logs to read from.\n * @param {Object} config Configuration object to be read from.\n * @return {Number} The newly created interval id.\n */\n\n function sendOnInterval(logs, config) {\n return setInterval(function () {\n if (!config.on) {\n return;\n }\n\n if (logs.length >= config.logCountThreshold) {\n sendLogs(logs.slice(0), config, 0); // Send a copy\n\n logs.splice(0); // Clear array reference (no reassignment)\n }\n }, config.transmitInterval);\n }\n /**\n * Attempts to flush the remaining logs when the window is closed.\n * @param {Array} logs Array of logs to be flushed.\n * @param {Object} config Configuration object to be read from.\n */\n\n function sendOnClose(logs, config) {\n window.addEventListener('pagehide', function () {\n if (logs.length > 0) {\n navigator.sendBeacon(config.url, JSON.stringify(logs));\n logs.splice(0); // clear log queue\n }\n });\n }\n /**\n * Sends the provided array of logs to the specified url,\n * retrying the request up to the specified number of retries.\n * @param {Array} logs Array of logs to send.\n * @param {string} config configuration parameters (e.g., to extract URL from & send the POST request to).\n * @param {Number} retries Maximum number of attempts to send the logs.\n */\n // @todo expose config object to sendLogs replate url with config.url\n\n function sendLogs(logs, config, retries) {\n var req = new XMLHttpRequest(); // @todo setRequestHeader for Auth\n\n var data = JSON.stringify(logs);\n req.open('POST', config.url);\n\n if (config.authHeader) {\n req.setRequestHeader('Authorization', config.authHeader);\n }\n\n req.setRequestHeader('Content-type', 'application/json;charset=UTF-8');\n\n req.onreadystatechange = function () {\n if (req.readyState === 4 && req.status !== 200) {\n if (retries > 0) {\n sendLogs(logs, config, retries--);\n }\n }\n };\n\n req.send(data);\n }\n\n var config = {};\n var logs = [];\n var startLoadTimestamp = Date.now();\n var endLoadTimestamp;\n\n window.onload = function () {\n endLoadTimestamp = Date.now();\n };\n\n exports.started = false;\n\n config.on = false;\n config.useraleVersion = version$1;\n configure(config, getInitialSettings());\n initPackager(logs, config);\n\n if (config.autostart) {\n setup(config);\n }\n /**\n * Hooks the global event listener, and starts up the\n * logging interval.\n * @param {Object} config Configuration settings for the logger\n */\n\n\n function setup(config) {\n if (!exports.started) {\n setTimeout(function () {\n var state = document.readyState;\n\n if (state === 'interactive' || state === 'complete') {\n attachHandlers(config);\n initSender(logs, config);\n exports.started = config.on = true;\n packageCustomLog({\n type: 'load',\n logType: 'raw',\n pageLoadTime: endLoadTimestamp - startLoadTimestamp\n }, function () {}, false);\n } else {\n setup(config);\n }\n }, 100);\n }\n } // Export the Userale API\n\n\n var version = version$1;\n /**\n * Used to start the logging process if the\n * autostart configuration option is set to false.\n */\n\n function start() {\n if (!exports.started) {\n setup(config);\n }\n\n config.on = true;\n }\n /**\n * Halts the logging process. Logs will no longer be sent.\n */\n\n function stop() {\n config.on = false;\n }\n /**\n * Updates the current configuration\n * object with the provided values.\n * @param {Object} newConfig The configuration options to use.\n * @return {Object} Returns the updated configuration.\n */\n\n function options(newConfig) {\n if (newConfig !== undefined) {\n configure(config, newConfig);\n }\n\n return config;\n }\n /**\n * Appends a log to the log queue.\n * @param {Object} customLog The log to append.\n * @return {boolean} Whether the operation succeeded.\n */\n\n function log(customLog) {\n if (customLog !== null && _typeof(customLog) === 'object') {\n logs.push(customLog);\n return true;\n } else {\n return false;\n }\n }\n\n exports.buildPath = buildPath;\n exports.details = defineCustomDetails;\n exports.filter = setLogFilter;\n exports.getSelector = getSelector;\n exports.log = log;\n exports.map = setLogMapper;\n exports.options = options;\n exports.packageCustomLog = packageCustomLog;\n exports.packageLog = packageLog;\n exports.start = start;\n exports.stop = stop;\n exports.version = version;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n\n//# sourceURL=webpack://flagon-userale-example/./node_modules/flagon-userale/build/userale-2.2.0.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module can't be inlined because the eval devtool is used.
/******/ var __webpack_exports__ = __webpack_require__("./index.js");
/******/
/******/ })()
;