This is an automated email from the ASF dual-hosted git repository. jkevan pushed a commit to branch UNOMI-665-allow-ctx-reload in repository https://gitbox.apache.org/repos/asf/unomi-tracker.git
commit 1d187b99f1d4ee4d0c5308bb8fcc13e53dc5b9c8 Author: Kevan <[email protected]> AuthorDate: Wed Sep 14 18:10:52 2022 +0200 UNOMI-665: allow for force reloading of the context --- dist/apache-unomi-tracker.cjs.js | 10 ++++++++-- dist/apache-unomi-tracker.esm.js | 10 ++++++++-- dist/apache-unomi-tracker.umd.js | 10 ++++++++-- src/tracker/tracker.js | 6 ++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dist/apache-unomi-tracker.cjs.js b/dist/apache-unomi-tracker.cjs.js index 18f70c9..facc450 100644 --- a/dist/apache-unomi-tracker.cjs.js +++ b/dist/apache-unomi-tracker.cjs.js @@ -316,10 +316,16 @@ var newTracker = function newTracker() { * * @param {boolean} [skipEvents=false] Should we send the events * @param {boolean} [invalidate=false] Should we invalidate the current context + * @param {boolean} [forceReload=false] This function contains an internal check to avoid loading of the context multiple times. + * But in some rare cases, it could be useful to force the reloading of the context and bypass the check. * @return {undefined} */ - loadContext: function loadContext(skipEvents, invalidate) { - if (wem.contextLoaded) { + loadContext: function loadContext() { + var skipEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var invalidate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var forceReload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + if (wem.contextLoaded && !forceReload) { console.log('Context already requested by', wem.contextLoaded); return; } diff --git a/dist/apache-unomi-tracker.esm.js b/dist/apache-unomi-tracker.esm.js index bcb7ba8..00c6ef6 100644 --- a/dist/apache-unomi-tracker.esm.js +++ b/dist/apache-unomi-tracker.esm.js @@ -308,10 +308,16 @@ var newTracker = function newTracker() { * * @param {boolean} [skipEvents=false] Should we send the events * @param {boolean} [invalidate=false] Should we invalidate the current context + * @param {boolean} [forceReload=false] This function contains an internal check to avoid loading of the context multiple times. + * But in some rare cases, it could be useful to force the reloading of the context and bypass the check. * @return {undefined} */ - loadContext: function loadContext(skipEvents, invalidate) { - if (wem.contextLoaded) { + loadContext: function loadContext() { + var skipEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var invalidate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var forceReload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + if (wem.contextLoaded && !forceReload) { console.log('Context already requested by', wem.contextLoaded); return; } diff --git a/dist/apache-unomi-tracker.umd.js b/dist/apache-unomi-tracker.umd.js index f81047a..d4e3b88 100644 --- a/dist/apache-unomi-tracker.umd.js +++ b/dist/apache-unomi-tracker.umd.js @@ -1963,10 +1963,16 @@ * * @param {boolean} [skipEvents=false] Should we send the events * @param {boolean} [invalidate=false] Should we invalidate the current context + * @param {boolean} [forceReload=false] This function contains an internal check to avoid loading of the context multiple times. + * But in some rare cases, it could be useful to force the reloading of the context and bypass the check. * @return {undefined} */ - loadContext: function loadContext(skipEvents, invalidate) { - if (wem.contextLoaded) { + loadContext: function loadContext() { + var skipEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var invalidate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var forceReload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + if (wem.contextLoaded && !forceReload) { console.log('Context already requested by', wem.contextLoaded); return; } diff --git a/src/tracker/tracker.js b/src/tracker/tracker.js index 2617119..1ffbf7b 100644 --- a/src/tracker/tracker.js +++ b/src/tracker/tracker.js @@ -301,10 +301,12 @@ export const newTracker = () => { * * @param {boolean} [skipEvents=false] Should we send the events * @param {boolean} [invalidate=false] Should we invalidate the current context + * @param {boolean} [forceReload=false] This function contains an internal check to avoid loading of the context multiple times. + * But in some rare cases, it could be useful to force the reloading of the context and bypass the check. * @return {undefined} */ - loadContext: function (skipEvents, invalidate) { - if (wem.contextLoaded) { + loadContext: function (skipEvents = false, invalidate = false, forceReload = false) { + if (wem.contextLoaded && !forceReload) { console.log('Context already requested by', wem.contextLoaded); return; }
