@starko-one/sdk 0.0.0-stage → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -0
- package/LICENSE +17 -0
- package/NOTICE +58 -0
- package/README.md +81 -2
- package/dist/api-B5IHeINe.d.ts +558 -0
- package/dist/api-DR4HazCu.d.cts +558 -0
- package/dist/browser/index.cjs +168 -0
- package/dist/browser/index.d.cts +131 -0
- package/dist/browser/index.d.ts +131 -0
- package/dist/browser/index.js +7 -0
- package/dist/build/rollup.cjs +22 -0
- package/dist/build/rollup.d.cts +34 -0
- package/dist/build/rollup.d.ts +34 -0
- package/dist/build/rollup.js +3 -0
- package/dist/build/vite.cjs +51 -0
- package/dist/build/vite.d.cts +23 -0
- package/dist/build/vite.d.ts +23 -0
- package/dist/build/vite.js +46 -0
- package/dist/build/webpack.cjs +18 -0
- package/dist/build/webpack.d.cts +39 -0
- package/dist/build/webpack.d.ts +39 -0
- package/dist/build/webpack.js +3 -0
- package/dist/chunk-7HYGODU6.cjs +583 -0
- package/dist/chunk-A5M4NOVT.js +413 -0
- package/dist/chunk-A7MYYWMP.cjs +15 -0
- package/dist/chunk-BAQA47FM.js +1113 -0
- package/dist/chunk-CM7HM6CC.js +563 -0
- package/dist/chunk-DFYNIWUN.js +608 -0
- package/dist/chunk-DMVVCGKO.cjs +96 -0
- package/dist/chunk-FARGXYJ4.cjs +56 -0
- package/dist/chunk-G3MYIAX2.js +1226 -0
- package/dist/chunk-G4NAVZQ4.js +249 -0
- package/dist/chunk-GH7RYPKS.js +96 -0
- package/dist/chunk-HADYYQNL.cjs +134 -0
- package/dist/chunk-HOQPAB4X.js +178 -0
- package/dist/chunk-J5RU73SW.js +214 -0
- package/dist/chunk-JNAJ3YZB.cjs +223 -0
- package/dist/chunk-KN7H22EQ.cjs +659 -0
- package/dist/chunk-LDQ4I7FZ.cjs +1151 -0
- package/dist/chunk-NPGESRVQ.js +1212 -0
- package/dist/chunk-OPWM5V7A.cjs +258 -0
- package/dist/chunk-PYYWPIFL.cjs +1230 -0
- package/dist/chunk-R7JLZ4WO.cjs +115 -0
- package/dist/chunk-SC6VQSES.js +213 -0
- package/dist/chunk-TPSJGLR3.cjs +220 -0
- package/dist/chunk-UKBY6HPC.js +131 -0
- package/dist/chunk-VRSEHRBX.cjs +185 -0
- package/dist/chunk-X74AONZA.js +90 -0
- package/dist/chunk-XW3I5CJN.js +12 -0
- package/dist/chunk-XW56FKKJ.js +53 -0
- package/dist/chunk-Z3G5SW7R.cjs +1251 -0
- package/dist/chunk-ZVMAN7OO.cjs +431 -0
- package/dist/cli/index.cjs +1487 -0
- package/dist/common-ARWXbeS3.d.ts +36 -0
- package/dist/common-CwIFh2hK.d.cts +36 -0
- package/dist/dedupe-eHBIfUUD.d.cts +13 -0
- package/dist/dedupe-fw8aNtt4.d.ts +13 -0
- package/dist/handler-DTZ4Rzcf.d.ts +82 -0
- package/dist/handler-_00lctTI.d.cts +82 -0
- package/dist/index.cjs +277 -0
- package/dist/index.d.cts +187 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +4 -0
- package/dist/next/client.cjs +113 -0
- package/dist/next/client.d.cts +26 -0
- package/dist/next/client.d.ts +26 -0
- package/dist/next/client.js +41 -0
- package/dist/next/config.cjs +275 -0
- package/dist/next/config.d.cts +193 -0
- package/dist/next/config.d.ts +193 -0
- package/dist/next/config.js +261 -0
- package/dist/next/index.cjs +148 -0
- package/dist/next/index.d.cts +32 -0
- package/dist/next/index.d.ts +32 -0
- package/dist/next/index.js +59 -0
- package/dist/node/index.cjs +257 -0
- package/dist/node/index.d.cts +145 -0
- package/dist/node/index.d.ts +145 -0
- package/dist/node/index.js +83 -0
- package/dist/options-0BhybO54.d.cts +47 -0
- package/dist/options-0BhybO54.d.ts +47 -0
- package/dist/react/index.cjs +107 -0
- package/dist/react/index.d.cts +84 -0
- package/dist/react/index.d.ts +84 -0
- package/dist/react/index.js +103 -0
- package/dist/scope-Bvh45bOf.d.cts +404 -0
- package/dist/scope-Bvh45bOf.d.ts +404 -0
- package/dist/server-edge-BPOGA3GH.cjs +51 -0
- package/dist/server-edge-GYKAJREU.js +48 -0
- package/dist/server-node-HYK2OB2J.js +24 -0
- package/dist/server-node-J2DBAHDV.cjs +27 -0
- package/dist/session-C_WzbEN2.d.cts +4 -0
- package/dist/session-C_WzbEN2.d.ts +4 -0
- package/dist/session-propagation-B7REA7uy.d.cts +30 -0
- package/dist/session-propagation-BnJjKJbR.d.ts +30 -0
- package/dist/starko.min.js +6 -0
- package/docs/browser.md +381 -0
- package/docs/configuration.md +269 -0
- package/docs/nextjs.md +312 -0
- package/docs/node.md +376 -0
- package/docs/other-backends.md +232 -0
- package/docs/privacy.md +112 -0
- package/docs/react.md +187 -0
- package/docs/source-maps.md +332 -0
- package/docs/troubleshooting.md +171 -0
- package/docs/widget.md +84 -0
- package/docs/wire-format.md +367 -0
- package/package.json +98 -4
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var Starko=(()=>{var Ee=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var gn=Object.prototype.hasOwnProperty;var hn=(t,e)=>{for(var n in e)Ee(t,n,{get:e[n],enumerable:!0})},yn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mn(e))!gn.call(t,i)&&i!==n&&Ee(t,i,{get:()=>e[i],enumerable:!(r=pn(e,i))||r.enumerable});return t};var bn=t=>yn(Ee({},"__esModule",{value:!0}),t);var Ar={};hn(Ar,{SDK_VERSION:()=>M,addBreadcrumb:()=>Ve,captureException:()=>Xe,captureMessage:()=>We,close:()=>Je,consoleErrorCaptureIntegration:()=>le,flush:()=>Qe,getClient:()=>E,identify:()=>$e,init:()=>Ue,setContext:()=>Ke,setExtra:()=>ze,setExtras:()=>He,setTag:()=>qe,setTags:()=>Ge,setUser:()=>Fe,withScope:()=>Ye});var l={MAX_EVENTS_PER_ENVELOPE:20,MAX_BODY_BYTES:524288,MAX_INFLATED_BYTES:2097152,MAX_EXCEPTIONS:10,MAX_FRAMES:50,MAX_CHUNK_IDS_PER_EVENT:8,MAX_JSON_DEPTH:20,MAX_TYPE:200,MAX_VALUE:2e3,MAX_FILENAME:1e3,MAX_FUNCTION:300,MAX_CONTEXT_LINE:300,MAX_CONTEXT_LINES:7,MAX_BREADCRUMBS:50,MAX_BREADCRUMB_BYTES:32768,MAX_TAGS:50,MAX_TAG_KEY:64,MAX_TAG_VALUE:256,MAX_EXTRA_BYTES:16384,MAX_FINGERPRINT:128,MAX_RELEASE:128,MAX_ENVIRONMENT:64,MAX_URL:2048},X=/^[A-Za-z0-9-]{8,70}$/,W={INGEST:"/api/v1/ingest/errors",CONFIG:"/api/v1/ingest/config",SOURCEMAPS_CHECK:"/api/v1/sourcemaps/check",SOURCEMAPS_UPLOAD:"/api/v1/sourcemaps/upload",SOURCEMAPS_COMPLETE:"/api/v1/sourcemaps/complete"},Ze="https://v2.starko.one",et=["token","access_token","id_token","refresh_token","code","key","api_key","apikey","secret","password","passwd","pwd","auth","authorization","session","sessionid","sid","sig","signature","jwt","otp","pin","email","phone","ssn","x-amz-signature","x-amz-credential","x-amz-security-token"],tt="[redacted]",Mr=3*1024*1024,Or=64*1024*1024;var nt="_starkoDebugIds",rt="_debugIds",it="_starkoRelease";var En="_sentryDebugIds",kn=[En,rt,nt],K,ot=new Map;function wn(t){try{let e=globalThis[t];return e&&typeof e=="object"?e:void 0}catch(e){return}}function st(t){let e=kn.map(wn);if(!e.some(Boolean))return{};let n=e.map(a=>a?Object.keys(a):[]),r=n.map(a=>a.length).join(":");if(K&&K.parser===t&&K.sizes===r)return K.map;let i={},o=(a,s)=>{var c,u;for(let d of a){let f=s[d];if(typeof f!="string")continue;let m=ot.get(d);m===void 0&&(m=(u=(c=t(d).find(p=>p.filename))==null?void 0:c.filename)!=null?u:null,ot.set(d,m)),m&&(i[m]=f)}};return e.forEach((a,s)=>a&&o(n[s],a)),K={parser:t,sizes:r,map:i},i}function at(){let t=globalThis[it];if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"&&typeof t.id=="string")return t.id}var ct="0.1.0-beta.0";var ut=Symbol.for("starko.sdk.instrument.v1");function dt(){let t=globalThis;return t[ut]||(t[ut]=new WeakMap)}var Sn=(t,e)=>{let n=dt().get(t);return n&&n[e]};function re(t,e){let n=Sn(t,e);return n?n.o:t[e]}function T(t,e,n){try{let r=t,i=dt(),o=i.get(r);o||i.set(r,o={});let a=o[e];if(!a){let c=r[e];if(typeof c!="function")return ke;let u={o:c,h:[],w:function(){let d=Array.prototype.slice.call(arguments),f=[];for(let p of u.h.slice())try{let g=p(this,d);g&&f.push(g)}catch(g){}let m=u.o.apply(this,d);for(let p of f)try{p(m)}catch(g){}return m}};if(r[e]=u.w,r[e]!==u.w)return ke;a=o[e]=u}let s=a;return s.h.push(n),()=>{try{let c=s.h.indexOf(n);if(c>=0&&s.h.splice(c,1),s.h.length||o[e]!==s)return;o[e]=void 0,r[e]===s.w&&(r[e]=s.o)}catch(c){}}}catch(r){return ke}}var ke=()=>{};var M=ct,we=t=>Object.prototype.toString.call(t),xe=(t,e)=>we(t)===`[object ${e}]`,x=t=>typeof t=="string",ie=t=>we(t)==="[object Object]",ft=t=>t===null||typeof t!="object"&&typeof t!="function";function R(t){if(/^\[object (?:Error|Exception|DOMException|WebAssembly\.Exception)\]$/.test(we(t)))return!0;try{return t instanceof Error}catch(e){return!1}}function O(t){if(!t||typeof t!="object")return!1;try{return typeof Event!="undefined"&&t instanceof Event}catch(e){return!1}}var lt=t=>!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function";function b(t,e){if(t.length<=e)return t;let n=e,r=t.charCodeAt(n-1);return r>=55296&&r<=56319&&n--,t.slice(0,n)}function w(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319?(e+=4,n++):e+=3}return e}function V(){let t=globalThis.crypto;try{if(t&&typeof t.randomUUID=="function")return t.randomUUID()}catch(r){}let e;try{t&&typeof t.getRandomValues=="function"&&(e=t.getRandomValues(new Uint8Array(16)))}catch(r){}let n=0;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>{let i=e?e[n++>>1]>>(n&1)*4:Math.random()*16;return(+r^(i&15)>>+r/4).toString(16)})}function y(t){try{return String(t)}catch(e){return"[unserializable]"}}var F="[starko]",Se={};try{if(typeof console!="undefined")for(let t of["log","warn"])Se[t]=re(console,t).bind(console)}catch(t){}function ve(...t){try{let e=Se.warn;e&&e(F,...t)}catch(e){}}function oe(t=!1){let e=new Set,n=(i,o)=>{if(r.enabled)try{let a=Se[i];a&&a(F,...o)}catch(a){}},r={enabled:t,log:(...i)=>n("log",i),warn:(...i)=>n("warn",i),alert:(i,...o)=>{e.has(i)||(e.add(i),ve(...o))}};return r}function S(t,e,n,r){try{return n()}catch(i){return t&&t.warn(`${e} failed`,i),r}}function Y(t,e){if(!e)return!1;for(let n of e)try{if(x(n)?t.includes(n):n.test(t))return!0}catch(r){}return!1}function N(t){let e=t&&t.unref;typeof e=="function"&&e.call(t)}var Q=(t,e,n)=>Math.min(n,Math.max(e,t)),v=(t,e)=>typeof t=="number"&&isFinite(t)?t:e;var J=100,vn=2e3;function Z(t,e=5){return j(t,e,new WeakSet)}function j(t,e,n){try{if(t===null||typeof t=="boolean")return t;if(typeof t=="string")return b(t,vn);if(typeof t=="number")return isFinite(t)?t:`[${y(t)}]`;if(typeof t=="undefined")return"[undefined]";if(typeof t=="bigint")return`[BigInt: ${t.toString()}]`;if(typeof t=="symbol")return`[${y(t)}]`;if(typeof t=="function")return`[Function: ${t.name||"<anonymous>"}]`;let r=t;if(n.has(r))return"[Circular]";let i=r;if(typeof i.nodeType=="number"&&typeof i.nodeName=="string")return`[${i.nodeName}]`;if(r.window===r)return"[Window]";if(r instanceof Date)return isNaN(r.getTime())?"[Invalid Date]":r.toISOString();if(r instanceof RegExp)return y(r);if(e<=0)return Array.isArray(r)?"[Array]":"[Object]";n.add(r);let o;if(Array.isArray(r)){let a=[];for(let s=0;s<r.length&&s<J;s++)a.push(j(r[s],e-1,n));r.length>J&&a.push(`[\u2026 ${r.length-J} more]`),o=a}else if(R(r)){let a=r,s={name:j(a.name,1,n),message:j(a.message,1,n)};for(let c of Object.keys(a).slice(0,J))s[c]=j(a[c],e-1,n);o=s}else{let a=r.toJSON;if(typeof a=="function"&&!ie(r))o=j(a.call(r),e-1,n);else{let s={},c=0;for(let u in r){if(!Object.prototype.hasOwnProperty.call(r,u))continue;if(c++>=J){s["\u2026"]="[more keys]";break}let d;try{d=r[u]}catch(f){d="[unserializable]"}d!==void 0&&(s[u]=j(d,e-1,n))}o=s}}return n.delete(r),o}catch(r){return"[unserializable]"}}function k(t){var e;try{return(e=JSON.stringify(t))!=null?e:"null"}catch(n){return'"[unserializable]"'}}function D(t,e,n=5){for(let r=n;r>=1;r--){let i=Z(t,r);if(w(k(i))<=e)return i}return{_truncated:`[over ${e} bytes]`}}var _n=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/s,h=(t,e)=>{try{return t[e]}catch(n){return}};function se(t){var e,n;try{let r=(n=(e=Object.getPrototypeOf(t))==null?void 0:e.constructor)==null?void 0:n.name;return x(r)&&r?r:void 0}catch(r){return}}function Tn(t){let e=h(t,"name"),n=h(t,"message"),r=h(t,"stack"),i={type:x(e)&&e||se(t)||"Error",value:x(n)?n:n==null?"":y(n),stack:x(r)?r:void 0},o=[],a=h(t,"cause");a!=null&&o.push(["cause",a]);let s=h(t,"errors");return Array.isArray(s)&&s.forEach((c,u)=>o.push([`errors[${u}]`,c])),o.length&&(i.children=o),i}function ae(t,e,n){if(xe(t,"ErrorEvent")||O(t)&&"error"in t&&"message"in t){let r=t,i=h(r,"filename"),o=h(r,"lineno"),a=h(r,"colno"),s=x(i)&&i&&typeof o=="number"&&o>0?`Error
|
|
2
|
+
at ${i}:${o}:${typeof a=="number"?a:0}`:void 0,c=h(r,"error");if(c!=null){let f=ae(c,{...e,synthetic:void 0},n);return!f.stack&&s&&(f.stack=s,f.synthetic=!1),f}let u=h(r,"message"),d=_n.exec(x(u)?u:"")||[];return{type:d[1]||"Error",value:d[2]||"",stack:s}}if(xe(t,"PromiseRejectionEvent")||O(t)&&("reason"in t||pt(t))){let r=h(t,"reason");return r===void 0&&pt(t)&&(r=h(h(t,"detail"),"reason")),ft(r)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${y(r)}`,...$(e)}:ae(r,e,n)}if(R(t)){let r=Tn(t);return r.stack||Object.assign(r,$(e)),r}if(O(t)){let r=h(t,"type");return{type:se(t)||"Event",value:`Event \`${se(t)||"Event"}\` (type=${x(r)?r:"unknown"}) captured as exception`,...$(e)}}if(t!==null&&typeof t=="object"){let r=t;if(ie(r))for(let u of Object.keys(r)){let d=h(r,u);if(R(d))return ae(d,e,n)}let i=h(r,"name"),o=h(r,"message"),a=h(r,"stack"),s;if(x(o)&&o)s=o;else{let d=Object.keys(r).sort().join(", ");d.length>40&&(d=b(d,40)+"\u2026");let f=se(r);s=`${f&&f!=="Object"?`'${f}'`:"Object"} captured as exception with keys: ${d||"[none]"}`}n&&(n.value=D(r,l.MAX_EXTRA_BYTES/2,3));let c={type:x(i)&&i||"Error",value:s};return x(a)&&a?c.stack=a:Object.assign(c,$(e)),c}return x(t)?{type:"Error",value:t,...$(e)}:{type:"Error",value:y(t),...$(e)}}function pt(t){let e=h(t,"detail");return!!e&&typeof e=="object"&&"reason"in e}function $(t){let e=t.synthetic;return!e||!e.stack?{}:{stack:e.stack,skip:e.skip,synthetic:!0}}function Rn(t,e){let n=st(e.parser);return t.map(r=>{let i={platform:e.framePlatform};r.filename!==void 0&&(i.filename=r.filename),r.function!==void 0&&(i.function=r.function),r.lineno!==void 0&&(i.lineno=r.lineno),r.colno!==void 0&&(i.colno=r.colno);try{let a=e.isInApp&&e.isInApp(r.filename);typeof a=="boolean"&&(i.in_app=a)}catch(a){}let o=r.filename?n[r.filename]:void 0;return o&&(i.chunk_id=o),i})}function mt(t,e,n){var c;let r={},i=[],o=new Set,a=(c=e==null?void 0:e.handled)!=null?c:!0,s=(u,d,f,m)=>{if(i.length>=l.MAX_EXCEPTIONS)return;if(u!==null&&typeof u=="object"){if(o.has(u))return;o.add(u)}let p=ae(u,f===void 0?n:{...n,synthetic:void 0},f===void 0?r:void 0),g=i.length,_={type:p.type||"Error",value:p.value||""},P=f===void 0?{type:(e==null?void 0:e.type)||"generic",handled:a,...An(e)}:{type:"chained",handled:a,source:d,exception_id:g,parent_id:f};if(p.synthetic&&(P.synthetic=!0),_.mechanism=P,p.stack){let ne=Rn(n.parser(p.stack,p.skip||0),n);ne.length&&(_.stacktrace={type:"raw",frames:ne})}if(i.push(_),!(m>=l.MAX_EXCEPTIONS))for(let[ne,ln]of p.children||[])s(ln,ne,g,m+1)};try{s(t,void 0,void 0,0)}catch(u){i.length||i.push({type:"Error",value:y(t),mechanism:{type:(e==null?void 0:e.type)||"generic",handled:a}})}return i.length>1&&(i[0].mechanism.exception_id=0),{exceptions:i,serialized:r.value}}function An(t){let e={};if(t)for(let n of Object.keys(t))t[n]!==void 0&&(e[n]=t[n]);return e}var _e=new WeakMap;function ee(t){if(!(!t||typeof t!="object"))try{return _e.get(t)}catch(e){return}}function gt(t,e){try{if(!t||typeof t!="object")return;_e.set(t,e);let n=h(t,"error")||h(t,"reason");O(t)&&n&&typeof n=="object"&&_e.set(n,e)}catch(n){}}function ht(t){if(O(t)){let e=h(t,"error")||h(t,"reason");if(e&&typeof e=="object")return e}return t}var ce=4*1024,Te=class t{constructor(e=l.MAX_BREADCRUMBS,n=l.MAX_BREADCRUMB_BYTES){this.maxItems=e;this.maxBytes=n;this.items=[];this.bytes=0;this.maxItems=Q(Math.floor(e),0,l.MAX_BREADCRUMBS)}add(e){if(this.maxItems===0)return;let n=Re(e),r=w(k(n))+1;for(r>ce&&n.data&&(n.data=D(n.data,ce/2,3),r=w(k(n))+1),r>ce&&(delete n.data,n.message&&(n.message=b(n.message,1024)),r=w(k(n))+1),this.items.push({crumb:n,bytes:r}),this.bytes+=r;this.items.length>this.maxItems||this.bytes>this.maxBytes;){let i=this.items.shift();if(!i)break;this.bytes-=i.bytes}}setMaxItems(e){for(this.maxItems=Q(Math.floor(e),0,l.MAX_BREADCRUMBS);this.items.length>this.maxItems;)this.bytes-=this.items.shift().bytes}get(){return this.items.map(e=>e.crumb)}get byteSize(){return this.bytes}clear(){this.items=[],this.bytes=0}clone(){let e=new t(this.maxItems,this.maxBytes);return e.items=this.items.slice(),e.bytes=this.bytes,e}},In=["fatal","error","warning","info","debug"],U=t=>In.includes(t);function Re(t){let e={timestamp:typeof t.timestamp=="number"&&isFinite(t.timestamp)?t.timestamp:Date.now(),type:typeof t.type=="string"&&t.type?b(t.type,32):"custom"};return t.category!=null&&(e.category=b(y(t.category),64)),t.message!=null&&(e.message=b(y(t.message),2048)),U(t.level)&&(e.level=t.level),t.data&&typeof t.data=="object"&&(e.data=D(t.data,ce,3)),e}var ue=class t{constructor(e=l.MAX_BREADCRUMBS){this.user=null;this.tags={};this.extra={};this.contexts={};this.breadcrumbs=new Te(e)}setUser(e){return this.user=e?{...e}:null,this}setTag(e,n){return this.tags={...this.tags,[e]:y(n)},this}setTags(e){for(let n of Object.keys(e||{}))this.setTag(n,e[n]);return this}setExtra(e,n){return this.extra={...this.extra,[e]:n},this}setExtras(e){return this.extra={...this.extra,...e},this}setContext(e,n){let r={...this.contexts};return n===null?delete r[e]:r[e]=n,this.contexts=r,this}setFingerprint(e){return this.fingerprint=e,this}setLevel(e){return this.level=e,this}addBreadcrumb(e){return this.breadcrumbs.add(e),this}clearBreadcrumbs(){return this.breadcrumbs.clear(),this}clear(){return this.user=null,this.tags={},this.extra={},this.contexts={},this.fingerprint=void 0,this.level=void 0,this.breadcrumbs.clear(),this}clone(){let e=new t(0);return e.user=this.user?{...this.user}:null,e.tags={...this.tags},e.extra={...this.extra},e.contexts={...this.contexts},e.fingerprint=this.fingerprint,e.level=this.level,e.breadcrumbs=this.breadcrumbs.clone(),e}applyToEvent(e){this.user&&Object.keys(this.user).length&&(e.user={...this.user,...e.user}),Object.keys(this.tags).length&&(e.tags={...this.tags,...e.tags}),Object.keys(this.extra).length&&(e.extra={...this.extra,...e.extra}),Object.keys(this.contexts).length&&(e.contexts={...this.contexts,...e.contexts}),this.fingerprint&&!e.fingerprint&&(e.fingerprint=this.fingerprint),this.level&&(e.level=this.level);let n=this.breadcrumbs.get();return n.length&&(e.breadcrumbs=[...n,...e.breadcrumbs||[]]),e}};function Mn(t){let e=/^(\d+)\.(\d+)/.exec(t);return e?e[1]==="0"?`0.${e[2]}`:e[1]:t}var yt=Symbol.for(`starko.sdk.carrier.v2/${Mn(M)}`);function q(){let t=globalThis,e=t[yt];return(!e||typeof e!="object")&&(e={version:M,client:void 0,globalScope:new ue,stack:[],manager:void 0},t[yt]=e),e}var bt={getScope:()=>{let t=q();return t.stack[t.stack.length-1]||t.globalScope},withScope(t){let e=q().stack,n=bt.getScope().clone();e.push(n);try{return t(n)}finally{let r=e.lastIndexOf(n);r>=0&&e.splice(r,1)}}},de=()=>q().manager||bt;function E(){return q().client}function Et(t){q().client=t}function G(t,e){try{let n=t&&t[e];return typeof n=="function"?n.bind(t):void 0}catch(n){return}}function C(){return de().getScope()}function Ae(){return q().globalScope}function kt(t){return de().withScope(t)}function wt(){let t=de();return t.peekScope?t.peekScope():t.getScope()}function Ie(t){let e=de();return e.scopeForUser?e.scopeForUser(t):e.getScope()}var Me="__STARKO_BRIDGE__",On="starko:bridge",Cn=/^[\w-]+\.[\w-]+\.[\w-]+$/,Ce=t=>t!==null&&typeof t=="object";function fe(){try{let t=globalThis[Me];return Ce(t)?t:void 0}catch(t){return}}function St(t){try{return Ce(t)&&typeof t.version=="string"&&typeof t.getSessionId=="function"&&typeof t.captureException=="function"}catch(e){return!1}}function vt(t){try{let e=(fe()||{}).widget;return e&&e[t]()}catch(e){return}}function _t(){try{return Ce((fe()||{}).widget)}catch(t){return!1}}function Tt(){let t=vt("getReplaySessionId");return typeof t=="string"&&X.test(t)?t:void 0}function Ln(){let t=vt("getClientToken");return typeof t=="string"&&t.length<=2048&&Cn.test(t)?t:void 0}function Le(){try{let t=E();if(!t||!t.isEnabled())return!1;let e=t.getIntegration("GlobalHandlers");return!!e&&e.captures!==!1}catch(t){return!1}}var Pn=Object.freeze({version:M,get capturesErrors(){return Le()},getSessionId:()=>{try{let t=E();return t&&t.getSessionId()||""}catch(t){return""}},captureException:(t,e)=>{try{let n=E();return n?n.captureException(t,{mechanism:{type:"widget",handled:!0},...e}):""}catch(n){return""}}}),Pe;function Oe(){try{let t=Le();Pe=t,typeof window!="undefined"&&typeof CustomEvent=="function"&&window.dispatchEvent(new CustomEvent(On,{detail:{side:"sdk",capturesErrors:t}}))}catch(t){}}function Ne(){try{let t=fe();t&&St(t.sdk)&&Le()!==Pe&&Oe()}catch(t){}}function xt(t){try{let e=globalThis,n=fe();if(!n){if(e[Me]!=null)return t&&t("__STARKO_BRIDGE__ is not an object: running without the widget bridge"),0;e[Me]=n={}}return St(n.sdk)?1:(Object.defineProperty(n,"sdk",{value:Pn,enumerable:!0,writable:!1,configurable:!1}),2)}catch(e){return t&&t("the widget bridge's sdk slot could not be set"),0}}function Rt(){let t;return{name:"WidgetBridge",setup(e){t=e.logger.log,xt(t)?Oe():Pe=void 0},processEvent(e){if(xt(t)===2&&Oe(),!e.client_token){let n=Ln();n&&(e.client_token=n)}return e},teardown(){Ne()}}}function le(t={}){let e;return{name:"ConsoleErrorCapture",setup(n){if(typeof console=="undefined")return;let r=!1;e=T(console,"error",(i,o)=>{if(r||o[0]===F||t.whenWidget&&!_t())return;let a=o.find(s=>R(s));if(!(!a||ee(a))){r=!0;try{n.captureException(a,{mechanism:{type:"console",handled:!0}})}finally{r=!1}}})},teardown(){e&&e(),e=void 0}}}var Nn=/^(?:<anonymous>|\[native code\]|native|<data:.*)$/,Bn=/^(?:chrome|moz|safari|safari-web|ms-browser)-extension:\/\//i,jn=/(?:starko[^\s/]*\.(?:one|me|app)|localhost:\d+)\/(?:widget(?:[.-][^\s/]*)?\.js|replay\/rrweb-record)/i,Dn=/\/widget(?:[.-][A-Za-z0-9]+)?\.js\b/i,Un=/^(?:\[object \w+\]|undefined|null|error|Non-Error promise rejection captured with value: (?:undefined|null)?)$/i,Xn=/^(?:uncaught\s+)?script error\.?$/i,Wn=/^resizeobserver loop|resizeobserver loop (?:limit exceeded|completed with undelivered notifications)/i,At=/\baborterror\b|^(?:the )?(?:user |operation was |request |fetch was |signal is )?aborted(?: a request| without reason)?\.?$|\bthe operation was aborted\b/i,It=/^(?:typeerror: )?(?:failed to fetch|networkerror when attempting to fetch resource\.?|load failed|network request failed|network error|the internet connection appears to be offline\.?)$/i,Mt=new Set;function Ot(t){t&&Mt.add(t)}function Fn(t){let e=t.exception_list[0];if(!e)return null;let n=(e.value||"").replace(/\s+/g," ").trim(),r=e.type&&e.type!=="Error"?`${e.type}: ${n}`:n,i=e.mechanism&&e.mechanism.synthetic||!e.stacktrace?[]:e.stacktrace.frames,o=i.length>0,a=i.map(s=>s.filename||"").filter(s=>s&&!Nn.test(s));return(!n||Un.test(n))&&!o?"empty message":Xn.test(n)&&!o?"cross-origin script error":i.slice(0,3).some(s=>s.filename&&Bn.test(s.filename))?"browser extension":Wn.test(n)?"ResizeObserver loop":e.type==="AbortError"||At.test(n)||At.test(r)?"aborted request":It.test(n)||It.test(r)||/\bnetworkerror\b/i.test(r)&&!o?"network error":a.length&&a.every(s=>jn.test(s)||Mt.has(s)||Dn.test(s)&&/starko/i.test(s))?"Starko script":null}function Ct(){return{name:"InboundFilters",processEvent(t,e,n){let r=Fn(t);return r?(n.logger.log("dropped",r),null):t}}}var $n=["unknown_workspace","disabled","origin_not_allowed"],Lt=1024,pe=class{constructor(e){this.items=[];this.running=null;this.sends=new Set;this.flying=new Set;this.retryAt=0;this.backoffUntil=0;this.pausedUntil=0;this.failures=0;this.disabled=!1;this.dropped=0;this.o={transport:e.transport,envelope:e.envelope,maxQueueSize:100,flushInterval:1e3,maxAttempts:3,pauseAfter:3,failurePauseMs:5*6e4,backoffMs:1e3,maxBackoffMs:6e4,sendTimeoutMs:3e4,random:Math.random,logger:oe()};for(let n of Object.keys(e))e[n]!==void 0&&(this.o[n]=e[n])}get size(){return this.items.length}get isSending(){return this.sends.size>0}get isDisabled(){return this.disabled}get isBlocked(){return this.blockedFor(!1)>0}filter(e){this.items=this.items.filter(n=>{try{return e(n.event)}catch(r){return!0}})}add(e){if(this.disabled)return;let n;try{n=JSON.stringify(e)}catch(i){}if(typeof n!="string"){this.o.logger.warn("unserializable event dropped");return}let r=w(n);if(r>l.MAX_BODY_BYTES-Lt){this.o.logger.warn("event too large",e.event_id);return}this.items.push({event:e,bytes:r,attempts:0,maxBatch:l.MAX_EVENTS_PER_ENVELOPE}),this.bound(),this.schedule(this.items.length>=l.MAX_EVENTS_PER_ENVELOPE?0:this.o.flushInterval)}disable(){this.disabled=!0,this.items=[],this.clearTimer()}holdOff(e){this.backoffUntil=Math.max(this.backoffUntil,Date.now()+e),this.clearTimer(),this.schedule(this.o.flushInterval)}resume(){this.disabled||(this.pausedUntil=this.backoffUntil=this.failures=0,this.schedule(0))}async flush(e=2e3,n=!1){this.clearTimer();let r=this.dropped;n&&this.sendAll();let i=(async()=>{for(let s=0;s<50;s++){for(;this.sends.size;)await Promise.all(this.sends);if(!this.items.length||this.disabled||this.blockedFor(n)>0)break;n?this.sendAll():await this.drain()}return!this.items.length&&!this.sends.size&&this.dropped===r})(),o,a=new Promise(s=>{o=setTimeout(()=>s(!1),Math.max(0,e))});try{return await Promise.race([i,a])}finally{clearTimeout(o),this.schedule(this.o.flushInterval)}}bound(){let e=this.items.length-this.o.maxQueueSize;e>0&&(this.items.splice(0,e),this.dropped++,this.o.logger.alert("queue",`events dropped: queue full (maxQueueSize ${this.o.maxQueueSize})`))}blockedFor(e){let n=Date.now();return Math.max(0,this.retryAt-n,this.pausedUntil-n,e?0:this.backoffUntil-n)}clearTimer(){clearTimeout(this.timer),this.timer=void 0}schedule(e){if(this.disabled||!this.items.length)return;let n=Math.max(e,this.blockedFor(!1));if(n<2**31-1){if(this.timer!==void 0){if(n>0)return;this.clearTimer()}this.timer=setTimeout(()=>{this.timer=void 0,this.drain()},n),N(this.timer)}}drain(){return this.running?this.running:(this.running=(async()=>{if(this.o.gate)try{await this.o.gate()}catch(e){}for(;this.items.length&&!this.disabled&&!this.blockedFor(!1)&&await this.send(this.take(),!1););})().catch(e=>this.o.logger.warn("send failed",e)).then(()=>{this.running=null,this.schedule(this.items.length>=l.MAX_EVENTS_PER_ENVELOPE?0:this.o.flushInterval)}),this.running)}sendAll(){let e=[];for(let n of this.flying)for(let r of n)r.done||r.rescued||this.items.includes(r)||(r.rescued=!0,e.push(r));for(this.items.unshift(...e);this.items.length&&!this.disabled&&!this.blockedFor(!0);)this.send(this.take(),!0)}take(){let e=[],n=Lt,r=l.MAX_EVENTS_PER_ENVELOPE;for(let i of this.items){if(r=Math.min(r,i.maxBatch),e.length>=r||e.length&&n+i.bytes+1>l.MAX_BODY_BYTES)break;e.push(i),n+=i.bytes+1}return this.items.splice(0,e.length),e}send(e,n){n||this.flying.add(e);let r;try{r=this.o.transport.send(this.o.envelope(e.map(a=>a.event)),{keepalive:n})}catch(a){this.o.logger.warn("send failed",a),r=Promise.resolve({status:0})}let i,o=Promise.race([Promise.resolve(r).then(void 0,a=>(this.o.logger.warn("send failed",a),{status:0})),new Promise(a=>{i=setTimeout(()=>a({status:0}),this.o.sendTimeoutMs),N(i)})]).then(a=>(clearTimeout(i),this.flying.delete(e),this.sends.delete(o),this.handle(e,a&&typeof a.status=="number"?a:{status:0}))).catch(()=>!1);return this.sends.add(o),o}requeue(e,n){this.items.unshift(...e.filter(r=>!r.done&&!this.items.includes(r)&&n(r))),this.bound()}handle(e,n){let{status:r,reason:i}=n,o=this.o.logger,a=Date.now(),s=typeof n.retryAfter=="number"&&isFinite(n.retryAfter)&&n.retryAfter>=0?n.retryAfter*1e3:void 0;if(r>=200&&r<300){this.failures=0;for(let p of e)p.done=!0;return this.items=this.items.filter(p=>!p.done),o.log(`sent ${e.length}`),!0}if((r===401||r===403)&&$n.includes(i)){o.warn(`${r} ${i}: off`),this.disable();try{this.o.onDisable&&this.o.onDisable(r)}catch(p){}return!1}if(r>=300&&r<400){this.dropped++;let p=n.location?` to ${n.location}`:"";return o.alert("redirect",`host answered ${r}, a redirect${p}: not followed, events not delivered. Set \`host\` to the final address.`),!0}if(r===413){if(e.length>1&&!e.some(p=>p.halved)){let p=Math.ceil(e.length/2);for(let g of e)g.halved=!0,g.maxBatch=p;this.requeue(e,()=>!0),o.warn("413: halving")}else this.dropped++,o.warn("413: dropped");return!0}if(r===429&&i==="quota")return this.retryAt=a+(s===void 0?36e5:s),this.dropped++,o.warn("429 quota: dropped"),this.schedule(0),!1;if((r===401||r===403)&&i==="invalid")return this.dropped++,o.alert("credentials",`${r}: secret key refused, events dropped. Check \`apiKey\`.`),!0;if(!(r===0||r===401||r===403||r===408||r===429||r>=500))return this.dropped++,o.warn(`${r}: dropped`),!0;let u=!1,d=1;this.requeue(e,p=>++p.attempts<this.o.maxAttempts?!!(d=p.attempts):(u=!0,!1)),u&&this.dropped++,u&&++this.failures>=this.o.pauseAfter&&(this.pausedUntil=a+this.o.failurePauseMs,o.warn("repeated failures: paused"));let f=Math.min(this.o.maxBackoffMs,this.o.backoffMs*2**(d-1)),m=Math.round(f*(.5+this.o.random()));return s!==void 0||r===429?this.retryAt=a+Math.max(m,s===void 0?6e4:s):this.backoffUntil=a+m,o.warn(`${r}: retry`),this.schedule(0),!1}};function Pt(t,e,n){let r=typeof t=="string"&&t?t:"Error",i=typeof e=="string"?e.slice(0,120):"";return i?`${r}: ${i.replace(/[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|\b(?=[0-9a-f]*\d)[0-9a-f]{8,}\b/gi,"<id>").replace(/\d+/g,"<n>")}`:n?`${r} @ ${n.filename}:${n.lineno}`:r}var qn=200,Gn=6e4,me=class{constructor(e={}){this.buckets=new Map;this.sent=0;this.recent=[];var r,i;let n=o=>typeof o=="number"&&!isNaN(o)?Math.max(0,o):1/0;this.burst=Math.max(1,(r=e.burst)!=null?r:10),this.refillMs=Math.max(1,(i=e.refillMs)!=null?i:1e4),this.lifetimeCap=n(e.lifetimeCap),this.perMinute=n(e.perMinute)}check(e,n=Date.now()){return this.test(e,n,!0)}peek(e,n=Date.now()){return this.test(e,n,!1)}test(e,n,r){if(this.sent>=this.lifetimeCap)return"lifetime cap";if(this.perMinute!==1/0){for(;this.recent.length&&this.recent[0]<=n-Gn;)this.recent.shift();if(this.recent.length>=this.perMinute)return"per-minute budget"}let i=this.buckets.get(e);if(!i)this.buckets.size>=qn&&this.buckets.delete(this.buckets.keys().next().value),i={tokens:this.burst,at:n},this.buckets.set(e,i);else{this.buckets.delete(e),this.buckets.set(e,i);let o=Math.floor((n-i.at)/this.refillMs);o>0&&(i.tokens=Math.min(this.burst,i.tokens+o),i.at+=o*this.refillMs)}return i.tokens<=0?"rate limited":(r&&(i.tokens--,i.tokens===this.burst-1&&(i.at=n),this.sent++,this.perMinute!==1/0&&this.recent.push(n)),null)}get count(){return this.sent}};var ge={enabled:!0,sample_rate:1,suppress:[]};function Nt(t){if(!t||typeof t!="object")return{...ge};let e=t,n=[];if(Array.isArray(e.suppress))for(let r of e.suppress.slice(0,100)){if(!r||typeof r!="object")continue;let i={};typeof r.type=="string"&&r.type&&(i.type=r.type),typeof r.value_contains=="string"&&r.value_contains&&(i.value_contains=r.value_contains),(i.type||i.value_contains)&&n.push(i)}return{enabled:e.enabled!==!1,sample_rate:typeof e.sample_rate=="number"&&isFinite(e.sample_rate)?Q(e.sample_rate,0,1):1,suppress:n}}function Bt(t,e){let n=t.exception_list[0];if(!n)return!1;let r=(n.value||"").toLowerCase();return e.some(i=>(i.type===void 0||i.type===n.type)&&(i.value_contains===void 0||r.includes(i.value_contains.toLowerCase())))}var jt=new Set(et);function zn(t){let e=t;try{e=decodeURIComponent(t.replace(/\+/g," "))}catch(n){}return jt.has(e.toLowerCase())?!0:e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[\s_-]+/).some(n=>jt.has(n))}function z(t){if(typeof t!="string")return t;let e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=n.indexOf("//"),i=n.indexOf("?");if(r>=0&&(i<0||r<i)&&(r===0||n[r-1]===":")){let s=r+2,c=s;for(;c<n.length&&n[c]!=="/"&&n[c]!=="?";)c++;let u=n.lastIndexOf("@",c-1);u>=s&&(n=n.slice(0,s)+n.slice(u+1))}let o=n.indexOf("?");if(o<0)return n;let a=n.slice(o+1).split("&").map(s=>{let c=s.indexOf("=");return c>0&&zn(s.slice(0,c))?`${s.slice(0,c)}=${tt}`:s}).join("&");return`${n.slice(0,o)}?${a}`}var Hn=`
|
|
3
|
+
\r\f\v"'\`<>()[]{}|\\^`;function Be(t){if(typeof t!="string"||t.indexOf("://")<0)return t;let e=t.toLowerCase(),n="",r=0,i=0;for(;;){let o=e.indexOf("http",i);if(o<0)break;let a=e.startsWith("://",o+4)?7:e.startsWith("s://",o+4)?8:0;if(!a){i=o+4;continue}let s=o+a;for(;s<t.length&&Hn.indexOf(t[s])<0;)s++;n+=t.slice(r,o)+z(t.slice(o,s)),r=i=s}return n+t.slice(r)}function je(t){return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?z(t):t}var he=200*1024,I=(t,e)=>t==null?void 0:b(y(t),e),Dt=t=>typeof t=="number"&&isFinite(t)&&t>0?Math.floor(t):void 0,L=t=>!!t&&typeof t=="object";function De(t,e,n){for(let[r,i]of n)e[r]!=null&&(t[r]=I(e[r],i));return t}var Kn=[["lang",32],["filename",l.MAX_FILENAME],["abs_path",l.MAX_FILENAME],["function",l.MAX_FUNCTION],["module",l.MAX_FUNCTION],["chunk_id",128],["context_line",l.MAX_CONTEXT_LINE]],Ut=(t,e,n)=>t.slice(e,n).map(r=>I(r,l.MAX_CONTEXT_LINE)||"");function Vn(t){let e=De({platform:I(t.platform,32)},t,Kn);e.filename&&(e.filename=je(e.filename)),e.abs_path&&(e.abs_path=je(e.abs_path));let n=Dt(t.lineno),r=Dt(t.colno);return n&&(e.lineno=n),r&&(e.colno=r),typeof t.in_app=="boolean"&&(e.in_app=t.in_app),Array.isArray(t.pre_context)&&(e.pre_context=Ut(t.pre_context,-l.MAX_CONTEXT_LINES)),Array.isArray(t.post_context)&&(e.post_context=Ut(t.post_context,0,l.MAX_CONTEXT_LINES)),typeof t.resolved=="boolean"&&(e.resolved=t.resolved),e}function Yn(t){let e={type:I(t.type,64)||"generic",handled:t.handled!==!1};typeof t.synthetic=="boolean"&&(e.synthetic=t.synthetic),t.source!=null&&(e.source=I(t.source,64));for(let n of["exception_id","parent_id"]){let r=t[n];typeof r=="number"&&r>=0&&r<1e3&&(e[n]=Math.floor(r))}return e}function Qn(t,e){let n={type:I(t.type,l.MAX_TYPE)||"Error",value:Be(I(t.value,l.MAX_VALUE)||"")};t.module!=null&&(n.module=I(t.module,l.MAX_TYPE)),L(t.mechanism)&&(n.mechanism=Yn(t.mechanism));let r=t.stacktrace&&t.stacktrace.frames;if(Array.isArray(r)&&r.length){let i=e>>1,o=r.length>e?[...r.slice(0,i),...r.slice(-(e-i))]:r;n.stacktrace={type:"raw",frames:o.filter(L).map(Vn)}}return n}var Jn=["url","from","to"];function Zn(t){let e=Re(t);e.message&&(e.message=Be(e.message));let n=e.data;if(n)for(let r of Jn)typeof n[r]=="string"&&(n[r]=z(n[r]));return e}function er(t){let e=[];for(let i of t.slice(-l.MAX_BREADCRUMBS))try{L(i)&&e.push(Zn(i))}catch(o){}let n=e.map(i=>w(k(i))+1),r=n.reduce((i,o)=>i+o,2);for(;e.length&&r>l.MAX_BREADCRUMB_BYTES;)r-=n[0],e=e.slice(1),n=n.slice(1);return e}function Xt(t,e){if(!L(t))return;let n=D(t,e);return L(n)&&!Array.isArray(n)&&Object.keys(n).length?n:void 0}function Wt(t){let e=Array.isArray(t.exception_list)?t.exception_list.filter(L).slice(0,l.MAX_EXCEPTIONS):[],n={event_id:I(t.event_id,64)||"",timestamp:v(t.timestamp,Date.now()),platform:I(t.platform,32),level:U(t.level)?t.level:"error",exception_list:e.map(s=>Qn(s,l.MAX_FRAMES))};n.exception_list.length||(n.exception_list=[{type:"Error",value:""}]),De(n,t,[["fingerprint",l.MAX_FINGERPRINT],["release",l.MAX_RELEASE],["environment",l.MAX_ENVIRONMENT],["client_token",2048],["user_agent",512],["server_name",256]]),typeof t.session_id=="string"&&X.test(t.session_id)&&(n.session_id=t.session_id);let r=(s,c)=>{let u=t[s];if(!L(u))return;let d=De({},u,c);Object.keys(d).length&&(n[s]=d)};r("user",[["id",256],["email",256],["name",256],["hash",256]]),r("request",[["url",l.MAX_URL],["method",16],["route",l.MAX_URL],["referrer",l.MAX_URL]]),r("trace",[["trace_id",64],["span_id",64]]),n.request&&(n.request.url&&(n.request.url=b(z(n.request.url),l.MAX_URL)),n.request.referrer&&(n.request.referrer=b(z(n.request.referrer),l.MAX_URL)));let i=L(t.tags)?Z(t.tags,1):void 0;if(L(i)){let s={},c=0;for(let u of Object.keys(i)){if(c++>=l.MAX_TAGS)break;s[b(u,l.MAX_TAG_KEY)]=I(i[u],l.MAX_TAG_VALUE)||""}c&&(n.tags=s)}let o=Xt(t.extra,l.MAX_EXTRA_BYTES);o&&(n.extra=o);let a=Xt(t.contexts,l.MAX_EXTRA_BYTES);if(a){let s={};for(let c of Object.keys(a)){let u=a[c];L(u)&&!Array.isArray(u)&&(s[c]=u)}Object.keys(s).length&&(n.contexts=s)}if(Array.isArray(t.breadcrumbs)&&t.breadcrumbs.length){let s=er(t.breadcrumbs);s.length&&(n.breadcrumbs=s)}return tr(n)}function tr(t){let e=()=>w(k(t));if(e()<=he)return t;for(let n of t.exception_list)for(let r of n.stacktrace?n.stacktrace.frames:[])delete r.pre_context,delete r.post_context;if(e()<=he)return t;for(let n of t.exception_list)n.stacktrace&&(n.stacktrace.frames=n.stacktrace.frames.slice(0,20));return e()<=he||(delete t.extra,delete t.contexts,delete t.breadcrumbs,e()<=he)||(t.exception_list=t.exception_list.slice(0,1)),t}var Ft=30,rr=1e4,$t=1e3,qt={},ir={"rate limited":"rate limit per error (10, then 1 per 10 s)","per-minute budget":"maxEventsPerMinute","lifetime cap":"maxEventsPerLifetime"},or=6e4,sr=/^(?:<anonymous>|\[native code\]|native)$/,ye=class{constructor(e){this.integrations=[];this.state="idle";this.remote=null;this.remoteReady=Promise.resolve();this.pending=[];this.inflight=new Set;this.drops={};let n={...e,host:(e.host||Ze).replace(/\/+$/,"")};this.options=n,this.logger=oe(!!n.debug);let r=(i,o)=>typeof i=="number"&&i>=0?i:o;this.limiter=new me({lifetimeCap:r(n.maxEventsPerLifetime,r(n.defaultMaxEventsPerLifetime,100)),perMinute:r(n.maxEventsPerMinute,n.defaultMaxEventsPerMinute)}),this.transport=n.transport({host:n.host,workspaceKey:n.workspaceKey,timeoutMs:n.requestTimeoutMs}),this.queue=new pe({transport:this.transport,envelope:i=>this.envelope(i),logger:this.logger,maxQueueSize:v(n.maxQueueSize,v(n.defaultMaxQueueSize,100)),flushInterval:v(n.flushInterval,1e3),failurePauseMs:n.failurePauseMs,onDisable:()=>this.shutdown("key refused"),gate:this.configGate()})}init(e){return S(this.logger,"init",()=>{if(this.state!=="idle")return;if(!this.options.workspaceKey||typeof this.options.workspaceKey!="string"){this.logger.warn("no workspaceKey"),this.state="disabled";return}if(this.options.enabled===!1){this.state="disabled";return}this.state="active",this.options.maxBreadcrumbs!==void 0&&Ae().breadcrumbs.setMaxItems(v(this.options.maxBreadcrumbs,50)),this.options.user&&Ae().setUser({...this.options.user,...this.options.userHash?{hash:this.options.userHash}:{}}),this.loadRemoteConfig();let n=new Map;for(let r of e)r&&r.name&&n.set(r.name,r);for(let r of n.values())try{r.setup&&r.setup(this),this.integrations.push(r)}catch(i){this.logger.warn(r.name,i)}this.logger.log("started")},void 0),this}isEnabled(){return this.state==="active"&&!this.queue.isDisabled}getIntegration(e){return this.integrations.find(n=>n.name===e)}getSessionId(){return S(this.logger,"session",()=>{let e=this.options.getSessionId;return e&&e()},void 0)}getRemoteConfig(){return this.remote}captureException(e,n,r){let i=ar(e)?new Error:void 0;return this.capture(e,n,r,i,!1)}captureMessage(e,n,r,i){let o=new Error;return this.capture(e,r,i,o,!0,n)}captureEvent(e,n,r){return S(this.logger,"capture",()=>{let i=e&&typeof e.event_id=="string"&&e.event_id||V();if(!this.isEnabled()||!e||typeof e!="object")return i;let o={...this.baseEvent(i,U(e.level)?e.level:"error"),...e,event_id:i};return Array.isArray(o.exception_list)||(o.exception_list=[]),this.process(o,Gt(n),r),i},"")}addBreadcrumb(e,n,r){S(this.logger,"breadcrumb",()=>{if(this.state==="closed"||this.state==="disabled"||!e||typeof e!="object")return;let i={...e,timestamp:e.timestamp||Date.now()};this.options.beforeBreadcrumb&&(i=this.options.beforeBreadcrumb(i,n)),i&&(r||C()).addBreadcrumb(i)},void 0)}hasPending(){return this.pending.length>0||this.inflight.size>0||this.queue.size>0||this.queue.isSending}async flush(e,n=!1){try{let r=Math.max(0,v(e,2e3)),i=Date.now();n&&(this.release(),this.queue.flush(r,!0));let o,a=new Promise(s=>o=setTimeout(s,r));try{!this.remote&&this.state==="active"&&!n&&await Promise.race([this.remoteReady,a]),this.inflight.size&&await Promise.race([Promise.all(this.inflight),a])}finally{clearTimeout(o)}return await this.queue.flush(Math.max(0,r-(Date.now()-i)),n)}catch(r){return this.logger.warn("flush failed",r),!1}}resume(){S(this.logger,"resume",()=>this.queue.resume(),void 0)}async close(e){try{this.teardown();let n=this.state==="active"?await this.flush(e):!0;return this.state="closed",this.queue.disable(),n}catch(n){return this.logger.warn("close failed",n),!1}}capture(e,n,r,i,o,a){try{let s=Gt(n),c=s.syntheticException;if(!o){let m=ee(e)||ee(ht(e));if(m)return m}let u=V();if(!this.isEnabled())return u;o||gt(e,u);let d=mt(o?y(e):e,{type:o?"message":"generic",handled:!0,...s.mechanism},this.buildContext(c||i,c?v(s.syntheticSkip,0):1)),f=this.baseEvent(u,o?U(a)?a:"info":U(s.level)?s.level:"error");return f.exception_list=d.exceptions,o?d.exceptions[0].type="Message":d.serialized!==void 0&&(f.extra={__serialized__:d.serialized}),this.process(f,{...s,originalException:e},r),u}catch(s){return this.logger.warn("capture failed",s),""}}buildContext(e,n){let r=this.options,i;try{i=e&&typeof e.stack=="string"?e.stack:void 0}catch(o){}return{parser:r.stackParser,framePlatform:r.framePlatform,isInApp:r.isInApp,synthetic:i?{stack:i,skip:n}:void 0}}baseEvent(e,n){return{event_id:e,timestamp:Date.now(),platform:this.options.platform,level:n,exception_list:[]}}envelope(e){return{v:1,workspace:this.options.workspaceKey,sdk:{name:this.options.sdkName,version:this.options.sdkVersion||M},sent_at:Date.now(),events:e}}process(e,n,r){let i=this.options;if(!e.release){let c=i.release||at();c&&(e.release=c)}if(i.environment&&!e.environment&&(e.environment=i.environment),!e.session_id){let c=this.getSessionId();c&&(e.session_id=c)}(r||wt()).applyToEvent(e),n.tags&&(e.tags={...e.tags,...n.tags}),n.extra&&(e.extra={...e.extra,...n.extra}),n.contexts&&(e.contexts={...e.contexts,...n.contexts}),n.fingerprint&&(e.fingerprint=y(n.fingerprint));let a=e;for(let c of this.integrations)if(c.processEvent){try{a=c.processEvent(a,n,this)}catch(u){this.logger.warn(c.name,u)}if(!a){this.logger.log("dropped",c.name);return}}let s=this.localFilter(a);if(s){this.logger.log("dropped",s);return}if(!this.remote){this.pending.length<Ft?this.pending.push([a,n]):this.logger.alert("pending",`events dropped: over ${Ft} before the remote config`);return}this.finish(a,n)}localFilter(e){let n=this.options,r=e.exception_list[0],i=n.ignoreErrors||[],o=n.allowUrls||[],a=n.denyUrls||[];if(i.length&&r){let s=r.value||"";if(Y(`${r.type}: ${s}`,i)||Y(s,i))return"ignoreErrors"}if(o.length||a.length){let s=cr(e);if(s&&Y(s,a))return"denyUrls";if(s&&o.length&&!Y(s,o))return"allowUrls"}return null}finish(e,n){let r=this.remote||ge;if(!this.isEnabled()||!r.enabled)return;if(Bt(e,r.suppress))return this.logger.log("dropped","suppress");let i=Math.min(1,Math.max(0,v(this.options.sampleRate,1)))*r.sample_rate;if(i<1&&Math.random()>=i)return this.logger.log("dropped","sample");let o=e.exception_list[0],a=Pt(o&&o.type,o&&o.value,o&&o.stacktrace?o.stacktrace.frames[0]:void 0),s=this.limiter.peek(a);if(s)return this.limitDrop(s,a);let c=f=>{if(!f||typeof f!="object"||!Array.isArray(f.exception_list))return this.logger.log("dropped","beforeSend");if(!this.isEnabled())return;let m=this.limiter.check(a);if(m)return this.limitDrop(m,a);this.queue.add(Wt(f))},u=this.options.beforeSend;if(!u)return c(e);let d;try{d=u(e,n)}catch(f){this.logger.warn("beforeSend",f);return}if(lt(d)){if(this.inflight.size>=$t){this.logger.alert("inflight",`events dropped: ${$t} async beforeSend calls pending`);return}let f,m=Math.max(0,v(this.options.beforeSendTimeoutMs,5e3)),p=new Promise(P=>{f=setTimeout(()=>P(qt),m),N(f)}),g=Promise.race([d,p]).then(P=>{if(clearTimeout(f),P===qt)return this.logger.alert("beforeSend",`event dropped: beforeSend did not settle in ${m} ms`);S(this.logger,"enqueue",()=>c(P),void 0)},P=>{clearTimeout(f),this.logger.warn("beforeSend",P)}),_=()=>this.inflight.delete(g);this.inflight.add(g),g.then(_,_)}else c(d)}limitDrop(e,n){this.logger.log("dropped",e,n);let r=this.drops[e]||(this.drops[e]={at:0,n:0});r.n++;let i=Date.now();r.at&&i-r.at<or||(this.notice(`events dropped by ${ir[e]}: ${r.n} ${r.at?`in ${Math.round((i-r.at)/1e3)} s`:"so far"}${e==="rate limited"?`, latest "${b(n,160)}"`:""}`),r.at=i,r.n=0)}notice(...e){ve(...e)}configGate(){}loadRemoteConfig(){if(this.options.remoteConfig===!1||!this.transport.fetchConfig)return this.applyRemoteConfig(ge);this.remoteReady=this.readConfig(rr,e=>this.applyRemoteConfig(e))}readConfig(e,n){return new Promise(r=>{let i=!1,o=s=>{i||(i=!0,clearTimeout(a),S(this.logger,"config",()=>n(Nt(s)),void 0),r())},a=setTimeout(()=>o(null),e);N(a);try{Promise.resolve(this.transport.fetchConfig()).then(o,s=>{this.logger.warn("config",s),o(null)})}catch(s){this.logger.warn("config",s),o(null)}})}release(){if(this.remote||!this.pending.length)return;let e=this.pending;this.pending=[];for(let[n,r]of e)S(this.logger,"capture",()=>this.finish(n,r),void 0)}applyRemoteConfig(e){this.remote=e;let n=this.pending;if(this.pending=[],!e.enabled){this.logger.log("config: disabled"),this.shutdown("config");return}for(let[r,i]of n)S(this.logger,"capture",()=>this.finish(r,i),void 0)}shutdown(e){this.state==="disabled"||this.state==="closed"||(this.logger.log("off",e),this.state="disabled",this.pending=[],this.queue.disable(),this.teardown())}teardown(){for(let e of this.integrations.splice(0).reverse())try{e.teardown&&e.teardown()}catch(n){this.logger.warn(e.name,n)}}};function Gt(t){try{let e={...t};for(let n of["mechanism","tags","extra","contexts","data"])e[n]&&typeof e[n]=="object"&&(e[n]={...e[n]});return e.syntheticException&&!R(e.syntheticException)&&delete e.syntheticException,e}catch(e){return{}}}function ar(t){try{return!R(t)&&!O(t)}catch(e){return!1}}function cr(t){for(let e of t.exception_list)for(let n of e.stacktrace?e.stacktrace.frames:[])if(n.filename&&!sr.test(n.filename))return n.filename}function ur(t){let e=[t.fingerprint||"",JSON.stringify([t.user,t.session_id])];for(let n of t.exception_list){e.push(n.type,n.value);for(let r of n.stacktrace?n.stacktrace.frames:[])e.push(`${r.filename}|${r.function}|${r.lineno}|${r.colno}`)}return e.join(`
|
|
4
|
+
`)}function zt(t={}){let e,n;return{name:"Dedupe",processEvent(r){let i=ur(r),o=t.requestKey&&t.requestKey();return i===e&&o===n?null:(e=i,n=o,r)},teardown(){e=void 0,n=void 0}}}var Ht=/^(.*?):(\d+)(?::(\d+))?$/;function Kt(t){let e=Ht.exec(t);return e?{filename:e[1]||void 0,lineno:+e[2],colno:e[3]?+e[3]:void 0}:{filename:t||void 0}}function B(t,e){let n={};return e.filename&&(n.filename=e.filename),t&&t!=="<anonymous>"&&t!=="?"&&(n.function=t),e.lineno&&(n.lineno=e.lineno),e.colno&&(n.colno=e.colno),n}var dr=/^\s*at (?:(.+?) \((.+)\)|(.+))\s*$/,fr=/\((\S+?):(\d+):(\d+)\)/,Vt=t=>{let e=dr.exec(t);if(!e)return;let n=e[1],r=(e[2]||e[3]||"").trim();if(!n&&/^async /.test(r)&&(r=r.slice(6)),n&&(n=n.replace(/^async /,"")),/^eval at /.test(r)){let i=fr.exec(r);return i?B(n,{filename:i[1],lineno:+i[2],colno:+i[3]}):B(n,{filename:"<anonymous>"})}return/^data:/.test(r)?B(n,{filename:"<data:"+r.slice(5,r.indexOf(",")>0?r.indexOf(","):40)+">"}):/^index \d+$/.test(r)?B(n,{}):B(n,Kt(r))},lr=/^(.*?) line (\d+)(?: > [A-Za-z]+(?: line \d+)?)* > (?:eval|Function)/,pr=t=>{let e=t.trim();if(!e)return;let n=e.indexOf("@"),r=n>=0?e.slice(0,n):void 0,i=n>=0?e.slice(n+1):e;if(n<0&&!Ht.test(i)&&i!=="[native code]")return;r&&(r=r.replace(/^async\*/,""));let o=lr.exec(i);return o?B(r||"eval",{filename:o[1],lineno:+o[2]}):i==="[native code]"?B(r,{filename:"[native code]"}):B(r,Kt(i))};function Yt(t=Vt,e=pr){return(n,r=0)=>{let i=[];if(typeof n!="string"||!n)return i;let o=n.split(`
|
|
5
|
+
`),a=o.some(s=>/^\s*at /.test(s));for(let s of o){if(i.length>=1e3+r)break;let c=s.replace(/\r$/,"");if(c.length>2048||a&&!/^\s*at /.test(c))continue;let u=(a?t:e)(c);u&&(u.filename||u.function)&&i.push(u)}return i.slice(r)}}var Qt=Yt(),Bi=Yt(Vt,()=>{});var te=t=>t.indexOf(W.INGEST)>=0||t.indexOf(W.CONFIG)>=0;var Jt={warn:"warning",error:"error"},mr=".starko-mask,[data-starko-mask],.starko-no-capture,[data-starko-no-capture]";function gr(t){let e=[],n=t;try{for(let i=0;n&&n.nodeType===1&&i<5;i++){let o=n.tagName.toLowerCase();n.id&&(o+=`#${n.id}`);let a=typeof n.className=="string"?n.className.trim().split(/\s+/).filter(s=>s&&/^[\w-]+$/.test(s)):[];for(let s of a.slice(0,2))o+=`.${s}`;for(let s of["type","name","role","data-testid"]){let c=n.getAttribute(s);c&&(o+=`[${s}="${b(c,30)}"]`)}if(e.unshift(o),n.id)break;n=n.parentElement}}catch(i){}let r=e.join(" > ");return r.length>120?"\u2026"+r.slice(r.length-119):r||"<unknown>"}var hr=t=>!t||t>=500?"error":t>=400?"warning":void 0;function Zt(t){if(!t)return t;try{let e=new URL(t,location.href);return e.origin===location.origin?e.pathname+e.search+e.hash:e.href}catch(e){return t}}function en(t={}){let e=[];return{name:"Breadcrumbs",setup(n){if(typeof window=="undefined")return;let r=!1,i=a=>{if(!r){r=!0;try{n.addBreadcrumb(a)}catch(s){}finally{r=!1}}},o=(a,s,c,u,d)=>i({timestamp:Date.now(),type:"http",category:a,level:d!==void 0?"error":hr(u),data:{method:s,url:b(c,2048),...d!==void 0?{error:b(y(d instanceof Error?d.message:d),200)}:{status_code:u}}});if(t.console!==!1&&typeof console!="undefined")for(let a of Object.keys(Jt))e.push(T(console,a,(s,c)=>{if(c[0]===F)return;let u=c.map(d=>typeof d=="string"?d:k(Z(d,2))).join(" ");i({timestamp:Date.now(),type:"console",category:"console",level:Jt[a],message:b(u,200)})}));if(t.dom!==!1&&typeof document!="undefined"){let a=s=>{try{let c=s.target;if(c&&typeof c.closest=="function"&&c.closest(mr))return;i({timestamp:Date.now(),type:"ui",category:"click",message:gr(c)})}catch(c){}};document.addEventListener("click",a,{capture:!0,passive:!0}),e.push(()=>document.removeEventListener("click",a,{capture:!0}))}if(t.fetch!==!1&&e.push(T(window,"fetch",(a,s)=>{let c=s[0],u=s[1],d=typeof c=="string"?c:c instanceof URL?c.href:String(c&&c.url||""),f=String(u&&u.method||(c&&typeof c=="object"&&"method"in c?c.method:"GET")).toUpperCase();if(!te(d))return m=>{let p=m;p&&typeof p.then=="function"&&p.then(g=>o("fetch",f,d,g.status),g=>o("fetch",f,d,0,g))}})),t.xhr!==!1&&typeof XMLHttpRequest=="function"){let a=XMLHttpRequest.prototype,s=new WeakMap;e.push(T(a,"open",(c,u)=>{s.set(c,[String(u[0]).toUpperCase(),String(u[1])])}),T(a,"send",c=>{let u=s.get(c);if(!u||te(u[1]))return;let d=c;d.addEventListener("loadend",()=>o("xhr",u[0],u[1],d.status))}))}if(t.history!==!1&&typeof history!="undefined"&&typeof location!="undefined"){let a=location.href,s=u=>{try{let d=u===void 0?location.href:new URL(String(u),location.href).href;if(d===a)return;i({timestamp:Date.now(),type:"navigation",category:"navigation",data:{from:Zt(a),to:Zt(d)}}),a=d}catch(d){}};for(let u of["pushState","replaceState"])e.push(T(history,u,(d,f)=>f[2]!=null?()=>s(f[2]):void 0));let c=()=>s(void 0);window.addEventListener("popstate",c),e.push(()=>window.removeEventListener("popstate",c))}},teardown(){for(let n of e.splice(0))try{n()}catch(r){}}}}function tn(t={}){let e=[],n={name:"GlobalHandlers",captures:!1,setup(r){if(typeof window=="undefined"||typeof window.addEventListener!="function")return;let i=(o,a)=>{let s=c=>{try{a(c)}catch(u){r.logger.warn(`${o} handler failed`,u)}};window.addEventListener(o,s),e.push(()=>window.removeEventListener(o,s))};t.onerror!==!1&&(i("error",o=>{let a=o;typeof a.message!="string"&&a.error==null||r.captureException(a,{mechanism:{type:"onerror",handled:!1},data:{event:a}})}),n.captures=!0),t.onunhandledrejection!==!1&&i("unhandledrejection",o=>{r.captureException(o,{mechanism:{type:"onunhandledrejection",handled:!1},data:{event:o}})})},teardown(){n.captures=!1;for(let r of e.splice(0))r();Ne()}};return n}function nn(){return{name:"HttpContext",processEvent(t){if(typeof location=="undefined")return t;let e={...t.request};!e.url&&location.href&&(e.url=location.href);try{!e.referrer&&typeof document!="undefined"&&document.referrer&&(e.referrer=document.referrer)}catch(n){}return t.request=e,t}}}var be="x-starko-session-id";function rn(){let t=[];return{name:"SessionPropagation",setup(e){if(typeof window=="undefined"||typeof location=="undefined")return;let n=o=>{let a=new URL(String(o),typeof document!="undefined"&&document.baseURI||location.href);return a.origin===location.origin&&!te(a.href)&&e.isEnabled()&&e.getSessionId()||""};if(t.push(T(window,"fetch",(o,a)=>{let s=a[0],c=a[1],u=typeof Request=="function"&&s instanceof Request?s:void 0,d=n(u?u.url:s),f=d&&new Headers(c&&c.headers||u&&u.headers);f&&!f.has(be)&&(f.set(be,d),a[1]={...c,headers:f})})),typeof XMLHttpRequest!="function")return;let r=new WeakMap,i=XMLHttpRequest.prototype;t.push(T(i,"open",(o,a)=>{r.delete(o),r.set(o,n(a[1]))}),T(i,"send",o=>{let a=r.get(o);a&&o.setRequestHeader(be,a)}))},teardown(){for(let e of t.splice(0))e()}}}var on="starko:errors:session",H;function sn(){if(H)return H;try{let t=sessionStorage.getItem(on);if(t&&X.test(t))return H=t}catch(t){}H=V();try{sessionStorage.setItem(on,H)}catch(t){}return H}var an=60*1024,yr=12e3;function cn(){try{let t=re(globalThis,"fetch");return typeof t=="function"?t.bind(globalThis):void 0}catch(t){return}}var br=cn();function Er(t,e=Date.now()){if(!t)return;let n=Number(t);if(!isNaN(n))return Math.max(0,n);let r=Date.parse(t);return isNaN(r)?void 0:Math.max(0,Math.ceil((r-e)/1e3))}function kr(t){let e=n=>n===401||n===403?6:n===413?5:n===429?4:n===0||n>=500?3:n>=400?2:1;return t.reduce((n,r)=>e(r.status)>e(n.status)?r:n,{status:200})}function wr(t,e){let n=w(k({...t,events:[]})),r=[],i={...t,events:[]},o=n;for(let a of t.events){let s=w(k(a))+1;i.events.length&&o+s>e&&(r.push({env:i,bytes:o}),i={...t,events:[]},o=n),i.events.push(a),o+=s}return i.events.length&&r.push({env:i,bytes:o}),r}function un(t){let e=t.host.replace(/\/+$/,""),n=Math.max(1,v(t.timeoutMs,yr)),r=()=>t.fetchImpl||br||cn(),i=0,o=(s,c)=>{let u=r();if(!u)return Promise.resolve(s);let d;try{d=new AbortController}catch(g){}let f,m;try{m=c(u,d&&d.signal).catch(()=>s)}catch(g){m=Promise.resolve(s)}let p=new Promise(g=>{f=setTimeout(()=>{try{d&&d.abort()}catch(_){}g(s)},n),N(f)});return Promise.race([m,p]).then(g=>(clearTimeout(f),g))},a=(s,c)=>o({status:0},async(u,d)=>{var p,g;let f=await u(e+W.INGEST,{method:"POST",body:s,headers:{"Content-Type":"text/plain;charset=UTF-8"},keepalive:c,credentials:"omit",redirect:"manual",signal:d}),m={status:f.type==="opaqueredirect"?302:f.status};try{m.retryAfter=Er(f.headers.get("Retry-After"))}catch(_){}if(m.status>=400)try{let _=(g=(p=await f.json())==null?void 0:p.data)==null?void 0:g.reason;typeof _=="string"&&(m.reason=_)}catch(_){}return m});return{async send(s,c={}){if(!c||!c.keepalive)return a(k(s),!1);let u=await Promise.all(wr(s,an).map(({env:d,bytes:f})=>{let m=i+f<=an;return m&&(i+=f),a(k({...d,sent_at:Date.now()}),m).then(p=>(m&&(i-=f),p))}));return kr(u)},fetchConfig(){return o(null,async(s,c)=>{let u=await s(`${e}${W.CONFIG}?workspace=${encodeURIComponent(t.workspaceKey)}`,{method:"GET",credentials:"omit",redirect:"manual",signal:c});if(u.type==="opaqueredirect"||u.status>=300&&u.status<400)return null;let d=await u.json(),f=d&&typeof d=="object"?d.data:null;return f&&typeof f=="object"?f:null})}}}function xr(){return[Ct(),zt(),tn(),en(),nn(),Rt(),rn(),le({whenWidget:!0})]}var Sr=/^(?:<anonymous>|\[native code\]|native|<data:.*|(?:chrome|moz|safari|safari-web|ms-browser)-extension:.*)$/i;function vr(t){return!t||Sr.test(t)||/\/node_modules\//.test(t)?!1:void 0}function _r(){let t=[];return{name:"FlushOnHide",setup(e){if(typeof window=="undefined"||typeof document=="undefined")return;let n=a=>()=>{try{a()}catch(s){}},r=n(()=>{e.flush(2e3,!0)}),i=n(()=>document.visibilityState==="hidden"&&r()),o=n(()=>e.resume());window.addEventListener("pagehide",r),window.addEventListener("online",o),document.addEventListener("visibilitychange",i),t.push(()=>window.removeEventListener("pagehide",r),()=>window.removeEventListener("online",o),()=>document.removeEventListener("visibilitychange",i))},teardown(){for(let e of t.splice(0))e()}}}function Ue(t){try{let e=E();e&&e.close(0);let n=t.defaultIntegrations===!1?[]:Array.isArray(t.defaultIntegrations)?t.defaultIntegrations:xr(),r;typeof t.integrations=="function"?r=t.integrations(n):r=[...n,...t.integrations||[]],r.some(a=>a&&a.name==="FlushOnHide")||r.push(_r());let i,o=()=>!!i.getIntegration("WidgetBridge");return i=new ye({...t,platform:"browser",framePlatform:"web:javascript",sdkName:"starko.browser",stackParser:Qt,isInApp:vr,getSessionId:()=>o()&&Tt()||sn(),defaultMaxEventsPerLifetime:100,transport:t.transport||un}),Et(i),i.init(r),i}catch(e){try{t&&t.debug&&console.warn("[starko] init failed",e)}catch(n){}return}}var dn=()=>{let t=E();return t&&t.logger},Tr=(t,e)=>{let n=dn();n&&n.warn(t,e)},A=(t,e)=>S(dn(),"API call",t,e),fn=t=>S(void 0,"",()=>t&&typeof t=="object"?{...t}:{},{});function Xe(t,e){let n;try{!(e&&e.syntheticException)&&!R(t)&&!O(t)&&(n=new Error)}catch(r){}return A(()=>{let r=G(E(),"captureException");if(!r)return"";let i=fn(e);return r(t,n?{...i,syntheticException:n,syntheticSkip:1}:i)},"")}function We(t,e){let n=new Error;return A(()=>{let r=G(E(),"captureMessage");if(!r)return"";let i=fn(e),o=typeof e=="string"?e:i.level||"info";return r(y(t),o,{...i,syntheticException:n,syntheticSkip:1})},"")}function Fe(t){A(()=>{let e=t&&typeof t=="object"?t:null,n=Ie(e);n&&n.setUser(e)},void 0)}function $e(t,e){A(()=>{let n=typeof t=="string"?{id:t}:{...t};e&&(n.hash=e);let r=Ie(n);r&&r.setUser(n)},void 0)}function qe(t,e){A(()=>{C().setTag(t,e)},void 0)}function Ge(t){A(()=>{C().setTags(t)},void 0)}function ze(t,e){A(()=>{C().setExtra(t,e)},void 0)}function He(t){A(()=>{C().setExtras(t)},void 0)}function Ke(t,e){A(()=>{C().setContext(t,e)},void 0)}function Ve(t,e){A(()=>{let n={timestamp:Date.now(),type:"custom",...t},r=G(E(),"addBreadcrumb");r?r(n,e):C().addBreadcrumb(n)},void 0)}function Ye(t){if(typeof t!="function")return;let e=!1;try{return kt(n=>(e=!0,t(n)))}catch(n){if(e)throw n;return Tr("withScope failed",n),t(C())}}function Qe(t){return A(()=>{let e=E(),n=G(e,"flush");return n?n(t):Promise.resolve(!e)},Promise.resolve(!1))}function Je(t){return A(()=>{let e=E(),n=G(e,"close");return n?n(t):Promise.resolve(!e)},Promise.resolve(!1))}function Rr(){let t=e=>document.querySelector(`script[data-workspace-key]${e}`);return document.currentScript||t('[src*="starko" i]')||t("")}(()=>{try{if(typeof document=="undefined")return;let t=Rr();if(!t)return;Ot(t.src);let e=t.getAttribute("data-workspace-key");if(!e)return;Ue({workspaceKey:e,release:t.getAttribute("data-release")||void 0,environment:t.getAttribute("data-environment")||void 0,host:t.getAttribute("data-host")||void 0,debug:t.hasAttribute("data-debug")})}catch(t){}})();return bn(Ar);})();
|
|
6
|
+
try{globalThis.Starko===void 0&&(globalThis.Starko=Starko)}catch(e){}
|
package/docs/browser.md
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# Browser
|
|
2
|
+
|
|
3
|
+
Error tracking for any web page, with or without a framework. For React see
|
|
4
|
+
also [react.md](./react.md); for Next.js use [nextjs.md](./nextjs.md) instead
|
|
5
|
+
of this page.
|
|
6
|
+
|
|
7
|
+
## Install with npm
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @starko-one/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
15
|
+
|
|
16
|
+
Starko.init({
|
|
17
|
+
workspaceKey: "<STARKO_WORKSPACE_KEY>",
|
|
18
|
+
release: "shop@4.12.0",
|
|
19
|
+
environment: "production",
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Call `init` once, in your entry file, before the rest of your app runs:
|
|
24
|
+
errors thrown before `init` are not captured. Calling `init` again replaces
|
|
25
|
+
the previous client. `init` never throws; it returns the client, or
|
|
26
|
+
`undefined` when it could not start.
|
|
27
|
+
|
|
28
|
+
The workspace key is the workspace id shown in Starko under Settings. It is
|
|
29
|
+
public: it only lets a page send errors. Never put a secret key
|
|
30
|
+
(`sk_starko_…`) in browser code.
|
|
31
|
+
|
|
32
|
+
Use as `release` the release your source maps were uploaded for. If you
|
|
33
|
+
use one of the build plugins, you can leave it out: the plugin writes the
|
|
34
|
+
release it uploaded for into your bundles and `init` uses it (it is read
|
|
35
|
+
for each event, so `init` may run before those bundles load). See
|
|
36
|
+
[source-maps.md](./source-maps.md).
|
|
37
|
+
|
|
38
|
+
## Install with a script tag
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script
|
|
42
|
+
src="https://cdn.jsdelivr.net/npm/@starko-one/sdk@0.1.0-beta.0/dist/starko.min.js"
|
|
43
|
+
data-workspace-key="<STARKO_WORKSPACE_KEY>"
|
|
44
|
+
data-release="shop@4.12.0"
|
|
45
|
+
data-environment="production"
|
|
46
|
+
></script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Always pin the exact version in the URL. An unpinned URL changes under you
|
|
50
|
+
when a new version is published. The bundle is 53 kB minified, 19.04 kB
|
|
51
|
+
gzipped.
|
|
52
|
+
|
|
53
|
+
The tag works as a classic script, with `defer` or `async`, and as
|
|
54
|
+
`<script type="module">`; in a module the bundle finds its tag by the
|
|
55
|
+
`data-workspace-key` attribute. A classic script defines `window.Starko`;
|
|
56
|
+
a module sets it unless the page already has a `Starko` global. With
|
|
57
|
+
`defer`, `async` or `type="module"`, the bundle runs after inline scripts
|
|
58
|
+
that follow the tag, so start it with the attributes, or call `init` from a
|
|
59
|
+
script of the same kind placed after the tag (`defer` and module scripts
|
|
60
|
+
run in document order; `async` ones do not).
|
|
61
|
+
|
|
62
|
+
With `data-workspace-key` on the tag, the bundle starts itself. The other
|
|
63
|
+
attributes it reads:
|
|
64
|
+
|
|
65
|
+
| Attribute | Option |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `data-workspace-key` | `workspaceKey`. Without it the bundle does not start; call `Starko.init` yourself. |
|
|
68
|
+
| `data-release` | `release` |
|
|
69
|
+
| `data-environment` | `environment` |
|
|
70
|
+
| `data-host` | `host` (default `https://v2.starko.one`) |
|
|
71
|
+
| `data-debug` | `debug: true` when the attribute is present |
|
|
72
|
+
|
|
73
|
+
For any other option, leave `data-workspace-key` off and call `init` from your
|
|
74
|
+
own script after the tag:
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/npm/@starko-one/sdk@0.1.0-beta.0/dist/starko.min.js"></script>
|
|
78
|
+
<script>
|
|
79
|
+
window.Starko.init({
|
|
80
|
+
workspaceKey: "<STARKO_WORKSPACE_KEY>",
|
|
81
|
+
release: "shop@4.12.0",
|
|
82
|
+
sampleRate: 0.5,
|
|
83
|
+
});
|
|
84
|
+
</script>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The bundle exposes `window.Starko` with `init`, `captureException`,
|
|
88
|
+
`captureMessage`, `setUser`, `identify`, `setTag`, `setTags`, `setExtra`,
|
|
89
|
+
`setExtras`, `setContext`, `addBreadcrumb`, `withScope`, `flush`, `close`,
|
|
90
|
+
`getClient`, `SDK_VERSION` and `consoleErrorCaptureIntegration`. The other
|
|
91
|
+
integration factories are only in the npm package. Errors raised entirely
|
|
92
|
+
inside the bundle itself are never reported.
|
|
93
|
+
|
|
94
|
+
## Identify the user
|
|
95
|
+
|
|
96
|
+
An error is linked to a customer in Starko only when the link is verified.
|
|
97
|
+
Send the user with a **user hash**: an HMAC-SHA256, in hex, of the user's id
|
|
98
|
+
(or of their email when you have no id), computed on **your backend** with
|
|
99
|
+
your workspace's identity secret. It is the same hash the Starko widget's
|
|
100
|
+
`identify` takes.
|
|
101
|
+
|
|
102
|
+
On your server (Node shown; any language with HMAC-SHA256 works):
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import { createHmac } from "node:crypto";
|
|
106
|
+
|
|
107
|
+
// Never run this in the browser: the identity secret must stay on your server.
|
|
108
|
+
// STARKO_IDENTITY_SECRET is an environment variable of your own holding it.
|
|
109
|
+
export function starkoUserHash(userId) {
|
|
110
|
+
return createHmac("sha256", process.env.STARKO_IDENTITY_SECRET).update(userId).digest("hex");
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Hand the hash to the page with the signed-in user (in your session payload,
|
|
115
|
+
say), then:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
119
|
+
|
|
120
|
+
export function onSignIn(user: { id: string; email: string; name: string }, starkoUserHash: string) {
|
|
121
|
+
Starko.identify({ id: user.id, email: user.email, name: user.name }, starkoUserHash);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function onSignOut() {
|
|
125
|
+
Starko.setUser(null);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- `identify(user, userHash)` sets the user and the hash. `identify("user_123", hash)` takes the id alone.
|
|
130
|
+
- `setUser({ id, email, name })` sets a user without a hash.
|
|
131
|
+
- `init({ user, userHash })` sets them at start.
|
|
132
|
+
- A user without a valid hash is kept on the error as text (the id and email
|
|
133
|
+
you sent) and is never linked to a customer, never counted as an affected
|
|
134
|
+
customer and never attached to a ticket: anyone can put any id in a
|
|
135
|
+
browser request, so an unverified id cannot be trusted.
|
|
136
|
+
- When the Starko widget is on the page, the SDK also sends the widget's own
|
|
137
|
+
token, which links the error to the widget's customer without a hash.
|
|
138
|
+
The token is checked first. When the widget's customer was identified
|
|
139
|
+
without verification (an email typed into the widget, for example), the
|
|
140
|
+
error is still linked to them and Starko labels the link "unverified"; a
|
|
141
|
+
valid hash you sent with `identify` links your user as verified instead.
|
|
142
|
+
See [widget.md](./widget.md).
|
|
143
|
+
- The hash is a credential. The SDK never logs it and the server does not store it.
|
|
144
|
+
|
|
145
|
+
## Capture errors yourself
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
149
|
+
|
|
150
|
+
async function checkout(cartId: string) {
|
|
151
|
+
try {
|
|
152
|
+
await fetch(`/api/checkout/${cartId}`, { method: "POST" });
|
|
153
|
+
} catch (error) {
|
|
154
|
+
const eventId = Starko.captureException(error, {
|
|
155
|
+
tags: { area: "checkout" },
|
|
156
|
+
extra: { cartId },
|
|
157
|
+
});
|
|
158
|
+
console.log("reported as", eventId);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Starko.captureMessage("Payment provider fell back to redirect flow", "warning");
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- `captureException(value, hint?)` takes anything thrown (an `Error`, a
|
|
166
|
+
string, an object) and returns the event id (`""` before `init`). The hint
|
|
167
|
+
may set `tags`, `extra`, `contexts`, `fingerprint` (events with the same
|
|
168
|
+
fingerprint become one issue) and `level`. Captured errors are recorded as
|
|
169
|
+
handled.
|
|
170
|
+
- `captureMessage(message, level?)` reports a message with the caller's
|
|
171
|
+
stack. The level defaults to `"info"`. Only `error` and `fatal` events can
|
|
172
|
+
file a ticket.
|
|
173
|
+
- The same error object is reported once, even if it is captured again or
|
|
174
|
+
later reaches the global handler.
|
|
175
|
+
|
|
176
|
+
Data for every later event:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
180
|
+
|
|
181
|
+
Starko.setTag("plan", "pro");
|
|
182
|
+
Starko.setTags({ region: "eu", tenant: "acme" });
|
|
183
|
+
Starko.setExtra("featureFlags", { newCheckout: true });
|
|
184
|
+
Starko.setContext("cart", { items: 3, currency: "EUR" });
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Data for one capture only:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
191
|
+
|
|
192
|
+
function reportImportFailure(error: unknown, fileName: string) {
|
|
193
|
+
Starko.withScope((scope) => {
|
|
194
|
+
scope.setTag("feature", "import");
|
|
195
|
+
scope.setExtra("fileName", fileName);
|
|
196
|
+
Starko.captureException(error);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Breadcrumbs
|
|
202
|
+
|
|
203
|
+
Breadcrumbs are what happened before the error. Recorded automatically:
|
|
204
|
+
|
|
205
|
+
| Kind | What is recorded |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| Clicks | A short CSS-like path of the element (`form#login > button.primary`), never its text or an input's value. Nothing inside elements with `starko-mask` / `starko-no-capture` classes or `data-starko-mask` / `data-starko-no-capture` attributes. |
|
|
208
|
+
| Navigation | `pushState`, `replaceState` and back/forward: from and to (path only when same-origin). |
|
|
209
|
+
| `fetch` and XHR | Method, URL and status code. Never bodies, cookies or headers. Requests to Starko are not recorded. |
|
|
210
|
+
| Console | `console.warn` and `console.error` only, as text cut to 200 characters. |
|
|
211
|
+
|
|
212
|
+
At most 50 breadcrumbs are kept (`maxBreadcrumbs`), and at most 32 KiB of
|
|
213
|
+
them are sent with an event.
|
|
214
|
+
|
|
215
|
+
Add your own, edit or drop any of them:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
219
|
+
|
|
220
|
+
Starko.init({
|
|
221
|
+
workspaceKey: "<STARKO_WORKSPACE_KEY>",
|
|
222
|
+
beforeBreadcrumb(breadcrumb) {
|
|
223
|
+
if (breadcrumb.category === "console" && breadcrumb.message?.includes("[analytics]")) return null;
|
|
224
|
+
return breadcrumb;
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
Starko.addBreadcrumb({ category: "cart", message: "Coupon applied", data: { code: "SPRING" } });
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
To turn off one kind, replace the default `Breadcrumbs` integration (an
|
|
232
|
+
integration with the same name as a default replaces it):
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
236
|
+
import { breadcrumbsIntegration } from "@starko-one/sdk/browser";
|
|
237
|
+
|
|
238
|
+
Starko.init({
|
|
239
|
+
workspaceKey: "<STARKO_WORKSPACE_KEY>",
|
|
240
|
+
integrations: [breadcrumbsIntegration({ console: false, dom: true, fetch: true, xhr: true, history: true })],
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## `beforeSend`
|
|
245
|
+
|
|
246
|
+
The last step before an event is queued. Return the event (changed or not),
|
|
247
|
+
or `null` to drop it. It may be `async`.
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
251
|
+
|
|
252
|
+
Starko.init({
|
|
253
|
+
workspaceKey: "<STARKO_WORKSPACE_KEY>",
|
|
254
|
+
beforeSend(event) {
|
|
255
|
+
if (event.request?.url?.includes("/admin/")) return null;
|
|
256
|
+
if (event.user) delete event.user.email;
|
|
257
|
+
return event;
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
- It runs after filtering, sampling and the rate limits, so it is not called
|
|
263
|
+
for events that would be dropped anyway.
|
|
264
|
+
- If it throws, the event is dropped (it may have been the step that removes
|
|
265
|
+
personal data). An async `beforeSend` that has not settled after
|
|
266
|
+
`beforeSendTimeoutMs` (default 5000 ms) is abandoned and its event dropped.
|
|
267
|
+
- The URL redaction described in [privacy.md](./privacy.md) runs after
|
|
268
|
+
`beforeSend`, so the event you see still has the raw URLs.
|
|
269
|
+
|
|
270
|
+
## Filter noise
|
|
271
|
+
|
|
272
|
+
Dropped before anything is sent, with no setting needed:
|
|
273
|
+
|
|
274
|
+
- an error with no message and no stack;
|
|
275
|
+
- a cross-origin `Script error.` without a stack (an error in a script from
|
|
276
|
+
another origin loaded without `crossorigin`; the browser hides its details);
|
|
277
|
+
- an error with a browser extension in its top three frames;
|
|
278
|
+
- `ResizeObserver loop …` errors;
|
|
279
|
+
- aborted requests (`AbortError`, "The operation was aborted", …);
|
|
280
|
+
- plain network failures (`Failed to fetch`, `Load failed`, `NetworkError …`
|
|
281
|
+
without a stack);
|
|
282
|
+
- errors raised entirely inside Starko's own scripts (widget, recorder, this SDK);
|
|
283
|
+
- the same error twice in a row (same type, message, frames, fingerprint,
|
|
284
|
+
user and session).
|
|
285
|
+
|
|
286
|
+
Your own rules:
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
290
|
+
|
|
291
|
+
Starko.init({
|
|
292
|
+
workspaceKey: "<STARKO_WORKSPACE_KEY>",
|
|
293
|
+
ignoreErrors: ["Non-critical widget timeout", /^ChunkLoadError/],
|
|
294
|
+
allowUrls: [/^https:\/\/shop\.example\.com\//],
|
|
295
|
+
denyUrls: [/\/vendor\/legacy-chat\.js/],
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
- `ignoreErrors` matches `Type: message` and `message`: a string matches
|
|
300
|
+
anywhere in it, a `RegExp` is tested against it.
|
|
301
|
+
- `allowUrls` / `denyUrls` match the file of the most recent stack frame that
|
|
302
|
+
has a file. An event without such a frame passes both.
|
|
303
|
+
- Rules set for the workspace in Starko (the remote config, below) drop
|
|
304
|
+
matching events too.
|
|
305
|
+
|
|
306
|
+
The built-in filters are the `InboundFilters` integration; removing it (see
|
|
307
|
+
[configuration.md](./configuration.md#adding-and-removing-integrations))
|
|
308
|
+
turns all of them off.
|
|
309
|
+
|
|
310
|
+
## Sampling and limits
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
314
|
+
|
|
315
|
+
Starko.init({ workspaceKey: "<STARKO_WORKSPACE_KEY>", sampleRate: 0.25 });
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
`sampleRate` (0 to 1, default 1) is the share of events sent. The workspace's
|
|
319
|
+
remote sample rate multiplies it. Limits that always apply in a browser:
|
|
320
|
+
|
|
321
|
+
- per error: 10 at once, then 1 every 10 seconds. An error here is its
|
|
322
|
+
type and the first 120 characters of its message, with numbers, UUIDs
|
|
323
|
+
and long hex ids masked (`Order 1234 not found` and `Order 98 not found`
|
|
324
|
+
count as one); without a message, its type and the file and line it was
|
|
325
|
+
thrown from;
|
|
326
|
+
- 100 events per page load (`maxEventsPerLifetime`);
|
|
327
|
+
- 100 events waiting in memory (`maxQueueSize`); the oldest are dropped first.
|
|
328
|
+
|
|
329
|
+
Drops by the first two limits are logged to the console even without
|
|
330
|
+
`debug`, at most once a minute per limit, with the number dropped since the
|
|
331
|
+
previous line; a full queue is logged once.
|
|
332
|
+
|
|
333
|
+
## Remote config
|
|
334
|
+
|
|
335
|
+
At `init` the SDK reads the workspace's settings from Starko
|
|
336
|
+
(`GET /api/v1/ingest/config`): whether error tracking is on, a sample rate
|
|
337
|
+
and suppression rules. Until the answer arrives (at most 10 seconds), up to
|
|
338
|
+
30 events are held; they are then sent or dropped by what it says. If error
|
|
339
|
+
tracking is off for the workspace, the SDK removes its hooks and sends
|
|
340
|
+
nothing. If the request fails, the SDK runs with the defaults (on, sample
|
|
341
|
+
rate 1, no rules).
|
|
342
|
+
|
|
343
|
+
`remoteConfig: false` skips the request; the workspace's on/off switch is
|
|
344
|
+
then only learned from the ingest API's answer to the first batch.
|
|
345
|
+
|
|
346
|
+
## Offline, and when the page is hidden
|
|
347
|
+
|
|
348
|
+
- Events are sent in batches of up to 20, one second after the first one
|
|
349
|
+
(`flushInterval`).
|
|
350
|
+
- A request that has not answered after 12 seconds (`requestTimeoutMs`) is
|
|
351
|
+
aborted and counts as a network failure.
|
|
352
|
+
- A failed batch is retried with back-off (waiting at least `Retry-After`
|
|
353
|
+
when the answer has one), at most three attempts. After
|
|
354
|
+
three batches in a row are given up, sending pauses for five minutes, and
|
|
355
|
+
resumes earlier when the browser fires `online`. Events captured while
|
|
356
|
+
offline wait in the queue (at most 100).
|
|
357
|
+
- When the page is hidden or unloaded (`visibilitychange` to hidden,
|
|
358
|
+
`pagehide`), the queue is sent at once with `keepalive`, so it can outlive
|
|
359
|
+
the page. Browsers allow 64 KiB of `keepalive` bodies in flight; a request
|
|
360
|
+
beyond that is sent without `keepalive` and may be cut off if the page is
|
|
361
|
+
really closing.
|
|
362
|
+
- Redirects are never followed. If your `host` redirects (`http://` to
|
|
363
|
+
`https://`, an apex domain), the batch is dropped and the console names the
|
|
364
|
+
redirect target, even without `debug`. Set `host` to the final address.
|
|
365
|
+
|
|
366
|
+
## Stop or flush
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
import * as Starko from "@starko-one/sdk/browser";
|
|
370
|
+
|
|
371
|
+
async function signOutEverywhere() {
|
|
372
|
+
await Starko.flush(2000); // true when everything queued went out within 2 s
|
|
373
|
+
await Starko.close(); // flush, then remove every hook; nothing is sent afterwards
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## See also
|
|
378
|
+
|
|
379
|
+
- [configuration.md](./configuration.md): every option and its default.
|
|
380
|
+
- [privacy.md](./privacy.md): what is collected and how to collect less.
|
|
381
|
+
- [troubleshooting.md](./troubleshooting.md).
|