This is an automated email from the ASF dual-hosted git repository.

jkevan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/unomi-tracker.git


The following commit(s) were added to refs/heads/main by this push:
     new b7d9715  UNOMI-665: allow for force reloading of the context (#5)
b7d9715 is described below

commit b7d9715427b369afccd78f54b83173cd350263de
Author: kevan Jahanshahi <[email protected]>
AuthorDate: Wed Sep 14 19:15:37 2022 +0200

    UNOMI-665: allow for force reloading of the context (#5)
---
 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;
             }

Reply via email to