Skip to content

Commit

Permalink
Chore: Update Statslite endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaneu authored Jun 27, 2024
1 parent fa36365 commit 8c9c630
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion build/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
})(window, document, "clarity", "script", "h5cwyu0xu4");

var sl=function(e){"use strict";class t{constructor(e,t){this.e=e,this.ts=new Date,this.p=t}}class i extends t{constructor(e,t=window.location.href,i=document.referrer){super("$pv",e),this.p=Object.assign(this.p,{url:t,referrer:i})}}return e.StatsliteClient=class{constructor(e,t,i=!0){this.customProperties={},this.globalProperties={},this.siteId=e,this.serviceEndpoint=t,this.globalProperties={sessionId:this.generateUuid()},i&&this.registerAutoEventTracking()}registerAutoEventTracking(){window.addEventListener("popstate",(()=>this.trackPageView())),window.addEventListener("hashchange",(()=>this.trackPageView()))}trackPageView(){let e=new i({},window.location.href,document.referrer);e=this.enrichEvent(e),this.sendEvent(e)}sendEvent(e){console.log("Sending event",e),fetch(`${this.serviceEndpoint}/${this.siteId}/collect`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then((e=>{e.ok})).catch((e=>{console.error("Network error:",e)}))}enrichEvent(e){Object.assign(e.p,this.customProperties),Object.assign(e.p,this.globalProperties);var t={browser:navigator.userAgent,screenWidth:window.screen.width,screenHeight:window.screen.height,language:navigator.language,timestamp:(new Date).toISOString(),ua:navigator.userAgent,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,eventId:this.generateUuid(),title:document.title};return Object.assign(e.p,t),e}generateUuid(){let e="";for(let t=0;t<36;t++)if(8===t||13===t||18===t||23===t)e+="-";else if(14===t)e+="4";else{e+="0123456789abcdef"[Math.floor(16*Math.random())]}return e}},e}({});
var track = new sl.StatsliteClient("fabricnotes", "https://statslite-capture-ring1.trafficmanager.net", false);
var track = new sl.StatsliteClient("fabricnotes", "https://statslite-capture-r1-dccndrbdbtcmf0bu.b02.azurefd.net", false);
track.trackPageView();

</script>
Expand Down

0 comments on commit 8c9c630

Please sign in to comment.