@utk09/ui-observability 0.9.3 → 0.9.4
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 +45 -0
- package/README.md +108 -33
- package/dist/{batch-D5qvsMQ_.cjs → batch-C4oF6XZT.cjs} +2 -2
- package/dist/{batch-D5qvsMQ_.cjs.map → batch-C4oF6XZT.cjs.map} +1 -1
- package/dist/{batch-DDgxg16_.js → batch-D-4xl7op.js} +4 -4
- package/dist/{batch-DDgxg16_.js.map → batch-D-4xl7op.js.map} +1 -1
- package/dist/{bus-C6RwKzPW.js → bus-Cyvq-Ngx.js} +5 -5
- package/dist/{bus-C6RwKzPW.js.map → bus-Cyvq-Ngx.js.map} +1 -1
- package/dist/{bus-WPVDFw2y.cjs → bus-rOhVuRee.cjs} +2 -2
- package/dist/{bus-WPVDFw2y.cjs.map → bus-rOhVuRee.cjs.map} +1 -1
- package/dist/capture/network.d.ts +1 -0
- package/dist/capture/types.d.ts +3 -0
- package/dist/capture/web-socket.d.ts +40 -0
- package/dist/{console-Dv5GfaNn.js → console-BT7mcgU6.js} +3 -3
- package/dist/{console-Dv5GfaNn.js.map → console-BT7mcgU6.js.map} +1 -1
- package/dist/{console-BSusX_M-.cjs → console-Boqa7new.cjs} +2 -2
- package/dist/{console-BSusX_M-.cjs.map → console-Boqa7new.cjs.map} +1 -1
- package/dist/constants-BgRS6MB0.cjs +2 -0
- package/dist/constants-BgRS6MB0.cjs.map +1 -0
- package/dist/constants-L_d5YvvQ.js +160 -0
- package/dist/constants-L_d5YvvQ.js.map +1 -0
- package/dist/constants.d.ts +34 -2
- package/dist/core/breadcrumbs.d.ts +3 -1
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/journey.d.ts +7 -0
- package/dist/core/meter.d.ts +19 -1
- package/dist/core/pipeline.d.ts +12 -4
- package/dist/core/record.d.ts +40 -8
- package/dist/core/remote-sampling.d.ts +7 -3
- package/dist/core/runtime.d.ts +62 -3
- package/dist/core/sampling.d.ts +32 -1
- package/dist/core/sender.d.ts +8 -0
- package/dist/core/spans.d.ts +34 -0
- package/dist/{errors-DCZWcHkd.js → errors-BDI96zKc.js} +6 -6
- package/dist/errors-BDI96zKc.js.map +1 -0
- package/dist/errors-_xEsCVXn.cjs +3 -0
- package/dist/errors-_xEsCVXn.cjs.map +1 -0
- package/dist/identity-Bwku7zzN.cjs +2 -0
- package/dist/identity-Bwku7zzN.cjs.map +1 -0
- package/dist/{identity-Di-QXGCC.js → identity-Dtv917nz.js} +33 -23
- package/dist/identity-Dtv917nz.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +803 -524
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-DX18p39D.cjs → indexeddb-storage-Cvavrf-y.cjs} +2 -2
- package/dist/{indexeddb-storage-DX18p39D.cjs.map → indexeddb-storage-Cvavrf-y.cjs.map} +1 -1
- package/dist/{indexeddb-storage-T9YIYVYC.js → indexeddb-storage-HgkQUTyS.js} +26 -26
- package/dist/{indexeddb-storage-T9YIYVYC.js.map → indexeddb-storage-HgkQUTyS.js.map} +1 -1
- package/dist/{interactions-_hfOerfC.cjs → interactions-Bhe1ft8P.cjs} +2 -2
- package/dist/interactions-Bhe1ft8P.cjs.map +1 -0
- package/dist/{interactions-BLH_tX87.js → interactions-Ck01cEij.js} +3 -3
- package/dist/interactions-Ck01cEij.js.map +1 -0
- package/dist/journey-Co9OlzrW.cjs +2 -0
- package/dist/journey-Co9OlzrW.cjs.map +1 -0
- package/dist/{journey-yALMEWF7.js → journey-DRK0A8u_.js} +37 -34
- package/dist/journey-DRK0A8u_.js.map +1 -0
- package/dist/{library-request-CQD4HUiP.js → library-request-ChCar5F8.js} +3 -3
- package/dist/{library-request-CQD4HUiP.js.map → library-request-ChCar5F8.js.map} +1 -1
- package/dist/{library-request-BcAxuwsf.cjs → library-request-gMFOCNcn.cjs} +2 -2
- package/dist/{library-request-BcAxuwsf.cjs.map → library-request-gMFOCNcn.cjs.map} +1 -1
- package/dist/log-record-cwFiLyPY.js +17 -0
- package/dist/log-record-cwFiLyPY.js.map +1 -0
- package/dist/log-record-jX9eWUP8.cjs +2 -0
- package/dist/log-record-jX9eWUP8.cjs.map +1 -0
- package/dist/{long-frames-D4Bm3Zkz.cjs → long-frames-Bky6nZDF.cjs} +2 -2
- package/dist/long-frames-Bky6nZDF.cjs.map +1 -0
- package/dist/{long-frames-DD_Um9_4.js → long-frames-DDumopji.js} +4 -4
- package/dist/long-frames-DDumopji.js.map +1 -0
- package/dist/models/config.d.ts +56 -5
- package/dist/models/log-record.d.ts +1 -1
- package/dist/models/plugin.d.ts +47 -0
- package/dist/models/stats.d.ts +11 -0
- package/dist/{network--GoE7_Or.js → network-BsBZ6_-Q.js} +43 -29
- package/dist/network-BsBZ6_-Q.js.map +1 -0
- package/dist/network-_4csBGBM.cjs +2 -0
- package/dist/network-_4csBGBM.cjs.map +1 -0
- package/dist/{platform-GaM6h7XM.js → platform-4yYjMD-B.js} +11 -6
- package/dist/platform-4yYjMD-B.js.map +1 -0
- package/dist/{platform-kIL5AZB7.cjs → platform-o7r1ocOu.cjs} +2 -2
- package/dist/platform-o7r1ocOu.cjs.map +1 -0
- package/dist/remote-rules-1KqfVBIu.js +91 -0
- package/dist/remote-rules-1KqfVBIu.js.map +1 -0
- package/dist/remote-rules-BHgEGlYi.cjs +2 -0
- package/dist/remote-rules-BHgEGlYi.cjs.map +1 -0
- package/dist/sampling-C4my-ma0.cjs +2 -0
- package/dist/sampling-C4my-ma0.cjs.map +1 -0
- package/dist/sampling-nYIWP_vP.js +86 -0
- package/dist/sampling-nYIWP_vP.js.map +1 -0
- package/dist/{sanitize-DP0xDPrt.js → sanitize-BiUKCUG6.js} +2 -2
- package/dist/{sanitize-DP0xDPrt.js.map → sanitize-BiUKCUG6.js.map} +1 -1
- package/dist/{sanitize--_e4oOPX.cjs → sanitize-BxuPSXOk.cjs} +2 -2
- package/dist/{sanitize--_e4oOPX.cjs.map → sanitize-BxuPSXOk.cjs.map} +1 -1
- package/dist/sender-6vrT9fFL.cjs +3 -0
- package/dist/sender-6vrT9fFL.cjs.map +1 -0
- package/dist/{sender-BUBWLn5i.js → sender-DFQMF39P.js} +382 -275
- package/dist/sender-DFQMF39P.js.map +1 -0
- package/dist/{storm-DhHGHhOc.cjs → storm-6YYbXzT_.cjs} +2 -2
- package/dist/{storm-DhHGHhOc.cjs.map → storm-6YYbXzT_.cjs.map} +1 -1
- package/dist/{storm-OD5J6Ylm.js → storm-CfO0Sam2.js} +2 -2
- package/dist/{storm-OD5J6Ylm.js.map → storm-CfO0Sam2.js.map} +1 -1
- package/dist/transport/exit-flush.d.ts +6 -0
- package/dist/transport/http-transport.d.ts +2 -1
- package/dist/transport/serializers/otlp-traces.d.ts +3 -0
- package/dist/transport/serializers/select.d.ts +8 -5
- package/dist/transport/status-transport.d.ts +7 -0
- package/dist/types-BR9t_w28.js +8 -0
- package/dist/types-BR9t_w28.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs +2 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -0
- package/dist/utils/identity.d.ts +11 -0
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/tracing.d.ts +82 -4
- package/dist/web-socket-Ar4cZxmd.js +102 -0
- package/dist/web-socket-Ar4cZxmd.js.map +1 -0
- package/dist/web-socket-BwJdwSHl.cjs +2 -0
- package/dist/web-socket-BwJdwSHl.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/constants-Cb92egPS.cjs +0 -2
- package/dist/constants-Cb92egPS.cjs.map +0 -1
- package/dist/constants-DhH6VI5a.js +0 -144
- package/dist/constants-DhH6VI5a.js.map +0 -1
- package/dist/deadline-CUrH0Hd8.cjs +0 -2
- package/dist/deadline-CUrH0Hd8.cjs.map +0 -1
- package/dist/deadline-DeqXEliN.js +0 -31
- package/dist/deadline-DeqXEliN.js.map +0 -1
- package/dist/errors-DCZWcHkd.js.map +0 -1
- package/dist/errors-ERu-su8m.cjs +0 -3
- package/dist/errors-ERu-su8m.cjs.map +0 -1
- package/dist/identity-C1WLItSl.cjs +0 -2
- package/dist/identity-C1WLItSl.cjs.map +0 -1
- package/dist/identity-Di-QXGCC.js.map +0 -1
- package/dist/interactions-BLH_tX87.js.map +0 -1
- package/dist/interactions-_hfOerfC.cjs.map +0 -1
- package/dist/journey-BRUj0hqD.cjs +0 -2
- package/dist/journey-BRUj0hqD.cjs.map +0 -1
- package/dist/journey-yALMEWF7.js.map +0 -1
- package/dist/long-frames-D4Bm3Zkz.cjs.map +0 -1
- package/dist/long-frames-DD_Um9_4.js.map +0 -1
- package/dist/network--GoE7_Or.js.map +0 -1
- package/dist/network-DcuS2H1P.cjs +0 -2
- package/dist/network-DcuS2H1P.cjs.map +0 -1
- package/dist/platform-GaM6h7XM.js.map +0 -1
- package/dist/platform-kIL5AZB7.cjs.map +0 -1
- package/dist/remote-rules-6ePq8CrI.js +0 -84
- package/dist/remote-rules-6ePq8CrI.js.map +0 -1
- package/dist/remote-rules-CI3gbRCL.cjs +0 -2
- package/dist/remote-rules-CI3gbRCL.cjs.map +0 -1
- package/dist/sampling-C-M8p3FK.cjs +0 -2
- package/dist/sampling-C-M8p3FK.cjs.map +0 -1
- package/dist/sampling-Ud_WiuU9.js +0 -65
- package/dist/sampling-Ud_WiuU9.js.map +0 -1
- package/dist/sender-BESHz6my.cjs +0 -3
- package/dist/sender-BESHz6my.cjs.map +0 -1
- package/dist/sender-BUBWLn5i.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-Cb92egPS.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./deadline-CUrH0Hd8.cjs"),r=require("./sampling-C-M8p3FK.cjs"),i=require("./sanitize--_e4oOPX.cjs"),a=require("./identity-C1WLItSl.cjs"),o=require("./platform-kIL5AZB7.cjs"),s=require("./batch-D5qvsMQ_.cjs"),c=require("./library-request-BcAxuwsf.cjs"),l=require("./journey-BRUj0hqD.cjs");function u(t){return Math.round((performance.now()-t)*e.z)/e.z}function d(e,t,n,r,i){e.logMetric(`${t}.duration`,n,`ms`,`histogram`,{status:r,...i})}function f(e,t,n,r,i){let a=u(n);e.error(`${t} failed`,r,{"action.duration_ms":a,status:`FAILURE`,...i}),d(e,t,a,`FAILURE`,i)}function p(e,t,n,r){let i=performance.now();try{let a=n();return d(e,t,u(i),`SUCCESS`,r),a}catch(n){throw f(e,t,i,n,r),n}}async function m(e,t,n,r){let i=performance.now();try{let a=await n();return d(e,t,u(i),`SUCCESS`,r),a}catch(n){throw f(e,t,i,n,r),n}}var h=[e.D,e.sn];function g(e,n){let r=n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!t.r(e))return;let n=Error(e.message);return n.name=e.name,n.stack=e.stack,n});if(r)return r;let i=n.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function _(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function v(e,n){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return n.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let n=e,r=t.r(e),i={},a=0;for(let e of Object.keys(n)){let o=n[e];(!r||!t.t.has(e))&&t.n(o)&&(i[e]=o,a++)}return a===0?void 0:i})}function y(e){if(!n.i(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function b(e){return h.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function x(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var S=class t{bind;namespace;options;levelType;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n,this.levelType=b(t)}child(e,n={}){return new t(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...n.scopedContext}})}trace=(e,t)=>{this.write(`TRACE`,this.levelType,e,t)};debug=(e,t)=>{this.write(`DEBUG`,this.levelType,e,t)};info=(e,t)=>{this.write(`INFO`,this.levelType,e,t)};warn=(e,t)=>{this.write(`WARN`,this.levelType,e,t)};error=(e,t,n)=>{this.writeError(`ERROR`,e,t,n)};fatal=(e,t,n)=>{this.writeError(`FATAL`,e,t,n)};logAction=(e,t)=>{this.write(`INFO`,`action`,e,t)};logEvent=(e,t)=>{this.write(`INFO`,`event`,e,t)};logMetric=(t,n,r=e.I,i=`gauge`,a)=>{if(!Number.isFinite(n)){this.bind().diagnostics.report(`record.dropped_malformed`,`The metric value is not a finite number. The library dropped the metric.`,{"metric.name":t});return}let o=x(a,this.bind().diagnostics),s={...o,"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,[e.vt.attributeKeys]:Object.keys(o)};this.write(`INFO`,`metric`,t,s,!0)};timeSync=(e,t,n)=>p(this,e,t,n);timeAsync=(e,t,n)=>m(this,e,t,n);write(e,t,n,r,i=!1){let a=this.bind();if(a.isDestroyed())return;if(!a.builder.isEnabled(e,t)){this.mirrors(a,e)&&this.print(a,e,n,r,void 0,null);return}let{record:o,dropped:s}=a.builder.build({level:e,type:t,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:i?r:x(r,a.diagnostics)}),c=o?o.body:s===`sampling`?n:void 0;t!==`metric`&&c!==void 0&&a.breadcrumbs.push({t:Date.now(),category:t===`action`?`action`:t===`event`?`event`:`log`,message:c}),this.print(a,e,n,r,void 0,o,s),a.emit(o)}writeError(t,n,r,i){let a=this.bind();if(a.isDestroyed())return;let o=a.builder.isEnabled(t);if(!o&&!this.mirrors(a,t))return;let s=i===void 0&&(a.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>y(r))??!1),c=s?r:i,l=s?void 0:r,u=l===void 0?void 0:g(l,a.diagnostics),d=u===void 0?void 0:_(l,u,a.diagnostics);if(!o){this.print(a,t,n,c,d,null);return}let f=u?v(l,a.diagnostics):void 0,{record:p,dropped:m}=a.builder.build({level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...x(c,a.diagnostics),...u?{"error.type":u.name,"error.message":u.message,"error.stack_trace":u.stack}:{},...f===void 0?{}:{[e.o]:f},[e.a]:a.breadcrumbs.snapshot()}});this.print(a,t,n,c,d,p,m),a.emit(p)}print(e,t,n,r,i,a,o){e.config.redact?a?e.console.write(this.namespace,t,a.body,a.attributes):o!==`redact`&&o!==`malformed`&&e.console.write(this.namespace,t,n,void 0,i):e.console.write(this.namespace,t,n,r,i)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},ee={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},te=class{settings;diagnostics;limits;constructor(t,n,r=e.At){this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!Object.hasOwn(e.ut,this.settings.level)?!1:e.ut[t]>=e.ut[this.settings.level]}write(e,t,n,r,a){if(!this.accepts(t)||typeof console>`u`||i.a())return;let o=`%c[%s]%c[${t}]%c`,{styles:s}=this.settings,c=ee[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${c}.`,()=>{let l=[];a!==void 0&&l.push(a),r!==void 0&&l.push(i.n(r,this.limits,this.diagnostics)),i.o(()=>{console[c](o,s.namespace,e,s[t],``,n,...l)})})}},ne=class{value=0;next(){return++this.value}},re=/^[0-9a-f]{32}$/,ie=/^[0-9a-f]{16}$/,C=/[1-9a-f]/;function ae(e){return re.test(e.traceId)&&C.test(e.traceId)&&ie.test(e.spanId)&&C.test(e.spanId)}function oe(){return a.o(16)}function se(){return a.o(8)}function w(){return{traceId:oe(),spanId:se(),traceFlags:1,startedAt:Date.now()}}function T(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var ce=class{diagnostics;maxAgeMs;load;ambient=w();otel;constructor(t,n=e.vn,r){this.diagnostics=t,this.maxAgeMs=n,this.load=r}async loadOtel(){if(this.load)try{this.otel=await this.load()}catch(e){this.diagnostics.report(`trace.otel_failed`,`The library could not load @opentelemetry/api. Records use the trace ids of the library.`,void 0,e)}}resolve(){let e=this.activeSpanContext();return e===void 0?(Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),T(this.ambient)):e}activeSpanContext(){let e=this.otel;if(e)return this.diagnostics.guard(`trace.otel_failed`,`The library could not read the active OpenTelemetry span.`,()=>{let t=e.trace.getActiveSpan();if(t===void 0)return;let n=t.spanContext();if(ae(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){return this.ambient=w(),T(this.ambient)}headers(){let t={},n=this.otel;if(n&&this.diagnostics.guard(`trace.otel_failed`,`The library could not add the OpenTelemetry headers.`,()=>{n.propagation.inject(n.context.active(),t)}),!t.traceparent){let n=this.resolve(),r=(n.traceFlags&255).toString(16).padStart(2,`0`);t[e._n]=`00-${n.traceId}-${n.spanId}-${r}`}return t}},le=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=Math.max(e,1),this.buffer=Array(this.capacity)}push(e){this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0)}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}},E=Object.keys(e.ut),ue=[`gzip`,`none`],de=[`omit`,`same-origin`,`include`],fe=[`auto`,`indexeddb`,`localstorage`,`memory`,`none`],pe=[`storage`,`memory`],me=[`auto`,`sender`,`forwarder`,`off`],he=[`auto`,`provider`,`client`],ge=[`auto`,`context`,`tab`,`origin`],D=[`error`,`warn`,`info`,`log`],_e=[`limited`,`until-delivered`],ve={logFlushIntervalMs:[100,6e4],logBatchSize:[1,1e3],metricFlushIntervalMs:[100,6e4],metricBatchSize:[1,1e3]},ye={maxBatches:[1,5e3],maxAgeMs:[6e4,6048e5],maxAttempts:[1,20]},be={maxBodyChars:[256,65536],maxAttributeChars:[256,65536],maxAttributeCount:[1,1024],maxStackChars:[256,65536],maxDepth:[1,16],maxArrayLength:[1,1e4],maxNodes:[100,1e5],maxRecordBytes:[1024,e.S]},xe=[6e4,864e5],Se=[`errors`,`rejections`,`resourceErrors`,`fetch`,`xhr`,`httpMetrics`,`interactions`,`navigation`,`webVitals`,`longFrames`,`fullUrls`],Ce=`null`,O=`a level name: ${A(E)}`,k=`true, false or a list of ${A(D)}`,we=`a list of strings and RegExp patterns`,Te=`a list of origin URLs such as "https://api.example" and RegExp patterns`,Ee=`a list of origin URLs such as "https://app.example". For a sandboxed frame, set bus.mode: "sender" in the frame`,De=`a list of strings`;function A(e){let t=e.map(e=>`"${e}"`);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function j(e){return typeof e==`string`?`"${e}"`:typeof e==`function`?`a function`:typeof e==`object`&&e?`an object`:String(e)}function M(e,t,n,r,i){e.report(`config.invalid`,`${t} must be ${n}. The value is ${j(r)}. The library keeps ${i}.`)}function N(e,t,n,r,i){if(t===void 0)return r;let a=n.find(e=>e===t);return a===void 0?(M(i,e,A(n),t,`"${r}"`),r):a}function P(e,t,n,r){return t===void 0?n:typeof t==`boolean`?t:(M(r,e,`true or false`,t,String(n)),n)}function Oe(e,t,n,r){return t===void 0?n:typeof t==`number`&&Number.isFinite(t)&&t>=0?t:(M(r,e,`a finite number of 0 or more`,t,String(n)),n)}function F(e,t,n,r,i){if(t===void 0)return r;let[a,o]=n;return typeof t==`number`&&Number.isInteger(t)&&t>=a&&t<=o?t:(M(i,e,`an integer from ${String(a)} to ${String(o)}`,t,String(r)),r)}function I(e,t,n,r,i){let a=t??{},o=Object.keys(r);return Object.fromEntries(o.map(t=>[t,F(`${e}.${t}`,a[t],r[t],n[t],i)]))}function L(e){if(typeof e!=`string`)return;let t=e.toUpperCase();return E.find(e=>e===t)}function ke(e,t,n,r){if(t===void 0)return n;let i=L(t);return i===void 0?(M(r,e,O,t,`"${n}"`),n):i}function R(e,t,n,r,i,a){if(t===void 0)return n;if(!Array.isArray(t))return M(a,e,r,t,`the list in force`),n;let o=[],s=t;for(let t of s){let n=i(t);n===void 0?a.report(`config.invalid`,`The library ignores the ${e} entry ${j(t)}. ${e} must be ${r}.`):o.push(n)}return o}function Ae(e){return typeof e==`string`?e:void 0}function je(e){return typeof e==`string`||e instanceof RegExp?e:void 0}function Me(e){return D.find(t=>t===e)}function z(e){if(typeof e==`string`)try{let{origin:t}=new URL(e);return t===Ce?void 0:t}catch{return}}function Ne(e){return e instanceof RegExp?e:z(e)}function Pe(e){return n.i(e)?Object.values(e).every(e=>typeof e==`string`):!1}function Fe(e,t,n){if(e!==void 0)return typeof e==`function`||Pe(e)?e:(M(n,`headers`,`an object of strings or a function`,e,`the headers in force`),t)}function Ie(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function Le(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||Ie(t)?t:(r.report(`config.invalid`,`serializer must be "${e.en}", "ecs" or an implementation. The library uses "${e.en}".`),e.en)}var Re=new Set(Object.keys(e.j));function ze(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)Re.has(e)?typeof i==`string`?n[e]=i:t.report(`config.invalid`,`console.styles.${e} must be a string. The library keeps the style in force.`):t.report(`config.invalid`,`The library ignores the unknown console.styles key "${e}". Check the spelling.`);return n}function Be(e,t,n){if(e===void 0)return t??`DEBUG`;let r=L(e);return r===void 0?(M(n,`console.level`,O,e,`the console level in force`),t):r}function Ve(t,n,r){if(t===void 0)return n;if(t===!1)return{level:null,styles:n.styles};if(t===!0)return{level:e.A,styles:n.styles};if(typeof t==`string`){let e=L(t);return e===void 0?(M(r,`console`,O,t,`the console level in force`),n):{level:e,styles:n.styles}}return typeof t!=`object`||!t?(r.report(`config.invalid`,`console must be a boolean, a level or an object. The console settings in force stay.`),n):{level:Be(t.level,n.level,r),styles:{...n.styles,...ze(t.styles,r)}}}function He(e,t,n){let r=e??{};return{...t,...r,rates:{...t.rates,...r.rates},alwaysSampleTypes:R(`sampling.alwaysSampleTypes`,r.alwaysSampleTypes,t.alwaysSampleTypes,De,Ae,n),remote:P(`sampling.remote`,r.remote,t.remote,n)}}function Ue(e,t,n){let r=e??{};return{mode:N(`bus.mode`,r.mode,me,t.mode,n),trustedOrigins:R(`bus.trustedOrigins`,r.trustedOrigins,t.trustedOrigins,Ee,z,n),openFinRole:N(`bus.openFinRole`,r.openFinRole,he,t.openFinRole,n)}}function We(e,t,n){let r=e??{};return{scope:N(`journey.scope`,r.scope,ge,t.scope,n),maxAgeMs:F(`journey.maxAgeMs`,r.maxAgeMs,xe,t.maxAgeMs,n)}}function Ge(e,t,n){let r=e??{};return{mode:N(`retention.mode`,r.mode,_e,t.mode,n),...I(`retention`,r,t,ye,n)}}function Ke(e,t,n){return e===void 0?t:typeof e==`boolean`?e:Array.isArray(e)?R(`capture.console`,e,[],k,Me,n):(M(n,`capture.console`,k,e,`the value in force`),t)}function qe(e,t,n){let r=e??{},i={...t,...r,console:Ke(r.console,t.console,n),longFrameThresholdMs:Oe(`capture.longFrameThresholdMs`,r.longFrameThresholdMs,t.longFrameThresholdMs,n),ignoreUrls:R(`capture.ignoreUrls`,r.ignoreUrls,t.ignoreUrls,we,je,n),propagateTraceHeaderTo:R(`capture.propagateTraceHeaderTo`,r.propagateTraceHeaderTo,t.propagateTraceHeaderTo,Te,Ne,n)};for(let e of Se)i[e]=P(`capture.${e}`,r[e],t[e],n);return i}function Je(t,n,r,i){let a=n;if(typeof t==`string`&&t!==``)try{new URL(t),a=t}catch(e){i.report(`config.invalid`,`metricsEndpoint is not a valid absolute URL: ${t}. The library keeps the value in force.`,void 0,e)}else t===``?a=``:t!==void 0&&M(i,`metricsEndpoint`,`a URL string`,t,`the value in force`);return a!==``&&r!==`otlp`?(i.report(`config.invalid`,`metricsEndpoint needs serializer "${e.en}". The library sends metric records as log records.`),``):a}function B(t,n,r){let i=r??e.F,a={...i,...t,endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,enabled:P(`enabled`,t.enabled,i.enabled,n),minLevel:ke(`minLevel`,t.minLevel,i.minLevel,n),compression:N(`compression`,t.compression,ue,i.compression,n),credentials:N(`credentials`,t.credentials,de,i.credentials,n),headers:`headers`in t?Fe(t.headers,i.headers,n):i.headers,storage:N(`storage`,t.storage,fe,i.storage,n),identity:N(`identity`,t.identity,pe,i.identity,n),serializer:Le(t.serializer,r?.serializer,n),console:Ve(t.console,i.console,n),sampling:He(t.sampling,i.sampling,n),bus:Ue(t.bus,i.bus,n),batching:I(`batching`,t.batching,i.batching,ve,n),retention:Ge(t.retention,i.retention,n),limits:I(`limits`,t.limits,i.limits,be,n),journey:We(t.journey,i.journey,n),capture:qe(t.capture,i.capture,n)};if(a.metricsEndpoint=Je(t.metricsEndpoint,i.metricsEndpoint,a.serializer,n),a.transport!==void 0&&typeof a.transport!=`function`&&(n.report(`config.invalid`,`transport must be a function. The library ignores the value.`),a.transport=i.transport),a.onDrop!==void 0&&typeof a.onDrop!=`function`&&(n.report(`config.invalid`,`onDrop must be a function. The library ignores the value.`),a.onDrop=i.onDrop),a.transportOnExit!==void 0&&typeof a.transportOnExit!=`function`&&(n.report(`config.invalid`,`transportOnExit must be a function. The library ignores the value.`),a.transportOnExit=i.transportOnExit),a.endpoint===``)a.transport===void 0&&n.report(`config.invalid`,`endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.`);else if(a.endpoint!==null)try{new URL(a.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.endpoint}.`,void 0,e)}a.metricsEndpoint!==``&&a.endpoint===null&&!a.transport&&n.report(`config.invalid`,`metricsEndpoint needs endpoint or transport. The library sends nothing to metricsEndpoint.`),a.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.Cn}'.`),e.Cn);let o=a.sampling.defaultRate;(typeof o!=`number`||o<0||o>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1. The value is ${String(o)}. The library uses 1.`),a.sampling.defaultRate=1);let s=a.sampling.remoteMaxRate;(typeof s!=`number`||!(s>=0&&s<=1))&&(n.report(`config.invalid`,`sampling.remoteMaxRate must be 0..1. The value is ${String(s)}. The library uses 1.`),a.sampling.remoteMaxRate=1);let c=Object.entries(a.sampling.rates);for(let[e,t]of c)(typeof t!=`number`||t<0||t>1)&&(n.report(`config.invalid`,`sampling.rates["${e}"] must be 0..1. The value is ${String(t)}. The library uses 1.`),a.sampling.rates[e]=1);a.capture.ignoreUrls=a.capture.ignoreUrls.filter(e=>e!==r?.endpoint&&e!==r?.metricsEndpoint);for(let e of[a.endpoint,a.metricsEndpoint])e&&!a.capture.ignoreUrls.includes(e)&&(a.capture.ignoreUrls=[...a.capture.ignoreUrls,e]);return Ye(t,n),a}function Ye(t,n){let r=new Set([...Object.keys(e.F),...e.xn]);for(let e of Object.keys(t))r.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${e}". Check the spelling.`);for(let r of e.k){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.F[r]),...e.Sn[r]]);for(let e of Object.keys(i))a.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${r}.${e}". Check the spelling.`)}}function Xe(t,n){for(let r of Object.keys(n))e.k.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.k)Object.assign(t[r],n[r])}var Ze=class{map=new Map;set(e,t){this.map.set(e,t)}setMany(e){for(let[t,n]of Object.entries(e))this.map.set(t,n)}remove(e){this.map.delete(e)}getAll(){return Object.fromEntries(this.map)}},Qe=class{handler;throttleMs;counters=new Map;lastEmitted=new Map;constructor(t,n=e.L){this.handler=t,this.throttleMs=n}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,n,r,a){let o=this.count(t),s=Date.now();if(s-(this.lastEmitted.get(t)??0)<this.throttleMs)return;this.lastEmitted.set(t,s);let c={code:t,message:n,detail:r,cause:a,at:s,count:o},{handler:l}=this;if(l)try{i.o(()=>{l(c)})}catch(t){this.count(`handler.threw`),typeof console<`u`&&i.o(()=>{console.warn(`${e.ft} The onDiagnostic handler threw an error.`,t)})}}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}};function V(e,t){e.length<20&&!e.includes(t)&&e.push(t)}var $e=class{config;diagnostics;pending=new Map;scheduled=!1;reporting=!1;constructor(e,t){this.config=e,this.diagnostics=t}add(t,n,r=[]){if(!this.config.onDrop||this.reporting||n.length===0&&r.length===0)return;let i=this.pending.get(t);i||(i={reason:t,records:0,batchIds:[],journeyIds:[],actions:[]},this.pending.set(t,i)),i.records+=n.length;for(let e of r)V(i.batchIds,e);for(let t of n){let n=s.t(t,e.s);typeof n==`string`&&V(i.journeyIds,n);let r=s.r(t)?t.body:void 0;typeof r==`string`&&V(i.actions,r)}this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){this.scheduled=!1;let e=[...this.pending.values()];this.pending.clear();let t=this.config.onDrop;if(t){this.reporting=!0;for(let n of e)this.diagnostics.guard(`handler.threw`,`The onDrop hook threw an error.`,()=>{c.r(()=>{i.o(()=>{t(n)})})});this.reporting=!1}}},H=class{onDrop;held=[];actions=0;constructor(e){this.onDrop=e}get records(){return this.held}get length(){return this.held.length}push(e){let t=s.r(e);if((t?this.actions:this.held.length-this.actions)<(t?2e3:500))this.actions+=+!!t;else{let e=this.held.findIndex(e=>s.r(e)===t),[n]=this.held.splice(e,1);this.onDrop(n)}this.held.push(e)}take(){let e=this.held;return this.held=[],this.actions=0,e}},et=`overflow`,tt=new Set([e.d,e.u,e.n,e.p,e.s,e.c,e.l]);function nt(e={}){let t={};for(let n of Object.keys(e).sort()){if(n.startsWith(`metric.`)||tt.has(n))continue;let r=e[n];(typeof r==`string`||typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r)}return t}function rt(e){if(!Array.isArray(e))return null;let t=Math.min(e.length,51);return Array.from({length:t},(t,n)=>e[n])}function it(e){return Array.isArray(e)&&e.length<=50&&e.every((t,n)=>typeof t==`number`&&Number.isFinite(t)&&(n===0||t>e[n-1]))}function at(t,n,r){let i={"metric.name":t.name,"metric.unit":t.unit,"metric.type":t.kind,[e.vt.start]:r,[e.vt.attributeKeys]:Object.keys(n.attributes)};return t.kind===`counter`?(i[`metric.value`]=n.sum,i):{...i,[e.vt.count]:n.count,[e.vt.sum]:n.sum,[e.vt.min]:n.min,[e.vt.max]:n.max,[e.vt.bounds]:t.boundaries,[e.vt.buckets]:n.buckets}}var ot=class{intervalMs;emit;diagnostics;instruments=new Map;timer=null;startedAt=0;constructor(e,t,n){this.intervalMs=e,this.emit=t,this.diagnostics=n}record(e,t,n){!Number.isFinite(t)||e.kind===`counter`&&t<0?this.diagnostics.report(`record.dropped_malformed`,`The value of the metric ${e.name} is not valid. The library dropped it.`,{"metric.name":e.name}):this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the metric ${e.name}.`,()=>{let r=this.instrumentOf(e);r&&(this.add(r,t,nt(n)),this.arm())})}collect(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null);let e=`${String(this.startedAt)}000000`,t=[...this.instruments.values()];this.instruments.clear();for(let{def:n,series:r}of t)for(let t of r.values())this.emit(n.name,t.attributes,at(n,t,e))}instrumentOf(t){let n=this.instruments.get(t.name);if(n)return n.def.kind===t.kind?n:(this.diagnostics.report(`record.dropped_malformed`,`The metric ${t.name} is a counter and a histogram. The library dropped the value.`,{"metric.name":t.name}),null);let r=rt(t.boundaries),i=it(r);t.kind===`histogram`&&!i&&this.diagnostics.report(`config.invalid`,`The boundaries of the metric ${t.name} must be at most 50 finite numbers in ascending order. The library uses the default boundaries.`);let a={def:{...t,boundaries:i?r:[...e._t]},series:new Map};return this.instruments.set(t.name,a),a}add(t,n,r){let i=JSON.stringify(r),a=t.series.get(i),o=r;if(!a&&t.series.size>=100&&(i=et,a=t.series.get(i),o={[e.f]:!0}),!a){let e=t.def.kind===`histogram`?t.def.boundaries.length+1:0,r=Array(e).fill(0);a={attributes:o,count:0,sum:0,min:n,max:n,buckets:r},t.series.set(i,a)}if(a.count+=1,a.sum+=n,a.min=Math.min(a.min,n),a.max=Math.max(a.max,n),a.buckets.length>0){let e=t.def.boundaries.findIndex(e=>n<=e);a.buckets[e===-1?a.buckets.length-1:e]+=1}}arm(){this.timer===null&&(this.startedAt=Date.now(),this.timer=setTimeout(()=>{this.collect()},this.intervalMs()),n.r(this.timer))}},st=`error.`,ct=[e.p,e.s,e.c];function U(e){return e}var lt=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t,n){let{config:r}=this.deps;if(!r.enabled)return!1;if(n!==void 0&&e.lt.includes(n))return!0;let i=this.deps.remote.sampling?.minLevel()??r.minLevel;return e.ut[t]>=e.ut[i]}build(t){let{config:n,diagnostics:a,tracing:s,journey:c,sequence:l,limits:u,remote:d}=this.deps;if(!this.isEnabled(t.level,t.type))return a.count(`record.dropped_by_level`),{record:null,dropped:`level`};let f=s.resolve(),p=c.current();if(!r.r({level:t.level,type:t.type,namespace:t.namespace,journeyId:p?.id??``,traceId:f.traceId,aggregated:t.aggregated},n,d.sampling?.current()??null))return a.count(`record.dropped_by_sampling`),{record:null,dropped:`sampling`};let m=l.next(),h=o.t(a),g=n.capture.fullUrls?h:o.i(h),_,v=0;try{let e=i.r(this.deps.context.getAll(),u,a),n=i.r(t.scoped??{},u,a),r=i.r(t.payload??{},u,a);v=e.bytes+n.bytes+r.bytes,_={...U(e.value),...U(n.value),...U(r.value)}}catch(t){a.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),_={[e.m]:!0}}Object.assign(_,t.fixed),_[e.d]=t.type,_[e.u]=m,_[e.n]=t.namespace,_[e.p]=g,p&&(_[e.s]=p.id,_[e.c]=p.name,p.parentId!==void 0&&(_[e.l]=p.parentId));let y=i.i(t.body,u.maxBodyChars);y!==t.body&&a.count(`record.truncated`);let b={timeUnixNano:r.o(),traceId:f.traceId,spanId:f.spanId,traceFlags:f.traceFlags,severityNumber:e.in[t.level],severityText:t.level,body:y,attributes:_,resource:this.resource()},x=n.redact;if(x){let n;try{n=x(b)}catch(e){return a.report(`record.dropped_by_redact`,`The redact hook threw an error. The library dropped the record.`,void 0,e),{record:null,dropped:`redact`}}if(n===null)return a.count(`record.dropped_by_redact`),{record:null,dropped:`redact`};let o=n??b;if(!r.a(o))return o===b?(a.report(`record.dropped_malformed`,`The redact hook changed the record to a shape that is not a record. The library dropped it.`),{record:null,dropped:`malformed`}):(a.report(`record.dropped_by_redact`,`The redact hook returned a value that is not a record. The library dropped the record.`),{record:null,dropped:`redact`});if(r.i(o.severityText)){if(o!==b){let e=i.r(o.attributes,u,a);b={...o,attributes:U(e.value)},v=e.bytes,Object.assign(b.attributes,t.fixed)}b.severityNumber=e.in[b.severityText]}else return a.report(`record.dropped_malformed`,`The redact hook set a severityText that is not a log level. The library dropped the record.`),{record:null,dropped:`malformed`}}if(v>u.maxRecordBytes){a.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:v,body:b.body});let n={[e.d]:t.type,[e.u]:m,[e.n]:t.namespace,[e.i]:!0,[e.r]:v};for(let e of ct)e in b.attributes&&(n[e]=b.attributes[e]);for(let[e,t]of Object.entries(b.attributes))e.startsWith(st)&&(n[e]=t);let r=i.r(n,u,a).bytes;r>u.maxRecordBytes&&`error.data`in n&&(Reflect.deleteProperty(n,e.o),r=i.r(n,u,a).bytes);let o=b.attributes[e.a];if(o!==void 0){let t=i.r(o,u,a).bytes;r+t<=u.maxRecordBytes&&(n[e.a]=o)}Object.assign(n,t.fixed),b.attributes=n}return{record:b}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.Vt]:t.serviceName,[e.Ht]:t.serviceVersion,[e.Lt]:t.environment,[e.Kt]:e.hn,[e.qt]:e.gn,[e.Gt]:e.mn,[e.Rt]:r.platform,[e.Ut]:n.sessionId,[e.Wt]:n.tabId,[e.It]:n.contextId,[e.Ft]:r.userAgent,...r.openfinUuid===void 0?{}:{[e.Bt]:r.openfinUuid},...r.openfinName===void 0?{}:{[e.zt]:r.openfinName}},this.resourceCache}},ut={errors:async()=>(await Promise.resolve().then(()=>require("./errors-ERu-su8m.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-DcuS2H1P.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-_hfOerfC.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-DFuoTQbZ.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-D4Bm3Zkz.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-BSusX_M-.cjs"))).ConsoleCapture},W=Symbol.for(e.Zt),G=Symbol.for(e.Qt),dt=[`batching`,`retention`];function K(e){return JSON.stringify({...e,webVitalsLoader:e.webVitalsLoader!==void 0,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String)})}function q(e){return{...e,endpoint:null,transport:void 0,transportOnExit:void 0,bus:{...e.bus,mode:`off`}}}function J(t){return t.sdkVersion===e.gn}var Y=class t{degraded;static local=null;sdkVersion=e.gn;diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new Ze;breadcrumbs;tracing;sequence=new ne;journey;builder;remote={sampling:null};console;drops;meter;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=new H(e=>{this.dropHeld(e)});captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1};bootBuffer=new H(e=>{this.dropHeld(e)});forwardBuffer=[];forwardScheduled=!1;roleResolved=!1;started=Promise.resolve();ready=!1;destroyed=!1;lastGapAt=0;limits;journeyOptions;tunablesLocked=!0;constructor(e,t=!1){this.degraded=t,this.diagnostics=new Qe(e.onDiagnostic),this.platform=o.n(this.diagnostics),this.config=B(e,this.diagnostics),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`?a.r():a.t,this.identity=a.s(this.diagnostics,this.stores),this.sessionTouch=new a.n(this.diagnostics,this.stores),this.breadcrumbs=new le(50),this.tracing=new ce(this.diagnostics,void 0,this.config.otelLoader),this.tracing.loadOtel(),this.limits={...this.config.limits},this.console=new te(this.config.console,this.diagnostics,this.limits),this.drops=new $e(this.config,this.diagnostics),this.journeyOptions={...l.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new l.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new lt({remote:this.remote,config:this.config,limits:this.limits,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform}),this.meter=new ot(()=>this.config.batching.metricFlushIntervalMs,(e,t,n)=>{this.emitPoint(e,t,n)},this.diagnostics)}recordMetric(e,t,n){this.destroyed||this.meter.record(e,t,n)}emitPoint(t,n,r){let{record:i}=this.builder.build({level:`INFO`,type:`metric`,body:t,namespace:e.yt,payload:n,fixed:r,aggregated:!0});this.emit(i)}busAccept=(e,t)=>{this.destroyed||this.ensureBus().then(n=>{n&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{n.acceptDirect(e,t)})})};static pinned(){return globalThis[W]??null}static current(){let e=t.local;if(e)return e.destroyed?null:e;let n=t.pinned();return n&&J(n)?n:null}static stopped(){let e=t.local;if(e?.destroyed)return e;let n=globalThis[G];return n&&J(n)?n:null}isDestroyed(){return this.destroyed}static configure(e,n=!1){let r=t.local;if(r&&!r.destroyed)return r.reconfigure(q(e)),r;t.local=null;let i=t.pinned();if(i){if(!J(i))return t.startDegraded(e,i.sdkVersion);if(!i.destroyed)return i.reconfigure(e),i}let a=new t(e);return a.tunablesLocked=!n,globalThis[W]=a,Reflect.deleteProperty(globalThis,G),a.init(),a}static startDegraded(n,r){let i=new t(q(n),!0);t.local=i;let a=typeof r==`string`?r:`before 0.9.0`;return i.diagnostics.report(`runtime.version_mismatch`,`Another copy of the library, version ${a}, owns the page runtime. This copy, version ${e.gn}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:a,own:e.gn}),i.init(),i}reconfigure(e){let t=this.keepDestination(e),n=K(this.config.capture),r=B(t,this.diagnostics,this.config);this.keepStartupTunables(r),Xe(this.config,r),this.diagnostics.setHandler(this.config.onDiagnostic),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),K(this.config.capture)!==n&&this.installCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,dt),!this.tunablesLocked){this.tunablesLocked=!0,Object.assign(this.limits,e.limits),this.journeyOptions.maxAgeMs=e.journey.maxAgeMs;return}this.keepSections(e,[`limits`]);let{maxAgeMs:t}=this.config.journey;e.journey.maxAgeMs!==t&&(this.diagnostics.report(`config.invalid`,`journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`,{requested:e.journey.maxAgeMs}),e.journey.maxAgeMs=t)}keepSections(e,t){for(let n of t)JSON.stringify(e[n])!==JSON.stringify(this.config[n])&&(this.diagnostics.report(`config.invalid`,`${n} cannot change after startup. The values in force stay.`,{requested:e[n]}),Object.assign(e,{[n]:this.config[n]}))}keepBuiltStorage(){let e=this.storageBuiltAs;e!==void 0&&this.config.storage!==e&&(this.diagnostics.report(`config.invalid`,`storage cannot change after startup. It stays ${e}.`,{requested:this.config.storage}),this.config.storage=e)}keepDestination(e){if(this.senderLoad===void 0)return e;let t=e;return`transport`in e&&e.transport===void 0!=(this.config.transport===void 0)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove transport after the delivery stack loads. The transport in force stays.`),t={...t},delete t.transport),(t.endpoint===null||t.endpoint===``)&&this.config.transport===void 0&&(this.diagnostics.report(`config.invalid`,`You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays.`),t={...t,endpoint:void 0}),t}keepBuiltIdentity(){let e=this.identityBuiltAs;this.config.identity!==e&&(this.diagnostics.report(`config.invalid`,`identity cannot change after startup. It stays ${e}.`,{requested:this.config.identity}),this.config.identity=e)}async init(){let e=this.installCaptures();this.started=this.boot(),await this.started,await e}async boot(){try{let e=this.journey.bootstrap();this.config.bus.mode!==`off`&&await this.ensureBus(),this.roleResolved=!0,await this.syncSender(),await e}catch(e){this.diagnostics.report(`pipeline.crashed`,`Startup failed. The runtime continues with reduced function.`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}ensureBus(){return this.busLoad??=this.startBus(),this.busLoad}constructBus(){return this.busBuilt??=this.buildBus(),this.busBuilt}async startBus(){let e=await this.constructBus();if(!e)return null;try{return await e.start(),e}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not start. This context sends its own records.`,void 0,e),null}}async buildBus(){try{let{Bus:e}=await Promise.resolve().then(()=>require("./bus-WPVDFw2y.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onRecords:e=>{this.ingestForwarded(e)},onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()},remote:this.remote});return this.bus=t,t}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not load. This context sends its own records.`,void 0,e),null}}role(){return this.bus?.getRole()??`sender`}syncSender(){return!this.hasDestination()||this.role()!==`sender`?Promise.resolve():this.loadSender()}hasDestination(){return!!this.config.endpoint||this.config.transport!==void 0}loadSender(){return this.senderLoad??=this.buildSender(),this.senderLoad}async buildSender(){this.storageBuiltAs=this.config.storage;try{let{Sender:e}=await Promise.resolve().then(()=>require("./sender-BESHz6my.cjs")),t=this.destroyed?null:await e.create({config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote,beforeExit:()=>{this.meter.collect()}});if(!t||this.destroyed){await t?.destroy();return}this.sender=t}catch(e){this.senderLoad=void 0,this.diagnostics.report(`pipeline.crashed`,`The delivery stack did not load. The library does not send records.`,{held:this.pendingRecords.length},e),this.drops.add(`load_failed`,this.pendingRecords.records)}for(let e of this.pendingRecords.take())this.sender?.push(e)}async installCaptures(){if(this.degraded)return;let t=++this.captureGeneration,n=this.config.capture,r=[];(n.errors||n.rejections||n.resourceErrors)&&r.push(`errors`),(n.fetch||n.xhr)&&r.push(`network`),(n.interactions||n.navigation)&&r.push(`interactions`),n.webVitals&&r.push(`webVitals`),n.longFrames&&r.push(`longFrames`),(Array.isArray(n.console)?n.console.length>0:n.console)&&r.push(`console`);let i=await Promise.all(r.map(e=>this.loadCapture(e)));if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures();let a={config:this.config,diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new S(()=>this,e.D),once:this.captureOnce,recordMetric:(e,t,n)=>{this.recordMetric(e,t,n)}};for(let e of i)e&&this.captures.push(new e(a));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not install the ${e.name} capture.`,()=>{e.install()})}uninstallCaptures(){for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${e.name} capture.`,()=>{e.uninstall()});this.captures.length=0}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,ut[e])}registerWorker(e){this.destroyed||this.constructBus().then(t=>{t&&!this.destroyed&&(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{t.attachWorker(e)}),this.ensureBus())})}async destroy(){if(this.destroyed)return;this.meter.collect(),this.destroyed=!0,this.uninstallCaptures();let e=this.sender?.destroy();this.journey.destroy(),this.sendForwarded(),this.bus?.destroy(),this.drops.add(`load_failed`,this.pendingRecords.take()),await e,await this.senderLoad,t.pinned()===this&&(Reflect.deleteProperty(globalThis,W),globalThis[G]=this)}emit(e){e&&!this.destroyed&&(this.sessionTouch.touch(this.identity.sessionId),this.ready?this.route(e):this.bootBuffer.push(e))}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){this.sender?this.sender.push(e):this.senderLoad?this.pendingRecords.push(e):(this.diagnostics.count(`record.dropped_no_destination`),this.hasDestination()&&this.drops.add(`load_failed`,[e]))}dropHeld(e){this.diagnostics.count(`record.dropped_boot_buffer_full`),this.drops.add(`buffer_full`,[e])}forward(e){this.forwardBuffer.push(e),!this.forwardScheduled&&(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1,this.sendForwarded()}))}sendForwarded(){let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus?.sendRecords(e)}ingestForwarded(e){if(!Array.isArray(e))this.diagnostics.count(`record.dropped_malformed`);else for(let t of e)r.a(t)?r.n(t,this.config,this.remote.sampling?.current()??null)?this.deliver(t):this.diagnostics.count(`record.dropped_by_sampling`):this.diagnostics.count(`record.dropped_malformed`)}releaseBootBuffer(){let e=this.bootBuffer.take(),t=this.journey.current();for(let n of e)t&&!n.attributes[`journey.id`]&&(n.attributes[`journey.id`]=t.id,n.attributes[`journey.name`]=t.name),this.route(n)}reportLoss=(e,t,n)=>{this.drops.add(e,t,n)};reportGap=(t,n)=>{this.drops.add(t.reason,n.flatMap(e=>e.records),n.map(e=>e.id));let r=Date.now();r-this.lastGapAt<6e4||(this.lastGapAt=r,new S(()=>this,e.sn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let e=a.i(this.diagnostics);this.diagnostics.report(`bus.role_resolved`,`Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.`,{was:this.identity.tabId,now:e}),this.identity.tabId=e,a.a(e,this.diagnostics,this.stores),this.builder.invalidateResource()}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){this.meter.collect(),this.ready||await this.started,this.role()===`forwarder`?this.sendForwarded():(await this.senderLoad,await this.sender?.flush())}};function ft(){let e=[],t=[],n={status:200};return{transport:r=>(e.push(r),n.status>=200&&n.status<300&&t.push(r),Promise.resolve({...n})),records:()=>t.flatMap(e=>[...e.records]),batches:()=>[...e],clear:()=>{e.length=0,t.length=0},respondWith:(e,t)=>{n=t===void 0?{status:e}:{status:e,retryAfterMs:t}}}}var X=new Map;function Z(){return(Y.current()??Y.stopped())||Y.configure({},!0)}function pt(e){Y.configure(e)}function Q(e,t){if(t)return new S(Z,e,t);let n=X.get(e);return n||(n=new S(Z,e),X.set(e,n)),n}function $(){return Q(`app`)}function mt(e,t){$().trace(e,t)}function ht(e,t){$().debug(e,t)}function gt(e,t){$().info(e,t)}function _t(e,t){$().warn(e,t)}function vt(e,t,n){$().error(e,t,n)}function yt(e,t,n){$().fatal(e,t,n)}function bt(e,t){$().logAction(e,t)}function xt(e,t){$().logEvent(e,t)}function St(e,t,n,r,i){$().logMetric(e,t,n,r,i)}function Ct(e,t={}){let n={name:e,kind:`counter`,unit:t.unit??`count`,boundaries:[]};return{add:(e,t)=>{Z().recordMetric(n,e,t)}}}function wt(t,n={}){let r={name:t,kind:`histogram`,unit:n.unit??`count`,boundaries:n.boundaries??e._t};return{record:(e,t)=>{Z().recordMetric(r,e,t)}}}function Tt(e,t,n){return $().timeSync(e,t,n)}function Et(e,t,n){return $().timeAsync(e,t,n)}function Dt(e,t){Z().context.set(e,t)}function Ot(e){Z().context.setMany(e)}function kt(e){Z().context.remove(e)}function At(e,t){return Z().journey.start(e,t)}function jt(){Z().journey.end()}function Mt(){return Z().journey.current()}function Nt(){return Z().journey.getToken()}function Pt(e){return Z().journey.adopt(e,`manual`,!0)}function Ft(e){Z().registerWorker(e)}function It(){Z().tracing.rotate(`explicit`)}function Lt(){return Z().tracing.headers()}function Rt(){return Z().flush()}function zt(){return Z().queueDepth()}function Bt(){return Z().diagnostics.snapshot()}async function Vt(){await Y.current()?.destroy()}exports.OneLogger=S,exports.adoptJourney=Pt,exports.configure=pt,exports.counter=Ct,exports.createMemoryTransport=ft,exports.currentJourney=Mt,exports.debug=ht,exports.endJourney=jt,exports.error=vt,exports.fatal=yt,exports.flush=Rt,exports.getDiagnosticCounters=Bt,exports.getJourneyToken=Nt,exports.getLogger=Q,exports.getQueueDepth=zt,exports.getTraceHeaders=Lt,exports.histogram=wt,exports.info=gt,exports.logAction=bt,exports.logEvent=xt,exports.logMetric=St,exports.registerWorker=Ft,exports.removeContext=kt,exports.setContext=Dt,exports.setContextMap=Ot,exports.shutdown=Vt,exports.startJourney=At,exports.startTrace=It,exports.timeAsync=Et,exports.timeSync=Tt,exports.trace=mt,exports.warn=_t;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-BgRS6MB0.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./sampling-C4my-ma0.cjs"),r=require("./log-record-jX9eWUP8.cjs"),i=require("./sanitize-BxuPSXOk.cjs"),a=require("./identity-Bwku7zzN.cjs"),o=require("./library-request-gMFOCNcn.cjs"),s=require("./platform-o7r1ocOu.cjs"),c=require("./batch-C4oF6XZT.cjs"),l=require("./journey-Co9OlzrW.cjs");function u(t){return Math.round((performance.now()-t)*e.z)/e.z}function d(e,t,n,r,i){e.logMetric(`${t}.duration`,n,`ms`,`histogram`,{status:r,...i})}function f(e,t,n,r,i){let a=u(n);e.error(`${t} failed`,r,{"action.duration_ms":a,status:`FAILURE`,...i}),d(e,t,a,`FAILURE`,i)}function p(e,t,n,r){let i=performance.now();try{let a=n();return d(e,t,u(i),`SUCCESS`,r),a}catch(n){throw f(e,t,i,n,r),n}}async function m(e,t,n,r){let i=performance.now();try{let a=await n();return d(e,t,u(i),`SUCCESS`,r),a}catch(n){throw f(e,t,i,n,r),n}}var h=[e.D,e.fn];function g(e,n){let r=n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!t.r(e))return;let n=Error(e.message);return n.name=e.name,n.stack=e.stack,n});if(r)return r;let i=n.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function _(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function v(e,n){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return n.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let n=e,r=t.r(e),i={},a=0;for(let e of Object.keys(n)){let o=n[e];(!r||!t.t.has(e))&&t.n(o)&&(i[e]=o,a++)}return a===0?void 0:i})}function y(e){if(!n.u(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function b(e){return h.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function x(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var S=class t{bind;namespace;options;levelType;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n,this.levelType=b(t)}child(e,n={}){return new t(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...n.scopedContext}})}trace=(e,t)=>{this.write(`TRACE`,this.levelType,e,t)};debug=(e,t)=>{this.write(`DEBUG`,this.levelType,e,t)};info=(e,t)=>{this.write(`INFO`,this.levelType,e,t)};warn=(e,t)=>{this.write(`WARN`,this.levelType,e,t)};error=(e,t,n)=>{this.writeError(`ERROR`,e,t,n)};fatal=(e,t,n)=>{this.writeError(`FATAL`,e,t,n)};logAction=(e,t)=>{this.write(`INFO`,`action`,e,t)};logEvent=(e,t)=>{this.write(`INFO`,`event`,e,t)};logMetric=(t,n,r=e.I,i=`gauge`,a)=>{if(!Number.isFinite(n)){this.bind().diagnostics.report(`record.dropped_malformed`,`The metric value is not a finite number. The library dropped the metric.`,{"metric.name":t});return}let o=x(a,this.bind().diagnostics),s={...o,"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,[e.St.attributeKeys]:Object.keys(o)};this.write(`INFO`,`metric`,t,s,!0)};timeSync=(e,t,n)=>p(this,e,t,n);timeAsync=(e,t,n)=>m(this,e,t,n);write(e,t,n,r,i=!1){let a=this.bind();if(a.isDestroyed())return;if(!a.builder.isEnabled(e,this.namespace,t)){this.mirrors(a,e)&&this.print(a,e,n,r,void 0,null);return}let{record:o,dropped:s}=a.builder.build({level:e,type:t,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:i?r:x(r,a.diagnostics)}),c=o?o.body:s===`sampling`?n:void 0;t!==`metric`&&c!==void 0&&a.breadcrumbs.push({t:Date.now(),category:t===`action`?`action`:t===`event`?`event`:`log`,message:c}),this.print(a,e,n,r,void 0,o,s),a.emit(o)}writeError(t,n,r,i){let a=this.bind();if(a.isDestroyed())return;let o=a.builder.isEnabled(t,this.namespace);if(!o&&!this.mirrors(a,t))return;let s=i===void 0&&(a.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>y(r))??!1),c=s?r:i,l=s?void 0:r,u=l===void 0?void 0:g(l,a.diagnostics),d=u===void 0?void 0:_(l,u,a.diagnostics);if(!o){this.print(a,t,n,c,d,null);return}let f=u?v(l,a.diagnostics):void 0,{record:p,dropped:m}=a.builder.build({level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...x(c,a.diagnostics),...u?{"error.type":u.name,"error.message":u.message,"error.stack_trace":u.stack}:{},...f===void 0?{}:{[e.o]:f},[e.a]:a.breadcrumbs.snapshot()}});this.print(a,t,n,c,d,p,m),a.emit(p)}print(e,t,n,r,i,a,o){e.config.redact?a?e.console.write(this.namespace,t,a.body,a.attributes):o!==`processor`&&o!==`redact`&&o!==`malformed`&&e.console.write(this.namespace,t,n,void 0,i):e.console.write(this.namespace,t,n,r,i)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},ee=`overflow`,te=new Set([e.d,e.u,e.n,e.p,e.s,e.c,e.l]);function ne(e={}){let t={};for(let n of Object.keys(e).sort()){if(n.startsWith(`metric.`)||te.has(n))continue;let r=e[n];(typeof r==`string`||typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r)}return t}function re(e){if(!Array.isArray(e))return null;let t=Math.min(e.length,51);return Array.from({length:t},(t,n)=>e[n])}function ie(e){return Array.isArray(e)&&e.length<=50&&e.every((t,n)=>typeof t==`number`&&Number.isFinite(t)&&(n===0||t>e[n-1]))}function ae(t,n,r){let i={"metric.name":t.name,"metric.unit":t.unit,"metric.type":t.kind,[e.St.start]:r,[e.St.attributeKeys]:Object.keys(n.attributes)};return t.kind===`counter`?(i[`metric.value`]=n.sum,i):{...i,[e.St.count]:n.count,[e.St.sum]:n.sum,[e.St.min]:n.min,[e.St.max]:n.max,[e.St.bounds]:t.boundaries,[e.St.buckets]:n.buckets}}function C(e,t,n){let r={name:e,kind:`counter`,unit:t.unit??`count`,boundaries:[]};return{add:(e,t)=>{n(r,e,t)}}}function w(t,n,r){let i={name:t,kind:`histogram`,unit:n.unit??`count`,boundaries:n.boundaries??e.xt};return{record:(e,t)=>{r(i,e,t)}}}var oe=class{intervalMs;emit;diagnostics;instruments=new Map;timer=null;startedAt=0;constructor(e,t,n){this.intervalMs=e,this.emit=t,this.diagnostics=n}record(e,t,n){!Number.isFinite(t)||e.kind===`counter`&&t<0?this.diagnostics.report(`record.dropped_malformed`,`The value of the metric ${e.name} is not valid. The library dropped it.`,{"metric.name":e.name}):this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the metric ${e.name}.`,()=>{let r=this.instrumentOf(e);r&&(this.add(r,t,ne(n)),this.arm())})}collect(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null);let e=`${String(this.startedAt)}000000`,t=[...this.instruments.values()];this.instruments.clear();for(let{def:n,series:r}of t)for(let t of r.values())this.emit(n.name,t.attributes,ae(n,t,e))}instrumentOf(t){let n=this.instruments.get(t.name);if(n)return n.def.kind===t.kind?n:(this.diagnostics.report(`record.dropped_malformed`,`The metric ${t.name} is a counter and a histogram. The library dropped the value.`,{"metric.name":t.name}),null);let r=re(t.boundaries),i=ie(r);t.kind===`histogram`&&!i&&this.diagnostics.report(`config.invalid`,`The boundaries of the metric ${t.name} must be at most 50 finite numbers in ascending order. The library uses the default boundaries.`);let a={def:{...t,boundaries:i?r:[...e.xt]},series:new Map};return this.instruments.set(t.name,a),a}add(t,n,r){let i=JSON.stringify(r),a=t.series.get(i),o=r;if(!a&&t.series.size>=100&&(i=ee,a=t.series.get(i),o={[e.f]:!0}),!a){let e=t.def.kind===`histogram`?t.def.boundaries.length+1:0,r=Array(e).fill(0);a={attributes:o,count:0,sum:0,min:n,max:n,buckets:r},t.series.set(i,a)}if(a.count+=1,a.sum+=n,a.min=Math.min(a.min,n),a.max=Math.max(a.max,n),a.buckets.length>0){let e=t.def.boundaries.findIndex(e=>n<=e);a.buckets[e===-1?a.buckets.length-1:e]+=1}}arm(){this.timer===null&&(this.startedAt=Date.now(),this.timer=setTimeout(()=>{this.collect()},this.intervalMs()),n.l(this.timer))}},se={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},ce=class{settings;diagnostics;limits;constructor(t,n,r=e.Pt){this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!Object.hasOwn(e.pt,this.settings.level)?!1:e.pt[t]>=e.pt[this.settings.level]}write(e,t,n,r,a){if(!this.accepts(t)||typeof console>`u`||i.a())return;let o=`%c[%s]%c[${t}]%c`,{styles:s}=this.settings,c=se[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${c}.`,()=>{let l=[];a!==void 0&&l.push(a),r!==void 0&&l.push(i.n(r,this.limits,this.diagnostics)),i.o(()=>{console[c](o,s.namespace,e,s[t],``,n,...l)})})}},le=class{value=0;next(){return++this.value}},ue=/^[0-9a-f]{32}$/,de=/^[0-9a-f]{16}$/,T=/[1-9a-f]/;function fe(e){return ue.test(e.traceId)&&T.test(e.traceId)&&de.test(e.spanId)&&T.test(e.spanId)}function pe(){return a.o(16)}function E(){return a.o(8)}function me(e){return{traceId:pe(),spanId:E(),traceFlags:1,startedAt:Date.now(),reason:e,ended:!1}}function he(e,t,n){return`00-${e}-${t}-${(n&255).toString(16).padStart(2,`0`)}`}function ge(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var _e=class{diagnostics;maxAgeMs;load;spans;ambient=me(`start`);otel;constructor(t,n=e.Cn,r,i){this.diagnostics=t,this.maxAgeMs=n,this.load=r,this.spans=i}async loadOtel(){if(this.load)try{this.otel=await this.load()}catch(e){this.diagnostics.report(`trace.otel_failed`,`The library could not load @opentelemetry/api. Records use the trace ids of the library.`,void 0,e)}}resolve(){return this.activeSpanContext()??this.ambientContext()}ambientContext(){return Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),ge(this.ambient)}activeSpanContext(){let e=this.otel;if(e)return this.diagnostics.guard(`trace.otel_failed`,`The library could not read the active OpenTelemetry span.`,()=>{let t=e.trace.getActiveSpan();if(t===void 0)return;let n=t.spanContext();if(fe(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){let t=this.ambient;this.ambient=me(e);let n=ge(this.ambient);return this.finish(t),n}end(){this.finish(this.ambient)}finish(e){e.ended||(e.ended=!0,this.spans?.onEnd({traceId:e.traceId,spanId:e.spanId,reason:e.reason,startedAt:e.startedAt,endedAt:Date.now()}))}headers(){return this.trace(!1).headers}request(){return this.trace(!0)}trace(t){let n={},r=this.otel;if(r&&this.diagnostics.guard(`trace.otel_failed`,`The library could not add the OpenTelemetry headers.`,()=>{r.propagation.inject(r.context.active(),n)}),n.traceparent)return{headers:n};let i=this.activeSpanContext(),a=i??this.ambientContext(),o=i?void 0:this.spans;if(!o?.enabled())return n[e.Sn]=he(a.traceId,a.spanId,a.traceFlags),{headers:n};let s=o.keeps(a.traceId),c=s?a.traceFlags:a.traceFlags&-2,l=t?E():a.spanId;return n[e.Sn]=he(a.traceId,l,c),!t||!s?{headers:n}:{headers:n,span:{traceId:a.traceId,spanId:l,parentSpanId:a.spanId}}}},ve=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=Math.max(e,1),this.buffer=Array(this.capacity)}push(e){this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0)}clear(){this.buffer.fill(void 0),this.pointer=0,this.filled=!1}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}},D=Object.keys(e.pt),ye=[`gzip`,`none`],be=[`omit`,`same-origin`,`include`],xe=[`auto`,`indexeddb`,`localstorage`,`memory`,`none`],Se=[`storage`,`memory`],Ce=[`auto`,`sender`,`forwarder`,`off`],we=[`auto`,`provider`,`client`],Te=[`auto`,`context`,`tab`,`origin`],O=[`error`,`warn`,`info`,`log`],Ee=[`limited`,`until-delivered`],De={logFlushIntervalMs:[100,6e4],logBatchSize:[1,1e3],metricFlushIntervalMs:[100,6e4],metricBatchSize:[1,1e3]},Oe={maxBatches:[1,5e3],maxAgeMs:[6e4,6048e5],maxAttempts:[1,20]},ke={maxBodyChars:[256,65536],maxAttributeChars:[256,65536],maxAttributeCount:[1,1024],maxStackChars:[256,65536],maxDepth:[1,16],maxArrayLength:[1,1e4],maxNodes:[100,1e5],maxRecordBytes:[1024,e.S]},Ae=[6e4,864e5],je=[`errors`,`rejections`,`resourceErrors`,`fetch`,`xhr`,`httpMetrics`,`interactions`,`navigation`,`webVitals`,`longFrames`,`fullUrls`,`webSocket`],Me=`null`,k=`a level name: ${j(D)}`,A=`true, false or a list of ${j(O)}`,Ne=`a list of strings and RegExp patterns`,Pe=`a list of origin URLs such as "https://api.example" and RegExp patterns`,Fe=`a list of origin URLs such as "https://app.example". For a sandboxed frame, set bus.mode: "sender" in the frame`,Ie=`a list of strings`;function j(e){let t=e.map(e=>`"${e}"`);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function M(e){return typeof e==`string`?`"${e}"`:typeof e==`function`?`a function`:typeof e==`object`&&e?`an object`:String(e)}function N(e,t,n,r,i){e.report(`config.invalid`,`${t} must be ${n}. The value is ${M(r)}. The library keeps ${i}.`)}function P(e,t,n,r,i){if(t===void 0)return r;let a=n.find(e=>e===t);return a===void 0?(N(i,e,j(n),t,`"${r}"`),r):a}function F(e,t,n,r){return t===void 0?n:typeof t==`boolean`?t:(N(r,e,`true or false`,t,String(n)),n)}function Le(e,t,n,r){return t===void 0?n:typeof t==`number`&&Number.isFinite(t)&&t>=0?t:(N(r,e,`a finite number of 0 or more`,t,String(n)),n)}function I(e,t,n,r,i){if(t===void 0)return r;let[a,o]=n;return typeof t==`number`&&Number.isInteger(t)&&t>=a&&t<=o?t:(N(i,e,`an integer from ${String(a)} to ${String(o)}`,t,String(r)),r)}function L(e,t,n,r,i){let a=t??{},o=Object.keys(r);return Object.fromEntries(o.map(t=>[t,I(`${e}.${t}`,a[t],r[t],n[t],i)]))}function R(e){if(typeof e!=`string`)return;let t=e.toUpperCase();return D.find(e=>e===t)}function Re(e,t,n,r){if(t===void 0)return n;let i=R(t);return i===void 0?(N(r,e,k,t,`"${n}"`),n):i}function ze(e,t,r){if(e===void 0)return t;if(!n.u(e))return N(r,`minLevels`,`an object of level names`,e,`the value in force`),t;let i=[];for(let[t,n]of Object.entries(e)){let e=R(n);t!==``&&e!==void 0?i.push([t,e]):N(r,`minLevels["${t}"]`,k,n,`minLevel for it`)}return Object.fromEntries(i)}function z(e,t,n,r,i,a){if(t===void 0)return n;if(!Array.isArray(t))return N(a,e,r,t,`the list in force`),n;let o=[],s=t;for(let t of s){let n=i(t);n===void 0?a.report(`config.invalid`,`The library ignores the ${e} entry ${M(t)}. ${e} must be ${r}.`):o.push(n)}return o}function Be(e){return typeof e==`function`?e:void 0}function Ve(e){return n.u(e)&&typeof e.name==`string`&&e.name!==``&&typeof e.install==`function`&&typeof e.uninstall==`function`?e:void 0}function He(e){return typeof e==`string`?e:void 0}function Ue(e){return typeof e==`string`||e instanceof RegExp?e:void 0}function We(e){return O.find(t=>t===e)}function B(e){if(typeof e==`string`)try{let{origin:t}=new URL(e);return t===Me?void 0:t}catch{return}}function Ge(e){return e instanceof RegExp?e:B(e)}function Ke(e){return n.u(e)?Object.values(e).every(e=>typeof e==`string`):!1}function qe(e,t,n){if(e!==void 0)return typeof e==`function`||Ke(e)?e:(N(n,`headers`,`an object of strings or a function`,e,`the headers in force`),t)}function Je(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function Ye(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||Je(t)?t:(r.report(`config.invalid`,`serializer must be "${e.in}", "ecs" or an implementation. The library uses "${e.in}".`),e.in)}var Xe=new Set(Object.keys(e.j));function Ze(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)Xe.has(e)?typeof i==`string`?n[e]=i:t.report(`config.invalid`,`console.styles.${e} must be a string. The library keeps the style in force.`):t.report(`config.invalid`,`The library ignores the unknown console.styles key "${e}". Check the spelling.`);return n}function Qe(e,t,n){if(e===void 0)return t??`DEBUG`;let r=R(e);return r===void 0?(N(n,`console.level`,k,e,`the console level in force`),t):r}function $e(t,n,r){if(t===void 0)return n;if(t===!1)return{level:null,styles:n.styles};if(t===!0)return{level:e.A,styles:n.styles};if(typeof t==`string`){let e=R(t);return e===void 0?(N(r,`console`,k,t,`the console level in force`),n):{level:e,styles:n.styles}}return typeof t!=`object`||!t?(r.report(`config.invalid`,`console must be a boolean, a level or an object. The console settings in force stay.`),n):{level:Qe(t.level,n.level,r),styles:{...n.styles,...Ze(t.styles,r)}}}function et(e,t,n){let r=e??{};return{...t,...r,rates:{...t.rates,...r.rates},alwaysSampleTypes:z(`sampling.alwaysSampleTypes`,r.alwaysSampleTypes,t.alwaysSampleTypes,Ie,He,n),remote:F(`sampling.remote`,r.remote,t.remote,n)}}function tt(e,t,n){let r=e??{};return{mode:P(`bus.mode`,r.mode,Ce,t.mode,n),trustedOrigins:z(`bus.trustedOrigins`,r.trustedOrigins,t.trustedOrigins,Fe,B,n),openFinRole:P(`bus.openFinRole`,r.openFinRole,we,t.openFinRole,n)}}function nt(e,t,n){let r=e??{};return{scope:P(`journey.scope`,r.scope,Te,t.scope,n),maxAgeMs:I(`journey.maxAgeMs`,r.maxAgeMs,Ae,t.maxAgeMs,n)}}function rt(e,t,n){let r=e??{};return{mode:P(`retention.mode`,r.mode,Ee,t.mode,n),...L(`retention`,r,t,Oe,n)}}function it(e,t,n){return e===void 0?t:typeof e==`boolean`?e:Array.isArray(e)?z(`capture.console`,e,[],A,We,n):(N(n,`capture.console`,A,e,`the value in force`),t)}function at(e,t,n){let r=e??{},i={...t,...r,console:it(r.console,t.console,n),longFrameThresholdMs:Le(`capture.longFrameThresholdMs`,r.longFrameThresholdMs,t.longFrameThresholdMs,n),ignoreUrls:z(`capture.ignoreUrls`,r.ignoreUrls,t.ignoreUrls,Ne,Ue,n),propagateTraceHeaderTo:z(`capture.propagateTraceHeaderTo`,r.propagateTraceHeaderTo,t.propagateTraceHeaderTo,Pe,Ge,n),plugins:z(`capture.plugins`,r.plugins,t.plugins,`a list of objects with a name, install() and uninstall()`,Ve,n)};for(let e of je)i[e]=F(`capture.${e}`,r[e],t[e],n);return i}var ot={metricsEndpoint:`The library sends metric records as log records.`,tracesEndpoint:`The library sends no span.`};function st(t,n,r,i,a){let o=r;if(typeof n==`string`&&n!==``)try{new URL(n),o=n}catch(e){a.report(`config.invalid`,`${t} is not a valid absolute URL: ${n}. The library keeps the value in force.`,void 0,e)}else n===``?o=``:n!==void 0&&N(a,t,`a URL string`,n,`the value in force`);return o!==``&&i!==`otlp`?(a.report(`config.invalid`,`${t} needs serializer "${e.in}". ${ot[t]}`),``):o}function V(t,n,r){let i=r??e.F,a={...i,...t,endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,enabled:F(`enabled`,t.enabled,i.enabled,n),minLevel:Re(`minLevel`,t.minLevel,i.minLevel,n),minLevels:ze(t.minLevels,i.minLevels,n),processors:z(`processors`,t.processors,i.processors,`a list of functions`,Be,n),compression:P(`compression`,t.compression,ye,i.compression,n),credentials:P(`credentials`,t.credentials,be,i.credentials,n),headers:`headers`in t?qe(t.headers,i.headers,n):i.headers,storage:P(`storage`,t.storage,xe,i.storage,n),identity:P(`identity`,t.identity,Se,i.identity,n),serializer:Ye(t.serializer,r?.serializer,n),console:$e(t.console,i.console,n),sampling:et(t.sampling,i.sampling,n),bus:tt(t.bus,i.bus,n),batching:L(`batching`,t.batching,i.batching,De,n),retention:rt(t.retention,i.retention,n),limits:L(`limits`,t.limits,i.limits,ke,n),journey:nt(t.journey,i.journey,n),capture:at(t.capture,i.capture,n)};for(let e of[`metricsEndpoint`,`tracesEndpoint`])a[e]=st(e,t[e],i[e],a.serializer,n);if(a.transport!==void 0&&typeof a.transport!=`function`&&(n.report(`config.invalid`,`transport must be a function. The library ignores the value.`),a.transport=i.transport),a.onDrop!==void 0&&typeof a.onDrop!=`function`&&(n.report(`config.invalid`,`onDrop must be a function. The library ignores the value.`),a.onDrop=i.onDrop),a.contextProvider!==void 0&&typeof a.contextProvider!=`function`&&(n.report(`config.invalid`,`contextProvider must be a function. The library ignores the value.`),a.contextProvider=i.contextProvider),a.transportOnExit!==void 0&&typeof a.transportOnExit!=`function`&&(n.report(`config.invalid`,`transportOnExit must be a function. The library ignores the value.`),a.transportOnExit=i.transportOnExit),a.endpoint===``)a.transport===void 0&&n.report(`config.invalid`,`endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.`);else if(a.endpoint!==null)try{new URL(a.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.endpoint}.`,void 0,e)}for(let e of[`metricsEndpoint`,`tracesEndpoint`])a[e]!==``&&a.endpoint===null&&!a.transport&&n.report(`config.invalid`,`${e} needs endpoint or transport. The library sends nothing to ${e}.`);a.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.kn}'.`),e.kn);let o=a.sampling.defaultRate;(typeof o!=`number`||o<0||o>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1. The value is ${String(o)}. The library uses 1.`),a.sampling.defaultRate=1);let s=a.sampling.remoteMaxRate;(typeof s!=`number`||!(s>=0&&s<=1))&&(n.report(`config.invalid`,`sampling.remoteMaxRate must be 0..1. The value is ${String(s)}. The library uses 1.`),a.sampling.remoteMaxRate=1);let c=Object.entries(a.sampling.rates);for(let[e,t]of c)(typeof t!=`number`||t<0||t>1)&&(n.report(`config.invalid`,`sampling.rates["${e}"] must be 0..1. The value is ${String(t)}. The library uses 1.`),a.sampling.rates[e]=1);a.capture.ignoreUrls=a.capture.ignoreUrls.filter(e=>e!==r?.endpoint&&e!==r?.metricsEndpoint&&e!==r?.tracesEndpoint);for(let e of[a.endpoint,a.metricsEndpoint,a.tracesEndpoint])e&&!a.capture.ignoreUrls.includes(e)&&(a.capture.ignoreUrls=[...a.capture.ignoreUrls,e]);return ct(t,n),a}function ct(t,n){let r=new Set([...Object.keys(e.F),...e.Dn]);for(let e of Object.keys(t))r.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${e}". Check the spelling.`);for(let r of e.k){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.F[r]),...e.On[r]]);for(let e of Object.keys(i))a.has(e)||n.report(`config.invalid`,`The library ignores the unknown config key "${r}.${e}". Check the spelling.`)}}function lt(t,n){for(let r of Object.keys(n))e.k.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.k)Object.assign(t[r],n[r])}var ut=class{map=new Map;set(e,t){this.map.set(e,t)}setMany(e){for(let[t,n]of Object.entries(e))this.map.set(t,n)}remove(e){this.map.delete(e)}getAll(){return Object.fromEntries(this.map)}},dt=class{handler;throttleMs;counters=new Map;lastEmitted=new Map;constructor(t,n=e.L){this.handler=t,this.throttleMs=n}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,n,r,a){let o=this.count(t),s=Date.now();if(s-(this.lastEmitted.get(t)??0)<this.throttleMs)return;this.lastEmitted.set(t,s);let c={code:t,message:n,detail:r,cause:a,at:s,count:o},{handler:l}=this;if(l)try{i.o(()=>{l(c)})}catch(t){this.count(`handler.threw`),typeof console<`u`&&i.o(()=>{console.warn(`${e.ht} The onDiagnostic handler threw an error.`,t)})}}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}};function H(e,t){e.length<20&&!e.includes(t)&&e.push(t)}var ft=class{config;diagnostics;pending=new Map;scheduled=!1;reporting=!1;constructor(e,t){this.config=e,this.diagnostics=t}add(t,n,r=[]){if(!this.config.onDrop||this.reporting||n.length===0&&r.length===0)return;let i=this.pending.get(t);i||(i={reason:t,records:0,batchIds:[],journeyIds:[],actions:[]},this.pending.set(t,i)),i.records+=n.length;for(let e of r)H(i.batchIds,e);for(let t of n){let n=c.t(t,e.s);typeof n==`string`&&H(i.journeyIds,n);let r=c.r(t)?t.body:void 0;typeof r==`string`&&H(i.actions,r)}this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){this.scheduled=!1;let e=[...this.pending.values()];this.pending.clear();let t=this.config.onDrop;if(t){this.reporting=!0;for(let n of e)this.diagnostics.guard(`handler.threw`,`The onDrop hook threw an error.`,()=>{o.r(()=>{i.o(()=>{t(n)})})});this.reporting=!1}}},U=class{onDrop;held=[];actions=0;constructor(e){this.onDrop=e}get records(){return this.held}get length(){return this.held.length}push(e){let t=c.r(e);if((t?this.actions:this.held.length-this.actions)<(t?2e3:500))this.actions+=+!!t;else{let e=this.held.findIndex(e=>c.r(e)===t),[n]=this.held.splice(e,1);this.onDrop(n)}this.held.push(e)}take(){let e=this.held;return this.held=[],this.actions=0,e}},pt=`error.`,mt=[e.p,e.s,e.c],ht={processor:{label:`A processor`,code:`record.dropped_by_processor`},redact:{label:`The redact hook`,code:`record.dropped_by_redact`}},gt=[`metric.name`,`metric.unit`,`metric.type`,`metric.value`,...Object.values(e.St),...Object.values(e.ln)];function _t(e){return Object.fromEntries(gt.filter(t=>t in e).map(t=>[t,e[t]]))}function W(e){return e}var vt=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t,r,i){let{config:a}=this.deps;if(!a.enabled)return!1;if(i!==void 0&&e.ft.includes(i))return!0;let o=this.deps.remote.sampling?.minLevelFor(r)??n.n(r,a);return e.pt[t]>=e.pt[o]}build(t){let{config:a,diagnostics:o,tracing:c,journey:l,sequence:u,limits:d,remote:f}=this.deps;if(!this.isEnabled(t.level,t.namespace,t.type))return o.count(`record.dropped_by_level`),{record:null,dropped:`level`};let p=t.trace??c.resolve(),m=l.current();if(!n.o({level:t.level,type:t.type,namespace:t.namespace,journeyId:m?.id??``,traceId:p.traceId,aggregated:t.aggregated},a,f.sampling?.current()??null))return o.count(`record.dropped_by_sampling`),{record:null,dropped:`sampling`};let h=u.next(),g=s.t(o),_=s.i(g,a.capture.fullUrls),v,y=0;try{let e=i.r(this.deps.context.getAll(),d,o),n=i.r(this.provided(),d,o),r=i.r(t.scoped??{},d,o),a=i.r(t.payload??{},d,o);y=e.bytes+n.bytes+r.bytes+a.bytes,v={...W(e.value),...W(n.value),...W(r.value),...W(a.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),v={[e.m]:!0}}Object.assign(v,t.fixed),v[e.d]=t.type,v[e.u]=h,v[e.n]=t.namespace,v[e.p]=_,m&&(v[e.s]=m.id,v[e.c]=m.name,m.parentId!==void 0&&(v[e.l]=m.parentId));let b=i.i(t.body,d.maxBodyChars);b!==t.body&&o.count(`record.truncated`);let x={timeUnixNano:r.r(),traceId:p.traceId,spanId:p.spanId,traceFlags:p.traceFlags,severityNumber:e.cn[t.level],severityText:t.level,body:b,attributes:v,resource:this.resource()},S=a.processors.map(e=>[e,`processor`]);if(a.redact&&S.push([a.redact,`redact`]),S.length>0){let e=this.applyHooks(x,S,t.fixed);if(typeof e==`string`)return{record:null,dropped:e};({record:x,bytes:y}=e)}if(y>d.maxRecordBytes){o.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:y,body:x.body});let n={[e.d]:t.type,[e.u]:h,[e.n]:t.namespace,[e.i]:!0,[e.r]:y};for(let e of mt)e in x.attributes&&(n[e]=x.attributes[e]);for(let[e,t]of Object.entries(x.attributes))e.startsWith(pt)&&(n[e]=t);let r=i.r(n,d,o).bytes;r>d.maxRecordBytes&&`error.data`in n&&(Reflect.deleteProperty(n,e.o),r=i.r(n,d,o).bytes);let a=x.attributes[e.a];if(a!==void 0){let t=i.r(a,d,o).bytes;r+t<=d.maxRecordBytes&&(n[e.a]=a)}Object.assign(n,t.fixed),x.attributes=n}return{record:x}}redactForwarded(e){let{redact:t}=this.deps.config;if(!t)return e;let n=[[t,`redact`]],r=this.applyHooks(e,n,_t(e.attributes));return typeof r==`string`?null:r.record}applyHooks(e,t,n){let r=e;for(let[e,n]of t){let t=this.runHook(e,n,r);if(typeof t==`string`)return t;r=t}let{diagnostics:a,limits:o}=this.deps,s=i.r(r.attributes,o,a),c=W(s.value);return Object.assign(c,n),{record:{...r,attributes:c},bytes:s.bytes}}runHook(t,n,i){let{diagnostics:a}=this.deps,{label:o,code:s}=ht[n],c;try{c=t(i)}catch(e){return a.report(s,`${o} threw an error. The library dropped the record.`,void 0,e),n}if(c===null)return a.count(s),n;let l=c??i;return r.n(l)?r.t(l.severityText)?{...l,severityNumber:e.cn[l.severityText]}:(a.report(`record.dropped_malformed`,`${o} set a severityText that is not a log level. The library dropped the record.`),`malformed`):l===i?(a.report(`record.dropped_malformed`,`${o} changed the record to a shape that is not a record. The library dropped it.`),`malformed`):(a.report(s,`${o} returned a value that is not a record. The library dropped the record.`),n)}provided(){let e=this.deps.config.contextProvider;if(!e)return{};let{diagnostics:t}=this.deps,r=t.guard(`handler.threw`,`The contextProvider threw an error. The record has no attributes from it.`,()=>{let t=e();return t===void 0?{}:n.u(t)&&typeof t.then!=`function`?t:null});return r===null&&t.report(`config.invalid`,`contextProvider must return an object of attributes. The library ignores the value.`),r??{}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.Gt]:t.serviceName,[e.Kt]:t.serviceVersion,[e.Vt]:t.environment,[e.Xt]:e.bn,[e.Zt]:e.xn,[e.Yt]:e.yn,[e.Ht]:r.platform,[e.qt]:n.sessionId,[e.Jt]:n.tabId,[e.Bt]:n.contextId,[e.zt]:r.userAgent,...r.openfinUuid===void 0?{}:{[e.Wt]:r.openfinUuid},...r.openfinName===void 0?{}:{[e.Ut]:r.openfinName}},this.resourceCache}},yt=1e3,bt={start:`ui.start`,interaction:`ui.interaction`,navigation:`ui.navigation`,explicit:`ui.trace`,maxAge:`ui.trace`};function G(e){return`${String(Math.round(e*yt))}000`}function xt(e){return{name:bt[e.reason],kind:`internal`,traceId:e.traceId,spanId:e.spanId,parentSpanId:``,startMs:e.startedAt,endMs:e.endedAt,error:!1,attributes:{}}}function St(t){return{[e.ln.kind]:t.kind,[e.ln.parentId]:t.parentSpanId,[e.ln.start]:G(t.startMs),[e.ln.end]:G(t.endMs),[e.ln.status]:t.error?`error`:`unset`}}var Ct={errors:async()=>(await Promise.resolve().then(()=>require("./errors-_xEsCVXn.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-_4csBGBM.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-Bhe1ft8P.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-DFuoTQbZ.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-Bky6nZDF.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-Boqa7new.cjs"))).ConsoleCapture},K=new WeakMap,wt=0;function Tt(e){let t=K.get(e);return t===void 0&&(t=++wt,K.set(e,t)),t}var q=Symbol.for(e.tn),J=Symbol.for(e.nn),Et=[`batching`,`retention`];function Y(e){return JSON.stringify({...e,webVitalsLoader:e.webVitalsLoader!==void 0,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String),plugins:e.plugins.map(Tt)})}function Dt(e){return{...e,endpoint:null,metricsEndpoint:``,tracesEndpoint:``,transport:void 0,transportOnExit:void 0,bus:{...e.bus,mode:`off`}}}function Ot(e){return!!e.endpoint||!!e.metricsEndpoint||!!e.tracesEndpoint||e.transport!==void 0}function X(t){return t.sdkVersion===e.xn}var Z=class t{static local=null;sdkVersion=e.xn;diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new ut;breadcrumbs;tracing;sequence=new le;journey;builder;remote={sampling:null};console;drops;meter;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=new U(e=>{this.dropHeld(e)});captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1};bootBuffer=new U(e=>{this.dropHeld(e)});forwardBuffer=[];forwardScheduled=!1;roleResolved=!1;started=Promise.resolve();ready=!1;destroyed=!1;lastGapAt=0;limits;journeyOptions;tunablesLocked=!0;degraded;serverReported=!1;onPageHide=()=>{this.role()===`forwarder`&&(this.tracing.end(),this.sendForwarded())};constructor(e,t=!1){this.diagnostics=new dt(e.onDiagnostic),this.platform=s.n(this.diagnostics),this.degraded=t||this.onServer(),this.config=V(this.allowed(e),this.diagnostics),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`||this.onServer()?a.r():a.t,this.identity=a.s(this.diagnostics,this.stores),this.sessionTouch=new a.n(this.diagnostics,this.stores),this.breadcrumbs=new ve(50);let r=e=>n.i(e,this.config.sampling.defaultRate);this.tracing=new _e(this.diagnostics,void 0,this.config.otelLoader,{enabled:()=>this.config.tracesEndpoint!==``,keeps:r,onEnd:e=>{r(e.traceId)&&this.recordSpan(xt(e))}}),this.tracing.loadOtel(),this.limits={...this.config.limits},this.console=new ce(this.config.console,this.diagnostics,this.limits),this.drops=new ft(this.config,this.diagnostics),this.journeyOptions={...l.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new l.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new vt({remote:this.remote,config:this.config,limits:this.limits,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform}),this.meter=new oe(()=>this.config.batching.metricFlushIntervalMs,(e,t,n)=>{this.emitPoint(e,t,n)},this.diagnostics)}addBreadcrumb(e,t){this.diagnostics.guard(`record.sanitize_failed`,`The library could not add the breadcrumb.`,()=>{let r={t:Date.now(),category:`custom`,message:i.i(String(e),this.limits.maxBodyChars)};if(t!==void 0){let e=i.n(t,this.limits,this.diagnostics);r.data=n.u(e)?e:{value:e}}this.breadcrumbs.push(r)})}recordMetric(e,t,n){this.destroyed||this.meter.record(e,t,n)}recordSpan(t){if(this.config.tracesEndpoint===``)return;let{record:n}=this.builder.build({level:`INFO`,type:`span`,body:t.name,namespace:e.wn,payload:t.attributes,fixed:St(t),trace:{traceId:t.traceId,spanId:t.spanId,traceFlags:1}});this.emit(n)}emitPoint(t,n,r){let{record:i}=this.builder.build({level:`INFO`,type:`metric`,body:t,namespace:e.Ct,payload:n,fixed:r,aggregated:!0});this.emit(i)}busAccept=(e,t)=>{this.destroyed||this.ensureBus().then(n=>{n&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{n.acceptDirect(e,t)})})};static pinned(){return globalThis[q]??null}static current(){let e=t.local;if(e)return e.destroyed?null:e;let n=t.pinned();return n&&X(n)?n:null}static stopped(){let e=t.local;if(e?.destroyed)return e;let n=globalThis[J];return n&&X(n)?n:null}isDestroyed(){return this.destroyed}static configure(e,n=!1){let r=t.local;if(r&&!r.destroyed)return r.reconfigure(e),r;t.local=null;let i=t.pinned();if(i){if(!X(i))return t.startDegraded(e,i.sdkVersion);if(!i.destroyed)return i.reconfigure(e),i}let a=new t(e);return a.tunablesLocked=!n,globalThis[q]=a,Reflect.deleteProperty(globalThis,J),a.init(),a}static startDegraded(n,r){let i=new t(n,!0);t.local=i;let a=typeof r==`string`?r:`before 0.9.0`;return i.diagnostics.report(`runtime.version_mismatch`,`Another copy of the library, version ${a}, owns the page runtime. This copy, version ${e.xn}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:a,own:e.xn}),i.init(),i}reconfigure(e){let t=this.keepDestination(this.allowed(e)),n=Y(this.config.capture),r=V(t,this.diagnostics,this.config);this.keepStartupTunables(r),lt(this.config,r),this.diagnostics.setHandler(this.config.onDiagnostic),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),Y(this.config.capture)!==n&&this.installCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}onServer(){return this.platform.platform===`node`}allowed(e){return this.degraded?(this.onServer()&&!this.serverReported&&Ot(e)&&(this.serverReported=!0,this.diagnostics.report(`config.invalid`,`The library runs console-only on Node. It sends no record and installs no capture. It ignores endpoint, metricsEndpoint, tracesEndpoint and transport.`)),Dt(e)):e}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,Et),!this.tunablesLocked){this.tunablesLocked=!0,Object.assign(this.limits,e.limits),this.journeyOptions.maxAgeMs=e.journey.maxAgeMs;return}this.keepSections(e,[`limits`]);let{maxAgeMs:t}=this.config.journey;e.journey.maxAgeMs!==t&&(this.diagnostics.report(`config.invalid`,`journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`,{requested:e.journey.maxAgeMs}),e.journey.maxAgeMs=t)}keepSections(e,t){for(let n of t)JSON.stringify(e[n])!==JSON.stringify(this.config[n])&&(this.diagnostics.report(`config.invalid`,`${n} cannot change after startup. The values in force stay.`,{requested:e[n]}),Object.assign(e,{[n]:this.config[n]}))}keepBuiltStorage(){let e=this.storageBuiltAs;e!==void 0&&this.config.storage!==e&&(this.diagnostics.report(`config.invalid`,`storage cannot change after startup. It stays ${e}.`,{requested:this.config.storage}),this.config.storage=e)}keepDestination(e){if(this.senderLoad===void 0)return e;let t=e;return`transport`in e&&e.transport===void 0!=(this.config.transport===void 0)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove transport after the delivery stack loads. The transport in force stays.`),t={...t},delete t.transport),(t.endpoint===null||t.endpoint===``)&&this.config.transport===void 0&&(this.diagnostics.report(`config.invalid`,`You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays.`),t={...t,endpoint:void 0}),t}keepBuiltIdentity(){let e=this.identityBuiltAs;this.config.identity!==e&&(this.diagnostics.report(`config.invalid`,`identity cannot change after startup. It stays ${e}.`,{requested:this.config.identity}),this.config.identity=e)}async init(){this.degraded||addEventListener(`pagehide`,this.onPageHide);let e=this.installCaptures();this.started=this.boot(),await this.started,await e}async boot(){try{let e=this.journey.bootstrap();this.config.bus.mode!==`off`&&await this.ensureBus(),this.roleResolved=!0,await this.syncSender(),await e}catch(e){this.diagnostics.report(`pipeline.crashed`,`Startup failed. The runtime continues with reduced function.`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}ensureBus(){return this.busLoad??=this.startBus(),this.busLoad}constructBus(){return this.busBuilt??=this.buildBus(),this.busBuilt}async startBus(){let e=await this.constructBus();if(!e)return null;try{return await e.start(),e}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not start. This context sends its own records.`,void 0,e),null}}async buildBus(){try{let{Bus:e}=await Promise.resolve().then(()=>require("./bus-rOhVuRee.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onRecords:e=>{this.ingestForwarded(e)},onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()},remote:this.remote});return this.bus=t,t}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not load. This context sends its own records.`,void 0,e),null}}role(){return this.bus?.getRole()??`sender`}syncSender(){return!this.hasDestination()||this.role()!==`sender`?Promise.resolve():this.loadSender()}hasDestination(){return!!this.config.endpoint||this.config.transport!==void 0}loadSender(){return this.senderLoad??=this.buildSender(),this.senderLoad}async buildSender(){this.storageBuiltAs=this.config.storage;try{let{Sender:e}=await Promise.resolve().then(()=>require("./sender-6vrT9fFL.cjs")),t=this.destroyed?null:await e.create({config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote,beforeExit:()=>{this.meter.collect(),this.tracing.end()}});if(!t||this.destroyed){await t?.destroy();return}this.sender=t}catch(e){this.senderLoad=void 0,this.diagnostics.report(`pipeline.crashed`,`The delivery stack did not load. The library does not send records.`,{held:this.pendingRecords.length},e),this.drops.add(`load_failed`,this.pendingRecords.records)}for(let e of this.pendingRecords.take())this.sender?.push(e)}async installCaptures(){if(this.degraded)return;let t=++this.captureGeneration,n=this.config.capture,r=[];(n.errors||n.rejections||n.resourceErrors)&&r.push(`errors`),(n.fetch||n.xhr)&&r.push(`network`),(n.interactions||n.navigation)&&r.push(`interactions`),n.webVitals&&r.push(`webVitals`),n.longFrames&&r.push(`longFrames`),(Array.isArray(n.console)?n.console.length>0:n.console)&&r.push(`console`);let[i,a]=await Promise.all([Promise.all(r.map(e=>this.loadCapture(e))),n.webSocket?this.loadWebSocket():void 0]);if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures();let o={config:this.config,diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new S(()=>this,e.D),once:this.captureOnce,recordMetric:(e,t,n)=>{this.recordMetric(e,t,n)},recordSpan:e=>{this.recordSpan(e)}};for(let e of i)e&&this.captures.push(new e(o));let s=a?[...n.plugins,new a(this.diagnostics,this.config)]:n.plugins;for(let e of s)this.captures.push(this.pluginCapture(e));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not install the ${e.name} capture.`,()=>{e.install()})}uninstallCaptures(){for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${e.name} capture.`,()=>{e.uninstall()});this.captures.length=0}loadWebSocket(){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the webSocket capture.`,async()=>(await Promise.resolve().then(()=>require("./web-socket-BwJdwSHl.cjs"))).WebSocketCapture)}pluginCapture(t){let{name:n}=t,r=(e,t,n)=>{this.recordMetric(e,t,n)},i={logger:new S(()=>this,`${e.D}.${n}`),counter:(e,t={})=>C(e,t,r),histogram:(e,t={})=>w(e,t,r),addBreadcrumb:(e,t)=>{this.addBreadcrumb(e,t)},ownRequest:o.r};return{name:n,install:()=>{t.install(i)},uninstall:()=>{t.uninstall()}}}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,Ct[e])}registerWorker(e){this.destroyed||this.constructBus().then(t=>{t&&!this.destroyed&&(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{t.attachWorker(e)}),this.ensureBus())})}async destroy(){if(this.destroyed)return;this.meter.collect(),this.tracing.end(),this.destroyed=!0,this.degraded||removeEventListener(`pagehide`,this.onPageHide),this.uninstallCaptures();let e=this.sender?.destroy();this.journey.destroy(),this.sendForwarded(),this.bus?.destroy(),this.drops.add(`load_failed`,this.pendingRecords.take()),await e,await this.senderLoad,t.pinned()===this&&(Reflect.deleteProperty(globalThis,q),globalThis[J]=this)}emit(e){e&&!this.destroyed&&(this.sessionTouch.touch(this.identity.sessionId),this.ready?this.route(e):this.bootBuffer.push(e))}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){this.sender?this.sender.push(e):this.senderLoad?this.pendingRecords.push(e):(this.diagnostics.count(`record.dropped_no_destination`),this.hasDestination()&&this.drops.add(`load_failed`,[e]))}dropHeld(e){this.diagnostics.count(`record.dropped_boot_buffer_full`),this.drops.add(`buffer_full`,[e])}forward(e){this.forwardBuffer.push(e),!this.forwardScheduled&&(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1,this.sendForwarded()}))}sendForwarded(){let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus?.sendRecords(e)}ingestForwarded(e){if(!Array.isArray(e))this.diagnostics.count(`record.dropped_malformed`);else for(let t of e){if(!r.n(t)){this.diagnostics.count(`record.dropped_malformed`);continue}if(!n.a(t,this.config,this.remote.sampling?.current()??null)){this.diagnostics.count(`record.dropped_by_sampling`);continue}let e=this.builder.redactForwarded(t);e&&this.deliver(e)}}releaseBootBuffer(){let e=this.bootBuffer.take(),{processors:t,redact:n}=this.config,r=t.length===0&&n===void 0?this.journey.current():null;for(let t of e)r&&!t.attributes[`journey.id`]&&(t.attributes[`journey.id`]=r.id,t.attributes[`journey.name`]=r.name),this.route(t)}reportLoss=(e,t,n)=>{this.drops.add(e,t,n)};reportGap=(t,n)=>{this.drops.add(t.reason,n.flatMap(e=>e.records),n.map(e=>e.id));let r=Date.now();r-this.lastGapAt<6e4||(this.lastGapAt=r,new S(()=>this,e.fn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let e=a.i(this.diagnostics);this.diagnostics.report(`bus.role_resolved`,`Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.`,{was:this.identity.tabId,now:e}),this.identity.tabId=e,a.a(e,this.diagnostics,this.stores),this.builder.invalidateResource()}newSession(){if(this.destroyed)return;this.meter.collect(),this.tracing.rotate(`explicit`),this.journey.end(),this.breadcrumbs.clear();let e=a.i(this.diagnostics);this.identity.sessionId=e,this.sessionTouch.restart(e),this.builder.invalidateResource()}async stats(){let e=await this.queueDepth(),t=this.sender?.stats()??{pending:0,inFlight:0,lastSendAt:null},n=this.bootBuffer.length+this.pendingRecords.length+this.forwardBuffer.length;return{...t,pending:t.pending+n,stored:e}}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){this.meter.collect(),this.ready||await this.started,this.role()===`forwarder`?this.sendForwarded():(await this.senderLoad,await this.sender?.flush())}};function kt(){let e=[],t=[],n={status:200};return{transport:r=>(e.push(r),n.status>=200&&n.status<300&&t.push(r),Promise.resolve({...n})),records:()=>t.flatMap(e=>[...e.records]),batches:()=>[...e],clear:()=>{e.length=0,t.length=0},respondWith:(e,t)=>{n=t===void 0?{status:e}:{status:e,retryAfterMs:t}}}}var At=new Map;function Q(){return(Z.current()??Z.stopped())||Z.configure({},!0)}function jt(e){Z.configure(e)}function Mt(e,t){if(t)return new S(Q,e,t);let n=At.get(e);return n||(n=new S(Q,e),At.set(e,n)),n}function $(){return Mt(`app`)}function Nt(e,t){$().trace(e,t)}function Pt(e,t){$().debug(e,t)}function Ft(e,t){$().info(e,t)}function It(e,t){$().warn(e,t)}function Lt(e,t,n){$().error(e,t,n)}function Rt(e,t,n){$().fatal(e,t,n)}function zt(e,t){$().logAction(e,t)}function Bt(e,t){$().logEvent(e,t)}function Vt(e,t,n,r,i){$().logMetric(e,t,n,r,i)}function Ht(e,t={}){return C(e,t,(e,t,n)=>{Q().recordMetric(e,t,n)})}function Ut(e,t={}){return w(e,t,(e,t,n)=>{Q().recordMetric(e,t,n)})}function Wt(e,t,n){return $().timeSync(e,t,n)}function Gt(e,t,n){return $().timeAsync(e,t,n)}function Kt(e,t){Q().addBreadcrumb(e,t)}function qt(e,t){Q().context.set(e,t)}function Jt(e){Q().context.setMany(e)}function Yt(e){Q().context.remove(e)}function Xt(e,t){return Q().journey.start(e,t)}function Zt(){Q().journey.end()}function Qt(){return Q().journey.current()}function $t(){return Q().journey.getToken()}function en(e){return Q().journey.adopt(e,`manual`,!0)}function tn(e){Q().registerWorker(e)}function nn(){Q().tracing.rotate(`explicit`)}function rn(){return Q().tracing.headers()}function an(){return Q().flush()}function on(){return Q().queueDepth()}function sn(){return Q().stats()}function cn(){Q().newSession()}function ln(){return Q().diagnostics.snapshot()}async function un(){await Z.current()?.destroy()}exports.OneLogger=S,exports.addBreadcrumb=Kt,exports.adoptJourney=en,exports.configure=jt,exports.counter=Ht,exports.createMemoryTransport=kt,exports.currentJourney=Qt,exports.debug=Pt,exports.endJourney=Zt,exports.error=Lt,exports.fatal=Rt,exports.flush=an,exports.getDiagnosticCounters=ln,exports.getJourneyToken=$t,exports.getLogger=Mt,exports.getQueueDepth=on,exports.getStats=sn,exports.getTraceHeaders=rn,exports.histogram=Ut,exports.info=Ft,exports.logAction=zt,exports.logEvent=Bt,exports.logMetric=Vt,exports.newSession=cn,exports.registerWorker=tn,exports.removeContext=Yt,exports.setContext=qt,exports.setContextMap=Jt,exports.shutdown=un,exports.startJourney=Xt,exports.startTrace=nn,exports.timeAsync=Gt,exports.timeSync=Wt,exports.trace=Nt,exports.warn=It;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|