This is an automated email from the ASF dual-hosted git repository. poorejc pushed a commit to branch setupStartStopRefactor in repository https://gitbox.apache.org/repos/asf/incubator-flagon-useralejs.git
commit c482c26b17791130eb77dba32318d352ed560e23 Author: poorejc <[email protected]> AuthorDate: Fri Mar 25 02:29:09 2022 -0400 setup, start, stop refactor --- build/UserALEWebExtension/content.js | 25 +++++++++++++++++++++---- build/userale-2.2.0.js | 22 ++++++++++++++-------- build/userale-2.2.0.min.js | 2 +- example/index.js | 1 + example/webpackUserAleExample/dist/main.js | 2 +- src/main.js | 14 +++++++------- 6 files changed, 45 insertions(+), 21 deletions(-) diff --git a/build/UserALEWebExtension/content.js b/build/UserALEWebExtension/content.js index 29b4df2..ac2a1c0 100644 --- a/build/UserALEWebExtension/content.js +++ b/build/UserALEWebExtension/content.js @@ -180,6 +180,8 @@ function timeStampScale(e) { * @param {Object} newConfig Configuration object to merge into the current config. */ function configure(config, newConfig) { + var configAutostart = config['autostart']; + var newConfigAutostart = newConfig['autostart']; Object.keys(newConfig).forEach(function (option) { if (option === 'userFromParams') { var userId = getUserIdFromParams(newConfig[option]); @@ -191,6 +193,10 @@ function configure(config, newConfig) { config[option] = newConfig[option]; }); + + if (configAutostart === false || newConfigAutostart === false) { + config['autostart'] = false; + } } /** * Attempts to extract the userid from the query parameters of the URL. @@ -1036,22 +1042,33 @@ function setup(config) { setTimeout(function () { var state = document.readyState; - if (state === 'interactive' || state === 'complete') { + if (config.autostart && (state === 'interactive' || state === 'complete')) { attachHandlers(config); - initSender(logs, config); - started = config.on = true; + start(); packageCustomLog({ type: 'load', logType: 'raw', pageLoadTime: endLoadTimestamp - startLoadTimestamp }, function () {}, false); } else { - setup(config); + attachHandlers(config); } }, 100); } } // Export the Userale API /** + * Used to start the logging process if the + * autostart configuration option is set to false. + */ + +function start() { + if (!started) { + initSender(logs, config); + started = config.on = true; + config.autostart = true; + } +} +/** * Updates the current configuration * object with the provided values. * @param {Object} newConfig The configuration options to use. diff --git a/build/userale-2.2.0.js b/build/userale-2.2.0.js index f61d08c..1eea6e0 100644 --- a/build/userale-2.2.0.js +++ b/build/userale-2.2.0.js @@ -168,6 +168,8 @@ * @param {Object} newConfig Configuration object to merge into the current config. */ function configure(config, newConfig) { + var configAutostart = config['autostart']; + var newConfigAutostart = newConfig['autostart']; Object.keys(newConfig).forEach(function (option) { if (option === 'userFromParams') { var userId = getUserIdFromParams(newConfig[option]); @@ -179,6 +181,10 @@ config[option] = newConfig[option]; }); + + if (configAutostart === false || newConfigAutostart === false) { + config['autostart'] = false; + } } /** * Attempts to extract the userid from the query parameters of the URL. @@ -1097,17 +1103,16 @@ setTimeout(function () { var state = document.readyState; - if (state === 'interactive' || state === 'complete') { + if (config.autostart && (state === 'interactive' || state === 'complete')) { attachHandlers(config); - initSender(logs, config); - exports.started = config.on = true; + start(); packageCustomLog({ type: 'load', logType: 'raw', pageLoadTime: endLoadTimestamp - startLoadTimestamp }, function () {}, false); } else { - setup(config); + attachHandlers(config); } }, 100); } @@ -1122,17 +1127,18 @@ function start() { if (!exports.started) { - setup(config); + initSender(logs, config); + exports.started = config.on = true; + config.autostart = true; } - - config.on = true; } /** * Halts the logging process. Logs will no longer be sent. */ function stop() { - config.on = false; + exports.started = config.on = false; + config.autostart = false; } /** * Updates the current configuration diff --git a/build/userale-2.2.0.min.js b/build/userale-2.2.0.min.js index 675bf81..155bc73 100644 --- a/build/userale-2.2.0.min.js +++ b/build/userale-2.2.0.min.js @@ -16,4 +16,4 @@ * @preserved */ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).userale={})}(this,(function(e){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}var t="2.2.0",o=null;fu [...] +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).userale={})}(this,(function(e){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}var n="2.2.0",o=null;fu [...] diff --git a/example/index.js b/example/index.js index 21d5113..d75323a 100644 --- a/example/index.js +++ b/example/index.js @@ -21,6 +21,7 @@ const changeMe = "me"; window.userale.options({ 'userId': changeMe, + 'autostart': true, 'logDetails': true, 'toolName': 'Apache UserALE.js Example (Custom)' }); diff --git a/example/webpackUserAleExample/dist/main.js b/example/webpackUserAleExample/dist/main.js index 6c02a0d..60615d1 100644 --- a/example/webpackUserAleExample/dist/main.js +++ b/example/webpackUserAleExample/dist/main.js @@ -16,7 +16,7 @@ /***/ ((__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. [...] +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. [...] /***/ }), diff --git a/src/main.js b/src/main.js index 5ca5386..d0ec10c 100644 --- a/src/main.js +++ b/src/main.js @@ -65,15 +65,14 @@ function setup(config) { if (config.autostart && (state === 'interactive' || state === 'complete')) { attachHandlers(config); - initSender(logs, config); - started = config.on = true; + start(); packageCustomLog({ type: 'load', logType: 'raw', pageLoadTime: endLoadTimestamp - startLoadTimestamp }, () => {},false) } else { - setup(config); + attachHandlers(config); } }, 100); } @@ -89,17 +88,18 @@ export const version = userAleVersion; */ export function start() { if (!started) { - setup(config); + initSender(logs, config); + started = config.on = true; + config.autostart = true; } - - config.on = true; } /** * Halts the logging process. Logs will no longer be sent. */ export function stop() { - config.on = false; + started = config.on = false; + config.autostart = false; } /**
