clarity-js 0.8.6-beta → 0.8.8-beta

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 yt},get start(){return mt},get stop(){return bt},get track(){return dt}}),n=Object.freeze({__proto__:null,get check(){return Mt},get compute(){return Tt},get data(){return pt},get start(){return It},get stop(){return xt},get trigger(){return Ot}}),e=Object.freeze({__proto__:null,get compute(){return Nt},get data(){return jt},get log(){return qt},get reset(){return Dt},get start(){return Ct},get stop(){return Pt},get updates(){return zt}}),r=Object.freeze({__proto__:null,get callback(){return Gt},get callbacks(){return Ut},get clear(){return Zt},get consent(){return Jt},get data(){return Ht},get electron(){return Xt},get id(){return Wt},get metadata(){return Yt},get save(){return Ft},get shortid(){return $t},get start(){return Vt},get stop(){return Bt}}),o=Object.freeze({__proto__:null,get data(){return un},get envelope(){return ln},get start(){return cn},get stop(){return sn}}),a={projectId:null,delay:1e3,lean:!1,lite:!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,delayDom:!1,throttleDom:!0,conversions:!1,includeSubdomains:!0,throttleMutations:!1,dropMutations:!1,criticalMs:200,discard:[]};function i(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var u=0;function c(t){void 0===t&&(t=null);var n=t&&t.timeStamp>0?t.timeStamp:performance.now(),e=t&&t.view?t.view.performance.timeOrigin:performance.timeOrigin;return Math.max(Math.round(n+e-u),0)}var s="0.8.6-beta";var l=255,d=!0,p=null,f=null;function h(t,n,e){void 0===n&&(n=!1),void 0===e&&(e=!1);var r=t;if(n)r="".concat("https://").concat("Electron");else{var o=a.drop;if(o&&o.length>0&&t&&t.indexOf("?")>0){var i=t.split("?"),u=i[0],c=i[1];r=u+"?"+c.split("&").map((function(t){return o.some((function(n){return 0===t.indexOf("".concat(n,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}}return e&&(r=r.substring(0,l)),r}function v(t,n,e){return function(){if(d&&null===p)try{p=new RegExp("\\p{N}","gu"),f=new RegExp("\\p{L}","gu"),new RegExp("\\p{Sc}","gu")}catch(t){d=!1}}(),t?t.replace(f,n).replace(p,e):t}var g=[],m=null;function y(){}var b=[];function w(){}function k(){}var S=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:m,hashText:w,keys:b,log:y,observe:function(){},reset:function(){},sheetAdoptionState:[],sheetUpdateState:[],start:function(){},state:g,stop:function(){},trigger:k}),_=null;function E(t,n){qn()&&t&&"string"==typeof t&&t.length<255&&(_=n&&"string"==typeof n&&n.length<255?{key:t,value:n}:{value:t},Et(24))}var I,M=null,O=null;function T(t){t in M||(M[t]=0),t in O||(O[t]=0),M[t]++,O[t]++}function x(t,n){null!==n&&(t in M||(M[t]=0),t in O||(O[t]=0),M[t]+=n,O[t]+=n)}function j(t,n){null!==n&&!1===isNaN(n)&&(t in M||(M[t]=0),(n>M[t]||0===M[t])&&(O[t]=n,M[t]=n))}function z(t,n,e){return window.setTimeout(fn(t),n,e)}function A(t){return window.clearTimeout(t)}var C=0,P=0,q=null;function N(){q&&A(q),q=z(D,P),C=c()}function D(){var t=c();I={gap:t-C},Et(25),I.gap<3e5?q=z(D,P):An&&(E("clarity","suspend"),oe(),["mousemove","touchstart"].forEach((function(t){return vn(document,t,Nn)})),["resize","scroll","pageshow"].forEach((function(t){return vn(window,t,Nn)})))}var R=Object.freeze({__proto__:null,get data(){return I},reset:N,start:function(){P=6e4,C=0},stop:function(){A(q),C=0,P=0}}),H=null;function U(t){qn()&&a.lean&&(a.lean=!1,H={key:t},Gt(),Ft(),a.upgrade&&a.upgrade(t),Et(3),a.lite)}var X=Object.freeze({__proto__:null,get data(){return H},start:function(){!a.lean&&a.upgrade&&a.upgrade("Config"),H=null},stop:function(){H=null},upgrade:U});function L(t,n,e,r){return new(e||(e=Promise))((function(o,a){function i(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(i,u)}c((r=r.apply(t,n||[])).next())}))}function V(t,n){var e,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(t,i)}catch(t){u=[6,t],r=0}finally{e=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}var B=null;function Y(t,n){J(t,"string"==typeof n?[n]:n)}function W(t,n,e,r){return void 0===n&&(n=null),void 0===e&&(e=null),void 0===r&&(r=null),L(this,void 0,void 0,(function(){var o,a;return V(this,(function(i){switch(i.label){case 0:return a={},[4,F(t)];case 1:return a.userId=i.sent(),a.userHint=r||((u=t)&&u.length>=5?"".concat(u.substring(0,2)).concat(v(u.substring(2),"*","*")):v(u,"*","*")),J("userId",[(o=a).userId]),J("userHint",[o.userHint]),J("userType",[K(t)]),n&&(J("sessionId",[n]),o.sessionId=n),e&&(J("pageId",[e]),o.pageId=e),[2,o]}var u}))}))}function J(t,n){if(qn()&&t&&n&&"string"==typeof t&&t.length<255){for(var e=(t in B?B[t]:[]),r=0;r<n.length;r++)"string"==typeof n[r]&&n[r].length<255&&e.push(n[r]);B[t]=e}}function Z(){Et(34)}function G(){B={}}function F(t){return L(this,void 0,void 0,(function(){var n;return V(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 K(t){return t&&t.indexOf("@")>0?"email":"string"}var Q="CompressionStream"in window;function $(t){return L(this,void 0,void 0,(function(){var n,e;return V(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),Q?(n=new ReadableStream({start:function(n){return L(this,void 0,void 0,(function(){return V(this,(function(e){return n.enqueue(t),n.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),e=Uint8Array.bind,[4,tt(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 tt(t){return L(this,void 0,void 0,(function(){var n,e,r,o,a;return V(this,(function(i){switch(i.label){case 0:n=t.getReader(),e=[],r=!1,o=[],i.label=1;case 1:return r?[3,3]:[4,n.read()];case 2:return a=i.sent(),r=a.done,o=a.value,r?[2,e]:(e.push.apply(e,o),[3,1]);case 3:return[2,e]}}))}))}var nt=null;function et(t){try{if(!nt)return;var n=function(t){try{return JSON.parse(t)}catch(t){return[]}}(t);n.forEach((function(t){nt(t)}))}catch(t){}}var rt=[S,e,Object.freeze({__proto__:null,compute:Z,get data(){return B},identify:W,reset:G,set:Y,start:function(){G()},stop:function(){G()}}),n,S,r,o,t,R,X,S];function ot(){M={},O={},T(5),rt.forEach((function(t){return fn(t.start)()}))}function at(){rt.slice().reverse().forEach((function(t){return fn(t.stop)()})),M={},O={}}function it(){Z(),Nt(),Et(0),Tt()}var ut,ct,st,lt,dt,pt,ft=0,ht=0,vt=null,gt=0;function mt(){lt=!0,ft=0,ht=0,gt=0,ut=[],ct=[],st={},dt=null}function yt(t,n){if(void 0===n&&(n=!0),lt){var e=c(),r=t.length>1?t[1]:null,o=JSON.stringify(t);switch(r){case 5:ft+=o.length;case 37:case 6:case 43:case 45:case 46:ht+=o.length,ut.push(o);break;default:ct.push(o)}T(25);var i=function(){var t=!1===a.lean&&ft>0?100:un.sequence*a.delay;return"string"==typeof a.upload?Math.max(Math.min(t,3e4),100):a.delay}();e-gt>2*i&&(A(vt),vt=null),n&&null===vt&&(25!==r&&N(),vt=z(wt,i),gt=e,Mt(ht))}}function bt(){A(vt),wt(!0),ft=0,ht=0,gt=0,ut=[],ct=[],st={},dt=null,lt=!1}function wt(t){return void 0===t&&(t=!1),L(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,s;return V(this,(function(l){switch(l.label){case 0:return vt=null,(n=!1===a.lean&&ht>0&&(ht<1048576||un.sequence>0))&&j(1,1),it(),e=!0===t,r=JSON.stringify(ln(e)),o="[".concat(ct.join(),"]"),i=n?"[".concat(ut.join(),"]"):"",u=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:i}),e?(s=null,[3,3]):[3,1];case 1:return[4,$(u)];case 2:s=l.sent(),l.label=3;case 3:return x(2,(c=s)?c.length:u.length),kt(u,c,un.sequence,e),ct=[],n&&(ut=[],ht=0,ft=0),[2]}}))}))}function kt(t,n,e,r){if(void 0===r&&(r=!1),"string"==typeof a.upload){var o=a.upload,i=!1;if(r&&"sendBeacon"in navigator)try{(i=navigator.sendBeacon.bind(navigator)(o,t))&&_t(e)}catch(t){}if(!1===i){e in st?st[e].attempts++:st[e]={data:t,attempts:1};var u=new XMLHttpRequest;u.open("POST",o,!0),u.timeout=15e3,u.ontimeout=function(){pn(new Error("".concat("Timeout"," : ").concat(o)))},null!==e&&(u.onreadystatechange=function(){fn(St)(u,e)}),u.withCredentials=!0,n?(u.setRequestHeader("Accept","application/x-clarity-gzip"),u.send(n)):u.send(t)}}else if(a.upload){(0,a.upload)(t),_t(e)}}function St(t,n){var e=st[n];t&&4===t.readyState&&e&&((t.status<200||t.status>208)&&e.attempts<=1?t.status>=400&&t.status<500?Ot(6):(0===t.status&&(a.upload=a.fallback?a.fallback:a.upload),kt(e.data,null,n)):(dt={sequence:n,attempts:e.attempts,status:t.status},e.attempts>1&&Et(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],i=o&&o.length>0?o.split(/ (.*)/):[""];switch(i[0]){case"END":Ot(6);break;case"UPGRADE":U("Auto");break;case"ACTION":a.action&&i.length>1&&a.action(i[1]);break;case"EXTRACT":i.length>1&&i[1];break;case"SIGNAL":i.length>1&&et(i[1])}}}(t.responseText),0===t.status&&(kt(e.data,null,n,!0),Ot(3)),t.status>=200&&t.status<=208&&_t(n),delete st[n]))}function _t(t){1===t&&(Ft(),Gt())}function Et(t){var n=[c(),t];switch(t){case 4:var e=g;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),n.push(e.data.scrollTime),n.push(e.data.pointerTime),n.push(e.data.moveX),n.push(e.data.moveY),n.push(e.data.moveTime),n.push(e.data.downX),n.push(e.data.downY),n.push(e.data.downTime),n.push(e.data.upX),n.push(e.data.upY),n.push(e.data.upTime),n.push(e.data.pointerPrevX),n.push(e.data.pointerPrevY),n.push(e.data.pointerPrevTime),yt(n,!1));break;case 25:n.push(I.gap),yt(n);break;case 35:n.push(pt.check),yt(n,!1);break;case 3:n.push(H.key),yt(n);break;case 2:n.push(dt.sequence),n.push(dt.attempts),n.push(dt.status),yt(n,!1);break;case 24:_.key&&n.push(_.key),n.push(_.value),yt(n);break;case 34:var r=Object.keys(B);if(r.length>0){for(var o=0,a=r;o<a.length;o++){var i=a[o];n.push(i),n.push(B[i])}G(),yt(n,!1)}break;case 0:var u=Object.keys(O);if(u.length>0){for(var s=0,l=u;s<l.length;s++){var d=l[s],p=parseInt(d,10);n.push(p),n.push(Math.round(O[d]))}O={},yt(n,!1)}break;case 1:var f=Object.keys(zt);if(f.length>0){for(var h=0,v=f;h<v.length;h++){var y=v[h];p=parseInt(y,10);n.push(p),n.push(zt[y])}Dt(),yt(n,!1)}break;case 36:var w=Object.keys(m);if(w.length>0){for(var k=0,S=w;k<S.length;k++){var E=S[k];p=parseInt(E,10);n.push(p),n.push([].concat.apply([],m[E]))}yt(n,!1)}break;case 40:b.forEach((function(t){n.push(t);var e=[];for(var r in m[t]){var o=parseInt(r,10);e.push(o),e.push(m[t][r])}n.push(e)})),yt(n,!1)}}function It(){pt={check:0}}function Mt(t){if(0===pt.check){var n=pt.check;n=un.sequence>=128?1:n,n=un.pageNum>=128?7:n,n=c()>72e5?2:n,(n=t>10485760?2:n)!==pt.check&&Ot(n)}}function Ot(t){pt.check=t,5!==t&&(Zt(),oe())}function Tt(){0!==pt.check&&Et(35)}function xt(){pt=null}var jt=null,zt=null,At=!1;function Ct(){jt={},zt={},At=!1}function Pt(){jt={},zt={},At=!1}function qt(t,n){if(n&&(n="".concat(n),t in jt||(jt[t]=[]),jt[t].indexOf(n)<0)){if(jt[t].length>128)return void(At||(At=!0,Ot(5)));jt[t].push(n),t in zt||(zt[t]=[]),zt[t].push(n)}}function Nt(){Et(1)}function Dt(){zt={},At=!1}function Rt(t){qt(36,t.toString())}var Ht=null,Ut=[],Xt=0,Lt=null;function Vt(){var t,n,e;Lt=null;var r=navigator&&"userAgent"in navigator?navigator.userAgent:"",o=null!==(e=null===(n=null===(t=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat())||void 0===t?void 0:t.resolvedOptions())||void 0===n?void 0:n.timeZone)&&void 0!==e?e:"",i=(new Date).getTimezoneOffset().toString(),u=window.location.ancestorOrigins?Array.from(window.location.ancestorOrigins).toString():"",c=document&&document.title?document.title:"";Xt=r.indexOf("Electron")>0?1:0;var s,l=function(){var t={session:$t(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},n=en("_clsk",!a.includeSubdomains);if(n){var e=n.includes("^")?n.split("^"):n.split("|");e.length>=5&&t.ts-tn(e[1])<18e5&&(t.session=e[0],t.count=tn(e[2])+1,t.upgrade=tn(e[3]),t.upload=e.length>=6?"".concat("https://").concat(e[5],"/").concat(e[4]):"".concat("https://").concat(e[4]))}return t}(),d=nn(),p=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);Ht={projectId:p,userId:d.id,sessionId:l.session,pageNum:l.count},a.lean=a.track&&null!==l.upgrade?0===l.upgrade:a.lean,a.upload=a.track&&"string"==typeof a.upload&&l.upload&&l.upload.length>"https://".length?l.upload:a.upload,qt(0,r),qt(3,c),qt(1,h(location.href,!!Xt)),qt(2,document.referrer),qt(15,function(){var t=$t();if(a.track&&Kt(window,"sessionStorage")){var n=sessionStorage.getItem("_cltk");t=n||t,sessionStorage.setItem("_cltk",t)}return t}()),qt(16,document.documentElement.lang),qt(17,document.dir),qt(26,"".concat(window.devicePixelRatio)),qt(28,d.dob.toString()),qt(29,d.version.toString()),qt(33,u),qt(34,o),qt(35,i),j(0,l.ts),j(1,0),j(35,Xt),navigator&&(qt(9,navigator.language),j(33,navigator.hardwareConcurrency),j(32,navigator.maxTouchPoints),j(34,Math.round(navigator.deviceMemory)),(s=navigator.userAgentData)&&s.getHighEntropyValues?s.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var n;qt(22,t.platform),qt(23,t.platformVersion),null===(n=t.brands)||void 0===n||n.forEach((function(t){qt(24,t.name+"~"+t.version)})),qt(25,t.model),j(27,t.mobile?1:0)})):qt(22,navigator.platform)),screen&&(j(14,Math.round(screen.width)),j(15,Math.round(screen.height)),j(16,Math.round(screen.colorDepth)));for(var f=0,v=a.cookies;f<v.length;f++){var g=v[f],m=en(g);m&&Y(g,m)}!function(t){Rt(t?1:0)}(a.track),Qt(d)}function Bt(){Lt=null,Ht=null,Ut.forEach((function(t){t.called=!1}))}function Yt(t,n,e){void 0===n&&(n=!0),void 0===e&&(e=!1);var r=a.lean?0:1,o=!1;Ht&&(r||!1===n)&&(t(Ht,!a.lean),o=!0),!e&&o||Ut.push({callback:t,wait:n,recall:e,called:o})}function Wt(){return Ht?[Ht.userId,Ht.sessionId,Ht.pageNum].join("."):""}function Jt(t){if(void 0===t&&(t=!0),!t)return a.track=!1,on("_clsk","",-Number.MAX_VALUE),on("_clck","",-Number.MAX_VALUE),oe(),void window.setTimeout(re,250);qn()&&(a.track=!0,Qt(nn(),1),Ft(),Rt(2))}function Zt(){on("_clsk","",0)}function Gt(){!function(t){if(Ut.length>0)for(var n=0;n<Ut.length;n++){var e=Ut[n];!e.callback||e.called||e.wait&&!t||(e.callback(Ht,!a.lean),e.called=!0,e.recall||(Ut.splice(n,1),n--))}}(a.lean?0:1)}function Ft(){if(Ht&&a.track){var t=Math.round(Date.now()),n=a.upload&&"string"==typeof a.upload?a.upload.replace("https://",""):"",e=a.lean?0:1;on("_clsk",[Ht.sessionId,t,Ht.pageNum,e,n].join("|"),1)}}function Kt(t,n){try{return!!t[n]}catch(t){return!1}}function Qt(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)&&on("_clck",[Ht.userId,2,e.toString(36),n,r].join("|"),365)}function $t(){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 tn(t,n){return void 0===n&&(n=10),parseInt(t,n)}function nn(){var t={id:$t(),version:0,expiry:null,consent:0,dob:0},n=en("_clck",!a.includeSubdomains);if(n&&n.length>0){var e=n.includes("^")?n.split("^"):n.split("|");e.length>1&&(t.version=tn(e[1])),e.length>2&&(t.expiry=tn(e[2],36)),e.length>3&&1===tn(e[3])&&(t.consent=1),e.length>4&&tn(e[1])>1&&(t.dob=tn(e[4])),a.track=a.track||1===t.consent,t.id=a.track?e[0]:t.id}return t}function en(t,n){var e;if(void 0===n&&(n=!1),Kt(document,"cookie")){var r=document.cookie.split(";");if(r)for(var o=0;o<r.length;o++){var a=r[o].split("=");if(a.length>1&&a[0]&&a[0].trim()===t){for(var i=rn(a[1]),u=i[0],c=i[1];u;)u=(e=rn(c))[0],c=e[1];return n?c.endsWith("".concat("~","1"))?c.substring(0,c.length-2):null:c}}}return null}function rn(t){try{var n=decodeURIComponent(t);return[n!=t,n]}catch(t){}return[!1,t]}function on(t,n,e){if((a.track||""==n)&&(navigator&&navigator.cookieEnabled||Kt(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(n),o=new Date;o.setDate(o.getDate()+e);var i=o?"expires="+o.toUTCString():"",u="".concat(t,"=").concat(r).concat(";").concat(i).concat(";path=/");try{if(null===Lt){for(var c=location.hostname?location.hostname.split("."):[],s=c.length-1;s>=0;s--)if(Lt=".".concat(c[s]).concat(Lt||""),s<c.length-1&&(document.cookie="".concat(u).concat(";").concat("domain=").concat(Lt),en(t)===n))return;Lt=""}}catch(t){Lt=""}document.cookie=Lt?"".concat(u).concat(";").concat("domain=").concat(Lt):u}}var an,un=null;function cn(){var t=Ht;un={version:s,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0,applicationPlatform:0,url:""}}function sn(){un=null}function ln(t){return un.start=un.start+un.duration,un.duration=c()-un.start,un.sequence++,un.upload=t&&"sendBeacon"in navigator?1:0,un.end=t?1:0,un.applicationPlatform=0,un.url=h(location.href,!1,!0),[un.version,un.sequence,un.start,un.duration,un.projectId,un.userId,un.sessionId,un.pageNum,un.upload,un.end,un.applicationPlatform,un.url]}function dn(){an=[]}function pn(t){if(an&&-1===an.indexOf(t.message)){var n=a.report;if(n&&n.length>0){var e={v:un.version,p:un.projectId,u:un.userId,s:un.sessionId,n:un.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)),an.push(t.message)}}return t}function fn(t){return function(){var n=performance.now();try{t.apply(this,arguments)}catch(t){throw pn(t)}var e=performance.now()-n;x(4,e),e>30&&(T(7),j(6,e),"".concat(t.dn||t.name,"-").concat(e))}}var hn=new Map;function vn(t,n,e,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0),e=fn(e);try{t[i("addEventListener")](n,e,{capture:r,passive:o}),function(t){return hn.has(t)}(t)||hn.set(t,[]),hn.get(t).push({event:n,listener:e,options:{capture:r,passive:o}})}catch(t){}}function gn(){hn.forEach((function(t,n){!function(t,n){t.forEach((function(t){try{n[i("removeEventListener")](t.event,t.listener,{capture:t.options.capture,passive:t.options.passive})}catch(t){}})),hn.delete(n)}(t,n)})),hn=new Map}var mn=null,yn=null,bn=null,wn=0;function kn(){return!(wn++>20)}function Sn(){Sn.dn=1,wn=0,bn!==En()&&(oe(),window.setTimeout(_n,250))}function _n(){re(),j(29,1)}function En(){return location.href?location.href.replace(location.hash,""):location.href}var In=[],Mn=null,On=null,Tn=null;function xn(){On&&(Tn(),On=null,null===Mn&&zn())}function jn(){In=[],Mn=null,On=null}function zn(){var t=In.shift();t&&(Mn=t,t.task().then((function(){t.id===Wt()&&(t.resolve(),Mn=null,zn())})).catch((function(n){t.id===Wt()&&(n&&(n.name,n.message,n.stack),Mn=null,zn())})))}var An=!1;function Cn(){An=!0,u=performance.now()+performance.timeOrigin,jn(),gn(),dn(),bn=En(),wn=0,vn(window,"popstate",Sn),null===mn&&(mn=history.pushState,history.pushState=function(){mn.apply(this,arguments),qn()&&kn()&&Sn()}),null===yn&&(yn=history.replaceState,history.replaceState=function(){yn.apply(this,arguments),qn()&&kn()&&Sn()})}function Pn(){bn=null,wn=0,dn(),gn(),jn(),u=0,An=!1}function qn(){return An}function Nn(){Nn.dn=2,re(),E("clarity","restart")}var Dn=null;function Rn(){Dn=null}function Hn(t){Dn={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){L(this,void 0,void 0,(function(){var n,e;return V(this,(function(r){return n=c(),e=[n,t],29===t&&(e.push(Dn.fetchStart),e.push(Dn.connectStart),e.push(Dn.connectEnd),e.push(Dn.requestStart),e.push(Dn.responseStart),e.push(Dn.responseEnd),e.push(Dn.domInteractive),e.push(Dn.domComplete),e.push(Dn.loadEventStart),e.push(Dn.loadEventEnd),e.push(Dn.redirectCount),e.push(Dn.size),e.push(Dn.type),e.push(Dn.protocol),e.push(Dn.encodedSize),e.push(Dn.decodedSize),Rn(),yt(e)),[2]}))}))}(29)}var Un,Xn=0,Ln=1/0,Vn=0,Bn=0,Yn=[],Wn=new Map,Jn=function(){return Xn||0},Zn=function(){if(!Yn.length)return-1;var t=Math.min(Yn.length-1,Math.floor((Jn()-Bn)/50));return Yn[t].latency},Gn=function(){Bn=Jn(),Yn.length=0,Wn.clear()},Fn=function(t){if(t.interactionId&&!(t.duration<40)){!function(t){"interactionCount"in performance?Xn=performance.interactionCount:t.interactionId&&(Ln=Math.min(Ln,t.interactionId),Vn=Math.max(Vn,t.interactionId),Xn=Vn?(Vn-Ln)/7+1:0)}(t);var n=Yn[Yn.length-1],e=Wn.get(t.interactionId);if(e||Yn.length<10||t.duration>(null==n?void 0:n.latency)){if(e)t.duration>e.latency&&(e.latency=t.duration);else{var r={id:t.interactionId,latency:t.duration};Wn.set(r.id,r),Yn.push(r)}Yn.sort((function(t,n){return n.latency-t.latency})),Yn.length>10&&Yn.splice(10).forEach((function(t){return Wn.delete(t.id)}))}}},Kn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint","event"];function Qn(){Qn.dn=26;try{Un&&Un.disconnect(),Un=new PerformanceObserver(fn($n));for(var t=0,n=Kn;t<n.length;t++){var e=n[t];PerformanceObserver.supportedEntryTypes.indexOf(e)>=0&&("layout-shift"===e&&x(9,0),Un.observe({type:e,buffered:!0}))}}catch(t){}}function $n(t){$n.dn=27,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":Hn(r);break;case"resource":var o=r.name;qt(4,te(o)),o!==a.upload&&o!==a.fallback||j(28,r.duration);break;case"longtask":T(7);break;case"first-input":n&&j(10,r.processingStart-r.startTime);break;case"event":n&&"PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&(Fn(r),qt(37,Zn().toString()));break;case"layout-shift":n&&!r.hadRecentInput&&x(9,1e3*r.value);break;case"largest-contentful-paint":n&&j(8,r.startTime)}}}(t.getEntries())}function te(t){var n=document.createElement("a");return n.href=t,n.host}var ne=Object.freeze({__proto__:null,start:function t(){t.dn=25,Rn(),function(){navigator&&"connection"in navigator&&qt(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?vn(window,"load",z.bind(this,Qn,0)):Qn())}()},stop:function(){Un&&Un.disconnect(),Un=null,Gn(),Rn()}}),ee=[S,S,S,ne];function re(t){void 0===t&&(t=null),function(){try{var t=navigator&&"globalPrivacyControl"in navigator&&1==navigator.globalPrivacyControl;return!1===An&&"undefined"!=typeof Promise&&window.MutationObserver&&document.createTreeWalker&&"now"in Date&&"now"in performance&&"undefined"!=typeof WeakMap&&!t}catch(t){return!1}}()&&(!function(t){if(null===t||An)return!1;for(var n in t)n in a&&(a[n]=t[n])}(t),Cn(),ot(),ee.forEach((function(t){return fn(t.start)()})),null===t&&ce())}function oe(){qn()&&(ee.slice().reverse().forEach((function(t){return fn(t.stop)()})),at(),Pn(),void 0!==ie&&(ie[ue]=function(){(ie[ue].q=ie[ue].q||[]).push(arguments),"start"===arguments[0]&&ie[ue].q.unshift(ie[ue].q.pop())&&ce()}))}var ae=Object.freeze({__proto__:null,consent:Jt,event:E,hashText:w,identify:W,metadata:Yt,pause:function(){qn()&&(E("clarity","pause"),null===On&&(On=new Promise((function(t){Tn=t}))))},resume:function(){qn()&&(xn(),E("clarity","resume"))},set:Y,signal:function(t){nt=t},start:re,stop:oe,upgrade:U,version:s}),ie=window,ue="clarity";function ce(){if(void 0!==ie){if(ie[ue]&&ie[ue].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=ie[ue]&&ie[ue].q||[];for(ie[ue]=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return ae[t].apply(ae,n)},ie[ue].v=s;t.length>0;)ie[ue].apply(ie,t.shift())}}ce()}();
1
+ !function(){"use strict";var t=Object.freeze({__proto__:null,get queue(){return gt},get start(){return ht},get stop(){return mt},get track(){return lt}}),e=Object.freeze({__proto__:null,get check(){return _t},get compute(){return It},get data(){return st},get start(){return St},get stop(){return Mt},get trigger(){return Et}}),n=Object.freeze({__proto__:null,get compute(){return Ct},get data(){return Ot},get log(){return $t},get reset(){return At},get start(){return xt},get stop(){return zt},get updates(){return Tt}}),o=Object.freeze({__proto__:null,get callback(){return Yt},get callbacks(){return Nt},get clear(){return Bt},get consent(){return Vt},get data(){return Pt},get electron(){return Dt},get id(){return Lt},get metadata(){return Xt},get save(){return Wt},get shortid(){return Ft},get start(){return Ht},get stop(){return Ut}}),r=Object.freeze({__proto__:null,get data(){return oe},get envelope(){return ie},get start(){return re},get stop(){return ae}});let a={projectId:null,delay:1e3,lean:!1,lite:!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,delayDom:!1,throttleDom:!0,conversions:!1,includeSubdomains:!0,throttleMutations:!1,dropMutations:!1,criticalMs:200,discard:[]};function i(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}let u=0;function l(t=null){let e=t&&t.timeStamp>0?t.timeStamp:performance.now(),n=t&&t.view?t.view.performance.timeOrigin:performance.timeOrigin;return Math.max(Math.round(e+n-u),0)}let s="0.8.8-beta";const c=255;let d=!0,p=null,f=null,h=null;function g(t,e=!1,n=!1){let o=t;if(e)o="https://Electron";else{let e=a.drop;if(e&&e.length>0&&t&&t.indexOf("?")>0){let[n,r]=t.split("?"),a="*na*";o=n+"?"+r.split("&").map((t=>e.some((e=>0===t.indexOf(`${e}=`)))?`${t.split("=")[0]}=${a}`:t)).join("&")}}return n&&(o=o.substring(0,c)),o}function m(t,e,n){return function(){if(d&&null===p)try{p=new RegExp("\\p{N}","gu"),f=new RegExp("\\p{L}","gu"),h=new RegExp("\\p{Sc}","gu")}catch(t){d=!1}}(),t?t.replace(f,e).replace(p,n):t}let y=[],v=null;function w(){}let k=[];function b(){}function S(){}var _=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:v,hashText:b,keys:k,log:w,observe:function(){},reset:function(){},sheetAdoptionState:[],sheetUpdateState:[],start:function(){},state:y,stop:function(){},trigger:S});let E=null;function I(t,e){ze()&&t&&"string"==typeof t&&t.length<255&&(E=e&&"string"==typeof e&&e.length<255?{key:t,value:e}:{value:t},bt(24))}let M,O=null,T=null;function j(t){t in O||(O[t]=0),t in T||(T[t]=0),O[t]++,T[t]++}function x(t,e){null!==e&&(t in O||(O[t]=0),t in T||(T[t]=0),O[t]+=e,T[t]+=e)}function z(t,e){null!==e&&!1===isNaN(e)&&(t in O||(O[t]=0),(e>O[t]||0===O[t])&&(T[t]=e,O[t]=e))}function $(t,e,n){return window.setTimeout(se(t),e,n)}function C(t){return window.clearTimeout(t)}let A=0,q=0,P=null;function N(){P&&C(P),P=$(D,q),A=l()}function D(){let t=l();M={gap:t-A},bt(25),M.gap<3e5?P=$(D,q):Te&&(I("clarity","suspend"),tn(),["mousemove","touchstart"].forEach((t=>de(document,t,$e))),["resize","scroll","pageshow"].forEach((t=>de(window,t,$e))))}var R=Object.freeze({__proto__:null,get data(){return M},reset:N,start:function(){q=6e4,A=0},stop:function(){C(P),A=0,q=0}});let H=null;function U(t){ze()&&a.lean&&(a.lean=!1,H={key:t},Yt(),Wt(),a.upgrade&&a.upgrade(t),bt(3),a.lite)}var X=Object.freeze({__proto__:null,get data(){return H},start:function(){!a.lean&&a.upgrade&&a.upgrade("Config"),H=null},stop:function(){H=null},upgrade:U});let L=null;function V(t,e){Y(t,"string"==typeof e?[e]:e)}async function B(t,e=null,n=null,o=null){let r={userId:await Z(t),userHint:o||(a=t,a&&a.length>=5?`${a.substring(0,2)}${m(a.substring(2),"*","*")}`:m(a,"*","*"))};var a;return Y("userId",[r.userId]),Y("userHint",[r.userHint]),Y("userType",[F(t)]),e&&(Y("sessionId",[e]),r.sessionId=e),n&&(Y("pageId",[n]),r.pageId=n),r}function Y(t,e){if(ze()&&t&&e&&"string"==typeof t&&t.length<255){let n=t in L?L[t]:[];for(let t=0;t<e.length;t++)"string"==typeof e[t]&&e[t].length<255&&n.push(e[t]);L[t]=n}}function W(){bt(34)}function J(){L={}}async function Z(t){try{if(crypto&&t){const e=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t));return Array.prototype.map.call(new Uint8Array(e),(t=>("00"+t.toString(16)).slice(-2))).join("")}return""}catch(t){return""}}function F(t){return t&&t.indexOf("@")>0?"email":"string"}const G="CompressionStream"in window;let K=null;function Q(t){try{if(!K)return;const e=function(t){try{return JSON.parse(t)}catch(t){return[]}}(t);e.forEach((t=>{K(t)}))}catch(t){}}const tt=[_,n,Object.freeze({__proto__:null,compute:W,get data(){return L},identify:B,reset:J,set:V,start:function(){J()},stop:function(){J()}}),e,_,o,r,t,R,X,_];function et(){O={},T={},j(5),tt.forEach((t=>se(t.start)()))}function nt(){tt.slice().reverse().forEach((t=>se(t.stop)())),O={},T={}}function ot(){W(),Ct(),bt(0),It()}let rt,at,it,ut,lt,st,ct=0,dt=0,pt=null,ft=0;function ht(){ut=!0,ct=0,dt=0,ft=0,rt=[],at=[],it={},lt=null}function gt(t,e=!0){if(ut){let n=l(),o=t.length>1?t[1]:null,r=JSON.stringify(t);switch(o){case 5:ct+=r.length;case 37:case 6:case 43:case 45:case 46:dt+=r.length,rt.push(r);break;default:at.push(r)}j(25);let i=function(){let t=!1===a.lean&&ct>0?100:oe.sequence*a.delay;return"string"==typeof a.upload?Math.max(Math.min(t,3e4),100):a.delay}();n-ft>2*i&&(C(pt),pt=null),e&&null===pt&&(25!==o&&N(),pt=$(yt,i),ft=n,_t(dt))}}function mt(){C(pt),yt(!0),ct=0,dt=0,ft=0,rt=[],at=[],it={},lt=null,ut=!1}async function yt(t=!1){pt=null;let e=!1===a.lean&&dt>0&&(dt<1048576||oe.sequence>0);e&&z(1,1),ot();let n=!0===t,o=function(t){return t.p.length>0?`{"e":${t.e},"a":${t.a},"p":${t.p}}`:`{"e":${t.e},"a":${t.a}}`}({e:JSON.stringify(ie(n)),a:`[${at.join()}]`,p:e?`[${rt.join()}]`:""}),r=n?null:await async function(t){try{if(G){const e=new ReadableStream({async start(e){e.enqueue(t),e.close()}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip"));return new Uint8Array(await async function(t){const e=t.getReader(),n=[];let o=!1,r=[];for(;!o;){if(({done:o,value:r}=await e.read()),o)return n;n.push(...r)}return n}(e))}}catch(t){}return null}(o);x(2,r?r.length:o.length),vt(o,r,oe.sequence,n),at=[],e&&(rt=[],dt=0,ct=0)}function vt(t,e,n,o=!1){if("string"==typeof a.upload){const r=a.upload;let i=!1;if(o&&"sendBeacon"in navigator)try{i=navigator.sendBeacon.bind(navigator)(r,t),i&&kt(n)}catch(t){}if(!1===i){n in it?it[n].attempts++:it[n]={data:t,attempts:1};let o=new XMLHttpRequest;o.open("POST",r,!0),o.timeout=15e3,o.ontimeout=()=>{le(new Error(`Timeout : ${r}`))},null!==n&&(o.onreadystatechange=()=>{se(wt)(o,n)}),o.withCredentials=!0,e?(o.setRequestHeader("Accept","application/x-clarity-gzip"),o.send(e)):o.send(t)}}else if(a.upload){(0,a.upload)(t),kt(n)}}function wt(t,e){var n=it[e];t&&4===t.readyState&&n&&((t.status<200||t.status>208)&&n.attempts<=1?t.status>=400&&t.status<500?Et(6):(0===t.status&&(a.upload=a.fallback?a.fallback:a.upload),vt(n.data,null,e)):(lt={sequence:e,attempts:n.attempts,status:t.status},n.attempts>1&&bt(2),200===t.status&&t.responseText&&function(t){let e=t&&t.length>0?t.split("\n"):[];for(var n of e){let t=n&&n.length>0?n.split(/ (.*)/):[""];switch(t[0]){case"END":Et(6);break;case"UPGRADE":U("Auto");break;case"ACTION":a.action&&t.length>1&&a.action(t[1]);break;case"EXTRACT":t.length>1&&t[1];break;case"SIGNAL":t.length>1&&Q(t[1])}}}(t.responseText),0===t.status&&(vt(n.data,null,e,!0),Et(3)),t.status>=200&&t.status<=208&&kt(e),delete it[e]))}function kt(t){1===t&&(Wt(),Yt())}function bt(t){let e=[l(),t];switch(t){case 4:let t=y;t&&(e=[t.time,t.event],e.push(t.data.visible),e.push(t.data.docWidth),e.push(t.data.docHeight),e.push(t.data.screenWidth),e.push(t.data.screenHeight),e.push(t.data.scrollX),e.push(t.data.scrollY),e.push(t.data.pointerX),e.push(t.data.pointerY),e.push(t.data.activityTime),e.push(t.data.scrollTime),e.push(t.data.pointerTime),e.push(t.data.moveX),e.push(t.data.moveY),e.push(t.data.moveTime),e.push(t.data.downX),e.push(t.data.downY),e.push(t.data.downTime),e.push(t.data.upX),e.push(t.data.upY),e.push(t.data.upTime),e.push(t.data.pointerPrevX),e.push(t.data.pointerPrevY),e.push(t.data.pointerPrevTime),gt(e,!1));break;case 25:e.push(M.gap),gt(e);break;case 35:e.push(st.check),gt(e,!1);break;case 3:e.push(H.key),gt(e);break;case 2:e.push(lt.sequence),e.push(lt.attempts),e.push(lt.status),gt(e,!1);break;case 24:E.key&&e.push(E.key),e.push(E.value),gt(e);break;case 34:let n=Object.keys(L);if(n.length>0){for(let t of n)e.push(t),e.push(L[t]);J(),gt(e,!1)}break;case 0:let o=Object.keys(T);if(o.length>0){for(let t of o){let n=parseInt(t,10);e.push(n),e.push(Math.round(T[t]))}T={},gt(e,!1)}break;case 1:let r=Object.keys(Tt);if(r.length>0){for(let t of r){let n=parseInt(t,10);e.push(n),e.push(Tt[t])}At(),gt(e,!1)}break;case 36:let a=Object.keys(v);if(a.length>0){for(let t of a){let n=parseInt(t,10);e.push(n),e.push([].concat(...v[t]))}gt(e,!1)}break;case 40:k.forEach((t=>{e.push(t);let n=[];for(let e in v[t]){let o=parseInt(e,10);n.push(o),n.push(v[t][e])}e.push(n)})),gt(e,!1)}}function St(){st={check:0}}function _t(t){if(0===st.check){let e=st.check;e=oe.sequence>=128?1:e,e=oe.pageNum>=128?7:e,e=l()>72e5?2:e,e=t>10485760?2:e,e!==st.check&&Et(e)}}function Et(t){st.check=t,5!==t&&(Bt(),tn())}function It(){0!==st.check&&bt(35)}function Mt(){st=null}let Ot=null,Tt=null,jt=!1;function xt(){Ot={},Tt={},jt=!1}function zt(){Ot={},Tt={},jt=!1}function $t(t,e){if(e&&(e=`${e}`,t in Ot||(Ot[t]=[]),Ot[t].indexOf(e)<0)){if(Ot[t].length>128)return void(jt||(jt=!0,Et(5)));Ot[t].push(e),t in Tt||(Tt[t]=[]),Tt[t].push(e)}}function Ct(){bt(1)}function At(){Tt={},jt=!1}function qt(t){$t(36,t.toString())}let Pt=null,Nt=[],Dt=0,Rt=null;function Ht(){var t,e,n;Rt=null;const o=navigator&&"userAgent"in navigator?navigator.userAgent:"",r=null!==(n=null===(e=null===(t=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat())||void 0===t?void 0:t.resolvedOptions())||void 0===e?void 0:e.timeZone)&&void 0!==n?n:"",i=(new Date).getTimezoneOffset().toString(),u=window.location.ancestorOrigins?Array.from(window.location.ancestorOrigins).toString():"",l=document&&document.title?document.title:"";Dt=o.indexOf("Electron")>0?1:0;let s=function(){let t={session:Ft(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},e=Qt("_clsk",!a.includeSubdomains);if(e){let n=e.includes("^")?e.split("^"):e.split("|");n.length>=5&&t.ts-Gt(n[1])<18e5&&(t.session=n[0],t.count=Gt(n[2])+1,t.upgrade=Gt(n[3]),t.upload=n.length>=6?`https://${n[5]}/${n[4]}`:`https://${n[4]}`)}return t}(),c=Kt(),d=a.projectId||function(t,e=null){let n=0,o=5381,r=o;for(let e=0;e<t.length;e+=2)o=(o<<5)+o^t.charCodeAt(e),e+1<t.length&&(r=(r<<5)+r^t.charCodeAt(e+1));return n=Math.abs(o+11579*r),(e?n%Math.pow(2,e):n).toString(36)}(location.host);Pt={projectId:d,userId:c.id,sessionId:s.session,pageNum:s.count},a.lean=a.track&&null!==s.upgrade?0===s.upgrade:a.lean,a.upload=a.track&&"string"==typeof a.upload&&s.upload&&s.upload.length>"https://".length?s.upload:a.upload,$t(0,o),$t(3,l),$t(1,g(location.href,!!Dt)),$t(2,document.referrer),$t(15,function(){let t=Ft();if(a.track&&Jt(window,"sessionStorage")){let e=sessionStorage.getItem("_cltk");t=e||t,sessionStorage.setItem("_cltk",t)}return t}()),$t(16,document.documentElement.lang),$t(17,document.dir),$t(26,`${window.devicePixelRatio}`),$t(28,c.dob.toString()),$t(29,c.version.toString()),$t(33,u),$t(34,r),$t(35,i),z(0,s.ts),z(1,0),z(35,Dt),navigator&&($t(9,navigator.language),z(33,navigator.hardwareConcurrency),z(32,navigator.maxTouchPoints),z(34,Math.round(navigator.deviceMemory)),function(){let t=navigator.userAgentData;t&&t.getHighEntropyValues?t.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((t=>{var e;$t(22,t.platform),$t(23,t.platformVersion),null===(e=t.brands)||void 0===e||e.forEach((t=>{$t(24,t.name+"~"+t.version)})),$t(25,t.model),z(27,t.mobile?1:0)})):$t(22,navigator.platform)}()),screen&&(z(14,Math.round(screen.width)),z(15,Math.round(screen.height)),z(16,Math.round(screen.colorDepth)));for(let t of a.cookies){let e=Qt(t);e&&V(t,e)}!function(t){qt(t?1:0)}(a.track),Zt(c)}function Ut(){Rt=null,Pt=null,Nt.forEach((t=>{t.called=!1}))}function Xt(t,e=!0,n=!1){let o=a.lean?0:1,r=!1;Pt&&(o||!1===e)&&(t(Pt,!a.lean),r=!0),!n&&r||Nt.push({callback:t,wait:e,recall:n,called:r})}function Lt(){return Pt?[Pt.userId,Pt.sessionId,Pt.pageNum].join("."):""}function Vt(t=!0){if(!t)return a.track=!1,ee("_clsk","",-Number.MAX_VALUE),ee("_clck","",-Number.MAX_VALUE),tn(),void window.setTimeout(Qe,250);ze()&&(a.track=!0,Zt(Kt(),1),Wt(),qt(2))}function Bt(){ee("_clsk","",0)}function Yt(){!function(t){if(Nt.length>0)for(let e=0;e<Nt.length;e++){const n=Nt[e];!n.callback||n.called||n.wait&&!t||(n.callback(Pt,!a.lean),n.called=!0,n.recall||(Nt.splice(e,1),e--))}}(a.lean?0:1)}function Wt(){if(!Pt||!a.track)return;let t=Math.round(Date.now()),e=a.upload&&"string"==typeof a.upload?a.upload.replace("https://",""):"",n=a.lean?0:1;ee("_clsk",[Pt.sessionId,t,Pt.pageNum,n,e].join("^"),1)}function Jt(t,e){try{return!!t[e]}catch(t){return!1}}function Zt(t,e=null){e=null===e?t.consent:e;let n=Math.ceil((Date.now()+31536e6)/864e5),o=0===t.dob?null===a.dob?0:a.dob:t.dob;if(null===t.expiry||Math.abs(n-t.expiry)>=1||t.consent!==e||t.dob!==o){ee("_clck",[Pt.userId,2,n.toString(36),e,o].join("^"),365)}}function Ft(){let 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 Gt(t,e=10){return parseInt(t,e)}function Kt(){let t={id:Ft(),version:0,expiry:null,consent:0,dob:0},e=Qt("_clck",!a.includeSubdomains);if(e&&e.length>0){let n=e.includes("^")?e.split("^"):e.split("|");n.length>1&&(t.version=Gt(n[1])),n.length>2&&(t.expiry=Gt(n[2],36)),n.length>3&&1===Gt(n[3])&&(t.consent=1),n.length>4&&Gt(n[1])>1&&(t.dob=Gt(n[4])),a.track=a.track||1===t.consent,t.id=a.track?n[0]:t.id}return t}function Qt(t,e=!1){if(Jt(document,"cookie")){let n=document.cookie.split(";");if(n)for(let o=0;o<n.length;o++){let r=n[o].split("=");if(r.length>1&&r[0]&&r[0].trim()===t){let[t,n]=te(r[1]);for(;t;)[t,n]=te(n);return e?n.endsWith("~1")?n.substring(0,n.length-2):null:n}}}return null}function te(t){try{let e=decodeURIComponent(t);return[e!=t,e]}catch(t){}return[!1,t]}function ee(t,e,n){if((a.track||""==e)&&(navigator&&navigator.cookieEnabled||Jt(document,"cookie"))){let o=function(t){return encodeURIComponent(t)}(e),r=new Date;r.setDate(r.getDate()+n);let a=`${t}=${o};${r?"expires="+r.toUTCString():""};path=/`;try{if(null===Rt){let n=location.hostname?location.hostname.split("."):[];for(let o=n.length-1;o>=0;o--)if(Rt=`.${n[o]}${Rt||""}`,o<n.length-1&&(document.cookie=`${a};domain=${Rt}`,Qt(t)===e))return;Rt=""}}catch(t){Rt=""}document.cookie=Rt?`${a};domain=${Rt}`:a}}let ne,oe=null;function re(){const t=Pt;oe={version:s,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0,applicationPlatform:0,url:""}}function ae(){oe=null}function ie(t){return oe.start=oe.start+oe.duration,oe.duration=l()-oe.start,oe.sequence++,oe.upload=t&&"sendBeacon"in navigator?1:0,oe.end=t?1:0,oe.applicationPlatform=0,oe.url=g(location.href,!1,!0),[oe.version,oe.sequence,oe.start,oe.duration,oe.projectId,oe.userId,oe.sessionId,oe.pageNum,oe.upload,oe.end,oe.applicationPlatform,oe.url]}function ue(){ne=[]}function le(t){if(ne&&-1===ne.indexOf(t.message)){const e=a.report;if(e&&e.length>0){let n={v:oe.version,p:oe.projectId,u:oe.userId,s:oe.sessionId,n:oe.pageNum};t.message&&(n.m=t.message),t.stack&&(n.e=t.stack);let o=new XMLHttpRequest;o.open("POST",e,!0),o.send(JSON.stringify(n)),ne.push(t.message)}}return t}function se(t){return function(){let e=performance.now();try{t.apply(this,arguments)}catch(t){throw le(t)}let n=performance.now()-e;x(4,n),n>30&&(j(7),z(6,n),t.dn||t.name)}}let ce=new Map;function de(t,e,n,o=!1,r=!0){n=se(n);try{t[i("addEventListener")](e,n,{capture:o,passive:r}),function(t){return ce.has(t)}(t)||ce.set(t,[]),ce.get(t).push({event:e,listener:n,options:{capture:o,passive:r}})}catch(t){}}function pe(){ce.forEach(((t,e)=>{!function(t,e){t.forEach((t=>{try{e[i("removeEventListener")](t.event,t.listener,{capture:t.options.capture,passive:t.options.passive})}catch(t){}})),ce.delete(e)}(t,e)})),ce=new Map}let fe=null,he=null,ge=null,me=0;function ye(){return!(me++>20)}function ve(){ve.dn=1,me=0,ge!==ke()&&(tn(),window.setTimeout(we,250))}function we(){Qe(),z(29,1)}function ke(){return location.href?location.href.replace(location.hash,""):location.href}let be=[],Se=null,_e=null,Ee=null;function Ie(){_e&&(Ee(),_e=null,null===Se&&Oe())}function Me(){be=[],Se=null,_e=null}function Oe(){let t=be.shift();t&&(Se=t,t.task().then((()=>{t.id===Lt()&&(t.resolve(),Se=null,Oe())})).catch((e=>{t.id===Lt()&&(e&&(e.name,e.message,e.stack),Se=null,Oe())})))}let Te=!1;function je(){Te=!0,u=performance.now()+performance.timeOrigin,Me(),pe(),ue(),ge=ke(),me=0,de(window,"popstate",ve),null===fe&&(fe=history.pushState,history.pushState=function(){fe.apply(this,arguments),ze()&&ye()&&ve()}),null===he&&(he=history.replaceState,history.replaceState=function(){he.apply(this,arguments),ze()&&ye()&&ve()})}function xe(){ge=null,me=0,ue(),pe(),Me(),u=0,Te=!1}function ze(){return Te}function $e(){$e.dn=2,Qe(),I("clarity","restart")}let Ce=null;function Ae(){Ce=null}function qe(t){Ce={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},async function(t){let e=[l(),t];29===t&&(e.push(Ce.fetchStart),e.push(Ce.connectStart),e.push(Ce.connectEnd),e.push(Ce.requestStart),e.push(Ce.responseStart),e.push(Ce.responseEnd),e.push(Ce.domInteractive),e.push(Ce.domComplete),e.push(Ce.loadEventStart),e.push(Ce.loadEventEnd),e.push(Ce.redirectCount),e.push(Ce.size),e.push(Ce.type),e.push(Ce.protocol),e.push(Ce.encodedSize),e.push(Ce.decodedSize),Ae(),gt(e))}(29)}let Pe=0,Ne=1/0,De=0,Re=0;const He=[],Ue=new Map,Xe=()=>Pe||0,Le=()=>{if(!He.length)return-1;const t=Math.min(He.length-1,Math.floor((Xe()-Re)/50));return He[t].latency},Ve=()=>{Re=Xe(),He.length=0,Ue.clear()},Be=t=>{if(!t.interactionId||t.duration<40)return;(t=>{"interactionCount"in performance?Pe=performance.interactionCount:t.interactionId&&(Ne=Math.min(Ne,t.interactionId),De=Math.max(De,t.interactionId),Pe=De?(De-Ne)/7+1:0)})(t);const e=He[He.length-1],n=Ue.get(t.interactionId);if(n||He.length<10||t.duration>(null==e?void 0:e.latency)){if(n)t.duration>n.latency&&(n.latency=t.duration);else{const e={id:t.interactionId,latency:t.duration};Ue.set(e.id,e),He.push(e)}He.sort(((t,e)=>e.latency-t.latency)),He.length>10&&He.splice(10).forEach((t=>Ue.delete(t.id)))}};let Ye;const We=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint","event"];function Je(){Je.dn=26;try{Ye&&Ye.disconnect(),Ye=new PerformanceObserver(se(Ze));for(let t of We)PerformanceObserver.supportedEntryTypes.indexOf(t)>=0&&("layout-shift"===t&&x(9,0),Ye.observe({type:t,buffered:!0}))}catch(t){}}function Ze(t){Ze.dn=27,function(t){let e=!("visibilityState"in document)||"visible"===document.visibilityState;for(let n=0;n<t.length;n++){let o=t[n];switch(o.entryType){case"navigation":qe(o);break;case"resource":let t=o.name;$t(4,Fe(t)),t!==a.upload&&t!==a.fallback||z(28,o.duration);break;case"longtask":j(7);break;case"first-input":e&&z(10,o.processingStart-o.startTime);break;case"event":e&&"PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&(Be(o),$t(37,Le().toString()));break;case"layout-shift":e&&!o.hadRecentInput&&x(9,1e3*o.value);break;case"largest-contentful-paint":e&&z(8,o.startTime)}}}(t.getEntries())}function Fe(t){let e=document.createElement("a");return e.href=t,e.host}var Ge=Object.freeze({__proto__:null,start:function t(){t.dn=25,Ae(),function(){navigator&&"connection"in navigator&&$t(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?de(window,"load",$.bind(this,Je,0)):Je())}()},stop:function(){Ye&&Ye.disconnect(),Ye=null,Ve(),Ae()}});const Ke=[_,_,_,Ge];function Qe(t=null){(function(){try{let t=navigator&&"globalPrivacyControl"in navigator&&1==navigator.globalPrivacyControl;return!1===Te&&"undefined"!=typeof Promise&&window.MutationObserver&&document.createTreeWalker&&"now"in Date&&"now"in performance&&"undefined"!=typeof WeakMap&&!t}catch(t){return!1}})()&&(!function(t){if(null===t||Te)return!1;for(let e in t)e in a&&(a[e]=t[e])}(t),je(),et(),Ke.forEach((t=>se(t.start)())),null===t&&rn())}function tn(){ze()&&(Ke.slice().reverse().forEach((t=>se(t.stop)())),nt(),xe(),void 0!==nn&&(nn[on]=function(){(nn[on].q=nn[on].q||[]).push(arguments),"start"===arguments[0]&&nn[on].q.unshift(nn[on].q.pop())&&rn()}))}var en=Object.freeze({__proto__:null,consent:Vt,event:I,hashText:b,identify:B,metadata:Xt,pause:function(){ze()&&(I("clarity","pause"),null===_e&&(_e=new Promise((t=>{Ee=t}))))},resume:function(){ze()&&(Ie(),I("clarity","resume"))},set:V,signal:function(t){K=t},start:Qe,stop:tn,upgrade:U,version:s});const nn=window,on="clarity";function rn(){if(void 0!==nn){if(nn[on]&&nn[on].v)return console.warn("Error CL001: Multiple Clarity tags detected.");let t=nn[on]&&nn[on].q||[];for(nn[on]=function(t,...e){return en[t](...e)},nn[on].v=s;t.length>0;)nn[on](...t.shift())}}rn()}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-js",
3
- "version": "0.8.6-beta",
3
+ "version": "0.8.8-beta",
4
4
  "description": "An analytics library that uses web page interactions to generate aggregated insights",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -1,2 +1,2 @@
1
- let version = "0.8.6-beta";
1
+ let version = "0.8.8-beta";
2
2
  export default version;
@@ -164,7 +164,7 @@ export function save(): void {
164
164
  let ts = Math.round(Date.now());
165
165
  let upload = config.upload && typeof config.upload === Constant.String ? (config.upload as string).replace(Constant.HTTPS, Constant.Empty) : Constant.Empty;
166
166
  let upgrade = config.lean ? BooleanFlag.False : BooleanFlag.True;
167
- setCookie(Constant.SessionKey, [data.sessionId, ts, data.pageNum, upgrade, upload].join(Constant.Pipe), Setting.SessionExpire);
167
+ setCookie(Constant.SessionKey, [data.sessionId, ts, data.pageNum, upgrade, upload].join(Constant.Caret), Setting.SessionExpire);
168
168
  }
169
169
 
170
170
  function processCallback(upgrade: BooleanFlag) {
@@ -199,7 +199,7 @@ function track(u: User, consent: BooleanFlag = null): void {
199
199
  // To avoid cookie churn, write user id cookie only once every day
200
200
  if (u.expiry === null || Math.abs(end - u.expiry) >= Setting.CookieInterval || u.consent !== consent || u.dob !== dob) {
201
201
  let cookieParts = [data.userId, Setting.CookieVersion, end.toString(36), consent, dob];
202
- setCookie(Constant.CookieKey, cookieParts.join(Constant.Pipe), Setting.Expire);
202
+ setCookie(Constant.CookieKey, cookieParts.join(Constant.Caret), Setting.Expire);
203
203
  }
204
204
  }
205
205
 
@@ -71,9 +71,6 @@ function handler(event: Event, root: Node, evt: MouseEvent): void {
71
71
  hash: null,
72
72
  trust: evt.isTrusted ? BooleanFlag.True : BooleanFlag.False,
73
73
  isFullText: textInfo.isFullText,
74
- tag: getElementAttribute(t, "tagName").substring(0, Setting.ClickTag),
75
- class: getElementAttribute(t, "className").substring(0, Setting.ClickClass),
76
- id: getElementAttribute(t, "id").substring(0, Setting.ClickId),
77
74
  }
78
75
  });
79
76
  schedule(encode.bind(this, event));
@@ -113,21 +110,13 @@ function text(element: Node): TextInfo {
113
110
  }
114
111
 
115
112
  function reaction(element: Node): BooleanFlag {
116
- const tagName = getElementAttribute(element, "tagName");
117
-
118
- if (UserInputTags.indexOf(tagName) >= 0) {
119
- return BooleanFlag.False;
120
- }
121
- return BooleanFlag.True;
122
- }
123
-
124
- function getElementAttribute(element: Node, attribute: "tagName" | "className" | "id"): string {
125
113
  if (element.nodeType === Node.ELEMENT_NODE) {
126
- const attr = (element as HTMLElement)?.[attribute];
127
- const value = typeof attr === "string" ? attr?.toLowerCase() : "";
128
- return value;
114
+ let tag = (element as HTMLElement).tagName.toLowerCase();
115
+ if (UserInputTags.indexOf(tag) >= 0) {
116
+ return BooleanFlag.False;
117
+ }
129
118
  }
130
- return "";
119
+ return BooleanFlag.True;
131
120
  }
132
121
 
133
122
  function layout(element: Element): Box {
@@ -68,9 +68,6 @@ export default async function (type: Event, ts: number = null): Promise<void> {
68
68
  tokens.push(cHash);
69
69
  tokens.push(entry.data.trust);
70
70
  tokens.push(entry.data.isFullText);
71
- tokens.push(entry.data.tag);
72
- tokens.push(entry.data.class);
73
- tokens.push(entry.data.id);
74
71
  queue(tokens);
75
72
  timeline.track(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
76
73
  }
@@ -24,11 +24,6 @@ import config from "@src/core/config";
24
24
  let observers: Set<MutationObserver> = new Set();
25
25
  let mutations: MutationQueue[] = [];
26
26
  let throttledMutations: { [key: number]: MutationRecordWithTime } = {};
27
- let insertRule: (rule: string, index?: number) => number = null;
28
- let deleteRule: (index?: number) => void = null;
29
- let attachShadow: (init: ShadowRootInit) => ShadowRoot = null;
30
- let mediaInsertRule: (rule: string, index?: number) => number = null;
31
- let mediaDeleteRule: (index?: number) => void = null;
32
27
  let queue: Node[] = [];
33
28
  let timeout: number = null;
34
29
  let throttleDelay: number = null;
@@ -47,71 +42,10 @@ export function start(): void {
47
42
  activePeriod = 0;
48
43
  history = {};
49
44
  observedNodes = new WeakMap<Node, MutationObserver>();
50
-
51
- // Some popular open source libraries, like styled-components, optimize performance
52
- // by injecting CSS using insertRule API vs. appending text node. A side effect of
53
- // using javascript API is that it doesn't trigger DOM mutation and therefore we
54
- // need to override the insertRule API and listen for changes manually.
55
- if (insertRule === null) {
56
- insertRule = CSSStyleSheet.prototype.insertRule;
57
- CSSStyleSheet.prototype.insertRule = function (): number {
58
- if (core.active()) {
59
- schedule(this.ownerNode);
60
- }
61
- return insertRule.apply(this, arguments);
62
- };
63
- }
64
-
65
- if ("CSSMediaRule" in window && mediaInsertRule === null) {
66
- mediaInsertRule = CSSMediaRule.prototype.insertRule;
67
- CSSMediaRule.prototype.insertRule = function (): number {
68
- if (core.active()) {
69
- schedule(this.parentStyleSheet.ownerNode);
70
- }
71
- return mediaInsertRule.apply(this, arguments);
72
- };
73
- }
74
-
75
- if (deleteRule === null) {
76
- deleteRule = CSSStyleSheet.prototype.deleteRule;
77
- CSSStyleSheet.prototype.deleteRule = function (): void {
78
- if (core.active()) {
79
- schedule(this.ownerNode);
80
- }
81
- return deleteRule.apply(this, arguments);
82
- };
83
- }
84
-
85
- if ("CSSMediaRule" in window && mediaDeleteRule === null) {
86
- mediaDeleteRule = CSSMediaRule.prototype.deleteRule;
87
- CSSMediaRule.prototype.deleteRule = function (): void {
88
- if (core.active()) {
89
- schedule(this.parentStyleSheet.ownerNode);
90
- }
91
- return mediaDeleteRule.apply(this, arguments);
92
- };
93
- }
94
-
95
- // Add a hook to attachShadow API calls
96
- // In case we are unable to add a hook and browser throws an exception,
97
- // reset attachShadow variable and resume processing like before
98
- if (attachShadow === null) {
99
- attachShadow = Element.prototype.attachShadow;
100
- try {
101
- Element.prototype.attachShadow = function (): ShadowRoot {
102
- if (core.active()) {
103
- return schedule(attachShadow.apply(this, arguments)) as ShadowRoot;
104
- } else {
105
- return attachShadow.apply(this, arguments);
106
- }
107
- };
108
- } catch {
109
- attachShadow = null;
110
- }
111
- }
45
+ proxyStyleRules(window);
112
46
  }
113
47
 
114
- export function observe(node: Node): void {
48
+ export function observe(node: Document | ShadowRoot): void {
115
49
  // Create a new observer for every time a new DOM tree (e.g. root document or shadowdom root) is discovered on the page
116
50
  // In the case of shadow dom, any mutations that happen within the shadow dom are not bubbled up to the host document
117
51
  // For this reason, we need to wire up mutations every time we see a new shadow dom.
@@ -125,6 +59,10 @@ export function observe(node: Node): void {
125
59
  observedNodes.set(node, observer);
126
60
  observers.add(observer);
127
61
  }
62
+ if (node['defaultView']) {
63
+ proxyStyleRules(node['defaultView']);
64
+ }
65
+
128
66
  } catch (e) {
129
67
  internal.log(Code.MutationObserver, Severity.Info, e ? e.name : null);
130
68
  }
@@ -407,3 +345,74 @@ function generate(target: Node, type: MutationRecordType): void {
407
345
  },
408
346
  ]);
409
347
  }
348
+
349
+
350
+ function proxyStyleRules(win: any): void {
351
+ if (win === null || win === undefined) {
352
+ return;
353
+ }
354
+
355
+ win.clarityOverrides = win.clarityOverrides || {};
356
+
357
+ // Some popular open source libraries, like styled-components, optimize performance
358
+ // by injecting CSS using insertRule API vs. appending text node. A side effect of
359
+ // using javascript API is that it doesn't trigger DOM mutation and therefore we
360
+ // need to override the insertRule API and listen for changes manually.
361
+ if (win.clarityOverrides.InsertRule === undefined) {
362
+ win.clarityOverrides.InsertRule = win.CSSStyleSheet.prototype.insertRule;
363
+ win.CSSStyleSheet.prototype.insertRule = function (): number {
364
+ if (core.active()) {
365
+ schedule(this.ownerNode);
366
+ }
367
+ return win.clarityOverrides.InsertRule.apply(this, arguments);
368
+ };
369
+ }
370
+
371
+ if ("CSSMediaRule" in win && win.clarityOverrides.MediaInsertRule === undefined) {
372
+ win.clarityOverrides.MediaInsertRule = win.CSSMediaRule.prototype.insertRule;
373
+ win.CSSMediaRule.prototype.insertRule = function (): number {
374
+ if (core.active()) {
375
+ schedule(this.parentStyleSheet.ownerNode);
376
+ }
377
+ return win.clarityOverrides.MediaInsertRule.apply(this, arguments);
378
+ };
379
+ }
380
+
381
+ if (win.clarityOverrides.DeleteRule === undefined) {
382
+ win.clarityOverrides.DeleteRule = win.CSSStyleSheet.prototype.deleteRule;
383
+ win.CSSStyleSheet.prototype.deleteRule = function (): void {
384
+ if (core.active()) {
385
+ schedule(this.ownerNode);
386
+ }
387
+ return win.clarityOverrides.DeleteRule.apply(this, arguments);
388
+ };
389
+ }
390
+
391
+ if ("CSSMediaRule" in win && win.clarityOverrides.MediaDeleteRule === undefined) {
392
+ win.clarityOverrides.MediaDeleteRule = win.CSSMediaRule.prototype.deleteRule;
393
+ win.CSSMediaRule.prototype.deleteRule = function (): void {
394
+ if (core.active()) {
395
+ schedule(this.parentStyleSheet.ownerNode);
396
+ }
397
+ return win.clarityOverrides.MediaDeleteRule.apply(this, arguments);
398
+ };
399
+ }
400
+
401
+ // Add a hook to attachShadow API calls
402
+ // In case we are unable to add a hook and browser throws an exception,
403
+ // reset attachShadow variable and resume processing like before
404
+ if (win.clarityOverrides.AttachShadow === undefined) {
405
+ win.clarityOverrides.AttachShadow = win.Element.prototype.attachShadow;
406
+ try {
407
+ win.Element.prototype.attachShadow = function (): ShadowRoot {
408
+ if (core.active()) {
409
+ return schedule(win.clarityOverrides.AttachShadow.apply(this, arguments)) as ShadowRoot;
410
+ } else {
411
+ return win.clarityOverrides.AttachShadow.apply(this, arguments);
412
+ }
413
+ };
414
+ } catch {
415
+ win.clarityOverrides.AttachShadow = null;
416
+ }
417
+ }
418
+ }
@@ -48,7 +48,7 @@ export default function (node: Node, source: Source, timestamp: number): Node {
48
48
  dom.parse(document);
49
49
  }
50
50
  checkDocumentStyles(node as Document, timestamp);
51
- observe(node);
51
+ observe(node as Document);
52
52
  break;
53
53
  case Node.DOCUMENT_FRAGMENT_NODE:
54
54
  let shadowRoot = (node as ShadowRoot);
@@ -212,7 +212,7 @@ export default function (node: Node, source: Source, timestamp: number): Node {
212
212
  return child;
213
213
  }
214
214
 
215
- function observe(root: Node): void {
215
+ function observe(root: Document | ShadowRoot): void {
216
216
  if (dom.has(root) || event.has(root)) { return; }
217
217
  mutation.observe(root); // Observe mutations for this root node
218
218
  interaction.observe(root); // Observe interactions for this root node
@@ -7,27 +7,27 @@ import { getId } from "@src/layout/dom";
7
7
  import * as core from "@src/core";
8
8
  import config from "@src/core/config";
9
9
  import { getCssRules } from "./node";
10
- import * as metric from "@src/data/metric";
11
10
 
12
11
  export let sheetUpdateState: StyleSheetState[] = [];
13
12
  export let sheetAdoptionState: StyleSheetState[] = [];
14
- let replace: (text?: string) => Promise<CSSStyleSheet> = null;
15
- let replaceSync: (text?: string) => void = null;
16
13
  const styleSheetId = 'claritySheetId';
17
14
  let styleSheetMap = {};
18
15
  let styleTimeMap: {[key: string]: number} = {};
19
16
  let documentNodes = [];
20
17
  let createdSheetIds = [];
21
18
 
22
- export function start(): void {
23
- if (config.lean && config.lite) { return; }
19
+ function proxyStyleRules(win: any) {
20
+ if ((config.lean && config.lite) || win === null || win === undefined) {
21
+ return;
22
+ }
23
+
24
+ win.clarityOverrides = win.clarityOverrides || {};
24
25
 
25
- if (window['CSSStyleSheet'] && CSSStyleSheet.prototype) {
26
- if (replace === null) {
27
- replace = CSSStyleSheet.prototype.replace;
28
- CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
26
+ if (win['CSSStyleSheet'] && win.CSSStyleSheet.prototype) {
27
+ if (win.clarityOverrides.replace === undefined) {
28
+ win.clarityOverrides.replace = win.CSSStyleSheet.prototype.replace;
29
+ win.CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
29
30
  if (core.active()) {
30
- metric.max(Metric.ConstructedStyles, 1);
31
31
  // if we haven't seen this stylesheet on this page yet, wait until the checkDocumentStyles has found it
32
32
  // and attached the sheet to a document. This way the timestamp of the style sheet creation will align
33
33
  // to when it is used in the document rather than potentially being misaligned during the traverse process.
@@ -35,15 +35,14 @@ export function start(): void {
35
35
  trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Replace, arguments[0]);
36
36
  }
37
37
  }
38
- return replace.apply(this, arguments);
38
+ return win.clarityOverrides.replace.apply(this, arguments);
39
39
  };
40
40
  }
41
-
42
- if (replaceSync === null) {
43
- replaceSync = CSSStyleSheet.prototype.replaceSync;
44
- CSSStyleSheet.prototype.replaceSync = function(): void {
41
+
42
+ if (win.clarityOverrides.replaceSync === undefined) {
43
+ win.clarityOverrides.replaceSync = win.CSSStyleSheet.prototype.replaceSync;
44
+ win.CSSStyleSheet.prototype.replaceSync = function(): void {
45
45
  if (core.active()) {
46
- metric.max(Metric.ConstructedStyles, 1);
47
46
  // if we haven't seen this stylesheet on this page yet, wait until the checkDocumentStyles has found it
48
47
  // and attached the sheet to a document. This way the timestamp of the style sheet creation will align
49
48
  // to when it is used in the document rather than potentially being misaligned during the traverse process.
@@ -51,10 +50,14 @@ export function start(): void {
51
50
  trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.ReplaceSync, arguments[0]);
52
51
  }
53
52
  }
54
- return replaceSync.apply(this, arguments);
53
+ return win.clarityOverrides.replaceSync.apply(this, arguments);
55
54
  };
56
55
  }
57
- }
56
+ }
57
+ }
58
+
59
+ export function start(): void {
60
+ proxyStyleRules(window);
58
61
  }
59
62
 
60
63
  export function checkDocumentStyles(documentNode: Document, timestamp: number): void {
@@ -62,13 +65,15 @@ export function checkDocumentStyles(documentNode: Document, timestamp: number):
62
65
 
63
66
  if (documentNodes.indexOf(documentNode) === -1) {
64
67
  documentNodes.push(documentNode);
68
+ if (documentNode.defaultView) {
69
+ proxyStyleRules(documentNode.defaultView);
70
+ }
65
71
  }
66
72
  timestamp = timestamp || time();
67
73
  if (!documentNode?.adoptedStyleSheets) {
68
74
  // if we don't have adoptedStyledSheets on the Node passed to us, we can short circuit.
69
75
  return;
70
76
  }
71
- metric.max(Metric.ConstructedStyles, 1);
72
77
  let currentStyleSheets: string[] = [];
73
78
  for (var styleSheet of documentNode.adoptedStyleSheets) {
74
79
  // If we haven't seen this style sheet on this page yet, we create a reference to it for the visualizer.
@@ -152,4 +157,4 @@ function arraysEqual(a: string[], b: string[]): boolean {
152
157
  }
153
158
 
154
159
  return a.every((value, index) => value === b[index]);
155
- }
160
+ }
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "module": "esnext",
4
- "target": "es5",
4
+ "target": "es2017",
5
5
  "lib": ["es6", "dom", "es2016", "es2017"],
6
6
  "moduleResolution": "node",
7
7
  "forceConsistentCasingInFileNames": true,
package/types/data.d.ts CHANGED
@@ -123,6 +123,9 @@ export const enum Metric {
123
123
  HardwareConcurrency = 33,
124
124
  DeviceMemory = 34,
125
125
  Electron = 35,
126
+ /**
127
+ * @deprecated No longer tracking
128
+ */
126
129
  ConstructedStyles = 36,
127
130
  /**
128
131
  * @deprecated Move it to dimension as it'll report only last value
@@ -232,9 +235,6 @@ export const enum Setting {
232
235
  PingTimeout = 5 * Time.Minute, // 5 Minutes
233
236
  SummaryInterval = 100, // Same events within 100ms will be collapsed into single summary
234
237
  ClickText = 25, // Maximum number of characters to send as part of Click event's text field
235
- ClickClass = 50, // Maximum number of characters to send as part of Click event's class name
236
- ClickTag = 10, // Maximum number of characters to send as part of Click event's tag
237
- ClickId = 25, // Maximum number of characters to send as part of Click event's id
238
238
  PayloadLimit = 128, // Do not allow more than specified payloads per page
239
239
  PageLimit = 128, // Do not allow more than 128 pages in a session
240
240
  ShutdownLimit = 2 * Time.Hour, // Shutdown instrumentation after specified time
@@ -123,9 +123,6 @@ export interface ClickData {
123
123
  hash: string;
124
124
  trust: number;
125
125
  isFullText: BooleanFlag;
126
- tag: string;
127
- class: string;
128
- id: string;
129
126
  }
130
127
 
131
128
  export interface TextInfo {