@sheeptrack/web 0.2.1 → 0.5.0
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.
- package/CHANGELOG.md +37 -0
- package/dist/consent.js +1 -1
- package/dist/esm/chunk-NGXLVBOU.js +1 -0
- package/dist/esm/consent.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/replay.js +22 -22
- package/dist/replay.js +20 -20
- package/dist/sheeptrack.js +2 -2
- package/dist/types/autocapture.d.ts +8 -2
- package/dist/types/consent.d.ts +2 -0
- package/dist/types/ctx.d.ts +3 -3
- package/dist/types/debug.d.ts +10 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/replay.d.ts +17 -0
- package/dist/types/util.d.ts +2 -2
- package/package.json +1 -1
package/dist/sheeptrack.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
2
|
-
`).slice(1,4).map(y=>y.replace(/[:\d]+\)?$/,"")).join("|"),p=se([i,a.replace(/\d+/g,"N"),l].join("|")).toString(16),f=t.drop().map(y=>y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),u=y=>y.replace(/https?:\/\/[^\s)'"]+/gi,j=>{let[,X,V=""]=j.match(/^(.*?)(:\d+:\d+)?$/);return x(X,t.drop())+V}),k=y=>f?y.replace(new RegExp(`([?&;#]|%3[bf]|%26|%23)(${f})(=|%3d)(?:%(?!26|23|3b)[0-9a-f]{2}|(?!:\\d+:\\d+(?:$|[\\s)]))[^&\\s)'"#%])*`,"gi"),"$1$2$3[redacted]"):y,b=y=>k(u(k(y)));t.onError?.({fingerprint:p,type:i}),e("$error",{message:W(b(a),500),stack:W(b(s),4e3),type:i,fingerprint:p,release:t.release,filename:c&&x(c,t.drop())})};addEventListener("error",i=>o(i.error?.name||"Error",i.message,i.error?.stack,i.filename)),addEventListener("unhandledrejection",i=>{let a=i.reason;o(a?.name||"UnhandledRejection",a?.message??String(a),a?.stack)})}if(t.network){let r=0,o=(s,c,l,p)=>{if(r>=200||c.startsWith(t.host))return;r++;let f=x(c,t.drop()).replace(yt,"/:id");e("$network",{method:s,url:f,status:l,duration_ms:Math.round(performance.now()-p)})},i=window.fetch;i&&(window.fetch=function(s,c){let l=performance.now(),p=(c?.method||(s instanceof Request?s.method:"GET")).toUpperCase(),f=typeof s=="string"?s:s instanceof URL?s.href:s.url;return i.call(this,s,c).then(u=>(o(p,f,u.status,l),u),u=>{throw o(p,f,0,l),u})});let a=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(s,c,...l){let p=performance.now();return this.addEventListener("loadend",()=>o(s.toUpperCase(),String(c),this.status,p)),a.call(this,s,c,...l)}}if(t.console){let r=0;for(let o of t.console){let i=console[o];console[o]=(...a)=>{i.apply(console,a),r++<100&&e("$console",{level:o,message:W(a.map(s=>typeof s=="string"?s:s instanceof Error?s.message:wt(s)).join(" "),500)})}}}t.vitals&&typeof PerformanceObserver<"u"&&bt(e,n)}var wt=e=>{try{return JSON.stringify(e)}catch{return String(e)}};function bt(e,t){let n,r=0,o=0,i=0,a=0,s=[],c=0,l=(u,k,b={})=>{try{new PerformanceObserver(y=>y.getEntries().forEach(k)).observe({type:u,buffered:!0,...b})}catch{}};l("largest-contentful-paint",u=>{n=u.startTime}),l("layout-shift",u=>{u.hadRecentInput||(o&&u.startTime-i<1e3&&u.startTime-a<5e3?o+=u.value:(o=u.value,a=u.startTime),i=u.startTime,r=Math.max(r,o))});let p=new Set;l("event",u=>{u.interactionId&&(p.has(u.interactionId)||(p.add(u.interactionId),c++),s=[...s,u.duration].sort((k,b)=>b-k).slice(0,10))},{durationThreshold:40});let f=()=>{let u={lcp:n&&Math.round(n),inp:s.length?s[Math.min(9,Math.floor(c/50))]:void 0,cls:r?+r.toFixed(4):void 0};(u.lcp!==void 0||u.inp!==void 0||u.cls!==void 0)&&e("$web_vitals",u),r=o=0,s=[],c=0,p.clear(),n=void 0};addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&f()),t(f)}function Oe(e){let t=[],n={},r=0,o=new Set,i=new Set;try{let l=e.load();l&&(t=JSON.parse(l))}catch{}async function a(l=!0){let p=await e.json(`/i/v1/flags/definitions?key=${encodeURIComponent(e.key)}${e.env?`&env=${e.env}`:""}`);if(p?.flags&&(t=p.flags,e.save(JSON.stringify(t))),l&&e.canPost()){let f=await e.json("/i/v1/flags",{api_key:e.key,distinct_id:e.id(),environment:e.env,properties:e.props()});f?.flags&&(n=f.flags)}o.forEach(f=>f())}function s(){r||typeof setInterval>"u"||(a(),r=setInterval(()=>document.visibilityState!=="hidden"&&a(!1),e.pollMs))}function c(l){s();let p=t.find(u=>u.key===l),f=p?Le(p,e.id(),e.props()):n[l];return f?(i.has(l)||(i.add(l),e.capture("$feature_flag_called",{flag:l,enabled:f.enabled,variant:f.variant})),f):{enabled:!1}}return{isEnabled:l=>c(l).enabled,getVariant:l=>c(l).variant,getPayload:l=>c(l).payload,reload:()=>a(),onChange(l){return s(),o.add(l),()=>{o.delete(l)}},reset(){i.clear(),r&&a()}}}var Ue=["necessary","analytics","replay","personalization","marketing"],De=30*6e4,je=2e3,St=15e5,kt=100,m,A="",$="",fe,G=!1,g=null,d=null,S="anon_"+L(),C=null,M={},q=null,w,h=[],U=[],K=Promise.resolve(),He,ie=0,ae=0,le=!1,he=!1,Be,ce,ze="",Fe={},ve=!1,v=null,ue=!1,z=!1,T=!1,de=!1,H,E,pe=[],ge=new Set,Te="null",Je,Xe=new Promise(e=>{Je=e}),N=e=>{try{return JSON.parse(localStorage.getItem(e)||"null")}catch{return null}},_=(e,t)=>{try{t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch{}},Y=(e,t)=>{I()==="full"&&_(e,t)},R=e=>!!e&&!!g&&Date.now()<e.t+(g.consent?.validity_days??180)*864e5&&(!g.consent||e.v===g.consent.version),D=e=>e==="necessary"||R(d)&&d.c[e]===!0,Ve=()=>g?.consent?.respect_gpc!==!1&&(navigator.globalPrivacyControl===!0||navigator.doNotTrack==="1"),Ct=/^(Europe\/|Asia\/(Nicosia|Famagusta)$|Atlantic\/(Canary|Madeira|Azores|Reykjavik)$|Africa\/Ceuta$|Indian\/(Reunion|Mayotte)$|America\/(Guadeloupe|Martinique|Cayenne|Marigot|St_Barthelemy)$)/,We=()=>{try{return Ct.test(Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{return!0}};function I(){if(R(d))return d.c.analytics?"full":"off";if(!g)return"wait";let e=g.consent;return!e?.enabled||e.exempt_analytics||e.regions==="eu"&&!We()?"mem":Ve()?"off":"wait"}function Ge(){let e=R(d)?d:null;return{id:e?.id,version:e?.v,categories:e?e.c:I()==="mem"?{analytics:!0}:{}}}var _t=e=>new Promise(t=>{let n=setTimeout(t,e);Be=()=>{clearTimeout(n),t()}});async function Z(e,t,n=1/0){for(let r=0;;r++){let o=null;try{o=await fetch(e,{credentials:"omit",...t})}catch{}if(o&&o.status!==429&&o.status<500||r+1>=n)return o;await _t(Math.max((Number(o?.headers.get("retry-after"))||0)*1e3,Math.min(3e5,1e3*2**r)*(.5+Math.random()/2)))}}var Ke=async(e,t,n,r)=>(await Z($+e,{method:"POST",body:await oe(t),keepalive:r},n))?.status??0,Et=async(e,t)=>{let n=await Z($+e,t?{method:"POST",body:JSON.stringify(t),headers:{"content-type":"text/plain"}}:{},1).catch(()=>null);return n?.ok?n.json().catch(()=>null):null},F=()=>[..._e,...m?.sensitiveParams??[],...g?.replay.mask.ignore_url_params??[]].map(e=>e.toLowerCase());function Ye(){let e=document.documentElement;return{url:x(location.href,F()),referrer:ze,lang:navigator.language,viewport_w:e.clientWidth,viewport_h:e.clientHeight,platform:"web",app_version:m.release,...Fe}}function B(){let e=Date.now();return(!w||e-w.t>De)&&(w={id:L(),t:e,u:Math.random(),v:Math.random(),n:0}),w.t=e,w.id}function P(e,t={},n={}){let r={id:L(),event:e,ts:new Date().toISOString(),distinct_id:C??S,session_id:B(),environment:fe,props:{...Ye(),...t},...n};C&&(r.identified=!0),Qe(r),$t(e)}function Qe(e){let t=I();if(t==="wait"||!g){U.push(e),U.length>kt&&U.shift();return}if(t==="off")return;let n=g.sampling;B(),!(w.u>=n.sessions||e.event!=="$identify"&&Math.random()>=n.events)&&(h.push(e)>je&&h.shift(),h.length>=m.batchSize?Ne():ie||(ie=setTimeout(()=>{ie=0,Ne()},m.batchInterval)),ae||(ae=setTimeout(()=>{ae=0,J()},1e3)))}function J(){if(I()!=="full")return;let e=h.slice(-je);for(;e.length>1&&JSON.stringify(e).length>St;)e=e.slice(e.length>>1);_("pt_q",e.length?e:null),_("pt_s",w)}var Ze=e=>JSON.stringify({api_key:A,sent_at:new Date().toISOString(),consent:Ge(),batch:e}),Q=()=>I()==="mem"||I()==="full";async function Ne(){if(!(le||!h.length||!Q())){le=!0;try{for(await K;h.length&&Q();){let e=h.slice(0,100);await Z($+"/i/v1/events",{method:"POST",body:await oe(Ze(e))});let t=new Set(e);h=h.filter(n=>!t.has(n)),J()}}finally{le=!1}}}function Ae(){for(J(),v?.beacon();h.length&&Q();){let e=h.slice(0,25);if(!navigator.sendBeacon?.($+"/i/v1/events",new Blob([Ze(e)],{type:"text/plain"})))break;let t=new Set(e);h=h.filter(n=>!t.has(n))}J()}function Rt(){let e=S;S=N("pt_id")||S,_("pt_id",S);let t=N("pt_s");t&&Date.now()-t.t<De&&(w=t);let n=N("pt_u");n&&D("personalization")&&(C=n.u,M=n.tr);let r=N("pt_q");Array.isArray(r)&&(h=[...r,...h]);for(let o of[...h,...U])o.distinct_id===e&&(o.distinct_id=S);he=!0}function et(){for(let e of["pt_id","pt_s","pt_q","pt_u","pt_cfg","pt_flags"])_(e,null);h=[],U=[],C=null,M={},w=void 0,he=!1,S="anon_"+L()}function xt(){let e=ke.get(),t=JSON.stringify(e);t!==Te&&(Te=t,ge.forEach(n=>{try{n(e)}catch{}}),dispatchEvent(new CustomEvent("pt:consent",{detail:e})))}function tt(){xt();let e=I();e==="full"&&!he&&Rt(),e!=="wait"&&(U.splice(0).forEach(t=>e!=="off"&&Qe(t)),rt(),be(),q&&D("personalization")&&(st(...q),q=null),J())}function ye(e,t){let n=R(d)?d.c:null,r={...e,necessary:!0},o=t==="withdraw"||!!n&&Ue.some(i=>n[i]&&!r[i]);d={id:d?.id||L(),v:g?.consent?.version??0,t:Date.now(),c:r,p:o?"withdraw":t},_("pt_consent",d),nt(d),r.analytics?r.personalization||(C=null,M={},q=null,_("pt_u",null)):et(),r.replay||(v?.stop(),v=null),tt(),E?.reset()}function nt(e){He=e;let t={api_key:A,consent_id:e.id,policy_version:e.v,choices:e.c,source:e.p};K=K.then(async()=>{let n=await Ke("/i/v1/consent",JSON.stringify(t),6,!0);n>199&&n<300&&(delete e.p,d===e&&_("pt_consent",e))})}function rt(){!g||!ve||document.querySelectorAll('script[type="text/plain"][data-pt-category]').forEach(e=>{if(!D(e.dataset.ptCategory))return;let t=document.createElement("script");for(let n of Array.from(e.attributes))n.name!=="type"&&n.name!=="data-pt-category"&&t.setAttribute(n.name,n.value);t.text=e.text,e.replaceWith(t)})}async function we(e){let t=g?.consent;if(!(!t||T)){T=!0,H?.(),H=void 0;try{(await import("./consent.js")).show({cfg:t,current:e&&d?d.c:null,onChoice:r=>ye(r,"banner"),onClose:()=>{T=!1,ot()}})}catch{T=!1}}}async function ot(){let e=g?.consent;if(!(!e?.enabled||!R(d)||T||H||de||typeof document>"u")){de=!0;try{if(document.readyState==="loading"&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0})),await new Promise(t=>setTimeout(t,1e3)),T||H||document.querySelector("[data-pt-consent-open]"))return;H=(await import("./consent.js")).manage(e,()=>{we(!0)})}catch{}finally{de=!1}}}function qe(){d?.p&&d!==He&&R(d)&&nt(d),tt();let e=g?.consent;e?.enabled&&!R(d)&&!Ve()&&(e.regions==="always"||We())?we(!1):ot()}function be(e=!1){let t=g?.replay;!ve||v||ue||z||!t?.enabled||!D("replay")||typeof document>"u"||(B(),!(w.u>=g.sampling.sessions||!(e||w.v<t.sample_rate))&&(ue=!0,import("./replay.js").then(n=>{if(v||!D("replay"))return;let r=(o,i)=>`/i/v1/replay/${o}/chunks?key=${encodeURIComponent(A)}&seq=${i}`;v=n.start({cfg:t,dropParams:F(),sessionId:B,distinctId:()=>C??S,consent:Ge,nextSeq:()=>(B(),w.n++),post:async(o,i,a)=>{await K;let s=await Ke(r(o,i),a,6);return s===403&&(v?.stop(),v=null,z=!0),s},beacon:(o,i,a)=>!!navigator.sendBeacon?.($+r(o,i),new Blob([a],{type:"text/plain"}))})}).catch(()=>{}).finally(()=>{ue=!1})))}function $t(e){let t=g?.replay.triggers;if(!t||v)return;let n=location.pathname+location.search,r=o=>new RegExp("^"+o.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(n);(e==="$error"&&t.on_error||t.events?.includes(e)||e==="$pageview"&&t.url_patterns?.some(r))&&be(!0)}function me(){let e=x(location.href,F());if(e===ce)return;ze=ce??x(document.referrer,F()),ce=e;let t=new URL(location.href).searchParams;for(let[n,r]of t)n.startsWith("utm_")&&(Fe[n]=r.slice(0,200));P("$pageview")}function Mt(){for(let e of["pushState","replaceState"]){let t=history[e];history[e]=function(...n){pe.forEach(o=>o());let r=t.apply(this,n);return me(),r}}addEventListener("popstate",()=>{pe.forEach(e=>e()),me()})}function Se(e,t){if(G||typeof window>"u")return;G=!0,A=e,m={batchInterval:5e3,batchSize:20,...t},$=m.host.replace(/\/$/,""),fe=m.environment,d=N("pt_consent");let n=d?.c.analytics?N("pt_cfg"):null;n&&n.consent?.version===d.v&&(g=n,qe()),E=Oe({key:A,env:fe,pollMs:m.flagsPollMs??3e4,capture:P,json:Et,id:()=>C??S,props:()=>({...Ye(),$platform:"web",...M}),load:()=>I()==="full"?localStorage.getItem("pt_flags"):null,save:i=>Y("pt_flags",JSON.parse(i)),canPost:()=>Q()}),(async()=>{let i=await Z(`${$}/i/v1/config?key=${encodeURIComponent(A)}`,{},5),a=i?.ok?await i.json().catch(()=>null):null;a&&(g=a,ve=!0,Y("pt_cfg",a),R(d)||(v?.stop(),v=null),qe(),Je())})();let r=i=>{pe.push(i)};m.autocapture!==!1&&xe(P,r),addEventListener("online",()=>Be?.()),document.addEventListener("click",i=>{i.target?.closest?.("[data-pt-consent-open]")&&(i.preventDefault(),ke.open())}),addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible"){z||v?.resume();return}Ae(),v?.pause()}),addEventListener("pagehide",Ae),m.pageviews!==!1&&(Mt(),me());let o=m.autocapture!==!1?Re(P,r,{frustration:m.frustration!==!1}):void 0;Pe(P,{errors:m.errors!==!1,network:m.network!==!1,vitals:m.vitals!==!1,console:m.console===void 0?["warn","error"]:m.console,drop:F,host:$,release:m.release,onError:o},r),document.addEventListener("DOMContentLoaded",rt)}function It(e,t){G&&P(e,t)}function st(e,t={}){if(!G)return;if(!D("personalization")){q=[e,t];return}let n=S;C=e,M={...M,...t},Y("pt_u",{u:C,tr:M}),P("$identify",{},{anonymous_id:n,traits:t}),E?.reset()}function Lt(){C=null,M={},q=null,w=void 0,S="anon_"+L(),_("pt_u",null),_("pt_s",null),Y("pt_id",S),E?.reset()}var it=e=>g?e():void Xe.then(e),Pt=e=>it(()=>ye(Object.fromEntries((e??Ue).map(t=>[t,!0])),"api")),Ot=()=>{et(),it(()=>ye({},"withdraw"))},ke={open:()=>Xe.then(()=>we(!0)),get:()=>R(d)?{...d.c}:null,onChange:e=>(ge.add(e),()=>{ge.delete(e)})},Tt={pause(){z=!0,v?.pause()},resume(){z=!1,v?v.resume():be()}},Nt={isEnabled:e=>E?.isEnabled(e)??!1,getVariant:e=>E?.getVariant(e),getPayload:e=>E?.getPayload(e),reload:()=>E?.reload(),onChange:e=>E?.onChange(e)??(()=>{})};var O=document.currentScript;globalThis.SheepTrack=Ce;O?.dataset.key&&Se(O.dataset.key,{host:O.dataset.host||new URL(O.src).origin,environment:O.dataset.env==="dev"||O.dataset.env==="prod"?O.dataset.env:void 0});})();
|
|
1
|
+
"use strict";(()=>{var pt=Object.create;var oe=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty;var se=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var yt=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},wt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mt(t))!vt.call(e,o)&&o!==n&&oe(e,o,{get:()=>t[o],enumerable:!(r=gt(t,o))||r.enumerable});return e};var ie=(e,t,n)=>(n=e!=null?pt(ht(e)):{},wt(t||!e||!e.__esModule?oe(n,"default",{value:e,enumerable:!0}):n,e));var Ee={};yt(Ee,{consent:()=>_e,flags:()=>Gt,identify:()=>dt,init:()=>Ce,optIn:()=>Vt,optOut:()=>Zt,replay:()=>Wt,reset:()=>Xt,track:()=>Jt});var $e=["token","access_token","id_token","refresh_token","password","pwd","secret","key","api_key","apikey","auth","authorization","code","session","sid","email","mail","signature","sig","otp"];function T(){let e=crypto.getRandomValues(new Uint8Array(16)),t=Date.now();for(let r=5;r>=0;r--)e[r]=t%256,t=Math.floor(t/256);e[6]=e[6]&15|112,e[8]=e[8]&63|128;let n=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}var I=(e,t)=>String(e??"").slice(0,t),bt=/^x-(amz|goog)-/i;function L(e,t){try{let n=new URL(e,location.href);n.username=n.password="";for(let r of[...n.searchParams.keys()])(t.includes(r.toLowerCase())||bt.test(r))&&n.searchParams.delete(r);return/^#\/[^?=&]*$/.test(n.hash)||(n.hash=""),n.href}catch{return""}}function Re(e){let t=[];for(let n=e,r=0;n&&n!==document.documentElement&&r<4;n=n.parentElement,r++){let o=n.tagName.toLowerCase();if(n.id&&/^[\w-]{1,40}$/.test(n.id)&&!/\d{3,}/.test(n.id)){t.unshift(`${o}#${n.id}`);break}let i=[...n.classList].find(l=>/^[a-zA-Z][\w-]{0,30}$/.test(l)&&!/\d{3,}/.test(l));i&&(o+=`.${i}`),t.unshift(o)}return t.join(" > ").slice(0,120)}async function ae(e){if(typeof e!="string")return e;if(typeof CompressionStream>"u")return new Blob([e],{type:"text/plain"});let t=await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"))).blob();return new Blob([t],{type:"text/plain"})}var St="a[href],button,summary,[role=button],[data-pt-event]",kt=1e3,Ct=500;function Me(e,t,n){let r,o=0,i=[],l=!1;return t(()=>{l=!0}),addEventListener("pagehide",()=>{l=!0}),addEventListener("click",a=>{let u=a.target;if(!a.isTrusted||!(u instanceof Element)||o++>=Ct||u.closest("[data-pt-block]"))return;let s=_t(u),d=Re(u),f=Math.round(a.clientX+(s?0:scrollX)),c=Math.round(a.clientY+(s?0:scrollY)),p=document.documentElement,m=u.closest("[data-pt-event]")?.getAttribute("data-pt-event"),y={selector:d,x:f,y:c,doc_w:p.scrollWidth,doc_h:p.scrollHeight};if(e("$autocapture",{...y,tag:u.tagName.toLowerCase(),pt_event:m||void 0}),m&&e(m.slice(0,100),{selector:d}),!n.frustration)return;let S=a.timeStamp||Date.now();r=y,setTimeout(()=>{r===y&&(r=void 0)},kt),i=i.filter(re=>S-re.t<1e3&&Math.hypot(re.x-f,re.y-c)<30),i.push({t:S,x:f,y:c}),i.length>=3&&(e("$rageclick",{...y,count:i.length}),i=[]);let C=u.closest(St);if(!C||C.closest("a[target=_blank],a[download]")||/^(mailto|tel):/.test(C.getAttribute("href")||""))return;l=!1;let j=!1,xe=new MutationObserver(()=>{j=!0});xe.observe(p,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),setTimeout(()=>{xe.disconnect(),!j&&!l&&e("$deadclick",y)},1e3)},{capture:!0,passive:!0}),a=>{r&&(e("$errorclick",{...r,...a}),r=void 0)}}function _t(e){let t=!1;for(;e&&e!==document.documentElement;e=e.parentElement){let n=getComputedStyle(e);t&&([n.transform,n.perspective,n.filter,n.backdropFilter].some(r=>r&&r!=="none")||/paint|layout|strict|content/.test(n.contain)||/transform|perspective|filter/.test(n.willChange))&&(t=!1),n.position==="fixed"&&(t=!0)}return t}function Ie(e,t,n){let r=0,o=-1,i=0,l=!1,a=()=>{let c=document.documentElement,p=Math.max(c.scrollHeight,1);return Math.min(100,Math.round((scrollY+c.clientHeight)/p*100))},u=0,s=0,d=()=>{i=0,l=!0;let c=document.documentElement;r=Math.max(r,a()),u=c.scrollHeight,s=c.clientHeight},f=(c=!1)=>{if(c||d(),r<=o)return;let p=n(),m=o>=0;o=r,e("$scroll_depth",{max_pct:r,doc_h:u,viewport_h:s,...p?{url:p}:{},...m?{resumed:m}:{}})};addEventListener("scroll",()=>{i||(i=requestAnimationFrame(d))},{passive:!0}),addEventListener("pagehide",()=>f()),addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&f()),d(),t(c=>{cancelAnimationFrame(i),f(c&&l),o=-1,r=0,l=!1,i=requestAnimationFrame(d)})}function le(e,t=0){let n=new TextEncoder().encode(e),r=t>>>0,o=3432918353,i=461845907,l=n.length&-4;for(let u=0;u<l;u+=4){let s=n[u]|n[u+1]<<8|n[u+2]<<16|n[u+3]<<24;s=Math.imul(s,o),s=s<<15|s>>>17,s=Math.imul(s,i),r^=s,r=r<<13|r>>>19,r=Math.imul(r,5)+3864292196|0}let a=0;switch(n.length&3){case 3:a^=n[l+2]<<16;case 2:a^=n[l+1]<<8;case 1:a^=n[l],a=Math.imul(a,o),a=a<<15|a>>>17,a=Math.imul(a,i),r^=a}return r^=n.length,r^=r>>>16,r=Math.imul(r,2246822507),r^=r>>>13,r=Math.imul(r,3266489909),r^=r>>>16,r>>>0}function Le(e,t,n=""){return le(`${e}.${t}${n}`)/4294967296}function Pe(e,t){let n=e.replace(/^0+/,""),r=t.replace(/^0+/,"");return n.length!==r.length?n.length<r.length?-1:1:n<r?-1:n>r?1:0}function Ae(e,t){let n=i=>{let l=i.replace(/^[ \t\r\n]+|[ \t\r\n]+$/g,"").replace(/^[vV]/,""),a=l.indexOf("+");a>=0&&(l=l.slice(0,a));let u=l.indexOf("-"),s=u>=0?l.slice(u+1):"",d=(u>=0?l.slice(0,u):l).split(".");return{core:[0,1,2].map(f=>/^\d+/.exec(d[f]??"")?.[0]??"0"),pre:s===""?[]:s.split(".")}},r=n(e),o=n(t);for(let i=0;i<3;i++){let l=Pe(r.core[i],o.core[i]);if(l!==0)return l}if(r.pre.length===0||o.pre.length===0)return r.pre.length===o.pre.length?0:r.pre.length===0?1:-1;for(let i=0;i<Math.min(r.pre.length,o.pre.length);i++){let l=r.pre[i],a=o.pre[i],u=/^\d+$/.test(l),s=/^\d+$/.test(a);if(u&&s){let d=Pe(l,a);if(d!==0)return d}else{if(u!==s)return u?-1:1;if(l!==a)return l<a?-1:1}}return r.pre.length===o.pre.length?0:r.pre.length<o.pre.length?-1:1}function Et(e,t){let n=t[e.property];if(e.operator==="is_set")return n!=null;if(e.operator==="is_not_set")return n==null;if(n==null)return!1;let r=String(n),o=Array.isArray(e.value)?e.value.map(String):[String(e.value)];switch(e.operator){case"eq":return r===String(e.value);case"neq":return r!==String(e.value);case"in":return o.includes(r);case"nin":return!o.includes(r);case"contains":return r.toLowerCase().includes(String(e.value).toLowerCase());case"ncontains":return!r.toLowerCase().includes(String(e.value).toLowerCase());case"regex":if(r.length>1024||String(e.value).length>200)return!1;try{return new RegExp(String(e.value)).test(r)}catch{return!1}case"gt":return Number(n)>Number(e.value);case"gte":return Number(n)>=Number(e.value);case"lt":return Number(n)<Number(e.value);case"lte":return Number(n)<=Number(e.value);case"semver_gte":return Ae(r,String(e.value))>=0;case"semver_lt":return Ae(r,String(e.value))<0}}function Te(e,t,n={}){if(!e.active)return{enabled:!1};let o=(e.groups.length?e.groups:[{conditions:[]}]).find(a=>a.conditions.every(u=>Et(u,n)));if(!o)return{enabled:!1};let i=o.rollout_percent??e.rollout_percent;if(Le(e.key,t)*100>=i)return{enabled:!1};if(!e.variants?.length)return Oe({enabled:!0},e.payloads?.true);let l=o.variant;if(!l){let a=Le(e.key,t,".variant")*100,u=0;l=e.variants[e.variants.length-1].key;for(let s of e.variants)if(u+=s.weight,a<u){l=s.key;break}}return Oe({enabled:!0,variant:l},e.payloads?.[l])}function Oe(e,t){return t===void 0?e:{...e,payload:t}}var xt=/\/(\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?=[/?#]|$)/gi,Ne=e=>/^[0-9a-f]{8,}$|^(?=.*\d)(?=.*[A-Za-z])\w{6,}$|^(?=.*[a-z])(?=.*[A-Z])[A-Za-z_]{8}$|^[A-Z]{8}$/.test(e),$t=e=>e.replace(/(^|.-)([\w-]{8})$/,(t,n,r)=>/^[a-z]{2,}-\d+$/.test(r)||!Ne(r.replace(/-/g,"_"))?t:n.slice(0,-1));function ze(e){let t=e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*|[?#].*$|:\d+(?::\d+)?$/gi,""),n=t.slice(0,t.lastIndexOf("/")+1),r=t.slice(n.length).split("."),o=r.length>1?"."+r.pop():"",i=r.map(l=>$t(l).split("-").filter(a=>a&&!Ne(a)).join("-")).filter(Boolean).join(".");return n+i+o}var Rt=e=>e.replace(/^(?:async|new)\s+/,"").split(".").map(t=>/^(?:[A-Za-z_$][\w$]{0,2})?$/.test(t)?"?":t).join(".");function Mt(e){let t=e.trim(),n=/^(?:at\s+|#\d+\s+)(?:async\s+)?(?:(.+?)\s+\()?(.+?)\)?$/.exec(t)||/^([^\s@]*)@(\S.*)$/.exec(t);return n?`${Rt(n[1]??"")}|${ze(n[2])}`:""}var It=(e,t)=>e.split(`
|
|
2
|
+
`).map(Mt).filter(Boolean).slice(0,t);function Lt(e){return e.replace(/\b[a-z][a-z0-9+.-]*:\/\/[^\s)'"]*[^\s)'".,;:!?]/gi,t=>ze(t)).replace(/\b0x[0-9a-f]+\b/gi,"X").replace(/\d+/g,"0")}function qe(e,t,n){let r=a=>{let u=[...t.drop().map(f=>f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),"x-(?:amz|goog)-[\\w-]+"].join("|"),s=f=>f.replace(/https?:\/\/[^\s)'"]+/gi,c=>{let[,p,m=""]=c.match(/^(.*?)(:\d+:\d+)?$/);return L(p,t.drop())+m}),d=f=>f.replace(new RegExp(`([?&;#]|%3[bf]|%26|%23)(${u})(=|%3d)(?:%(?!26|23|3b)[0-9a-f]{2}|(?!:\\d+:\\d+(?:$|[\\s)]))[^&\\s)'"#%])*`,"gi"),"$1$2$3[redacted]");return d(s(d(a)))};if(t.errors){let a=0,u=(s,d,f="",c)=>{if(a++>=20)return;let p=I(s,100),m=I(d,500),y=I(f,4e3),S=le([p,Lt(m),...It(y,3)].join("|")).toString(16);t.onError?.({fingerprint:S,type:p}),e("$error",{message:I(r(m),500),stack:I(r(y),4e3),type:p,fingerprint:S,release:t.release,filename:c&&L(c,t.drop())})};addEventListener("error",s=>u(s.error?.name||"Error",s.message,s.error?.stack,s.filename)),addEventListener("unhandledrejection",s=>{let d=s.reason;u(d?.name||"UnhandledRejection",d?.message??String(d),d?.stack)})}if(t.network){let a=0,u=(c,p,m,y,S)=>{if(a>=200||p.startsWith(t.host))return;a++;let C=L(p,t.drop()).replace(xt,"/:id"),j=S?Number(S):NaN;e("$network",{method:c,url:C,status:m,duration_ms:Math.round(performance.now()-y),size:j>=0?j:void 0})},s=window.fetch;s&&(window.fetch=function(c,p){let m=performance.now(),y=(p?.method||(c instanceof Request?c.method:"GET")).toUpperCase(),S=typeof c=="string"?c:c instanceof URL?c.href:c.url;return s.call(this,c,p).then(C=>(u(y,S,C.status,m,C.headers?.get("content-length")),C),C=>{throw u(y,S,0,m),C})});let d=XMLHttpRequest.prototype.open,f=new WeakMap;XMLHttpRequest.prototype.open=function(c,p,...m){let y=performance.now(),S=()=>{this.removeEventListener("loadend",S),u(c.toUpperCase(),String(p),this.status,y,this.status?this.getResponseHeader("content-length"):null)},C=f.get(this);return C&&this.removeEventListener("loadend",C),f.set(this,S),this.addEventListener("loadend",S),d.call(this,c,p,...m)}}let o=0,i=new Set,l=()=>{for(let a of t.console()||[]){if(i.has(a)||typeof console[a]!="function")continue;i.add(a);let u=console[a];console[a]=(...s)=>{u.apply(console,s),(t.console()||[]).includes(a)&&o++<100&&e("$console",{level:a,message:I(r(I(s.map(d=>typeof d=="string"?d:d instanceof Error?d.message:Pt(d)).join(" "),2e3)),500)})}}};return l(),t.vitals&&typeof PerformanceObserver<"u"&&At(e,n),l}var Pt=e=>{try{return JSON.stringify(e)}catch{return String(e)}};function At(e,t){let n,r=0,o=0,i=0,l=0,a=[],u=0,s=(c,p,m={})=>{try{new PerformanceObserver(y=>y.getEntries().forEach(p)).observe({type:c,buffered:!0,...m})}catch{}};s("largest-contentful-paint",c=>{n=c.startTime}),s("layout-shift",c=>{c.hadRecentInput||(o&&c.startTime-i<1e3&&c.startTime-l<5e3?o+=c.value:(o=c.value,l=c.startTime),i=c.startTime,r=Math.max(r,o))});let d=new Set;s("event",c=>{c.interactionId&&(d.has(c.interactionId)||(d.add(c.interactionId),u++),a=[...a,c.duration].sort((p,m)=>m-p).slice(0,10))},{durationThreshold:40});let f=()=>{let c={lcp:n&&Math.round(n),inp:a.length?a[Math.min(9,Math.floor(u/50))]:void 0,cls:r?+r.toFixed(4):void 0};(c.lcp!==void 0||c.inp!==void 0||c.cls!==void 0)&&e("$web_vitals",c),r=o=0,a=[],u=0,d.clear(),n=void 0};addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&f()),t(f)}function Fe(e){let t=[],n={},r=0,o=new Set,i=new Set;try{let s=e.load();s&&(t=JSON.parse(s))}catch{}async function l(s=!0){let d=await e.json(`/i/v1/flags/definitions?key=${encodeURIComponent(e.key)}${e.env?`&env=${e.env}`:""}`);if(d?.flags&&(t=d.flags,e.save(JSON.stringify(t))),s&&e.canPost()){let f=await e.json("/i/v1/flags",{api_key:e.key,distinct_id:e.id(),environment:e.env,properties:e.props()});f?.flags&&(n=f.flags)}o.forEach(f=>f())}function a(){r||typeof setInterval>"u"||(l(),r=setInterval(()=>document.visibilityState!=="hidden"&&l(!1),e.pollMs))}function u(s){a();let d=t.find(c=>c.key===s),f=d?Te(d,e.id(),e.props()):n[s];return f?(i.has(s)||(i.add(s),e.capture("$feature_flag_called",{flag:s,enabled:f.enabled,variant:f.variant})),f):{enabled:!1}}return{isEnabled:s=>u(s).enabled,getVariant:s=>u(s).variant,getPayload:s=>u(s).payload,reload:()=>l(),onChange(s){return a(),o.add(s),()=>{o.delete(s)}},reset(){i.clear(),r&&l()}}}var Be=["necessary","analytics","replay","personalization","marketing"],ge=30*6e4,Je=2e3,Ot=15e5,Tt=100,v,F="",A="",me,K=!1,h=null,g=null,_="anon_"+T(),E=null,O={},U=null,k,w=[],D=[],Y=Promise.resolve(),Xe,ce=0,ue=0,de=!1,Q=!1,Ve,G,Ze="",We={},te=!1,b=null,fe=!1,X=!1,q=!1,pe=!1,B,Ge,$,he=[],ve=new Set,Ue="null",Ke,Ye=new Promise(e=>{Ke=e}),P=e=>{try{return JSON.parse(localStorage.getItem(e)||"null")}catch{return null}},R=(e,t)=>{try{t==null?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch{}},V=(e,t)=>{x()==="full"&&R(e,t)},M=e=>!!e&&!!h&&Date.now()<e.t+(h.consent?.validity_days??180)*864e5&&(!h.consent||e.v===h.consent.version),H=e=>e==="necessary"||M(g)&&g.c[e]===!0,ye=()=>h?.consent?.respect_gpc!==!1&&(navigator.globalPrivacyControl===!0||navigator.doNotTrack==="1"),Nt=/^(Europe\/|Asia\/(Nicosia|Famagusta)$|Atlantic\/(Canary|Madeira|Azores|Reykjavik)$|Africa\/Ceuta$|Indian\/(Reunion|Mayotte)$|America\/(Guadeloupe|Martinique|Cayenne|Marigot|St_Barthelemy)$)/,Qe=()=>{try{return Nt.test(Intl.DateTimeFormat().resolvedOptions().timeZone)}catch{return!0}};function x(){let e=h?.consent;return M(g)?g.c.analytics?"full":e?.exempt_analytics&&!ye()?"mem":"off":h?!e?.enabled||e.regions==="eu"&&!Qe()?"mem":ye()?"off":e.exempt_analytics?"mem":"wait":"wait"}function et(){let e=M(g)?g:null;return{id:e?.id,version:e?.v,categories:x()==="mem"?{...e?.c,analytics:!0}:e?e.c:{}}}var zt=e=>new Promise(t=>{let n=setTimeout(t,e);Ve=()=>{clearTimeout(n),t()}});async function ne(e,t,n=1/0){for(let r=0;;r++){let o=null;try{o=await fetch(e,{credentials:"omit",...t})}catch{}if(o&&o.status!==429&&o.status<500||r+1>=n)return o;await zt(Math.max((Number(o?.headers.get("retry-after"))||0)*1e3,Math.min(3e5,1e3*2**r)*(.5+Math.random()/2)))}}var tt=async(e,t,n,r)=>(await ne(A+e,{method:"POST",body:await ae(t),keepalive:r},n))?.status??0,qt=async(e,t)=>{let n=await ne(A+e,t?{method:"POST",body:JSON.stringify(t),headers:{"content-type":"text/plain"}}:{},1).catch(()=>null);return n?.ok?n.json().catch(()=>null):null},Ft=["log","info","warn","error","debug"],Ut=()=>{if(v?.console===void 0&&!te)return!1;let e=v?.console!==void 0?v.console:h?.replay.console;return e===!1?!1:Array.isArray(e)?e.filter(t=>Ft.includes(t)):["warn","error"]},Z=()=>[...$e,...v?.sensitiveParams??[],...h?.replay.mask.ignore_url_params??[]].map(e=>e.toLowerCase());function nt(){let e=document.documentElement;return{url:L(location.href,Z()),referrer:Ze,lang:navigator.language,viewport_w:e.clientWidth,viewport_h:e.clientHeight,platform:"web",app_version:v.release,...We}}function J(){let e=Date.now(),t=!k||e-k.t>ge?x()==="full"?P("pt_s"):null:k,n=t&&e-t.t<=ge?t:{id:T(),t:e,u:Math.random(),v:Math.random(),n:0};return n.t=e,(k=n).id}function N(e,t={},n={}){let r={id:T(),event:e,ts:new Date().toISOString(),distinct_id:E??_,session_id:J(),environment:me,props:{...nt(),...t},...n};E&&(r.identified=!0),rt(r),jt(e)}function rt(e){let t=x();if(t==="wait"||!h){D.push(e),D.length>Tt&&D.shift();return}if(t==="off")return;let n=h.sampling;J(),!(k.u>=n.sessions||e.event!=="$identify"&&Math.random()>=n.events)&&(w.push(e)>Je&&w.shift(),w.length>=v.batchSize?De():ce||(ce=setTimeout(()=>{ce=0,De()},v.batchInterval)),ue||(ue=setTimeout(()=>{ue=0,W()},1e3)))}function W(){if(x()!=="full")return;let e=w.slice(-Je);for(;e.length>1&&JSON.stringify(e).length>Ot;)e=e.slice(e.length>>1);R("pt_q",e.length?e:null),ot()}function ot(e=0){if(!k)return 0;let t=P("pt_s"),n=Math.max(k.n,t?.id===k.id?~~t.n:0);return k.n=n+e,V("pt_s",k),n}var st=e=>JSON.stringify({api_key:F,sent_at:new Date().toISOString(),consent:et(),batch:e}),ee=()=>x()==="mem"||x()==="full";async function De(){if(!(de||!w.length||!ee())){de=!0;try{for(await Y;w.length&&ee();){let e=w.slice(0,100);await ne(A+"/i/v1/events",{method:"POST",body:await ae(st(e))});let t=new Set(e);w=w.filter(n=>!t.has(n)),W()}}finally{de=!1}}}function He(){for(W(),b?.beacon();w.length&&ee();){let e=w.slice(0,25);if(!navigator.sendBeacon?.(A+"/i/v1/events",new Blob([st(e)],{type:"text/plain"})))break;let t=new Set(e);w=w.filter(n=>!t.has(n))}W()}function Dt(){let e=_;_=P("pt_id")||_,R("pt_id",_);let t=P("pt_s");t&&Date.now()-t.t<ge&&(k=t);let n=P("pt_u");n&&H("personalization")&&(E=n.u,O=n.tr);let r=P("pt_q");Array.isArray(r)&&(w=[...r,...w]);for(let o of[...w,...D])o.distinct_id===e&&(o.distinct_id=_);Q=!0}function it(){for(let e of["pt_id","pt_s","pt_q","pt_u","pt_cfg","pt_flags"])R(e,null);E=null,O={},(Q||x()!=="mem")&&(w=[],D=[],k=void 0,_="anon_"+T()),Q=!1}function Ht(){let e=_e.get(),t=JSON.stringify(e);t!==Ue&&(Ue=t,ve.forEach(n=>{try{n(e)}catch{}}),dispatchEvent(new CustomEvent("pt:consent",{detail:e})))}function at(){Ht();let e=x();e==="full"&&!Q&&Dt(),e!=="wait"&&(D.splice(0).forEach(t=>e!=="off"&&rt(t)),ct(),ke(),U&&H("personalization")&&(dt(...U),U=null),W())}function be(e,t){let n=M(g)?g.c:null,r={...e,necessary:!0},o=t==="withdraw"||!!n&&Be.some(i=>n[i]&&!r[i]);g={id:g?.id||T(),v:h?.consent?.version??0,t:Date.now(),c:r,p:o?"withdraw":t},R("pt_consent",g),lt(g),r.analytics?r.personalization||(E=null,O={},U=null,R("pt_u",null)):it(),r.replay||(b?.stop(),b=null),at(),$?.reset()}function lt(e){Xe=e;let t={api_key:F,consent_id:e.id,policy_version:e.v,choices:e.c,source:e.p};Y=Y.then(async()=>{let n=await tt("/i/v1/consent",JSON.stringify(t),6,!0);n>199&&n<300&&(delete e.p,g===e&&R("pt_consent",e))}).catch(()=>{})}function ct(){!h||!te||document.querySelectorAll('script[type="text/plain"][data-pt-category]').forEach(e=>{if(!H(e.dataset.ptCategory))return;let t=document.createElement("script");for(let n of Array.from(e.attributes))n.name!=="type"&&n.name!=="data-pt-category"&&t.setAttribute(n.name,n.value);t.text=e.text,e.replaceWith(t)})}async function Se(e){let t=h?.consent;if(!(!t||q)){q=!0,B?.(),B=void 0;try{(await import("./consent.js")).show({cfg:t,current:e&&g?g.c:null,onChoice:r=>be(r,"banner"),onClose:()=>{q=!1,ut()}})}catch{q=!1}}}async function ut(){let e=h?.consent;if(!(!e?.enabled||!M(g)||q||B||pe||typeof document>"u")){pe=!0;try{if(document.readyState==="loading"&&await new Promise(t=>document.addEventListener("DOMContentLoaded",t,{once:!0})),await new Promise(t=>setTimeout(t,1e3)),q||B||document.querySelector("[data-pt-consent-open]"))return;B=(await import("./consent.js")).manage(e,()=>{Se(!0)})}catch{}finally{pe=!1}}}function je(){g?.p&&g!==Xe&&M(g)&<(g),Ge?.(),at();let e=h?.consent;e?.enabled&&!M(g)&&!ye()&&(e.regions==="always"||Qe())?Se(!1):ut()}function ke(e=!1){let t=h?.replay;!te||b||fe||X||!t?.enabled||!H("replay")||typeof document>"u"||(J(),!(k.u>=h.sampling.sessions||!(e||k.v<t.sample_rate))&&(fe=!0,import("./replay.js").then(n=>{if(b||!H("replay"))return;let r=(o,i)=>`/i/v1/replay/${o}/chunks?key=${encodeURIComponent(F)}&seq=${i}`;b=n.start({cfg:t,dropParams:Z(),sessionId:J,distinctId:()=>E??_,consent:et,nextSeq:()=>(J(),ot(1)),post:async(o,i,l)=>{await Y;let a=await tt(r(o,i),l,6);return a===403&&(b?.stop(),b=null,X=!0),a},beacon:(o,i,l)=>!!navigator.sendBeacon?.(A+r(o,i),typeof l=="string"?new Blob([l],{type:"text/plain"}):l)})}).catch(()=>{}).finally(()=>{fe=!1})))}function jt(e){let t=h?.replay.triggers;if(!t||b)return;let n=location.pathname+location.search,r=o=>new RegExp("^"+o.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(n);(e==="$error"&&t.on_error||t.events?.includes(e)||e==="$pageview"&&t.url_patterns?.some(r))&&ke(!0)}function we(){let e=L(location.href,Z());if(e===G)return;Ze=G??(document.referrer?L(document.referrer,Z()):""),G=e;let t=new URL(location.href).searchParams;for(let[n,r]of t)n.startsWith("utm_")&&(We[n]=r.slice(0,200));N("$pageview")}function Bt(){for(let e of["pushState","replaceState"]){let t=history[e];history[e]=function(...n){he.forEach(o=>o());let r=t.apply(this,n);return we(),r}}addEventListener("popstate",()=>{he.forEach(e=>e(!0)),we()})}function Ce(e,t){if(K||typeof window>"u")return;K=!0,F=e,v={batchInterval:5e3,batchSize:20,...t},A=v.host.replace(/\/$/,""),me=v.environment,g=P("pt_consent");let n=g?.c.analytics?P("pt_cfg"):null;n&&n.consent?.version===g.v&&(h=n,je()),$=Fe({key:F,env:me,pollMs:v.flagsPollMs??3e4,capture:N,json:qt,id:()=>E??_,props:()=>({...nt(),$platform:"web",...O}),load:()=>x()==="full"?localStorage.getItem("pt_flags"):null,save:i=>V("pt_flags",JSON.parse(i)),canPost:()=>ee()}),(async()=>{let i=await ne(`${A}/i/v1/config?key=${encodeURIComponent(F)}`,{},5),l=i?.ok?await i.json().catch(()=>null):null;l&&(h=l,te=!0,V("pt_cfg",l),M(g)||(b?.stop(),b=null),je(),Ke())})();let r=i=>{he.push(i)};v.autocapture!==!1&&Ie(N,r,()=>G??void 0),addEventListener("online",()=>Ve?.()),document.addEventListener("click",i=>{i.target?.closest?.("[data-pt-consent-open]")&&(i.preventDefault(),_e.open())}),addEventListener("visibilitychange",()=>{if(document.visibilityState==="visible"){X||b?.resume();return}He(),b?.pause()}),addEventListener("pagehide",He),v.pageviews!==!1&&(Bt(),we());let o=v.autocapture!==!1?Me(N,r,{frustration:v.frustration!==!1}):void 0;Ge=qe(N,{errors:v.errors!==!1,network:v.network!==!1,vitals:v.vitals!==!1,console:Ut,drop:Z,host:A,release:v.release,onError:o},r),document.addEventListener("DOMContentLoaded",ct)}function Jt(e,t){K&&N(e,t)}function dt(e,t={}){if(!K)return;if(!H("personalization")){U=[e,t];return}let n=_;E=e,O={...O,...t},V("pt_u",{u:E,tr:O}),N("$identify",{},{anonymous_id:n,traits:t}),$?.reset()}function Xt(){E=null,O={},U=null,k=void 0,_="anon_"+T(),R("pt_u",null),R("pt_s",null),V("pt_id",_),$?.reset()}var ft=e=>h?e():void Ye.then(e),Vt=e=>ft(()=>be(Object.fromEntries((e??Be).map(t=>[t,!0])),"api")),Zt=()=>{it(),ft(()=>be({},"withdraw"))},_e={open:()=>Ye.then(()=>Se(!0)),get:()=>M(g)?{...g.c}:null,onChange:e=>(ve.add(e),()=>{ve.delete(e)})},Wt={pause(){X=!0,b?.pause()},resume(){X=!1,b?b.resume():ke()}},Gt={isEnabled:e=>$?.isEnabled(e)??!1,getVariant:e=>$?.getVariant(e),getPayload:e=>$?.getPayload(e),reload:()=>$?.reload(),onChange:e=>$?.onChange(e)??(()=>{})};var z=document.currentScript;globalThis.SheepTrack=Ee;z?.dataset.key&&Ce(z.dataset.key,{host:z.dataset.host||new URL(z.src).origin,environment:z.dataset.env==="dev"||z.dataset.env==="prod"?z.dataset.env:void 0});})();
|
|
@@ -4,6 +4,12 @@ type Capture = (name: string, props: Record<string, unknown>) => void;
|
|
|
4
4
|
export declare function installClicks(capture: Capture, onNav: (cb: () => void) => void, o: {
|
|
5
5
|
frustration: boolean;
|
|
6
6
|
}): (err: Record<string, unknown>) => void;
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* One $scroll_depth per page view (heatmaps, FR-RPW-15): max depth as % of document height. A tab that goes to the background is
|
|
9
|
+
* reported at once (it may never come back: mobile browsers kill it without pagehide); if the reader returns and goes deeper, the
|
|
10
|
+
* next report (`resumed: true`) carries the new max, and nothing is sent again while the max has not grown.
|
|
11
|
+
* `pageUrl` = URL of the current page view: on popstate the browser has already moved to the next page when the hook runs, so the
|
|
12
|
+
* report of the page left uses it and the last measures, never the live location / document.
|
|
13
|
+
*/
|
|
14
|
+
export declare function installScroll(capture: Capture, onNav: (cb: (popped?: boolean) => void) => void, pageUrl: () => string | undefined): void;
|
|
9
15
|
export {};
|
package/dist/types/consent.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BannerArgs, ConsentCfg } from './ctx.js';
|
|
2
2
|
/** [r, g, b] of a #rrggbb or a computed rgb()/rgba() colour; null when unknown or (almost) transparent. */
|
|
3
3
|
export declare const rgb: (c?: string | null) => number[] | null;
|
|
4
|
+
/** Text colour with the better contrast on `c`: black and white are equally good at a relative luminance of about 0.179, not 0.4. Names (yellow) are resolved by the browser. */
|
|
5
|
+
export declare const onColor: (c: string) => "#000" | "#fff";
|
|
4
6
|
/** Look of the host page (font, text and background colours, its first button) so the banner fits the site without settings. */
|
|
5
7
|
export declare function pageTheme(): Record<string, string>;
|
|
6
8
|
/** Small floating "Manage my cookies" button, so a choice can be changed or withdrawn at any time (FR-CMP-07). */
|
package/dist/types/ctx.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export interface ReplayCtx {
|
|
|
9
9
|
consent(): ConsentState;
|
|
10
10
|
nextSeq(): number;
|
|
11
11
|
dropParams: string[];
|
|
12
|
-
/** Resolves with the final HTTP status (0 = gave up). */
|
|
13
|
-
post(sid: string, seq: number,
|
|
12
|
+
/** Resolves with the final HTTP status (0 = gave up). body: JSON, or a Blob already packed (gzip). */
|
|
13
|
+
post(sid: string, seq: number, body: string | Blob): Promise<number>;
|
|
14
14
|
/** false when the browser refused it (size limit): the chunk is kept for a later POST. */
|
|
15
|
-
beacon(sid: string, seq: number,
|
|
15
|
+
beacon(sid: string, seq: number, body: string | Blob): boolean;
|
|
16
16
|
}
|
|
17
17
|
export interface ReplayHandle {
|
|
18
18
|
stop(): void;
|
package/dist/types/debug.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ type Capture = (name: string, props: Record<string, unknown>) => void;
|
|
|
2
2
|
export interface DebugOpts {
|
|
3
3
|
errors: boolean;
|
|
4
4
|
network: boolean;
|
|
5
|
-
console: string[] | false;
|
|
6
5
|
vitals: boolean;
|
|
6
|
+
/** Console levels to capture, read on every call: the project's remote config can change them after init. */
|
|
7
|
+
console: () => readonly string[] | false;
|
|
7
8
|
drop: () => string[];
|
|
8
9
|
host: string;
|
|
9
10
|
release?: string;
|
|
@@ -13,5 +14,12 @@ export interface DebugOpts {
|
|
|
13
14
|
type: string;
|
|
14
15
|
}) => void;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
/** One stack-trace line (V8 `at fn (url:1:2)`, Firefox/Safari `fn@url:1:2`, Dart `#0 fn (url:1:2)`) as `function|path`; '' if it is not a frame. */
|
|
18
|
+
export declare function normalizeStackFrame(line: string): string;
|
|
19
|
+
/** The first `max` frame lines of a stack (the `Type: message` header and anything not shaped like a frame are skipped). */
|
|
20
|
+
export declare const stackFrames: (stack: string, max: number) => string[];
|
|
21
|
+
/** Error message without what varies between occurrences or builds: numbers, hex addresses, URL origin/query and bundle hashes. */
|
|
22
|
+
export declare function normalizeErrorMessage(message: string): string;
|
|
23
|
+
/** Returns `syncConsole`, to call when the console levels may have changed (remote config loaded). */
|
|
24
|
+
export declare function installDebug(capture: Capture, o: DebugOpts, onNav: (cb: () => void) => void): () => void;
|
|
17
25
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface InitOptions {
|
|
|
13
13
|
network?: boolean;
|
|
14
14
|
vitals?: boolean;
|
|
15
15
|
frustration?: boolean;
|
|
16
|
-
/** Console levels captured.
|
|
16
|
+
/** Console levels captured. When omitted, the project setting applies (remote config), else warn+error: console.log often carries personal data. */
|
|
17
17
|
console?: ('log' | 'info' | 'warn' | 'error' | 'debug')[] | false;
|
|
18
18
|
/** Extra query params stripped from every URL we record. */
|
|
19
19
|
sensitiveParams?: string[];
|
package/dist/types/replay.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import type { ReplayCtx, ReplayHandle } from './ctx.js';
|
|
2
|
+
/**
|
|
3
|
+
* A full snapshot at most every 2 min: the player seeks from the last one instead of replaying the session from its start.
|
|
4
|
+
* rrweb checks the delay on each incremental event, so an idle page gets its checkpoint with its next event, not on a clock
|
|
5
|
+
* (nothing happened in between: the seek has nothing to replay there).
|
|
6
|
+
*/
|
|
7
|
+
export declare const CHECKOUT_MS = 120000;
|
|
2
8
|
/** srcset parsed as the HTML spec does (URL up to whitespace, descriptors up to the next comma, with or without a space), each URL cleaned. */
|
|
3
9
|
export declare function cleanSrcset(v: string, drop: string[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* Top window: merge the iframes that send their events. Framed page: rrweb would post every event to window.parent
|
|
12
|
+
* with targetOrigin '*', so only do it when the parent's origin is verified and explicitly allowed; otherwise record on its own.
|
|
13
|
+
* Only location.ancestorOrigins names the actual parent; document.referrer is the page that started the navigation, which
|
|
14
|
+
* can differ from the embedding one, so where ancestorOrigins is missing (Firefox) the frame records separately.
|
|
15
|
+
*/
|
|
16
|
+
export declare function crossOriginIframes(cfg: ReplayCtx['cfg'], w?: Window): boolean;
|
|
17
|
+
/** Splits off a trailing rrweb Meta (type 4) so it travels with the FullSnapshot that follows it; a lone Meta is sent as is. */
|
|
18
|
+
export declare function holdTrailingMeta<E extends {
|
|
19
|
+
type: number;
|
|
20
|
+
}>(events: E[]): [E[], E | undefined];
|
|
4
21
|
export declare function start(ctx: ReplayCtx): ReplayHandle;
|
package/dist/types/util.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export declare const trunc: (s: unknown, n: number) => string;
|
|
|
5
5
|
export declare function cleanUrl(u: string, drop: string[]): string;
|
|
6
6
|
/** Short CSS path (max 4 levels, tag + #id or first plain class). Never uses text content. */
|
|
7
7
|
export declare function selector(el: Element): string;
|
|
8
|
-
/** gzip when CompressionStream exists; text/plain avoids the CORS preflight. */
|
|
9
|
-
export declare function pack(s: string): Promise<Blob>;
|
|
8
|
+
/** gzip when CompressionStream exists (the server detects it by its magic bytes); text/plain avoids the CORS preflight. A Blob is already packed. */
|
|
9
|
+
export declare function pack(s: string | Blob): Promise<Blob>;
|