/*
 * This code is for Internal Salesforce use only, and subject to change without notice.
 * Customers shouldn't reference this file in any web pages.
 */
var NetworkTracking={timerId:null,queue:[],hasPerfLogged:!1,config:{URL:"",DEFAULT_LOG_NAME:"",DEFAULT_PAGE:"",LOG_LINE_PATTERN:'{"logName" : "{0}", "logLevel" : "INFO", "logAttrs" : {1}}',ATTRS_PATTERN:'{"pageId": "{0}", "viewId": "{1}"}',LOG_LINES:"logLines",MAX_BUFFER_SIZE:100,FLUSH_SIZE:100,FLUSH_INTERVAL:1500,AUTO_FLUSH:!0},init:function(a,b,c){this.config.URL=a;this.config.DEFAULT_LOG_NAME=b;this.config.DEFAULT_PAGE=c;a=this.logMetrics.bind(this);setTimeout(a,6E4);window.addEventListener("unload",
a)},queueMessage:function(a,b){var c=this.config.LOG_LINE_PATTERN.replace("{0}",a).replace("{1}",b);this.queue.push(c);this.queue.length>this.config.MAX_BUFFER_SIZE&&this.queue.shift()},startFlushTimer:function(){if(!this.timerId&&this.config.AUTO_FLUSH)if(0<this.config.FLUSH_INTERVAL){var a=this;this.timerId=setTimeout(function(){a.flush()},this.config.FLUSH_INTERVAL)}else this.flush()},getLogQueue:function(){return this.queue},log:function(a,b){this.queueMessage(a,b);this.startFlushTimer()},logPageView:function(a){a=
this.config.ATTRS_PATTERN.replace("{0}",this.config.DEFAULT_PAGE).replace("{1}",a?a:"");this.log(this.config.DEFAULT_LOG_NAME,a)},logMetrics:function(a){if(!this.hasPerfLogged&&window.CCRZ){a=this.gatherPerfLogline();a=encodeURIComponent(this.arrayToString([a]));a=this.config.LOG_LINES+"\x3d"+a;var b=new Blob([a],{type:"application/x-www-form-urlencoded; charset\x3dUTF-8"});navigator&&(navigator.sendBeacon&&!navigator.sendBeacon(this.config.URL,b))&&(b=this._createXmlHttpObject(),b.open("POST",this.config.URL,
!0),b.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset\x3dUTF-8"),b.send(a));this.hasPerfLogged=!0}},gatherPerfLogline:function(){var a=this.gatherPageLevelData();return JSON.stringify({logName:"networkPagePerformance",logLevel:"INFO",logAttrs:{url:window.location&&window.location.href,connect:a.connect||!1,domComplete:a.domComplete||!1,load:a.load||!1}})},gatherPageLevelData:function(){if(!window.performance||!window.performance.timing)return{};var a=window.performance.timing;
return{connect:a.connectEnd-a.navigationStart,domComplete:a.domComplete-a.navigationStart,load:a.loadEventEnd-a.navigationStart}},flush:function(){this.timerId&&(clearTimeout(this.timerId),this.timerId=null);if(0===this.queue.length)return 0;var a=this.queue.splice(0,this.config.FLUSH_SIZE),b=this._createXmlHttpObject();if(null!=b)return b.open("POST",this.config.URL,!0),b.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset\x3dUTF-8"),b.send(this.config.LOG_LINES+"\x3d"+encodeURI(this.arrayToString(a))),
0<this.queue.length&&this.startFlushTimer(),a.length},_createXmlHttpObject:function(){if(window.XMLHttpRequest)return new window.XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(a){}},arrayToString:function(a){for(var b="[",c=0;c<a.length;c++)b+=a[c],c<a.length-1&&(b+=",");return b+"]"}};

//# sourceMappingURL=/javascript/1679590411000/sfdc/source/NetworkTracking.js.map
