@abyss-project/monitor-browser 1.2.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/monitor-browser",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Browser SDK of Abyss-Monitor: real user monitoring (sessions, page views, requests, errors)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -36,8 +36,9 @@
36
36
  },
37
37
  "homepage": "https://gitlab.com/abyss-group/abyss-monitor/abyss-monitor",
38
38
  "dependencies": {
39
+ "rrweb": "2.0.0-alpha.20",
39
40
  "web-vitals": "4.2.4",
40
- "@abyss-project/monitor": "12.1.0"
41
+ "@abyss-project/monitor": "13.1.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/node": "^20.17.31",
@@ -1 +0,0 @@
1
- var e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,x=t=>typeof t=="string"&&e.test(t);var l=":id",c=40,I=/^\d{3,}$/,p=/^[0-9a-f]{16,}$/i,O=/^[a-z][a-z0-9+.-]*:\/\//i,A=t=>t.length>c||e.test(t)||I.test(t)||p.test(t),S=t=>t===""?"/":t.split("/").map(r=>A(r)?l:r).join("/"),f=t=>{try{let r=new URL(t.startsWith("//")?`https:${t}`:t);return{host:r.host===""?null:r.host.toLowerCase(),path:r.pathname}}catch{return{host:null,path:"/"}}},N=t=>{let n=(typeof t=="string"?t.trim():"").split("#")[0].split("?")[0],{host:o,path:s}=O.test(n)||n.startsWith("//")?f(n):{host:null,path:n};return{host:o,path:S(s)}};var g="x-abyss-request-id",d="x-abyss-session-id";var h="abyss_rid",C="abyss_sid";var K=t=>new Date(t).toISOString(),y=(t,r)=>t>0&&r>=t?Math.round(r-t):null,H=t=>{var r;if(typeof t=="string")return t;if(t instanceof Error)return`${t.name}: ${t.message}`;try{return(r=JSON.stringify(t))!=null?r:String(t)}catch{return String(t)}},k=(t,r,n,o=!1)=>{let s={capture:o,passive:!0};return t.addEventListener(r,n,s),()=>t.removeEventListener(r,n,s)},E=t=>{let r=0;for(let n=0;n<t.length;n+=1){let o=t.charCodeAt(n);o<128?r+=1:o<2048?r+=2:o>=55296&&o<56320?(r+=4,n+=1):r+=3}return r},m=(t,r)=>{if(E(t)<=r)return t;let n=0;for(let o=0;o<t.length;o+=1){let s=t.charCodeAt(o)>=55296&&t.charCodeAt(o)<56320,i=E(t.slice(o,s?o+2:o+1));if(n+i>r)return t.slice(0,o);n+=i,s&&(o+=1)}return t},F=t=>{if(typeof t=="string")return E(t);if(typeof Blob!="undefined"&&t instanceof Blob)return t.size;let r=t==null?void 0:t.byteLength;return typeof r=="number"?r:0},W=t=>{try{let r=sessionStorage.getItem(t);return r===null?null:JSON.parse(r)}catch{return null}},$=(t,r)=>{try{sessionStorage.setItem(t,JSON.stringify(r))}catch{}},B=t=>{try{sessionStorage.removeItem(t)}catch{}};var Q=()=>{let t=globalThis.crypto;if(typeof(t==null?void 0:t.randomUUID)=="function")return t.randomUUID();let r=new Uint8Array(16);t.getRandomValues(r),r[6]=r[6]&15|64,r[8]=r[8]&63|128;let n=Array.from(r,o=>(o+256).toString(16).slice(1)).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`};export{x as a,N as b,g as c,d,h as e,C as f,K as g,y as h,H as i,k as j,E as k,m as l,F as m,W as n,$ as o,B as p,Q as q};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,x= exports.a =t=>typeof t=="string"&&e.test(t);var l=":id",c=40,I=/^\d{3,}$/,p=/^[0-9a-f]{16,}$/i,O=/^[a-z][a-z0-9+.-]*:\/\//i,A=t=>t.length>c||e.test(t)||I.test(t)||p.test(t),S=t=>t===""?"/":t.split("/").map(r=>A(r)?l:r).join("/"),f=t=>{try{let r=new URL(t.startsWith("//")?`https:${t}`:t);return{host:r.host===""?null:r.host.toLowerCase(),path:r.pathname}}catch (e2){return{host:null,path:"/"}}},N= exports.b =t=>{let n=(typeof t=="string"?t.trim():"").split("#")[0].split("?")[0],{host:o,path:s}=O.test(n)||n.startsWith("//")?f(n):{host:null,path:n};return{host:o,path:S(s)}};var g="x-abyss-request-id",d= exports.d ="x-abyss-session-id";var h="abyss_rid",C= exports.f ="abyss_sid";var K=t=>new Date(t).toISOString(),y= exports.h =(t,r)=>t>0&&r>=t?Math.round(r-t):null,H= exports.i =t=>{var r;if(typeof t=="string")return t;if(t instanceof Error)return`${t.name}: ${t.message}`;try{return(r=JSON.stringify(t))!=null?r:String(t)}catch (e3){return String(t)}},k= exports.j =(t,r,n,o=!1)=>{let s={capture:o,passive:!0};return t.addEventListener(r,n,s),()=>t.removeEventListener(r,n,s)},E= exports.k =t=>{let r=0;for(let n=0;n<t.length;n+=1){let o=t.charCodeAt(n);o<128?r+=1:o<2048?r+=2:o>=55296&&o<56320?(r+=4,n+=1):r+=3}return r},m= exports.l =(t,r)=>{if(E(t)<=r)return t;let n=0;for(let o=0;o<t.length;o+=1){let s=t.charCodeAt(o)>=55296&&t.charCodeAt(o)<56320,i=E(t.slice(o,s?o+2:o+1));if(n+i>r)return t.slice(0,o);n+=i,s&&(o+=1)}return t},F= exports.m =t=>{if(typeof t=="string")return E(t);if(typeof Blob!="undefined"&&t instanceof Blob)return t.size;let r=t==null?void 0:t.byteLength;return typeof r=="number"?r:0},W= exports.n =t=>{try{let r=sessionStorage.getItem(t);return r===null?null:JSON.parse(r)}catch (e4){return null}},$= exports.o =(t,r)=>{try{sessionStorage.setItem(t,JSON.stringify(r))}catch (e5){}},B= exports.p =t=>{try{sessionStorage.removeItem(t)}catch (e6){}};var Q=()=>{let t=globalThis.crypto;if(typeof(t==null?void 0:t.randomUUID)=="function")return t.randomUUID();let r=new Uint8Array(16);t.getRandomValues(r),r[6]=r[6]&15|64,r[8]=r[8]&63|128;let n=Array.from(r,o=>(o+256).toString(16).slice(1)).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`};exports.a = x; exports.b = N; exports.c = g; exports.d = d; exports.e = h; exports.f = C; exports.g = K; exports.h = y; exports.i = H; exports.j = k; exports.k = E; exports.l = m; exports.m = F; exports.n = W; exports.o = $; exports.p = B; exports.q = Q;
@@ -1 +0,0 @@
1
- import{a as U,c as B,h as W}from"./chunk-UO34ZFAC.mjs";import{g as d,i as K,j as h,l as j,q as l}from"./chunk-AAXB6P4Z.mjs";var vt=1024,gt=50,q=r=>{let t=[["error","error"],["warn","warn"]],e=null,n=0,i=t.map(([o,s])=>{let a=console[o],u=(...c)=>{try{let y=r.pageViewId();y!==e&&(e=y,n=0),n+=1,n>gt?r.drop():r.record({id:l(),type:"console",pageViewId:y,occurredAt:d(Date.now()),level:s,message:j(c.map(K).join(" "),vt)})}catch{r.drop()}a.apply(console,c)};return console[o]=u,()=>{console[o]===u&&(console[o]=a)}});return()=>i.forEach(o=>o())};var yt=/^[a-z][a-z0-9-]{0,31}$/,Tt=r=>{try{let e=new URL(r);if(e.host)return`${e.protocol}//${e.host}`}catch{}let t=r.trim().toLowerCase().replace(/:.*$/,"");return yt.test(t)?t:null},$=r=>{let t=null,e=new Set;return h(document,"securitypolicyviolation",n=>{var i;try{let o=r.pageViewId();o!==t&&(t=o,e=new Set);let s=n.effectiveDirective||n.violatedDirective,a=Tt((i=n.blockedURI)!=null?i:""),u=`${s}${a!=null?a:""}`;if(!s||e.has(u))return;e.add(u),r.record({id:l(),type:"cspViolation",pageViewId:o,occurredAt:d(Date.now()),effectiveDirective:s,blockedUri:a,sourceFile:n.sourceFile||null,lineNumber:n.lineNumber||null,disposition:n.disposition==="report"?"report":"enforce"})}catch{r.drop()}},!0)};var w=1e3,Et=3,wt='button,a,[role="button"],input[type="submit"]',R=class{constructor(t){this.host=t;this.last=null;this.burst=[];this.raged=!1;this.activity=0;this.watched=new Set;this.observer=null}start(){typeof MutationObserver!="undefined"&&(this.observer=new MutationObserver(()=>this.notifyActivity()));let t=[h(window,"click",e=>{try{e.target instanceof Element&&this.click(e.target)}catch{this.host.drop()}},!0),h(window,"pagehide",()=>this.cancel())];return()=>{t.forEach(e=>e()),this.cancel(),this.observer=null}}notifyActivity(){this.activity+=1}notifyError(){let t=this.last;!t||t.errored||Date.now()-t.at>w||(t.errored=!0,this.settle(t),this.emit(t,"ERROR_CLICK"))}click(t){let e=Date.now(),n=this.last,o=n!==null&&n.element===t&&e-n.at<=w;o&&this.settle(n),this.burst=o?[...this.burst.filter(a=>e-a<=w),e]:[e],o||(this.raged=!1);let s={element:t,at:e,pageViewId:this.host.pageViewId(),route:this.host.resolveRoute(),activity:this.activity,errored:!1,timer:null};this.last=s,this.burst.length>=Et&&!this.raged&&(this.raged=!0,this.emit(s,"RAGE_CLICK")),!o&&t.closest(wt)&&this.watch(s)}watch(t){this.watched.size===0&&this.observer&&this.observer.observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),this.watched.add(t),t.timer=setTimeout(()=>{try{this.settle(t),t.activity===this.activity&&!t.errored&&this.emit(t,"DEAD_CLICK")}catch{this.host.drop()}},w)}settle(t){var e;t.timer!==null&&(clearTimeout(t.timer),t.timer=null),this.watched.delete(t)&&this.watched.size===0&&((e=this.observer)==null||e.disconnect())}cancel(){this.watched.forEach(t=>this.settle(t)),this.last=null,this.burst=[],this.raged=!1}emit(t,e){this.host.record({id:l(),type:"frustration",pageViewId:t.pageViewId,occurredAt:d(t.at),frustrationType:e,route:t.route,element:this.host.describe(t.element)})}};var Rt=50,It=1e3,bt=(r,t)=>{let e=typeof performance=="undefined"?NaN:performance.timeOrigin;return Number.isFinite(e)&&e>0&&Number.isFinite(r)?e+r:Date.now()-t},Ct=()=>{var t;if(typeof PerformanceObserver=="undefined")return null;let r=(t=PerformanceObserver.supportedEntryTypes)!=null?t:[];return r.includes("long-animation-frame")?"long-animation-frame":r.includes("longtask")?"longtask":null},I=class{constructor(t){this.host=t;this.page=null}start(){let t=Ct();if(!t)return()=>{};let e=new PerformanceObserver(n=>{try{n.getEntries().forEach(i=>this.add(i.duration,i.startTime))}catch{this.host.drop()}});return e.observe({type:t,buffered:!0}),()=>e.disconnect()}annotate(t){var e;((e=this.page)==null?void 0:e.id)===t.id&&(t.longTaskCount=this.page.count,t.longTaskTotalMs=Math.round(this.page.totalMs))}add(t,e){var i;let n=this.host.pageViewId();!n||!(t>=Rt)||(((i=this.page)==null?void 0:i.id)!==n&&(this.page={id:n,count:0,totalMs:0}),this.page.count+=1,this.page.totalMs+=t,t>=It&&this.host.record({id:l(),type:"longTask",pageViewId:n,route:this.host.resolveRoute(),startedAt:d(bt(e,t)),durationMs:Math.round(t)}))}};var Vt=64,z=20,O=r=>typeof r=="string"&&r.length>0&&r.length<=Vt,X=()=>{let r=typeof performance=="undefined"?NaN:performance.timeOrigin;return Number.isFinite(r)&&r>0&&r<=Date.now()?r:null},b=class{constructor(t){this.host=t;this.page=null;this.pending=[];this.durations=new Map}pageView(t){var o,s;if(((o=this.page)==null?void 0:o.id)===t.id)return;let e=this.page===null,n=(s=e?X():null)!=null?s:Date.parse(t.startedAt);this.page={id:t.id,origin:n,count:0};for(let[a,u]of this.durations)e&&u.pageViewId===null?u.pageViewId=t.id:this.durations.delete(a);let i=this.pending;this.pending=[],i.forEach(a=>this.send(a))}addTiming(t,e=Date.now()){if(!O(t)){this.host.drop();return}let n=this.page?this.page.origin:X();if(n===null){this.host.drop();return}this.send({id:l(),type:"timing",occurredAt:d(e),name:t,kind:"TIMING",valueMs:Math.max(0,Math.round(e-n))})}startDuration(t,e,n=Date.now()){var o,s;if(!O(t)){this.host.drop();return}let i={startedAt:n,pageViewId:(s=(o=this.page)==null?void 0:o.id)!=null?s:null};if(e!==void 0){let a=U({},e,this.host.drop);Object.keys(a).length>0&&(i.attributes=a)}this.durations.set(t,i)}stopDuration(t,e=Date.now()){let n=O(t)?this.durations.get(t):void 0;if(!n){this.host.drop();return}this.durations.delete(t),this.send({id:l(),type:"timing",occurredAt:d(n.startedAt),name:t,kind:"DURATION",valueMs:Math.max(0,Math.round(e-n.startedAt)),...n.attributes?{attributes:n.attributes}:{}})}send(t){if(!this.page){this.pending.length<z?this.pending.push(t):this.host.drop();return}if(this.page.count>=z){this.host.drop();return}this.page.count+=1,this.host.record({...t,pageViewId:this.page.id})}};var _;var nt=-1,g=function(r){addEventListener("pageshow",(function(t){t.persisted&&(nt=t.timeStamp,r(t))}),!0)},x=function(){var r=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(r&&r.responseStart>0&&r.responseStart<performance.now())return r},M=function(){var r=x();return r&&r.activationStart||0},m=function(r,t){var e=x(),n="navigate";return nt>=0?n="back-forward-cache":e&&(document.prerendering||M()>0?n="prerender":document.wasDiscarded?n="restore":e.type&&(n=e.type.replace(/_/g,"-"))),{name:r,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},E=function(r,t,e){try{if(PerformanceObserver.supportedEntryTypes.includes(r)){var n=new PerformanceObserver((function(i){Promise.resolve().then((function(){t(i.getEntries())}))}));return n.observe(Object.assign({type:r,buffered:!0},e||{})),n}}catch{}},f=function(r,t,e,n){var i,o;return function(s){t.value>=0&&(s||n)&&((o=t.value-(i||0))||i===void 0)&&(i=t.value,t.delta=o,t.rating=(function(a,u){return a>u[1]?"poor":a>u[0]?"needs-improvement":"good"})(t.value,e),r(t))}},F=function(r){requestAnimationFrame((function(){return requestAnimationFrame((function(){return r()}))}))},A=function(r){document.addEventListener("visibilitychange",(function(){document.visibilityState==="hidden"&&r()}))},H=function(r){var t=!1;return function(){t||(r(),t=!0)}},v=-1,Y=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},S=function(r){document.visibilityState==="hidden"&&v>-1&&(v=r.type==="visibilitychange"?r.timeStamp:0,St())},J=function(){addEventListener("visibilitychange",S,!0),addEventListener("prerenderingchange",S,!0)},St=function(){removeEventListener("visibilitychange",S,!0),removeEventListener("prerenderingchange",S,!0)},it=function(){return v<0&&(v=Y(),J(),g((function(){setTimeout((function(){v=Y(),J()}),0)}))),{get firstHiddenTime(){return v}}},P=function(r){document.prerendering?addEventListener("prerenderingchange",(function(){return r()}),!0):r()},Q=[1800,3e3],G=function(r,t){t=t||{},P((function(){var e,n=it(),i=m("FCP"),o=E("paint",(function(s){s.forEach((function(a){a.name==="first-contentful-paint"&&(o.disconnect(),a.startTime<n.firstHiddenTime&&(i.value=Math.max(a.startTime-M(),0),i.entries.push(a),e(!0)))}))}));o&&(e=f(r,i,Q,t.reportAllChanges),g((function(s){i=m("FCP"),e=f(r,i,Q,t.reportAllChanges),F((function(){i.value=performance.now()-s.timeStamp,e(!0)}))})))}))},Z=[.1,.25],ot=function(r,t){t=t||{},G(H((function(){var e,n=m("CLS",0),i=0,o=[],s=function(u){u.forEach((function(c){if(!c.hadRecentInput){var y=o[0],ht=o[o.length-1];i&&c.startTime-ht.startTime<1e3&&c.startTime-y.startTime<5e3?(i+=c.value,o.push(c)):(i=c.value,o=[c])}})),i>n.value&&(n.value=i,n.entries=o,e())},a=E("layout-shift",s);a&&(e=f(r,n,Z,t.reportAllChanges),A((function(){s(a.takeRecords()),e(!0)})),g((function(){i=0,n=m("CLS",0),e=f(r,n,Z,t.reportAllChanges),F((function(){return e()}))})),setTimeout(e,0))})))},st=0,N=1/0,C=0,Mt=function(r){r.forEach((function(t){t.interactionId&&(N=Math.min(N,t.interactionId),C=Math.max(C,t.interactionId),st=C?(C-N)/7+1:0)}))},at=function(){return _?st:performance.interactionCount||0},At=function(){"interactionCount"in performance||_||(_=E("event",Mt,{type:"event",buffered:!0,durationThreshold:0}))},p=[],V=new Map,ut=0,Pt=function(){var r=Math.min(p.length-1,Math.floor((at()-ut)/50));return p[r]},Lt=[],Dt=function(r){if(Lt.forEach((function(i){return i(r)})),r.interactionId||r.entryType==="first-input"){var t=p[p.length-1],e=V.get(r.interactionId);if(e||p.length<10||r.duration>t.latency){if(e)r.duration>e.latency?(e.entries=[r],e.latency=r.duration):r.duration===e.latency&&r.startTime===e.entries[0].startTime&&e.entries.push(r);else{var n={id:r.interactionId,latency:r.duration,entries:[r]};V.set(n.id,n),p.push(n)}p.sort((function(i,o){return o.latency-i.latency})),p.length>10&&p.splice(10).forEach((function(i){return V.delete(i.id)}))}}},ct=function(r){var t=self.requestIdleCallback||self.setTimeout,e=-1;return r=H(r),document.visibilityState==="hidden"?r():(e=t(r),A(r)),e},tt=[200,500],lt=function(r,t){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(t=t||{},P((function(){var e;At();var n,i=m("INP"),o=function(a){ct((function(){a.forEach(Dt);var u=Pt();u&&u.latency!==i.value&&(i.value=u.latency,i.entries=u.entries,n())}))},s=E("event",o,{durationThreshold:(e=t.durationThreshold)!==null&&e!==void 0?e:40});n=f(r,i,tt,t.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),A((function(){o(s.takeRecords()),n(!0)})),g((function(){ut=at(),p.length=0,V.clear(),i=m("INP"),n=f(r,i,tt,t.reportAllChanges)})))})))},et=[2500,4e3],k={},dt=function(r,t){t=t||{},P((function(){var e,n=it(),i=m("LCP"),o=function(u){t.reportAllChanges||(u=u.slice(-1)),u.forEach((function(c){c.startTime<n.firstHiddenTime&&(i.value=Math.max(c.startTime-M(),0),i.entries=[c],e())}))},s=E("largest-contentful-paint",o);if(s){e=f(r,i,et,t.reportAllChanges);var a=H((function(){k[i.id]||(o(s.takeRecords()),s.disconnect(),k[i.id]=!0,e(!0))}));["keydown","click"].forEach((function(u){addEventListener(u,(function(){return ct(a)}),{once:!0,capture:!0})})),A(a),g((function(u){i=m("LCP"),e=f(r,i,et,t.reportAllChanges),F((function(){i.value=performance.now()-u.timeStamp,k[i.id]=!0,e(!0)}))}))}}))},rt=[800,1800],Ot=function r(t){document.prerendering?P((function(){return r(t)})):document.readyState!=="complete"?addEventListener("load",(function(){return r(t)}),!0):setTimeout(t,0)},pt=function(r,t){t=t||{};var e=m("TTFB"),n=f(r,e,rt,t.reportAllChanges);Ot((function(){var i=x();i&&(e.value=Math.max(i.responseStart-M(),0),e.entries=[i],n(!0),g((function(){e=m("TTFB",0),(n=f(r,e,rt,t.reportAllChanges))(!0)})))}))};var Nt={LCP:"lcpMs",FCP:"fcpMs",TTFB:"ttfbMs"},mt=()=>({lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null}),kt=r=>Math.round(r*1e4)/1e4,L=class{constructor(t){this.host=t;this.initial=null;this.current=null;this.early=mt();this.stopped=!1;var e;this.layoutShifts=typeof PerformanceObserver!="undefined"&&((e=PerformanceObserver.supportedEntryTypes)!=null?e:[]).includes("layout-shift")}start(){let t=n=>{try{this.report(n)}catch{this.host.drop()}},e={reportAllChanges:!0};dt(t,e),G(t,e),pt(t,e),lt(t,e),ot(t,e)}stop(){this.stopped=!0}pageView(t){var i;if(((i=this.current)==null?void 0:i.pageViewId)===t)return;let e=this.initial?mt():this.early;this.layoutShifts&&(e.cls=0);let n={pageViewId:t,values:e,dirty:Object.values(e).some(o=>o!==null)};this.initial||(this.initial=n),this.current=n}flush(){this.stopped||(this.send(this.initial),this.current!==this.initial&&this.send(this.current))}report(t){var i,o;if(this.stopped)return;let e=Nt[t.name];if(e){let s=t.navigationType==="back-forward-cache"?this.current:this.initial,a=s?s.values:this.early;a[e]=Math.round(t.value),s&&(s.dirty=!0);return}let n=this.current;n&&(t.name==="INP"?(n.values.inpMs=Math.max((i=n.values.inpMs)!=null?i:0,Math.round(t.value)),n.dirty=!0):t.name==="CLS"&&t.delta>0&&(n.values.cls=kt(((o=n.values.cls)!=null?o:0)+t.delta),n.dirty=!0))}send(t){!t||!t.dirty||(t.dirty=!1,this.host.record({id:l(),type:"vitals",pageViewId:t.pageViewId,...t.values}))}};var D=class{constructor(t){this.timings=new b(t),this.vitals=new L(t),this.longTasks=new I(t)}annotate(t){this.longTasks.annotate(t)}pageViewSent(t){this.timings.pageView(t),this.vitals.pageView(t.id),t.durationMs!==null&&this.vitals.flush()}hidden(){this.vitals.flush()}install(){this.vitals.start();let t=this.longTasks.start();return()=>{this.vitals.stop(),t()}}};var _t={IMG:"src",SCRIPT:"src",LINK:"href",AUDIO:"src",VIDEO:"src",SOURCE:"src",TRACK:"src",IFRAME:"src",EMBED:"src",INPUT:"src",OBJECT:"data"},xt=r=>{if(!(r instanceof Element))return null;let t=_t[r.tagName];if(!t)return null;let n=r.currentSrc||r.getAttribute(t),i=n?B(n):null;return i&&(i.protocol==="http:"||i.protocol==="https:")?i.href:null},ft=r=>h(window,"error",t=>{try{let e=xt(t.target);if(e===null)return;let n=W(r,"RESOURCE","GET",e,Date.now(),null);n.outcome="NETWORK_ERROR",r.record(n)}catch{r.drop()}},!0);var Ae=r=>{let{instrument:t}=r,e={pageViewId:t.pageViewId,resolveRoute:r.resolveRoute,record:s=>t.record(s),drop:t.drop,describe:r.describe},n=new D(e),i=new R(e),o=[n.install(),i.start(),ft(t),$(t),...r.captureConsole?[q(t)]:[]];return{perf:n,frustration:i,teardown:()=>o.reverse().forEach(s=>{try{s()}catch{t.drop()}})}};export{Ae as installDeferred};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIZ7REN7Ejs = require('./chunk-IZ7REN7E.js');var _chunkUZZNGXXEjs = require('./chunk-UZZNGXXE.js');var vt=1024,gt=50,q=r=>{let t=[["error","error"],["warn","warn"]],e=null,n=0,i=t.map(([o,s])=>{let a=console[o],u=(...c)=>{try{let y=r.pageViewId();y!==e&&(e=y,n=0),n+=1,n>gt?r.drop():r.record({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"console",pageViewId:y,occurredAt:_chunkUZZNGXXEjs.g.call(void 0, Date.now()),level:s,message:_chunkUZZNGXXEjs.l.call(void 0, c.map(_chunkUZZNGXXEjs.i).join(" "),vt)})}catch (e2){r.drop()}a.apply(console,c)};return console[o]=u,()=>{console[o]===u&&(console[o]=a)}});return()=>i.forEach(o=>o())};var yt=/^[a-z][a-z0-9-]{0,31}$/,Tt=r=>{try{let e=new URL(r);if(e.host)return`${e.protocol}//${e.host}`}catch (e3){}let t=r.trim().toLowerCase().replace(/:.*$/,"");return yt.test(t)?t:null},$=r=>{let t=null,e=new Set;return _chunkUZZNGXXEjs.j.call(void 0, document,"securitypolicyviolation",n=>{var i;try{let o=r.pageViewId();o!==t&&(t=o,e=new Set);let s=n.effectiveDirective||n.violatedDirective,a=Tt((i=n.blockedURI)!=null?i:""),u=`${s}${a!=null?a:""}`;if(!s||e.has(u))return;e.add(u),r.record({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"cspViolation",pageViewId:o,occurredAt:_chunkUZZNGXXEjs.g.call(void 0, Date.now()),effectiveDirective:s,blockedUri:a,sourceFile:n.sourceFile||null,lineNumber:n.lineNumber||null,disposition:n.disposition==="report"?"report":"enforce"})}catch (e4){r.drop()}},!0)};var w=1e3,Et=3,wt='button,a,[role="button"],input[type="submit"]',R=class{constructor(t){this.host=t;this.last=null;this.burst=[];this.raged=!1;this.activity=0;this.watched=new Set;this.observer=null}start(){typeof MutationObserver!="undefined"&&(this.observer=new MutationObserver(()=>this.notifyActivity()));let t=[_chunkUZZNGXXEjs.j.call(void 0, window,"click",e=>{try{e.target instanceof Element&&this.click(e.target)}catch (e5){this.host.drop()}},!0),_chunkUZZNGXXEjs.j.call(void 0, window,"pagehide",()=>this.cancel())];return()=>{t.forEach(e=>e()),this.cancel(),this.observer=null}}notifyActivity(){this.activity+=1}notifyError(){let t=this.last;!t||t.errored||Date.now()-t.at>w||(t.errored=!0,this.settle(t),this.emit(t,"ERROR_CLICK"))}click(t){let e=Date.now(),n=this.last,o=n!==null&&n.element===t&&e-n.at<=w;o&&this.settle(n),this.burst=o?[...this.burst.filter(a=>e-a<=w),e]:[e],o||(this.raged=!1);let s={element:t,at:e,pageViewId:this.host.pageViewId(),route:this.host.resolveRoute(),activity:this.activity,errored:!1,timer:null};this.last=s,this.burst.length>=Et&&!this.raged&&(this.raged=!0,this.emit(s,"RAGE_CLICK")),!o&&t.closest(wt)&&this.watch(s)}watch(t){this.watched.size===0&&this.observer&&this.observer.observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),this.watched.add(t),t.timer=setTimeout(()=>{try{this.settle(t),t.activity===this.activity&&!t.errored&&this.emit(t,"DEAD_CLICK")}catch (e6){this.host.drop()}},w)}settle(t){var e;t.timer!==null&&(clearTimeout(t.timer),t.timer=null),this.watched.delete(t)&&this.watched.size===0&&((e=this.observer)==null||e.disconnect())}cancel(){this.watched.forEach(t=>this.settle(t)),this.last=null,this.burst=[],this.raged=!1}emit(t,e){this.host.record({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"frustration",pageViewId:t.pageViewId,occurredAt:_chunkUZZNGXXEjs.g.call(void 0, t.at),frustrationType:e,route:t.route,element:this.host.describe(t.element)})}};var Rt=50,It=1e3,bt=(r,t)=>{let e=typeof performance=="undefined"?NaN:performance.timeOrigin;return Number.isFinite(e)&&e>0&&Number.isFinite(r)?e+r:Date.now()-t},Ct=()=>{var t;if(typeof PerformanceObserver=="undefined")return null;let r=(t=PerformanceObserver.supportedEntryTypes)!=null?t:[];return r.includes("long-animation-frame")?"long-animation-frame":r.includes("longtask")?"longtask":null},I=class{constructor(t){this.host=t;this.page=null}start(){let t=Ct();if(!t)return()=>{};let e=new PerformanceObserver(n=>{try{n.getEntries().forEach(i=>this.add(i.duration,i.startTime))}catch (e7){this.host.drop()}});return e.observe({type:t,buffered:!0}),()=>e.disconnect()}annotate(t){var e;((e=this.page)==null?void 0:e.id)===t.id&&(t.longTaskCount=this.page.count,t.longTaskTotalMs=Math.round(this.page.totalMs))}add(t,e){var i;let n=this.host.pageViewId();!n||!(t>=Rt)||(((i=this.page)==null?void 0:i.id)!==n&&(this.page={id:n,count:0,totalMs:0}),this.page.count+=1,this.page.totalMs+=t,t>=It&&this.host.record({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"longTask",pageViewId:n,route:this.host.resolveRoute(),startedAt:_chunkUZZNGXXEjs.g.call(void 0, bt(e,t)),durationMs:Math.round(t)}))}};var Vt=64,z=20,O=r=>typeof r=="string"&&r.length>0&&r.length<=Vt,X=()=>{let r=typeof performance=="undefined"?NaN:performance.timeOrigin;return Number.isFinite(r)&&r>0&&r<=Date.now()?r:null},b=class{constructor(t){this.host=t;this.page=null;this.pending=[];this.durations=new Map}pageView(t){var o,s;if(((o=this.page)==null?void 0:o.id)===t.id)return;let e=this.page===null,n=(s=e?X():null)!=null?s:Date.parse(t.startedAt);this.page={id:t.id,origin:n,count:0};for(let[a,u]of this.durations)e&&u.pageViewId===null?u.pageViewId=t.id:this.durations.delete(a);let i=this.pending;this.pending=[],i.forEach(a=>this.send(a))}addTiming(t,e=Date.now()){if(!O(t)){this.host.drop();return}let n=this.page?this.page.origin:X();if(n===null){this.host.drop();return}this.send({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"timing",occurredAt:_chunkUZZNGXXEjs.g.call(void 0, e),name:t,kind:"TIMING",valueMs:Math.max(0,Math.round(e-n))})}startDuration(t,e,n=Date.now()){var o,s;if(!O(t)){this.host.drop();return}let i={startedAt:n,pageViewId:(s=(o=this.page)==null?void 0:o.id)!=null?s:null};if(e!==void 0){let a=_chunkIZ7REN7Ejs.a.call(void 0, {},e,this.host.drop);Object.keys(a).length>0&&(i.attributes=a)}this.durations.set(t,i)}stopDuration(t,e=Date.now()){let n=O(t)?this.durations.get(t):void 0;if(!n){this.host.drop();return}this.durations.delete(t),this.send({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"timing",occurredAt:_chunkUZZNGXXEjs.g.call(void 0, n.startedAt),name:t,kind:"DURATION",valueMs:Math.max(0,Math.round(e-n.startedAt)),...n.attributes?{attributes:n.attributes}:{}})}send(t){if(!this.page){this.pending.length<z?this.pending.push(t):this.host.drop();return}if(this.page.count>=z){this.host.drop();return}this.page.count+=1,this.host.record({...t,pageViewId:this.page.id})}};var _;var nt=-1,g=function(r){addEventListener("pageshow",(function(t){t.persisted&&(nt=t.timeStamp,r(t))}),!0)},x=function(){var r=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(r&&r.responseStart>0&&r.responseStart<performance.now())return r},M=function(){var r=x();return r&&r.activationStart||0},m=function(r,t){var e=x(),n="navigate";return nt>=0?n="back-forward-cache":e&&(document.prerendering||M()>0?n="prerender":document.wasDiscarded?n="restore":e.type&&(n=e.type.replace(/_/g,"-"))),{name:r,value:t===void 0?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:n}},E=function(r,t,e){try{if(PerformanceObserver.supportedEntryTypes.includes(r)){var n=new PerformanceObserver((function(i){Promise.resolve().then((function(){t(i.getEntries())}))}));return n.observe(Object.assign({type:r,buffered:!0},e||{})),n}}catch (e8){}},f=function(r,t,e,n){var i,o;return function(s){t.value>=0&&(s||n)&&((o=t.value-(i||0))||i===void 0)&&(i=t.value,t.delta=o,t.rating=(function(a,u){return a>u[1]?"poor":a>u[0]?"needs-improvement":"good"})(t.value,e),r(t))}},F=function(r){requestAnimationFrame((function(){return requestAnimationFrame((function(){return r()}))}))},A=function(r){document.addEventListener("visibilitychange",(function(){document.visibilityState==="hidden"&&r()}))},H=function(r){var t=!1;return function(){t||(r(),t=!0)}},v=-1,Y=function(){return document.visibilityState!=="hidden"||document.prerendering?1/0:0},S=function(r){document.visibilityState==="hidden"&&v>-1&&(v=r.type==="visibilitychange"?r.timeStamp:0,St())},J=function(){addEventListener("visibilitychange",S,!0),addEventListener("prerenderingchange",S,!0)},St=function(){removeEventListener("visibilitychange",S,!0),removeEventListener("prerenderingchange",S,!0)},it=function(){return v<0&&(v=Y(),J(),g((function(){setTimeout((function(){v=Y(),J()}),0)}))),{get firstHiddenTime(){return v}}},P=function(r){document.prerendering?addEventListener("prerenderingchange",(function(){return r()}),!0):r()},Q=[1800,3e3],G=function(r,t){t=t||{},P((function(){var e,n=it(),i=m("FCP"),o=E("paint",(function(s){s.forEach((function(a){a.name==="first-contentful-paint"&&(o.disconnect(),a.startTime<n.firstHiddenTime&&(i.value=Math.max(a.startTime-M(),0),i.entries.push(a),e(!0)))}))}));o&&(e=f(r,i,Q,t.reportAllChanges),g((function(s){i=m("FCP"),e=f(r,i,Q,t.reportAllChanges),F((function(){i.value=performance.now()-s.timeStamp,e(!0)}))})))}))},Z=[.1,.25],ot=function(r,t){t=t||{},G(H((function(){var e,n=m("CLS",0),i=0,o=[],s=function(u){u.forEach((function(c){if(!c.hadRecentInput){var y=o[0],ht=o[o.length-1];i&&c.startTime-ht.startTime<1e3&&c.startTime-y.startTime<5e3?(i+=c.value,o.push(c)):(i=c.value,o=[c])}})),i>n.value&&(n.value=i,n.entries=o,e())},a=E("layout-shift",s);a&&(e=f(r,n,Z,t.reportAllChanges),A((function(){s(a.takeRecords()),e(!0)})),g((function(){i=0,n=m("CLS",0),e=f(r,n,Z,t.reportAllChanges),F((function(){return e()}))})),setTimeout(e,0))})))},st=0,N=1/0,C=0,Mt=function(r){r.forEach((function(t){t.interactionId&&(N=Math.min(N,t.interactionId),C=Math.max(C,t.interactionId),st=C?(C-N)/7+1:0)}))},at=function(){return _?st:performance.interactionCount||0},At=function(){"interactionCount"in performance||_||(_=E("event",Mt,{type:"event",buffered:!0,durationThreshold:0}))},p=[],V=new Map,ut=0,Pt=function(){var r=Math.min(p.length-1,Math.floor((at()-ut)/50));return p[r]},Lt=[],Dt=function(r){if(Lt.forEach((function(i){return i(r)})),r.interactionId||r.entryType==="first-input"){var t=p[p.length-1],e=V.get(r.interactionId);if(e||p.length<10||r.duration>t.latency){if(e)r.duration>e.latency?(e.entries=[r],e.latency=r.duration):r.duration===e.latency&&r.startTime===e.entries[0].startTime&&e.entries.push(r);else{var n={id:r.interactionId,latency:r.duration,entries:[r]};V.set(n.id,n),p.push(n)}p.sort((function(i,o){return o.latency-i.latency})),p.length>10&&p.splice(10).forEach((function(i){return V.delete(i.id)}))}}},ct=function(r){var t=self.requestIdleCallback||self.setTimeout,e=-1;return r=H(r),document.visibilityState==="hidden"?r():(e=t(r),A(r)),e},tt=[200,500],lt=function(r,t){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(t=t||{},P((function(){var e;At();var n,i=m("INP"),o=function(a){ct((function(){a.forEach(Dt);var u=Pt();u&&u.latency!==i.value&&(i.value=u.latency,i.entries=u.entries,n())}))},s=E("event",o,{durationThreshold:(e=t.durationThreshold)!==null&&e!==void 0?e:40});n=f(r,i,tt,t.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),A((function(){o(s.takeRecords()),n(!0)})),g((function(){ut=at(),p.length=0,V.clear(),i=m("INP"),n=f(r,i,tt,t.reportAllChanges)})))})))},et=[2500,4e3],k={},dt=function(r,t){t=t||{},P((function(){var e,n=it(),i=m("LCP"),o=function(u){t.reportAllChanges||(u=u.slice(-1)),u.forEach((function(c){c.startTime<n.firstHiddenTime&&(i.value=Math.max(c.startTime-M(),0),i.entries=[c],e())}))},s=E("largest-contentful-paint",o);if(s){e=f(r,i,et,t.reportAllChanges);var a=H((function(){k[i.id]||(o(s.takeRecords()),s.disconnect(),k[i.id]=!0,e(!0))}));["keydown","click"].forEach((function(u){addEventListener(u,(function(){return ct(a)}),{once:!0,capture:!0})})),A(a),g((function(u){i=m("LCP"),e=f(r,i,et,t.reportAllChanges),F((function(){i.value=performance.now()-u.timeStamp,k[i.id]=!0,e(!0)}))}))}}))},rt=[800,1800],Ot=function r(t){document.prerendering?P((function(){return r(t)})):document.readyState!=="complete"?addEventListener("load",(function(){return r(t)}),!0):setTimeout(t,0)},pt=function(r,t){t=t||{};var e=m("TTFB"),n=f(r,e,rt,t.reportAllChanges);Ot((function(){var i=x();i&&(e.value=Math.max(i.responseStart-M(),0),e.entries=[i],n(!0),g((function(){e=m("TTFB",0),(n=f(r,e,rt,t.reportAllChanges))(!0)})))}))};var Nt={LCP:"lcpMs",FCP:"fcpMs",TTFB:"ttfbMs"},mt=()=>({lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null}),kt=r=>Math.round(r*1e4)/1e4,L=class{constructor(t){this.host=t;this.initial=null;this.current=null;this.early=mt();this.stopped=!1;var e;this.layoutShifts=typeof PerformanceObserver!="undefined"&&((e=PerformanceObserver.supportedEntryTypes)!=null?e:[]).includes("layout-shift")}start(){let t=n=>{try{this.report(n)}catch (e9){this.host.drop()}},e={reportAllChanges:!0};dt(t,e),G(t,e),pt(t,e),lt(t,e),ot(t,e)}stop(){this.stopped=!0}pageView(t){var i;if(((i=this.current)==null?void 0:i.pageViewId)===t)return;let e=this.initial?mt():this.early;this.layoutShifts&&(e.cls=0);let n={pageViewId:t,values:e,dirty:Object.values(e).some(o=>o!==null)};this.initial||(this.initial=n),this.current=n}flush(){this.stopped||(this.send(this.initial),this.current!==this.initial&&this.send(this.current))}report(t){var i,o;if(this.stopped)return;let e=Nt[t.name];if(e){let s=t.navigationType==="back-forward-cache"?this.current:this.initial,a=s?s.values:this.early;a[e]=Math.round(t.value),s&&(s.dirty=!0);return}let n=this.current;n&&(t.name==="INP"?(n.values.inpMs=Math.max((i=n.values.inpMs)!=null?i:0,Math.round(t.value)),n.dirty=!0):t.name==="CLS"&&t.delta>0&&(n.values.cls=kt(((o=n.values.cls)!=null?o:0)+t.delta),n.dirty=!0))}send(t){!t||!t.dirty||(t.dirty=!1,this.host.record({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"vitals",pageViewId:t.pageViewId,...t.values}))}};var D=class{constructor(t){this.timings=new b(t),this.vitals=new L(t),this.longTasks=new I(t)}annotate(t){this.longTasks.annotate(t)}pageViewSent(t){this.timings.pageView(t),this.vitals.pageView(t.id),t.durationMs!==null&&this.vitals.flush()}hidden(){this.vitals.flush()}install(){this.vitals.start();let t=this.longTasks.start();return()=>{this.vitals.stop(),t()}}};var _t={IMG:"src",SCRIPT:"src",LINK:"href",AUDIO:"src",VIDEO:"src",SOURCE:"src",TRACK:"src",IFRAME:"src",EMBED:"src",INPUT:"src",OBJECT:"data"},xt=r=>{if(!(r instanceof Element))return null;let t=_t[r.tagName];if(!t)return null;let n=r.currentSrc||r.getAttribute(t),i=n?_chunkIZ7REN7Ejs.c.call(void 0, n):null;return i&&(i.protocol==="http:"||i.protocol==="https:")?i.href:null},ft=r=>_chunkUZZNGXXEjs.j.call(void 0, window,"error",t=>{try{let e=xt(t.target);if(e===null)return;let n=_chunkIZ7REN7Ejs.h.call(void 0, r,"RESOURCE","GET",e,Date.now(),null);n.outcome="NETWORK_ERROR",r.record(n)}catch (e10){r.drop()}},!0);var Ae=r=>{let{instrument:t}=r,e={pageViewId:t.pageViewId,resolveRoute:r.resolveRoute,record:s=>t.record(s),drop:t.drop,describe:r.describe},n=new D(e),i=new R(e),o=[n.install(),i.start(),ft(t),$(t),...r.captureConsole?[q(t)]:[]];return{perf:n,frustration:i,teardown:()=>o.reverse().forEach(s=>{try{s()}catch (e11){t.drop()}})}};exports.installDeferred = Ae;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSWUATOHjs = require('./chunk-GSWUATOH.js');require('./chunk-LRYKS5XR.js');require('./chunk-UZZNGXXE.js');exports.MAX_FEEDBACKS_PER_SESSION = _chunkGSWUATOHjs.b; exports.MAX_FEEDBACK_MESSAGE_LENGTH = _chunkGSWUATOHjs.a; exports.feedbackUnavailable = _chunkGSWUATOHjs.c; exports.sendFeedback = _chunkGSWUATOHjs.d; exports.showReportDialog = _chunkGSWUATOHjs.e;
@@ -1 +0,0 @@
1
- import{a,b,c,d,e}from"./chunk-UKLKIMTU.mjs";import"./chunk-QEU2JJHJ.mjs";import"./chunk-AAXB6P4Z.mjs";export{b as MAX_FEEDBACKS_PER_SESSION,a as MAX_FEEDBACK_MESSAGE_LENGTH,c as feedbackUnavailable,d as sendFeedback,e as showReportDialog};
@@ -1 +0,0 @@
1
- import{g as c,l as u,m as d,q as m}from"./chunk-AAXB6P4Z.mjs";var f=100,E=1e4,h=600,y=1e4,v=4096,M=1024,C=16384,b=255,_=6e4,A=s=>typeof s=="number"&&Number.isFinite(s)?Math.min(C,Math.max(M,Math.floor(s))):v,a=s=>s===null?null:s.slice(0,b),p=s=>s===null||typeof s=="string",R=s=>s.type==="request"&&s.kind!=="WEBSOCKET"&&s.kind!=="SSE"&&s.outcome!=="SUCCESS"&&s.outcome!=="ABORTED",g=s=>s.event.outcome!=="SUCCESS"&&s.event.outcome!=="ABORTED",S=class{constructor(t,e){this.options=t;this.host=e;this.states=new Map;this.sessionId=null;this.sessionCount=0;this.maxBytes=A(t.maxMessageBytes),this.sendAll=t.mode==="ALL"}message(t,e){let n=this.stateOf(t);if(!n.matched)return;let o=this.build(t,e);if(this.sendAll||e.at<=n.followUntil){this.emit(n,o);return}n.buffer.push(o),n.buffer.length>f&&n.buffer.shift()}closed(t,e){this.states.has(t)&&g(t)&&this.anomaly(e),this.states.delete(t)}observe(t){(t.type==="frustration"||R(t))&&this.anomaly(Date.now())}anomaly(t){for(let e of this.states.values()){if(!e.matched)continue;let n=e.buffer;e.buffer=[],n.forEach(o=>this.emit(e,o)),e.followUntil=t+E}}stateOf(t){let e=this.states.get(t);return e||(e={connection:t,matched:this.matches(t.event.url),buffer:[],followUntil:0,windowStart:0,windowCount:0},this.states.set(t,e)),e}matches(t){let{urls:e}=this.options;return Array.isArray(e)&&e.some(n=>n instanceof RegExp?(n.lastIndex=0,n.test(t)):typeof n=="string"&&n.length>0&&t.startsWith(n))}build(t,e){let{data:n}=e,o=typeof n=="string",r=o?u(n,this.maxBytes):null,i=null;return o||(i=typeof Blob!="undefined"&&n instanceof Blob?"blob":"arraybuffer"),{id:m(),type:"socketMessage",connectionId:t.event.id,occurredAt:c(e.at),direction:e.direction,sizeBytes:d(n),truncated:o&&r.length<n.length,eventName:a(e.eventName),eventId:a(e.eventId),binaryType:i,payload:r}}emit(t,e){var i;let n=this.redact(e);if(!n)return;let o=this.host.sessionId();o!==this.sessionId&&(this.sessionId=o,this.sessionCount=0);let r=Date.parse(n.occurredAt);if(r-t.windowStart>=_&&(t.windowStart=r,t.windowCount=0),t.windowCount>=h||this.sessionCount>=y){let{event:l}=t.connection;l.droppedMessages=((i=l.droppedMessages)!=null?i:0)+1,t.connection.dirty=!0;return}t.windowCount+=1,this.sessionCount+=1,this.host.record(n)}redact(t){let{redact:e}=this.options;if(typeof e!="function")return t;let n;try{n=e({...t})}catch{return this.host.drop(),null}if(n===null)return null;let o=n,r=t.binaryType!==null;if(!o||typeof o!="object"||(r?o.payload!==null:typeof o.payload!="string")||!p(o.eventName)||!p(o.eventId))return this.host.drop(),null;let i=r?null:u(o.payload,this.maxBytes);return{...t,payload:i,truncated:t.truncated||i!==null&&i!==o.payload,eventName:a(o.eventName),eventId:a(o.eventId)}}};export{E as ANOMALY_FOLLOW_UP_MS,v as DEFAULT_MAX_MESSAGE_BYTES,C as MAX_MAX_MESSAGE_BYTES,h as MAX_SOCKET_MESSAGES_PER_MINUTE,y as MAX_SOCKET_MESSAGES_PER_SESSION,M as MIN_MAX_MESSAGE_BYTES,f as SOCKET_MESSAGE_BUFFER_SIZE,S as SocketMessageCapture};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUZZNGXXEjs = require('./chunk-UZZNGXXE.js');var f=100,E= exports.ANOMALY_FOLLOW_UP_MS =1e4,h= exports.MAX_SOCKET_MESSAGES_PER_MINUTE =600,y= exports.MAX_SOCKET_MESSAGES_PER_SESSION =1e4,v= exports.DEFAULT_MAX_MESSAGE_BYTES =4096,M= exports.MIN_MAX_MESSAGE_BYTES =1024,C= exports.MAX_MAX_MESSAGE_BYTES =16384,b=255,_=6e4,A=s=>typeof s=="number"&&Number.isFinite(s)?Math.min(C,Math.max(M,Math.floor(s))):v,a=s=>s===null?null:s.slice(0,b),p=s=>s===null||typeof s=="string",R=s=>s.type==="request"&&s.kind!=="WEBSOCKET"&&s.kind!=="SSE"&&s.outcome!=="SUCCESS"&&s.outcome!=="ABORTED",g=s=>s.event.outcome!=="SUCCESS"&&s.event.outcome!=="ABORTED",S= exports.SocketMessageCapture =class{constructor(t,e){this.options=t;this.host=e;this.states=new Map;this.sessionId=null;this.sessionCount=0;this.maxBytes=A(t.maxMessageBytes),this.sendAll=t.mode==="ALL"}message(t,e){let n=this.stateOf(t);if(!n.matched)return;let o=this.build(t,e);if(this.sendAll||e.at<=n.followUntil){this.emit(n,o);return}n.buffer.push(o),n.buffer.length>f&&n.buffer.shift()}closed(t,e){this.states.has(t)&&g(t)&&this.anomaly(e),this.states.delete(t)}observe(t){(t.type==="frustration"||R(t))&&this.anomaly(Date.now())}anomaly(t){for(let e of this.states.values()){if(!e.matched)continue;let n=e.buffer;e.buffer=[],n.forEach(o=>this.emit(e,o)),e.followUntil=t+E}}stateOf(t){let e=this.states.get(t);return e||(e={connection:t,matched:this.matches(t.event.url),buffer:[],followUntil:0,windowStart:0,windowCount:0},this.states.set(t,e)),e}matches(t){let{urls:e}=this.options;return Array.isArray(e)&&e.some(n=>n instanceof RegExp?(n.lastIndex=0,n.test(t)):typeof n=="string"&&n.length>0&&t.startsWith(n))}build(t,e){let{data:n}=e,o=typeof n=="string",r=o?_chunkUZZNGXXEjs.l.call(void 0, n,this.maxBytes):null,i=null;return o||(i=typeof Blob!="undefined"&&n instanceof Blob?"blob":"arraybuffer"),{id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"socketMessage",connectionId:t.event.id,occurredAt:_chunkUZZNGXXEjs.g.call(void 0, e.at),direction:e.direction,sizeBytes:_chunkUZZNGXXEjs.m.call(void 0, n),truncated:o&&r.length<n.length,eventName:a(e.eventName),eventId:a(e.eventId),binaryType:i,payload:r}}emit(t,e){var i;let n=this.redact(e);if(!n)return;let o=this.host.sessionId();o!==this.sessionId&&(this.sessionId=o,this.sessionCount=0);let r=Date.parse(n.occurredAt);if(r-t.windowStart>=_&&(t.windowStart=r,t.windowCount=0),t.windowCount>=h||this.sessionCount>=y){let{event:l}=t.connection;l.droppedMessages=((i=l.droppedMessages)!=null?i:0)+1,t.connection.dirty=!0;return}t.windowCount+=1,this.sessionCount+=1,this.host.record(n)}redact(t){let{redact:e}=this.options;if(typeof e!="function")return t;let n;try{n=e({...t})}catch (e2){return this.host.drop(),null}if(n===null)return null;let o=n,r=t.binaryType!==null;if(!o||typeof o!="object"||(r?o.payload!==null:typeof o.payload!="string")||!p(o.eventName)||!p(o.eventId))return this.host.drop(),null;let i=r?null:_chunkUZZNGXXEjs.l.call(void 0, o.payload,this.maxBytes);return{...t,payload:i,truncated:t.truncated||i!==null&&i!==o.payload,eventName:a(o.eventName),eventId:a(o.eventId)}}};exports.ANOMALY_FOLLOW_UP_MS = E; exports.DEFAULT_MAX_MESSAGE_BYTES = v; exports.MAX_MAX_MESSAGE_BYTES = C; exports.MAX_SOCKET_MESSAGES_PER_MINUTE = h; exports.MAX_SOCKET_MESSAGES_PER_SESSION = y; exports.MIN_MAX_MESSAGE_BYTES = M; exports.SOCKET_MESSAGE_BUFFER_SIZE = f; exports.SocketMessageCapture = S;