siteMapPerso

article

11/15/2023 7:39:12 PM

Changes

mySiteMap.js 56(+30 -26)

Details

mySiteMap.js 56(+30 -26)

diff --git a/mySiteMap.js b/mySiteMap.js
index bb753a1..2726642 100644
--- a/mySiteMap.js
+++ b/mySiteMap.js
@@ -1,6 +1,7 @@
 
 
 let enviroment = "";
+let pages = []
 
 esURLValida(window.location.href)
 
@@ -16,8 +17,6 @@ dateTime = `${dateTime.getDate()}/${dateTime.getMonth()}/${dateTime.getFullYear(
 let isMatch = false
 let url = ""
 
-
-
 //SELECTORES y zonas Genericos
 let globalZones = [
     { name: "Header", selector: '#page-header' },
@@ -69,19 +68,40 @@ let payWallInteractions = {
     name: "PayWall"
 }
 
-let articleInteractions = {
-    name: "Article"
-}
 
 const home = new PageType("Home", "cronista.com", homeInteractions, homeListeners, false);
 const payWall = new PageType("PayWall", `cronista.com/suscripciones`, payWallInteractions, payWallListeners, false);
-const article = new PageType("Article", window.location.href, articleInteractions, articleListeners, document.querySelector("#pagecontent .news"));
+let article = ""
+if (document.querySelector("#pagecontent .news")) {
+    console.log(window.cronistaDataLayer[0].articleProperty.id)
+    let interactions = {
+        name: SalesforceInteractions.CatalogObjectInteractionName.ViewCatalogObject,
+        catalogObject: {
+            type: "Article",
+            id: window.cronistaDataLayer[0].articleProperty.id,
+            attributes: {
+                url: window.location.href,
+                name: document.getElementById("content-title").innerText,
+                articleId: window.cronistaDataLayer[0].articleProperty.id,
+                articleTitle: document.getElementById("content-title").innerText,
+                publishDate: new Date(parseInt(window.cronistaDataLayer[0].articleProperty.datePublished)),
+                authorName: window.cronistaDataLayer[0].articleProperty.authorName,
+                canonicalUrl: window.cronistaDataLayer[0].articleProperty.canonica,
+                accessCondition: window.cronistaDataLayer[0].articleProperty.conditionsOfAccess
+            },
+        },
+    }
+    article = new PageType("Article", window.location.href, interactions, articleListeners, document.querySelector("#pagecontent .news"));
+    console.log(article.interaction)
+    pages.push(article)
+}
 
 
+//[home, payWall, article]
 function Pages() {
-    return [home, payWall, article]
+    pages.push(home, payWall, article)
+    return pages
 }
-//
 
 SalesforceInteractions.init({
     cookieDomain: "cronista.com",
@@ -120,8 +140,8 @@ SalesforceInteractions.init({
 });
 
 function PageType(name, myUrl, interaction, myEvents, isArticle) {
+    console.log(interaction)
     this.name = name;
-    this.interaction = interaction;
     this.isMatch = () => {
         let url = window.location.href;
         if (url.includes('?')) {
@@ -137,29 +157,13 @@ function PageType(name, myUrl, interaction, myEvents, isArticle) {
         }
         return isMatch;
     };
+    this.interaction = interaction;
     this.listeners = GenerateListeners(name, myEvents);
     if (name == "PayWall") {
         this.onActionEvent = (actionEvent) => {
             return PayWallActions(actionEvent);
         }
     }
-    if (isArticle) {
-        this.onActionEvent = (actionEvent) => {
-            return ArticleActions(actionEvent);
-        }
-    }
-}
-
-function ArticleActions(actionEvent) {
-    actionEvent.user = actionEvent.user || {};
-    actionEvent.user.attributes = actionEvent.user.attributes || {};
-    actionEvent.user.attributes.authorName = window.cronistaDataLayer[0].articleProperty.authorName;
-    actionEvent.user.attributes.publishDate = new Date(parseInt(window.cronistaDataLayer[0].articleProperty.datePublished));
-    actionEvent.user.attributes.articleId = window.cronistaDataLayer[0].articleProperty.id;
-    actionEvent.user.attributes.accessCondition = window.cronistaDataLayer[0].articleProperty.conditionsOfAccess;
-    actionEvent.user.attributes.canonicalUrl = window.cronistaDataLayer[0].articleProperty.canonica;
-    actionEvent.user.attributes.articleTitle = window.cronistaDataLayer[0].articleProperty.articleTitle;
-    return actionEvent;
 }
 
 function PayWallActions(actionEvent) {