1 2 3 4var stats = { 5 category: { 6 title: TITLE_NAME 7 }, 8 event: { 9 open_edition : "open edition", 10 open_newsstand : "open newsstand", 11 open_multimedia : "open multimedia", 12 flip : "change page", 13 zoom : "zoom page", 14 search : "search", 15 logout : "logout", 16 login : "login", 17 time_expired : "time expired", 18 init_checkout : "init checkout", 19 end_checkout : "end checkout", 20 station_lock : "station lock", 21 station_change : "station change", 22 user_register : "user registered", 23 recover_password: "recover password", 24 discount_code : "used discount code", 25 share : "page share", 26 open_article : "open article", 27 open_myprofile : "open my profile", 28 open_archive : "open archive newsstand", 29 search_archive : "search archive" 30 } 31} 32 33function getPageObject(pageNumber) { 34 let nextBiggerPage = null; 35 for (let i = 0; i < SUMMARY.summary.length; i++) { 36 let page = parseInt(SUMMARY.summary[i].page); 37 38 if (page === pageNumber) { 39 return SUMMARY.summary[i]; 40 } 41 if (page > pageNumber && (nextBiggerPage === null || page < nextBiggerPage.page)) { 42 nextBiggerPage = SUMMARY.summary[i]; 43 } 44 } 45 return nextBiggerPage; 46} 47 48 49function getPageSection(pageNumber) { 50 var found = {}; 51 if (SUMMARY === undefined) { 52 return found; 53 } 54 if (Object.keys(SUMMARY).length > 0) { 55 56 var pageObject = getPageObject(parseInt(pageNumber)); 57 return { 58 "section" : pageObject.section, 59 "parent_section" : pageObject.parent_section, 60 }; 61 62 // for( var i =0; i < SUMMARY.summary.length; i++) { 63 // var summaryPage = parseInt(SUMMARY.summary[i].page); 64 // pageNumber = parseInt(pageNumber ); 65 // if (summaryPage >= pageNumber) { 66 // console.log(SUMMARY.summary[i]); 67 // var section = SUMMARY.summary[i].section; 68 // var parent_section = SUMMARY.summary[i].parent_section; 69 // return { 70 // "section" : section, 71 // "parent_section" : parent_section, 72 // }; 73 // //return section; 74 // } 75 // } 76 } 77 return found; 78} 79 80 81let startTime = Date.now(); 82 83const getSecondsSinceStart = () => { 84 let seconds = Math.floor((Date.now() - startTime) / 1000); 85 if (seconds >= 180) { 86 seconds = 180; 87 } 88 return seconds; 89}; 90function push_stats(category, action, label) { 91 if (label.indexOf("@")>0) label = "xxx"; 92 if (typeof gtag == 'undefined') { 93 return; 94 } 95 96 97 var objectEvent = { 98 "edition_id": VNP.getEditionSlug(), 99 "title_id": VNP.getTitleSlug(), 100 "label": VNP.getEditionLabel(), 101 "user_id": GENERAL_USERID, 102 } 103 104 if (action.includes("open edition")) { 105 objectEvent.initialPage = 1; 106 objectEvent.readable = action=="aurhorized"; 107 gtag('event', 'open_edition', objectEvent); 108 //console.log("open edition", objectEvent) 109 } 110 111 112 113 if (action.includes("change page")) { 114 let durationOnPage = getSecondsSinceStart(); 115 objectEvent.page = label.split("-")[0]; 116 objectEvent.section = getPageSection(label.split("-")[0]).section; 117 objectEvent.parent_section = getPageSection(label.split("-")[0]).parent_section; 118 objectEvent.duration = durationOnPage*1000; 119 gtag('event', 'change_page_edition', objectEvent) 120 startTime = Date.now(); 121 //console.log(objectEvent); 122 } 123 124 if (action.includes("zoom page")) { 125 objectEvent.page = label.split("-")[0]; 126 objectEvent.section = getPageSection(label.split("-")[0]).section; 127 objectEvent.parent_section = getPageSection(label.split("-")[0]).parent_section; 128 gtag('event', 'zoom_edition', objectEvent) 129 } 130 131 if (action.includes("open multimedia")) { 132 objectEvent.link = label.split("-")[0]; 133 objectEvent.section = getPageSection(label.split("-")[0]).section; 134 objectEvent.parent_section = getPageSection(label.split("-")[0]).parent_section; 135 gtag('event', 'open_multimedia_edition', objectEvent) 136 //console.log(objectEvent); 137 } 138 139 if (action.includes("open article")) { 140 objectEvent.article_id = label.split("-")[0]; 141 objectEvent.section = getPageSection(label.split("-")[0]).section; 142 objectEvent.parent_section = getPageSection(label.split("-")[0]).parent_section; 143 gtag('event', 'open_article_edition', objectEvent) 144 // console.log(objectEvent); 145 } 146 147 /* 148 *
149 * open_edition (edition_id: id,title_id: title_id, label: label, inital_page: page, readable: bool) 150⢠change_page_edition (edition_id: id,title_id: title_id, label: label, page: page) 151⢠add_favorite (edition_id: id,title_id: title_id, label: label, page: page) 152⢠share_edition (edition_id: id,title_id: title_id, label: label, page : page) 153⢠zoom_edition (edition_id: id,title_id: title_id, label: label, page: page) 154⢠open_edition_link (edition_id: id,title_id: title_id, label: label, link: link) 155⢠open_article_edition (edition_id: id,title_id: title_id, label: label, article_id: id) 156⢠open_multimedia_edition (edition_id: id,title_id: title_id, label: label, link: multimedia) 157⢠Purchase (only iOS & Android Native) 158⢠purchase_start (product_id : product_id , edition_id: edition_id?) 159⢠purchase_end (product_id : product_id , status: status, edition_id: edition_id?) 160⢠purchase_restore () 161⢠Purchase WebView (only Android) 162⢠purchase_webview (id_edition: id_edition?) 163 * */ 164 console.log(objectEvent); 165 console.log("cat: "+ category, "act:" + action, "label: "+ label); 166}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.