clarity-js 0.7.18 → 0.7.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(){"use strict";var t=Object.freeze({__proto__:null,get queue(){return ht},get start(){return ft},get stop(){return vt},get track(){return ct}}),n=Object.freeze({__proto__:null,get check(){return _t},get compute(){return Et},get data(){return it},get start(){return kt},get stop(){return It},get trigger(){return St}}),e=Object.freeze({__proto__:null,get compute(){return zt},get data(){return Mt},get log(){return jt},get reset(){return qt},get start(){return Ot},get stop(){return Tt},get updates(){return xt}}),r=Object.freeze({__proto__:null,get callbacks(){return At},get clear(){return Vt},get consent(){return Bt},get data(){return Ct},get electron(){return Nt},get id(){return Ut},get metadata(){return Ht},get save(){return Lt},get shortid(){return Jt},get start(){return Pt},get stop(){return Dt}}),o=Object.freeze({__proto__:null,get data(){return $t},get envelope(){return en},get start(){return tn},get stop(){return nn}}),a={projectId:null,delay:1e3,lean:!1,track:!0,content:!0,drop:[],mask:[],unmask:[],regions:[],cookies:[],fraud:!0,checksum:[],report:null,upload:null,fallback:null,upgrade:null,action:null,dob:null};function u(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var c=0;function i(t){void 0===t&&(t=null);var n=t&&t.timeStamp>0?t.timeStamp:performance.now();return Math.max(Math.round(n-c),0)}var s="0.7.18";var l=!0,d=null,p=null;function f(t,n,e){return function(){if(l&&null===d)try{d=new RegExp("\\p{N}","gu"),p=new RegExp("\\p{L}","gu"),new RegExp("\\p{Sc}","gu")}catch(t){l=!1}}(),t?t.replace(p,n).replace(d,e):t}var h=[],v=null;function g(){}var m=[];function y(){}function b(){}var w=Object.freeze({__proto__:null,compute:function(){},data:v,hashText:y,keys:m,log:g,observe:function(){},reset:function(){},start:function(){},state:h,stop:function(){},trigger:b}),k=null;function _(t,n){On()&&t&&"string"==typeof t&&t.length<255&&(k=n&&"string"==typeof n&&n.length<255?{key:t,value:n}:{value:t},wt(24))}var S,E=null,I=null;function M(t){t in E||(E[t]=0),t in I||(I[t]=0),E[t]++,I[t]++}function x(t,n){null!==n&&(t in E||(E[t]=0),t in I||(I[t]=0),E[t]+=n,I[t]+=n)}function O(t,n){null!==n&&!1===isNaN(n)&&(t in E||(E[t]=0),(n>E[t]||0===E[t])&&(I[t]=n,E[t]=n))}function T(t,n,e){return window.setTimeout(an(t),n,e)}function j(t){return window.clearTimeout(t)}var z=0,q=0,C=null;function A(){C&&j(C),C=T(N,q),z=i()}function N(){var t=i();S={gap:t-z},wt(25),S.gap<3e5?C=T(N,q):In&&(_("clarity","suspend"),Bn(),["mousemove","touchstart"].forEach((function(t){return cn(document,t,jn)})),["resize","scroll","pageshow"].forEach((function(t){return cn(window,t,jn)})))}var R=Object.freeze({__proto__:null,get data(){return S},reset:A,start:function(){q=6e4,z=0},stop:function(){j(C),z=0,q=0}}),P=null;function D(t){On()&&a.lean&&(a.lean=!1,P={key:t},Lt(),a.upgrade&&a.upgrade(t),wt(3))}var H=Object.freeze({__proto__:null,get data(){return P},start:function(){!a.lean&&a.upgrade&&a.upgrade("Config"),P=null},stop:function(){P=null},upgrade:D});function U(t,n,e,r){return new(e||(e=Promise))((function(o,a){function u(t){try{i(r.next(t))}catch(t){a(t)}}function c(t){try{i(r.throw(t))}catch(t){a(t)}}function i(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}i((r=r.apply(t,n||[])).next())}))}function B(t,n){var e,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(i){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,i])}}}var V=null;function L(t,n){W(t,"string"==typeof n?[n]:n)}function X(t,n,e,r){return void 0===n&&(n=null),void 0===e&&(e=null),void 0===r&&(r=null),U(this,void 0,void 0,(function(){var o,a;return B(this,(function(u){switch(u.label){case 0:return a={},[4,G(t)];case 1:return a.userId=u.sent(),a.userHint=r||((c=t)&&c.length>=5?"".concat(c.substring(0,2)).concat(f(c.substring(2),"*","*")):f(c,"*","*")),W("userId",[(o=a).userId]),W("userHint",[o.userHint]),W("userType",[Y(t)]),n&&(W("sessionId",[n]),o.sessionId=n),e&&(W("pageId",[e]),o.pageId=e),[2,o]}var c}))}))}function W(t,n){if(On()&&t&&n&&"string"==typeof t&&t.length<255){for(var e=(t in V?V[t]:[]),r=0;r<n.length;r++)"string"==typeof n[r]&&n[r].length<255&&e.push(n[r]);V[t]=e}}function J(){wt(34)}function Z(){V={}}function G(t){return U(this,void 0,void 0,(function(){var n;return B(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),crypto&&t?[4,crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))]:[3,2];case 1:return n=e.sent(),[2,Array.prototype.map.call(new Uint8Array(n),(function(t){return("00"+t.toString(16)).slice(-2)})).join("")];case 2:return[2,""];case 3:return[3,5];case 4:return e.sent(),[2,""];case 5:return[2]}}))}))}function Y(t){return t&&t.indexOf("@")>0?"email":"string"}var F="CompressionStream"in window;function K(t){return U(this,void 0,void 0,(function(){var n,e;return B(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),F?(n=new ReadableStream({start:function(n){return U(this,void 0,void 0,(function(){return B(this,(function(e){return n.enqueue(t),n.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),e=Uint8Array.bind,[4,Q(n)]):[3,2];case 1:return[2,new(e.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,null]}}))}))}function Q(t){return U(this,void 0,void 0,(function(){var n,e,r,o,a;return B(this,(function(u){switch(u.label){case 0:n=t.getReader(),e=[],r=!1,o=[],u.label=1;case 1:return r?[3,3]:[4,n.read()];case 2:return a=u.sent(),r=a.done,o=a.value,r?[2,e]:(e.push.apply(e,o),[3,1]);case 3:return[2,e]}}))}))}var $=[w,e,Object.freeze({__proto__:null,compute:J,get data(){return V},identify:X,reset:Z,set:L,start:function(){Z()},stop:function(){Z()}}),n,w,r,o,t,R,H,w];function tt(){E={},I={},M(5),$.forEach((function(t){return an(t.start)()}))}function nt(){$.slice().reverse().forEach((function(t){return an(t.stop)()})),E={},I={}}function et(){J(),zt(),wt(0),Et()}var rt,ot,at,ut,ct,it,st=0,lt=0,dt=null,pt=0;function ft(){ut=!0,st=0,lt=0,pt=0,rt=[],ot=[],at={},ct=null}function ht(t,n){if(void 0===n&&(n=!0),ut){var e=i(),r=t.length>1?t[1]:null,o=JSON.stringify(t);switch(r){case 5:st+=o.length;case 37:case 6:case 43:lt+=o.length,rt.push(o);break;default:ot.push(o)}M(25);var u=function(){var t=!1===a.lean&&st>0?100:$t.sequence*a.delay;return"string"==typeof a.upload?Math.max(Math.min(t,3e4),100):a.delay}();e-pt>2*u&&(j(dt),dt=null),n&&null===dt&&(25!==r&&A(),dt=T(gt,u),pt=e,_t(lt))}}function vt(){j(dt),gt(!0),st=0,lt=0,pt=0,rt=[],ot=[],at={},ct=null,ut=!1}function gt(t){return void 0===t&&(t=!1),U(this,void 0,void 0,(function(){var n,e,r,o,u,c,i,s;return B(this,(function(l){switch(l.label){case 0:return dt=null,(n=!1===a.lean&&lt>0&&(lt<1048576||$t.sequence>0))&&O(1,1),et(),e=!0===t,r=JSON.stringify(en(e)),o="[".concat(ot.join(),"]"),u=n?"[".concat(rt.join(),"]"):"",c=function(t){return t.p.length>0?'{"e":'.concat(t.e,',"a":').concat(t.a,',"p":').concat(t.p,"}"):'{"e":'.concat(t.e,',"a":').concat(t.a,"}")}({e:r,a:o,p:u}),e?(s=null,[3,3]):[3,1];case 1:return[4,K(c)];case 2:s=l.sent(),l.label=3;case 3:return x(2,(i=s)?i.length:c.length),mt(c,i,$t.sequence,e),ot=[],n&&(rt=[],lt=0,st=0),[2]}}))}))}function mt(t,n,e,r){if(void 0===r&&(r=!1),"string"==typeof a.upload){var o=a.upload,u=!1;if(r&&"sendBeacon"in navigator)try{(u=navigator.sendBeacon.bind(navigator)(o,t))&&bt(e)}catch(t){}if(!1===u){e in at?at[e].attempts++:at[e]={data:t,attempts:1};var c=new XMLHttpRequest;c.open("POST",o,!0),c.timeout=15e3,c.ontimeout=function(){on(new Error("".concat("Timeout"," : ").concat(o)))},null!==e&&(c.onreadystatechange=function(){an(yt)(c,e)}),c.withCredentials=!0,n?(c.setRequestHeader("Accept","application/x-clarity-gzip"),c.send(n)):c.send(t)}}else if(a.upload){(0,a.upload)(t),bt(e)}}function yt(t,n){var e=at[n];t&&4===t.readyState&&e&&((t.status<200||t.status>208)&&e.attempts<=1?t.status>=400&&t.status<500?St(6):(0===t.status&&(a.upload=a.fallback?a.fallback:a.upload),mt(e.data,null,n)):(ct={sequence:n,attempts:e.attempts,status:t.status},e.attempts>1&&wt(2),200===t.status&&t.responseText&&function(t){for(var n=t&&t.length>0?t.split("\n"):[],e=0,r=n;e<r.length;e++){var o=r[e],u=o&&o.length>0?o.split(/ (.*)/):[""];switch(u[0]){case"END":St(6);break;case"UPGRADE":D("Auto");break;case"ACTION":a.action&&u.length>1&&a.action(u[1]);break;case"EXTRACT":u.length>1&&u[1]}}}(t.responseText),0===t.status&&(mt(e.data,null,n,!0),St(3)),t.status>=200&&t.status<=208&&bt(n),delete at[n]))}function bt(t){1===t&&Lt()}function wt(t){var n=[i(),t];switch(t){case 4:var e=h;e&&((n=[e.time,e.event]).push(e.data.visible),n.push(e.data.docWidth),n.push(e.data.docHeight),n.push(e.data.screenWidth),n.push(e.data.screenHeight),n.push(e.data.scrollX),n.push(e.data.scrollY),n.push(e.data.pointerX),n.push(e.data.pointerY),n.push(e.data.activityTime),ht(n,!1));break;case 25:n.push(S.gap),ht(n);break;case 35:n.push(it.check),ht(n,!1);break;case 3:n.push(P.key),ht(n);break;case 2:n.push(ct.sequence),n.push(ct.attempts),n.push(ct.status),ht(n,!1);break;case 24:k.key&&n.push(k.key),n.push(k.value),ht(n);break;case 34:var r=Object.keys(V);if(r.length>0){for(var o=0,a=r;o<a.length;o++){var u=a[o];n.push(u),n.push(V[u])}Z(),ht(n,!1)}break;case 0:var c=Object.keys(I);if(c.length>0){for(var s=0,l=c;s<l.length;s++){var d=l[s],p=parseInt(d,10);n.push(p),n.push(Math.round(I[d]))}I={},ht(n,!1)}break;case 1:var f=Object.keys(xt);if(f.length>0){for(var g=0,y=f;g<y.length;g++){var b=y[g];p=parseInt(b,10);n.push(p),n.push(xt[b])}qt(),ht(n,!1)}break;case 36:var w=Object.keys(v);if(w.length>0){for(var _=0,E=w;_<E.length;_++){var M=E[_];p=parseInt(M,10);n.push(p),n.push([].concat.apply([],v[M]))}ht(n,!1)}break;case 40:m.forEach((function(t){n.push(t);var e=[];for(var r in v[t]){var o=parseInt(r,10);e.push(o),e.push(v[t][r])}n.push(e)})),ht(n,!1)}}function kt(){it={check:0}}function _t(t){if(0===it.check){var n=it.check;n=$t.sequence>=128?1:n,n=$t.pageNum>=128?7:n,n=i()>72e5?2:n,(n=t>10485760?2:n)!==it.check&&St(n)}}function St(t){it.check=t,Vt(),Bn()}function Et(){0!==it.check&&wt(35)}function It(){it=null}var Mt=null,xt=null;function Ot(){Mt={},xt={}}function Tt(){Mt={},xt={}}function jt(t,n){n&&(n="".concat(n),t in Mt||(Mt[t]=[]),Mt[t].indexOf(n)<0&&(Mt[t].push(n),t in xt||(xt[t]=[]),xt[t].push(n),Mt[t].length>128&&St(5)))}function zt(){wt(1)}function qt(){xt={}}var Ct=null,At=[],Nt=0,Rt=null;function Pt(){Rt=null;var t=navigator&&"userAgent"in navigator?navigator.userAgent:"",n=document&&document.title?document.title:"";Nt=t.indexOf("Electron")>0?1:0;var e,r=function(){var t={session:Jt(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},n=Yt("_clsk");if(n){var e=n.split("|");e.length>=5&&t.ts-Zt(e[1])<18e5&&(t.session=e[0],t.count=Zt(e[2])+1,t.upgrade=Zt(e[3]),t.upload=e.length>=6?"".concat("https://").concat(e[5],"/").concat(e[4]):"".concat("https://").concat(e[4]))}return t}(),o=Gt(),u=a.projectId||function(t,n){void 0===n&&(n=null);for(var e,r=5381,o=r,a=0;a<t.length;a+=2)r=(r<<5)+r^t.charCodeAt(a),a+1<t.length&&(o=(o<<5)+o^t.charCodeAt(a+1));return e=Math.abs(r+11579*o),(n?e%Math.pow(2,n):e).toString(36)}(location.host);Ct={projectId:u,userId:o.id,sessionId:r.session,pageNum:r.count},a.lean=a.track&&null!==r.upgrade?0===r.upgrade:a.lean,a.upload=a.track&&"string"==typeof a.upload&&r.upload&&r.upload.length>"https://".length?r.upload:a.upload,jt(0,t),jt(3,n),jt(1,function(t,n){if(void 0===n&&(n=!1),n)return"".concat("https://").concat("Electron");var e=a.drop;if(e&&e.length>0&&t&&t.indexOf("?")>0){var r=t.split("?");return r[0]+"?"+r[1].split("&").map((function(t){return e.some((function(n){return 0===t.indexOf("".concat(n,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}return t}(location.href,!!Nt)),jt(2,document.referrer),jt(15,function(){var t=Jt();if(a.track&&Xt(window,"sessionStorage")){var n=sessionStorage.getItem("_cltk");t=n||t,sessionStorage.setItem("_cltk",t)}return t}()),jt(16,document.documentElement.lang),jt(17,document.dir),jt(26,"".concat(window.devicePixelRatio)),jt(28,o.dob.toString()),jt(29,o.version.toString()),O(0,r.ts),O(1,0),O(35,Nt),navigator&&(jt(9,navigator.language),O(33,navigator.hardwareConcurrency),O(32,navigator.maxTouchPoints),O(34,Math.round(navigator.deviceMemory)),(e=navigator.userAgentData)&&e.getHighEntropyValues?e.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var n;jt(22,t.platform),jt(23,t.platformVersion),null===(n=t.brands)||void 0===n||n.forEach((function(t){jt(24,t.name+"~"+t.version)})),jt(25,t.model),O(27,t.mobile?1:0)})):jt(22,navigator.platform)),screen&&(O(14,Math.round(screen.width)),O(15,Math.round(screen.height)),O(16,Math.round(screen.colorDepth)));for(var c=0,i=a.cookies;c<i.length;c++){var s=i[c],l=Yt(s);l&&L(s,l)}Wt(o)}function Dt(){Rt=null,Ct=null}function Ht(t,n){void 0===n&&(n=!0);var e=a.lean?0:1;Ct&&(e||!1===n)?t(Ct,!a.lean):At.push({callback:t,wait:n})}function Ut(){return Ct?[Ct.userId,Ct.sessionId,Ct.pageNum].join("."):""}function Bt(t){if(void 0===t&&(t=!0),!t)return Kt("_clsk","",0),Kt("_clck","",0),Bn(),void window.setTimeout(Un,250);On()&&(a.track=!0,Wt(Gt(),1))}function Vt(){Kt("_clsk","",0)}function Lt(){var t=Math.round(Date.now()),n=a.upload&&"string"==typeof a.upload?a.upload.replace("https://",""):"",e=a.lean?0:1;!function(t){At.length>0&&At.forEach((function(n){!n.callback||n.wait&&!t||n.callback(Ct,!a.lean)}))}(e),Kt("_clsk",[Ct.sessionId,t,Ct.pageNum,e,n].join("|"),1)}function Xt(t,n){try{return!!t[n]}catch(t){return!1}}function Wt(t,n){void 0===n&&(n=null),n=null===n?t.consent:n;var e=Math.ceil((Date.now()+31536e6)/864e5),r=0===t.dob?null===a.dob?0:a.dob:t.dob;(null===t.expiry||Math.abs(e-t.expiry)>=1||t.consent!==n||t.dob!==r)&&Kt("_clck",[Ct.userId,2,e.toString(36),n,r].join("|"),365)}function Jt(){var t=Math.floor(Math.random()*Math.pow(2,32));return window&&window.crypto&&window.crypto.getRandomValues&&Uint32Array&&(t=window.crypto.getRandomValues(new Uint32Array(1))[0]),t.toString(36)}function Zt(t,n){return void 0===n&&(n=10),parseInt(t,n)}function Gt(){var t={id:Jt(),version:0,expiry:null,consent:0,dob:0},n=Yt("_clck");if(n&&n.length>0){for(var e=n.split("|"),r=0,o=0,u=document.cookie.split(";");o<u.length;o++){r+="_clck"===u[o].split("=")[0].trim()?1:0}if(1===e.length||r>1){var c="".concat(";").concat("expires=").concat(new Date(0).toUTCString()).concat(";path=/");document.cookie="".concat("_clck","=").concat(c),document.cookie="".concat("_clsk","=").concat(c)}e.length>1&&(t.version=Zt(e[1])),e.length>2&&(t.expiry=Zt(e[2],36)),e.length>3&&1===Zt(e[3])&&(t.consent=1),e.length>4&&Zt(e[1])>1&&(t.dob=Zt(e[4])),a.track=a.track||1===t.consent,t.id=a.track?e[0]:t.id}return t}function Yt(t){var n;if(Xt(document,"cookie")){var e=document.cookie.split(";");if(e)for(var r=0;r<e.length;r++){var o=e[r].split("=");if(o.length>1&&o[0]&&o[0].trim()===t){for(var a=Ft(o[1]),u=a[0],c=a[1];u;)u=(n=Ft(c))[0],c=n[1];return c}}}return null}function Ft(t){try{var n=decodeURIComponent(t);return[n!=t,n]}catch(t){}return[!1,t]}function Kt(t,n,e){if(a.track&&(navigator&&navigator.cookieEnabled||Xt(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(n),o=new Date;o.setDate(o.getDate()+e);var u=o?"expires="+o.toUTCString():"",c="".concat(t,"=").concat(r).concat(";").concat(u).concat(";path=/");try{if(null===Rt){for(var i=location.hostname?location.hostname.split("."):[],s=i.length-1;s>=0;s--)if(Rt=".".concat(i[s]).concat(Rt||""),s<i.length-1&&(document.cookie="".concat(c).concat(";").concat("domain=").concat(Rt),Yt(t)===n))return;Rt=""}}catch(t){Rt=""}document.cookie=Rt?"".concat(c).concat(";").concat("domain=").concat(Rt):c}}var Qt,$t=null;function tn(){var t=Ct;$t={version:s,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0}}function nn(){$t=null}function en(t){return $t.start=$t.start+$t.duration,$t.duration=i()-$t.start,$t.sequence++,$t.upload=t&&"sendBeacon"in navigator?1:0,$t.end=t?1:0,[$t.version,$t.sequence,$t.start,$t.duration,$t.projectId,$t.userId,$t.sessionId,$t.pageNum,$t.upload,$t.end]}function rn(){Qt=[]}function on(t){if(Qt&&-1===Qt.indexOf(t.message)){var n=a.report;if(n&&n.length>0){var e={v:$t.version,p:$t.projectId,u:$t.userId,s:$t.sessionId,n:$t.pageNum};t.message&&(e.m=t.message),t.stack&&(e.e=t.stack);var r=new XMLHttpRequest;r.open("POST",n,!0),r.send(JSON.stringify(e)),Qt.push(t.message)}}return t}function an(t){return function(){var n=performance.now();try{t.apply(this,arguments)}catch(t){throw on(t)}var e=performance.now()-n;x(4,e),e>30&&(M(7),O(6,e))}}var un=[];function cn(t,n,e,r){void 0===r&&(r=!1),e=an(e);try{t[u("addEventListener")](n,e,r),un.push({event:n,target:t,listener:e,capture:r})}catch(t){}}function sn(){for(var t=0,n=un;t<n.length;t++){var e=n[t];try{e.target[u("removeEventListener")](e.event,e.listener,e.capture)}catch(t){}}un=[]}var ln=null,dn=null,pn=null,fn=0;function hn(){return!(fn++>20)}function vn(){fn=0,pn!==mn()&&(Bn(),window.setTimeout(gn,250))}function gn(){Un(),O(29,1)}function mn(){return location.href?location.href.replace(location.hash,""):location.href}var yn=[],bn=null,wn=null,kn=null;function _n(){wn&&(kn(),wn=null,null===bn&&En())}function Sn(){yn=[],bn=null,wn=null}function En(){var t=yn.shift();t&&(bn=t,t.task().then((function(){t.id===Ut()&&(t.resolve(),bn=null,En())})).catch((function(n){t.id===Ut()&&(n&&(n.name,n.message,n.stack),bn=null,En())})))}var In=!1;function Mn(){In=!0,c=performance.now(),Sn(),sn(),rn(),pn=mn(),fn=0,cn(window,"popstate",vn),null===ln&&(ln=history.pushState,history.pushState=function(){ln.apply(this,arguments),On()&&hn()&&vn()}),null===dn&&(dn=history.replaceState,history.replaceState=function(){dn.apply(this,arguments),On()&&hn()&&vn()})}function xn(){pn=null,fn=0,rn(),sn(),Sn(),c=0,In=!1}function On(){return In}function Tn(t){if(null===t||In)return!1;for(var n in t)n in a&&(a[n]=t[n]);return!0}function jn(){Un(),_("clarity","restart")}var zn,qn=null;function Cn(){qn=null}function An(t){qn={fetchStart:Math.round(t.fetchStart),connectStart:Math.round(t.connectStart),connectEnd:Math.round(t.connectEnd),requestStart:Math.round(t.requestStart),responseStart:Math.round(t.responseStart),responseEnd:Math.round(t.responseEnd),domInteractive:Math.round(t.domInteractive),domComplete:Math.round(t.domComplete),loadEventStart:Math.round(t.loadEventStart),loadEventEnd:Math.round(t.loadEventEnd),redirectCount:Math.round(t.redirectCount),size:t.transferSize?t.transferSize:0,type:t.type,protocol:t.nextHopProtocol,encodedSize:t.encodedBodySize?t.encodedBodySize:0,decodedSize:t.decodedBodySize?t.decodedBodySize:0},function(t){U(this,void 0,void 0,(function(){var n,e;return B(this,(function(r){return n=i(),e=[n,t],29===t&&(e.push(qn.fetchStart),e.push(qn.connectStart),e.push(qn.connectEnd),e.push(qn.requestStart),e.push(qn.responseStart),e.push(qn.responseEnd),e.push(qn.domInteractive),e.push(qn.domComplete),e.push(qn.loadEventStart),e.push(qn.loadEventEnd),e.push(qn.redirectCount),e.push(qn.size),e.push(qn.type),e.push(qn.protocol),e.push(qn.encodedSize),e.push(qn.decodedSize),Cn(),ht(e)),[2]}))}))}(29)}var Nn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint"];function Rn(){try{zn&&zn.disconnect(),zn=new PerformanceObserver(an(Pn));for(var t=0,n=Nn;t<n.length;t++){var e=n[t];PerformanceObserver.supportedEntryTypes.indexOf(e)>=0&&("layout-shift"===e&&x(9,0),zn.observe({type:e,buffered:!0}))}}catch(t){}}function Pn(t){!function(t){for(var n=(!("visibilityState"in document)||"visible"===document.visibilityState),e=0;e<t.length;e++){var r=t[e];switch(r.entryType){case"navigation":An(r);break;case"resource":var o=r.name;jt(4,Dn(o)),o!==a.upload&&o!==a.fallback||O(28,r.duration);break;case"longtask":M(7);break;case"first-input":n&&O(10,r.processingStart-r.startTime);break;case"layout-shift":n&&!r.hadRecentInput&&x(9,1e3*r.value);break;case"largest-contentful-paint":n&&O(8,r.startTime)}}}(t.getEntries())}function Dn(t){var n=document.createElement("a");return n.href=t,n.host}var Hn=[w,w,w,Object.freeze({__proto__:null,start:function(){Cn(),function(){navigator&&"connection"in navigator&&jt(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?cn(window,"load",T.bind(this,Rn,0)):Rn())}()},stop:function(){zn&&zn.disconnect(),zn=null,Cn()}})];function Un(t){void 0===t&&(t=null),function(){try{return!1===In&&"undefined"!=typeof Promise&&window.MutationObserver&&document.createTreeWalker&&"now"in Date&&"now"in performance&&"undefined"!=typeof WeakMap}catch(t){return!1}}()&&(Tn(t),Mn(),tt(),Hn.forEach((function(t){return an(t.start)()})),null===t&&Wn())}function Bn(){On()&&(Hn.slice().reverse().forEach((function(t){return an(t.stop)()})),nt(),xn(),void 0!==Ln&&(Ln[Xn]=function(){(Ln[Xn].q=Ln[Xn].q||[]).push(arguments),"start"===arguments[0]&&Ln[Xn].q.unshift(Ln[Xn].q.pop())&&Wn()}))}var Vn=Object.freeze({__proto__:null,consent:Bt,event:_,hashText:y,identify:X,metadata:Ht,pause:function(){On()&&(_("clarity","pause"),null===wn&&(wn=new Promise((function(t){kn=t}))))},resume:function(){On()&&(_n(),_("clarity","resume"))},set:L,start:Un,stop:Bn,upgrade:D,version:s}),Ln=window,Xn="clarity";function Wn(){if(void 0!==Ln){if(Ln[Xn]&&Ln[Xn].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=Ln[Xn]&&Ln[Xn].q||[];for(Ln[Xn]=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return Vn[t].apply(Vn,n)},Ln[Xn].v=s;t.length>0;)Ln[Xn].apply(Ln,t.shift())}}Wn()}();
1
+ !function(){"use strict";var t=Object.freeze({__proto__:null,get queue(){return ht},get start(){return ft},get stop(){return vt},get track(){return ct}}),n=Object.freeze({__proto__:null,get check(){return _t},get compute(){return Et},get data(){return it},get start(){return kt},get stop(){return It},get trigger(){return St}}),e=Object.freeze({__proto__:null,get compute(){return zt},get data(){return Mt},get log(){return jt},get reset(){return qt},get start(){return Ot},get stop(){return Tt},get updates(){return xt}}),r=Object.freeze({__proto__:null,get callbacks(){return At},get clear(){return Vt},get consent(){return Bt},get data(){return Ct},get electron(){return Nt},get id(){return Ut},get metadata(){return Ht},get save(){return Lt},get shortid(){return Jt},get start(){return Dt},get stop(){return Pt}}),o=Object.freeze({__proto__:null,get data(){return $t},get envelope(){return en},get start(){return tn},get stop(){return nn}}),a={projectId:null,delay:1e3,lean:!1,track:!0,content:!0,drop:[],mask:[],unmask:[],regions:[],cookies:[],fraud:!0,checksum:[],report:null,upload:null,fallback:null,upgrade:null,action:null,dob:null};function u(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var c=0;function i(t){void 0===t&&(t=null);var n=t&&t.timeStamp>0?t.timeStamp:performance.now();return Math.max(Math.round(n-c),0)}var s="0.7.19";var l=!0,d=null,p=null;function f(t,n,e){return function(){if(l&&null===d)try{d=new RegExp("\\p{N}","gu"),p=new RegExp("\\p{L}","gu"),new RegExp("\\p{Sc}","gu")}catch(t){l=!1}}(),t?t.replace(p,n).replace(d,e):t}var h=[],v=null;function g(){}var m=[];function y(){}function b(){}var w=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:v,hashText:y,keys:m,log:g,observe:function(){},reset:function(){},start:function(){},state:h,stop:function(){},trigger:b}),k=null;function _(t,n){On()&&t&&"string"==typeof t&&t.length<255&&(k=n&&"string"==typeof n&&n.length<255?{key:t,value:n}:{value:t},wt(24))}var S,E=null,I=null;function M(t){t in E||(E[t]=0),t in I||(I[t]=0),E[t]++,I[t]++}function x(t,n){null!==n&&(t in E||(E[t]=0),t in I||(I[t]=0),E[t]+=n,I[t]+=n)}function O(t,n){null!==n&&!1===isNaN(n)&&(t in E||(E[t]=0),(n>E[t]||0===E[t])&&(I[t]=n,E[t]=n))}function T(t,n,e){return window.setTimeout(an(t),n,e)}function j(t){return window.clearTimeout(t)}var z=0,q=0,C=null;function A(){C&&j(C),C=T(N,q),z=i()}function N(){var t=i();S={gap:t-z},wt(25),S.gap<3e5?C=T(N,q):In&&(_("clarity","suspend"),Bn(),["mousemove","touchstart"].forEach((function(t){return cn(document,t,jn)})),["resize","scroll","pageshow"].forEach((function(t){return cn(window,t,jn)})))}var R=Object.freeze({__proto__:null,get data(){return S},reset:A,start:function(){q=6e4,z=0},stop:function(){j(C),z=0,q=0}}),D=null;function P(t){On()&&a.lean&&(a.lean=!1,D={key:t},Lt(),a.upgrade&&a.upgrade(t),wt(3))}var H=Object.freeze({__proto__:null,get data(){return D},start:function(){!a.lean&&a.upgrade&&a.upgrade("Config"),D=null},stop:function(){D=null},upgrade:P});function U(t,n,e,r){return new(e||(e=Promise))((function(o,a){function u(t){try{i(r.next(t))}catch(t){a(t)}}function c(t){try{i(r.throw(t))}catch(t){a(t)}}function i(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}i((r=r.apply(t,n||[])).next())}))}function B(t,n){var e,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(i){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,i])}}}var V=null;function L(t,n){W(t,"string"==typeof n?[n]:n)}function X(t,n,e,r){return void 0===n&&(n=null),void 0===e&&(e=null),void 0===r&&(r=null),U(this,void 0,void 0,(function(){var o,a;return B(this,(function(u){switch(u.label){case 0:return a={},[4,G(t)];case 1:return a.userId=u.sent(),a.userHint=r||((c=t)&&c.length>=5?"".concat(c.substring(0,2)).concat(f(c.substring(2),"*","*")):f(c,"*","*")),W("userId",[(o=a).userId]),W("userHint",[o.userHint]),W("userType",[Y(t)]),n&&(W("sessionId",[n]),o.sessionId=n),e&&(W("pageId",[e]),o.pageId=e),[2,o]}var c}))}))}function W(t,n){if(On()&&t&&n&&"string"==typeof t&&t.length<255){for(var e=(t in V?V[t]:[]),r=0;r<n.length;r++)"string"==typeof n[r]&&n[r].length<255&&e.push(n[r]);V[t]=e}}function J(){wt(34)}function Z(){V={}}function G(t){return U(this,void 0,void 0,(function(){var n;return B(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),crypto&&t?[4,crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))]:[3,2];case 1:return n=e.sent(),[2,Array.prototype.map.call(new Uint8Array(n),(function(t){return("00"+t.toString(16)).slice(-2)})).join("")];case 2:return[2,""];case 3:return[3,5];case 4:return e.sent(),[2,""];case 5:return[2]}}))}))}function Y(t){return t&&t.indexOf("@")>0?"email":"string"}var F="CompressionStream"in window;function K(t){return U(this,void 0,void 0,(function(){var n,e;return B(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),F?(n=new ReadableStream({start:function(n){return U(this,void 0,void 0,(function(){return B(this,(function(e){return n.enqueue(t),n.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),e=Uint8Array.bind,[4,Q(n)]):[3,2];case 1:return[2,new(e.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,null]}}))}))}function Q(t){return U(this,void 0,void 0,(function(){var n,e,r,o,a;return B(this,(function(u){switch(u.label){case 0:n=t.getReader(),e=[],r=!1,o=[],u.label=1;case 1:return r?[3,3]:[4,n.read()];case 2:return a=u.sent(),r=a.done,o=a.value,r?[2,e]:(e.push.apply(e,o),[3,1]);case 3:return[2,e]}}))}))}var $=[w,e,Object.freeze({__proto__:null,compute:J,get data(){return V},identify:X,reset:Z,set:L,start:function(){Z()},stop:function(){Z()}}),n,w,r,o,t,R,H,w];function tt(){E={},I={},M(5),$.forEach((function(t){return an(t.start)()}))}function nt(){$.slice().reverse().forEach((function(t){return an(t.stop)()})),E={},I={}}function et(){J(),zt(),wt(0),Et()}var rt,ot,at,ut,ct,it,st=0,lt=0,dt=null,pt=0;function ft(){ut=!0,st=0,lt=0,pt=0,rt=[],ot=[],at={},ct=null}function ht(t,n){if(void 0===n&&(n=!0),ut){var e=i(),r=t.length>1?t[1]:null,o=JSON.stringify(t);switch(r){case 5:st+=o.length;case 37:case 6:case 43:case 45:case 46:lt+=o.length,rt.push(o);break;default:ot.push(o)}M(25);var u=function(){var t=!1===a.lean&&st>0?100:$t.sequence*a.delay;return"string"==typeof a.upload?Math.max(Math.min(t,3e4),100):a.delay}();e-pt>2*u&&(j(dt),dt=null),n&&null===dt&&(25!==r&&A(),dt=T(gt,u),pt=e,_t(lt))}}function vt(){j(dt),gt(!0),st=0,lt=0,pt=0,rt=[],ot=[],at={},ct=null,ut=!1}function gt(t){return void 0===t&&(t=!1),U(this,void 0,void 0,(function(){var n,e,r,o,u,c,i,s;return B(this,(function(l){switch(l.label){case 0:return dt=null,(n=!1===a.lean&&lt>0&&(lt<1048576||$t.sequence>0))&&O(1,1),et(),e=!0===t,r=JSON.stringify(en(e)),o="[".concat(ot.join(),"]"),u=n?"[".concat(rt.join(),"]"):"",c=function(t){return t.p.length>0?'{"e":'.concat(t.e,',"a":').concat(t.a,',"p":').concat(t.p,"}"):'{"e":'.concat(t.e,',"a":').concat(t.a,"}")}({e:r,a:o,p:u}),e?(s=null,[3,3]):[3,1];case 1:return[4,K(c)];case 2:s=l.sent(),l.label=3;case 3:return x(2,(i=s)?i.length:c.length),mt(c,i,$t.sequence,e),ot=[],n&&(rt=[],lt=0,st=0),[2]}}))}))}function mt(t,n,e,r){if(void 0===r&&(r=!1),"string"==typeof a.upload){var o=a.upload,u=!1;if(r&&"sendBeacon"in navigator)try{(u=navigator.sendBeacon.bind(navigator)(o,t))&&bt(e)}catch(t){}if(!1===u){e in at?at[e].attempts++:at[e]={data:t,attempts:1};var c=new XMLHttpRequest;c.open("POST",o,!0),c.timeout=15e3,c.ontimeout=function(){on(new Error("".concat("Timeout"," : ").concat(o)))},null!==e&&(c.onreadystatechange=function(){an(yt)(c,e)}),c.withCredentials=!0,n?(c.setRequestHeader("Accept","application/x-clarity-gzip"),c.send(n)):c.send(t)}}else if(a.upload){(0,a.upload)(t),bt(e)}}function yt(t,n){var e=at[n];t&&4===t.readyState&&e&&((t.status<200||t.status>208)&&e.attempts<=1?t.status>=400&&t.status<500?St(6):(0===t.status&&(a.upload=a.fallback?a.fallback:a.upload),mt(e.data,null,n)):(ct={sequence:n,attempts:e.attempts,status:t.status},e.attempts>1&&wt(2),200===t.status&&t.responseText&&function(t){for(var n=t&&t.length>0?t.split("\n"):[],e=0,r=n;e<r.length;e++){var o=r[e],u=o&&o.length>0?o.split(/ (.*)/):[""];switch(u[0]){case"END":St(6);break;case"UPGRADE":P("Auto");break;case"ACTION":a.action&&u.length>1&&a.action(u[1]);break;case"EXTRACT":u.length>1&&u[1]}}}(t.responseText),0===t.status&&(mt(e.data,null,n,!0),St(3)),t.status>=200&&t.status<=208&&bt(n),delete at[n]))}function bt(t){1===t&&Lt()}function wt(t){var n=[i(),t];switch(t){case 4:var e=h;e&&((n=[e.time,e.event]).push(e.data.visible),n.push(e.data.docWidth),n.push(e.data.docHeight),n.push(e.data.screenWidth),n.push(e.data.screenHeight),n.push(e.data.scrollX),n.push(e.data.scrollY),n.push(e.data.pointerX),n.push(e.data.pointerY),n.push(e.data.activityTime),ht(n,!1));break;case 25:n.push(S.gap),ht(n);break;case 35:n.push(it.check),ht(n,!1);break;case 3:n.push(D.key),ht(n);break;case 2:n.push(ct.sequence),n.push(ct.attempts),n.push(ct.status),ht(n,!1);break;case 24:k.key&&n.push(k.key),n.push(k.value),ht(n);break;case 34:var r=Object.keys(V);if(r.length>0){for(var o=0,a=r;o<a.length;o++){var u=a[o];n.push(u),n.push(V[u])}Z(),ht(n,!1)}break;case 0:var c=Object.keys(I);if(c.length>0){for(var s=0,l=c;s<l.length;s++){var d=l[s],p=parseInt(d,10);n.push(p),n.push(Math.round(I[d]))}I={},ht(n,!1)}break;case 1:var f=Object.keys(xt);if(f.length>0){for(var g=0,y=f;g<y.length;g++){var b=y[g];p=parseInt(b,10);n.push(p),n.push(xt[b])}qt(),ht(n,!1)}break;case 36:var w=Object.keys(v);if(w.length>0){for(var _=0,E=w;_<E.length;_++){var M=E[_];p=parseInt(M,10);n.push(p),n.push([].concat.apply([],v[M]))}ht(n,!1)}break;case 40:m.forEach((function(t){n.push(t);var e=[];for(var r in v[t]){var o=parseInt(r,10);e.push(o),e.push(v[t][r])}n.push(e)})),ht(n,!1)}}function kt(){it={check:0}}function _t(t){if(0===it.check){var n=it.check;n=$t.sequence>=128?1:n,n=$t.pageNum>=128?7:n,n=i()>72e5?2:n,(n=t>10485760?2:n)!==it.check&&St(n)}}function St(t){it.check=t,Vt(),Bn()}function Et(){0!==it.check&&wt(35)}function It(){it=null}var Mt=null,xt=null;function Ot(){Mt={},xt={}}function Tt(){Mt={},xt={}}function jt(t,n){n&&(n="".concat(n),t in Mt||(Mt[t]=[]),Mt[t].indexOf(n)<0&&(Mt[t].push(n),t in xt||(xt[t]=[]),xt[t].push(n),Mt[t].length>128&&St(5)))}function zt(){wt(1)}function qt(){xt={}}var Ct=null,At=[],Nt=0,Rt=null;function Dt(){Rt=null;var t=navigator&&"userAgent"in navigator?navigator.userAgent:"",n=document&&document.title?document.title:"";Nt=t.indexOf("Electron")>0?1:0;var e,r=function(){var t={session:Jt(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},n=Yt("_clsk");if(n){var e=n.split("|");e.length>=5&&t.ts-Zt(e[1])<18e5&&(t.session=e[0],t.count=Zt(e[2])+1,t.upgrade=Zt(e[3]),t.upload=e.length>=6?"".concat("https://").concat(e[5],"/").concat(e[4]):"".concat("https://").concat(e[4]))}return t}(),o=Gt(),u=a.projectId||function(t,n){void 0===n&&(n=null);for(var e,r=5381,o=r,a=0;a<t.length;a+=2)r=(r<<5)+r^t.charCodeAt(a),a+1<t.length&&(o=(o<<5)+o^t.charCodeAt(a+1));return e=Math.abs(r+11579*o),(n?e%Math.pow(2,n):e).toString(36)}(location.host);Ct={projectId:u,userId:o.id,sessionId:r.session,pageNum:r.count},a.lean=a.track&&null!==r.upgrade?0===r.upgrade:a.lean,a.upload=a.track&&"string"==typeof a.upload&&r.upload&&r.upload.length>"https://".length?r.upload:a.upload,jt(0,t),jt(3,n),jt(1,function(t,n){if(void 0===n&&(n=!1),n)return"".concat("https://").concat("Electron");var e=a.drop;if(e&&e.length>0&&t&&t.indexOf("?")>0){var r=t.split("?");return r[0]+"?"+r[1].split("&").map((function(t){return e.some((function(n){return 0===t.indexOf("".concat(n,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}return t}(location.href,!!Nt)),jt(2,document.referrer),jt(15,function(){var t=Jt();if(a.track&&Xt(window,"sessionStorage")){var n=sessionStorage.getItem("_cltk");t=n||t,sessionStorage.setItem("_cltk",t)}return t}()),jt(16,document.documentElement.lang),jt(17,document.dir),jt(26,"".concat(window.devicePixelRatio)),jt(28,o.dob.toString()),jt(29,o.version.toString()),O(0,r.ts),O(1,0),O(35,Nt),navigator&&(jt(9,navigator.language),O(33,navigator.hardwareConcurrency),O(32,navigator.maxTouchPoints),O(34,Math.round(navigator.deviceMemory)),(e=navigator.userAgentData)&&e.getHighEntropyValues?e.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var n;jt(22,t.platform),jt(23,t.platformVersion),null===(n=t.brands)||void 0===n||n.forEach((function(t){jt(24,t.name+"~"+t.version)})),jt(25,t.model),O(27,t.mobile?1:0)})):jt(22,navigator.platform)),screen&&(O(14,Math.round(screen.width)),O(15,Math.round(screen.height)),O(16,Math.round(screen.colorDepth)));for(var c=0,i=a.cookies;c<i.length;c++){var s=i[c],l=Yt(s);l&&L(s,l)}Wt(o)}function Pt(){Rt=null,Ct=null}function Ht(t,n){void 0===n&&(n=!0);var e=a.lean?0:1;Ct&&(e||!1===n)?t(Ct,!a.lean):At.push({callback:t,wait:n})}function Ut(){return Ct?[Ct.userId,Ct.sessionId,Ct.pageNum].join("."):""}function Bt(t){if(void 0===t&&(t=!0),!t)return Kt("_clsk","",0),Kt("_clck","",0),Bn(),void window.setTimeout(Un,250);On()&&(a.track=!0,Wt(Gt(),1))}function Vt(){Kt("_clsk","",0)}function Lt(){var t=Math.round(Date.now()),n=a.upload&&"string"==typeof a.upload?a.upload.replace("https://",""):"",e=a.lean?0:1;!function(t){At.length>0&&At.forEach((function(n){!n.callback||n.wait&&!t||n.callback(Ct,!a.lean)}))}(e),Kt("_clsk",[Ct.sessionId,t,Ct.pageNum,e,n].join("|"),1)}function Xt(t,n){try{return!!t[n]}catch(t){return!1}}function Wt(t,n){void 0===n&&(n=null),n=null===n?t.consent:n;var e=Math.ceil((Date.now()+31536e6)/864e5),r=0===t.dob?null===a.dob?0:a.dob:t.dob;(null===t.expiry||Math.abs(e-t.expiry)>=1||t.consent!==n||t.dob!==r)&&Kt("_clck",[Ct.userId,2,e.toString(36),n,r].join("|"),365)}function Jt(){var t=Math.floor(Math.random()*Math.pow(2,32));return window&&window.crypto&&window.crypto.getRandomValues&&Uint32Array&&(t=window.crypto.getRandomValues(new Uint32Array(1))[0]),t.toString(36)}function Zt(t,n){return void 0===n&&(n=10),parseInt(t,n)}function Gt(){var t={id:Jt(),version:0,expiry:null,consent:0,dob:0},n=Yt("_clck");if(n&&n.length>0){for(var e=n.split("|"),r=0,o=0,u=document.cookie.split(";");o<u.length;o++){r+="_clck"===u[o].split("=")[0].trim()?1:0}if(1===e.length||r>1){var c="".concat(";").concat("expires=").concat(new Date(0).toUTCString()).concat(";path=/");document.cookie="".concat("_clck","=").concat(c),document.cookie="".concat("_clsk","=").concat(c)}e.length>1&&(t.version=Zt(e[1])),e.length>2&&(t.expiry=Zt(e[2],36)),e.length>3&&1===Zt(e[3])&&(t.consent=1),e.length>4&&Zt(e[1])>1&&(t.dob=Zt(e[4])),a.track=a.track||1===t.consent,t.id=a.track?e[0]:t.id}return t}function Yt(t){var n;if(Xt(document,"cookie")){var e=document.cookie.split(";");if(e)for(var r=0;r<e.length;r++){var o=e[r].split("=");if(o.length>1&&o[0]&&o[0].trim()===t){for(var a=Ft(o[1]),u=a[0],c=a[1];u;)u=(n=Ft(c))[0],c=n[1];return c}}}return null}function Ft(t){try{var n=decodeURIComponent(t);return[n!=t,n]}catch(t){}return[!1,t]}function Kt(t,n,e){if(a.track&&(navigator&&navigator.cookieEnabled||Xt(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(n),o=new Date;o.setDate(o.getDate()+e);var u=o?"expires="+o.toUTCString():"",c="".concat(t,"=").concat(r).concat(";").concat(u).concat(";path=/");try{if(null===Rt){for(var i=location.hostname?location.hostname.split("."):[],s=i.length-1;s>=0;s--)if(Rt=".".concat(i[s]).concat(Rt||""),s<i.length-1&&(document.cookie="".concat(c).concat(";").concat("domain=").concat(Rt),Yt(t)===n))return;Rt=""}}catch(t){Rt=""}document.cookie=Rt?"".concat(c).concat(";").concat("domain=").concat(Rt):c}}var Qt,$t=null;function tn(){var t=Ct;$t={version:s,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0}}function nn(){$t=null}function en(t){return $t.start=$t.start+$t.duration,$t.duration=i()-$t.start,$t.sequence++,$t.upload=t&&"sendBeacon"in navigator?1:0,$t.end=t?1:0,[$t.version,$t.sequence,$t.start,$t.duration,$t.projectId,$t.userId,$t.sessionId,$t.pageNum,$t.upload,$t.end]}function rn(){Qt=[]}function on(t){if(Qt&&-1===Qt.indexOf(t.message)){var n=a.report;if(n&&n.length>0){var e={v:$t.version,p:$t.projectId,u:$t.userId,s:$t.sessionId,n:$t.pageNum};t.message&&(e.m=t.message),t.stack&&(e.e=t.stack);var r=new XMLHttpRequest;r.open("POST",n,!0),r.send(JSON.stringify(e)),Qt.push(t.message)}}return t}function an(t){return function(){var n=performance.now();try{t.apply(this,arguments)}catch(t){throw on(t)}var e=performance.now()-n;x(4,e),e>30&&(M(7),O(6,e))}}var un=[];function cn(t,n,e,r){void 0===r&&(r=!1),e=an(e);try{t[u("addEventListener")](n,e,r),un.push({event:n,target:t,listener:e,capture:r})}catch(t){}}function sn(){for(var t=0,n=un;t<n.length;t++){var e=n[t];try{e.target[u("removeEventListener")](e.event,e.listener,e.capture)}catch(t){}}un=[]}var ln=null,dn=null,pn=null,fn=0;function hn(){return!(fn++>20)}function vn(){fn=0,pn!==mn()&&(Bn(),window.setTimeout(gn,250))}function gn(){Un(),O(29,1)}function mn(){return location.href?location.href.replace(location.hash,""):location.href}var yn=[],bn=null,wn=null,kn=null;function _n(){wn&&(kn(),wn=null,null===bn&&En())}function Sn(){yn=[],bn=null,wn=null}function En(){var t=yn.shift();t&&(bn=t,t.task().then((function(){t.id===Ut()&&(t.resolve(),bn=null,En())})).catch((function(n){t.id===Ut()&&(n&&(n.name,n.message,n.stack),bn=null,En())})))}var In=!1;function Mn(){In=!0,c=performance.now(),Sn(),sn(),rn(),pn=mn(),fn=0,cn(window,"popstate",vn),null===ln&&(ln=history.pushState,history.pushState=function(){ln.apply(this,arguments),On()&&hn()&&vn()}),null===dn&&(dn=history.replaceState,history.replaceState=function(){dn.apply(this,arguments),On()&&hn()&&vn()})}function xn(){pn=null,fn=0,rn(),sn(),Sn(),c=0,In=!1}function On(){return In}function Tn(t){if(null===t||In)return!1;for(var n in t)n in a&&(a[n]=t[n]);return!0}function jn(){Un(),_("clarity","restart")}var zn,qn=null;function Cn(){qn=null}function An(t){qn={fetchStart:Math.round(t.fetchStart),connectStart:Math.round(t.connectStart),connectEnd:Math.round(t.connectEnd),requestStart:Math.round(t.requestStart),responseStart:Math.round(t.responseStart),responseEnd:Math.round(t.responseEnd),domInteractive:Math.round(t.domInteractive),domComplete:Math.round(t.domComplete),loadEventStart:Math.round(t.loadEventStart),loadEventEnd:Math.round(t.loadEventEnd),redirectCount:Math.round(t.redirectCount),size:t.transferSize?t.transferSize:0,type:t.type,protocol:t.nextHopProtocol,encodedSize:t.encodedBodySize?t.encodedBodySize:0,decodedSize:t.decodedBodySize?t.decodedBodySize:0},function(t){U(this,void 0,void 0,(function(){var n,e;return B(this,(function(r){return n=i(),e=[n,t],29===t&&(e.push(qn.fetchStart),e.push(qn.connectStart),e.push(qn.connectEnd),e.push(qn.requestStart),e.push(qn.responseStart),e.push(qn.responseEnd),e.push(qn.domInteractive),e.push(qn.domComplete),e.push(qn.loadEventStart),e.push(qn.loadEventEnd),e.push(qn.redirectCount),e.push(qn.size),e.push(qn.type),e.push(qn.protocol),e.push(qn.encodedSize),e.push(qn.decodedSize),Cn(),ht(e)),[2]}))}))}(29)}var Nn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint"];function Rn(){try{zn&&zn.disconnect(),zn=new PerformanceObserver(an(Dn));for(var t=0,n=Nn;t<n.length;t++){var e=n[t];PerformanceObserver.supportedEntryTypes.indexOf(e)>=0&&("layout-shift"===e&&x(9,0),zn.observe({type:e,buffered:!0}))}}catch(t){}}function Dn(t){!function(t){for(var n=(!("visibilityState"in document)||"visible"===document.visibilityState),e=0;e<t.length;e++){var r=t[e];switch(r.entryType){case"navigation":An(r);break;case"resource":var o=r.name;jt(4,Pn(o)),o!==a.upload&&o!==a.fallback||O(28,r.duration);break;case"longtask":M(7);break;case"first-input":n&&O(10,r.processingStart-r.startTime);break;case"layout-shift":n&&!r.hadRecentInput&&x(9,1e3*r.value);break;case"largest-contentful-paint":n&&O(8,r.startTime)}}}(t.getEntries())}function Pn(t){var n=document.createElement("a");return n.href=t,n.host}var Hn=[w,w,w,Object.freeze({__proto__:null,start:function(){Cn(),function(){navigator&&"connection"in navigator&&jt(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?cn(window,"load",T.bind(this,Rn,0)):Rn())}()},stop:function(){zn&&zn.disconnect(),zn=null,Cn()}})];function Un(t){void 0===t&&(t=null),function(){try{return!1===In&&"undefined"!=typeof Promise&&window.MutationObserver&&document.createTreeWalker&&"now"in Date&&"now"in performance&&"undefined"!=typeof WeakMap}catch(t){return!1}}()&&(Tn(t),Mn(),tt(),Hn.forEach((function(t){return an(t.start)()})),null===t&&Wn())}function Bn(){On()&&(Hn.slice().reverse().forEach((function(t){return an(t.stop)()})),nt(),xn(),void 0!==Ln&&(Ln[Xn]=function(){(Ln[Xn].q=Ln[Xn].q||[]).push(arguments),"start"===arguments[0]&&Ln[Xn].q.unshift(Ln[Xn].q.pop())&&Wn()}))}var Vn=Object.freeze({__proto__:null,consent:Bt,event:_,hashText:y,identify:X,metadata:Ht,pause:function(){On()&&(_("clarity","pause"),null===wn&&(wn=new Promise((function(t){kn=t}))))},resume:function(){On()&&(_n(),_("clarity","resume"))},set:L,start:Un,stop:Bn,upgrade:P,version:s}),Ln=window,Xn="clarity";function Wn(){if(void 0!==Ln){if(Ln[Xn]&&Ln[Xn].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=Ln[Xn]&&Ln[Xn].q||[];for(Ln[Xn]=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return Vn[t].apply(Vn,n)},Ln[Xn].v=s;t.length>0;)Ln[Xn].apply(Ln,t.shift())}}Wn()}();
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "clarity-js",
3
- "version": "0.7.18",
3
+ "version": "0.7.19",
4
4
  "description": "An analytics library that uses web page interactions to generate aggregated insights",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
7
7
  "main": "build/clarity.js",
8
8
  "module": "build/clarity.module.js",
9
9
  "unpkg": "build/clarity.min.js",
10
+ "extended": "build/clarity.extended.js",
10
11
  "insight": "build/clarity.insight.js",
11
12
  "performance": "build/clarity.performance.js",
12
13
  "types": "types/index.d.ts",
package/rollup.config.ts CHANGED
@@ -13,6 +13,11 @@ export default [
13
13
  { file: pkg.module, format: "es", exports: "named" }
14
14
  ],
15
15
  plugins: [
16
+ alias({
17
+ entries: [
18
+ { find: '@src/layout/adoptedStyles', replacement: '@src/insight/blank' }
19
+ ]
20
+ }),
16
21
  resolve(),
17
22
  typescript(),
18
23
  commonjs({ include: ["node_modules/**"] })
@@ -29,6 +34,25 @@ export default [
29
34
  if (message.code === 'CIRCULAR_DEPENDENCY') { return; }
30
35
  warn(message);
31
36
  },
37
+ plugins: [
38
+ alias({
39
+ entries: [
40
+ { find: '@src/layout/adoptedStyles', replacement: '@src/insight/blank' }
41
+ ]
42
+ }),
43
+ resolve(),
44
+ typescript(),
45
+ terser({output: {comments: false}}),
46
+ commonjs({ include: ["node_modules/**"] })
47
+ ]
48
+ },
49
+ {
50
+ input: "src/global.ts",
51
+ output: [ { file: pkg.extended, format: "iife", exports: "named" } ],
52
+ onwarn(message, warn) {
53
+ if (message.code === 'CIRCULAR_DEPENDENCY') { return; }
54
+ warn(message);
55
+ },
32
56
  plugins: [
33
57
  resolve(),
34
58
  typescript(),
@@ -46,6 +70,7 @@ export default [
46
70
  plugins: [
47
71
  alias({
48
72
  entries: [
73
+ { find: '@src/layout/adoptedStyles', replacement: '@src/insight/blank' },
49
74
  { find: '@src/layout/document', replacement: '@src/layout/document' },
50
75
  { find: '@src/layout/encode', replacement: '@src/insight/encode' },
51
76
  { find: /@src\/interaction\/(change|clipboard|input|pointer|selection)/, replacement: '@src/insight/blank' },
@@ -1,2 +1,2 @@
1
- let version = "0.7.18";
1
+ let version = "0.7.19";
2
2
  export default version;
@@ -16,6 +16,7 @@ import * as ping from "@src/data/ping";
16
16
  import * as timeline from "@src/interaction/timeline";
17
17
  import * as region from "@src/layout/region";
18
18
  import * as extract from "@src/data/extract";
19
+ import * as style from "@src/layout/style";
19
20
  import { report } from "@src/core/report";
20
21
 
21
22
  let discoverBytes: number = 0;
@@ -51,6 +52,8 @@ export function queue(tokens: Token[], transmit: boolean = true): void {
51
52
  case Event.Box:
52
53
  case Event.Mutation:
53
54
  case Event.Snapshot:
55
+ case Event.StyleSheetAdoption:
56
+ case Event.StyleSheetUpdate:
54
57
  playbackBytes += event.length;
55
58
  playback.push(event);
56
59
  break;
@@ -110,6 +113,7 @@ async function upload(final: boolean = false): Promise<void> {
110
113
  region.compute();
111
114
  timeline.compute();
112
115
  data.compute();
116
+ style.compute();
113
117
 
114
118
  // Treat this as the last payload only if final boolean was explicitly set to true.
115
119
  // In real world tests, we noticed that certain third party scripts (e.g. https://www.npmjs.com/package/raven-js)
@@ -9,3 +9,4 @@ export function stop(): void {}
9
9
  export function log(): void {}
10
10
  export function observe(): void {}
11
11
  export function compute(): void {}
12
+ export function checkDocumentStyles(_d: Document): void {}
@@ -9,6 +9,7 @@ import * as doc from "@src/layout/document";
9
9
  import encode from "@src/layout/encode";
10
10
  import * as region from "@src/layout/region";
11
11
  import traverse from "@src/layout/traverse";
12
+ import { checkDocumentStyles } from "@src/layout/style";
12
13
 
13
14
  export function start(): void {
14
15
  task.schedule(discover, Priority.High).then((): void => {
@@ -23,6 +24,7 @@ async function discover(): Promise<void> {
23
24
  let timer: Timer = { id: id(), cost: Metric.LayoutCost };
24
25
  task.start(timer);
25
26
  await traverse(document, timer, Source.Discover);
27
+ checkDocumentStyles(document);
26
28
  await encode(Event.Discover, timer, ts);
27
29
  task.stop(timer);
28
30
  }
@@ -9,9 +9,10 @@ import tokenize from "@src/data/token";
9
9
  import * as baseline from "@src/data/baseline";
10
10
  import { queue } from "@src/data/upload";
11
11
  import * as fraud from "@src/diagnostic/fraud";
12
- import * as doc from "./document";
13
- import * as dom from "./dom";
14
- import * as region from "./region";
12
+ import * as doc from "@src/layout/document";
13
+ import * as dom from "@src/layout/dom";
14
+ import * as region from "@src/layout/region";
15
+ import * as style from "@src/layout/style";
15
16
  import * as animation from "@src/layout/animation";
16
17
 
17
18
  export default async function (type: Event, timer: Timer = null, ts: number = null): Promise<void> {
@@ -36,6 +37,25 @@ export default async function (type: Event, timer: Timer = null, ts: number = nu
36
37
  }
37
38
  region.reset();
38
39
  break;
40
+ case Event.StyleSheetAdoption:
41
+ for (let entry of style.state) {
42
+ tokens = [entry.time, entry.event];
43
+ tokens.push(entry.data.id);
44
+ tokens.push(entry.data.operation);
45
+ tokens.push(entry.data.newIds);
46
+ queue(tokens);
47
+ }
48
+ style.reset();
49
+ break;
50
+ case Event.StyleSheetUpdate:
51
+ for (let entry of style.state) {
52
+ tokens = [entry.time, entry.event];
53
+ tokens.push(entry.data.id);
54
+ tokens.push(entry.data.operation);
55
+ tokens.push(entry.data.cssRules);
56
+ queue(tokens);
57
+ }
58
+ style.reset();
39
59
  case Event.Animation:
40
60
  for (let entry of animation.state) {
41
61
  tokens = [entry.time, entry.event];
@@ -3,6 +3,7 @@ import * as doc from "@src/layout/document";
3
3
  import * as dom from "@src/layout/dom";
4
4
  import * as mutation from "@src/layout/mutation";
5
5
  import * as region from "@src/layout/region";
6
+ import * as style from "@src/layout/style";
6
7
  import * as animation from "@src/layout/animation";
7
8
 
8
9
  export { hashText } from "@src/layout/dom";
@@ -15,6 +16,7 @@ export function start(): void {
15
16
  dom.start();
16
17
  mutation.start();
17
18
  discover.start();
19
+ style.start();
18
20
  animation.start();
19
21
  }
20
22
 
@@ -23,5 +25,6 @@ export function stop(): void {
23
25
  dom.stop();
24
26
  mutation.stop();
25
27
  doc.stop();
28
+ style.stop();
26
29
  animation.stop();
27
30
  }
@@ -6,6 +6,7 @@ import * as internal from "@src/diagnostic/internal";
6
6
  import * as interaction from "@src/interaction";
7
7
  import * as mutation from "@src/layout/mutation";
8
8
  import * as schema from "@src/layout/schema";
9
+ import { checkDocumentStyles } from "@src/layout/style";
9
10
  import { electron } from "@src/data/metadata";
10
11
 
11
12
  const IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
@@ -42,6 +43,7 @@ export default function (node: Node, source: Source): Node {
42
43
  // We check for regions in the beginning when discovering document and
43
44
  // later whenever there are new additions or modifications to DOM (mutations)
44
45
  if (node === document) dom.parse(document);
46
+ checkDocumentStyles(node as Document);
45
47
  observe(node);
46
48
  break;
47
49
  case Node.DOCUMENT_FRAGMENT_NODE:
@@ -51,13 +53,12 @@ export default function (node: Node, source: Source): Node {
51
53
  let type = typeof (shadowRoot.constructor);
52
54
  if (type === Constant.Function && shadowRoot.constructor.toString().indexOf(Constant.NativeCode) >= 0) {
53
55
  observe(shadowRoot);
56
+
54
57
  // See: https://wicg.github.io/construct-stylesheets/ for more details on adoptedStyleSheets.
55
58
  // At the moment, we are only able to capture "open" shadow DOM nodes. If they are closed, they are not accessible.
56
59
  // In future we may decide to proxy "attachShadow" call to gain access, but at the moment, we don't want to
57
60
  // cause any unintended side effect to the page. We will re-evaluate after we gather more real world data on this.
58
61
  let style = Constant.Empty as string;
59
- let adoptedStyleSheets: CSSStyleSheet[] = "adoptedStyleSheets" in shadowRoot ? shadowRoot["adoptedStyleSheets"] : [];
60
- for (let styleSheet of adoptedStyleSheets) { style += getCssRules(styleSheet); }
61
62
  let fragmentData = { tag: Constant.ShadowDomTag, attributes: { style } };
62
63
  dom[call](node, shadowRoot.host, fragmentData, source);
63
64
  } else {
@@ -66,6 +67,7 @@ export default function (node: Node, source: Source): Node {
66
67
  // the same way we observe real shadow DOM nodes (encapsulation provided by the browser).
67
68
  dom[call](node, shadowRoot.host, { tag: Constant.PolyfillShadowDomTag, attributes: {} }, source);
68
69
  }
70
+ checkDocumentStyles(node as Document);
69
71
  }
70
72
  break;
71
73
  case Node.TEXT_NODE:
@@ -206,7 +208,7 @@ function getStyleValue(style: HTMLStyleElement): string {
206
208
  return value;
207
209
  }
208
210
 
209
- function getCssRules(sheet: CSSStyleSheet): string {
211
+ export function getCssRules(sheet: CSSStyleSheet): string {
210
212
  let value = Constant.Empty as string;
211
213
  let cssRules = null;
212
214
  // Firefox throws a SecurityError when trying to access cssRules of a stylesheet from a different domain
@@ -0,0 +1,127 @@
1
+ import { Event } from "@clarity-types/data";
2
+ import { StyleSheetOperation, StyleSheetState } from "@clarity-types/layout";
3
+ import { time } from "@src/core/time";
4
+ import { shortid } from "@src/data/metadata";
5
+ import encode from "@src/layout/encode";
6
+ import { getId, getNode } from "@src/layout/dom";
7
+ import * as core from "@src/core";
8
+ import { getCssRules } from "./node";
9
+
10
+ export let state: StyleSheetState[] = [];
11
+ let replace: (text?: string) => Promise<CSSStyleSheet> = null;
12
+ let replaceSync: (text?: string) => void = null;
13
+ const styleSheetId = 'claritySheetId';
14
+ let styleSheetMap = {};
15
+
16
+ export function start(): void {
17
+ reset();
18
+
19
+ if (replace === null) {
20
+ replace = CSSStyleSheet.prototype.replace;
21
+ CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
22
+ if (core.active()) {
23
+ if (!this[styleSheetId]) {
24
+ this[styleSheetId] = shortid();
25
+ // need to pass a create style sheet event (don't add it to any nodes, but do create it)
26
+ trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Create);
27
+ }
28
+
29
+ trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Replace, arguments[0]);
30
+ }
31
+ return replace.apply(this, arguments);
32
+ };
33
+ }
34
+
35
+ if (replaceSync === null) {
36
+ replaceSync = CSSStyleSheet.prototype.replaceSync;
37
+ CSSStyleSheet.prototype.replaceSync = function(): void {
38
+ if (core.active()) {
39
+ if (!this[styleSheetId]) {
40
+ this[styleSheetId] = shortid();
41
+ // need to pass a create style sheet event (don't add it to any nodes, but do create it)
42
+ trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Create);
43
+ }
44
+ trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.ReplaceSync, arguments[0]);
45
+ }
46
+ return replaceSync.apply(this, arguments);
47
+ };
48
+ }
49
+ }
50
+
51
+ export function checkDocumentStyles(documentNode: Document): void {
52
+ if (!documentNode?.adoptedStyleSheets) {
53
+ // if we don't have adoptedStyledSheets on the Node passed to us, we can short circuit.
54
+ return;
55
+ }
56
+ let currentStyleSheets: string[] = [];
57
+ for (var styleSheet of documentNode.adoptedStyleSheets) {
58
+ // if we haven't seen this style sheet, create it and pass a replaceSync with its contents
59
+ if (!styleSheet[styleSheetId]) {
60
+ styleSheet[styleSheetId] = shortid();
61
+ trackStyleChange(time(), styleSheet[styleSheetId], StyleSheetOperation.Create);
62
+ trackStyleChange(time(), styleSheet[styleSheetId], StyleSheetOperation.ReplaceSync, getCssRules(styleSheet));
63
+ }
64
+ currentStyleSheets.push(styleSheet[styleSheetId]);
65
+ }
66
+
67
+ let documentId = getId(documentNode, true);
68
+ if (!styleSheetMap[documentId]) {
69
+ styleSheetMap[documentId] = [];
70
+ }
71
+ if (!arraysEqual(currentStyleSheets, styleSheetMap[documentId])) {
72
+ // Using -1 to signify the root document node as we don't track that as part of our nodeMap
73
+ trackStyleAdoption(time(), documentNode == document ? -1 : getId(documentNode), StyleSheetOperation.SetAdoptedStyles, currentStyleSheets);
74
+ styleSheetMap[documentId] = currentStyleSheets;
75
+ }
76
+ }
77
+
78
+ export function compute(): void {
79
+ checkDocumentStyles(document);
80
+ Object.keys(styleSheetMap).forEach((x) => checkDocumentStyles(getNode(parseInt(x, 10)) as Document));
81
+ }
82
+
83
+ export function reset(): void {
84
+ state = [];
85
+
86
+ }
87
+
88
+ export function stop(): void {
89
+ styleSheetMap = {};
90
+ reset();
91
+ }
92
+
93
+ function trackStyleChange(time: number, id: string, operation: StyleSheetOperation, cssRules?: string): void {
94
+ state.push({
95
+ time,
96
+ event: Event.StyleSheetUpdate,
97
+ data: {
98
+ id,
99
+ operation,
100
+ cssRules
101
+ }
102
+ });
103
+
104
+ encode(Event.StyleSheetUpdate);
105
+ }
106
+
107
+ function trackStyleAdoption(time: number, id: number, operation: StyleSheetOperation, newIds: string[]): void {
108
+ state.push({
109
+ time,
110
+ event: Event.StyleSheetAdoption,
111
+ data: {
112
+ id,
113
+ operation,
114
+ newIds
115
+ }
116
+ });
117
+
118
+ encode(Event.StyleSheetAdoption);
119
+ }
120
+
121
+ function arraysEqual(a: string[], b: string[]): boolean {
122
+ if (a.length !== b.length) {
123
+ return false;
124
+ }
125
+
126
+ return a.every((value, index) => value === b[index]);
127
+ }
package/types/data.d.ts CHANGED
@@ -65,7 +65,9 @@ export const enum Event {
65
65
  Fraud = 41,
66
66
  Change = 42,
67
67
  Snapshot = 43,
68
- Animation = 44
68
+ Animation = 44,
69
+ StyleSheetAdoption = 45,
70
+ StyleSheetUpdate = 46
69
71
  }
70
72
 
71
73
  export const enum Metric {
package/types/layout.d.ts CHANGED
@@ -157,6 +157,13 @@ export const enum Setting {
157
157
  MutationActivePeriod = 3000 // Unit: milliseconds. Let mutations continue as normal during active periods of user interactions
158
158
  }
159
159
 
160
+ export const enum StyleSheetOperation {
161
+ Create = 0,
162
+ Replace = 1,
163
+ ReplaceSync = 2,
164
+ SetAdoptedStyles = 3
165
+ }
166
+
160
167
  /* Helper Interfaces */
161
168
  export interface Box {
162
169
  x: number; // Left
@@ -223,6 +230,12 @@ export interface RegionState {
223
230
  data: RegionData;
224
231
  }
225
232
 
233
+ export interface StyleSheetState {
234
+ time: number;
235
+ event: number,
236
+ data: StyleSheetData
237
+ }
238
+
226
239
  /* Event Data */
227
240
 
228
241
  export interface DocumentData {
@@ -243,3 +256,10 @@ export interface TargetMetadata {
243
256
  privacy: Privacy;
244
257
  node: Node;
245
258
  }
259
+
260
+ export interface StyleSheetData {
261
+ id: number | string;
262
+ operation: StyleSheetOperation;
263
+ cssRules?: string;
264
+ newIds?: string[]
265
+ }