clarity-js 0.8.5 → 0.8.6

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 wt},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,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.5";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 w=[];function b(){}function k(){}var S=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:m,hashText:b,keys:w,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))}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(bt,i),gt=e,Mt(ht))}}function wt(){A(vt),bt(!0),ft=0,ht=0,gt=0,ut=[],ct=[],st={},dt=null,lt=!1}function bt(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 b=Object.keys(m);if(b.length>0){for(var k=0,S=b;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:w.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,wn=null,bn=0;function kn(){return!(bn++>20)}function Sn(){Sn.dn=1,bn=0,wn!==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(),wn=En(),bn=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(){wn=null,bn=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:b,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 yt},get start(){return mt},get stop(){return wt},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";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 w=[];function b(){}function k(){}var S=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:m,hashText:b,keys:w,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(bt,i),gt=e,Mt(ht))}}function wt(){A(vt),bt(!0),ft=0,ht=0,gt=0,ut=[],ct=[],st={},dt=null,lt=!1}function bt(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 b=Object.keys(m);if(b.length>0){for(var k=0,S=b;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:w.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,wn=null,bn=0;function kn(){return!(bn++>20)}function Sn(){Sn.dn=1,bn=0,wn!==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(),wn=En(),bn=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(){wn=null,bn=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:b,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()}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-js",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "An analytics library that uses web page interactions to generate aggregated insights",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -4,6 +4,7 @@ let config: Config = {
4
4
  projectId: null,
5
5
  delay: 1 * Time.Second,
6
6
  lean: false,
7
+ lite: false,
7
8
  track: true,
8
9
  content: true,
9
10
  drop: [],
@@ -1,2 +1,2 @@
1
- let version = "0.8.5";
1
+ let version = "0.8.6";
2
2
  export default version;
@@ -3,6 +3,8 @@ import * as core from "@src/core";
3
3
  import config from "@src/core/config";
4
4
  import encode from "@src/data/encode";
5
5
  import * as metadata from "@src/data/metadata";
6
+ import * as discover from "@src/layout/discover";
7
+ import * as style from "@src/layout/style";
6
8
 
7
9
  export let data: UpgradeData = null;
8
10
 
@@ -29,6 +31,11 @@ export function upgrade(key: string): void {
29
31
  if (config.upgrade) { config.upgrade(key); }
30
32
 
31
33
  encode(Event.Upgrade);
34
+
35
+ if (config.lite) {
36
+ discover.start();
37
+ style.start();
38
+ }
32
39
  }
33
40
  }
34
41
 
package/src/layout/dom.ts CHANGED
@@ -426,6 +426,8 @@ function getPreviousId(node: Node): number {
426
426
  }
427
427
 
428
428
  function track(id: number, source: Source, changed: boolean = true, parentChanged: boolean = false): void {
429
+ if (config.lean && config.lite) { return; }
430
+
429
431
  // Keep track of the order in which mutations happened, they may not be sequential
430
432
  // Edge case: If an element is added later on, and pre-discovered element is moved as a child.
431
433
  // In that case, we need to reorder the pre-discovered element in the update list to keep visualization consistent.
@@ -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
@@ -5,23 +5,28 @@ import { shortid } from "@src/data/metadata";
5
5
  import encode from "@src/layout/encode";
6
6
  import { getId } from "@src/layout/dom";
7
7
  import * as core from "@src/core";
8
+ import config from "@src/core/config";
8
9
  import { getCssRules } from "./node";
9
10
  import * as metric from "@src/data/metric";
10
11
 
11
12
  export let sheetUpdateState: StyleSheetState[] = [];
12
13
  export let sheetAdoptionState: StyleSheetState[] = [];
13
- let replace: (text?: string) => Promise<CSSStyleSheet> = null;
14
- let replaceSync: (text?: string) => void = null;
15
14
  const styleSheetId = 'claritySheetId';
16
15
  let styleSheetMap = {};
17
16
  let styleTimeMap: {[key: string]: number} = {};
18
17
  let documentNodes = [];
19
18
  let createdSheetIds = [];
20
19
 
21
- export function start(): void {
22
- if (window['CSSStyleSheet'] && CSSStyleSheet.prototype) {
23
- if (replace === null) {
24
- replace = CSSStyleSheet.prototype.replace;
20
+ function proxyStyleRules(win: any) {
21
+ if ((config.lean && config.lite) || win === null || win === undefined) {
22
+ return;
23
+ }
24
+
25
+ win.clarityOverrides = win.clarityOverrides || {};
26
+
27
+ if (win['CSSStyleSheet'] && win.CSSStyleSheet.prototype) {
28
+ if (win.clarityOverrides.replace === undefined) {
29
+ win.clarityOverrides.replace = CSSStyleSheet.prototype.replace;
25
30
  CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
26
31
  if (core.active()) {
27
32
  metric.max(Metric.ConstructedStyles, 1);
@@ -32,12 +37,12 @@ export function start(): void {
32
37
  trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Replace, arguments[0]);
33
38
  }
34
39
  }
35
- return replace.apply(this, arguments);
40
+ return win.clarityOverrides.replace.apply(this, arguments);
36
41
  };
37
42
  }
38
-
39
- if (replaceSync === null) {
40
- replaceSync = CSSStyleSheet.prototype.replaceSync;
43
+
44
+ if (win.clarityOverrides.replaceSync === undefined) {
45
+ win.clarityOverrides.replaceSync = CSSStyleSheet.prototype.replaceSync;
41
46
  CSSStyleSheet.prototype.replaceSync = function(): void {
42
47
  if (core.active()) {
43
48
  metric.max(Metric.ConstructedStyles, 1);
@@ -48,15 +53,24 @@ export function start(): void {
48
53
  trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.ReplaceSync, arguments[0]);
49
54
  }
50
55
  }
51
- return replaceSync.apply(this, arguments);
56
+ return win.clarityOverrides.replaceSync.apply(this, arguments);
52
57
  };
53
58
  }
54
- }
59
+ }
60
+ }
61
+
62
+ export function start(): void {
63
+ proxyStyleRules(window);
55
64
  }
56
65
 
57
66
  export function checkDocumentStyles(documentNode: Document, timestamp: number): void {
67
+ if (config.lean && config.lite) { return; }
68
+
58
69
  if (documentNodes.indexOf(documentNode) === -1) {
59
70
  documentNodes.push(documentNode);
71
+ if (documentNode.defaultView) {
72
+ proxyStyleRules(documentNode.defaultView);
73
+ }
60
74
  }
61
75
  timestamp = timestamp || time();
62
76
  if (!documentNode?.adoptedStyleSheets) {
package/types/core.d.ts CHANGED
@@ -120,6 +120,7 @@ export interface Config {
120
120
  projectId?: string;
121
121
  delay?: number;
122
122
  lean?: boolean;
123
+ lite?: boolean;
123
124
  track?: boolean;
124
125
  content?: boolean;
125
126
  drop?: string[];