clarity-js 0.7.53 → 0.7.57

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 gt},get start(){return vt},get stop(){return mt},get track(){return st}}),n=Object.freeze({__proto__:null,get check(){return Et},get compute(){return Mt},get data(){return lt},get start(){return _t},get stop(){return Ot},get trigger(){return It}}),e=Object.freeze({__proto__:null,get compute(){return At},get data(){return Tt},get log(){return Ct},get reset(){return qt},get start(){return jt},get stop(){return zt},get updates(){return xt}}),r=Object.freeze({__proto__:null,get callback(){return Wt},get callbacks(){return Pt},get clear(){return Jt},get consent(){return Xt},get data(){return Dt},get electron(){return Rt},get id(){return Bt},get metadata(){return Vt},get save(){return Zt},get shortid(){return Yt},get start(){return Ht},get stop(){return Lt}}),o=Object.freeze({__proto__:null,get data(){return rn},get envelope(){return cn},get start(){return on},get stop(){return an}}),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,longTask:30};function i(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var c=0;function u(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-c),0)}var s="0.7.53";var l=!0,d=null,f=null;function p(t,n,e){return function(){if(l&&null===d)try{d=new RegExp("\\p{N}","gu"),f=new RegExp("\\p{L}","gu"),new RegExp("\\p{Sc}","gu")}catch(t){l=!1}}(),t?t.replace(f,n).replace(d,e):t}var h=[],v=null;function g(){}var m=[];function y(){}function w(){}var b=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:v,hashText:y,keys:m,log:g,observe:function(){},reset:function(){},sheetAdoptionState:[],sheetUpdateState:[],start:function(){},state:h,stop:function(){},trigger:w}),k=null;function S(t,n){Cn()&&t&&"string"==typeof t&&t.length<255&&(k=n&&"string"==typeof n&&n.length<255?{key:t,value:n}:{value:t},St(24))}var _,E=null,I=null;function M(t){t in E||(E[t]=0),t in I||(I[t]=0),E[t]++,I[t]++}function O(t,n){null!==n&&(t in E||(E[t]=0),t in I||(I[t]=0),E[t]+=n,I[t]+=n)}function T(t,n){null!==n&&!1===isNaN(n)&&(t in E||(E[t]=0),(n>E[t]||0===E[t])&&(I[t]=n,E[t]=n))}function x(t,n,e){return window.setTimeout(ln(t),n,e)}function j(t){return window.clearTimeout(t)}var z=0,C=0,A=null;function q(){A&&j(A),A=x(N,C),z=u()}function N(){var t=u();_={gap:t-z},St(25),_.gap<3e5?A=x(N,C):xn&&(S("clarity","suspend"),te(),["mousemove","touchstart"].forEach((function(t){return fn(document,t,An)})),["resize","scroll","pageshow"].forEach((function(t){return fn(window,t,An)})))}var D=Object.freeze({__proto__:null,get data(){return _},reset:q,start:function(){C=6e4,z=0},stop:function(){j(A),z=0,C=0}}),P=null;function R(t){Cn()&&a.lean&&(a.lean=!1,P={key:t},Wt(),Zt(),a.upgrade&&a.upgrade(t),St(3))}var U=Object.freeze({__proto__:null,get data(){return P},start:function(){!a.lean&&a.upgrade&&a.upgrade("Config"),P=null},stop:function(){P=null},upgrade:R});function H(t,n,e,r){return new(e||(e=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function c(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(i,c)}u((r=r.apply(t,n||[])).next())}))}function L(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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var V=null;function B(t,n){J(t,"string"==typeof n?[n]:n)}function X(t,n,e,r){return void 0===n&&(n=null),void 0===e&&(e=null),void 0===r&&(r=null),H(this,void 0,void 0,(function(){var o,a;return L(this,(function(i){switch(i.label){case 0:return a={},[4,G(t)];case 1:return a.userId=i.sent(),a.userHint=r||((c=t)&&c.length>=5?"".concat(c.substring(0,2)).concat(p(c.substring(2),"*","*")):p(c,"*","*")),J("userId",[(o=a).userId]),J("userHint",[o.userHint]),J("userType",[F(t)]),n&&(J("sessionId",[n]),o.sessionId=n),e&&(J("pageId",[e]),o.pageId=e),[2,o]}var c}))}))}function J(t,n){if(Cn()&&t&&n&&"string"==typeof t&&t.length<255){for(var e=(t in V?V[t]:[]),r=0;r<n.length;r++)"string"==typeof n[r]&&n[r].length<255&&e.push(n[r]);V[t]=e}}function W(){St(34)}function Z(){V={}}function G(t){return H(this,void 0,void 0,(function(){var n;return L(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 F(t){return t&&t.indexOf("@")>0?"email":"string"}var Y="CompressionStream"in window;function K(t){return H(this,void 0,void 0,(function(){var n,e;return L(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),Y?(n=new ReadableStream({start:function(n){return H(this,void 0,void 0,(function(){return L(this,(function(e){return n.enqueue(t),n.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),e=Uint8Array.bind,[4,Q(n)]):[3,2];case 1:return[2,new(e.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,null]}}))}))}function Q(t){return H(this,void 0,void 0,(function(){var n,e,r,o,a;return L(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 $=null;function tt(t){try{if(!$)return;var n=function(t){try{return JSON.parse(t)}catch(t){return[]}}(t);n.forEach((function(t){$(t)}))}catch(t){}}var nt=[b,e,Object.freeze({__proto__:null,compute:W,get data(){return V},identify:X,reset:Z,set:B,start:function(){Z()},stop:function(){Z()}}),n,b,r,o,t,D,U,b];function et(){E={},I={},M(5),nt.forEach((function(t){return ln(t.start)()}))}function rt(){nt.slice().reverse().forEach((function(t){return ln(t.stop)()})),E={},I={}}function ot(){W(),At(),St(0),Mt()}var at,it,ct,ut,st,lt,dt=0,ft=0,pt=null,ht=0;function vt(){ut=!0,dt=0,ft=0,ht=0,at=[],it=[],ct={},st=null}function gt(t,n){if(void 0===n&&(n=!0),ut){var e=u(),r=t.length>1?t[1]:null,o=JSON.stringify(t);switch(r){case 5:dt+=o.length;case 37:case 6:case 43:case 45:case 46:ft+=o.length,at.push(o);break;default:it.push(o)}M(25);var i=function(){var t=!1===a.lean&&dt>0?100:rn.sequence*a.delay;return"string"==typeof a.upload?Math.max(Math.min(t,3e4),100):a.delay}();e-ht>2*i&&(j(pt),pt=null),n&&null===pt&&(25!==r&&q(),pt=x(yt,i),ht=e,Et(ft))}}function mt(){j(pt),yt(!0),dt=0,ft=0,ht=0,at=[],it=[],ct={},st=null,ut=!1}function yt(t){return void 0===t&&(t=!1),H(this,void 0,void 0,(function(){var n,e,r,o,i,c,u,s;return L(this,(function(l){switch(l.label){case 0:return pt=null,(n=!1===a.lean&&ft>0&&(ft<1048576||rn.sequence>0))&&T(1,1),ot(),e=!0===t,r=JSON.stringify(cn(e)),o="[".concat(it.join(),"]"),i=n?"[".concat(at.join(),"]"):"",c=function(t){return t.p.length>0?'{"e":'.concat(t.e,',"a":').concat(t.a,',"p":').concat(t.p,"}"):'{"e":'.concat(t.e,',"a":').concat(t.a,"}")}({e:r,a:o,p:i}),e?(s=null,[3,3]):[3,1];case 1:return[4,K(c)];case 2:s=l.sent(),l.label=3;case 3:return O(2,(u=s)?u.length:c.length),wt(c,u,rn.sequence,e),it=[],n&&(at=[],ft=0,dt=0),[2]}}))}))}function wt(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))&&kt(e)}catch(t){}if(!1===i){e in ct?ct[e].attempts++:ct[e]={data:t,attempts:1};var c=new XMLHttpRequest;c.open("POST",o,!0),c.timeout=15e3,c.ontimeout=function(){sn(new Error("".concat("Timeout"," : ").concat(o)))},null!==e&&(c.onreadystatechange=function(){ln(bt)(c,e)}),c.withCredentials=!0,n?(c.setRequestHeader("Accept","application/x-clarity-gzip"),c.send(n)):c.send(t)}}else if(a.upload){(0,a.upload)(t),kt(e)}}function bt(t,n){var e=ct[n];t&&4===t.readyState&&e&&((t.status<200||t.status>208)&&e.attempts<=1?t.status>=400&&t.status<500?It(6):(0===t.status&&(a.upload=a.fallback?a.fallback:a.upload),wt(e.data,null,n)):(st={sequence:n,attempts:e.attempts,status:t.status},e.attempts>1&&St(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":It(6);break;case"UPGRADE":R("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&&tt(i[1])}}}(t.responseText),0===t.status&&(wt(e.data,null,n,!0),It(3)),t.status>=200&&t.status<=208&&kt(n),delete ct[n]))}function kt(t){1===t&&(Zt(),Wt())}function St(t){var n=[u(),t];switch(t){case 4:var e=h;e&&((n=[e.time,e.event]).push(e.data.visible),n.push(e.data.docWidth),n.push(e.data.docHeight),n.push(e.data.screenWidth),n.push(e.data.screenHeight),n.push(e.data.scrollX),n.push(e.data.scrollY),n.push(e.data.pointerX),n.push(e.data.pointerY),n.push(e.data.activityTime),n.push(e.data.scrollTime),gt(n,!1));break;case 25:n.push(_.gap),gt(n);break;case 35:n.push(lt.check),gt(n,!1);break;case 3:n.push(P.key),gt(n);break;case 2:n.push(st.sequence),n.push(st.attempts),n.push(st.status),gt(n,!1);break;case 24:k.key&&n.push(k.key),n.push(k.value),gt(n);break;case 34:var r=Object.keys(V);if(r.length>0){for(var o=0,a=r;o<a.length;o++){var i=a[o];n.push(i),n.push(V[i])}Z(),gt(n,!1)}break;case 0:var c=Object.keys(I);if(c.length>0){for(var s=0,l=c;s<l.length;s++){var d=l[s],f=parseInt(d,10);n.push(f),n.push(Math.round(I[d]))}I={},gt(n,!1)}break;case 1:var p=Object.keys(xt);if(p.length>0){for(var g=0,y=p;g<y.length;g++){var w=y[g];f=parseInt(w,10);n.push(f),n.push(xt[w])}qt(),gt(n,!1)}break;case 36:var b=Object.keys(v);if(b.length>0){for(var S=0,E=b;S<E.length;S++){var M=E[S];f=parseInt(M,10);n.push(f),n.push([].concat.apply([],v[M]))}gt(n,!1)}break;case 40:m.forEach((function(t){n.push(t);var e=[];for(var r in v[t]){var o=parseInt(r,10);e.push(o),e.push(v[t][r])}n.push(e)})),gt(n,!1)}}function _t(){lt={check:0}}function Et(t){if(0===lt.check){var n=lt.check;n=rn.sequence>=128?1:n,n=rn.pageNum>=128?7:n,n=u()>72e5?2:n,(n=t>10485760?2:n)!==lt.check&&It(n)}}function It(t){lt.check=t,Jt(),te()}function Mt(){0!==lt.check&&St(35)}function Ot(){lt=null}var Tt=null,xt=null;function jt(){Tt={},xt={}}function zt(){Tt={},xt={}}function Ct(t,n){n&&(n="".concat(n),t in Tt||(Tt[t]=[]),Tt[t].indexOf(n)<0&&(Tt[t].push(n),t in xt||(xt[t]=[]),xt[t].push(n),Tt[t].length>128&&It(5)))}function At(){St(1)}function qt(){xt={}}function Nt(t){Ct(36,t.toString())}var Dt=null,Pt=[],Rt=0,Ut=null;function Ht(){var t,n,e;Ut=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(),c=window.location.ancestorOrigins?Array.from(window.location.ancestorOrigins).toString():"",u=document&&document.title?document.title:"";Rt=r.indexOf("Electron")>0?1:0;var s,l=function(){var t={session:Yt(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},n=$t("_clsk");if(n){var e=n.split("|");e.length>=5&&t.ts-Kt(e[1])<18e5&&(t.session=e[0],t.count=Kt(e[2])+1,t.upgrade=Kt(e[3]),t.upload=e.length>=6?"".concat("https://").concat(e[5],"/").concat(e[4]):"".concat("https://").concat(e[4]))}return t}(),d=Qt(),f=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);Dt={projectId:f,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,Ct(0,r),Ct(3,u),Ct(1,function(t,n){if(void 0===n&&(n=!1),n)return"".concat("https://").concat("Electron");var e=a.drop;if(e&&e.length>0&&t&&t.indexOf("?")>0){var r=t.split("?");return r[0]+"?"+r[1].split("&").map((function(t){return e.some((function(n){return 0===t.indexOf("".concat(n,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}return t}(location.href,!!Rt)),Ct(2,document.referrer),Ct(15,function(){var t=Yt();if(a.track&&Gt(window,"sessionStorage")){var n=sessionStorage.getItem("_cltk");t=n||t,sessionStorage.setItem("_cltk",t)}return t}()),Ct(16,document.documentElement.lang),Ct(17,document.dir),Ct(26,"".concat(window.devicePixelRatio)),Ct(28,d.dob.toString()),Ct(29,d.version.toString()),Ct(33,c),Ct(34,o),Ct(35,i),T(0,l.ts),T(1,0),T(35,Rt),navigator&&(Ct(9,navigator.language),T(33,navigator.hardwareConcurrency),T(32,navigator.maxTouchPoints),T(34,Math.round(navigator.deviceMemory)),(s=navigator.userAgentData)&&s.getHighEntropyValues?s.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var n;Ct(22,t.platform),Ct(23,t.platformVersion),null===(n=t.brands)||void 0===n||n.forEach((function(t){Ct(24,t.name+"~"+t.version)})),Ct(25,t.model),T(27,t.mobile?1:0)})):Ct(22,navigator.platform)),screen&&(T(14,Math.round(screen.width)),T(15,Math.round(screen.height)),T(16,Math.round(screen.colorDepth)));for(var p=0,h=a.cookies;p<h.length;p++){var v=h[p],g=$t(v);g&&B(v,g)}!function(t){Nt(t?1:0)}(a.track),Ft(d)}function Lt(){Ut=null,Dt=null,Pt.forEach((function(t){t.called=!1}))}function Vt(t,n,e){void 0===n&&(n=!0),void 0===e&&(e=!1);var r=a.lean?0:1,o=!1;Dt&&(r||!1===n)&&(t(Dt,!a.lean),o=!0),!e&&o||Pt.push({callback:t,wait:n,recall:e,called:o})}function Bt(){return Dt?[Dt.userId,Dt.sessionId,Dt.pageNum].join("."):""}function Xt(t){if(void 0===t&&(t=!0),!t)return a.track=!1,nn("_clsk","",-Number.MAX_VALUE),nn("_clck","",-Number.MAX_VALUE),te(),void window.setTimeout($n,250);Cn()&&(a.track=!0,Ft(Qt(),1),Zt(),Nt(2))}function Jt(){nn("_clsk","",0)}function Wt(){!function(t){if(Pt.length>0)for(var n=0;n<Pt.length;n++){var e=Pt[n];!e.callback||e.called||e.wait&&!t||(e.callback(Dt,!a.lean),e.called=!0,e.recall||(Pt.splice(n,1),n--))}}(a.lean?0:1)}function Zt(){if(Dt){var t=Math.round(Date.now()),n=a.upload&&"string"==typeof a.upload?a.upload.replace("https://",""):"",e=a.lean?0:1;nn("_clsk",[Dt.sessionId,t,Dt.pageNum,e,n].join("|"),1)}}function Gt(t,n){try{return!!t[n]}catch(t){return!1}}function Ft(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)&&nn("_clck",[Dt.userId,2,e.toString(36),n,r].join("|"),365)}function Yt(){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 Kt(t,n){return void 0===n&&(n=10),parseInt(t,n)}function Qt(){var t={id:Yt(),version:0,expiry:null,consent:0,dob:0},n=$t("_clck");if(n&&n.length>0){for(var e=n.split("|"),r=0,o=0,i=document.cookie.split(";");o<i.length;o++){r+="_clck"===i[o].split("=")[0].trim()?1:0}if(1===e.length||r>1){var c="".concat(";").concat("expires=").concat(new Date(0).toUTCString()).concat(";path=/");document.cookie="".concat("_clck","=").concat(c),document.cookie="".concat("_clsk","=").concat(c)}e.length>1&&(t.version=Kt(e[1])),e.length>2&&(t.expiry=Kt(e[2],36)),e.length>3&&1===Kt(e[3])&&(t.consent=1),e.length>4&&Kt(e[1])>1&&(t.dob=Kt(e[4])),a.track=a.track||1===t.consent,t.id=a.track?e[0]:t.id}return t}function $t(t){var n;if(Gt(document,"cookie")){var e=document.cookie.split(";");if(e)for(var r=0;r<e.length;r++){var o=e[r].split("=");if(o.length>1&&o[0]&&o[0].trim()===t){for(var a=tn(o[1]),i=a[0],c=a[1];i;)i=(n=tn(c))[0],c=n[1];return c}}}return null}function tn(t){try{var n=decodeURIComponent(t);return[n!=t,n]}catch(t){}return[!1,t]}function nn(t,n,e){if((a.track||""==n)&&(navigator&&navigator.cookieEnabled||Gt(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(n),o=new Date;o.setDate(o.getDate()+e);var i=o?"expires="+o.toUTCString():"",c="".concat(t,"=").concat(r).concat(";").concat(i).concat(";path=/");try{if(null===Ut){for(var u=location.hostname?location.hostname.split("."):[],s=u.length-1;s>=0;s--)if(Ut=".".concat(u[s]).concat(Ut||""),s<u.length-1&&(document.cookie="".concat(c).concat(";").concat("domain=").concat(Ut),$t(t)===n))return;Ut=""}}catch(t){Ut=""}document.cookie=Ut?"".concat(c).concat(";").concat("domain=").concat(Ut):c}}var en,rn=null;function on(){var t=Dt;rn={version:s,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0}}function an(){rn=null}function cn(t){return rn.start=rn.start+rn.duration,rn.duration=u()-rn.start,rn.sequence++,rn.upload=t&&"sendBeacon"in navigator?1:0,rn.end=t?1:0,[rn.version,rn.sequence,rn.start,rn.duration,rn.projectId,rn.userId,rn.sessionId,rn.pageNum,rn.upload,rn.end]}function un(){en=[]}function sn(t){if(en&&-1===en.indexOf(t.message)){var n=a.report;if(n&&n.length>0){var e={v:rn.version,p:rn.projectId,u:rn.userId,s:rn.sessionId,n:rn.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)),en.push(t.message)}}return t}function ln(t){return function(){var n=performance.now();try{t.apply(this,arguments)}catch(t){throw sn(t)}var e=performance.now()-n;O(4,e),e>a.longTask&&(M(7),T(6,e))}}var dn=[];function fn(t,n,e,r){void 0===r&&(r=!1),e=ln(e);try{t[i("addEventListener")](n,e,r),dn.push({event:n,target:t,listener:e,capture:r})}catch(t){}}function pn(){for(var t=0,n=dn;t<n.length;t++){var e=n[t];try{e.target[i("removeEventListener")](e.event,e.listener,e.capture)}catch(t){}}dn=[]}var hn=null,vn=null,gn=null,mn=0;function yn(){return!(mn++>20)}function wn(){mn=0,gn!==kn()&&(te(),window.setTimeout(bn,250))}function bn(){$n(),T(29,1)}function kn(){return location.href?location.href.replace(location.hash,""):location.href}var Sn=[],_n=null,En=null,In=null;function Mn(){En&&(In(),En=null,null===_n&&Tn())}function On(){Sn=[],_n=null,En=null}function Tn(){var t=Sn.shift();t&&(_n=t,t.task().then((function(){t.id===Bt()&&(t.resolve(),_n=null,Tn())})).catch((function(n){t.id===Bt()&&(n&&(n.name,n.message,n.stack),_n=null,Tn())})))}var xn=!1;function jn(){xn=!0,c=performance.now()+performance.timeOrigin,On(),pn(),un(),gn=kn(),mn=0,fn(window,"popstate",wn),null===hn&&(hn=history.pushState,history.pushState=function(){hn.apply(this,arguments),Cn()&&yn()&&wn()}),null===vn&&(vn=history.replaceState,history.replaceState=function(){vn.apply(this,arguments),Cn()&&yn()&&wn()})}function zn(){gn=null,mn=0,un(),pn(),On(),c=0,xn=!1}function Cn(){return xn}function An(){$n(),S("clarity","restart")}var qn=null;function Nn(){qn=null}function Dn(t){qn={fetchStart:Math.round(t.fetchStart),connectStart:Math.round(t.connectStart),connectEnd:Math.round(t.connectEnd),requestStart:Math.round(t.requestStart),responseStart:Math.round(t.responseStart),responseEnd:Math.round(t.responseEnd),domInteractive:Math.round(t.domInteractive),domComplete:Math.round(t.domComplete),loadEventStart:Math.round(t.loadEventStart),loadEventEnd:Math.round(t.loadEventEnd),redirectCount:Math.round(t.redirectCount),size:t.transferSize?t.transferSize:0,type:t.type,protocol:t.nextHopProtocol,encodedSize:t.encodedBodySize?t.encodedBodySize:0,decodedSize:t.decodedBodySize?t.decodedBodySize:0},function(t){H(this,void 0,void 0,(function(){var n,e;return L(this,(function(r){return n=u(),e=[n,t],29===t&&(e.push(qn.fetchStart),e.push(qn.connectStart),e.push(qn.connectEnd),e.push(qn.requestStart),e.push(qn.responseStart),e.push(qn.responseEnd),e.push(qn.domInteractive),e.push(qn.domComplete),e.push(qn.loadEventStart),e.push(qn.loadEventEnd),e.push(qn.redirectCount),e.push(qn.size),e.push(qn.type),e.push(qn.protocol),e.push(qn.encodedSize),e.push(qn.decodedSize),Nn(),gt(e)),[2]}))}))}(29)}var Pn,Rn=0,Un=1/0,Hn=0,Ln=0,Vn=[],Bn=new Map,Xn=function(){return Rn||0},Jn=function(){if(!Vn.length)return-1;var t=Math.min(Vn.length-1,Math.floor((Xn()-Ln)/50));return Vn[t].latency},Wn=function(){Ln=Xn(),Vn.length=0,Bn.clear()},Zn=function(t){if(t.interactionId&&!(t.duration<40)){!function(t){"interactionCount"in performance?Rn=performance.interactionCount:t.interactionId&&(Un=Math.min(Un,t.interactionId),Hn=Math.max(Hn,t.interactionId),Rn=Hn?(Hn-Un)/7+1:0)}(t);var n=Vn[Vn.length-1],e=Bn.get(t.interactionId);if(e||Vn.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};Bn.set(r.id,r),Vn.push(r)}Vn.sort((function(t,n){return n.latency-t.latency})),Vn.length>10&&Vn.splice(10).forEach((function(t){return Bn.delete(t.id)}))}}},Gn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint","event"];function Fn(){try{Pn&&Pn.disconnect(),Pn=new PerformanceObserver(ln(Yn));for(var t=0,n=Gn;t<n.length;t++){var e=n[t];PerformanceObserver.supportedEntryTypes.indexOf(e)>=0&&("layout-shift"===e&&O(9,0),Pn.observe({type:e,buffered:!0}))}}catch(t){}}function Yn(t){!function(t){for(var n=(!("visibilityState"in document)||"visible"===document.visibilityState),e=0;e<t.length;e++){var r=t[e];switch(r.entryType){case"navigation":Dn(r);break;case"resource":var o=r.name;Ct(4,Kn(o)),o!==a.upload&&o!==a.fallback||T(28,r.duration);break;case"longtask":M(7);break;case"first-input":n&&T(10,r.processingStart-r.startTime);break;case"event":n&&"PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&(Zn(r),Ct(37,Jn().toString()));break;case"layout-shift":n&&!r.hadRecentInput&&O(9,1e3*r.value);break;case"largest-contentful-paint":n&&T(8,r.startTime)}}}(t.getEntries())}function Kn(t){var n=document.createElement("a");return n.href=t,n.host}var Qn=[b,b,b,Object.freeze({__proto__:null,start:function(){Nn(),function(){navigator&&"connection"in navigator&&Ct(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?fn(window,"load",x.bind(this,Fn,0)):Fn())}()},stop:function(){Pn&&Pn.disconnect(),Pn=null,Wn(),Nn()}})];function $n(t){void 0===t&&(t=null),function(){try{var t=navigator&&"globalPrivacyControl"in navigator&&1==navigator.globalPrivacyControl;return!1===xn&&"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||xn)return!1;for(var n in t)n in a&&(a[n]=t[n])}(t),jn(),et(),Qn.forEach((function(t){return ln(t.start)()})),null===t&&oe())}function te(){Cn()&&(Qn.slice().reverse().forEach((function(t){return ln(t.stop)()})),rt(),zn(),void 0!==ee&&(ee[re]=function(){(ee[re].q=ee[re].q||[]).push(arguments),"start"===arguments[0]&&ee[re].q.unshift(ee[re].q.pop())&&oe()}))}var ne=Object.freeze({__proto__:null,consent:Xt,event:S,hashText:y,identify:X,metadata:Vt,pause:function(){Cn()&&(S("clarity","pause"),null===En&&(En=new Promise((function(t){In=t}))))},resume:function(){Cn()&&(Mn(),S("clarity","resume"))},set:B,signal:function(t){$=t},start:$n,stop:te,upgrade:R,version:s}),ee=window,re="clarity";function oe(){if(void 0!==ee){if(ee[re]&&ee[re].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=ee[re]&&ee[re].q||[];for(ee[re]=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return ne[t].apply(ne,n)},ee[re].v=s;t.length>0;)ee[re].apply(ee,t.shift())}}oe()}();
1
+ !function(){"use strict";var t=Object.freeze({__proto__:null,get queue(){return gt},get start(){return vt},get stop(){return mt},get track(){return st}}),n=Object.freeze({__proto__:null,get check(){return Et},get compute(){return Mt},get data(){return lt},get start(){return _t},get stop(){return Ot},get trigger(){return It}}),e=Object.freeze({__proto__:null,get compute(){return qt},get data(){return Tt},get log(){return At},get reset(){return Nt},get start(){return zt},get stop(){return Ct},get updates(){return xt}}),r=Object.freeze({__proto__:null,get callback(){return Zt},get callbacks(){return Rt},get clear(){return Jt},get consent(){return Wt},get data(){return Pt},get electron(){return Ut},get id(){return Xt},get metadata(){return Bt},get save(){return Gt},get shortid(){return Kt},get start(){return Lt},get stop(){return Vt}}),o=Object.freeze({__proto__:null,get data(){return on},get envelope(){return un},get start(){return an},get stop(){return cn}}),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,longTask:30,includeSubdomains:!0};function i(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var c=0;function u(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-c),0)}var s="0.7.57";var l=!0,d=null,f=null;function p(t,n,e){return function(){if(l&&null===d)try{d=new RegExp("\\p{N}","gu"),f=new RegExp("\\p{L}","gu"),new RegExp("\\p{Sc}","gu")}catch(t){l=!1}}(),t?t.replace(f,n).replace(d,e):t}var h=[],v=null;function g(){}var m=[];function y(){}function b(){}var w=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:v,hashText:y,keys:m,log:g,observe:function(){},reset:function(){},sheetAdoptionState:[],sheetUpdateState:[],start:function(){},state:h,stop:function(){},trigger:b}),k=null;function S(t,n){An()&&t&&"string"==typeof t&&t.length<255&&(k=n&&"string"==typeof n&&n.length<255?{key:t,value:n}:{value:t},St(24))}var _,E=null,I=null;function M(t){t in E||(E[t]=0),t in I||(I[t]=0),E[t]++,I[t]++}function O(t,n){null!==n&&(t in E||(E[t]=0),t in I||(I[t]=0),E[t]+=n,I[t]+=n)}function T(t,n){null!==n&&!1===isNaN(n)&&(t in E||(E[t]=0),(n>E[t]||0===E[t])&&(I[t]=n,E[t]=n))}function x(t,n,e){return window.setTimeout(dn(t),n,e)}function j(t){return window.clearTimeout(t)}var z=0,C=0,A=null;function q(){A&&j(A),A=x(N,C),z=u()}function N(){var t=u();_={gap:t-z},St(25),_.gap<3e5?A=x(N,C):jn&&(S("clarity","suspend"),ne(),["mousemove","touchstart"].forEach((function(t){return pn(document,t,qn)})),["resize","scroll","pageshow"].forEach((function(t){return pn(window,t,qn)})))}var D=Object.freeze({__proto__:null,get data(){return _},reset:q,start:function(){C=6e4,z=0},stop:function(){j(A),z=0,C=0}}),P=null;function R(t){An()&&a.lean&&(a.lean=!1,P={key:t},Zt(),Gt(),a.upgrade&&a.upgrade(t),St(3))}var U=Object.freeze({__proto__:null,get data(){return P},start:function(){!a.lean&&a.upgrade&&a.upgrade("Config"),P=null},stop:function(){P=null},upgrade:R});function H(t,n,e,r){return new(e||(e=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function c(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(i,c)}u((r=r.apply(t,n||[])).next())}))}function L(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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var V=null;function B(t,n){W(t,"string"==typeof n?[n]:n)}function X(t,n,e,r){return void 0===n&&(n=null),void 0===e&&(e=null),void 0===r&&(r=null),H(this,void 0,void 0,(function(){var o,a;return L(this,(function(i){switch(i.label){case 0:return a={},[4,G(t)];case 1:return a.userId=i.sent(),a.userHint=r||((c=t)&&c.length>=5?"".concat(c.substring(0,2)).concat(p(c.substring(2),"*","*")):p(c,"*","*")),W("userId",[(o=a).userId]),W("userHint",[o.userHint]),W("userType",[F(t)]),n&&(W("sessionId",[n]),o.sessionId=n),e&&(W("pageId",[e]),o.pageId=e),[2,o]}var c}))}))}function W(t,n){if(An()&&t&&n&&"string"==typeof t&&t.length<255){for(var e=(t in V?V[t]:[]),r=0;r<n.length;r++)"string"==typeof n[r]&&n[r].length<255&&e.push(n[r]);V[t]=e}}function J(){St(34)}function Z(){V={}}function G(t){return H(this,void 0,void 0,(function(){var n;return L(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 F(t){return t&&t.indexOf("@")>0?"email":"string"}var Y="CompressionStream"in window;function K(t){return H(this,void 0,void 0,(function(){var n,e;return L(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),Y?(n=new ReadableStream({start:function(n){return H(this,void 0,void 0,(function(){return L(this,(function(e){return n.enqueue(t),n.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),e=Uint8Array.bind,[4,Q(n)]):[3,2];case 1:return[2,new(e.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,null]}}))}))}function Q(t){return H(this,void 0,void 0,(function(){var n,e,r,o,a;return L(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 $=null;function tt(t){try{if(!$)return;var n=function(t){try{return JSON.parse(t)}catch(t){return[]}}(t);n.forEach((function(t){$(t)}))}catch(t){}}var nt=[w,e,Object.freeze({__proto__:null,compute:J,get data(){return V},identify:X,reset:Z,set:B,start:function(){Z()},stop:function(){Z()}}),n,w,r,o,t,D,U,w];function et(){E={},I={},M(5),nt.forEach((function(t){return dn(t.start)()}))}function rt(){nt.slice().reverse().forEach((function(t){return dn(t.stop)()})),E={},I={}}function ot(){J(),qt(),St(0),Mt()}var at,it,ct,ut,st,lt,dt=0,ft=0,pt=null,ht=0;function vt(){ut=!0,dt=0,ft=0,ht=0,at=[],it=[],ct={},st=null}function gt(t,n){if(void 0===n&&(n=!0),ut){var e=u(),r=t.length>1?t[1]:null,o=JSON.stringify(t);switch(r){case 5:dt+=o.length;case 37:case 6:case 43:case 45:case 46:ft+=o.length,at.push(o);break;default:it.push(o)}M(25);var i=function(){var t=!1===a.lean&&dt>0?100:on.sequence*a.delay;return"string"==typeof a.upload?Math.max(Math.min(t,3e4),100):a.delay}();e-ht>2*i&&(j(pt),pt=null),n&&null===pt&&(25!==r&&q(),pt=x(yt,i),ht=e,Et(ft))}}function mt(){j(pt),yt(!0),dt=0,ft=0,ht=0,at=[],it=[],ct={},st=null,ut=!1}function yt(t){return void 0===t&&(t=!1),H(this,void 0,void 0,(function(){var n,e,r,o,i,c,u,s;return L(this,(function(l){switch(l.label){case 0:return pt=null,(n=!1===a.lean&&ft>0&&(ft<1048576||on.sequence>0))&&T(1,1),ot(),e=!0===t,r=JSON.stringify(un(e)),o="[".concat(it.join(),"]"),i=n?"[".concat(at.join(),"]"):"",c=function(t){return t.p.length>0?'{"e":'.concat(t.e,',"a":').concat(t.a,',"p":').concat(t.p,"}"):'{"e":'.concat(t.e,',"a":').concat(t.a,"}")}({e:r,a:o,p:i}),e?(s=null,[3,3]):[3,1];case 1:return[4,K(c)];case 2:s=l.sent(),l.label=3;case 3:return O(2,(u=s)?u.length:c.length),bt(c,u,on.sequence,e),it=[],n&&(at=[],ft=0,dt=0),[2]}}))}))}function bt(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))&&kt(e)}catch(t){}if(!1===i){e in ct?ct[e].attempts++:ct[e]={data:t,attempts:1};var c=new XMLHttpRequest;c.open("POST",o,!0),c.timeout=15e3,c.ontimeout=function(){ln(new Error("".concat("Timeout"," : ").concat(o)))},null!==e&&(c.onreadystatechange=function(){dn(wt)(c,e)}),c.withCredentials=!0,n?(c.setRequestHeader("Accept","application/x-clarity-gzip"),c.send(n)):c.send(t)}}else if(a.upload){(0,a.upload)(t),kt(e)}}function wt(t,n){var e=ct[n];t&&4===t.readyState&&e&&((t.status<200||t.status>208)&&e.attempts<=1?t.status>=400&&t.status<500?It(6):(0===t.status&&(a.upload=a.fallback?a.fallback:a.upload),bt(e.data,null,n)):(st={sequence:n,attempts:e.attempts,status:t.status},e.attempts>1&&St(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":It(6);break;case"UPGRADE":R("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&&tt(i[1])}}}(t.responseText),0===t.status&&(bt(e.data,null,n,!0),It(3)),t.status>=200&&t.status<=208&&kt(n),delete ct[n]))}function kt(t){1===t&&(Gt(),Zt())}function St(t){var n=[u(),t];switch(t){case 4:var e=h;e&&((n=[e.time,e.event]).push(e.data.visible),n.push(e.data.docWidth),n.push(e.data.docHeight),n.push(e.data.screenWidth),n.push(e.data.screenHeight),n.push(e.data.scrollX),n.push(e.data.scrollY),n.push(e.data.pointerX),n.push(e.data.pointerY),n.push(e.data.activityTime),n.push(e.data.scrollTime),gt(n,!1));break;case 25:n.push(_.gap),gt(n);break;case 35:n.push(lt.check),gt(n,!1);break;case 3:n.push(P.key),gt(n);break;case 2:n.push(st.sequence),n.push(st.attempts),n.push(st.status),gt(n,!1);break;case 24:k.key&&n.push(k.key),n.push(k.value),gt(n);break;case 34:var r=Object.keys(V);if(r.length>0){for(var o=0,a=r;o<a.length;o++){var i=a[o];n.push(i),n.push(V[i])}Z(),gt(n,!1)}break;case 0:var c=Object.keys(I);if(c.length>0){for(var s=0,l=c;s<l.length;s++){var d=l[s],f=parseInt(d,10);n.push(f),n.push(Math.round(I[d]))}I={},gt(n,!1)}break;case 1:var p=Object.keys(xt);if(p.length>0){for(var g=0,y=p;g<y.length;g++){var b=y[g];f=parseInt(b,10);n.push(f),n.push(xt[b])}Nt(),gt(n,!1)}break;case 36:var w=Object.keys(v);if(w.length>0){for(var S=0,E=w;S<E.length;S++){var M=E[S];f=parseInt(M,10);n.push(f),n.push([].concat.apply([],v[M]))}gt(n,!1)}break;case 40:m.forEach((function(t){n.push(t);var e=[];for(var r in v[t]){var o=parseInt(r,10);e.push(o),e.push(v[t][r])}n.push(e)})),gt(n,!1)}}function _t(){lt={check:0}}function Et(t){if(0===lt.check){var n=lt.check;n=on.sequence>=128?1:n,n=on.pageNum>=128?7:n,n=u()>72e5?2:n,(n=t>10485760?2:n)!==lt.check&&It(n)}}function It(t){lt.check=t,5!==t&&(Jt(),ne())}function Mt(){0!==lt.check&&St(35)}function Ot(){lt=null}var Tt=null,xt=null,jt=!1;function zt(){Tt={},xt={},jt=!1}function Ct(){Tt={},xt={},jt=!1}function At(t,n){if(n&&(n="".concat(n),t in Tt||(Tt[t]=[]),Tt[t].indexOf(n)<0)){if(Tt[t].length>128)return void(jt||(jt=!0,It(5)));Tt[t].push(n),t in xt||(xt[t]=[]),xt[t].push(n)}}function qt(){St(1)}function Nt(){xt={},jt=!1}function Dt(t){At(36,t.toString())}var Pt=null,Rt=[],Ut=0,Ht=null;function Lt(){var t,n,e;Ht=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(),c=window.location.ancestorOrigins?Array.from(window.location.ancestorOrigins).toString():"",u=document&&document.title?document.title:"";Ut=r.indexOf("Electron")>0?1:0;var s,l=function(){var t={session:Kt(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},n=tn("_clsk",!a.includeSubdomains);if(n){var e=n.split("|");e.length>=5&&t.ts-Qt(e[1])<18e5&&(t.session=e[0],t.count=Qt(e[2])+1,t.upgrade=Qt(e[3]),t.upload=e.length>=6?"".concat("https://").concat(e[5],"/").concat(e[4]):"".concat("https://").concat(e[4]))}return t}(),d=$t(),f=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);Pt={projectId:f,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,At(0,r),At(3,u),At(1,function(t,n){if(void 0===n&&(n=!1),n)return"".concat("https://").concat("Electron");var e=a.drop;if(e&&e.length>0&&t&&t.indexOf("?")>0){var r=t.split("?");return r[0]+"?"+r[1].split("&").map((function(t){return e.some((function(n){return 0===t.indexOf("".concat(n,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}return t}(location.href,!!Ut)),At(2,document.referrer),At(15,function(){var t=Kt();if(a.track&&Ft(window,"sessionStorage")){var n=sessionStorage.getItem("_cltk");t=n||t,sessionStorage.setItem("_cltk",t)}return t}()),At(16,document.documentElement.lang),At(17,document.dir),At(26,"".concat(window.devicePixelRatio)),At(28,d.dob.toString()),At(29,d.version.toString()),At(33,c),At(34,o),At(35,i),T(0,l.ts),T(1,0),T(35,Ut),navigator&&(At(9,navigator.language),T(33,navigator.hardwareConcurrency),T(32,navigator.maxTouchPoints),T(34,Math.round(navigator.deviceMemory)),(s=navigator.userAgentData)&&s.getHighEntropyValues?s.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var n;At(22,t.platform),At(23,t.platformVersion),null===(n=t.brands)||void 0===n||n.forEach((function(t){At(24,t.name+"~"+t.version)})),At(25,t.model),T(27,t.mobile?1:0)})):At(22,navigator.platform)),screen&&(T(14,Math.round(screen.width)),T(15,Math.round(screen.height)),T(16,Math.round(screen.colorDepth)));for(var p=0,h=a.cookies;p<h.length;p++){var v=h[p],g=tn(v);g&&B(v,g)}!function(t){Dt(t?1:0)}(a.track),Yt(d)}function Vt(){Ht=null,Pt=null,Rt.forEach((function(t){t.called=!1}))}function Bt(t,n,e){void 0===n&&(n=!0),void 0===e&&(e=!1);var r=a.lean?0:1,o=!1;Pt&&(r||!1===n)&&(t(Pt,!a.lean),o=!0),!e&&o||Rt.push({callback:t,wait:n,recall:e,called:o})}function Xt(){return Pt?[Pt.userId,Pt.sessionId,Pt.pageNum].join("."):""}function Wt(t){if(void 0===t&&(t=!0),!t)return a.track=!1,en("_clsk","",-Number.MAX_VALUE),en("_clck","",-Number.MAX_VALUE),ne(),void window.setTimeout(te,250);An()&&(a.track=!0,Yt($t(),1),Gt(),Dt(2))}function Jt(){en("_clsk","",0)}function Zt(){!function(t){if(Rt.length>0)for(var n=0;n<Rt.length;n++){var e=Rt[n];!e.callback||e.called||e.wait&&!t||(e.callback(Pt,!a.lean),e.called=!0,e.recall||(Rt.splice(n,1),n--))}}(a.lean?0:1)}function Gt(){if(Pt){var t=Math.round(Date.now()),n=a.upload&&"string"==typeof a.upload?a.upload.replace("https://",""):"",e=a.lean?0:1;en("_clsk",[Pt.sessionId,t,Pt.pageNum,e,n].join("|"),1)}}function Ft(t,n){try{return!!t[n]}catch(t){return!1}}function Yt(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)&&en("_clck",[Pt.userId,2,e.toString(36),n,r].join("|"),365)}function Kt(){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 Qt(t,n){return void 0===n&&(n=10),parseInt(t,n)}function $t(){var t={id:Kt(),version:0,expiry:null,consent:0,dob:0},n=tn("_clck",!a.includeSubdomains);if(n&&n.length>0){for(var e=n.split("|"),r=0,o=0,i=document.cookie.split(";");o<i.length;o++){r+="_clck"===i[o].split("=")[0].trim()?1:0}if(1===e.length||r>1){var c="".concat(";").concat("expires=").concat(new Date(0).toUTCString()).concat(";path=/");document.cookie="".concat("_clck","=").concat(c),document.cookie="".concat("_clsk","=").concat(c)}e.length>1&&(t.version=Qt(e[1])),e.length>2&&(t.expiry=Qt(e[2],36)),e.length>3&&1===Qt(e[3])&&(t.consent=1),e.length>4&&Qt(e[1])>1&&(t.dob=Qt(e[4])),a.track=a.track||1===t.consent,t.id=a.track?e[0]:t.id}return t}function tn(t,n){var e;if(void 0===n&&(n=!1),Ft(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=nn(a[1]),c=i[0],u=i[1];c;)c=(e=nn(u))[0],u=e[1];return n?u.endsWith("".concat("~","1"))?u.substring(0,u.length-2):null:u}}}return null}function nn(t){try{var n=decodeURIComponent(t);return[n!=t,n]}catch(t){}return[!1,t]}function en(t,n,e){if((a.track||""==n)&&(navigator&&navigator.cookieEnabled||Ft(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(n),o=new Date;o.setDate(o.getDate()+e);var i=o?"expires="+o.toUTCString():"",c="".concat(t,"=").concat(r).concat(";").concat(i).concat(";path=/");try{if(null===Ht){for(var u=location.hostname?location.hostname.split("."):[],s=u.length-1;s>=0;s--)if(Ht=".".concat(u[s]).concat(Ht||""),s<u.length-1&&(document.cookie="".concat(c).concat(";").concat("domain=").concat(Ht),tn(t)===n))return;Ht=""}}catch(t){Ht=""}document.cookie=Ht?"".concat(c).concat(";").concat("domain=").concat(Ht):c}}var rn,on=null;function an(){var t=Pt;on={version:s,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0}}function cn(){on=null}function un(t){return on.start=on.start+on.duration,on.duration=u()-on.start,on.sequence++,on.upload=t&&"sendBeacon"in navigator?1:0,on.end=t?1:0,[on.version,on.sequence,on.start,on.duration,on.projectId,on.userId,on.sessionId,on.pageNum,on.upload,on.end]}function sn(){rn=[]}function ln(t){if(rn&&-1===rn.indexOf(t.message)){var n=a.report;if(n&&n.length>0){var e={v:on.version,p:on.projectId,u:on.userId,s:on.sessionId,n:on.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)),rn.push(t.message)}}return t}function dn(t){return function(){var n=performance.now();try{t.apply(this,arguments)}catch(t){throw ln(t)}var e=performance.now()-n;O(4,e),e>a.longTask&&(M(7),T(6,e))}}var fn=[];function pn(t,n,e,r){void 0===r&&(r=!1),e=dn(e);try{t[i("addEventListener")](n,e,r),fn.push({event:n,target:t,listener:e,capture:r})}catch(t){}}function hn(){for(var t=0,n=fn;t<n.length;t++){var e=n[t];try{e.target[i("removeEventListener")](e.event,e.listener,e.capture)}catch(t){}}fn=[]}var vn=null,gn=null,mn=null,yn=0;function bn(){return!(yn++>20)}function wn(){yn=0,mn!==Sn()&&(ne(),window.setTimeout(kn,250))}function kn(){te(),T(29,1)}function Sn(){return location.href?location.href.replace(location.hash,""):location.href}var _n=[],En=null,In=null,Mn=null;function On(){In&&(Mn(),In=null,null===En&&xn())}function Tn(){_n=[],En=null,In=null}function xn(){var t=_n.shift();t&&(En=t,t.task().then((function(){t.id===Xt()&&(t.resolve(),En=null,xn())})).catch((function(n){t.id===Xt()&&(n&&(n.name,n.message,n.stack),En=null,xn())})))}var jn=!1;function zn(){jn=!0,c=performance.now()+performance.timeOrigin,Tn(),hn(),sn(),mn=Sn(),yn=0,pn(window,"popstate",wn),null===vn&&(vn=history.pushState,history.pushState=function(){vn.apply(this,arguments),An()&&bn()&&wn()}),null===gn&&(gn=history.replaceState,history.replaceState=function(){gn.apply(this,arguments),An()&&bn()&&wn()})}function Cn(){mn=null,yn=0,sn(),hn(),Tn(),c=0,jn=!1}function An(){return jn}function qn(){te(),S("clarity","restart")}var Nn=null;function Dn(){Nn=null}function Pn(t){Nn={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){H(this,void 0,void 0,(function(){var n,e;return L(this,(function(r){return n=u(),e=[n,t],29===t&&(e.push(Nn.fetchStart),e.push(Nn.connectStart),e.push(Nn.connectEnd),e.push(Nn.requestStart),e.push(Nn.responseStart),e.push(Nn.responseEnd),e.push(Nn.domInteractive),e.push(Nn.domComplete),e.push(Nn.loadEventStart),e.push(Nn.loadEventEnd),e.push(Nn.redirectCount),e.push(Nn.size),e.push(Nn.type),e.push(Nn.protocol),e.push(Nn.encodedSize),e.push(Nn.decodedSize),Dn(),gt(e)),[2]}))}))}(29)}var Rn,Un=0,Hn=1/0,Ln=0,Vn=0,Bn=[],Xn=new Map,Wn=function(){return Un||0},Jn=function(){if(!Bn.length)return-1;var t=Math.min(Bn.length-1,Math.floor((Wn()-Vn)/50));return Bn[t].latency},Zn=function(){Vn=Wn(),Bn.length=0,Xn.clear()},Gn=function(t){if(t.interactionId&&!(t.duration<40)){!function(t){"interactionCount"in performance?Un=performance.interactionCount:t.interactionId&&(Hn=Math.min(Hn,t.interactionId),Ln=Math.max(Ln,t.interactionId),Un=Ln?(Ln-Hn)/7+1:0)}(t);var n=Bn[Bn.length-1],e=Xn.get(t.interactionId);if(e||Bn.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};Xn.set(r.id,r),Bn.push(r)}Bn.sort((function(t,n){return n.latency-t.latency})),Bn.length>10&&Bn.splice(10).forEach((function(t){return Xn.delete(t.id)}))}}},Fn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint","event"];function Yn(){try{Rn&&Rn.disconnect(),Rn=new PerformanceObserver(dn(Kn));for(var t=0,n=Fn;t<n.length;t++){var e=n[t];PerformanceObserver.supportedEntryTypes.indexOf(e)>=0&&("layout-shift"===e&&O(9,0),Rn.observe({type:e,buffered:!0}))}}catch(t){}}function Kn(t){!function(t){for(var n=(!("visibilityState"in document)||"visible"===document.visibilityState),e=0;e<t.length;e++){var r=t[e];switch(r.entryType){case"navigation":Pn(r);break;case"resource":var o=r.name;At(4,Qn(o)),o!==a.upload&&o!==a.fallback||T(28,r.duration);break;case"longtask":M(7);break;case"first-input":n&&T(10,r.processingStart-r.startTime);break;case"event":n&&"PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&(Gn(r),At(37,Jn().toString()));break;case"layout-shift":n&&!r.hadRecentInput&&O(9,1e3*r.value);break;case"largest-contentful-paint":n&&T(8,r.startTime)}}}(t.getEntries())}function Qn(t){var n=document.createElement("a");return n.href=t,n.host}var $n=[w,w,w,Object.freeze({__proto__:null,start:function(){Dn(),function(){navigator&&"connection"in navigator&&At(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?pn(window,"load",x.bind(this,Yn,0)):Yn())}()},stop:function(){Rn&&Rn.disconnect(),Rn=null,Zn(),Dn()}})];function te(t){void 0===t&&(t=null),function(){try{var t=navigator&&"globalPrivacyControl"in navigator&&1==navigator.globalPrivacyControl;return!1===jn&&"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||jn)return!1;for(var n in t)n in a&&(a[n]=t[n])}(t),zn(),et(),$n.forEach((function(t){return dn(t.start)()})),null===t&&ae())}function ne(){An()&&($n.slice().reverse().forEach((function(t){return dn(t.stop)()})),rt(),Cn(),void 0!==re&&(re[oe]=function(){(re[oe].q=re[oe].q||[]).push(arguments),"start"===arguments[0]&&re[oe].q.unshift(re[oe].q.pop())&&ae()}))}var ee=Object.freeze({__proto__:null,consent:Wt,event:S,hashText:y,identify:X,metadata:Bt,pause:function(){An()&&(S("clarity","pause"),null===In&&(In=new Promise((function(t){Mn=t}))))},resume:function(){An()&&(On(),S("clarity","resume"))},set:B,signal:function(t){$=t},start:te,stop:ne,upgrade:R,version:s}),re=window,oe="clarity";function ae(){if(void 0!==re){if(re[oe]&&re[oe].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=re[oe]&&re[oe].q||[];for(re[oe]=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return ee[t].apply(ee,n)},re[oe].v=s;t.length>0;)re[oe].apply(re,t.shift())}}ae()}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-js",
3
- "version": "0.7.53",
3
+ "version": "0.7.57",
4
4
  "description": "An analytics library that uses web page interactions to generate aggregated insights",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@ let config: Config = {
23
23
  throttleDom: true,
24
24
  conversions: false,
25
25
  longTask: 30,
26
+ includeSubdomains: true,
26
27
  };
27
28
 
28
29
  export default config;
@@ -1,2 +1,2 @@
1
- let version = "0.7.53";
1
+ let version = "0.7.57";
2
2
  export default version;
@@ -4,15 +4,18 @@ import encode from "./encode";
4
4
 
5
5
  export let data: DimensionData = null;
6
6
  export let updates: DimensionData = null;
7
+ let limited = false;
7
8
 
8
9
  export function start(): void {
9
10
  data = {};
10
11
  updates = {};
12
+ limited = false;
11
13
  }
12
14
 
13
15
  export function stop(): void {
14
16
  data = {};
15
17
  updates = {};
18
+ limited = false;
16
19
  }
17
20
 
18
21
  export function log(dimension: Dimension, value: string): void {
@@ -22,13 +25,20 @@ export function log(dimension: Dimension, value: string): void {
22
25
  value = `${value}`;
23
26
  if (!(dimension in data)) { data[dimension] = []; }
24
27
  if (data[dimension].indexOf(value) < 0) {
28
+ // Limit check to ensure we have a cap on number of dimensions we can collect
29
+ if (data[dimension].length > Setting.CollectionLimit) {
30
+ if (!limited) {
31
+ limited = true;
32
+ limit.trigger(Check.Collection);
33
+ }
34
+ return;
35
+ }
36
+
25
37
  data[dimension].push(value);
26
38
  // If this is a new value, track it as part of updates object
27
39
  // This allows us to only send back new values in subsequent payloads
28
40
  if (!(dimension in updates)) { updates[dimension] = []; }
29
41
  updates[dimension].push(value);
30
- // Limit check to ensure we have a cap on number of dimensions we can collect
31
- if (data[dimension].length > Setting.CollectionLimit) { limit.trigger(Check.Collection); }
32
42
  }
33
43
  }
34
44
  }
@@ -39,4 +49,5 @@ export function compute(): void {
39
49
 
40
50
  export function reset(): void {
41
51
  updates = {};
52
+ limited = false;
42
53
  }
package/src/data/limit.ts CHANGED
@@ -26,8 +26,11 @@ export function check(bytes: number): void {
26
26
 
27
27
  export function trigger(reason: Check): void {
28
28
  data.check = reason;
29
- metadata.clear();
30
- clarity.stop();
29
+ // limit the dimensions we collect, but we don't need to stop Clarity entirely if we hit the limit
30
+ if (reason !== Check.Collection) {
31
+ metadata.clear();
32
+ clarity.stop();
33
+ }
31
34
  }
32
35
 
33
36
  export function compute(): void {
@@ -213,7 +213,7 @@ export function shortid(): string {
213
213
 
214
214
  function session(): Session {
215
215
  let output: Session = { session: shortid(), ts: Math.round(Date.now()), count: 1, upgrade: null, upload: Constant.Empty };
216
- let value = getCookie(Constant.SessionKey);
216
+ let value = getCookie(Constant.SessionKey, !config.includeSubdomains);
217
217
  if (value) {
218
218
  let parts = value.split(Constant.Pipe);
219
219
  // Making it backward & forward compatible by using greater than comparison (v0.6.21)
@@ -234,7 +234,7 @@ function num(string: string, base: number = 10): number {
234
234
 
235
235
  function user(): User {
236
236
  let output: User = { id: shortid(), version: 0, expiry: null, consent: BooleanFlag.False, dob: 0 };
237
- let cookie = getCookie(Constant.CookieKey);
237
+ let cookie = getCookie(Constant.CookieKey, !config.includeSubdomains);
238
238
  if (cookie && cookie.length > 0) {
239
239
  // Splitting and looking up first part for forward compatibility, in case we wish to store additional information in a cookie
240
240
  let parts = cookie.split(Constant.Pipe);
@@ -266,7 +266,7 @@ function user(): User {
266
266
  return output;
267
267
  }
268
268
 
269
- function getCookie(key: string): string {
269
+ function getCookie(key: string, limit = false): string {
270
270
  if (supported(document, Constant.Cookie)) {
271
271
  let cookies: string[] = document.cookie.split(Constant.Semicolon);
272
272
  if (cookies) {
@@ -285,6 +285,13 @@ function getCookie(key: string): string {
285
285
  [isEncoded, decodedValue] = decodeCookieValue(decodedValue);
286
286
  }
287
287
 
288
+ // If we are limiting cookies, check if the cookie value is limited
289
+ if (limit) {
290
+ return decodedValue.endsWith(`${Constant.Tilde}1`)
291
+ ? decodedValue.substring(0, decodedValue.length - 2)
292
+ : null;
293
+ }
294
+
288
295
  return decodedValue;
289
296
  }
290
297
  }
@@ -1,9 +1,12 @@
1
1
  import { Event } from "@clarity-types/data";
2
- import { ResizeData } from "@clarity-types/interaction";
2
+ import { ResizeData, Setting } from "@clarity-types/interaction";
3
+ import { clearTimeout, setTimeout } from "@src/core/timeout";
3
4
  import { bind } from "@src/core/event";
4
5
  import encode from "./encode";
6
+ import { schedule } from "@src/core/task";
5
7
 
6
8
  export let data: ResizeData;
9
+ let timeout: number = null;
7
10
 
8
11
  export function start(): void {
9
12
  bind(window, "resize", recompute);
@@ -18,11 +21,17 @@ function recompute(): void {
18
21
  width: de && "clientWidth" in de ? Math.min(de.clientWidth, window.innerWidth) : window.innerWidth,
19
22
  height: de && "clientHeight" in de ? Math.min(de.clientHeight, window.innerHeight) : window.innerHeight,
20
23
  };
21
- encode(Event.Resize);
24
+ clearTimeout(timeout);
25
+ timeout = setTimeout(process, Setting.LookAhead, Event.Resize);
26
+ }
27
+
28
+ function process(event: Event): void {
29
+ schedule(encode.bind(this, event));
22
30
  }
23
31
 
24
32
  export function reset(): void {
25
33
  data = null;
34
+ clearTimeout(timeout);
26
35
  }
27
36
 
28
37
  export function stop(): void {
@@ -10,6 +10,7 @@ export let state: AnimationState[] = [];
10
10
  let elementAnimate: (keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions) => Animation = null;
11
11
  let animationPlay: () => void = null;
12
12
  let animationPause: () => void = null;
13
+ let animationCommitStyles: () => void = null;
13
14
  let animationCancel: () => void = null;
14
15
  let animationFinish: () => void = null;
15
16
  const animationId = 'clarityAnimationId';
@@ -19,13 +20,16 @@ const maxOperations = 20;
19
20
  export function start(): void {
20
21
  if (
21
22
  window["Animation"] &&
23
+ window["Animation"].prototype &&
22
24
  window["KeyframeEffect"] &&
25
+ window["KeyframeEffect"].prototype &&
23
26
  window["KeyframeEffect"].prototype.getKeyframes &&
24
27
  window["KeyframeEffect"].prototype.getTiming
25
28
  ) {
26
29
  reset();
27
30
  overrideAnimationHelper(animationPlay, "play");
28
31
  overrideAnimationHelper(animationPause, "pause");
32
+ overrideAnimationHelper(animationCommitStyles, "commitStyles");
29
33
  overrideAnimationHelper(animationCancel, "cancel");
30
34
  overrideAnimationHelper(animationFinish, "finish");
31
35
  if (elementAnimate === null) {
@@ -116,6 +120,9 @@ function trackAnimationOperation(animation: Animation, name: string) {
116
120
  case "finish":
117
121
  operation = AnimationOperation.Finish;
118
122
  break;
123
+ case "commitStyles":
124
+ operation = AnimationOperation.CommitStyles;
125
+ break;
119
126
  }
120
127
  if (operation) {
121
128
  track(time(), animation[animationId], operation);
@@ -123,4 +130,4 @@ function trackAnimationOperation(animation: Animation, name: string) {
123
130
  }
124
131
  }
125
132
  }
126
- }
133
+ }
package/src/layout/dom.ts CHANGED
@@ -2,7 +2,9 @@ import { Privacy } from "@clarity-types/core";
2
2
  import { Code, Setting, Severity } from "@clarity-types/data";
3
3
  import { Constant, Mask, NodeInfo, NodeMeta, NodeValue, Selector, SelectorInput, Source } from "@clarity-types/layout";
4
4
  import config from "@src/core/config";
5
+ import { bind } from "@src/core/event";
5
6
  import hash from "@src/core/hash";
7
+ import { shortid } from "@src/data/metadata";
6
8
  import * as internal from "@src/diagnostic/internal";
7
9
  import * as region from "@src/layout/region";
8
10
  import * as selector from "@src/layout/selector";
@@ -120,7 +122,7 @@ export function add(node: Node, parent: Node, data: NodeInfo, source: Source): v
120
122
 
121
123
  privacy(node, values[id], parentValue);
122
124
  updateSelector(values[id]);
123
- size(values[id]);
125
+ updateImageSize(values[id]);
124
126
  track(id, source);
125
127
  }
126
128
 
@@ -250,6 +252,12 @@ function privacy(node: Node, value: NodeValue, parent: NodeValue): void {
250
252
  // In a mode where we mask sensitive information by default, look through class names to aggressively mask content
251
253
  metadata.privacy = inspect(attributes[Constant.Class], maskText, metadata);
252
254
  break;
255
+ case tag === Constant.ImageTag:
256
+ // Mask images with blob src as it is not publicly available anyway.
257
+ if(attributes.src?.startsWith('blob:')){
258
+ metadata.privacy = Privacy.TextImage;
259
+ }
260
+ break;
253
261
  }
254
262
  }
255
263
 
@@ -361,10 +369,21 @@ function removeNodeFromNodesMap(id: number) {
361
369
  }
362
370
  }
363
371
 
364
- function size(value: NodeValue): void {
372
+ function updateImageSize(value: NodeValue): void {
365
373
  // If this element is a image node, and is masked, then track box model for the current element
366
- if (value.data.tag === Constant.ImageTag && value.metadata.privacy === Privacy.TextImage) { value.metadata.size = []; }
374
+ if (value.data.tag === Constant.ImageTag && value.metadata.privacy === Privacy.TextImage) {
375
+ let img = getNode(value.id) as HTMLImageElement;
376
+ // We will not capture the natural image dimensions until it loads.
377
+ if(img && (!img.complete || img.naturalWidth === 0)){
378
+ // This will trigger mutation to update the original width and height after image loads.
379
+ bind(img, 'load', () => {
380
+ img.setAttribute('data-clarity-loaded', `${shortid()}`);
381
+ })
382
+ }
383
+ value.metadata.size = [];
384
+ }
367
385
  }
386
+
368
387
  function getPreviousId(node: Node): number {
369
388
  let id = null;
370
389
 
@@ -1,6 +1,6 @@
1
1
  import { Priority, Task, Timer } from "@clarity-types/core";
2
2
  import { Code, Event, Metric, Severity } from "@clarity-types/data";
3
- import { Constant, MutationHistory, MutationQueue, Setting, Source } from "@clarity-types/layout";
3
+ import { Constant, MutationHistory, MutationRecordWithTime, MutationQueue, Setting, Source } from "@clarity-types/layout";
4
4
  import api from "@src/core/api";
5
5
  import * as core from "@src/core";
6
6
  import { bind } from "@src/core/event";
@@ -21,6 +21,7 @@ import config from "@src/core/config";
21
21
 
22
22
  let observers: MutationObserver[] = [];
23
23
  let mutations: MutationQueue[] = [];
24
+ let throttledMutations: { [key: number]: MutationRecordWithTime } = {};
24
25
  let insertRule: (rule: string, index?: number) => number = null;
25
26
  let deleteRule: (index?: number) => void = null;
26
27
  let attachShadow: (init: ShadowRootInit) => ShadowRoot = null;
@@ -28,6 +29,7 @@ let mediaInsertRule: (rule: string, index?: number) => number = null;
28
29
  let mediaDeleteRule: (index?: number) => void = null;
29
30
  let queue: Node[] = [];
30
31
  let timeout: number = null;
32
+ let throttleDelay: number = null;
31
33
  let activePeriod = null;
32
34
  let history: MutationHistory = {};
33
35
 
@@ -117,6 +119,7 @@ export function stop(): void {
117
119
  observers = [];
118
120
  history = {};
119
121
  mutations = [];
122
+ throttledMutations = [];
120
123
  queue = [];
121
124
  activePeriod = 0;
122
125
  timeout = null;
@@ -137,6 +140,30 @@ function handle(m: MutationRecord[]): void {
137
140
  });
138
141
  }
139
142
 
143
+ async function processMutation(timer: Timer, mutation: MutationRecord, instance: number, timestamp: number): Promise<void> {
144
+ let state = task.state(timer);
145
+ if (state === Task.Wait) { state = await task.suspend(timer); }
146
+ if (state === Task.Stop) { return; }
147
+ let target = mutation.target;
148
+ let type = config.throttleDom ? track(mutation, timer, instance, timestamp) : mutation.type;
149
+ if (type && target && target.ownerDocument) { dom.parse(target.ownerDocument); }
150
+ if (type && target && target.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (target as ShadowRoot).host) { dom.parse(target as ShadowRoot); }
151
+ switch (type) {
152
+ case Constant.Attributes:
153
+ processNode(target, Source.Attributes, timestamp);
154
+ break;
155
+ case Constant.CharacterData:
156
+ processNode(target, Source.CharacterData, timestamp);
157
+ break;
158
+ case Constant.ChildList:
159
+ processNodeList(mutation.addedNodes, Source.ChildListAdd, timer, timestamp);
160
+ processNodeList(mutation.removedNodes, Source.ChildListRemove, timer, timestamp);
161
+ break;
162
+ case Constant.Throttle:
163
+ default:
164
+ break;
165
+ }
166
+ }
140
167
  async function process(): Promise<void> {
141
168
  let timer: Timer = { id: id(), cost: Metric.LayoutCost };
142
169
  task.start(timer);
@@ -144,34 +171,28 @@ async function process(): Promise<void> {
144
171
  let record = mutations.shift();
145
172
  let instance = time();
146
173
  for (let mutation of record.mutations) {
147
- let state = task.state(timer);
148
- if (state === Task.Wait) { state = await task.suspend(timer); }
149
- if (state === Task.Stop) { break; }
150
- let target = mutation.target;
151
- let type = config.throttleDom ? track(mutation, timer, instance, record.time) : mutation.type;
152
- if (type && target && target.ownerDocument) { dom.parse(target.ownerDocument); }
153
- if (type && target && target.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (target as ShadowRoot).host) { dom.parse(target as ShadowRoot); }
154
- switch (type) {
155
- case Constant.Attributes:
156
- processNode(target, Source.Attributes, record.time);
157
- break;
158
- case Constant.CharacterData:
159
- processNode(target, Source.CharacterData, record.time);
160
- break;
161
- case Constant.ChildList:
162
- processNodeList(mutation.addedNodes, Source.ChildListAdd, timer, record.time);
163
- processNodeList(mutation.removedNodes, Source.ChildListRemove, timer, record.time);
164
- break;
165
- case Constant.Suspend:
166
- let value = dom.get(target);
167
- if (value) { value.metadata.suspend = true; }
168
- break;
169
- default:
170
- break;
171
- }
174
+ processMutation(timer, mutation, instance, record.time)
172
175
  }
173
176
  await encode(Event.Mutation, timer, record.time);
174
177
  }
178
+
179
+ let processedMutations = false;
180
+ for (var key of Object.keys(throttledMutations)) {
181
+ let throttledMutationToProcess: MutationRecordWithTime = throttledMutations[key];
182
+ delete throttledMutations[key];
183
+ processMutation(timer, throttledMutationToProcess.mutation, time(), throttledMutationToProcess.timestamp);
184
+ processedMutations = true;
185
+ }
186
+
187
+ if (Object.keys(throttledMutations).length > 0) {
188
+ processThrottledMutations();
189
+ }
190
+
191
+ // ensure we encode the previously throttled mutations once we have finished them
192
+ if (Object.keys(throttledMutations).length === 0 && processedMutations) {
193
+ await encode(Event.Mutation, timer, time());
194
+ }
195
+
175
196
  task.stop(timer);
176
197
  }
177
198
 
@@ -197,13 +218,16 @@ function track(m: MutationRecord, timer: Timer, instance: number, timestamp: num
197
218
  h[0] = inactive ? (h[1] === instance ? h[0] : h[0] + 1) : 1;
198
219
  h[1] = instance;
199
220
  // Return updated mutation type based on if we have already hit the threshold or not
200
- if (h[0] === Setting.MutationSuspendThreshold) {
221
+ if (h[0] >= Setting.MutationSuspendThreshold) {
201
222
  // Store a reference to removedNodes so we can process them later
202
223
  // when we resume mutations again on user interactions
203
224
  h[2] = m.removedNodes;
204
- return Constant.Suspend;
205
- } else if (h[0] > Setting.MutationSuspendThreshold) {
206
- return Constant.Empty;
225
+ if (instance > timestamp + Setting.MutationActivePeriod) {
226
+ return m.type;
227
+ }
228
+ // we only store the most recent mutation for a given key if it is being throttled
229
+ throttledMutations[key] = {mutation: m, timestamp};
230
+ return Constant.Throttle;
207
231
  }
208
232
  }
209
233
  return m.type;
@@ -229,6 +253,13 @@ async function processNodeList(list: NodeList, source: Source, timer: Timer, tim
229
253
  }
230
254
  }
231
255
 
256
+ function processThrottledMutations(): void {
257
+ if (throttleDelay) {
258
+ clearTimeout(throttleDelay);
259
+ }
260
+ throttleDelay = setTimeout(() => { task.schedule(process, Priority.High) }, Setting.LookAhead);
261
+ }
262
+
232
263
  export function schedule(node: Node): Node {
233
264
  // Only schedule manual trigger for this node if it's not already in the queue
234
265
  if (queue.indexOf(node) < 0) { queue.push(node); }
@@ -35,9 +35,6 @@ export function ld(json: any): void {
35
35
  metric.max(Metric.RatingCount, num(json[JsonLD.RatingCount]));
36
36
  metric.max(Metric.ReviewCount, num(json[JsonLD.ReviewCount]));
37
37
  break;
38
- case JsonLD.Author:
39
- dimension.log(Dimension.AuthorName, json[JsonLD.Name]);
40
- break;
41
38
  case JsonLD.Offer:
42
39
  dimension.log(Dimension.ProductAvailability, json[JsonLD.Availability]);
43
40
  dimension.log(Dimension.ProductCondition, json[JsonLD.ItemCondition]);
package/types/core.d.ts CHANGED
@@ -137,6 +137,7 @@ export interface Config {
137
137
  throttleDom?: boolean;
138
138
  conversions?: boolean;
139
139
  longTask?: number;
140
+ includeSubdomains?: boolean;
140
141
  }
141
142
 
142
143
  export const enum Constant {
package/types/layout.d.ts CHANGED
@@ -7,7 +7,8 @@ export const enum AnimationOperation {
7
7
  Play = 1,
8
8
  Pause = 2,
9
9
  Cancel = 3,
10
- Finish = 4
10
+ Finish = 4,
11
+ CommitStyles = 5
11
12
  }
12
13
 
13
14
  export const enum Source {
@@ -105,7 +106,7 @@ export const enum Constant {
105
106
  ChildList = "childList",
106
107
  Attributes = "attributes",
107
108
  CharacterData = "characterData",
108
- Suspend = "suspend",
109
+ Throttle = "throttle",
109
110
  LoadEvent = "load",
110
111
  Pixel = "px",
111
112
  BorderBox = "border-box",
@@ -217,6 +218,11 @@ export interface MutationQueue {
217
218
  mutations: MutationRecord[];
218
219
  }
219
220
 
221
+ export interface MutationRecordWithTime {
222
+ timestamp: number;
223
+ mutation: MutationRecord;
224
+ }
225
+
220
226
  export interface MutationHistory {
221
227
  [key: string]: [/* Count */ number, /* Instance */ number, /* Remove Nodes Buffer */ NodeList?];
222
228
  }