siteMapPerso

se agrego name y lastName

11/21/2023 3:28:57 PM

Changes

mySiteMap.js 80(+43 -37)

Details

mySiteMap.js 80(+43 -37)

diff --git a/mySiteMap.js b/mySiteMap.js
index 40e3820..4107096 100644
--- a/mySiteMap.js
+++ b/mySiteMap.js
@@ -6,7 +6,8 @@ esURLValida(window.location.href)
 //DATOS DE USUARIO
 const email = vsm.session.email != "" ? vsm.session.email : "";
 const idUser = vsm.session.id != "" ? vsm.session.id : "";
-const userName = vsm.session.title != "" ? vsm.session.title : "";
+const firstName = vsm.session.name != "" ? vsm.session.name : "";
+const lastName = vsm.session.lastName != "" ? vsm.session.lastName : "";
 const isSuscriber = site.session.isSuscriber() && site.session != undefined ? "Suscriptor" : "Usuario";
 let dateTime = new Date();
 dateTime = `${dateTime.getDate()}/${dateTime.getMonth()}/${dateTime.getFullYear()} - hora ${dateTime.getHours()}:${dateTime.getMinutes()}`
@@ -112,42 +113,6 @@ function Pages() {
     return pages
 }
 
-SalesforceInteractions.init({
-    cookieDomain: "cronista.com",
-}).then(() => {
-    const sitemapConfig = {
-        global: {
-            onActionEvent: (actionEvent) => {
-                url = window.location.href
-                if (email) {
-                    actionEvent.user = actionEvent.user || {};
-                    actionEvent.user.attributes = actionEvent.user.attributes || {};
-                    actionEvent.user.identities = actionEvent.user.identities || {};
-                    actionEvent.user.attributes.URL || {};
-                    actionEvent.user.attributes.contentZones || {};
-                    actionEvent.user.attributes.emailAddress = email;
-                    actionEvent.user.attributes.isSuscription = isSuscriber;
-                    actionEvent.user.attributes.name = userName;
-                    actionEvent.user.attributes.lastName = userName;
-                    actionEvent.user.attributes.date = dateTime
-                    actionEvent.user.identities.userIdCms = idUser;
-                }
-                return actionEvent;
-            },
-            contentZones: GenerateContentZones(globalZones),
-            listeners: GenerateListeners("Global", globalListeners),
-        },
-        pageTypeDefault: {
-            name: "default",
-            interaction: {
-                name: "Default Page",
-            }
-        },
-        pageTypes: Pages()
-    };
-    SalesforceInteractions.initSitemap(sitemapConfig);
-});
-
 function PageType(name, myUrl, interaction, myEvents, isArticle) {
     this.name = name;
     this.isMatch = () => {
@@ -174,6 +139,24 @@ function PageType(name, myUrl, interaction, myEvents, isArticle) {
     }
 }
 
+function GlobalActions(actionEvent) {
+    url = window.location.href
+    if (email) {
+        actionEvent.user = actionEvent.user || {};
+        actionEvent.user.attributes = actionEvent.user.attributes || {};
+        actionEvent.user.identities = actionEvent.user.identities || {};
+        actionEvent.user.attributes.URL || {};
+        actionEvent.user.attributes.contentZones || {};
+        actionEvent.user.attributes.emailAddress = email;
+        actionEvent.user.attributes.isSuscription = isSuscriber;
+        actionEvent.user.attributes.name = firstName;
+        actionEvent.user.attributes.lastName = lastName;
+        actionEvent.user.attributes.date = dateTime
+        actionEvent.user.identities.userIdCms = idUser;
+    }
+    return actionEvent;
+}
+
 function PayWallActions(actionEvent) {
     let limit = new URL(window.location.href).searchParams.get("limit")
     actionEvent.user = actionEvent.user || {};
@@ -298,3 +281,26 @@ function esURLValida(url) {
     enviroment = regex[0]
 }
 
+
+SalesforceInteractions.init({
+    cookieDomain: "cronista.com",
+}).then(() => {
+    const sitemapConfig = {
+        global: {
+            onActionEvent: (actionEvent) => {
+                return GlobalActions(actionEvent);
+            },
+            contentZones: GenerateContentZones(globalZones),
+            listeners: GenerateListeners("Global", globalListeners),
+        },
+        pageTypeDefault: {
+            name: "default",
+            interaction: {
+                name: "Default Page",
+            }
+        },
+        pageTypes: Pages()
+    };
+    SalesforceInteractions.initSitemap(sitemapConfig);
+});
+