1var loadStart = new Date().getTime(); 2var loadEnd; 3var activityTimeout; 4var ua = UAParser(navigator.userAgent); 5 6function activityCheck() { 7 if (window.self === window.top) { 8 clearTimeout(activityTimeout); 9 10 activityTimeout = setTimeout(function () { 11 slickInsertAnalytics({ 12 type: "endsession", 13 }); 14 }, 300000); 15 } 16} 17 18function slickInsertAnalytics(data) { 19 if (window.self === window.top && window.location.hostname !== "localhost") { 20 data.domain = window.location.hostname.replace("www.", ""); 21 data.url = 22 window.location.pathname + window.location.search + window.location.hash; 23 data.referrer = document.referrer; 24 data.user_language = navigator.language; 25 data.user_agent = navigator.userAgent; 26 data.os = ua.os.name; 27 data.browser = ua.browser.name; 28 data.browser_version = ua.browser.version; 29 data.device_type = ua.device.type || "desktop"; 30 data.device_vendor = ua.device.vendor || null; 31 data.device_model = ua.device.model || null; 32 33 var xhr = new XMLHttpRequest(); 34 xhr.open("POST", "/s/scripts/get-ip"); 35 xhr.onload = function () { 36 var res = JSON.parse(this.response); 37 38 if (res && res.status === "Success") { 39 var ip = res.ip; 40 41 if (ip !== "::1" && ip !== "127.0.0.1" && ip !== "localhost") { 42 var xhr2 = new XMLHttpRequest(); 43 xhr2.open("GET", "https://ipapi.co/" + ip + "/json/"); 44 xhr2.onload = function () { 45 var res = JSON.parse(this.response); 46 47 if (res.city) { 48 data.city = res.city; 49 data.region = res.region; 50 data.region_code = res.region_code; 51 data.country = res.country_name; 52 data.country_code = res.country_code_iso3; 53 data.latitude = res.latitude; 54 data.longitude = res.longitude; 55 } else { 56 console.warn("IP API Error"); 57 } 58 59 var xhr3 = new XMLHttpRequest(); 60 xhr3.open("POST", "/s/scripts/analytics"); 61 xhr3.setRequestHeader("Content-Type", "application/json"); 62 xhr3.send(JSON.stringify(data)); 63 }; 64 xhr2.send(); 65 } else { 66 var xhr3 = new XMLHttpRequest(); 67 xhr3.open("POST", "/s/scripts/analytics"); 68 xhr3.setRequestHeader("Content-Type", "application/json"); 69 xhr3.send(JSON.stringify(data)); 70 } 71 } else { 72 console.warn("Get IP Error"); 73 74 var xhr3 = new XMLHttpRequest(); 75 xhr3.open("POST", "/s/scripts/analytics"); 76 xhr3.setRequestHeader("Content-Type", "application/json"); 77 xhr3.send(JSON.stringify(data)); 78 } 79 }; 80 xhr.send(); 81 } 82} 83 84function slickEvent(options) { 85 if (window.self === window.top) { 86 var data = { 87 type: "event", 88 }; 89 90 for (var key in options) { 91 data[key] = options[key]; 92 } 93 94 slickInsertAnalytics(data); 95 } 96} 97 98function slickError(options) { 99 if (window.self === window.top) { 100 var data = { 101 type: "error", 102 }; 103 104 for (var key in options) { 105 data[key] = options[key]; 106 } 107 108 slickInsertAnalytics(data); 109 } 110} 111 112window.addEventListener( 113 "error", 114 function (e) { 115 if (window.self === window.top) { 116 console.log("error: ", e); 117 } 118 }, 119 true 120); 121 122window.addEventListener("load", function (e) { 123 if (window.self === window.top) { 124 loadEnd = new Date().getTime(); 125 126 slickInsertAnalytics({ 127 type: "pageview", 128 page_load: (loadEnd - loadStart) / 1000, 129 duration: 0, 130 }); 131 132 activityCheck(); 133 } 134}); 135 136window.addEventListener("mousemove", activityCheck); 137window.addEventListener("touchend", activityCheck); 138window.addEventListener("keyup", activityCheck); 139window.addEventListener("scroll", activityCheck);
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.