@abyss-project/monitor-browser 1.0.1 → 1.2.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/README.md +91 -0
- package/dist/chunk-AAXB6P4Z.mjs +1 -0
- package/dist/chunk-GSWUATOH.js +1 -0
- package/dist/chunk-IZ7REN7E.js +1 -0
- package/dist/chunk-LRYKS5XR.js +1 -0
- package/dist/chunk-QEU2JJHJ.mjs +1 -0
- package/dist/chunk-UKLKIMTU.mjs +1 -0
- package/dist/chunk-UO34ZFAC.mjs +1 -0
- package/dist/chunk-UZZNGXXE.js +1 -0
- package/dist/cli/bin.js +150 -0
- package/dist/deferred-6XZ757WK.mjs +1 -0
- package/dist/deferred-PTNDFC5D.js +1 -0
- package/dist/dialog-KZS5WNFT.js +17 -0
- package/dist/dialog-QWESR3KT.mjs +17 -0
- package/dist/index.d.mts +127 -2
- package/dist/index.d.ts +127 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/send-67SJQRSY.js +1 -0
- package/dist/send-WHX2VHVF.mjs +1 -0
- package/dist/socket-messages-VEEQGHB6.mjs +1 -0
- package/dist/socket-messages-WSFNWWG4.js +1 -0
- package/package.json +7 -2
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @abyss-project/monitor-browser
|
|
2
|
+
|
|
3
|
+
SDK navigateur d'AbyssMonitor : mesure de l'expérience réelle (sessions, pages vues, requêtes,
|
|
4
|
+
erreurs JS, web vitals, gels, frustration, actions, feature flags, retours utilisateurs, messages
|
|
5
|
+
WebSocket et SSE). Spécification : `docs/superpowers/specs/2026-10-07-rum-navigateur-design.md`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { AbyssRum } from '@abyss-project/monitor-browser';
|
|
9
|
+
|
|
10
|
+
AbyssRum.init({ apiUrl, applicationId, token, release, instrumentedOrigins });
|
|
11
|
+
AbyssRum.setActor(user.id);
|
|
12
|
+
AbyssRum.addAction('checkout.submit', { items: 3 });
|
|
13
|
+
AbyssRum.addFeatureFlagEvaluation('new-checkout', true);
|
|
14
|
+
await AbyssRum.sendFeedback({ message, email }); // rejet : RumFeedbackError, champ `code`
|
|
15
|
+
AbyssRum.showReportDialog({ locale: 'fr' });
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`onFeedbackSent` (option de `init`) est appelée une fois par retour stocké par l'API (réponse 2xx),
|
|
19
|
+
qu'il vienne de `sendFeedback` ou de la fenêtre `showReportDialog`, jamais sur un échec. Elle reçoit
|
|
20
|
+
`{ sessionId, offsetMs, route, message, email }`, soit les valeurs de l'événement envoyé (après
|
|
21
|
+
`beforeSend` et masquage de la route). Une exception du rappel est avalée et comptée dans
|
|
22
|
+
`droppedEvents` ; elle ne rejette jamais `sendFeedback`.
|
|
23
|
+
|
|
24
|
+
Aucun appel ne lève d'erreur vers l'application : une erreur interne est comptée dans
|
|
25
|
+
`droppedEvents`. Seule `sendFeedback` rejette sa promesse, avec un code lisible
|
|
26
|
+
(`RumFeedbackErrorCode`).
|
|
27
|
+
|
|
28
|
+
## Chargement en plusieurs morceaux (§4)
|
|
29
|
+
|
|
30
|
+
Le paquet est construit avec le découpage de code de tsup, en ESM et en CJS. Le morceau d'entrée
|
|
31
|
+
ne contient que ce qui doit capter dès `init` ou dès la configuration : session, transport,
|
|
32
|
+
configuration distante, échantillonnage, pages vues, requêtes `fetch` et XHR, WebSocket et SSE
|
|
33
|
+
(compteurs), erreurs JS, actions, feature flags. Le reste est chargé par `import()` :
|
|
34
|
+
|
|
35
|
+
| Morceau | Contenu | Chargé |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `deferred` | web vitals (`web-vitals`), gels, mesures personnalisées, ressources en échec, violations CSP, frustration, console | après la réponse de configuration, si le RUM est actif |
|
|
38
|
+
| `socket-messages` | contenu des messages WebSocket et SSE (§38) | après la configuration, seulement avec l'option `captureSocketMessages`, le panneau `socketMessages.enabled` et une session échantillonnée |
|
|
39
|
+
| `send` | envoi d'un retour utilisateur (§37.1) | au premier `sendFeedback` ou `showReportDialog` |
|
|
40
|
+
| `dialog` | fenêtre de signalement, en shadow DOM | à la première ouverture de la fenêtre |
|
|
41
|
+
|
|
42
|
+
Rien n'est perdu pendant le chargement : les web vitals et les gels sont lus dans les entrées
|
|
43
|
+
mises en mémoire par le navigateur (`buffered`), et les mesures personnalisées (`addTiming`,
|
|
44
|
+
`startDuration`, `stopDuration`) restent synchrones pour l'application. Elles sont gardées avec
|
|
45
|
+
l'heure de l'appel, puis rejouées dans l'ordre. Un morceau qui ne se charge pas est compté dans
|
|
46
|
+
`droppedEvents`, ainsi que les appels qui l'attendaient.
|
|
47
|
+
|
|
48
|
+
## Budgets de poids
|
|
49
|
+
|
|
50
|
+
`pnpm test` et `prepublishOnly` lancent `scripts/check-bundle.mjs` après le build. Il vérifie
|
|
51
|
+
d'abord qu'aucun fichier n'importe un paquet ou un module Node : seulement ses propres morceaux.
|
|
52
|
+
Il contrôle ensuite les poids sur les sorties ESM et CJS, en gzip niveau 9. Un morceau est mesuré
|
|
53
|
+
comme ses fichiers mis bout à bout, comme le bundler de l'application les regroupe.
|
|
54
|
+
|
|
55
|
+
| Morceau | Plafond gzip | Ce qui est mesuré |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| entrée | 12 Ko (12 288 octets) | `index` et les morceaux partagés qu'il importe statiquement : tout ce qui se charge au démarrage |
|
|
58
|
+
| `deferred` | 7 Ko | le morceau et les morceaux partagés qu'il est seul à amener |
|
|
59
|
+
| `dialog` | 4 Ko | idem |
|
|
60
|
+
| `socket-messages` | 2 Ko | idem |
|
|
61
|
+
| `send` | 2 Ko | idem |
|
|
62
|
+
|
|
63
|
+
Un nouveau morceau dynamique sans plafond fait échouer la vérification : il faut lui en donner un
|
|
64
|
+
ici et dans `check-bundle.mjs`.
|
|
65
|
+
|
|
66
|
+
Le sous-chemin pur `@abyss-project/monitor/rum` est compilé depuis ses sources TypeScript (alias
|
|
67
|
+
dans `tsup.config.ts`). esbuild remplace alors les valeurs des enums du contrat par leurs
|
|
68
|
+
littéraux et retire ce que le SDK n'utilise pas, ce qu'il ne peut pas faire sur le build CommonJS
|
|
69
|
+
du core.
|
|
70
|
+
|
|
71
|
+
## Capture des messages WebSocket et SSE (§38)
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
AbyssRum.init({
|
|
75
|
+
// …
|
|
76
|
+
captureSocketMessages: {
|
|
77
|
+
urls: ['wss://api.example.com/live', /\/events$/], // une chaîne : préfixe ; une RegExp : test
|
|
78
|
+
mode: RumSocketCaptureMode.ON_ANOMALY, // par défaut
|
|
79
|
+
maxMessageBytes: 4096, // de 1 024 à 16 384
|
|
80
|
+
redact: (message) => ({ ...message, payload: mask(message.payload) }), // null : jeté
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Il faut à la fois l'option dans le code et `socketMessagesEnabled` dans le panneau. En mode
|
|
86
|
+
`ON_ANOMALY`, les 100 derniers messages de chaque connexion sont gardés en mémoire. Ils partent
|
|
87
|
+
quand une anomalie survient pendant que la connexion est ouverte : erreur JS, signal de
|
|
88
|
+
frustration, requête en échec, ou fin anormale d'une connexion (WebSocket fermé en code ≥ 1002,
|
|
89
|
+
SSE en échec). Les messages des 10 secondes suivantes partent aussi. Au-delà de 600 messages par
|
|
90
|
+
minute et par connexion, ou de 10 000 par session, un message est compté dans `droppedMessages`
|
|
91
|
+
sur la connexion, sans être stocké.
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunkLRYKS5XRjs = require('./chunk-LRYKS5XR.js');var _chunkUZZNGXXEjs = require('./chunk-UZZNGXXE.js');var F=2e3,b= exports.b =5,g=255,k=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,i=new Map,A= exports.c =e=>{var t,n;return(n=e.unavailable())!=null?n:((t=i.get(e.sessionId()))!=null?t:0)>=b?"LIMIT_REACHED":null},D=(e,t)=>{let n=t==null?void 0:t.message;if(typeof n!="string"||n.trim().length===0||n.length>F)return"INVALID_MESSAGE";let r=t==null?void 0:t.email,a=null;if(r!=null&&r!==""){let s=typeof r=="string"?r.trim():"";if(s.length>g||!k.test(s))return"INVALID_EMAIL";a=s}let o=Date.now();return{id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"feedback",pageViewId:e.pageViewId(),occurredAt:_chunkUZZNGXXEjs.g.call(void 0, o),offsetMs:Math.max(0,o-e.sessionStartedAt()),route:e.resolveRoute(),message:n,email:a}},v=e=>e>=200&&e<300?null:e===409?"LIMIT_REACHED":e===0||e===429||e>=500?"SEND_FAILED":"REFUSED",y= exports.d =async(e,t)=>{var d,u,c;let n=A(e);if(n!==null)throw new (0, _chunkLRYKS5XRjs.b)(n);let r=D(e,t);if(typeof r=="string")throw new (0, _chunkLRYKS5XRjs.b)(r);let a=e.prepare(r);if(!a)throw new (0, _chunkLRYKS5XRjs.b)("DISCARDED");let o=e.sessionId();i.set(o,((d=i.get(o))!=null?d:0)+1);let s=v(await e.post(a).catch(()=>0));if(s==="SEND_FAILED"?i.set(o,((u=i.get(o))!=null?u:1)-1):s==="LIMIT_REACHED"&&i.set(o,b),s!==null)throw new (0, _chunkLRYKS5XRjs.b)(s);let{offsetMs:R,route:f,message:p,email:I}=a;(c=e.sent)==null||c.call(e,{sessionId:o,offsetMs:R,route:f,message:p,email:I})},H= exports.e =(e,t)=>Promise.resolve().then(() => _interopRequireWildcard(require("./dialog-KZS5WNFT.js"))).then(({openReportDialog:n})=>n(e,t));exports.a = F; exports.b = b; exports.c = A; exports.d = y; exports.e = H;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUZZNGXXEjs = require('./chunk-UZZNGXXE.js');var a=/^[a-zA-Z0-9_.-]{1,64}$/,m=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),p=t=>typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)||typeof t=="string"&&t.length<=256,f= exports.a =(t,e,o,n=30)=>{let r={...t};if(!e||typeof e!="object"||Array.isArray(e))return o(),r;for(let[s,u]of Object.entries(e))!a.test(s)||s==="__proto__"?o():u===null?delete r[s]:!p(u)||!m(r,s)&&Object.keys(r).length>=n?o():r[s]=u;return r};var S=4096,d= exports.c =t=>{try{return new URL(t,window.location.href)}catch (e2){return null}},R= exports.d =t=>{let e=d(t);return e?`${e.protocol==="ws:"?"http:":e.protocol==="wss:"?"https:":e.protocol}//${e.host}`.toLowerCase():null},y= exports.e =(t,e)=>{var o;return t.instrumentedOrigins.includes((o=R(e.href))!=null?o:"")},O= exports.f =t=>{let e=t==null?void 0:t.name;return e==="AbortError"?"ABORTED":e==="TimeoutError"?"TIMEOUT":navigator.onLine===!1?"OFFLINE":"NETWORK_ERROR"},I= exports.g =t=>t>=400?"HTTP_ERROR":"SUCCESS",v= exports.h =(t,e,o,n,r,s)=>({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"request",pageViewId:t.pageViewId(),kind:e,method:o,url:n,startedAt:_chunkUZZNGXXEjs.g.call(void 0, r),status:null,outcome:"SUCCESS",durationMs:null,dnsMs:null,tcpMs:null,tlsMs:null,ttfbMs:null,downloadMs:null,requestId:s,instrumented:s!==null}),w= exports.i =(t,e)=>{let o;try{o=performance.getEntriesByName(t,"resource")}catch (e3){return null}let n=o.filter(r=>performance.timeOrigin+r.startTime>=e-50).pop();return!n||!n.requestStart?null:{dnsMs:_chunkUZZNGXXEjs.h.call(void 0, n.domainLookupStart,n.domainLookupEnd),tcpMs:_chunkUZZNGXXEjs.h.call(void 0, n.connectStart,n.connectEnd),tlsMs:n.secureConnectionStart>0?_chunkUZZNGXXEjs.h.call(void 0, n.secureConnectionStart,n.connectEnd):null,ttfbMs:_chunkUZZNGXXEjs.h.call(void 0, n.requestStart,n.responseStart),downloadMs:_chunkUZZNGXXEjs.h.call(void 0, n.responseStart,n.responseEnd)}};exports.a = f; exports.b = S; exports.c = d; exports.d = R; exports.e = y; exports.f = O; exports.g = I; exports.h = v; exports.i = w;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var A=(D=>(D.FEEDBACK_DISABLED="FEEDBACK_DISABLED",D.NO_SESSION="NO_SESSION",D.INVALID_MESSAGE="INVALID_MESSAGE",D.INVALID_EMAIL="INVALID_EMAIL",D.LIMIT_REACHED="LIMIT_REACHED",D.DISCARDED="DISCARDED",D.REFUSED="REFUSED",D.SEND_FAILED="SEND_FAILED",D))(A||{}),E= exports.b =class extends Error{constructor(I){super(`Feedback not sent: ${I}`);this.code=I;this.name="RumFeedbackError"}};exports.a = A; exports.b = E;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=(D=>(D.FEEDBACK_DISABLED="FEEDBACK_DISABLED",D.NO_SESSION="NO_SESSION",D.INVALID_MESSAGE="INVALID_MESSAGE",D.INVALID_EMAIL="INVALID_EMAIL",D.LIMIT_REACHED="LIMIT_REACHED",D.DISCARDED="DISCARDED",D.REFUSED="REFUSED",D.SEND_FAILED="SEND_FAILED",D))(A||{}),E=class extends Error{constructor(I){super(`Feedback not sent: ${I}`);this.code=I;this.name="RumFeedbackError"}};export{A as a,E as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as m}from"./chunk-QEU2JJHJ.mjs";import{g as l,q as E}from"./chunk-AAXB6P4Z.mjs";var F=2e3,b=5,g=255,k=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,i=new Map,A=e=>{var t,n;return(n=e.unavailable())!=null?n:((t=i.get(e.sessionId()))!=null?t:0)>=b?"LIMIT_REACHED":null},D=(e,t)=>{let n=t==null?void 0:t.message;if(typeof n!="string"||n.trim().length===0||n.length>F)return"INVALID_MESSAGE";let r=t==null?void 0:t.email,a=null;if(r!=null&&r!==""){let s=typeof r=="string"?r.trim():"";if(s.length>g||!k.test(s))return"INVALID_EMAIL";a=s}let o=Date.now();return{id:E(),type:"feedback",pageViewId:e.pageViewId(),occurredAt:l(o),offsetMs:Math.max(0,o-e.sessionStartedAt()),route:e.resolveRoute(),message:n,email:a}},v=e=>e>=200&&e<300?null:e===409?"LIMIT_REACHED":e===0||e===429||e>=500?"SEND_FAILED":"REFUSED",y=async(e,t)=>{var d,u,c;let n=A(e);if(n!==null)throw new m(n);let r=D(e,t);if(typeof r=="string")throw new m(r);let a=e.prepare(r);if(!a)throw new m("DISCARDED");let o=e.sessionId();i.set(o,((d=i.get(o))!=null?d:0)+1);let s=v(await e.post(a).catch(()=>0));if(s==="SEND_FAILED"?i.set(o,((u=i.get(o))!=null?u:1)-1):s==="LIMIT_REACHED"&&i.set(o,b),s!==null)throw new m(s);let{offsetMs:R,route:f,message:p,email:I}=a;(c=e.sent)==null||c.call(e,{sessionId:o,offsetMs:R,route:f,message:p,email:I})},H=(e,t)=>import("./dialog-QWESR3KT.mjs").then(({openReportDialog:n})=>n(e,t));export{F as a,b,A as c,y as d,H as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as c,h as i,q as l}from"./chunk-AAXB6P4Z.mjs";var a=/^[a-zA-Z0-9_.-]{1,64}$/,m=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),p=t=>typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)||typeof t=="string"&&t.length<=256,f=(t,e,o,n=30)=>{let r={...t};if(!e||typeof e!="object"||Array.isArray(e))return o(),r;for(let[s,u]of Object.entries(e))!a.test(s)||s==="__proto__"?o():u===null?delete r[s]:!p(u)||!m(r,s)&&Object.keys(r).length>=n?o():r[s]=u;return r};var S=4096,d=t=>{try{return new URL(t,window.location.href)}catch{return null}},R=t=>{let e=d(t);return e?`${e.protocol==="ws:"?"http:":e.protocol==="wss:"?"https:":e.protocol}//${e.host}`.toLowerCase():null},y=(t,e)=>{var o;return t.instrumentedOrigins.includes((o=R(e.href))!=null?o:"")},O=t=>{let e=t==null?void 0:t.name;return e==="AbortError"?"ABORTED":e==="TimeoutError"?"TIMEOUT":navigator.onLine===!1?"OFFLINE":"NETWORK_ERROR"},I=t=>t>=400?"HTTP_ERROR":"SUCCESS",v=(t,e,o,n,r,s)=>({id:l(),type:"request",pageViewId:t.pageViewId(),kind:e,method:o,url:n,startedAt:c(r),status:null,outcome:"SUCCESS",durationMs:null,dnsMs:null,tcpMs:null,tlsMs:null,ttfbMs:null,downloadMs:null,requestId:s,instrumented:s!==null}),w=(t,e)=>{let o;try{o=performance.getEntriesByName(t,"resource")}catch{return null}let n=o.filter(r=>performance.timeOrigin+r.startTime>=e-50).pop();return!n||!n.requestStart?null:{dnsMs:i(n.domainLookupStart,n.domainLookupEnd),tcpMs:i(n.connectStart,n.connectEnd),tlsMs:n.secureConnectionStart>0?i(n.secureConnectionStart,n.connectEnd):null,ttfbMs:i(n.requestStart,n.responseStart),downloadMs:i(n.responseStart,n.responseEnd)}};export{f as a,S as b,d as c,R as d,y as e,O as f,I as g,v as h,w as i};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/cli/upload.ts
|
|
5
|
+
var import_promises = require("fs/promises");
|
|
6
|
+
var import_node_path = require("path");
|
|
7
|
+
var API_KEY_ENV = "ABYSS_MONITOR_API_KEY";
|
|
8
|
+
var API_KEY_HEADER = "abyss-api-key-application";
|
|
9
|
+
var MAP_EXTENSION = ".map";
|
|
10
|
+
var USAGE = "Usage: abyss-monitor-sourcemaps upload --api <url> --application <id> --release <release> --dir <dist> [--delete-after]";
|
|
11
|
+
var CliError = class extends Error {
|
|
12
|
+
};
|
|
13
|
+
var VALUE_OPTIONS = ["--api", "--application", "--release", "--dir"];
|
|
14
|
+
var parseUpload = (args) => {
|
|
15
|
+
const values = /* @__PURE__ */ new Map();
|
|
16
|
+
let deleteAfter = false;
|
|
17
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
18
|
+
const arg = args[index];
|
|
19
|
+
if (arg === "--delete-after") {
|
|
20
|
+
deleteAfter = true;
|
|
21
|
+
} else if (VALUE_OPTIONS.includes(arg)) {
|
|
22
|
+
const value = args[index + 1];
|
|
23
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
24
|
+
throw new CliError(`${arg} needs a value.
|
|
25
|
+
${USAGE}`);
|
|
26
|
+
}
|
|
27
|
+
values.set(arg, value);
|
|
28
|
+
index += 1;
|
|
29
|
+
} else {
|
|
30
|
+
throw new CliError(`Unknown option ${arg}.
|
|
31
|
+
${USAGE}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const missing = VALUE_OPTIONS.filter((option) => !values.get(option));
|
|
35
|
+
if (missing.length > 0) {
|
|
36
|
+
throw new CliError(`Missing ${missing.join(", ")}.
|
|
37
|
+
${USAGE}`);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
api: values.get("--api"),
|
|
41
|
+
application: values.get("--application"),
|
|
42
|
+
release: values.get("--release"),
|
|
43
|
+
dir: values.get("--dir"),
|
|
44
|
+
deleteAfter
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var findMaps = async (dir) => {
|
|
48
|
+
let entries;
|
|
49
|
+
try {
|
|
50
|
+
entries = await (0, import_promises.readdir)(dir, { recursive: true });
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new CliError(
|
|
53
|
+
`Cannot read ${dir}: ${error instanceof Error ? error.message : String(error)}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return entries.filter((entry) => entry.endsWith(MAP_EXTENSION)).map((entry) => entry.split(import_node_path.sep).join("/")).sort();
|
|
57
|
+
};
|
|
58
|
+
var apiMessage = (body) => {
|
|
59
|
+
try {
|
|
60
|
+
const { error } = JSON.parse(body);
|
|
61
|
+
const detail = error?.params?.validationMessage;
|
|
62
|
+
if (error?.message) {
|
|
63
|
+
return detail ? `${error.message}: ${detail}` : error.message;
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
return body.slice(0, 500);
|
|
68
|
+
};
|
|
69
|
+
var uploadOne = async (options, apiKey, mapPath) => {
|
|
70
|
+
const payload = await (0, import_promises.readFile)((0, import_node_path.join)(options.dir, mapPath));
|
|
71
|
+
const form = new FormData();
|
|
72
|
+
form.append("fileName", mapPath.slice(0, -MAP_EXTENSION.length));
|
|
73
|
+
form.append("file", new Blob([new Uint8Array(payload)]), mapPath.split("/").pop());
|
|
74
|
+
const url = `${options.api.replace(/\/+$/, "")}/api/application/${encodeURIComponent(
|
|
75
|
+
options.application
|
|
76
|
+
)}/release/${encodeURIComponent(options.release)}/source-map`;
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await fetch(url, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: { [API_KEY_HEADER]: apiKey },
|
|
82
|
+
body: form
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
const cause = error.cause?.message;
|
|
86
|
+
throw new CliError(
|
|
87
|
+
`Could not reach ${options.api} to send ${mapPath}: ${cause ?? (error instanceof Error ? error.message : String(error))}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
throw new CliError(
|
|
92
|
+
`${mapPath} was refused (HTTP ${response.status}): ${apiMessage(await response.text())}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var upload = async (options, io) => {
|
|
97
|
+
const apiKey = io.env[API_KEY_ENV];
|
|
98
|
+
if (!apiKey) {
|
|
99
|
+
throw new CliError(`${API_KEY_ENV} is not set: it holds the application's API key.`);
|
|
100
|
+
}
|
|
101
|
+
const maps = await findMaps(options.dir);
|
|
102
|
+
if (maps.length === 0) {
|
|
103
|
+
throw new CliError(`No .map file under ${options.dir}: was the build run with source maps?`);
|
|
104
|
+
}
|
|
105
|
+
for (const mapPath of maps) {
|
|
106
|
+
await uploadOne(options, apiKey, mapPath);
|
|
107
|
+
io.out(`sent ${mapPath}`);
|
|
108
|
+
}
|
|
109
|
+
io.out(`${maps.length} source map(s) sent for release ${options.release}.`);
|
|
110
|
+
if (options.deleteAfter) {
|
|
111
|
+
for (const mapPath of maps) {
|
|
112
|
+
await (0, import_promises.unlink)((0, import_node_path.join)(options.dir, mapPath));
|
|
113
|
+
}
|
|
114
|
+
io.out(`${maps.length} source map(s) deleted from ${options.dir}.`);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var runCli = async (argv, io) => {
|
|
118
|
+
try {
|
|
119
|
+
const [command, ...args] = argv;
|
|
120
|
+
if (command !== "upload") {
|
|
121
|
+
throw new CliError(USAGE);
|
|
122
|
+
}
|
|
123
|
+
await upload(parseUpload(args), io);
|
|
124
|
+
return 0;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
io.err(error instanceof Error ? error.message : String(error));
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/cli/bin.ts
|
|
132
|
+
var MINIMUM_NODE_MAJOR = 20;
|
|
133
|
+
var major = Number(process.versions.node.split(".")[0]);
|
|
134
|
+
if (major < MINIMUM_NODE_MAJOR) {
|
|
135
|
+
process.stderr.write(
|
|
136
|
+
`abyss-monitor-sourcemaps needs Node ${MINIMUM_NODE_MAJOR} or later, this is ${process.versions.node}.
|
|
137
|
+
`
|
|
138
|
+
);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
} else {
|
|
141
|
+
runCli(process.argv.slice(2), {
|
|
142
|
+
env: process.env,
|
|
143
|
+
out: (line) => process.stdout.write(`${line}
|
|
144
|
+
`),
|
|
145
|
+
err: (line) => process.stderr.write(`${line}
|
|
146
|
+
`)
|
|
147
|
+
}).then((code) => {
|
|
148
|
+
process.exitCode = code;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSWUATOHjs = require('./chunk-GSWUATOH.js');var _chunkLRYKS5XRjs = require('./chunk-LRYKS5XR.js');require('./chunk-UZZNGXXE.js');var L="abyss-rum-report-dialog",A={fr:{title:"Signaler un probl\xE8me",message:"Que s\u2019est-il pass\xE9 ?",email:"E-mail (facultatif)",cancel:"Annuler",send:"Envoyer",sending:"Envoi\u2026",sent:"Merci, votre signalement a \xE9t\xE9 envoy\xE9.",errors:{FEEDBACK_DISABLED:"Les signalements ne sont pas disponibles.",NO_SESSION:"Les signalements ne sont pas disponibles.",INVALID_MESSAGE:`D\xE9crivez le probl\xE8me en ${_chunkGSWUATOHjs.a} caract\xE8res au plus.`,INVALID_EMAIL:"Cette adresse e-mail n\u2019est pas valide.",LIMIT_REACHED:"Vous avez d\xE9j\xE0 envoy\xE9 plusieurs signalements.",DISCARDED:"Le signalement n\u2019a pas pu \xEAtre envoy\xE9.",REFUSED:"Le signalement n\u2019a pas pu \xEAtre envoy\xE9.",SEND_FAILED:"L\u2019envoi a \xE9chou\xE9. R\xE9essayez dans un instant."}},en:{title:"Report a problem",message:"What happened?",email:"E-mail (optional)",cancel:"Cancel",send:"Send",sending:"Sending\u2026",sent:"Thank you, your report was sent.",errors:{FEEDBACK_DISABLED:"Reports are not available.",NO_SESSION:"Reports are not available.",INVALID_MESSAGE:`Describe the problem in ${_chunkGSWUATOHjs.a} characters at most.`,INVALID_EMAIL:"This e-mail address is not valid.",LIMIT_REACHED:"You have already sent several reports.",DISCARDED:"The report could not be sent.",REFUSED:"The report could not be sent.",SEND_FAILED:"Sending failed. Try again in a moment."}}},R= exports.SENT_MESSAGE_MS =2e3,I=`
|
|
2
|
+
:host{all:initial}
|
|
3
|
+
.backdrop{position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(10,14,20,.55);font:14px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#111827}
|
|
4
|
+
.dialog{box-sizing:border-box;width:100%;max-width:440px;padding:20px;border-radius:12px;background:#fff;box-shadow:0 20px 50px rgba(0,0,0,.3)}
|
|
5
|
+
h2{margin:0 0 12px;font-size:17px;font-weight:600}
|
|
6
|
+
label{display:block;margin:12px 0 4px;font-weight:500}
|
|
7
|
+
textarea,input{box-sizing:border-box;width:100%;padding:8px 10px;border:1px solid #d1d5db;border-radius:8px;font:inherit;color:inherit;background:#fff}
|
|
8
|
+
textarea{min-height:110px;resize:vertical}
|
|
9
|
+
textarea:focus,input:focus,button:focus-visible{outline:2px solid #2563eb;outline-offset:1px}
|
|
10
|
+
.status{min-height:20px;margin:10px 0 0;font-size:13px}
|
|
11
|
+
.status.error{color:#b91c1c}
|
|
12
|
+
.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}
|
|
13
|
+
button{padding:8px 14px;border:1px solid #d1d5db;border-radius:8px;font:inherit;cursor:pointer;background:#fff;color:inherit}
|
|
14
|
+
button.primary{border-color:#2563eb;background:#2563eb;color:#fff}
|
|
15
|
+
button:disabled{opacity:.6;cursor:default}
|
|
16
|
+
@media (prefers-color-scheme:dark){.dialog{background:#111827;color:#f3f4f6}textarea,input,button{background:#1f2937;border-color:#374151;color:#f3f4f6}button.primary{background:#3b82f6;border-color:#3b82f6}.status.error{color:#fca5a5}}
|
|
17
|
+
`,T=o=>o==="fr"||o==="en"?o:/^en\b/i.test(document.documentElement.lang)?"en":"fr",e=(o,a={},...t)=>{let s=Object.assign(document.createElement(o),a);return t.forEach(p=>s.appendChild(p)),s},M= exports.openReportDialog =(o,a)=>{if(_chunkGSWUATOHjs.c.call(void 0, o)!==null||document.querySelector(L))return;let t=A[T(a.locale)],s=document.createElement(L),p=s.attachShadow({mode:"open"}),i=document.activeElement,S=typeof a.title=="string"&&a.title?a.title:t.title,d=e("textarea",{id:"message",required:!0,maxLength:_chunkGSWUATOHjs.a}),u=e("input",{id:"email",type:"email",autocomplete:"email",value:typeof a.email=="string"?a.email:""}),r=e("p",{className:"status"});r.setAttribute("role","status");let f=e("button",{type:"button",textContent:t.cancel}),b=e("button",{type:"submit",className:"primary",textContent:t.send}),l=e("form",{className:"dialog",noValidate:!0},e("h2",{id:"title",textContent:S}),e("label",{htmlFor:"message",textContent:t.message}),d,e("label",{htmlFor:"email",textContent:t.email}),u,r,e("div",{className:"actions"},f,b));l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","title");let g=e("div",{className:"backdrop"},l);p.append(e("style",{textContent:I}),g);let E=!1,c=()=>{var n;E||(E=!0,document.removeEventListener("keydown",x,!0),s.remove(),(n=i==null?void 0:i.focus)==null||n.call(i))},x=n=>{n.key==="Escape"&&c()},k=n=>{r.className="status error",r.textContent=t.errors[n]};f.addEventListener("click",c),g.addEventListener("click",n=>{n.target===g&&c()}),l.addEventListener("submit",n=>{n.preventDefault(),b.disabled=!0,r.className="status",r.textContent=t.sending,_chunkGSWUATOHjs.d.call(void 0, o,{message:d.value,email:u.value}).then(()=>{r.textContent=t.sent,d.disabled=!0,u.disabled=!0,setTimeout(c,R)},y=>{b.disabled=!1,k(y instanceof _chunkLRYKS5XRjs.b?y.code:"SEND_FAILED")})}),document.addEventListener("keydown",x,!0),document.body.appendChild(s),d.focus()};exports.REPORT_DIALOG_TAG = L; exports.SENT_MESSAGE_MS = R; exports.openReportDialog = M;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{a as m,c as h,d as v}from"./chunk-UKLKIMTU.mjs";import{b as D}from"./chunk-QEU2JJHJ.mjs";import"./chunk-AAXB6P4Z.mjs";var L="abyss-rum-report-dialog",A={fr:{title:"Signaler un probl\xE8me",message:"Que s\u2019est-il pass\xE9 ?",email:"E-mail (facultatif)",cancel:"Annuler",send:"Envoyer",sending:"Envoi\u2026",sent:"Merci, votre signalement a \xE9t\xE9 envoy\xE9.",errors:{FEEDBACK_DISABLED:"Les signalements ne sont pas disponibles.",NO_SESSION:"Les signalements ne sont pas disponibles.",INVALID_MESSAGE:`D\xE9crivez le probl\xE8me en ${m} caract\xE8res au plus.`,INVALID_EMAIL:"Cette adresse e-mail n\u2019est pas valide.",LIMIT_REACHED:"Vous avez d\xE9j\xE0 envoy\xE9 plusieurs signalements.",DISCARDED:"Le signalement n\u2019a pas pu \xEAtre envoy\xE9.",REFUSED:"Le signalement n\u2019a pas pu \xEAtre envoy\xE9.",SEND_FAILED:"L\u2019envoi a \xE9chou\xE9. R\xE9essayez dans un instant."}},en:{title:"Report a problem",message:"What happened?",email:"E-mail (optional)",cancel:"Cancel",send:"Send",sending:"Sending\u2026",sent:"Thank you, your report was sent.",errors:{FEEDBACK_DISABLED:"Reports are not available.",NO_SESSION:"Reports are not available.",INVALID_MESSAGE:`Describe the problem in ${m} characters at most.`,INVALID_EMAIL:"This e-mail address is not valid.",LIMIT_REACHED:"You have already sent several reports.",DISCARDED:"The report could not be sent.",REFUSED:"The report could not be sent.",SEND_FAILED:"Sending failed. Try again in a moment."}}},R=2e3,I=`
|
|
2
|
+
:host{all:initial}
|
|
3
|
+
.backdrop{position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(10,14,20,.55);font:14px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#111827}
|
|
4
|
+
.dialog{box-sizing:border-box;width:100%;max-width:440px;padding:20px;border-radius:12px;background:#fff;box-shadow:0 20px 50px rgba(0,0,0,.3)}
|
|
5
|
+
h2{margin:0 0 12px;font-size:17px;font-weight:600}
|
|
6
|
+
label{display:block;margin:12px 0 4px;font-weight:500}
|
|
7
|
+
textarea,input{box-sizing:border-box;width:100%;padding:8px 10px;border:1px solid #d1d5db;border-radius:8px;font:inherit;color:inherit;background:#fff}
|
|
8
|
+
textarea{min-height:110px;resize:vertical}
|
|
9
|
+
textarea:focus,input:focus,button:focus-visible{outline:2px solid #2563eb;outline-offset:1px}
|
|
10
|
+
.status{min-height:20px;margin:10px 0 0;font-size:13px}
|
|
11
|
+
.status.error{color:#b91c1c}
|
|
12
|
+
.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}
|
|
13
|
+
button{padding:8px 14px;border:1px solid #d1d5db;border-radius:8px;font:inherit;cursor:pointer;background:#fff;color:inherit}
|
|
14
|
+
button.primary{border-color:#2563eb;background:#2563eb;color:#fff}
|
|
15
|
+
button:disabled{opacity:.6;cursor:default}
|
|
16
|
+
@media (prefers-color-scheme:dark){.dialog{background:#111827;color:#f3f4f6}textarea,input,button{background:#1f2937;border-color:#374151;color:#f3f4f6}button.primary{background:#3b82f6;border-color:#3b82f6}.status.error{color:#fca5a5}}
|
|
17
|
+
`,T=o=>o==="fr"||o==="en"?o:/^en\b/i.test(document.documentElement.lang)?"en":"fr",e=(o,a={},...t)=>{let s=Object.assign(document.createElement(o),a);return t.forEach(p=>s.appendChild(p)),s},M=(o,a)=>{if(h(o)!==null||document.querySelector(L))return;let t=A[T(a.locale)],s=document.createElement(L),p=s.attachShadow({mode:"open"}),i=document.activeElement,S=typeof a.title=="string"&&a.title?a.title:t.title,d=e("textarea",{id:"message",required:!0,maxLength:m}),u=e("input",{id:"email",type:"email",autocomplete:"email",value:typeof a.email=="string"?a.email:""}),r=e("p",{className:"status"});r.setAttribute("role","status");let f=e("button",{type:"button",textContent:t.cancel}),b=e("button",{type:"submit",className:"primary",textContent:t.send}),l=e("form",{className:"dialog",noValidate:!0},e("h2",{id:"title",textContent:S}),e("label",{htmlFor:"message",textContent:t.message}),d,e("label",{htmlFor:"email",textContent:t.email}),u,r,e("div",{className:"actions"},f,b));l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","title");let g=e("div",{className:"backdrop"},l);p.append(e("style",{textContent:I}),g);let E=!1,c=()=>{var n;E||(E=!0,document.removeEventListener("keydown",x,!0),s.remove(),(n=i==null?void 0:i.focus)==null||n.call(i))},x=n=>{n.key==="Escape"&&c()},k=n=>{r.className="status error",r.textContent=t.errors[n]};f.addEventListener("click",c),g.addEventListener("click",n=>{n.target===g&&c()}),l.addEventListener("submit",n=>{n.preventDefault(),b.disabled=!0,r.className="status",r.textContent=t.sending,v(o,{message:d.value,email:u.value}).then(()=>{r.textContent=t.sent,d.disabled=!0,u.disabled=!0,setTimeout(c,R)},y=>{b.disabled=!1,k(y instanceof D?y.code:"SEND_FAILED")})}),document.addEventListener("keydown",x,!0),document.body.appendChild(s),d.focus()};export{L as REPORT_DIALOG_TAG,R as SENT_MESSAGE_MS,M as openReportDialog};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RumDeviceType, RumAttributeValues, RumEvent } from '@abyss-project/monitor/rum';
|
|
1
|
+
import { RumDeviceType, RumAttributeValues, RumEvent, IRumSocketMessageEvent } from '@abyss-project/monitor/rum';
|
|
2
2
|
export { RumEvent } from '@abyss-project/monitor/rum';
|
|
3
3
|
|
|
4
4
|
/** What `sampler` receives, once per session, at its creation (RUM spec §35.2). */
|
|
@@ -22,6 +22,37 @@ interface RumSamplingDecision {
|
|
|
22
22
|
session: boolean;
|
|
23
23
|
replay: boolean;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* A WebSocket or SSE message as `captureSocketMessages.redact` receives it (§38.2). Only `payload`,
|
|
27
|
+
* `eventName` and `eventId` are read back; a text message keeps a text payload, cut again to
|
|
28
|
+
* `maxMessageBytes`, and a binary one a `null` payload.
|
|
29
|
+
*/
|
|
30
|
+
type RumSocketMessage = IRumSocketMessageEvent;
|
|
31
|
+
/** Which messages are recorded once the message capture is on (§38.1, §38.2). */
|
|
32
|
+
declare enum RumSocketCaptureMode {
|
|
33
|
+
/** Every message of a matching connection. */
|
|
34
|
+
ALL = "ALL",
|
|
35
|
+
/**
|
|
36
|
+
* The last 100 messages of each connection are held, and sent only when an anomaly happens while
|
|
37
|
+
* it is open (JS error, frustration signal, abnormal close, failed request), with the messages of
|
|
38
|
+
* the 10 seconds that follow.
|
|
39
|
+
*/
|
|
40
|
+
ON_ANOMALY = "ON_ANOMALY"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Content capture of the WebSocket and SSE messages (§38.1). It works only when the environment's
|
|
44
|
+
* panel switch `socketMessagesEnabled` is on too, and for sampled sessions only.
|
|
45
|
+
*/
|
|
46
|
+
interface CaptureSocketMessagesOptions {
|
|
47
|
+
/** Connections whose messages are recorded: a string matches the URLs it starts, a RegExp tests it. */
|
|
48
|
+
urls: (string | RegExp)[];
|
|
49
|
+
/** `ON_ANOMALY` by default. */
|
|
50
|
+
mode?: RumSocketCaptureMode | 'ALL' | 'ON_ANOMALY';
|
|
51
|
+
/** A text payload is cut to this many UTF-8 bytes: 4,096 by default, from 1,024 to 16,384. */
|
|
52
|
+
maxMessageBytes?: number;
|
|
53
|
+
/** Gives the message masked, or `null` to discard it. A failure discards it too. */
|
|
54
|
+
redact?: (message: RumSocketMessage) => RumSocketMessage | null;
|
|
55
|
+
}
|
|
25
56
|
/** `setAttributes` input: `null` removes the key (§35.1). */
|
|
26
57
|
type RumAttributeInput = Record<string, string | number | boolean | null>;
|
|
27
58
|
/** Options of `AbyssRum.init` (RUM spec §5.1, §35, §36). */
|
|
@@ -56,6 +87,63 @@ interface AbyssRumOptions {
|
|
|
56
87
|
* `proxyUrl` + `/rum/:applicationId/...` instead of `apiUrl` + `/api/rum/...` (§36.2).
|
|
57
88
|
*/
|
|
58
89
|
proxyUrl?: string;
|
|
90
|
+
/** Records the content of WebSocket and SSE messages (§38); off without it. */
|
|
91
|
+
captureSocketMessages?: CaptureSocketMessagesOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Called once per feedback stored by the API (a 2xx answer), whether it comes from
|
|
94
|
+
* `sendFeedback` or from the `showReportDialog` window; never on a failure. The values are those
|
|
95
|
+
* of the event sent, so after `beforeSend` and the masking of the route. An exception of the
|
|
96
|
+
* callback is swallowed and counted in `droppedEvents`; it never rejects `sendFeedback`.
|
|
97
|
+
*/
|
|
98
|
+
onFeedbackSent?: (feedback: RumFeedbackSent) => void;
|
|
99
|
+
}
|
|
100
|
+
/** What `onFeedbackSent` receives: the stored feedback and the session instant it was sent at. */
|
|
101
|
+
interface RumFeedbackSent {
|
|
102
|
+
sessionId: string;
|
|
103
|
+
/** Milliseconds since the start of the session. */
|
|
104
|
+
offsetMs: number;
|
|
105
|
+
/** Masked route. */
|
|
106
|
+
route: string;
|
|
107
|
+
message: string;
|
|
108
|
+
email: string | null;
|
|
109
|
+
}
|
|
110
|
+
/** `sendFeedback` input (§37.1). */
|
|
111
|
+
interface RumFeedbackInput {
|
|
112
|
+
/** 2,000 characters at most, not blank. */
|
|
113
|
+
message: string;
|
|
114
|
+
email?: string | null;
|
|
115
|
+
}
|
|
116
|
+
/** `showReportDialog` options (§37.1). */
|
|
117
|
+
interface RumReportDialogOptions {
|
|
118
|
+
title?: string;
|
|
119
|
+
/** Prefills the e-mail field. */
|
|
120
|
+
email?: string;
|
|
121
|
+
/** French by default, English when the page's `lang` is English. */
|
|
122
|
+
locale?: 'fr' | 'en';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Why a feedback was not sent: the code of the rejected promise of `sendFeedback` (§37.1). */
|
|
126
|
+
declare enum RumFeedbackErrorCode {
|
|
127
|
+
/** The environment has not enabled end-user feedback (`feedbackEnabled`). */
|
|
128
|
+
FEEDBACK_DISABLED = "FEEDBACK_DISABLED",
|
|
129
|
+
/** The SDK has no session: not started, RUM off for the environment, stopped or refused. */
|
|
130
|
+
NO_SESSION = "NO_SESSION",
|
|
131
|
+
/** Blank message, or longer than 2,000 characters. */
|
|
132
|
+
INVALID_MESSAGE = "INVALID_MESSAGE",
|
|
133
|
+
INVALID_EMAIL = "INVALID_EMAIL",
|
|
134
|
+
/** 5 feedbacks were already sent for this session. */
|
|
135
|
+
LIMIT_REACHED = "LIMIT_REACHED",
|
|
136
|
+
/** `beforeSend` discarded the feedback. */
|
|
137
|
+
DISCARDED = "DISCARDED",
|
|
138
|
+
/** The API refused the feedback. */
|
|
139
|
+
REFUSED = "REFUSED",
|
|
140
|
+
/** Network failure, rate limit, unexpected answer or module not loaded: it may be sent later. */
|
|
141
|
+
SEND_FAILED = "SEND_FAILED"
|
|
142
|
+
}
|
|
143
|
+
/** The rejection of `sendFeedback`: `code` says why. */
|
|
144
|
+
declare class RumFeedbackError extends Error {
|
|
145
|
+
readonly code: RumFeedbackErrorCode;
|
|
146
|
+
constructor(code: RumFeedbackErrorCode);
|
|
59
147
|
}
|
|
60
148
|
|
|
61
149
|
/**
|
|
@@ -83,8 +171,45 @@ declare const AbyssRum: {
|
|
|
83
171
|
setAttributes(attributes: RumAttributeInput): void;
|
|
84
172
|
/** Sends a JS error, always, whatever the sampling of the session. */
|
|
85
173
|
captureError(error: unknown, context?: Record<string, string>): void;
|
|
174
|
+
/**
|
|
175
|
+
* A named user action of the current page view (§35.7), shown in the session's chronology. A name
|
|
176
|
+
* of 64 characters at most, attributes with the limits of `setAttributes`; beyond, the call or
|
|
177
|
+
* the key is ignored and counted in `droppedEvents`.
|
|
178
|
+
*/
|
|
179
|
+
addAction(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
180
|
+
/**
|
|
181
|
+
* A feature flag evaluation (§36.5): the latest value wins, for the session and for the current
|
|
182
|
+
* page view. At most 50 flags per session, keys and values with the limits of `setAttributes`;
|
|
183
|
+
* beyond, the call is ignored and counted in `droppedEvents`. Can be called before `init`.
|
|
184
|
+
*/
|
|
185
|
+
addFeatureFlagEvaluation(key: string, value: string | number | boolean): void;
|
|
186
|
+
/**
|
|
187
|
+
* Sends an end-user feedback (§37.1) from the application's own interface: a message of 2,000
|
|
188
|
+
* characters at most and an optional e-mail, tied to the session and to the instant. Rejected with
|
|
189
|
+
* a `RumFeedbackError` whose `code` says why: feedback disabled for the environment, no session,
|
|
190
|
+
* invalid input, 5 feedbacks already sent in the session, refused or failed sending.
|
|
191
|
+
*/
|
|
192
|
+
sendFeedback(input: RumFeedbackInput): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Opens the provided report dialog (§37.1), loaded on demand and isolated in a shadow root. It
|
|
195
|
+
* opens only when `sendFeedback` could send: nothing shows otherwise.
|
|
196
|
+
*/
|
|
197
|
+
showReportDialog(options?: RumReportDialogOptions): void;
|
|
198
|
+
/**
|
|
199
|
+
* A custom measure (§36.6): the time elapsed since the start of the current page view — the start
|
|
200
|
+
* of the navigation for the initial load. A name of 64 characters at most, 20 measures at most
|
|
201
|
+
* per page view; beyond, the call is ignored and counted in `droppedEvents`.
|
|
202
|
+
*/
|
|
203
|
+
addTiming(name: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* Starts a free duration named `name` (§36.6), stopped by `stopDuration(name)`. A duration not
|
|
206
|
+
* stopped when its page view ends is discarded; starting a running name again restarts it.
|
|
207
|
+
*/
|
|
208
|
+
startDuration(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
209
|
+
/** Stops the duration `name` and sends it; an unknown name is counted in `droppedEvents`. */
|
|
210
|
+
stopDuration(name: string): void;
|
|
86
211
|
/** Stops everything, empties the buffers and removes the session. `init` can be called again. */
|
|
87
212
|
stop(): void;
|
|
88
213
|
};
|
|
89
214
|
|
|
90
|
-
export { AbyssRum, type AbyssRumOptions, type RumAttributeInput, type RumSamplingContext, type RumSamplingDecision };
|
|
215
|
+
export { AbyssRum, type AbyssRumOptions, type CaptureSocketMessagesOptions, type RumAttributeInput, RumFeedbackError, RumFeedbackErrorCode, type RumFeedbackInput, type RumFeedbackSent, type RumReportDialogOptions, type RumSamplingContext, type RumSamplingDecision, RumSocketCaptureMode, type RumSocketMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RumDeviceType, RumAttributeValues, RumEvent } from '@abyss-project/monitor/rum';
|
|
1
|
+
import { RumDeviceType, RumAttributeValues, RumEvent, IRumSocketMessageEvent } from '@abyss-project/monitor/rum';
|
|
2
2
|
export { RumEvent } from '@abyss-project/monitor/rum';
|
|
3
3
|
|
|
4
4
|
/** What `sampler` receives, once per session, at its creation (RUM spec §35.2). */
|
|
@@ -22,6 +22,37 @@ interface RumSamplingDecision {
|
|
|
22
22
|
session: boolean;
|
|
23
23
|
replay: boolean;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* A WebSocket or SSE message as `captureSocketMessages.redact` receives it (§38.2). Only `payload`,
|
|
27
|
+
* `eventName` and `eventId` are read back; a text message keeps a text payload, cut again to
|
|
28
|
+
* `maxMessageBytes`, and a binary one a `null` payload.
|
|
29
|
+
*/
|
|
30
|
+
type RumSocketMessage = IRumSocketMessageEvent;
|
|
31
|
+
/** Which messages are recorded once the message capture is on (§38.1, §38.2). */
|
|
32
|
+
declare enum RumSocketCaptureMode {
|
|
33
|
+
/** Every message of a matching connection. */
|
|
34
|
+
ALL = "ALL",
|
|
35
|
+
/**
|
|
36
|
+
* The last 100 messages of each connection are held, and sent only when an anomaly happens while
|
|
37
|
+
* it is open (JS error, frustration signal, abnormal close, failed request), with the messages of
|
|
38
|
+
* the 10 seconds that follow.
|
|
39
|
+
*/
|
|
40
|
+
ON_ANOMALY = "ON_ANOMALY"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Content capture of the WebSocket and SSE messages (§38.1). It works only when the environment's
|
|
44
|
+
* panel switch `socketMessagesEnabled` is on too, and for sampled sessions only.
|
|
45
|
+
*/
|
|
46
|
+
interface CaptureSocketMessagesOptions {
|
|
47
|
+
/** Connections whose messages are recorded: a string matches the URLs it starts, a RegExp tests it. */
|
|
48
|
+
urls: (string | RegExp)[];
|
|
49
|
+
/** `ON_ANOMALY` by default. */
|
|
50
|
+
mode?: RumSocketCaptureMode | 'ALL' | 'ON_ANOMALY';
|
|
51
|
+
/** A text payload is cut to this many UTF-8 bytes: 4,096 by default, from 1,024 to 16,384. */
|
|
52
|
+
maxMessageBytes?: number;
|
|
53
|
+
/** Gives the message masked, or `null` to discard it. A failure discards it too. */
|
|
54
|
+
redact?: (message: RumSocketMessage) => RumSocketMessage | null;
|
|
55
|
+
}
|
|
25
56
|
/** `setAttributes` input: `null` removes the key (§35.1). */
|
|
26
57
|
type RumAttributeInput = Record<string, string | number | boolean | null>;
|
|
27
58
|
/** Options of `AbyssRum.init` (RUM spec §5.1, §35, §36). */
|
|
@@ -56,6 +87,63 @@ interface AbyssRumOptions {
|
|
|
56
87
|
* `proxyUrl` + `/rum/:applicationId/...` instead of `apiUrl` + `/api/rum/...` (§36.2).
|
|
57
88
|
*/
|
|
58
89
|
proxyUrl?: string;
|
|
90
|
+
/** Records the content of WebSocket and SSE messages (§38); off without it. */
|
|
91
|
+
captureSocketMessages?: CaptureSocketMessagesOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Called once per feedback stored by the API (a 2xx answer), whether it comes from
|
|
94
|
+
* `sendFeedback` or from the `showReportDialog` window; never on a failure. The values are those
|
|
95
|
+
* of the event sent, so after `beforeSend` and the masking of the route. An exception of the
|
|
96
|
+
* callback is swallowed and counted in `droppedEvents`; it never rejects `sendFeedback`.
|
|
97
|
+
*/
|
|
98
|
+
onFeedbackSent?: (feedback: RumFeedbackSent) => void;
|
|
99
|
+
}
|
|
100
|
+
/** What `onFeedbackSent` receives: the stored feedback and the session instant it was sent at. */
|
|
101
|
+
interface RumFeedbackSent {
|
|
102
|
+
sessionId: string;
|
|
103
|
+
/** Milliseconds since the start of the session. */
|
|
104
|
+
offsetMs: number;
|
|
105
|
+
/** Masked route. */
|
|
106
|
+
route: string;
|
|
107
|
+
message: string;
|
|
108
|
+
email: string | null;
|
|
109
|
+
}
|
|
110
|
+
/** `sendFeedback` input (§37.1). */
|
|
111
|
+
interface RumFeedbackInput {
|
|
112
|
+
/** 2,000 characters at most, not blank. */
|
|
113
|
+
message: string;
|
|
114
|
+
email?: string | null;
|
|
115
|
+
}
|
|
116
|
+
/** `showReportDialog` options (§37.1). */
|
|
117
|
+
interface RumReportDialogOptions {
|
|
118
|
+
title?: string;
|
|
119
|
+
/** Prefills the e-mail field. */
|
|
120
|
+
email?: string;
|
|
121
|
+
/** French by default, English when the page's `lang` is English. */
|
|
122
|
+
locale?: 'fr' | 'en';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Why a feedback was not sent: the code of the rejected promise of `sendFeedback` (§37.1). */
|
|
126
|
+
declare enum RumFeedbackErrorCode {
|
|
127
|
+
/** The environment has not enabled end-user feedback (`feedbackEnabled`). */
|
|
128
|
+
FEEDBACK_DISABLED = "FEEDBACK_DISABLED",
|
|
129
|
+
/** The SDK has no session: not started, RUM off for the environment, stopped or refused. */
|
|
130
|
+
NO_SESSION = "NO_SESSION",
|
|
131
|
+
/** Blank message, or longer than 2,000 characters. */
|
|
132
|
+
INVALID_MESSAGE = "INVALID_MESSAGE",
|
|
133
|
+
INVALID_EMAIL = "INVALID_EMAIL",
|
|
134
|
+
/** 5 feedbacks were already sent for this session. */
|
|
135
|
+
LIMIT_REACHED = "LIMIT_REACHED",
|
|
136
|
+
/** `beforeSend` discarded the feedback. */
|
|
137
|
+
DISCARDED = "DISCARDED",
|
|
138
|
+
/** The API refused the feedback. */
|
|
139
|
+
REFUSED = "REFUSED",
|
|
140
|
+
/** Network failure, rate limit, unexpected answer or module not loaded: it may be sent later. */
|
|
141
|
+
SEND_FAILED = "SEND_FAILED"
|
|
142
|
+
}
|
|
143
|
+
/** The rejection of `sendFeedback`: `code` says why. */
|
|
144
|
+
declare class RumFeedbackError extends Error {
|
|
145
|
+
readonly code: RumFeedbackErrorCode;
|
|
146
|
+
constructor(code: RumFeedbackErrorCode);
|
|
59
147
|
}
|
|
60
148
|
|
|
61
149
|
/**
|
|
@@ -83,8 +171,45 @@ declare const AbyssRum: {
|
|
|
83
171
|
setAttributes(attributes: RumAttributeInput): void;
|
|
84
172
|
/** Sends a JS error, always, whatever the sampling of the session. */
|
|
85
173
|
captureError(error: unknown, context?: Record<string, string>): void;
|
|
174
|
+
/**
|
|
175
|
+
* A named user action of the current page view (§35.7), shown in the session's chronology. A name
|
|
176
|
+
* of 64 characters at most, attributes with the limits of `setAttributes`; beyond, the call or
|
|
177
|
+
* the key is ignored and counted in `droppedEvents`.
|
|
178
|
+
*/
|
|
179
|
+
addAction(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
180
|
+
/**
|
|
181
|
+
* A feature flag evaluation (§36.5): the latest value wins, for the session and for the current
|
|
182
|
+
* page view. At most 50 flags per session, keys and values with the limits of `setAttributes`;
|
|
183
|
+
* beyond, the call is ignored and counted in `droppedEvents`. Can be called before `init`.
|
|
184
|
+
*/
|
|
185
|
+
addFeatureFlagEvaluation(key: string, value: string | number | boolean): void;
|
|
186
|
+
/**
|
|
187
|
+
* Sends an end-user feedback (§37.1) from the application's own interface: a message of 2,000
|
|
188
|
+
* characters at most and an optional e-mail, tied to the session and to the instant. Rejected with
|
|
189
|
+
* a `RumFeedbackError` whose `code` says why: feedback disabled for the environment, no session,
|
|
190
|
+
* invalid input, 5 feedbacks already sent in the session, refused or failed sending.
|
|
191
|
+
*/
|
|
192
|
+
sendFeedback(input: RumFeedbackInput): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Opens the provided report dialog (§37.1), loaded on demand and isolated in a shadow root. It
|
|
195
|
+
* opens only when `sendFeedback` could send: nothing shows otherwise.
|
|
196
|
+
*/
|
|
197
|
+
showReportDialog(options?: RumReportDialogOptions): void;
|
|
198
|
+
/**
|
|
199
|
+
* A custom measure (§36.6): the time elapsed since the start of the current page view — the start
|
|
200
|
+
* of the navigation for the initial load. A name of 64 characters at most, 20 measures at most
|
|
201
|
+
* per page view; beyond, the call is ignored and counted in `droppedEvents`.
|
|
202
|
+
*/
|
|
203
|
+
addTiming(name: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* Starts a free duration named `name` (§36.6), stopped by `stopDuration(name)`. A duration not
|
|
206
|
+
* stopped when its page view ends is discarded; starting a running name again restarts it.
|
|
207
|
+
*/
|
|
208
|
+
startDuration(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
209
|
+
/** Stops the duration `name` and sends it; an unknown name is counted in `droppedEvents`. */
|
|
210
|
+
stopDuration(name: string): void;
|
|
86
211
|
/** Stops everything, empties the buffers and removes the session. `init` can be called again. */
|
|
87
212
|
stop(): void;
|
|
88
213
|
};
|
|
89
214
|
|
|
90
|
-
export { AbyssRum, type AbyssRumOptions, type RumAttributeInput, type RumSamplingContext, type RumSamplingDecision };
|
|
215
|
+
export { AbyssRum, type AbyssRumOptions, type CaptureSocketMessagesOptions, type RumAttributeInput, RumFeedbackError, RumFeedbackErrorCode, type RumFeedbackInput, type RumFeedbackSent, type RumReportDialogOptions, type RumSamplingContext, type RumSamplingDecision, RumSocketCaptureMode, type RumSocketMessage };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var ft=Object.create;var Se=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var St=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rt(t))!gt.call(e,o)&&o!==n&&Se(e,o,{get:()=>t[o],enumerable:!(s=ht(t,o))||s.enumerable});return e};var v=(e,t,n)=>(n=e!=null?ft(Et(e)):{},St(!e||!e.__esModule?Se(n,"default",{value:e,enumerable:true}):n,e));var Pe=V(f=>{Object.defineProperty(f,"__esModule",{value:true});f.RumCspDisposition=f.RumBreadcrumbKind=f.RumConsoleLevel=f.RumTimingKind=f.RumSocketBinaryType=f.RumSocketDirection=f.RumFrustrationType=f.RumDeviceType=f.RumNavigationType=f.RumRequestKind=f.RumRequestOutcome=f.RumEventType=void 0;var Ie;(function(e){e.SESSION="session",e.PAGE_VIEW="pageView",e.VITALS="vitals",e.REQUEST="request",e.ERROR="error",e.CONSOLE="console",e.ACTION="action",e.FRUSTRATION="frustration",e.TIMING="timing",e.CSP_VIOLATION="cspViolation",e.SOCKET_MESSAGE="socketMessage",e.FEEDBACK="feedback";})(Ie||(f.RumEventType=Ie={}));var be;(function(e){e.SUCCESS="SUCCESS",e.HTTP_ERROR="HTTP_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.OFFLINE="OFFLINE",e.ABORTED="ABORTED",e.TIMEOUT="TIMEOUT";})(be||(f.RumRequestOutcome=be={}));var Te;(function(e){e.FETCH="FETCH",e.XHR="XHR",e.RESOURCE="RESOURCE",e.WEBSOCKET="WEBSOCKET",e.SSE="SSE";})(Te||(f.RumRequestKind=Te={}));var Ae;(function(e){e.NAVIGATE="NAVIGATE",e.RELOAD="RELOAD",e.BACK_FORWARD="BACK_FORWARD",e.SPA="SPA";})(Ae||(f.RumNavigationType=Ae={}));var we;(function(e){e.DESKTOP="desktop",e.MOBILE="mobile",e.TABLET="tablet";})(we||(f.RumDeviceType=we={}));var Oe;(function(e){e.RAGE_CLICK="RAGE_CLICK",e.DEAD_CLICK="DEAD_CLICK",e.ERROR_CLICK="ERROR_CLICK";})(Oe||(f.RumFrustrationType=Oe={}));var _e;(function(e){e.IN="IN",e.OUT="OUT";})(_e||(f.RumSocketDirection=_e={}));var Ce;(function(e){e.BLOB="blob",e.ARRAYBUFFER="arraybuffer";})(Ce||(f.RumSocketBinaryType=Ce={}));var Me;(function(e){e.TIMING="TIMING",e.DURATION="DURATION";})(Me||(f.RumTimingKind=Me={}));var ke;(function(e){e.ERROR="error",e.WARN="warn";})(ke||(f.RumConsoleLevel=ke={}));var De;(function(e){e.NAVIGATION="NAVIGATION",e.REQUEST="REQUEST",e.CLICK="CLICK";})(De||(f.RumBreadcrumbKind=De={}));var Ne;(function(e){e.ENFORCE="enforce",e.REPORT="report";})(Ne||(f.RumCspDisposition=Ne={}));});var Le=V(Ue=>{Object.defineProperty(Ue,"__esModule",{value:true});});var ie=V(P=>{Object.defineProperty(P,"__esModule",{value:true});P.isUuid=P.UUID_PATTERN=void 0;P.UUID_PATTERN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var bt=e=>typeof e=="string"&&P.UUID_PATTERN.test(e);P.isUuid=bt;});var xe=V(O=>{Object.defineProperty(O,"__esModule",{value:true});O.maskUrl=O.MASK_URL_MAX_SEGMENT_LENGTH=O.MASKED_SEGMENT=void 0;var Tt=ie();O.MASKED_SEGMENT=":id";O.MASK_URL_MAX_SEGMENT_LENGTH=40;var At=/^\d{3,}$/,wt=/^[0-9a-f]{16,}$/i,Ot=/^[a-z][a-z0-9+.-]*:\/\//i,_t=e=>e.length>O.MASK_URL_MAX_SEGMENT_LENGTH||Tt.UUID_PATTERN.test(e)||At.test(e)||wt.test(e),Ct=e=>e===""?"/":e.split("/").map(t=>_t(t)?O.MASKED_SEGMENT:t).join("/"),Mt=e=>{try{let t=new URL(e.startsWith("//")?`https:${e}`:e);return {host:t.host===""?null:t.host.toLowerCase(),path:t.pathname}}catch{return {host:null,path:"/"}}},kt=e=>{let n=(typeof e=="string"?e.trim():"").split("#")[0].split("?")[0],{host:s,path:o}=Ot.test(n)||n.startsWith("//")?Mt(n):{host:null,path:n};return {host:s,path:Ct(o)}};O.maskUrl=kt;});var Ve=V(R=>{Object.defineProperty(R,"__esModule",{value:true});R.TIMING_ALLOW_ORIGIN_HEADER=R.SOCKET_SESSION_ID_PARAM=R.SOCKET_REQUEST_ID_PARAM=R.MONITOR_CORRELATION_HEADERS=R.SESSION_ID_HEADER=R.REQUEST_ID_HEADER=void 0;R.REQUEST_ID_HEADER="x-abyss-request-id";R.SESSION_ID_HEADER="x-abyss-session-id";R.MONITOR_CORRELATION_HEADERS=[R.REQUEST_ID_HEADER,R.SESSION_ID_HEADER];R.SOCKET_REQUEST_ID_PARAM="abyss_rid";R.SOCKET_SESSION_ID_PARAM="abyss_sid";R.TIMING_ALLOW_ORIGIN_HEADER="Timing-Allow-Origin";});var g=V(A=>{var Dt=A&&A.__createBinding||(Object.create?(function(e,t,n,s){s===void 0&&(s=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:true,get:function(){return t[n]}}),Object.defineProperty(e,s,o);}):(function(e,t,n,s){s===void 0&&(s=n),e[s]=t[n];})),G=A&&A.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&Dt(t,e,n);};Object.defineProperty(A,"__esModule",{value:true});G(Pe(),A);G(Le(),A);G(xe(),A);G(Ve(),A);G(ie(),A);});var ye=e=>e===null?null:typeof e=="string"&&e.trim()!==""?e:void 0;var yt=/^[a-zA-Z0-9_.-]{1,64}$/,vt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),It=e=>typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.length<=256,ve=(e,t,n)=>{let s={...e};if(!t||typeof t!="object"||Array.isArray(t))return n(),s;for(let[o,r]of Object.entries(t))!yt.test(o)||o==="__proto__"?n():r===null?delete s[o]:!It(r)||!vt(s,o)&&Object.keys(s).length>=30?n():s[o]=r;return s};var I=v(g());var Nt=["id","type","sessionId"],Pt=(e,t)=>e==null?t==null||["string","number","boolean"].includes(typeof t):Array.isArray(e)?Array.isArray(t):t!==null&&typeof t==typeof e,He=(e,t,n)=>{if(!t)return e;let s;try{s=t(JSON.parse(JSON.stringify(e)));}catch{return n(),e}if(s===null)return null;if(!s||typeof s!="object"||Array.isArray(s))return n(),null;let o=e,r=s,i={};for(let a of Object.keys(o))if(Nt.includes(a))i[a]=o[a];else if(Pt(o[a],r[a]))r[a]!==void 0&&(i[a]=r[a]);else return n(),null;return i};var j=v(g());var M=e=>new Date(e).toISOString(),S=(e,t)=>e>0&&t>=e?Math.round(t-e):null,$=e=>{var t;if(typeof e=="string")return e;if(e instanceof Error)return `${e.name}: ${e.message}`;try{return (t=JSON.stringify(e))!=null?t:String(e)}catch{return String(e)}},_=(e,t,n,s=false)=>{let o={capture:s,passive:true};return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)},H=e=>{let t=0;for(let n=0;n<e.length;n+=1){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:s>=55296&&s<56320?(t+=4,n+=1):t+=3;}return t},Q=(e,t)=>{if(H(e)<=t)return e;let n=0;for(let s=0;s<e.length;s+=1){let o=e.charCodeAt(s)>=55296&&e.charCodeAt(s)<56320,r=H(e.slice(s,o?s+2:s+1));if(n+r>t)return e.slice(0,s);n+=r,o&&(s+=1);}return e},ae=e=>{if(typeof e=="string")return H(e);if(typeof Blob!="undefined"&&e instanceof Blob)return e.size;let t=e==null?void 0:e.byteLength;return typeof t=="number"?t:0},z=e=>{try{let t=sessionStorage.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}},Y=(e,t)=>{try{sessionStorage.setItem(e,JSON.stringify(t));}catch{}},Be=e=>{try{sessionStorage.removeItem(e);}catch{}};var E=()=>{let e=globalThis.crypto;if(typeof(e==null?void 0:e.randomUUID)=="function")return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,s=>(s+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)}`};var Ut=1024,Lt=50,qe=e=>{let t=[["error",j.RumConsoleLevel.ERROR],["warn",j.RumConsoleLevel.WARN]],n=null,s=0,o=t.map(([r,i])=>{let a=console[r],d=(...c)=>{try{let u=e.pageViewId();u!==n&&(n=u,s=0),s+=1,s>Lt?e.drop():e.record({id:E(),type:j.RumEventType.CONSOLE,pageViewId:u,occurredAt:M(Date.now()),level:i,message:Q(c.map($).join(" "),Ut)});}catch{e.drop();}a.apply(console,c);};return console[r]=d,()=>{console[r]===d&&(console[r]=a);}});return ()=>o.forEach(r=>r())};var C=v(g());var J=4096,U=e=>{try{return new URL(e,window.location.href)}catch{return null}},ue=e=>{let t=U(e);return t?`${t.protocol==="ws:"?"http:":t.protocol==="wss:"?"https:":t.protocol}//${t.host}`.toLowerCase():null},B=(e,t)=>{var n;return e.instrumentedOrigins.includes((n=ue(t.href))!=null?n:"")},k=e=>{let t=e==null?void 0:e.name;return t==="AbortError"?C.RumRequestOutcome.ABORTED:t==="TimeoutError"?C.RumRequestOutcome.TIMEOUT:navigator.onLine===false?C.RumRequestOutcome.OFFLINE:C.RumRequestOutcome.NETWORK_ERROR},Z=e=>e>=400?C.RumRequestOutcome.HTTP_ERROR:C.RumRequestOutcome.SUCCESS,q=(e,t,n,s,o,r)=>({id:E(),type:C.RumEventType.REQUEST,pageViewId:e.pageViewId(),kind:t,method:n,url:s,startedAt:M(o),status:null,outcome:C.RumRequestOutcome.SUCCESS,durationMs:null,dnsMs:null,tcpMs:null,tlsMs:null,ttfbMs:null,downloadMs:null,requestId:r,instrumented:r!==null}),Fe=(e,t)=>{let n;try{n=performance.getEntriesByName(e,"resource");}catch{return null}let s=n.filter(o=>performance.timeOrigin+o.startTime>=t-50).pop();return !s||!s.requestStart?null:{dnsMs:S(s.domainLookupStart,s.domainLookupEnd),tcpMs:S(s.connectStart,s.connectEnd),tlsMs:s.secureConnectionStart>0?S(s.secureConnectionStart,s.connectEnd):null,ttfbMs:S(s.requestStart,s.responseStart),downloadMs:S(s.responseStart,s.responseEnd)}};var L=v(g());var w=v(g());var xt=123,ce=(e,t,n)=>{let s=U(String(n));if(!s)return null;let o=s.href,r=null;B(e,s)&&(r=E(),s.searchParams.set(w.SOCKET_REQUEST_ID_PARAM,r),s.searchParams.set(w.SOCKET_SESSION_ID_PARAM,e.sessionId()));let i=Date.now(),a=q(e,t,"GET",o,i,r);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let d={event:a,startedAt:i,opened:false,dirty:true,done:false};return e.trackConnection(d),{connection:d,nativeUrl:r===null?String(n):s.href}},de=e=>{e.opened||(e.opened=true,e.event.connectMs=Date.now()-e.startedAt,e.dirty=true);},ee=(e,t,n)=>{var o,r,i,a;let{event:s}=e;t==="in"?(s.messagesIn=((o=s.messagesIn)!=null?o:0)+1,s.bytesIn=((r=s.bytesIn)!=null?r:0)+ae(n)):(s.messagesOut=((i=s.messagesOut)!=null?i:0)+1,s.bytesOut=((a=s.bytesOut)!=null?a:0)+ae(n)),e.dirty=true;},te=(e,t)=>{e.done||(e.event.durationMs=Date.now()-e.startedAt,e.event.outcome=t,e.done=true,e.dirty=true);},Vt=(e,t,n,s)=>{if(n)return w.RumRequestOutcome.ABORTED;if(e&&(t===1e3||t===1001||s&&t===1005))return w.RumRequestOutcome.SUCCESS;let o=k();return o===w.RumRequestOutcome.OFFLINE||!e?o:w.RumRequestOutcome.HTTP_ERROR},Ke=e=>{let t=window.WebSocket;if(typeof t!="function")return ()=>{};let n=t.prototype,s=n.send,o=n.close,r=new WeakMap,i=(u,l)=>{r.set(u,l),u.addEventListener("open",()=>de(l)),u.addEventListener("message",p=>ee(l,"in",p.data)),u.addEventListener("close",p=>{let h=r.get(u);l.event.closeCode=p.code,l.event.closeReason=p.reason?Q(p.reason,xt):null,te(l,Vt(l.opened,p.code,(h==null?void 0:h.abortedByApp)===true,(h==null?void 0:h.closedByApp)===true));});},a=new Proxy(t,{construct(u,l,p){let h=null;try{h=ce(e,w.RumRequestKind.WEBSOCKET,l[0]);}catch{e.drop();}let b=h?[h.nativeUrl,...l.slice(1)]:l,m=Reflect.construct(u,b,p===a?u:p);return h&&i(m,h.connection),m}}),d=function(u){s.call(this,u);let l=r.get(this);l&&ee(l,"out",u);},c=function(u,l){let p=r.get(this);return p&&(p.abortedByApp=this.readyState===t.CONNECTING,p.closedByApp=true),o.apply(this,arguments)};return window.WebSocket=a,n.send=d,n.close=c,()=>{window.WebSocket===a&&(window.WebSocket=t),n.send===d&&(n.send=s),n.close===c&&(n.close=o);}};var We=e=>{let t=window,n=t.EventSource;if(typeof n!="function")return ()=>{};let s=n.prototype,o=s.close,r=new WeakMap,i=(c,u)=>{r.set(c,u),u.event.reconnectCount=0,c.addEventListener("open",()=>de(u)),c.addEventListener("message",l=>ee(u,"in",l.data)),c.addEventListener("error",()=>{var p;if(c.readyState===n.CONNECTING){u.event.reconnectCount=((p=u.event.reconnectCount)!=null?p:0)+1,u.dirty=true;return}let l=k();te(u,u.opened&&l!==L.RumRequestOutcome.OFFLINE?L.RumRequestOutcome.HTTP_ERROR:l);});},a=new Proxy(n,{construct(c,u,l){let p=null;try{p=ce(e,L.RumRequestKind.SSE,u[0]);}catch{e.drop();}let h=p?[p.nativeUrl,...u.slice(1)]:u,b=Reflect.construct(c,h,l===a?c:l);return p&&i(b,p.connection),b}}),d=function(){o.call(this);let c=r.get(this);c&&te(c,c.opened?L.RumRequestOutcome.SUCCESS:L.RumRequestOutcome.ABORTED);};return t.EventSource=a,s.close=d,()=>{t.EventSource===a&&(t.EventSource=n),s.close===d&&(s.close=o);}};var F=v(g());var Ht=(e,t,n)=>{var u,l,p;let s=typeof Request!="undefined"&&t instanceof Request?t:null,o=U(s?s.url:String(t));if(!o)return null;let r=((l=(u=n==null?void 0:n.method)!=null?u:s==null?void 0:s.method)!=null?l:"GET").toUpperCase(),i=Date.now(),a=null,d=n;if(B(e,o)){a=E();let h=new Headers((p=n==null?void 0:n.headers)!=null?p:s==null?void 0:s.headers);h.set(F.REQUEST_ID_HEADER,a),h.set(F.SESSION_ID_HEADER,e.sessionId()),d={...n,headers:h};}let c=q(e,F.RumRequestKind.FETCH,r,o.href,i,a);return e.trackTiming(c.id,o.href,i),{event:c,init:d,startedAt:i}},Bt=(e,t,n)=>{let{event:s}=t;if(s.durationMs=Date.now()-t.startedAt,s.status=n.status,s.outcome=Z(n.status),s.instrumented||n.status<400){e.record(s);return}n.clone().text().then(o=>{s.responseBodyExcerpt=o.slice(0,J),e.record(s);},()=>e.record(s));},Ge=e=>{let t=window.fetch;if(typeof t!="function")return ()=>{};let n=(s,o)=>{let r=null;try{r=Ht(e,s,o);}catch{e.drop();}let i=t.call(window,s,r?r.init:o);if(r){let a=r;i.then(d=>{try{Bt(e,a,d);}catch{e.drop();}},d=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=k(d),e.record(a.event);});}return i};return window.fetch=n,()=>{window.fetch===n&&(window.fetch=t);}};var D=v(g());var je=e=>{let t=window.XMLHttpRequest;if(typeof t!="function")return ()=>{};let n=t.prototype,s=n.open,o=n.send,r=new WeakMap,i=function(c,u){try{r.set(this,{method:String(c).toUpperCase(),url:String(u)});}catch{e.drop();}return s.apply(this,arguments)},a=(c,u,l)=>{let p=U(l);if(!p)return;let h=Date.now(),b=null;B(e,p)&&(b=E(),c.setRequestHeader(D.REQUEST_ID_HEADER,b),c.setRequestHeader(D.SESSION_ID_HEADER,e.sessionId()));let m=q(e,D.RumRequestKind.XHR,u,p.href,h,b);e.trackTiming(m.id,p.href,h);let T=null;c.addEventListener("error",()=>T=k()),c.addEventListener("abort",()=>T=D.RumRequestOutcome.ABORTED),c.addEventListener("timeout",()=>T=D.RumRequestOutcome.TIMEOUT),c.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=T===null&&c.status>0?c.status:null,m.outcome=m.status===null?T!=null?T:k():Z(m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(c.responseType===""||c.responseType==="text")&&(m.responseBodyExcerpt=c.responseText.slice(0,J)),e.record(m);});},d=function(c){let u=r.get(this);if(u)try{a(this,u.method,u.url);}catch{e.drop();}return o.call(this,c)};return n.open=i,n.send=d,()=>{n.open===i&&(n.open=s),n.send===d&&(n.send=o);}};var le=v(g()),qt=/^([a-z][a-z0-9+.-]*:)\/\//i,Ft=["url","blockedUri","sourceFile"],Kt=["route","referrerRoute","entryPath"],Wt=e=>{let{host:t,path:n}=(0, le.maskUrl)(e);if(t===null)return n;let s=qt.exec(e.trim());return `${s?s[1].toLowerCase():"https:"}//${t}${n}`},pe=e=>(0, le.maskUrl)(e).path,Xe=e=>{let t=e;for(let n of Ft)typeof t[n]=="string"&&(t[n]=Wt(t[n]));for(let n of Kt)typeof t[n]=="string"&&(t[n]=pe(t[n]));return e};var x=v(g());var Gt={reload:x.RumNavigationType.RELOAD,back_forward:x.RumNavigationType.BACK_FORWARD},$e=()=>{try{return performance.getEntriesByType("navigation")[0]}catch{return}},Qe=e=>({dnsMs:e?S(e.domainLookupStart,e.domainLookupEnd):null,tcpMs:e?S(e.connectStart,e.connectEnd):null,tlsMs:e&&e.secureConnectionStart>0?S(e.secureConnectionStart,e.connectEnd):null,requestMs:e?S(e.requestStart,e.responseStart):null,responseMs:e?S(e.responseStart,e.responseEnd):null,domProcessingMs:e?S(e.responseEnd,e.domComplete):null,loadMs:e&&e.loadEventEnd>0?Math.round(e.loadEventEnd-e.startTime):null}),ze=e=>{var h,b;let t=null,n=null,s=(m,T=null,mt)=>{let ge=Date.now();return t={startedAt:ge,path:window.location.pathname,event:{id:E(),type:x.RumEventType.PAGE_VIEW,route:e.resolveRoute(),referrerRoute:T,startedAt:M(ge),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...mt}},e.record({...t.event}),t.event.id},o=()=>{t&&(t.event.durationMs=Date.now()-t.startedAt,e.record({...t.event}));},r=()=>{try{if(e.onNavigation(),t&&window.location.pathname!==t.path){let m=t.event.route;o(),s(x.RumNavigationType.SPA,m);}}catch{e.drop();}},i=()=>{t&&t.event.id===n&&(Object.assign(t.event,Qe($e())),e.record({...t.event}));},a=$e(),d=document.readyState==="complete",c=(b=Gt[(h=a==null?void 0:a.type)!=null?h:""])!=null?b:x.RumNavigationType.NAVIGATE;n=s(c,null,d?Qe(a):void 0);let u=[_(window,"popstate",r)];if(!d){let m;u.push(_(window,"load",()=>{m=setTimeout(i,0);}),()=>clearTimeout(m));}let l=window.history.pushState,p=function(...m){let T=l.apply(this,m);return r(),T};return window.history.pushState=p,u.push(()=>{window.history.pushState===p&&(window.history.pushState=l);}),{currentId:()=>{var m;return (m=t==null?void 0:t.event.id)!=null?m:null},start:m=>{s(m);},end:o,stop:()=>u.forEach(m=>m())}};var Ye=e=>e.replace(/\/+$/,""),me=(e,t)=>`${e.proxyUrl?`${Ye(e.proxyUrl)}/rum`:`${Ye(e.apiUrl)}/api/rum`}/${encodeURIComponent(e.applicationId)}/${t}?token=${encodeURIComponent(e.token)}`;var Ze="abyss-rum-config",jt=600*1e3,Je=e=>typeof e=="number"&&e>=0&&e<=1?e:0,et=e=>{var s,o;let t=e;if(!t||typeof t.enabled!="boolean"||typeof t.sessionSampleRate!="number")return null;let n=(s=t.replay)!=null?s:{};return {enabled:t.enabled,sessionSampleRate:Je(t.sessionSampleRate),sessionQuotaExhausted:t.sessionQuotaExhausted===true,country:typeof t.country=="string"?t.country:null,feedbackEnabled:t.feedbackEnabled===true,replay:{enabled:n.enabled===true,sampleRate:Je(n.sampleRate),unmaskSelectors:Array.isArray(n.unmaskSelectors)?n.unmaskSelectors.filter(r=>typeof r=="string"):[]},socketMessages:{enabled:((o=t.socketMessages)==null?void 0:o.enabled)===true}}},tt=(e,t)=>{let n=z(Ze);if(!n||n.key!==e||typeof n.at!="number")return;let s=t-n.at;return s>=0&&s<jt?et(n.config):void 0},nt=async(e,t,n,s)=>{let o=null;try{let r=await t(e,{credentials:"omit"});o=r.ok?et(await r.json()):null;}catch{o=null;}return Y(Ze,{key:n,at:s,config:o}),o};var ne=v(g()),Xt=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,$t=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,Qt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],st=e=>Xt.test(e)?ne.RumDeviceType.TABLET:$t.test(e)?ne.RumDeviceType.MOBILE:ne.RumDeviceType.DESKTOP,ot=e=>{var t,n;return (n=(t=Qt.find(([s])=>s.test(e)))==null?void 0:t[1])!=null?n:"Other"},rt=(e,t,n,s)=>{if(!e)return n;try{let o=e({...t,attributes:{...t.attributes}});if(typeof(o==null?void 0:o.session)=="boolean"&&typeof o.replay=="boolean")return {session:o.session,replay:o.replay}}catch{}return s(),n};var N=v(g());var zt=200,Yt=(e,t,n)=>({session:e<t,replay:e<t*n}),it=(e,t,n,s)=>{let o=Yt(e.random,e.sessionSampleRate,e.replaySampleRate),r=rt(t,e,o,s),i=r.session&&!n;return {session:i,replay:i&&r.replay}},Jt=e=>e.type===N.RumEventType.REQUEST&&(e.kind===N.RumRequestKind.FETCH||e.kind===N.RumRequestKind.XHR)&&e.outcome===N.RumRequestOutcome.SUCCESS,se=class{constructor(t){this.onDrop=t;this.held=null;this.released=new Set;this.successes=new Map;}accept(t,n){var o,r,i;if(n){if(Jt(t)){let a=(o=t.pageViewId)!=null?o:"",d=((r=this.successes.get(a))!=null?r:0)+1;if(this.successes.set(a,d),d>zt)return this.onDrop(),[]}return [t]}if(t.type===N.RumEventType.PAGE_VIEW)return this.released.has(t.id)?[t]:(this.held=t,[]);if(t.type!==N.RumEventType.ERROR)return [];let s=[];return t.pageViewId!==null&&!this.released.has(t.pageViewId)&&(this.released.add(t.pageViewId),((i=this.held)==null?void 0:i.id)===t.pageViewId&&(s.push(this.held),this.held=null)),s.push(t),s}reset(){this.held=null,this.released.clear(),this.successes.clear();}};var at=v(g());var fe="abyss-rum-session",Zt=1800*1e3,en=14400*1e3,he=(e,t)=>t-e.lastActivityAt>=Zt||t-e.startedAt>=en,tn=e=>typeof(e==null?void 0:e.session)=="boolean"&&typeof e.replay=="boolean",nn=()=>{let e=z(fe);return !e||!(0, at.isUuid)(e.id)||typeof e.startedAt!="number"||typeof e.lastActivityAt!="number"||typeof e.random!="number"?null:{id:e.id,startedAt:e.startedAt,lastActivityAt:e.lastActivityAt,random:e.random,decision:tn(e.decision)?e.decision:null,entryPath:typeof e.entryPath=="string"?e.entryPath:null,cut:e.cut===true}},K=e=>Y(fe,e),ut=()=>Be(fe),Re=e=>{let t={id:E(),startedAt:e,lastActivityAt:e,random:Math.random(),decision:null,entryPath:null,cut:false};return K(t),t},ct=e=>{let t=nn();return t&&!he(t,e)?t:Re(e)};var dt=64*1024,sn=60*1e3;var oe=class{constructor(t,n,s){this.url=t;this.fetchImpl=n;this.handlers=s;this.pausedUntil=0;}isPaused(t){return t<this.pausedUntil}send(t,n,s){let o=JSON.stringify({...t,events:[]}).slice(0,-2),r=H(o)+2,i=[],a=[],d=r;for(let c of n){let u=JSON.stringify(c),l=H(u);if(r+l>dt){this.handlers.onDrop(1);continue}let p=l+(i.length>0?1:0);d+p>dt&&(this.post(`${o}${i.join(",")}]}`,a,s,t.sessionId),i=[],a=[],d=r),d+=l+(i.length>0?1:0),i.push(u),a.push(c);}i.length>0&&this.post(`${o}${i.join(",")}]}`,a,s,t.sessionId);}post(t,n,s,o){let r=i=>this.handlers.onResult(n,i,o);if(s&&this.beacon(t)){r("OK");return}this.fetchImpl(this.url,{method:"POST",body:t,keepalive:true,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,r),()=>r("FAIL")).catch(()=>this.handlers.onDrop(1));}beacon(t){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,t)}catch{return false}}async handle(t,n){if(t.status===429){this.pausedUntil=Date.now()+sn,n("RETRY");return}if(t.status===401||t.status===403||t.status===404){n("CUT");return}if(!t.ok){n("FAIL");return}n("OK");let s=false;try{s=(await t.json()).liveWatched===!0;}catch{}this.handlers.onLiveWatched(s);}};var on=5e3,rn=50,lt=200,an=50,un=e=>{let t=e;return t&&typeof t=="object"&&typeof t.message=="string"?{name:typeof t.name=="string"&&t.name?t.name:"Error",message:t.message,stack:typeof t.stack=="string"?t.stack:null}:{name:"Error",message:$(e),stack:null}},cn=e=>{if(!e||typeof e!="object")return;let t=Object.entries(e).filter(([,n])=>typeof n=="string");return t.length>0?Object.fromEntries(t):void 0},re=class{constructor(t,n){this.options=t;this.shared=n;this.config=null;this.ready=false;this.stopped=false;this.flushing=false;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.connections=new Set;this.timings=new Map;this.sessionDirty=true;this.closed=false;this.liveWatched=false;this.drop=()=>{this.shared.dropped+=1;};var o;let s=window.fetch;this.nativeFetch=(r,i)=>s.call(window,r,i),this.instrumentedOrigins=((o=t.instrumentedOrigins)!=null?o:[]).map(r=>ue(String(r))).filter(r=>r!==null),this.filter=new se(this.drop),this.transport=new oe(me(t,"batch"),this.nativeFetch,{onResult:(r,i,a)=>this.guard(()=>this.onResult(r,i,a)),onLiveWatched:r=>{this.liveWatched=r;},onDrop:r=>{this.shared.dropped+=r;}}),this.session=ct(Date.now());}start(){if(this.session.cut){this.stopped=true;return}let t=Date.now(),n=`${this.options.applicationId}:${this.options.token}`,s=tt(n,t);if(s!==void 0){this.configure(s);return}nt(me(this.options,"config"),this.nativeFetch,n,t).then(o=>this.guard(()=>this.configure(o)),this.drop);}stop(){this.shutdown(),ut();}captureError(t,n){var o,r;let s=cn(n);this.record({id:E(),type:I.RumEventType.ERROR,pageViewId:(r=(o=this.pageViews)==null?void 0:o.currentId())!=null?r:null,occurredAt:M(Date.now()),route:this.resolveRoute(),...un(t),breadcrumbs:[],repeat:1,...s?{context:s}:{}});}markDirty(){this.sessionDirty=true;}replayState(){var n,s,o,r;let t=false;try{t=((s=(n=this.options).consent)==null?void 0:s.call(n).analytics)===!0;}catch{this.drop();}return {record:this.ready&&((o=this.session.decision)==null?void 0:o.replay)===true&&((r=this.config)==null?void 0:r.replay.enabled)===true&&t,liveWatched:this.liveWatched}}guard(t){try{t();}catch{this.drop();}}configure(t){var o,r;if(this.stopped)return;if(!t||!t.enabled){this.shutdown();return}this.config=t,this.session.decision||this.decide(),this.ready=true,this.install();let n=this.pending;this.pending=[];let s=(r=(o=this.pageViews)==null?void 0:o.currentId())!=null?r:null;for(let i of n)i.type===I.RumEventType.ERROR&&i.pageViewId===null&&(i.pageViewId=s),this.record(i);}decide(){let t=this.config,n=navigator.userAgent;this.session.decision=it({route:pe(this.resolveRoute()),deviceType:st(n),browserFamily:ot(n),country:t.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:t.sessionSampleRate,replaySampleRate:t.replay.sampleRate},this.options.sampler,t.sessionQuotaExhausted,this.drop),K(this.session);}install(){let t={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:()=>{var o,r;return (r=(o=this.pageViews)==null?void 0:o.currentId())!=null?r:null},record:o=>this.record(o),drop:this.drop,trackTiming:(o,r,i)=>this.timings.set(o,{url:r,startedAt:i}),trackConnection:o=>this.connections.add(o)};this.pageViews=ze({resolveRoute:()=>this.resolveRoute(),record:o=>this.record(o),onNavigation:()=>this.touch(),drop:this.drop});let n=setInterval(()=>this.guard(()=>this.flush(false)),on),s=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(n),Ge(t),je(t),Ke(t),We(t),...this.options.captureConsole===false?[]:[qe(t)],_(window,"click",s,true),_(window,"keydown",s,true),_(window,"error",o=>this.guard(()=>{var r;return this.captureError((r=o.error)!=null?r:o.message)})),_(window,"pagehide",()=>this.guard(()=>this.onPageHide())),_(window,"pageshow",o=>this.guard(()=>{var r;o.persisted&&(this.closed=false,this.sessionDirty=true,(r=this.pageViews)==null||r.start(I.RumNavigationType.BACK_FORWARD));})),_(document,"visibilitychange",()=>this.guard(()=>{document.visibilityState==="hidden"&&this.flush(true);}))];}shutdown(){this.stopped=true,this.ready=false;let t=this.teardowns;this.teardowns=[],t.reverse().forEach(n=>this.guard(n)),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear();}resolveRoute(){let{routeResolver:t}=this.options;if(t)try{return String(t(window.location))}catch{this.drop();}return window.location.pathname}touch(){var n,s;if(!this.ready)return;let t=Date.now();if(!he(this.session,t)){this.session.lastActivityAt=t,K(this.session);return}(n=this.pageViews)==null||n.end(),this.flush(false),this.shared.dropped+=this.queue.length,this.queue=[],this.session=Re(t),this.decide(),this.filter.reset(),this.sessionDirty=true,this.closed=false,(s=this.pageViews)==null||s.start(I.RumNavigationType.SPA);}onPageHide(){var t;(t=this.pageViews)==null||t.end();for(let n of this.connections)n.done||(n.event.durationMs=Date.now()-n.startedAt,n.done=true,n.dirty=true);this.closed=true,this.sessionDirty=true,this.flush(true);}record(t){var n;try{if(this.stopped)return;if(!this.ready){this.pending.length<an?this.pending.push(t):this.drop();return}let s=((n=this.session.decision)==null?void 0:n.session)===!0;if(!s&&t.type!==I.RumEventType.ERROR&&t.type!==I.RumEventType.PAGE_VIEW)return;let o=He(t,this.options.beforeSend,this.drop);if(!o)return;Xe(o),o.type===I.RumEventType.PAGE_VIEW&&this.session.entryPath===null&&(this.session.entryPath=o.route,K(this.session));for(let r of this.filter.accept(o,s))this.enqueue(r);}catch{this.drop();}}enqueue(t){if(this.queue.length>=lt){this.drop();return}this.queue.push(t),this.queue.length>=rn&&!this.flushing&&this.flush(false);}flush(t){var n,s;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=true;try{for(let d of this.connections)d.dirty&&(d.dirty=!1,this.record({...d.event})),d.done&&this.connections.delete(d);let o=this.queue;this.queue=[],this.fillTimings(o);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(o.length===0&&!(r&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:I.RumEventType.SESSION,entryPath:(s=this.session.entryPath)!=null?s:"/",sampled:r,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...o]:o,t);}finally{this.flushing=false;}}}header(){let t={sessionId:this.session.id,sessionStartedAt:M(this.session.startedAt)};return this.options.release&&(t.release=this.options.release),this.shared.actor!==void 0&&(t.actor=this.shared.actor),this.shared.attributesSet&&(t.attributes={...this.shared.attributes}),t}fillTimings(t){for(let n of t){let s=this.timings.get(n.id);s&&(this.timings.delete(n.id),Object.assign(n,Fe(s.url,s.startedAt)));}}onResult(t,n,s){if(n==="OK")return;if(n==="CUT"){this.session.cut=true,K(this.session),this.shutdown();return}let o=t.filter(i=>i.type!==I.RumEventType.SESSION),r=t.find(i=>i.type===I.RumEventType.SESSION);if(r&&(this.shared.dropped+=r.droppedEvents,this.sessionDirty=true),n==="RETRY"&&s===this.session.id){let i=o.slice(0,Math.max(0,lt-this.queue.length));this.shared.dropped+=o.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=o.length;}},pt=null,y={actor:void 0,attributes:{},attributesSet:false,dropped:0},W=()=>pt,Ee=e=>{pt=e;};var X=e=>{try{e();}catch{y.dropped+=1;}},Ts={init(e){X(()=>{if(W()||!(e!=null&&e.token)||!e.applicationId||!e.apiUrl&&!e.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let t=new re(e,y);Ee(t),t.start();});},setActor(e){X(()=>{var n;let t=ye(e);if(t===void 0){y.dropped+=1;return}y.actor=t,(n=W())==null||n.markDirty();});},setAttributes(e){X(()=>{var t;y.attributes=ve(y.attributes,e,()=>{y.dropped+=1;}),y.attributesSet=!0,(t=W())==null||t.markDirty();});},captureError(e,t){X(()=>{var n;return (n=W())==null?void 0:n.captureError(e,t)});},stop(){X(()=>{var e;(e=W())==null||e.stop(),Ee(null),y.actor=void 0,y.attributes={},y.attributesSet=!1,y.dropped=0;});}};
|
|
2
|
-
exports.AbyssRum=Ts;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunkLRYKS5XRjs = require('./chunk-LRYKS5XR.js');var _chunkIZ7REN7Ejs = require('./chunk-IZ7REN7E.js');var _chunkUZZNGXXEjs = require('./chunk-UZZNGXXE.js');var Se=t=>t===null?null:typeof t=="string"&&t.trim()!==""?t:void 0;var be=50,D=class{constructor(){this.session={};this.pageViewId=null;this.page={}}add(e,s,n){if(s==null)return n(),!1;let r=!1,o=()=>{r=!0,n()},i={[String(e)]:s};return this.session=_chunkIZ7REN7Ejs.a.call(void 0, this.session,i,o,be),r||(this.page=_chunkIZ7REN7Ejs.a.call(void 0, this.page,i,o,be)),!r}hasAny(){return Object.keys(this.session).length>0}annotate(e){e.id!==this.pageViewId&&(this.pageViewId!==null&&(this.page={}),this.pageViewId=e.id),Object.keys(this.page).length>0&&(e.featureFlags={...this.page})}};var Qe=64,we=(t,e,s,n)=>{if(typeof t!="string"||t.length===0||t.length>Qe)return n(),null;let r={id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"action",pageViewId:s,occurredAt:_chunkUZZNGXXEjs.g.call(void 0, Date.now()),name:t};if(e!==void 0){let o=_chunkIZ7REN7Ejs.a.call(void 0, {},e,n);Object.keys(o).length>0&&(r.attributes=o)}return r};var ze=["id","type","sessionId"],Je=(t,e)=>t==null?e==null||["string","number","boolean"].includes(typeof e):Array.isArray(t)?Array.isArray(e):e!==null&&typeof e==typeof t,te=(t,e,s)=>{if(!e)return t;let n;try{n=e(JSON.parse(JSON.stringify(t)))}catch (e2){return s(),t}if(n===null)return null;if(!n||typeof n!="object"||Array.isArray(n))return s(),null;let r=t,o=n,i={};for(let a of Object.keys(r))if(ze.includes(a))i[a]=r[a];else if(Je(r[a],o[a]))o[a]!==void 0&&(i[a]=o[a]);else return s(),null;return i};var Ze=/^([a-z][a-z0-9+.-]*:)\/\//i,et=["url","blockedUri","sourceFile"],tt=["route","referrerRoute","entryPath"],se=t=>{let{host:e,path:s}=_chunkUZZNGXXEjs.b.call(void 0, t);if(e===null)return s;let n=Ze.exec(t.trim());return`${n?n[1].toLowerCase():"https:"}//${e}${s}`},x=t=>_chunkUZZNGXXEjs.b.call(void 0, t).path,ne=t=>{let e=t;for(let s of et)typeof e[s]=="string"&&(e[s]=se(e[s]));for(let s of tt)typeof e[s]=="string"&&(e[s]=x(e[s]));return t};var st=20,nt=256,rt='[data-testid],[aria-label],button,a,input,select,textarea,summary,[role="button"],[role="link"]',Ie=(t,e)=>{let s=t.getAttribute(e);return s===null?null:s.slice(0,nt)},re=t=>{var s;let e=(s=t.closest(rt))!=null?s:t;return{tag:e.tagName.toLowerCase().slice(0,64),testId:Ie(e,"data-testid"),ariaLabel:Ie(e,"aria-label")}},q=class{constructor(){this.items=[];this.lastPageViewId=null}observe(e){e.type==="pageView"&&e.id!==this.lastPageViewId?(this.lastPageViewId=e.id,this.add({kind:"NAVIGATION",route:x(e.route)})):e.type==="request"&&e.kind!=="WEBSOCKET"&&e.kind!=="SSE"&&this.add({kind:"REQUEST",method:e.method,url:se(e.url),status:e.status})}click(e){e instanceof Element&&this.add({kind:"CLICK",element:re(e)})}snapshot(){return this.items.map(e=>({...e}))}add(e){this.items.push({...e,occurredAt:_chunkUZZNGXXEjs.g.call(void 0, Date.now())}),this.items.length>st&&this.items.shift()}};var ot=/^\s*at\s|@\S+:\d+/,it=t=>{var e,s;return(s=(e=(t!=null?t:"").split(`
|
|
2
|
+
`).find(n=>ot.test(n)))==null?void 0:e.trim())!=null?s:""},W=class{constructor(e){this.release=e;this.held=new Map}add(e){var r;let s=`${(r=e.pageViewId)!=null?r:""}${e.message}${it(e.stack)}`,n=this.held.get(s);if(n){n.event.repeat+=1;return}this.held.set(s,{event:e,timer:setTimeout(()=>this.releaseKey(s),1e4)})}flush(){[...this.held.keys()].forEach(e=>this.releaseKey(e))}clear(){this.held.forEach(e=>clearTimeout(e.timer)),this.held.clear()}releaseKey(e){let s=this.held.get(e);s&&(clearTimeout(s.timer),this.held.delete(e),this.release(s.event))}};var at=/^ResizeObserver loop/,ut=/^Script error\.?$/,dt=t=>{let e=t;return e&&typeof e=="object"&&typeof e.message=="string"?{name:typeof e.name=="string"&&e.name?e.name:"Error",message:e.message,stack:typeof e.stack=="string"?e.stack:null}:{name:"Error",message:_chunkUZZNGXXEjs.i.call(void 0, t),stack:null}},lt=t=>{if(!t||typeof t!="object")return;let e=Object.entries(t).filter(([,s])=>typeof s=="string");return e.length>0?Object.fromEntries(e):void 0},ct=t=>at.test(t.message)||ut.test(t.message)&&!t.stack,j=class{constructor(e){this.host=e;this.breadcrumbs=new q;this.pageViewId=null;this.dedup=new W(s=>e.record(s))}capture(e,s){let n=dt(e);if(ct(n)){this.host.drop();return}this.host.captured();let r=lt(s);this.dedup.add({id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"error",pageViewId:this.host.pageViewId(),occurredAt:_chunkUZZNGXXEjs.g.call(void 0, Date.now()),route:this.host.resolveRoute(),...n,breadcrumbs:this.breadcrumbs.snapshot(),repeat:1,...r?{context:r}:{}})}observe(e){this.breadcrumbs.observe(e),e.type==="pageView"&&e.id!==this.pageViewId&&(this.pageViewId!==null&&this.dedup.flush(),this.pageViewId=e.id)}install(){let e=n=>()=>{try{n()}catch (e3){this.host.drop()}},s=[_chunkUZZNGXXEjs.j.call(void 0, window,"error",n=>{n.target instanceof Element||e(()=>{var r;return this.capture((r=n.error)!=null?r:n.message)})()}),_chunkUZZNGXXEjs.j.call(void 0, window,"unhandledrejection",n=>e(()=>this.capture(n.reason))()),_chunkUZZNGXXEjs.j.call(void 0, window,"click",n=>e(()=>this.breadcrumbs.click(n.target))(),!0),_chunkUZZNGXXEjs.j.call(void 0, window,"pagehide",e(()=>this.dedup.flush())),_chunkUZZNGXXEjs.j.call(void 0, document,"visibilitychange",e(()=>{document.visibilityState==="hidden"&&this.dedup.flush()}))];return()=>{s.forEach(n=>n()),this.dedup.clear()}}};var mt=123,ie=(t,e,s)=>{let n=_chunkIZ7REN7Ejs.c.call(void 0, String(s));if(!n)return null;let r=n.href,o=null;_chunkIZ7REN7Ejs.e.call(void 0, t,n)&&(o=_chunkUZZNGXXEjs.q.call(void 0, ),n.searchParams.set(_chunkUZZNGXXEjs.e,o),n.searchParams.set(_chunkUZZNGXXEjs.f,t.sessionId()));let i=Date.now(),a=_chunkIZ7REN7Ejs.h.call(void 0, t,e,"GET",r,i,o);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let p={event:a,startedAt:i,opened:!1,dirty:!0,done:!1};return t.trackConnection(p),{connection:p,nativeUrl:o===null?String(s):n.href}},ae=t=>{t.opened||(t.opened=!0,t.event.connectMs=Date.now()-t.startedAt,t.dirty=!0)},K=(t,e,s)=>{var r,o,i,a;let{event:n}=t;e==="in"?(n.messagesIn=((r=n.messagesIn)!=null?r:0)+1,n.bytesIn=((o=n.bytesIn)!=null?o:0)+_chunkUZZNGXXEjs.m.call(void 0, s)):(n.messagesOut=((i=n.messagesOut)!=null?i:0)+1,n.bytesOut=((a=n.bytesOut)!=null?a:0)+_chunkUZZNGXXEjs.m.call(void 0, s)),t.dirty=!0},X=(t,e)=>{t.done||(t.event.durationMs=Date.now()-t.startedAt,t.event.outcome=e,t.done=!0,t.dirty=!0)},ke=(t,e)=>({direction:t,data:e,at:Date.now(),eventName:null,eventId:null}),ht=(t,e,s,n)=>{if(s)return"ABORTED";if(t&&(e===1e3||e===1001||n&&e===1005))return"SUCCESS";let r=_chunkIZ7REN7Ejs.f.call(void 0, );return r==="OFFLINE"||!t?r:"HTTP_ERROR"},Ae=t=>{let e=window.WebSocket;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.send,r=s.close,o=new WeakMap,i=(u,d)=>{o.set(u,d),u.addEventListener("open",()=>ae(d)),u.addEventListener("message",c=>{K(d,"in",c.data),t.socketMessage(d,ke("IN",c.data))}),u.addEventListener("close",c=>{let h=o.get(u);d.event.closeCode=c.code,d.event.closeReason=c.reason?_chunkUZZNGXXEjs.l.call(void 0, c.reason,mt):null,X(d,ht(d.opened,c.code,(h==null?void 0:h.abortedByApp)===!0,(h==null?void 0:h.closedByApp)===!0)),t.socketClosed(d)})},a=new Proxy(e,{construct(u,d,c){let h=null;try{h=ie(t,"WEBSOCKET",d[0])}catch (e4){t.drop()}let y=h?[h.nativeUrl,...d.slice(1)]:d,m=Reflect.construct(u,y,c===a?u:c);return h&&i(m,h.connection),m}}),p=function(u){n.call(this,u);let d=o.get(this);d&&(K(d,"out",u),t.socketMessage(d,ke("OUT",u)))},l=function(u,d){let c=o.get(this);return c&&(c.abortedByApp=this.readyState===e.CONNECTING,c.closedByApp=!0),r.apply(this,arguments)};return window.WebSocket=a,s.send=p,s.close=l,()=>{window.WebSocket===a&&(window.WebSocket=e),s.send===p&&(s.send=n),s.close===l&&(s.close=r)}};var Te=t=>{let e=window,s=e.EventSource;if(typeof s!="function")return()=>{};let n=s.prototype,r=n.close,o=new WeakMap,i=(l,u)=>{o.set(l,u),u.event.reconnectCount=0,l.addEventListener("open",()=>ae(u)),l.addEventListener("message",d=>{K(u,"in",d.data),t.socketMessage(u,{direction:"IN",data:d.data,at:Date.now(),eventName:d.type,eventId:d.lastEventId||null})}),l.addEventListener("error",()=>{var c;if(l.readyState===s.CONNECTING){u.event.reconnectCount=((c=u.event.reconnectCount)!=null?c:0)+1,u.dirty=!0;return}let d=_chunkIZ7REN7Ejs.f.call(void 0, );X(u,u.opened&&d!=="OFFLINE"?"HTTP_ERROR":d),t.socketClosed(u)})},a=new Proxy(s,{construct(l,u,d){let c=null;try{c=ie(t,"SSE",u[0])}catch (e5){t.drop()}let h=c?[c.nativeUrl,...u.slice(1)]:u,y=Reflect.construct(l,h,d===a?l:d);return c&&i(y,c.connection),y}}),p=function(){r.call(this);let l=o.get(this);l&&(X(l,l.opened?"SUCCESS":"ABORTED"),t.socketClosed(l))};return e.EventSource=a,n.close=p,()=>{e.EventSource===a&&(e.EventSource=s),n.close===p&&(n.close=r)}};var ft=(t,e,s)=>{var u,d,c;let n=typeof Request!="undefined"&&e instanceof Request?e:null,r=_chunkIZ7REN7Ejs.c.call(void 0, n?n.url:String(e));if(!r)return null;let o=((d=(u=s==null?void 0:s.method)!=null?u:n==null?void 0:n.method)!=null?d:"GET").toUpperCase(),i=Date.now(),a=null,p=s;if(_chunkIZ7REN7Ejs.e.call(void 0, t,r)){a=_chunkUZZNGXXEjs.q.call(void 0, );let h=new Headers((c=s==null?void 0:s.headers)!=null?c:n==null?void 0:n.headers);h.set(_chunkUZZNGXXEjs.c,a),h.set(_chunkUZZNGXXEjs.d,t.sessionId()),p={...s,headers:h}}let l=_chunkIZ7REN7Ejs.h.call(void 0, t,"FETCH",o,r.href,i,a);return t.trackTiming(l.id,r.href,i),{event:l,init:p,startedAt:i}},gt=(t,e,s)=>{let{event:n}=e;if(n.durationMs=Date.now()-e.startedAt,n.status=s.status,n.outcome=_chunkIZ7REN7Ejs.g.call(void 0, s.status),n.instrumented||s.status<400){t.record(n);return}s.clone().text().then(r=>{n.responseBodyExcerpt=r.slice(0,_chunkIZ7REN7Ejs.b),t.record(n)},()=>t.record(n))},Oe=t=>{let e=window.fetch;if(typeof e!="function")return()=>{};let s=(n,r)=>{let o=null;try{o=ft(t,n,r)}catch (e6){t.drop()}let i=e.call(window,n,o?o.init:r);if(o){let a=o;i.then(p=>{try{gt(t,a,p)}catch (e7){t.drop()}},p=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=_chunkIZ7REN7Ejs.f.call(void 0, p),t.record(a.event)})}return i};return window.fetch=s,()=>{window.fetch===s&&(window.fetch=e)}};var Ce=t=>{let e=window.XMLHttpRequest;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.open,r=s.send,o=new WeakMap,i=function(l,u){try{o.set(this,{method:String(l).toUpperCase(),url:String(u)})}catch (e8){t.drop()}return n.apply(this,arguments)},a=(l,u,d)=>{let c=_chunkIZ7REN7Ejs.c.call(void 0, d);if(!c)return;let h=Date.now(),y=null;_chunkIZ7REN7Ejs.e.call(void 0, t,c)&&(y=_chunkUZZNGXXEjs.q.call(void 0, ),l.setRequestHeader(_chunkUZZNGXXEjs.c,y),l.setRequestHeader(_chunkUZZNGXXEjs.d,t.sessionId()));let m=_chunkIZ7REN7Ejs.h.call(void 0, t,"XHR",u,c.href,h,y);t.trackTiming(m.id,c.href,h);let E=null;l.addEventListener("error",()=>E=_chunkIZ7REN7Ejs.f.call(void 0, )),l.addEventListener("abort",()=>E="ABORTED"),l.addEventListener("timeout",()=>E="TIMEOUT"),l.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=E===null&&l.status>0?l.status:null,m.outcome=m.status===null?E!=null?E:_chunkIZ7REN7Ejs.f.call(void 0, ):_chunkIZ7REN7Ejs.g.call(void 0, m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(l.responseType===""||l.responseType==="text")&&(m.responseBodyExcerpt=l.responseText.slice(0,_chunkIZ7REN7Ejs.b)),t.record(m)})},p=function(l){let u=o.get(this);if(u)try{a(this,u.method,u.url)}catch (e9){t.drop()}return r.call(this,l)};return s.open=i,s.send=p,()=>{s.open===i&&(s.open=n),s.send===p&&(s.send=r)}};var V=class{constructor(e,s){this.max=e;this.drop=s;this.value=null;this.calls=null;this.failed=!1}get(){return this.value}hold(){!this.value&&!this.calls&&(this.calls=[])}run(e){if(this.value)try{e(this.value)}catch (e10){this.drop()}else this.calls&&this.calls.length<this.max?this.calls.push(e):(this.calls||this.failed)&&this.drop()}resolve(e){var n;let s=(n=this.calls)!=null?n:[];this.calls=null,this.value=e,s.forEach(r=>this.run(r))}fail(){var e;((e=this.calls)!=null?e:[]).forEach(()=>this.drop()),this.calls=null,this.failed=!0}close(){this.value=null,this.calls=null}};var vt={reload:"RELOAD",back_forward:"BACK_FORWARD"},De=()=>{try{return performance.getEntriesByType("navigation")[0]}catch (e11){return}},Me=t=>({dnsMs:t?_chunkUZZNGXXEjs.h.call(void 0, t.domainLookupStart,t.domainLookupEnd):null,tcpMs:t?_chunkUZZNGXXEjs.h.call(void 0, t.connectStart,t.connectEnd):null,tlsMs:t&&t.secureConnectionStart>0?_chunkUZZNGXXEjs.h.call(void 0, t.secureConnectionStart,t.connectEnd):null,requestMs:t?_chunkUZZNGXXEjs.h.call(void 0, t.requestStart,t.responseStart):null,responseMs:t?_chunkUZZNGXXEjs.h.call(void 0, t.responseStart,t.responseEnd):null,domProcessingMs:t?_chunkUZZNGXXEjs.h.call(void 0, t.responseEnd,t.domComplete):null,loadMs:t&&t.loadEventEnd>0?Math.round(t.loadEventEnd-t.startTime):null}),Pe=t=>{var h,y;let e=null,s=null,n=(m,E=null,Ye)=>{let pe=Date.now();return e={startedAt:pe,path:window.location.pathname,event:{id:_chunkUZZNGXXEjs.q.call(void 0, ),type:"pageView",route:t.resolveRoute(),referrerRoute:E,startedAt:_chunkUZZNGXXEjs.g.call(void 0, pe),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...Ye}},t.record({...e.event}),e.event.id},r=()=>{e&&(e.event.durationMs=Date.now()-e.startedAt,t.record({...e.event}))},o=()=>{try{if(t.onNavigation(),e&&window.location.pathname!==e.path){let m=e.event.route;r(),n("SPA",m)}}catch (e12){t.drop()}},i=()=>{e&&e.event.id===s&&(Object.assign(e.event,Me(De())),t.record({...e.event}))},a=De(),p=document.readyState==="complete",l=(y=vt[(h=a==null?void 0:a.type)!=null?h:""])!=null?y:"NAVIGATE";s=n(l,null,p?Me(a):void 0);let u=[_chunkUZZNGXXEjs.j.call(void 0, window,"popstate",o)];if(!p){let m;u.push(_chunkUZZNGXXEjs.j.call(void 0, window,"load",()=>{m=setTimeout(i,0)}),()=>clearTimeout(m))}let d=window.history.pushState,c=function(...m){let E=d.apply(this,m);return o(),E};return window.history.pushState=c,u.push(()=>{window.history.pushState===c&&(window.history.pushState=d)}),{currentId:()=>{var m;return(m=e==null?void 0:e.event.id)!=null?m:null},start:m=>{n(m)},end:r,stop:()=>u.forEach(m=>m())}};var xe=t=>t.replace(/\/+$/,""),G=(t,e)=>`${t.proxyUrl?`${xe(t.proxyUrl)}/rum`:`${xe(t.apiUrl)}/api/rum`}/${encodeURIComponent(t.applicationId)}/${e}?token=${encodeURIComponent(t.token)}`;var Ve="abyss-rum-config",yt=600*1e3,_e=t=>typeof t=="number"&&t>=0&&t<=1?t:0,Fe=t=>{var n,r;let e=t;if(!e||typeof e.enabled!="boolean"||typeof e.sessionSampleRate!="number")return null;let s=(n=e.replay)!=null?n:{};return{enabled:e.enabled,sessionSampleRate:_e(e.sessionSampleRate),sessionQuotaExhausted:e.sessionQuotaExhausted===!0,country:typeof e.country=="string"?e.country:null,feedbackEnabled:e.feedbackEnabled===!0,replay:{enabled:s.enabled===!0,sampleRate:_e(s.sampleRate),unmaskSelectors:Array.isArray(s.unmaskSelectors)?s.unmaskSelectors.filter(o=>typeof o=="string"):[]},socketMessages:{enabled:((r=e.socketMessages)==null?void 0:r.enabled)===!0}}},Ne=(t,e)=>{let s=_chunkUZZNGXXEjs.n.call(void 0, Ve);if(!s||s.key!==t||typeof s.at!="number")return;let n=e-s.at;return n>=0&&n<yt?Fe(s.config):void 0},Le=async(t,e,s,n)=>{let r=null;try{let o=await e(t,{credentials:"omit"});r=o.ok?Fe(await o.json()):null}catch (e13){r=null}return _chunkUZZNGXXEjs.o.call(void 0, Ve,{key:s,at:n,config:r}),r};var Et=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,St=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,bt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],He=t=>Et.test(t)?"tablet":St.test(t)?"mobile":"desktop",Ue=t=>{var e,s;return(s=(e=bt.find(([n])=>n.test(t)))==null?void 0:e[1])!=null?s:"Other"},Be=(t,e,s,n)=>{if(!t)return s;try{let r=t({...e,attributes:{...e.attributes}});if(typeof(r==null?void 0:r.session)=="boolean"&&typeof r.replay=="boolean")return{session:r.session,replay:r.replay}}catch (e14){}return n(),s};var wt=200,It=(t,e,s)=>({session:t<e,replay:t<e*s}),qe=(t,e,s,n)=>{let r=It(t.random,t.sessionSampleRate,t.replaySampleRate),o=Be(e,t,r,n),i=o.session&&!s;return{session:i,replay:i&&o.replay}},kt=t=>t.type==="request"&&(t.kind==="FETCH"||t.kind==="XHR")&&t.outcome==="SUCCESS",$=class{constructor(e){this.onDrop=e;this.held=null;this.released=new Set;this.successes=new Map}accept(e,s){var r,o,i;if(s){if(kt(e)){let a=(r=e.pageViewId)!=null?r:"",p=((o=this.successes.get(a))!=null?o:0)+1;if(this.successes.set(a,p),p>wt)return this.onDrop(),[]}return[e]}if(e.type==="pageView")return this.released.has(e.id)?[e]:(this.held=e,[]);if(e.type!=="error")return[];let n=[];return e.pageViewId!==null&&!this.released.has(e.pageViewId)&&(this.released.add(e.pageViewId),((i=this.held)==null?void 0:i.id)===e.pageViewId&&(n.push(this.held),this.held=null)),n.push(e),n}reset(){this.held=null,this.released.clear(),this.successes.clear()}};var ue="abyss-rum-session",At=1800*1e3,Tt=14400*1e3,de=(t,e)=>e-t.lastActivityAt>=At||e-t.startedAt>=Tt,Ot=t=>typeof(t==null?void 0:t.session)=="boolean"&&typeof t.replay=="boolean",Ct=()=>{let t=_chunkUZZNGXXEjs.n.call(void 0, ue);return!t||!_chunkUZZNGXXEjs.a.call(void 0, t.id)||typeof t.startedAt!="number"||typeof t.lastActivityAt!="number"||typeof t.random!="number"?null:{id:t.id,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,random:t.random,decision:Ot(t.decision)?t.decision:null,entryPath:typeof t.entryPath=="string"?t.entryPath:null,cut:t.cut===!0}},M=t=>_chunkUZZNGXXEjs.o.call(void 0, ue,t),We=()=>_chunkUZZNGXXEjs.p.call(void 0, ue),le=t=>{let e={id:_chunkUZZNGXXEjs.q.call(void 0, ),startedAt:t,lastActivityAt:t,random:Math.random(),decision:null,entryPath:null,cut:!1};return M(e),e},je=t=>{let e=Ct();return e&&!de(e,t)?e:le(t)};var Ke=64*1024,Dt=60*1e3;var Y=class{constructor(e,s,n){this.url=e;this.fetchImpl=s;this.handlers=n;this.pausedUntil=0}isPaused(e){return e<this.pausedUntil}send(e,s,n){let r=JSON.stringify({...e,events:[]}).slice(0,-2),o=_chunkUZZNGXXEjs.k.call(void 0, r)+2,i=[],a=[],p=o;for(let l of s){let u=JSON.stringify(l),d=_chunkUZZNGXXEjs.k.call(void 0, u);if(o+d>Ke){this.handlers.onDrop(1);continue}let c=d+(i.length>0?1:0);p+c>Ke&&(this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId),i=[],a=[],p=o),p+=d+(i.length>0?1:0),i.push(u),a.push(l)}i.length>0&&this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId)}post(e,s,n,r){let o=i=>this.handlers.onResult(s,i,r);if(n&&this.beacon(e)){o("OK");return}this.fetchImpl(this.url,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,o),()=>o("FAIL")).catch(()=>this.handlers.onDrop(1))}beacon(e){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,e)}catch (e15){return!1}}async handle(e,s){if(e.status===429){this.pausedUntil=Date.now()+Dt,s("RETRY");return}if(e.status===401||e.status===403||e.status===404){s("CUT");return}if(!e.ok){s("FAIL");return}s("OK");let n=!1;try{n=(await e.json()).liveWatched===!0}catch (e16){}this.handlers.onLiveWatched(n)}};var Mt=5e3,Pt=50,Xe=200,xt=50,_t=100,Vt=200,Q=class{constructor(e,s){this.options=e;this.shared=s;this.config=null;this.ready=!1;this.stopped=!1;this.flushing=!1;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.lastPageViewId=null;this.deferred=new V(_t,()=>this.drop());this.sockets=new V(Vt,()=>this.drop());this.errors=new j({pageViewId:()=>this.pageViewId(),resolveRoute:()=>this.resolveRoute(),record:e=>this.record(e),drop:()=>this.drop(),captured:()=>{var s;let e=Date.now();(s=this.deferred.get())==null||s.frustration.notifyError(),this.sockets.run(n=>n.anomaly(e))}});this.connections=new Set;this.timings=new Map;this.sessionDirty=!0;this.closed=!1;this.liveWatched=!1;this.drop=()=>{this.shared.dropped+=1};this.pageViewId=()=>{var e,s;return(s=(e=this.pageViews)==null?void 0:e.currentId())!=null?s:null};var r;let n=window.fetch;this.nativeFetch=(o,i)=>n.call(window,o,i),this.instrumentedOrigins=((r=e.instrumentedOrigins)!=null?r:[]).map(o=>_chunkIZ7REN7Ejs.d.call(void 0, String(o))).filter(o=>o!==null),this.filter=new $(this.drop),this.transport=new Y(G(e,"batch"),this.nativeFetch,{onResult:(o,i,a)=>this.guard(()=>this.onResult(o,i,a)),onLiveWatched:o=>{this.liveWatched=o},onDrop:o=>{this.shared.dropped+=o}}),this.session=je(Date.now()),this.deferred.hold()}start(){if(this.session.cut){this.stopped=!0;return}let e=Date.now(),s=`${this.options.applicationId}:${this.options.token}`,n=Ne(s,e);if(n!==void 0){this.configure(n);return}Le(G(this.options,"config"),this.nativeFetch,s,e).then(r=>this.guard(()=>this.configure(r)),this.drop)}stop(){this.shutdown(),We()}captureError(e,s){this.errors.capture(e,s)}addAction(e,s){let n=we(e,s,this.pageViewId(),this.drop);n&&this.record(n)}addTiming(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.addTiming(e,s))}startDuration(e,s){let n=Date.now();this.deferred.run(r=>r.perf.timings.startDuration(e,s,n))}stopDuration(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.stopDuration(e,s))}sendFeedback(e){let s=this.feedbackState();return s!==null?Promise.reject(new (0, _chunkLRYKS5XRjs.b)(s)):this.feedback((n,r)=>n.sendFeedback(r,e))}showReportDialog(e){this.feedbackState()===null&&this.feedback((s,n)=>s.showReportDialog(n,e!=null?e:{})).catch(this.drop)}markDirty(){this.sessionDirty=!0}replayState(){var s,n,r,o;let e=!1;try{e=((n=(s=this.options).consent)==null?void 0:n.call(s).analytics)===!0}catch (e17){this.drop()}return{record:this.ready&&((r=this.session.decision)==null?void 0:r.replay)===!0&&((o=this.config)==null?void 0:o.replay.enabled)===!0&&e,liveWatched:this.liveWatched}}guard(e){try{e()}catch (e18){this.drop()}}load(e,s){e.catch(()=>{this.drop(),s()})}feedback(e){return Promise.resolve().then(() => _interopRequireWildcard(require("./send-67SJQRSY.js"))).then(s=>e(s,this.feedbackHost()),()=>{throw new (0, _chunkLRYKS5XRjs.b)("SEND_FAILED")})}feedbackState(){var e;return!this.ready||this.stopped?"NO_SESSION":((e=this.config)==null?void 0:e.feedbackEnabled)===!0?null:"FEEDBACK_DISABLED"}feedbackHost(){return{unavailable:()=>this.feedbackState(),sessionId:()=>this.session.id,sessionStartedAt:()=>this.session.startedAt,pageViewId:this.pageViewId,resolveRoute:()=>this.resolveRoute(),prepare:e=>{let s=te(e,this.options.beforeSend,this.drop);return s&&ne(s)},post:e=>(this.flush(!1),this.nativeFetch(G(this.options,"feedback"),{method:"POST",body:JSON.stringify({...this.header(),events:[e]}),keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(s=>s.status)),sent:e=>this.guard(()=>{var s,n;return(n=(s=this.options).onFeedbackSent)==null?void 0:n.call(s,e)})}}loadDeferred(e){this.load(Promise.resolve().then(() => _interopRequireWildcard(require("./deferred-PTNDFC5D.js"))).then(({installDeferred:s})=>this.guard(()=>{if(this.stopped)return;let n=s({instrument:e,resolveRoute:()=>this.resolveRoute(),captureConsole:this.options.captureConsole!==!1,describe:re});this.teardowns.push(n.teardown),this.deferred.resolve(n)})),()=>this.deferred.fail())}loadSocketCapture(e){var n;let s=this.options.captureSocketMessages;!s||!e.socketMessages.enabled||((n=this.session.decision)==null?void 0:n.session)!==!0||(this.sockets.hold(),this.load(Promise.resolve().then(() => _interopRequireWildcard(require("./socket-messages-WSFNWWG4.js"))).then(({SocketMessageCapture:r})=>this.guard(()=>{this.stopped||this.sockets.resolve(new r(s,{sessionId:()=>this.session.id,record:o=>this.record(o),drop:this.drop}))})),()=>this.sockets.fail()))}onPageView(e){var s,n;this.shared.featureFlags.annotate(e),(s=this.deferred.get())==null||s.perf.annotate(e),this.record(e),e.id!==this.lastPageViewId&&(this.lastPageViewId=e.id,(n=this.deferred.get())==null||n.frustration.notifyActivity()),this.deferred.run(r=>r.perf.pageViewSent(e))}configure(e){if(this.stopped)return;if(!e||!e.enabled){this.shutdown();return}this.config=e,this.session.decision||this.decide(),this.ready=!0,this.install(),this.loadSocketCapture(e);let s=this.pending;this.pending=[];let n=this.pageViewId();for(let r of s)(r.type==="error"||r.type==="action")&&r.pageViewId===null&&(r.pageViewId=n),this.record(r)}decide(){let e=this.config,s=navigator.userAgent;this.session.decision=qe({route:x(this.resolveRoute()),deviceType:He(s),browserFamily:Ue(s),country:e.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:e.sessionSampleRate,replaySampleRate:e.replay.sampleRate},this.options.sampler,e.sessionQuotaExhausted,this.drop),M(this.session)}install(){let e={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:this.pageViewId,record:r=>this.record(r),drop:this.drop,trackTiming:(r,o,i)=>{var a;this.timings.set(r,{url:o,startedAt:i}),(a=this.deferred.get())==null||a.frustration.notifyActivity()},trackConnection:r=>this.connections.add(r),socketMessage:(r,o)=>this.sockets.run(i=>i.message(r,o)),socketClosed:r=>{let o=Date.now();this.sockets.run(i=>i.closed(r,o))}};this.pageViews=Pe({resolveRoute:()=>this.resolveRoute(),record:r=>this.onPageView(r),onNavigation:()=>this.touch(),drop:this.drop});let s=setInterval(()=>this.guard(()=>this.flush(!1)),Mt),n=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(s),Oe(e),Ce(e),Ae(e),Te(e),_chunkUZZNGXXEjs.j.call(void 0, window,"click",n,!0),_chunkUZZNGXXEjs.j.call(void 0, window,"keydown",n,!0),this.errors.install(),_chunkUZZNGXXEjs.j.call(void 0, window,"pagehide",()=>this.guard(()=>this.onPageHide())),_chunkUZZNGXXEjs.j.call(void 0, window,"pageshow",r=>this.guard(()=>{var o;r.persisted&&(this.closed=!1,this.sessionDirty=!0,(o=this.pageViews)==null||o.start("BACK_FORWARD"))})),_chunkUZZNGXXEjs.j.call(void 0, document,"visibilitychange",()=>this.guard(()=>{var r;document.visibilityState==="hidden"&&((r=this.deferred.get())==null||r.perf.hidden(),this.flush(!0))}))],this.loadDeferred(e)}shutdown(){this.stopped=!0,this.ready=!1;let e=this.teardowns;this.teardowns=[],e.reverse().forEach(s=>this.guard(s)),this.deferred.close(),this.sockets.close(),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear()}resolveRoute(){let{routeResolver:e}=this.options;if(e)try{return String(e(window.location))}catch (e19){this.drop()}return window.location.pathname}touch(){var s,n;if(!this.ready)return;let e=Date.now();if(!de(this.session,e)){this.session.lastActivityAt=e,M(this.session);return}(s=this.pageViews)==null||s.end(),this.flush(!1),this.shared.dropped+=this.queue.length,this.queue=[],this.session=le(e),this.decide(),this.filter.reset(),this.sessionDirty=!0,this.closed=!1,(n=this.pageViews)==null||n.start("SPA")}onPageHide(){var e;(e=this.pageViews)==null||e.end();for(let s of this.connections)s.done||(s.event.durationMs=Date.now()-s.startedAt,s.done=!0,s.dirty=!0);this.closed=!0,this.sessionDirty=!0,this.flush(!0)}record(e){var s,n;try{if(this.stopped)return;if(this.errors.observe(e),!this.ready){this.pending.length<xt?this.pending.push(e):this.drop();return}(s=this.sockets.get())==null||s.observe(e);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(!r&&e.type!=="error"&&e.type!=="pageView")return;let o=te(e,this.options.beforeSend,this.drop);if(!o)return;ne(o),o.type==="pageView"&&this.session.entryPath===null&&(this.session.entryPath=o.route,M(this.session));for(let i of this.filter.accept(o,r))this.enqueue(i)}catch (e20){this.drop()}}enqueue(e){if(this.queue.length>=Xe){this.drop();return}this.queue.push(e),this.queue.length>=Pt&&!this.flushing&&this.flush(!1)}flush(e){var s,n;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=!0;try{for(let p of this.connections)p.dirty&&(p.dirty=!1,this.record({...p.event})),p.done&&this.connections.delete(p);let r=this.queue;this.queue=[],this.fillTimings(r);let o=((s=this.session.decision)==null?void 0:s.session)===!0;if(r.length===0&&!(o&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:"session",entryPath:(n=this.session.entryPath)!=null?n:"/",sampled:o,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...r]:r,e)}finally{this.flushing=!1}}}header(){let e={sessionId:this.session.id,sessionStartedAt:_chunkUZZNGXXEjs.g.call(void 0, this.session.startedAt)};return this.options.release&&(e.release=this.options.release),this.shared.actor!==void 0&&(e.actor=this.shared.actor),this.shared.attributesSet&&(e.attributes={...this.shared.attributes}),this.shared.featureFlags.hasAny()&&(e.featureFlags={...this.shared.featureFlags.session}),e}fillTimings(e){for(let s of e){let n=this.timings.get(s.id);n&&(this.timings.delete(s.id),Object.assign(s,_chunkIZ7REN7Ejs.i.call(void 0, n.url,n.startedAt)))}}onResult(e,s,n){if(s==="OK")return;if(s==="CUT"){this.session.cut=!0,M(this.session),this.shutdown();return}let r=e.filter(i=>i.type!=="session"),o=e.find(i=>i.type==="session");if(o&&(this.shared.dropped+=o.droppedEvents,this.sessionDirty=!0),s==="RETRY"&&n===this.session.id){let i=r.slice(0,Math.max(0,Xe-this.queue.length));this.shared.dropped+=r.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=r.length}},Ge=null,f={actor:void 0,attributes:{},attributesSet:!1,dropped:0,featureFlags:new D},v=()=>Ge,ce=t=>{Ge=t};var $e=(s=>(s.ALL="ALL",s.ON_ANOMALY="ON_ANOMALY",s))($e||{});var S=t=>{try{t()}catch (e21){f.dropped+=1}},yn= exports.AbyssRum ={init(t){S(()=>{if(v()||!(t!=null&&t.token)||!t.applicationId||!t.apiUrl&&!t.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let e=new Q(t,f);ce(e),e.start()})},setActor(t){S(()=>{var s;let e=Se(t);if(e===void 0){f.dropped+=1;return}f.actor=e,(s=v())==null||s.markDirty()})},setAttributes(t){S(()=>{var e;f.attributes=_chunkIZ7REN7Ejs.a.call(void 0, f.attributes,t,()=>{f.dropped+=1}),f.attributesSet=!0,(e=v())==null||e.markDirty()})},captureError(t,e){S(()=>{var s;return(s=v())==null?void 0:s.captureError(t,e)})},addAction(t,e){S(()=>{var s;return(s=v())==null?void 0:s.addAction(t,e)})},addFeatureFlagEvaluation(t,e){S(()=>{var s;f.featureFlags.add(t,e,()=>f.dropped+=1)&&((s=v())==null||s.markDirty())})},sendFeedback(t){var e,s;return(s=(e=v())==null?void 0:e.sendFeedback(t))!=null?s:Promise.reject(new (0, _chunkLRYKS5XRjs.b)("NO_SESSION"))},showReportDialog(t){S(()=>{var e;return(e=v())==null?void 0:e.showReportDialog(t)})},addTiming(t){S(()=>{var e;return(e=v())==null?void 0:e.addTiming(t)})},startDuration(t,e){S(()=>{var s;return(s=v())==null?void 0:s.startDuration(t,e)})},stopDuration(t){S(()=>{var e;return(e=v())==null?void 0:e.stopDuration(t)})},stop(){S(()=>{var t;(t=v())==null||t.stop(),ce(null),f.actor=void 0,f.attributes={},f.attributesSet=!1,f.dropped=0,f.featureFlags=new D})}};exports.AbyssRum = yn; exports.RumFeedbackError = _chunkLRYKS5XRjs.b; exports.RumFeedbackErrorCode = _chunkLRYKS5XRjs.a; exports.RumSocketCaptureMode = $e;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ft=Object.create;var Se=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var St=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rt(t))!gt.call(e,o)&&o!==n&&Se(e,o,{get:()=>t[o],enumerable:!(s=ht(t,o))||s.enumerable});return e};var v=(e,t,n)=>(n=e!=null?ft(Et(e)):{},St(!e||!e.__esModule?Se(n,"default",{value:e,enumerable:true}):n,e));var Pe=V(f=>{Object.defineProperty(f,"__esModule",{value:true});f.RumCspDisposition=f.RumBreadcrumbKind=f.RumConsoleLevel=f.RumTimingKind=f.RumSocketBinaryType=f.RumSocketDirection=f.RumFrustrationType=f.RumDeviceType=f.RumNavigationType=f.RumRequestKind=f.RumRequestOutcome=f.RumEventType=void 0;var Ie;(function(e){e.SESSION="session",e.PAGE_VIEW="pageView",e.VITALS="vitals",e.REQUEST="request",e.ERROR="error",e.CONSOLE="console",e.ACTION="action",e.FRUSTRATION="frustration",e.TIMING="timing",e.CSP_VIOLATION="cspViolation",e.SOCKET_MESSAGE="socketMessage",e.FEEDBACK="feedback";})(Ie||(f.RumEventType=Ie={}));var be;(function(e){e.SUCCESS="SUCCESS",e.HTTP_ERROR="HTTP_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.OFFLINE="OFFLINE",e.ABORTED="ABORTED",e.TIMEOUT="TIMEOUT";})(be||(f.RumRequestOutcome=be={}));var Te;(function(e){e.FETCH="FETCH",e.XHR="XHR",e.RESOURCE="RESOURCE",e.WEBSOCKET="WEBSOCKET",e.SSE="SSE";})(Te||(f.RumRequestKind=Te={}));var Ae;(function(e){e.NAVIGATE="NAVIGATE",e.RELOAD="RELOAD",e.BACK_FORWARD="BACK_FORWARD",e.SPA="SPA";})(Ae||(f.RumNavigationType=Ae={}));var we;(function(e){e.DESKTOP="desktop",e.MOBILE="mobile",e.TABLET="tablet";})(we||(f.RumDeviceType=we={}));var Oe;(function(e){e.RAGE_CLICK="RAGE_CLICK",e.DEAD_CLICK="DEAD_CLICK",e.ERROR_CLICK="ERROR_CLICK";})(Oe||(f.RumFrustrationType=Oe={}));var _e;(function(e){e.IN="IN",e.OUT="OUT";})(_e||(f.RumSocketDirection=_e={}));var Ce;(function(e){e.BLOB="blob",e.ARRAYBUFFER="arraybuffer";})(Ce||(f.RumSocketBinaryType=Ce={}));var Me;(function(e){e.TIMING="TIMING",e.DURATION="DURATION";})(Me||(f.RumTimingKind=Me={}));var ke;(function(e){e.ERROR="error",e.WARN="warn";})(ke||(f.RumConsoleLevel=ke={}));var De;(function(e){e.NAVIGATION="NAVIGATION",e.REQUEST="REQUEST",e.CLICK="CLICK";})(De||(f.RumBreadcrumbKind=De={}));var Ne;(function(e){e.ENFORCE="enforce",e.REPORT="report";})(Ne||(f.RumCspDisposition=Ne={}));});var Le=V(Ue=>{Object.defineProperty(Ue,"__esModule",{value:true});});var ie=V(P=>{Object.defineProperty(P,"__esModule",{value:true});P.isUuid=P.UUID_PATTERN=void 0;P.UUID_PATTERN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var bt=e=>typeof e=="string"&&P.UUID_PATTERN.test(e);P.isUuid=bt;});var xe=V(O=>{Object.defineProperty(O,"__esModule",{value:true});O.maskUrl=O.MASK_URL_MAX_SEGMENT_LENGTH=O.MASKED_SEGMENT=void 0;var Tt=ie();O.MASKED_SEGMENT=":id";O.MASK_URL_MAX_SEGMENT_LENGTH=40;var At=/^\d{3,}$/,wt=/^[0-9a-f]{16,}$/i,Ot=/^[a-z][a-z0-9+.-]*:\/\//i,_t=e=>e.length>O.MASK_URL_MAX_SEGMENT_LENGTH||Tt.UUID_PATTERN.test(e)||At.test(e)||wt.test(e),Ct=e=>e===""?"/":e.split("/").map(t=>_t(t)?O.MASKED_SEGMENT:t).join("/"),Mt=e=>{try{let t=new URL(e.startsWith("//")?`https:${e}`:e);return {host:t.host===""?null:t.host.toLowerCase(),path:t.pathname}}catch{return {host:null,path:"/"}}},kt=e=>{let n=(typeof e=="string"?e.trim():"").split("#")[0].split("?")[0],{host:s,path:o}=Ot.test(n)||n.startsWith("//")?Mt(n):{host:null,path:n};return {host:s,path:Ct(o)}};O.maskUrl=kt;});var Ve=V(R=>{Object.defineProperty(R,"__esModule",{value:true});R.TIMING_ALLOW_ORIGIN_HEADER=R.SOCKET_SESSION_ID_PARAM=R.SOCKET_REQUEST_ID_PARAM=R.MONITOR_CORRELATION_HEADERS=R.SESSION_ID_HEADER=R.REQUEST_ID_HEADER=void 0;R.REQUEST_ID_HEADER="x-abyss-request-id";R.SESSION_ID_HEADER="x-abyss-session-id";R.MONITOR_CORRELATION_HEADERS=[R.REQUEST_ID_HEADER,R.SESSION_ID_HEADER];R.SOCKET_REQUEST_ID_PARAM="abyss_rid";R.SOCKET_SESSION_ID_PARAM="abyss_sid";R.TIMING_ALLOW_ORIGIN_HEADER="Timing-Allow-Origin";});var g=V(A=>{var Dt=A&&A.__createBinding||(Object.create?(function(e,t,n,s){s===void 0&&(s=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:true,get:function(){return t[n]}}),Object.defineProperty(e,s,o);}):(function(e,t,n,s){s===void 0&&(s=n),e[s]=t[n];})),G=A&&A.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&Dt(t,e,n);};Object.defineProperty(A,"__esModule",{value:true});G(Pe(),A);G(Le(),A);G(xe(),A);G(Ve(),A);G(ie(),A);});var ye=e=>e===null?null:typeof e=="string"&&e.trim()!==""?e:void 0;var yt=/^[a-zA-Z0-9_.-]{1,64}$/,vt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),It=e=>typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.length<=256,ve=(e,t,n)=>{let s={...e};if(!t||typeof t!="object"||Array.isArray(t))return n(),s;for(let[o,r]of Object.entries(t))!yt.test(o)||o==="__proto__"?n():r===null?delete s[o]:!It(r)||!vt(s,o)&&Object.keys(s).length>=30?n():s[o]=r;return s};var I=v(g());var Nt=["id","type","sessionId"],Pt=(e,t)=>e==null?t==null||["string","number","boolean"].includes(typeof t):Array.isArray(e)?Array.isArray(t):t!==null&&typeof t==typeof e,He=(e,t,n)=>{if(!t)return e;let s;try{s=t(JSON.parse(JSON.stringify(e)));}catch{return n(),e}if(s===null)return null;if(!s||typeof s!="object"||Array.isArray(s))return n(),null;let o=e,r=s,i={};for(let a of Object.keys(o))if(Nt.includes(a))i[a]=o[a];else if(Pt(o[a],r[a]))r[a]!==void 0&&(i[a]=r[a]);else return n(),null;return i};var j=v(g());var M=e=>new Date(e).toISOString(),S=(e,t)=>e>0&&t>=e?Math.round(t-e):null,$=e=>{var t;if(typeof e=="string")return e;if(e instanceof Error)return `${e.name}: ${e.message}`;try{return (t=JSON.stringify(e))!=null?t:String(e)}catch{return String(e)}},_=(e,t,n,s=false)=>{let o={capture:s,passive:true};return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)},H=e=>{let t=0;for(let n=0;n<e.length;n+=1){let s=e.charCodeAt(n);s<128?t+=1:s<2048?t+=2:s>=55296&&s<56320?(t+=4,n+=1):t+=3;}return t},Q=(e,t)=>{if(H(e)<=t)return e;let n=0;for(let s=0;s<e.length;s+=1){let o=e.charCodeAt(s)>=55296&&e.charCodeAt(s)<56320,r=H(e.slice(s,o?s+2:s+1));if(n+r>t)return e.slice(0,s);n+=r,o&&(s+=1);}return e},ae=e=>{if(typeof e=="string")return H(e);if(typeof Blob!="undefined"&&e instanceof Blob)return e.size;let t=e==null?void 0:e.byteLength;return typeof t=="number"?t:0},z=e=>{try{let t=sessionStorage.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}},Y=(e,t)=>{try{sessionStorage.setItem(e,JSON.stringify(t));}catch{}},Be=e=>{try{sessionStorage.removeItem(e);}catch{}};var E=()=>{let e=globalThis.crypto;if(typeof(e==null?void 0:e.randomUUID)=="function")return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,s=>(s+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)}`};var Ut=1024,Lt=50,qe=e=>{let t=[["error",j.RumConsoleLevel.ERROR],["warn",j.RumConsoleLevel.WARN]],n=null,s=0,o=t.map(([r,i])=>{let a=console[r],d=(...c)=>{try{let u=e.pageViewId();u!==n&&(n=u,s=0),s+=1,s>Lt?e.drop():e.record({id:E(),type:j.RumEventType.CONSOLE,pageViewId:u,occurredAt:M(Date.now()),level:i,message:Q(c.map($).join(" "),Ut)});}catch{e.drop();}a.apply(console,c);};return console[r]=d,()=>{console[r]===d&&(console[r]=a);}});return ()=>o.forEach(r=>r())};var C=v(g());var J=4096,U=e=>{try{return new URL(e,window.location.href)}catch{return null}},ue=e=>{let t=U(e);return t?`${t.protocol==="ws:"?"http:":t.protocol==="wss:"?"https:":t.protocol}//${t.host}`.toLowerCase():null},B=(e,t)=>{var n;return e.instrumentedOrigins.includes((n=ue(t.href))!=null?n:"")},k=e=>{let t=e==null?void 0:e.name;return t==="AbortError"?C.RumRequestOutcome.ABORTED:t==="TimeoutError"?C.RumRequestOutcome.TIMEOUT:navigator.onLine===false?C.RumRequestOutcome.OFFLINE:C.RumRequestOutcome.NETWORK_ERROR},Z=e=>e>=400?C.RumRequestOutcome.HTTP_ERROR:C.RumRequestOutcome.SUCCESS,q=(e,t,n,s,o,r)=>({id:E(),type:C.RumEventType.REQUEST,pageViewId:e.pageViewId(),kind:t,method:n,url:s,startedAt:M(o),status:null,outcome:C.RumRequestOutcome.SUCCESS,durationMs:null,dnsMs:null,tcpMs:null,tlsMs:null,ttfbMs:null,downloadMs:null,requestId:r,instrumented:r!==null}),Fe=(e,t)=>{let n;try{n=performance.getEntriesByName(e,"resource");}catch{return null}let s=n.filter(o=>performance.timeOrigin+o.startTime>=t-50).pop();return !s||!s.requestStart?null:{dnsMs:S(s.domainLookupStart,s.domainLookupEnd),tcpMs:S(s.connectStart,s.connectEnd),tlsMs:s.secureConnectionStart>0?S(s.secureConnectionStart,s.connectEnd):null,ttfbMs:S(s.requestStart,s.responseStart),downloadMs:S(s.responseStart,s.responseEnd)}};var L=v(g());var w=v(g());var xt=123,ce=(e,t,n)=>{let s=U(String(n));if(!s)return null;let o=s.href,r=null;B(e,s)&&(r=E(),s.searchParams.set(w.SOCKET_REQUEST_ID_PARAM,r),s.searchParams.set(w.SOCKET_SESSION_ID_PARAM,e.sessionId()));let i=Date.now(),a=q(e,t,"GET",o,i,r);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let d={event:a,startedAt:i,opened:false,dirty:true,done:false};return e.trackConnection(d),{connection:d,nativeUrl:r===null?String(n):s.href}},de=e=>{e.opened||(e.opened=true,e.event.connectMs=Date.now()-e.startedAt,e.dirty=true);},ee=(e,t,n)=>{var o,r,i,a;let{event:s}=e;t==="in"?(s.messagesIn=((o=s.messagesIn)!=null?o:0)+1,s.bytesIn=((r=s.bytesIn)!=null?r:0)+ae(n)):(s.messagesOut=((i=s.messagesOut)!=null?i:0)+1,s.bytesOut=((a=s.bytesOut)!=null?a:0)+ae(n)),e.dirty=true;},te=(e,t)=>{e.done||(e.event.durationMs=Date.now()-e.startedAt,e.event.outcome=t,e.done=true,e.dirty=true);},Vt=(e,t,n,s)=>{if(n)return w.RumRequestOutcome.ABORTED;if(e&&(t===1e3||t===1001||s&&t===1005))return w.RumRequestOutcome.SUCCESS;let o=k();return o===w.RumRequestOutcome.OFFLINE||!e?o:w.RumRequestOutcome.HTTP_ERROR},Ke=e=>{let t=window.WebSocket;if(typeof t!="function")return ()=>{};let n=t.prototype,s=n.send,o=n.close,r=new WeakMap,i=(u,l)=>{r.set(u,l),u.addEventListener("open",()=>de(l)),u.addEventListener("message",p=>ee(l,"in",p.data)),u.addEventListener("close",p=>{let h=r.get(u);l.event.closeCode=p.code,l.event.closeReason=p.reason?Q(p.reason,xt):null,te(l,Vt(l.opened,p.code,(h==null?void 0:h.abortedByApp)===true,(h==null?void 0:h.closedByApp)===true));});},a=new Proxy(t,{construct(u,l,p){let h=null;try{h=ce(e,w.RumRequestKind.WEBSOCKET,l[0]);}catch{e.drop();}let b=h?[h.nativeUrl,...l.slice(1)]:l,m=Reflect.construct(u,b,p===a?u:p);return h&&i(m,h.connection),m}}),d=function(u){s.call(this,u);let l=r.get(this);l&&ee(l,"out",u);},c=function(u,l){let p=r.get(this);return p&&(p.abortedByApp=this.readyState===t.CONNECTING,p.closedByApp=true),o.apply(this,arguments)};return window.WebSocket=a,n.send=d,n.close=c,()=>{window.WebSocket===a&&(window.WebSocket=t),n.send===d&&(n.send=s),n.close===c&&(n.close=o);}};var We=e=>{let t=window,n=t.EventSource;if(typeof n!="function")return ()=>{};let s=n.prototype,o=s.close,r=new WeakMap,i=(c,u)=>{r.set(c,u),u.event.reconnectCount=0,c.addEventListener("open",()=>de(u)),c.addEventListener("message",l=>ee(u,"in",l.data)),c.addEventListener("error",()=>{var p;if(c.readyState===n.CONNECTING){u.event.reconnectCount=((p=u.event.reconnectCount)!=null?p:0)+1,u.dirty=true;return}let l=k();te(u,u.opened&&l!==L.RumRequestOutcome.OFFLINE?L.RumRequestOutcome.HTTP_ERROR:l);});},a=new Proxy(n,{construct(c,u,l){let p=null;try{p=ce(e,L.RumRequestKind.SSE,u[0]);}catch{e.drop();}let h=p?[p.nativeUrl,...u.slice(1)]:u,b=Reflect.construct(c,h,l===a?c:l);return p&&i(b,p.connection),b}}),d=function(){o.call(this);let c=r.get(this);c&&te(c,c.opened?L.RumRequestOutcome.SUCCESS:L.RumRequestOutcome.ABORTED);};return t.EventSource=a,s.close=d,()=>{t.EventSource===a&&(t.EventSource=n),s.close===d&&(s.close=o);}};var F=v(g());var Ht=(e,t,n)=>{var u,l,p;let s=typeof Request!="undefined"&&t instanceof Request?t:null,o=U(s?s.url:String(t));if(!o)return null;let r=((l=(u=n==null?void 0:n.method)!=null?u:s==null?void 0:s.method)!=null?l:"GET").toUpperCase(),i=Date.now(),a=null,d=n;if(B(e,o)){a=E();let h=new Headers((p=n==null?void 0:n.headers)!=null?p:s==null?void 0:s.headers);h.set(F.REQUEST_ID_HEADER,a),h.set(F.SESSION_ID_HEADER,e.sessionId()),d={...n,headers:h};}let c=q(e,F.RumRequestKind.FETCH,r,o.href,i,a);return e.trackTiming(c.id,o.href,i),{event:c,init:d,startedAt:i}},Bt=(e,t,n)=>{let{event:s}=t;if(s.durationMs=Date.now()-t.startedAt,s.status=n.status,s.outcome=Z(n.status),s.instrumented||n.status<400){e.record(s);return}n.clone().text().then(o=>{s.responseBodyExcerpt=o.slice(0,J),e.record(s);},()=>e.record(s));},Ge=e=>{let t=window.fetch;if(typeof t!="function")return ()=>{};let n=(s,o)=>{let r=null;try{r=Ht(e,s,o);}catch{e.drop();}let i=t.call(window,s,r?r.init:o);if(r){let a=r;i.then(d=>{try{Bt(e,a,d);}catch{e.drop();}},d=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=k(d),e.record(a.event);});}return i};return window.fetch=n,()=>{window.fetch===n&&(window.fetch=t);}};var D=v(g());var je=e=>{let t=window.XMLHttpRequest;if(typeof t!="function")return ()=>{};let n=t.prototype,s=n.open,o=n.send,r=new WeakMap,i=function(c,u){try{r.set(this,{method:String(c).toUpperCase(),url:String(u)});}catch{e.drop();}return s.apply(this,arguments)},a=(c,u,l)=>{let p=U(l);if(!p)return;let h=Date.now(),b=null;B(e,p)&&(b=E(),c.setRequestHeader(D.REQUEST_ID_HEADER,b),c.setRequestHeader(D.SESSION_ID_HEADER,e.sessionId()));let m=q(e,D.RumRequestKind.XHR,u,p.href,h,b);e.trackTiming(m.id,p.href,h);let T=null;c.addEventListener("error",()=>T=k()),c.addEventListener("abort",()=>T=D.RumRequestOutcome.ABORTED),c.addEventListener("timeout",()=>T=D.RumRequestOutcome.TIMEOUT),c.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=T===null&&c.status>0?c.status:null,m.outcome=m.status===null?T!=null?T:k():Z(m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(c.responseType===""||c.responseType==="text")&&(m.responseBodyExcerpt=c.responseText.slice(0,J)),e.record(m);});},d=function(c){let u=r.get(this);if(u)try{a(this,u.method,u.url);}catch{e.drop();}return o.call(this,c)};return n.open=i,n.send=d,()=>{n.open===i&&(n.open=s),n.send===d&&(n.send=o);}};var le=v(g()),qt=/^([a-z][a-z0-9+.-]*:)\/\//i,Ft=["url","blockedUri","sourceFile"],Kt=["route","referrerRoute","entryPath"],Wt=e=>{let{host:t,path:n}=(0, le.maskUrl)(e);if(t===null)return n;let s=qt.exec(e.trim());return `${s?s[1].toLowerCase():"https:"}//${t}${n}`},pe=e=>(0, le.maskUrl)(e).path,Xe=e=>{let t=e;for(let n of Ft)typeof t[n]=="string"&&(t[n]=Wt(t[n]));for(let n of Kt)typeof t[n]=="string"&&(t[n]=pe(t[n]));return e};var x=v(g());var Gt={reload:x.RumNavigationType.RELOAD,back_forward:x.RumNavigationType.BACK_FORWARD},$e=()=>{try{return performance.getEntriesByType("navigation")[0]}catch{return}},Qe=e=>({dnsMs:e?S(e.domainLookupStart,e.domainLookupEnd):null,tcpMs:e?S(e.connectStart,e.connectEnd):null,tlsMs:e&&e.secureConnectionStart>0?S(e.secureConnectionStart,e.connectEnd):null,requestMs:e?S(e.requestStart,e.responseStart):null,responseMs:e?S(e.responseStart,e.responseEnd):null,domProcessingMs:e?S(e.responseEnd,e.domComplete):null,loadMs:e&&e.loadEventEnd>0?Math.round(e.loadEventEnd-e.startTime):null}),ze=e=>{var h,b;let t=null,n=null,s=(m,T=null,mt)=>{let ge=Date.now();return t={startedAt:ge,path:window.location.pathname,event:{id:E(),type:x.RumEventType.PAGE_VIEW,route:e.resolveRoute(),referrerRoute:T,startedAt:M(ge),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...mt}},e.record({...t.event}),t.event.id},o=()=>{t&&(t.event.durationMs=Date.now()-t.startedAt,e.record({...t.event}));},r=()=>{try{if(e.onNavigation(),t&&window.location.pathname!==t.path){let m=t.event.route;o(),s(x.RumNavigationType.SPA,m);}}catch{e.drop();}},i=()=>{t&&t.event.id===n&&(Object.assign(t.event,Qe($e())),e.record({...t.event}));},a=$e(),d=document.readyState==="complete",c=(b=Gt[(h=a==null?void 0:a.type)!=null?h:""])!=null?b:x.RumNavigationType.NAVIGATE;n=s(c,null,d?Qe(a):void 0);let u=[_(window,"popstate",r)];if(!d){let m;u.push(_(window,"load",()=>{m=setTimeout(i,0);}),()=>clearTimeout(m));}let l=window.history.pushState,p=function(...m){let T=l.apply(this,m);return r(),T};return window.history.pushState=p,u.push(()=>{window.history.pushState===p&&(window.history.pushState=l);}),{currentId:()=>{var m;return (m=t==null?void 0:t.event.id)!=null?m:null},start:m=>{s(m);},end:o,stop:()=>u.forEach(m=>m())}};var Ye=e=>e.replace(/\/+$/,""),me=(e,t)=>`${e.proxyUrl?`${Ye(e.proxyUrl)}/rum`:`${Ye(e.apiUrl)}/api/rum`}/${encodeURIComponent(e.applicationId)}/${t}?token=${encodeURIComponent(e.token)}`;var Ze="abyss-rum-config",jt=600*1e3,Je=e=>typeof e=="number"&&e>=0&&e<=1?e:0,et=e=>{var s,o;let t=e;if(!t||typeof t.enabled!="boolean"||typeof t.sessionSampleRate!="number")return null;let n=(s=t.replay)!=null?s:{};return {enabled:t.enabled,sessionSampleRate:Je(t.sessionSampleRate),sessionQuotaExhausted:t.sessionQuotaExhausted===true,country:typeof t.country=="string"?t.country:null,feedbackEnabled:t.feedbackEnabled===true,replay:{enabled:n.enabled===true,sampleRate:Je(n.sampleRate),unmaskSelectors:Array.isArray(n.unmaskSelectors)?n.unmaskSelectors.filter(r=>typeof r=="string"):[]},socketMessages:{enabled:((o=t.socketMessages)==null?void 0:o.enabled)===true}}},tt=(e,t)=>{let n=z(Ze);if(!n||n.key!==e||typeof n.at!="number")return;let s=t-n.at;return s>=0&&s<jt?et(n.config):void 0},nt=async(e,t,n,s)=>{let o=null;try{let r=await t(e,{credentials:"omit"});o=r.ok?et(await r.json()):null;}catch{o=null;}return Y(Ze,{key:n,at:s,config:o}),o};var ne=v(g()),Xt=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,$t=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,Qt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],st=e=>Xt.test(e)?ne.RumDeviceType.TABLET:$t.test(e)?ne.RumDeviceType.MOBILE:ne.RumDeviceType.DESKTOP,ot=e=>{var t,n;return (n=(t=Qt.find(([s])=>s.test(e)))==null?void 0:t[1])!=null?n:"Other"},rt=(e,t,n,s)=>{if(!e)return n;try{let o=e({...t,attributes:{...t.attributes}});if(typeof(o==null?void 0:o.session)=="boolean"&&typeof o.replay=="boolean")return {session:o.session,replay:o.replay}}catch{}return s(),n};var N=v(g());var zt=200,Yt=(e,t,n)=>({session:e<t,replay:e<t*n}),it=(e,t,n,s)=>{let o=Yt(e.random,e.sessionSampleRate,e.replaySampleRate),r=rt(t,e,o,s),i=r.session&&!n;return {session:i,replay:i&&r.replay}},Jt=e=>e.type===N.RumEventType.REQUEST&&(e.kind===N.RumRequestKind.FETCH||e.kind===N.RumRequestKind.XHR)&&e.outcome===N.RumRequestOutcome.SUCCESS,se=class{constructor(t){this.onDrop=t;this.held=null;this.released=new Set;this.successes=new Map;}accept(t,n){var o,r,i;if(n){if(Jt(t)){let a=(o=t.pageViewId)!=null?o:"",d=((r=this.successes.get(a))!=null?r:0)+1;if(this.successes.set(a,d),d>zt)return this.onDrop(),[]}return [t]}if(t.type===N.RumEventType.PAGE_VIEW)return this.released.has(t.id)?[t]:(this.held=t,[]);if(t.type!==N.RumEventType.ERROR)return [];let s=[];return t.pageViewId!==null&&!this.released.has(t.pageViewId)&&(this.released.add(t.pageViewId),((i=this.held)==null?void 0:i.id)===t.pageViewId&&(s.push(this.held),this.held=null)),s.push(t),s}reset(){this.held=null,this.released.clear(),this.successes.clear();}};var at=v(g());var fe="abyss-rum-session",Zt=1800*1e3,en=14400*1e3,he=(e,t)=>t-e.lastActivityAt>=Zt||t-e.startedAt>=en,tn=e=>typeof(e==null?void 0:e.session)=="boolean"&&typeof e.replay=="boolean",nn=()=>{let e=z(fe);return !e||!(0, at.isUuid)(e.id)||typeof e.startedAt!="number"||typeof e.lastActivityAt!="number"||typeof e.random!="number"?null:{id:e.id,startedAt:e.startedAt,lastActivityAt:e.lastActivityAt,random:e.random,decision:tn(e.decision)?e.decision:null,entryPath:typeof e.entryPath=="string"?e.entryPath:null,cut:e.cut===true}},K=e=>Y(fe,e),ut=()=>Be(fe),Re=e=>{let t={id:E(),startedAt:e,lastActivityAt:e,random:Math.random(),decision:null,entryPath:null,cut:false};return K(t),t},ct=e=>{let t=nn();return t&&!he(t,e)?t:Re(e)};var dt=64*1024,sn=60*1e3;var oe=class{constructor(t,n,s){this.url=t;this.fetchImpl=n;this.handlers=s;this.pausedUntil=0;}isPaused(t){return t<this.pausedUntil}send(t,n,s){let o=JSON.stringify({...t,events:[]}).slice(0,-2),r=H(o)+2,i=[],a=[],d=r;for(let c of n){let u=JSON.stringify(c),l=H(u);if(r+l>dt){this.handlers.onDrop(1);continue}let p=l+(i.length>0?1:0);d+p>dt&&(this.post(`${o}${i.join(",")}]}`,a,s,t.sessionId),i=[],a=[],d=r),d+=l+(i.length>0?1:0),i.push(u),a.push(c);}i.length>0&&this.post(`${o}${i.join(",")}]}`,a,s,t.sessionId);}post(t,n,s,o){let r=i=>this.handlers.onResult(n,i,o);if(s&&this.beacon(t)){r("OK");return}this.fetchImpl(this.url,{method:"POST",body:t,keepalive:true,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,r),()=>r("FAIL")).catch(()=>this.handlers.onDrop(1));}beacon(t){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,t)}catch{return false}}async handle(t,n){if(t.status===429){this.pausedUntil=Date.now()+sn,n("RETRY");return}if(t.status===401||t.status===403||t.status===404){n("CUT");return}if(!t.ok){n("FAIL");return}n("OK");let s=false;try{s=(await t.json()).liveWatched===!0;}catch{}this.handlers.onLiveWatched(s);}};var on=5e3,rn=50,lt=200,an=50,un=e=>{let t=e;return t&&typeof t=="object"&&typeof t.message=="string"?{name:typeof t.name=="string"&&t.name?t.name:"Error",message:t.message,stack:typeof t.stack=="string"?t.stack:null}:{name:"Error",message:$(e),stack:null}},cn=e=>{if(!e||typeof e!="object")return;let t=Object.entries(e).filter(([,n])=>typeof n=="string");return t.length>0?Object.fromEntries(t):void 0},re=class{constructor(t,n){this.options=t;this.shared=n;this.config=null;this.ready=false;this.stopped=false;this.flushing=false;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.connections=new Set;this.timings=new Map;this.sessionDirty=true;this.closed=false;this.liveWatched=false;this.drop=()=>{this.shared.dropped+=1;};var o;let s=window.fetch;this.nativeFetch=(r,i)=>s.call(window,r,i),this.instrumentedOrigins=((o=t.instrumentedOrigins)!=null?o:[]).map(r=>ue(String(r))).filter(r=>r!==null),this.filter=new se(this.drop),this.transport=new oe(me(t,"batch"),this.nativeFetch,{onResult:(r,i,a)=>this.guard(()=>this.onResult(r,i,a)),onLiveWatched:r=>{this.liveWatched=r;},onDrop:r=>{this.shared.dropped+=r;}}),this.session=ct(Date.now());}start(){if(this.session.cut){this.stopped=true;return}let t=Date.now(),n=`${this.options.applicationId}:${this.options.token}`,s=tt(n,t);if(s!==void 0){this.configure(s);return}nt(me(this.options,"config"),this.nativeFetch,n,t).then(o=>this.guard(()=>this.configure(o)),this.drop);}stop(){this.shutdown(),ut();}captureError(t,n){var o,r;let s=cn(n);this.record({id:E(),type:I.RumEventType.ERROR,pageViewId:(r=(o=this.pageViews)==null?void 0:o.currentId())!=null?r:null,occurredAt:M(Date.now()),route:this.resolveRoute(),...un(t),breadcrumbs:[],repeat:1,...s?{context:s}:{}});}markDirty(){this.sessionDirty=true;}replayState(){var n,s,o,r;let t=false;try{t=((s=(n=this.options).consent)==null?void 0:s.call(n).analytics)===!0;}catch{this.drop();}return {record:this.ready&&((o=this.session.decision)==null?void 0:o.replay)===true&&((r=this.config)==null?void 0:r.replay.enabled)===true&&t,liveWatched:this.liveWatched}}guard(t){try{t();}catch{this.drop();}}configure(t){var o,r;if(this.stopped)return;if(!t||!t.enabled){this.shutdown();return}this.config=t,this.session.decision||this.decide(),this.ready=true,this.install();let n=this.pending;this.pending=[];let s=(r=(o=this.pageViews)==null?void 0:o.currentId())!=null?r:null;for(let i of n)i.type===I.RumEventType.ERROR&&i.pageViewId===null&&(i.pageViewId=s),this.record(i);}decide(){let t=this.config,n=navigator.userAgent;this.session.decision=it({route:pe(this.resolveRoute()),deviceType:st(n),browserFamily:ot(n),country:t.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:t.sessionSampleRate,replaySampleRate:t.replay.sampleRate},this.options.sampler,t.sessionQuotaExhausted,this.drop),K(this.session);}install(){let t={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:()=>{var o,r;return (r=(o=this.pageViews)==null?void 0:o.currentId())!=null?r:null},record:o=>this.record(o),drop:this.drop,trackTiming:(o,r,i)=>this.timings.set(o,{url:r,startedAt:i}),trackConnection:o=>this.connections.add(o)};this.pageViews=ze({resolveRoute:()=>this.resolveRoute(),record:o=>this.record(o),onNavigation:()=>this.touch(),drop:this.drop});let n=setInterval(()=>this.guard(()=>this.flush(false)),on),s=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(n),Ge(t),je(t),Ke(t),We(t),...this.options.captureConsole===false?[]:[qe(t)],_(window,"click",s,true),_(window,"keydown",s,true),_(window,"error",o=>this.guard(()=>{var r;return this.captureError((r=o.error)!=null?r:o.message)})),_(window,"pagehide",()=>this.guard(()=>this.onPageHide())),_(window,"pageshow",o=>this.guard(()=>{var r;o.persisted&&(this.closed=false,this.sessionDirty=true,(r=this.pageViews)==null||r.start(I.RumNavigationType.BACK_FORWARD));})),_(document,"visibilitychange",()=>this.guard(()=>{document.visibilityState==="hidden"&&this.flush(true);}))];}shutdown(){this.stopped=true,this.ready=false;let t=this.teardowns;this.teardowns=[],t.reverse().forEach(n=>this.guard(n)),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear();}resolveRoute(){let{routeResolver:t}=this.options;if(t)try{return String(t(window.location))}catch{this.drop();}return window.location.pathname}touch(){var n,s;if(!this.ready)return;let t=Date.now();if(!he(this.session,t)){this.session.lastActivityAt=t,K(this.session);return}(n=this.pageViews)==null||n.end(),this.flush(false),this.shared.dropped+=this.queue.length,this.queue=[],this.session=Re(t),this.decide(),this.filter.reset(),this.sessionDirty=true,this.closed=false,(s=this.pageViews)==null||s.start(I.RumNavigationType.SPA);}onPageHide(){var t;(t=this.pageViews)==null||t.end();for(let n of this.connections)n.done||(n.event.durationMs=Date.now()-n.startedAt,n.done=true,n.dirty=true);this.closed=true,this.sessionDirty=true,this.flush(true);}record(t){var n;try{if(this.stopped)return;if(!this.ready){this.pending.length<an?this.pending.push(t):this.drop();return}let s=((n=this.session.decision)==null?void 0:n.session)===!0;if(!s&&t.type!==I.RumEventType.ERROR&&t.type!==I.RumEventType.PAGE_VIEW)return;let o=He(t,this.options.beforeSend,this.drop);if(!o)return;Xe(o),o.type===I.RumEventType.PAGE_VIEW&&this.session.entryPath===null&&(this.session.entryPath=o.route,K(this.session));for(let r of this.filter.accept(o,s))this.enqueue(r);}catch{this.drop();}}enqueue(t){if(this.queue.length>=lt){this.drop();return}this.queue.push(t),this.queue.length>=rn&&!this.flushing&&this.flush(false);}flush(t){var n,s;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=true;try{for(let d of this.connections)d.dirty&&(d.dirty=!1,this.record({...d.event})),d.done&&this.connections.delete(d);let o=this.queue;this.queue=[],this.fillTimings(o);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(o.length===0&&!(r&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:I.RumEventType.SESSION,entryPath:(s=this.session.entryPath)!=null?s:"/",sampled:r,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...o]:o,t);}finally{this.flushing=false;}}}header(){let t={sessionId:this.session.id,sessionStartedAt:M(this.session.startedAt)};return this.options.release&&(t.release=this.options.release),this.shared.actor!==void 0&&(t.actor=this.shared.actor),this.shared.attributesSet&&(t.attributes={...this.shared.attributes}),t}fillTimings(t){for(let n of t){let s=this.timings.get(n.id);s&&(this.timings.delete(n.id),Object.assign(n,Fe(s.url,s.startedAt)));}}onResult(t,n,s){if(n==="OK")return;if(n==="CUT"){this.session.cut=true,K(this.session),this.shutdown();return}let o=t.filter(i=>i.type!==I.RumEventType.SESSION),r=t.find(i=>i.type===I.RumEventType.SESSION);if(r&&(this.shared.dropped+=r.droppedEvents,this.sessionDirty=true),n==="RETRY"&&s===this.session.id){let i=o.slice(0,Math.max(0,lt-this.queue.length));this.shared.dropped+=o.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=o.length;}},pt=null,y={actor:void 0,attributes:{},attributesSet:false,dropped:0},W=()=>pt,Ee=e=>{pt=e;};var X=e=>{try{e();}catch{y.dropped+=1;}},Ts={init(e){X(()=>{if(W()||!(e!=null&&e.token)||!e.applicationId||!e.apiUrl&&!e.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let t=new re(e,y);Ee(t),t.start();});},setActor(e){X(()=>{var n;let t=ye(e);if(t===void 0){y.dropped+=1;return}y.actor=t,(n=W())==null||n.markDirty();});},setAttributes(e){X(()=>{var t;y.attributes=ve(y.attributes,e,()=>{y.dropped+=1;}),y.attributesSet=!0,(t=W())==null||t.markDirty();});},captureError(e,t){X(()=>{var n;return (n=W())==null?void 0:n.captureError(e,t)});},stop(){X(()=>{var e;(e=W())==null||e.stop(),Ee(null),y.actor=void 0,y.attributes={},y.attributesSet=!1,y.dropped=0;});}};
|
|
2
|
-
export{Ts as AbyssRum};
|
|
1
|
+
import{a as z,b as A}from"./chunk-QEU2JJHJ.mjs";import{a as I,b as U,c as T,d as ye,e as O,f as w,g as B,h as C,i as Ee}from"./chunk-UO34ZFAC.mjs";import{a as me,b as J,c as F,d as N,e as he,f as fe,g as b,h as k,i as ge,j as g,k as Z,l as Re,m as ee,n as L,o as H,p as ve,q as R}from"./chunk-AAXB6P4Z.mjs";var Se=t=>t===null?null:typeof t=="string"&&t.trim()!==""?t:void 0;var be=50,D=class{constructor(){this.session={};this.pageViewId=null;this.page={}}add(e,s,n){if(s==null)return n(),!1;let r=!1,o=()=>{r=!0,n()},i={[String(e)]:s};return this.session=I(this.session,i,o,be),r||(this.page=I(this.page,i,o,be)),!r}hasAny(){return Object.keys(this.session).length>0}annotate(e){e.id!==this.pageViewId&&(this.pageViewId!==null&&(this.page={}),this.pageViewId=e.id),Object.keys(this.page).length>0&&(e.featureFlags={...this.page})}};var Qe=64,we=(t,e,s,n)=>{if(typeof t!="string"||t.length===0||t.length>Qe)return n(),null;let r={id:R(),type:"action",pageViewId:s,occurredAt:b(Date.now()),name:t};if(e!==void 0){let o=I({},e,n);Object.keys(o).length>0&&(r.attributes=o)}return r};var ze=["id","type","sessionId"],Je=(t,e)=>t==null?e==null||["string","number","boolean"].includes(typeof e):Array.isArray(t)?Array.isArray(e):e!==null&&typeof e==typeof t,te=(t,e,s)=>{if(!e)return t;let n;try{n=e(JSON.parse(JSON.stringify(t)))}catch{return s(),t}if(n===null)return null;if(!n||typeof n!="object"||Array.isArray(n))return s(),null;let r=t,o=n,i={};for(let a of Object.keys(r))if(ze.includes(a))i[a]=r[a];else if(Je(r[a],o[a]))o[a]!==void 0&&(i[a]=o[a]);else return s(),null;return i};var Ze=/^([a-z][a-z0-9+.-]*:)\/\//i,et=["url","blockedUri","sourceFile"],tt=["route","referrerRoute","entryPath"],se=t=>{let{host:e,path:s}=J(t);if(e===null)return s;let n=Ze.exec(t.trim());return`${n?n[1].toLowerCase():"https:"}//${e}${s}`},x=t=>J(t).path,ne=t=>{let e=t;for(let s of et)typeof e[s]=="string"&&(e[s]=se(e[s]));for(let s of tt)typeof e[s]=="string"&&(e[s]=x(e[s]));return t};var st=20,nt=256,rt='[data-testid],[aria-label],button,a,input,select,textarea,summary,[role="button"],[role="link"]',Ie=(t,e)=>{let s=t.getAttribute(e);return s===null?null:s.slice(0,nt)},re=t=>{var s;let e=(s=t.closest(rt))!=null?s:t;return{tag:e.tagName.toLowerCase().slice(0,64),testId:Ie(e,"data-testid"),ariaLabel:Ie(e,"aria-label")}},q=class{constructor(){this.items=[];this.lastPageViewId=null}observe(e){e.type==="pageView"&&e.id!==this.lastPageViewId?(this.lastPageViewId=e.id,this.add({kind:"NAVIGATION",route:x(e.route)})):e.type==="request"&&e.kind!=="WEBSOCKET"&&e.kind!=="SSE"&&this.add({kind:"REQUEST",method:e.method,url:se(e.url),status:e.status})}click(e){e instanceof Element&&this.add({kind:"CLICK",element:re(e)})}snapshot(){return this.items.map(e=>({...e}))}add(e){this.items.push({...e,occurredAt:b(Date.now())}),this.items.length>st&&this.items.shift()}};var ot=/^\s*at\s|@\S+:\d+/,it=t=>{var e,s;return(s=(e=(t!=null?t:"").split(`
|
|
2
|
+
`).find(n=>ot.test(n)))==null?void 0:e.trim())!=null?s:""},W=class{constructor(e){this.release=e;this.held=new Map}add(e){var r;let s=`${(r=e.pageViewId)!=null?r:""}${e.message}${it(e.stack)}`,n=this.held.get(s);if(n){n.event.repeat+=1;return}this.held.set(s,{event:e,timer:setTimeout(()=>this.releaseKey(s),1e4)})}flush(){[...this.held.keys()].forEach(e=>this.releaseKey(e))}clear(){this.held.forEach(e=>clearTimeout(e.timer)),this.held.clear()}releaseKey(e){let s=this.held.get(e);s&&(clearTimeout(s.timer),this.held.delete(e),this.release(s.event))}};var at=/^ResizeObserver loop/,ut=/^Script error\.?$/,dt=t=>{let e=t;return e&&typeof e=="object"&&typeof e.message=="string"?{name:typeof e.name=="string"&&e.name?e.name:"Error",message:e.message,stack:typeof e.stack=="string"?e.stack:null}:{name:"Error",message:ge(t),stack:null}},lt=t=>{if(!t||typeof t!="object")return;let e=Object.entries(t).filter(([,s])=>typeof s=="string");return e.length>0?Object.fromEntries(e):void 0},ct=t=>at.test(t.message)||ut.test(t.message)&&!t.stack,j=class{constructor(e){this.host=e;this.breadcrumbs=new q;this.pageViewId=null;this.dedup=new W(s=>e.record(s))}capture(e,s){let n=dt(e);if(ct(n)){this.host.drop();return}this.host.captured();let r=lt(s);this.dedup.add({id:R(),type:"error",pageViewId:this.host.pageViewId(),occurredAt:b(Date.now()),route:this.host.resolveRoute(),...n,breadcrumbs:this.breadcrumbs.snapshot(),repeat:1,...r?{context:r}:{}})}observe(e){this.breadcrumbs.observe(e),e.type==="pageView"&&e.id!==this.pageViewId&&(this.pageViewId!==null&&this.dedup.flush(),this.pageViewId=e.id)}install(){let e=n=>()=>{try{n()}catch{this.host.drop()}},s=[g(window,"error",n=>{n.target instanceof Element||e(()=>{var r;return this.capture((r=n.error)!=null?r:n.message)})()}),g(window,"unhandledrejection",n=>e(()=>this.capture(n.reason))()),g(window,"click",n=>e(()=>this.breadcrumbs.click(n.target))(),!0),g(window,"pagehide",e(()=>this.dedup.flush())),g(document,"visibilitychange",e(()=>{document.visibilityState==="hidden"&&this.dedup.flush()}))];return()=>{s.forEach(n=>n()),this.dedup.clear()}}};var mt=123,ie=(t,e,s)=>{let n=T(String(s));if(!n)return null;let r=n.href,o=null;O(t,n)&&(o=R(),n.searchParams.set(he,o),n.searchParams.set(fe,t.sessionId()));let i=Date.now(),a=C(t,e,"GET",r,i,o);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let p={event:a,startedAt:i,opened:!1,dirty:!0,done:!1};return t.trackConnection(p),{connection:p,nativeUrl:o===null?String(s):n.href}},ae=t=>{t.opened||(t.opened=!0,t.event.connectMs=Date.now()-t.startedAt,t.dirty=!0)},K=(t,e,s)=>{var r,o,i,a;let{event:n}=t;e==="in"?(n.messagesIn=((r=n.messagesIn)!=null?r:0)+1,n.bytesIn=((o=n.bytesIn)!=null?o:0)+ee(s)):(n.messagesOut=((i=n.messagesOut)!=null?i:0)+1,n.bytesOut=((a=n.bytesOut)!=null?a:0)+ee(s)),t.dirty=!0},X=(t,e)=>{t.done||(t.event.durationMs=Date.now()-t.startedAt,t.event.outcome=e,t.done=!0,t.dirty=!0)},ke=(t,e)=>({direction:t,data:e,at:Date.now(),eventName:null,eventId:null}),ht=(t,e,s,n)=>{if(s)return"ABORTED";if(t&&(e===1e3||e===1001||n&&e===1005))return"SUCCESS";let r=w();return r==="OFFLINE"||!t?r:"HTTP_ERROR"},Ae=t=>{let e=window.WebSocket;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.send,r=s.close,o=new WeakMap,i=(u,d)=>{o.set(u,d),u.addEventListener("open",()=>ae(d)),u.addEventListener("message",c=>{K(d,"in",c.data),t.socketMessage(d,ke("IN",c.data))}),u.addEventListener("close",c=>{let h=o.get(u);d.event.closeCode=c.code,d.event.closeReason=c.reason?Re(c.reason,mt):null,X(d,ht(d.opened,c.code,(h==null?void 0:h.abortedByApp)===!0,(h==null?void 0:h.closedByApp)===!0)),t.socketClosed(d)})},a=new Proxy(e,{construct(u,d,c){let h=null;try{h=ie(t,"WEBSOCKET",d[0])}catch{t.drop()}let y=h?[h.nativeUrl,...d.slice(1)]:d,m=Reflect.construct(u,y,c===a?u:c);return h&&i(m,h.connection),m}}),p=function(u){n.call(this,u);let d=o.get(this);d&&(K(d,"out",u),t.socketMessage(d,ke("OUT",u)))},l=function(u,d){let c=o.get(this);return c&&(c.abortedByApp=this.readyState===e.CONNECTING,c.closedByApp=!0),r.apply(this,arguments)};return window.WebSocket=a,s.send=p,s.close=l,()=>{window.WebSocket===a&&(window.WebSocket=e),s.send===p&&(s.send=n),s.close===l&&(s.close=r)}};var Te=t=>{let e=window,s=e.EventSource;if(typeof s!="function")return()=>{};let n=s.prototype,r=n.close,o=new WeakMap,i=(l,u)=>{o.set(l,u),u.event.reconnectCount=0,l.addEventListener("open",()=>ae(u)),l.addEventListener("message",d=>{K(u,"in",d.data),t.socketMessage(u,{direction:"IN",data:d.data,at:Date.now(),eventName:d.type,eventId:d.lastEventId||null})}),l.addEventListener("error",()=>{var c;if(l.readyState===s.CONNECTING){u.event.reconnectCount=((c=u.event.reconnectCount)!=null?c:0)+1,u.dirty=!0;return}let d=w();X(u,u.opened&&d!=="OFFLINE"?"HTTP_ERROR":d),t.socketClosed(u)})},a=new Proxy(s,{construct(l,u,d){let c=null;try{c=ie(t,"SSE",u[0])}catch{t.drop()}let h=c?[c.nativeUrl,...u.slice(1)]:u,y=Reflect.construct(l,h,d===a?l:d);return c&&i(y,c.connection),y}}),p=function(){r.call(this);let l=o.get(this);l&&(X(l,l.opened?"SUCCESS":"ABORTED"),t.socketClosed(l))};return e.EventSource=a,n.close=p,()=>{e.EventSource===a&&(e.EventSource=s),n.close===p&&(n.close=r)}};var ft=(t,e,s)=>{var u,d,c;let n=typeof Request!="undefined"&&e instanceof Request?e:null,r=T(n?n.url:String(e));if(!r)return null;let o=((d=(u=s==null?void 0:s.method)!=null?u:n==null?void 0:n.method)!=null?d:"GET").toUpperCase(),i=Date.now(),a=null,p=s;if(O(t,r)){a=R();let h=new Headers((c=s==null?void 0:s.headers)!=null?c:n==null?void 0:n.headers);h.set(F,a),h.set(N,t.sessionId()),p={...s,headers:h}}let l=C(t,"FETCH",o,r.href,i,a);return t.trackTiming(l.id,r.href,i),{event:l,init:p,startedAt:i}},gt=(t,e,s)=>{let{event:n}=e;if(n.durationMs=Date.now()-e.startedAt,n.status=s.status,n.outcome=B(s.status),n.instrumented||s.status<400){t.record(n);return}s.clone().text().then(r=>{n.responseBodyExcerpt=r.slice(0,U),t.record(n)},()=>t.record(n))},Oe=t=>{let e=window.fetch;if(typeof e!="function")return()=>{};let s=(n,r)=>{let o=null;try{o=ft(t,n,r)}catch{t.drop()}let i=e.call(window,n,o?o.init:r);if(o){let a=o;i.then(p=>{try{gt(t,a,p)}catch{t.drop()}},p=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=w(p),t.record(a.event)})}return i};return window.fetch=s,()=>{window.fetch===s&&(window.fetch=e)}};var Ce=t=>{let e=window.XMLHttpRequest;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.open,r=s.send,o=new WeakMap,i=function(l,u){try{o.set(this,{method:String(l).toUpperCase(),url:String(u)})}catch{t.drop()}return n.apply(this,arguments)},a=(l,u,d)=>{let c=T(d);if(!c)return;let h=Date.now(),y=null;O(t,c)&&(y=R(),l.setRequestHeader(F,y),l.setRequestHeader(N,t.sessionId()));let m=C(t,"XHR",u,c.href,h,y);t.trackTiming(m.id,c.href,h);let E=null;l.addEventListener("error",()=>E=w()),l.addEventListener("abort",()=>E="ABORTED"),l.addEventListener("timeout",()=>E="TIMEOUT"),l.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=E===null&&l.status>0?l.status:null,m.outcome=m.status===null?E!=null?E:w():B(m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(l.responseType===""||l.responseType==="text")&&(m.responseBodyExcerpt=l.responseText.slice(0,U)),t.record(m)})},p=function(l){let u=o.get(this);if(u)try{a(this,u.method,u.url)}catch{t.drop()}return r.call(this,l)};return s.open=i,s.send=p,()=>{s.open===i&&(s.open=n),s.send===p&&(s.send=r)}};var V=class{constructor(e,s){this.max=e;this.drop=s;this.value=null;this.calls=null;this.failed=!1}get(){return this.value}hold(){!this.value&&!this.calls&&(this.calls=[])}run(e){if(this.value)try{e(this.value)}catch{this.drop()}else this.calls&&this.calls.length<this.max?this.calls.push(e):(this.calls||this.failed)&&this.drop()}resolve(e){var n;let s=(n=this.calls)!=null?n:[];this.calls=null,this.value=e,s.forEach(r=>this.run(r))}fail(){var e;((e=this.calls)!=null?e:[]).forEach(()=>this.drop()),this.calls=null,this.failed=!0}close(){this.value=null,this.calls=null}};var vt={reload:"RELOAD",back_forward:"BACK_FORWARD"},De=()=>{try{return performance.getEntriesByType("navigation")[0]}catch{return}},Me=t=>({dnsMs:t?k(t.domainLookupStart,t.domainLookupEnd):null,tcpMs:t?k(t.connectStart,t.connectEnd):null,tlsMs:t&&t.secureConnectionStart>0?k(t.secureConnectionStart,t.connectEnd):null,requestMs:t?k(t.requestStart,t.responseStart):null,responseMs:t?k(t.responseStart,t.responseEnd):null,domProcessingMs:t?k(t.responseEnd,t.domComplete):null,loadMs:t&&t.loadEventEnd>0?Math.round(t.loadEventEnd-t.startTime):null}),Pe=t=>{var h,y;let e=null,s=null,n=(m,E=null,Ye)=>{let pe=Date.now();return e={startedAt:pe,path:window.location.pathname,event:{id:R(),type:"pageView",route:t.resolveRoute(),referrerRoute:E,startedAt:b(pe),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...Ye}},t.record({...e.event}),e.event.id},r=()=>{e&&(e.event.durationMs=Date.now()-e.startedAt,t.record({...e.event}))},o=()=>{try{if(t.onNavigation(),e&&window.location.pathname!==e.path){let m=e.event.route;r(),n("SPA",m)}}catch{t.drop()}},i=()=>{e&&e.event.id===s&&(Object.assign(e.event,Me(De())),t.record({...e.event}))},a=De(),p=document.readyState==="complete",l=(y=vt[(h=a==null?void 0:a.type)!=null?h:""])!=null?y:"NAVIGATE";s=n(l,null,p?Me(a):void 0);let u=[g(window,"popstate",o)];if(!p){let m;u.push(g(window,"load",()=>{m=setTimeout(i,0)}),()=>clearTimeout(m))}let d=window.history.pushState,c=function(...m){let E=d.apply(this,m);return o(),E};return window.history.pushState=c,u.push(()=>{window.history.pushState===c&&(window.history.pushState=d)}),{currentId:()=>{var m;return(m=e==null?void 0:e.event.id)!=null?m:null},start:m=>{n(m)},end:r,stop:()=>u.forEach(m=>m())}};var xe=t=>t.replace(/\/+$/,""),G=(t,e)=>`${t.proxyUrl?`${xe(t.proxyUrl)}/rum`:`${xe(t.apiUrl)}/api/rum`}/${encodeURIComponent(t.applicationId)}/${e}?token=${encodeURIComponent(t.token)}`;var Ve="abyss-rum-config",yt=600*1e3,_e=t=>typeof t=="number"&&t>=0&&t<=1?t:0,Fe=t=>{var n,r;let e=t;if(!e||typeof e.enabled!="boolean"||typeof e.sessionSampleRate!="number")return null;let s=(n=e.replay)!=null?n:{};return{enabled:e.enabled,sessionSampleRate:_e(e.sessionSampleRate),sessionQuotaExhausted:e.sessionQuotaExhausted===!0,country:typeof e.country=="string"?e.country:null,feedbackEnabled:e.feedbackEnabled===!0,replay:{enabled:s.enabled===!0,sampleRate:_e(s.sampleRate),unmaskSelectors:Array.isArray(s.unmaskSelectors)?s.unmaskSelectors.filter(o=>typeof o=="string"):[]},socketMessages:{enabled:((r=e.socketMessages)==null?void 0:r.enabled)===!0}}},Ne=(t,e)=>{let s=L(Ve);if(!s||s.key!==t||typeof s.at!="number")return;let n=e-s.at;return n>=0&&n<yt?Fe(s.config):void 0},Le=async(t,e,s,n)=>{let r=null;try{let o=await e(t,{credentials:"omit"});r=o.ok?Fe(await o.json()):null}catch{r=null}return H(Ve,{key:s,at:n,config:r}),r};var Et=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,St=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,bt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],He=t=>Et.test(t)?"tablet":St.test(t)?"mobile":"desktop",Ue=t=>{var e,s;return(s=(e=bt.find(([n])=>n.test(t)))==null?void 0:e[1])!=null?s:"Other"},Be=(t,e,s,n)=>{if(!t)return s;try{let r=t({...e,attributes:{...e.attributes}});if(typeof(r==null?void 0:r.session)=="boolean"&&typeof r.replay=="boolean")return{session:r.session,replay:r.replay}}catch{}return n(),s};var wt=200,It=(t,e,s)=>({session:t<e,replay:t<e*s}),qe=(t,e,s,n)=>{let r=It(t.random,t.sessionSampleRate,t.replaySampleRate),o=Be(e,t,r,n),i=o.session&&!s;return{session:i,replay:i&&o.replay}},kt=t=>t.type==="request"&&(t.kind==="FETCH"||t.kind==="XHR")&&t.outcome==="SUCCESS",$=class{constructor(e){this.onDrop=e;this.held=null;this.released=new Set;this.successes=new Map}accept(e,s){var r,o,i;if(s){if(kt(e)){let a=(r=e.pageViewId)!=null?r:"",p=((o=this.successes.get(a))!=null?o:0)+1;if(this.successes.set(a,p),p>wt)return this.onDrop(),[]}return[e]}if(e.type==="pageView")return this.released.has(e.id)?[e]:(this.held=e,[]);if(e.type!=="error")return[];let n=[];return e.pageViewId!==null&&!this.released.has(e.pageViewId)&&(this.released.add(e.pageViewId),((i=this.held)==null?void 0:i.id)===e.pageViewId&&(n.push(this.held),this.held=null)),n.push(e),n}reset(){this.held=null,this.released.clear(),this.successes.clear()}};var ue="abyss-rum-session",At=1800*1e3,Tt=14400*1e3,de=(t,e)=>e-t.lastActivityAt>=At||e-t.startedAt>=Tt,Ot=t=>typeof(t==null?void 0:t.session)=="boolean"&&typeof t.replay=="boolean",Ct=()=>{let t=L(ue);return!t||!me(t.id)||typeof t.startedAt!="number"||typeof t.lastActivityAt!="number"||typeof t.random!="number"?null:{id:t.id,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,random:t.random,decision:Ot(t.decision)?t.decision:null,entryPath:typeof t.entryPath=="string"?t.entryPath:null,cut:t.cut===!0}},M=t=>H(ue,t),We=()=>ve(ue),le=t=>{let e={id:R(),startedAt:t,lastActivityAt:t,random:Math.random(),decision:null,entryPath:null,cut:!1};return M(e),e},je=t=>{let e=Ct();return e&&!de(e,t)?e:le(t)};var Ke=64*1024,Dt=60*1e3;var Y=class{constructor(e,s,n){this.url=e;this.fetchImpl=s;this.handlers=n;this.pausedUntil=0}isPaused(e){return e<this.pausedUntil}send(e,s,n){let r=JSON.stringify({...e,events:[]}).slice(0,-2),o=Z(r)+2,i=[],a=[],p=o;for(let l of s){let u=JSON.stringify(l),d=Z(u);if(o+d>Ke){this.handlers.onDrop(1);continue}let c=d+(i.length>0?1:0);p+c>Ke&&(this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId),i=[],a=[],p=o),p+=d+(i.length>0?1:0),i.push(u),a.push(l)}i.length>0&&this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId)}post(e,s,n,r){let o=i=>this.handlers.onResult(s,i,r);if(n&&this.beacon(e)){o("OK");return}this.fetchImpl(this.url,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,o),()=>o("FAIL")).catch(()=>this.handlers.onDrop(1))}beacon(e){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,e)}catch{return!1}}async handle(e,s){if(e.status===429){this.pausedUntil=Date.now()+Dt,s("RETRY");return}if(e.status===401||e.status===403||e.status===404){s("CUT");return}if(!e.ok){s("FAIL");return}s("OK");let n=!1;try{n=(await e.json()).liveWatched===!0}catch{}this.handlers.onLiveWatched(n)}};var Mt=5e3,Pt=50,Xe=200,xt=50,_t=100,Vt=200,Q=class{constructor(e,s){this.options=e;this.shared=s;this.config=null;this.ready=!1;this.stopped=!1;this.flushing=!1;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.lastPageViewId=null;this.deferred=new V(_t,()=>this.drop());this.sockets=new V(Vt,()=>this.drop());this.errors=new j({pageViewId:()=>this.pageViewId(),resolveRoute:()=>this.resolveRoute(),record:e=>this.record(e),drop:()=>this.drop(),captured:()=>{var s;let e=Date.now();(s=this.deferred.get())==null||s.frustration.notifyError(),this.sockets.run(n=>n.anomaly(e))}});this.connections=new Set;this.timings=new Map;this.sessionDirty=!0;this.closed=!1;this.liveWatched=!1;this.drop=()=>{this.shared.dropped+=1};this.pageViewId=()=>{var e,s;return(s=(e=this.pageViews)==null?void 0:e.currentId())!=null?s:null};var r;let n=window.fetch;this.nativeFetch=(o,i)=>n.call(window,o,i),this.instrumentedOrigins=((r=e.instrumentedOrigins)!=null?r:[]).map(o=>ye(String(o))).filter(o=>o!==null),this.filter=new $(this.drop),this.transport=new Y(G(e,"batch"),this.nativeFetch,{onResult:(o,i,a)=>this.guard(()=>this.onResult(o,i,a)),onLiveWatched:o=>{this.liveWatched=o},onDrop:o=>{this.shared.dropped+=o}}),this.session=je(Date.now()),this.deferred.hold()}start(){if(this.session.cut){this.stopped=!0;return}let e=Date.now(),s=`${this.options.applicationId}:${this.options.token}`,n=Ne(s,e);if(n!==void 0){this.configure(n);return}Le(G(this.options,"config"),this.nativeFetch,s,e).then(r=>this.guard(()=>this.configure(r)),this.drop)}stop(){this.shutdown(),We()}captureError(e,s){this.errors.capture(e,s)}addAction(e,s){let n=we(e,s,this.pageViewId(),this.drop);n&&this.record(n)}addTiming(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.addTiming(e,s))}startDuration(e,s){let n=Date.now();this.deferred.run(r=>r.perf.timings.startDuration(e,s,n))}stopDuration(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.stopDuration(e,s))}sendFeedback(e){let s=this.feedbackState();return s!==null?Promise.reject(new A(s)):this.feedback((n,r)=>n.sendFeedback(r,e))}showReportDialog(e){this.feedbackState()===null&&this.feedback((s,n)=>s.showReportDialog(n,e!=null?e:{})).catch(this.drop)}markDirty(){this.sessionDirty=!0}replayState(){var s,n,r,o;let e=!1;try{e=((n=(s=this.options).consent)==null?void 0:n.call(s).analytics)===!0}catch{this.drop()}return{record:this.ready&&((r=this.session.decision)==null?void 0:r.replay)===!0&&((o=this.config)==null?void 0:o.replay.enabled)===!0&&e,liveWatched:this.liveWatched}}guard(e){try{e()}catch{this.drop()}}load(e,s){e.catch(()=>{this.drop(),s()})}feedback(e){return import("./send-WHX2VHVF.mjs").then(s=>e(s,this.feedbackHost()),()=>{throw new A("SEND_FAILED")})}feedbackState(){var e;return!this.ready||this.stopped?"NO_SESSION":((e=this.config)==null?void 0:e.feedbackEnabled)===!0?null:"FEEDBACK_DISABLED"}feedbackHost(){return{unavailable:()=>this.feedbackState(),sessionId:()=>this.session.id,sessionStartedAt:()=>this.session.startedAt,pageViewId:this.pageViewId,resolveRoute:()=>this.resolveRoute(),prepare:e=>{let s=te(e,this.options.beforeSend,this.drop);return s&&ne(s)},post:e=>(this.flush(!1),this.nativeFetch(G(this.options,"feedback"),{method:"POST",body:JSON.stringify({...this.header(),events:[e]}),keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(s=>s.status)),sent:e=>this.guard(()=>{var s,n;return(n=(s=this.options).onFeedbackSent)==null?void 0:n.call(s,e)})}}loadDeferred(e){this.load(import("./deferred-6XZ757WK.mjs").then(({installDeferred:s})=>this.guard(()=>{if(this.stopped)return;let n=s({instrument:e,resolveRoute:()=>this.resolveRoute(),captureConsole:this.options.captureConsole!==!1,describe:re});this.teardowns.push(n.teardown),this.deferred.resolve(n)})),()=>this.deferred.fail())}loadSocketCapture(e){var n;let s=this.options.captureSocketMessages;!s||!e.socketMessages.enabled||((n=this.session.decision)==null?void 0:n.session)!==!0||(this.sockets.hold(),this.load(import("./socket-messages-VEEQGHB6.mjs").then(({SocketMessageCapture:r})=>this.guard(()=>{this.stopped||this.sockets.resolve(new r(s,{sessionId:()=>this.session.id,record:o=>this.record(o),drop:this.drop}))})),()=>this.sockets.fail()))}onPageView(e){var s,n;this.shared.featureFlags.annotate(e),(s=this.deferred.get())==null||s.perf.annotate(e),this.record(e),e.id!==this.lastPageViewId&&(this.lastPageViewId=e.id,(n=this.deferred.get())==null||n.frustration.notifyActivity()),this.deferred.run(r=>r.perf.pageViewSent(e))}configure(e){if(this.stopped)return;if(!e||!e.enabled){this.shutdown();return}this.config=e,this.session.decision||this.decide(),this.ready=!0,this.install(),this.loadSocketCapture(e);let s=this.pending;this.pending=[];let n=this.pageViewId();for(let r of s)(r.type==="error"||r.type==="action")&&r.pageViewId===null&&(r.pageViewId=n),this.record(r)}decide(){let e=this.config,s=navigator.userAgent;this.session.decision=qe({route:x(this.resolveRoute()),deviceType:He(s),browserFamily:Ue(s),country:e.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:e.sessionSampleRate,replaySampleRate:e.replay.sampleRate},this.options.sampler,e.sessionQuotaExhausted,this.drop),M(this.session)}install(){let e={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:this.pageViewId,record:r=>this.record(r),drop:this.drop,trackTiming:(r,o,i)=>{var a;this.timings.set(r,{url:o,startedAt:i}),(a=this.deferred.get())==null||a.frustration.notifyActivity()},trackConnection:r=>this.connections.add(r),socketMessage:(r,o)=>this.sockets.run(i=>i.message(r,o)),socketClosed:r=>{let o=Date.now();this.sockets.run(i=>i.closed(r,o))}};this.pageViews=Pe({resolveRoute:()=>this.resolveRoute(),record:r=>this.onPageView(r),onNavigation:()=>this.touch(),drop:this.drop});let s=setInterval(()=>this.guard(()=>this.flush(!1)),Mt),n=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(s),Oe(e),Ce(e),Ae(e),Te(e),g(window,"click",n,!0),g(window,"keydown",n,!0),this.errors.install(),g(window,"pagehide",()=>this.guard(()=>this.onPageHide())),g(window,"pageshow",r=>this.guard(()=>{var o;r.persisted&&(this.closed=!1,this.sessionDirty=!0,(o=this.pageViews)==null||o.start("BACK_FORWARD"))})),g(document,"visibilitychange",()=>this.guard(()=>{var r;document.visibilityState==="hidden"&&((r=this.deferred.get())==null||r.perf.hidden(),this.flush(!0))}))],this.loadDeferred(e)}shutdown(){this.stopped=!0,this.ready=!1;let e=this.teardowns;this.teardowns=[],e.reverse().forEach(s=>this.guard(s)),this.deferred.close(),this.sockets.close(),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear()}resolveRoute(){let{routeResolver:e}=this.options;if(e)try{return String(e(window.location))}catch{this.drop()}return window.location.pathname}touch(){var s,n;if(!this.ready)return;let e=Date.now();if(!de(this.session,e)){this.session.lastActivityAt=e,M(this.session);return}(s=this.pageViews)==null||s.end(),this.flush(!1),this.shared.dropped+=this.queue.length,this.queue=[],this.session=le(e),this.decide(),this.filter.reset(),this.sessionDirty=!0,this.closed=!1,(n=this.pageViews)==null||n.start("SPA")}onPageHide(){var e;(e=this.pageViews)==null||e.end();for(let s of this.connections)s.done||(s.event.durationMs=Date.now()-s.startedAt,s.done=!0,s.dirty=!0);this.closed=!0,this.sessionDirty=!0,this.flush(!0)}record(e){var s,n;try{if(this.stopped)return;if(this.errors.observe(e),!this.ready){this.pending.length<xt?this.pending.push(e):this.drop();return}(s=this.sockets.get())==null||s.observe(e);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(!r&&e.type!=="error"&&e.type!=="pageView")return;let o=te(e,this.options.beforeSend,this.drop);if(!o)return;ne(o),o.type==="pageView"&&this.session.entryPath===null&&(this.session.entryPath=o.route,M(this.session));for(let i of this.filter.accept(o,r))this.enqueue(i)}catch{this.drop()}}enqueue(e){if(this.queue.length>=Xe){this.drop();return}this.queue.push(e),this.queue.length>=Pt&&!this.flushing&&this.flush(!1)}flush(e){var s,n;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=!0;try{for(let p of this.connections)p.dirty&&(p.dirty=!1,this.record({...p.event})),p.done&&this.connections.delete(p);let r=this.queue;this.queue=[],this.fillTimings(r);let o=((s=this.session.decision)==null?void 0:s.session)===!0;if(r.length===0&&!(o&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:"session",entryPath:(n=this.session.entryPath)!=null?n:"/",sampled:o,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...r]:r,e)}finally{this.flushing=!1}}}header(){let e={sessionId:this.session.id,sessionStartedAt:b(this.session.startedAt)};return this.options.release&&(e.release=this.options.release),this.shared.actor!==void 0&&(e.actor=this.shared.actor),this.shared.attributesSet&&(e.attributes={...this.shared.attributes}),this.shared.featureFlags.hasAny()&&(e.featureFlags={...this.shared.featureFlags.session}),e}fillTimings(e){for(let s of e){let n=this.timings.get(s.id);n&&(this.timings.delete(s.id),Object.assign(s,Ee(n.url,n.startedAt)))}}onResult(e,s,n){if(s==="OK")return;if(s==="CUT"){this.session.cut=!0,M(this.session),this.shutdown();return}let r=e.filter(i=>i.type!=="session"),o=e.find(i=>i.type==="session");if(o&&(this.shared.dropped+=o.droppedEvents,this.sessionDirty=!0),s==="RETRY"&&n===this.session.id){let i=r.slice(0,Math.max(0,Xe-this.queue.length));this.shared.dropped+=r.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=r.length}},Ge=null,f={actor:void 0,attributes:{},attributesSet:!1,dropped:0,featureFlags:new D},v=()=>Ge,ce=t=>{Ge=t};var $e=(s=>(s.ALL="ALL",s.ON_ANOMALY="ON_ANOMALY",s))($e||{});var S=t=>{try{t()}catch{f.dropped+=1}},yn={init(t){S(()=>{if(v()||!(t!=null&&t.token)||!t.applicationId||!t.apiUrl&&!t.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let e=new Q(t,f);ce(e),e.start()})},setActor(t){S(()=>{var s;let e=Se(t);if(e===void 0){f.dropped+=1;return}f.actor=e,(s=v())==null||s.markDirty()})},setAttributes(t){S(()=>{var e;f.attributes=I(f.attributes,t,()=>{f.dropped+=1}),f.attributesSet=!0,(e=v())==null||e.markDirty()})},captureError(t,e){S(()=>{var s;return(s=v())==null?void 0:s.captureError(t,e)})},addAction(t,e){S(()=>{var s;return(s=v())==null?void 0:s.addAction(t,e)})},addFeatureFlagEvaluation(t,e){S(()=>{var s;f.featureFlags.add(t,e,()=>f.dropped+=1)&&((s=v())==null||s.markDirty())})},sendFeedback(t){var e,s;return(s=(e=v())==null?void 0:e.sendFeedback(t))!=null?s:Promise.reject(new A("NO_SESSION"))},showReportDialog(t){S(()=>{var e;return(e=v())==null?void 0:e.showReportDialog(t)})},addTiming(t){S(()=>{var e;return(e=v())==null?void 0:e.addTiming(t)})},startDuration(t,e){S(()=>{var s;return(s=v())==null?void 0:s.startDuration(t,e)})},stopDuration(t){S(()=>{var e;return(e=v())==null?void 0:e.stopDuration(t)})},stop(){S(()=>{var t;(t=v())==null||t.stop(),ce(null),f.actor=void 0,f.attributes={},f.attributesSet=!1,f.dropped=0,f.featureFlags=new D})}};export{yn as AbyssRum,A as RumFeedbackError,z as RumFeedbackErrorCode,$e as RumSocketCaptureMode};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abyss-project/monitor-browser",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.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",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"abyss-monitor-sourcemaps": "dist/cli/bin.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"import": {
|
|
@@ -33,9 +36,11 @@
|
|
|
33
36
|
},
|
|
34
37
|
"homepage": "https://gitlab.com/abyss-group/abyss-monitor/abyss-monitor",
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"
|
|
39
|
+
"web-vitals": "4.2.4",
|
|
40
|
+
"@abyss-project/monitor": "12.1.0"
|
|
37
41
|
},
|
|
38
42
|
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.17.31",
|
|
39
44
|
"@typescript-eslint/eslint-plugin": "8.71.0",
|
|
40
45
|
"@typescript-eslint/parser": "8.71.0",
|
|
41
46
|
"eslint": "^8.57.1",
|