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

dgriffon pushed a commit to branch fix-variant-without-event
in repository https://gitbox.apache.org/repos/asf/unomi-tracker.git

commit 36389af0156e4ebd8cce43ec71767b73ba180c20
Author: David Griffon <[email protected]>
AuthorDate: Thu Sep 7 17:48:46 2023 +0200

    UNOMI-803 : allow empty event within a variant
---
 dist/apache-unomi-tracker.cjs.js     | 43 +++++++++++++++++++-----------------
 dist/apache-unomi-tracker.cjs.js.map |  2 +-
 dist/apache-unomi-tracker.esm.js     | 43 +++++++++++++++++++-----------------
 dist/apache-unomi-tracker.esm.js.map |  2 +-
 dist/apache-unomi-tracker.umd.js     | 43 +++++++++++++++++++-----------------
 dist/apache-unomi-tracker.umd.js.map |  2 +-
 src/apache-unomi-tracker.js          | 33 +++++++++++++--------------
 7 files changed, 89 insertions(+), 79 deletions(-)

diff --git a/dist/apache-unomi-tracker.cjs.js b/dist/apache-unomi-tracker.cjs.js
index 18250e5..e0491d7 100644
--- a/dist/apache-unomi-tracker.cjs.js
+++ b/dist/apache-unomi-tracker.cjs.js
@@ -229,28 +229,30 @@ var newTracker = function newTracker() {
               if (filter) {
                 filter.style.display = filter.id === selectedFilter.content ? 
'' : 'none';
               }
-            } // we now add control group information to event if the user is 
in the control group.
-
+            }
 
-            if (inControlGroup) {
-              console.info('[WEM] Profile is in control group for target: ' + 
target + ', adding to personalization event...');
-              selectedFilter.event.target.properties.inControlGroup = true;
+            if (selectedFilter.event) {
+              // we now add control group information to event if the user is 
in the control group.
+              if (inControlGroup) {
+                console.info('[WEM] Profile is in control group for target: ' 
+ target + ', adding to personalization event...');
+                selectedFilter.event.target.properties.inControlGroup = true;
 
-              if (selectedFilter.event.target.properties.variants) {
-                
selectedFilter.event.target.properties.variants.forEach(function (variant) {
-                  return variant.inControlGroup = true;
-                });
-              }
-            } // send event to unomi
+                if (selectedFilter.event.target.properties.variants) {
+                  
selectedFilter.event.target.properties.variants.forEach(function (variant) {
+                    return variant.inControlGroup = true;
+                  });
+                }
+              } // send event to unomi
 
 
-            wem.collectEvent(wem._completeEvent(selectedFilter.event), 
function () {
-              console.info('[WEM] Personalization event successfully 
collected.');
-            }, function () {
-              console.error('[WEM] Could not send personalization event.');
-            }); //Trigger variant display event for personalization
+              wem.collectEvent(wem._completeEvent(selectedFilter.event), 
function () {
+                console.info('[WEM] Personalization event successfully 
collected.');
+              }, function () {
+                console.error('[WEM] Could not send personalization event.');
+              }); //Trigger variant display event for personalization
 
-            wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+              wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+            }
           } else {
             var elements = document.getElementById(target).children;
 
@@ -634,7 +636,8 @@ var newTracker = function newTracker() {
         expires = '; expires=' + d.toUTCString();
       }
 
-      document.cookie = cookieName + '=' + cookieValue + expires + '; path=/; 
SameSite=Strict';
+      var secure = location.protocol === 'https:' ? '; secure' : '';
+      document.cookie = cookieName + '=' + cookieValue + expires + '; path=/; 
SameSite=Strict' + secure;
     },
 
     /**
@@ -1520,8 +1523,8 @@ var newTracker = function newTracker() {
 
       if (!enable) {
         wem.cxs = {};
-        document.cookie = wem.trackerProfileIdCookieName + '=; expires=Thu, 01 
Jan 1970 00:00:00 UTC; path=/;';
-        document.cookie = wem.contextServerCookieName + '=; expires=Thu, 01 
Jan 1970 00:00:00 UTC; path=/;';
+        wem.removeCookie(wem.contextServerCookieName);
+        wem.removeCookie(wem.trackerProfileIdCookieName);
         delete wem.contextLoaded;
       } else {
         if (wem.DOMLoaded) {
diff --git a/dist/apache-unomi-tracker.cjs.js.map 
b/dist/apache-unomi-tracker.cjs.js.map
index 831e2f4..c5c12d1 100644
--- a/dist/apache-unomi-tracker.cjs.js.map
+++ b/dist/apache-unomi-tracker.cjs.js.map
@@ -1 +1 @@
-{"version":3,"file":"apache-unomi-tracker.cjs.js","sources":["../src/apache-unomi-tracker.js","../src/index.js"],"sourcesContent":["/*\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 compl [...]
\ No newline at end of file
+{"version":3,"file":"apache-unomi-tracker.cjs.js","sources":["../src/apache-unomi-tracker.js","../src/index.js"],"sourcesContent":["/*\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 compl [...]
\ No newline at end of file
diff --git a/dist/apache-unomi-tracker.esm.js b/dist/apache-unomi-tracker.esm.js
index 256537c..f63d7e7 100644
--- a/dist/apache-unomi-tracker.esm.js
+++ b/dist/apache-unomi-tracker.esm.js
@@ -221,28 +221,30 @@ var newTracker = function newTracker() {
               if (filter) {
                 filter.style.display = filter.id === selectedFilter.content ? 
'' : 'none';
               }
-            } // we now add control group information to event if the user is 
in the control group.
-
+            }
 
-            if (inControlGroup) {
-              console.info('[WEM] Profile is in control group for target: ' + 
target + ', adding to personalization event...');
-              selectedFilter.event.target.properties.inControlGroup = true;
+            if (selectedFilter.event) {
+              // we now add control group information to event if the user is 
in the control group.
+              if (inControlGroup) {
+                console.info('[WEM] Profile is in control group for target: ' 
+ target + ', adding to personalization event...');
+                selectedFilter.event.target.properties.inControlGroup = true;
 
-              if (selectedFilter.event.target.properties.variants) {
-                
selectedFilter.event.target.properties.variants.forEach(function (variant) {
-                  return variant.inControlGroup = true;
-                });
-              }
-            } // send event to unomi
+                if (selectedFilter.event.target.properties.variants) {
+                  
selectedFilter.event.target.properties.variants.forEach(function (variant) {
+                    return variant.inControlGroup = true;
+                  });
+                }
+              } // send event to unomi
 
 
-            wem.collectEvent(wem._completeEvent(selectedFilter.event), 
function () {
-              console.info('[WEM] Personalization event successfully 
collected.');
-            }, function () {
-              console.error('[WEM] Could not send personalization event.');
-            }); //Trigger variant display event for personalization
+              wem.collectEvent(wem._completeEvent(selectedFilter.event), 
function () {
+                console.info('[WEM] Personalization event successfully 
collected.');
+              }, function () {
+                console.error('[WEM] Could not send personalization event.');
+              }); //Trigger variant display event for personalization
 
-            wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+              wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+            }
           } else {
             var elements = document.getElementById(target).children;
 
@@ -626,7 +628,8 @@ var newTracker = function newTracker() {
         expires = '; expires=' + d.toUTCString();
       }
 
-      document.cookie = cookieName + '=' + cookieValue + expires + '; path=/; 
SameSite=Strict';
+      var secure = location.protocol === 'https:' ? '; secure' : '';
+      document.cookie = cookieName + '=' + cookieValue + expires + '; path=/; 
SameSite=Strict' + secure;
     },
 
     /**
@@ -1512,8 +1515,8 @@ var newTracker = function newTracker() {
 
       if (!enable) {
         wem.cxs = {};
-        document.cookie = wem.trackerProfileIdCookieName + '=; expires=Thu, 01 
Jan 1970 00:00:00 UTC; path=/;';
-        document.cookie = wem.contextServerCookieName + '=; expires=Thu, 01 
Jan 1970 00:00:00 UTC; path=/;';
+        wem.removeCookie(wem.contextServerCookieName);
+        wem.removeCookie(wem.trackerProfileIdCookieName);
         delete wem.contextLoaded;
       } else {
         if (wem.DOMLoaded) {
diff --git a/dist/apache-unomi-tracker.esm.js.map 
b/dist/apache-unomi-tracker.esm.js.map
index 7744392..124a17e 100644
--- a/dist/apache-unomi-tracker.esm.js.map
+++ b/dist/apache-unomi-tracker.esm.js.map
@@ -1 +1 @@
-{"version":3,"file":"apache-unomi-tracker.esm.js","sources":["../src/apache-unomi-tracker.js","../src/index.js"],"sourcesContent":["/*\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 compl [...]
\ No newline at end of file
+{"version":3,"file":"apache-unomi-tracker.esm.js","sources":["../src/apache-unomi-tracker.js","../src/index.js"],"sourcesContent":["/*\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 compl [...]
\ No newline at end of file
diff --git a/dist/apache-unomi-tracker.umd.js b/dist/apache-unomi-tracker.umd.js
index de8d511..29af405 100644
--- a/dist/apache-unomi-tracker.umd.js
+++ b/dist/apache-unomi-tracker.umd.js
@@ -1876,28 +1876,30 @@
                 if (filter) {
                   filter.style.display = filter.id === selectedFilter.content 
? '' : 'none';
                 }
-              } // we now add control group information to event if the user 
is in the control group.
-
+              }
 
-              if (inControlGroup) {
-                console.info('[WEM] Profile is in control group for target: ' 
+ target + ', adding to personalization event...');
-                selectedFilter.event.target.properties.inControlGroup = true;
+              if (selectedFilter.event) {
+                // we now add control group information to event if the user 
is in the control group.
+                if (inControlGroup) {
+                  console.info('[WEM] Profile is in control group for target: 
' + target + ', adding to personalization event...');
+                  selectedFilter.event.target.properties.inControlGroup = true;
 
-                if (selectedFilter.event.target.properties.variants) {
-                  
selectedFilter.event.target.properties.variants.forEach(function (variant) {
-                    return variant.inControlGroup = true;
-                  });
-                }
-              } // send event to unomi
+                  if (selectedFilter.event.target.properties.variants) {
+                    
selectedFilter.event.target.properties.variants.forEach(function (variant) {
+                      return variant.inControlGroup = true;
+                    });
+                  }
+                } // send event to unomi
 
 
-              wem.collectEvent(wem._completeEvent(selectedFilter.event), 
function () {
-                console.info('[WEM] Personalization event successfully 
collected.');
-              }, function () {
-                console.error('[WEM] Could not send personalization event.');
-              }); //Trigger variant display event for personalization
+                wem.collectEvent(wem._completeEvent(selectedFilter.event), 
function () {
+                  console.info('[WEM] Personalization event successfully 
collected.');
+                }, function () {
+                  console.error('[WEM] Could not send personalization event.');
+                }); //Trigger variant display event for personalization
 
-              wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+                wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+              }
             } else {
               var elements = document.getElementById(target).children;
 
@@ -2281,7 +2283,8 @@
           expires = '; expires=' + d.toUTCString();
         }
 
-        document.cookie = cookieName + '=' + cookieValue + expires + '; 
path=/; SameSite=Strict';
+        var secure = location.protocol === 'https:' ? '; secure' : '';
+        document.cookie = cookieName + '=' + cookieValue + expires + '; 
path=/; SameSite=Strict' + secure;
       },
 
       /**
@@ -3167,8 +3170,8 @@
 
         if (!enable) {
           wem.cxs = {};
-          document.cookie = wem.trackerProfileIdCookieName + '=; expires=Thu, 
01 Jan 1970 00:00:00 UTC; path=/;';
-          document.cookie = wem.contextServerCookieName + '=; expires=Thu, 01 
Jan 1970 00:00:00 UTC; path=/;';
+          wem.removeCookie(wem.contextServerCookieName);
+          wem.removeCookie(wem.trackerProfileIdCookieName);
           delete wem.contextLoaded;
         } else {
           if (wem.DOMLoaded) {
diff --git a/dist/apache-unomi-tracker.umd.js.map 
b/dist/apache-unomi-tracker.umd.js.map
index efb77c4..184cacc 100644
--- a/dist/apache-unomi-tracker.umd.js.map
+++ b/dist/apache-unomi-tracker.umd.js.map
@@ -1 +1 @@
-{"version":3,"file":"apache-unomi-tracker.umd.js","sources":["../node_modules/@babel/runtime/helpers/esm/typeof.js","../node_modules/es6-crawler-detect/src/lib/crawler/provider.js","../node_modules/es6-crawler-detect/src/lib/crawler/crawlers.js","../node_modules/es6-crawler-detect/src/lib/crawler/exclusions.js","../node_modules/es6-crawler-detect/src/lib/crawler/headers.js","../node_modules/es6-crawler-detect/src/lib/crawler.js","../node_modules/es6-crawler-detect/src/index.js","../src/a
 [...]
\ No newline at end of file
+{"version":3,"file":"apache-unomi-tracker.umd.js","sources":["../node_modules/@babel/runtime/helpers/esm/typeof.js","../node_modules/es6-crawler-detect/src/lib/crawler/provider.js","../node_modules/es6-crawler-detect/src/lib/crawler/crawlers.js","../node_modules/es6-crawler-detect/src/lib/crawler/exclusions.js","../node_modules/es6-crawler-detect/src/lib/crawler/headers.js","../node_modules/es6-crawler-detect/src/lib/crawler.js","../node_modules/es6-crawler-detect/src/index.js","../src/a
 [...]
\ No newline at end of file
diff --git a/src/apache-unomi-tracker.js b/src/apache-unomi-tracker.js
index 3207722..9d17075 100644
--- a/src/apache-unomi-tracker.js
+++ b/src/apache-unomi-tracker.js
@@ -207,25 +207,26 @@ export const newTracker = () => {
                                 filter.style.display = (filter.id === 
selectedFilter.content) ? '' : 'none';
                             }
                         }
-
-                        // we now add control group information to event if 
the user is in the control group.
-                        if (inControlGroup) {
-                            console.info('[WEM] Profile is in control group 
for target: ' + target + ', adding to personalization event...');
-                            
selectedFilter.event.target.properties.inControlGroup = true;
-                            if 
(selectedFilter.event.target.properties.variants) {
-                                
selectedFilter.event.target.properties.variants.forEach(variant => 
variant.inControlGroup = true);
+                        if (selectedFilter.event) {
+                            // we now add control group information to event 
if the user is in the control group.
+                            if (inControlGroup) {
+                                console.info('[WEM] Profile is in control 
group for target: ' + target + ', adding to personalization event...');
+                                
selectedFilter.event.target.properties.inControlGroup = true;
+                                if 
(selectedFilter.event.target.properties.variants) {
+                                    
selectedFilter.event.target.properties.variants.forEach(variant => 
variant.inControlGroup = true);
+                                }
                             }
-                        }
 
-                        // send event to unomi
-                        
wem.collectEvent(wem._completeEvent(selectedFilter.event), function () {
-                            console.info('[WEM] Personalization event 
successfully collected.');
-                        }, function () {
-                            console.error('[WEM] Could not send 
personalization event.');
-                        });
+                            // send event to unomi
+                            
wem.collectEvent(wem._completeEvent(selectedFilter.event), function () {
+                                console.info('[WEM] Personalization event 
successfully collected.');
+                            }, function () {
+                                console.error('[WEM] Could not send 
personalization event.');
+                            });
 
-                        //Trigger variant display event for personalization
-                        
wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+                            //Trigger variant display event for personalization
+                            
wem._dispatchJSExperienceDisplayedEvent(selectedFilter.event);
+                        }
                     } else {
                         var elements = 
document.getElementById(target).children;
                         for (var eIndex in elements) {

Reply via email to