@utk09/ui-observability 0.9.0 → 0.9.2

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.
Files changed (144) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +83 -52
  3. package/dist/batch-4xKzzSCj.js +31 -0
  4. package/dist/batch-4xKzzSCj.js.map +1 -0
  5. package/dist/batch-cys7e53Q.cjs +2 -0
  6. package/dist/batch-cys7e53Q.cjs.map +1 -0
  7. package/dist/{bus-CtJWf9QN.cjs → bus-B6vzPmQM.cjs} +2 -2
  8. package/dist/{bus-CtJWf9QN.cjs.map → bus-B6vzPmQM.cjs.map} +1 -1
  9. package/dist/{bus-D8kH58tb.js → bus-DrixwdiX.js} +10 -10
  10. package/dist/{bus-D8kH58tb.js.map → bus-DrixwdiX.js.map} +1 -1
  11. package/dist/capture/network.d.ts +2 -0
  12. package/dist/capture/types.d.ts +3 -0
  13. package/dist/{console-DjLbryED.js → console-B3vGRW5p.js} +3 -3
  14. package/dist/{console-DjLbryED.js.map → console-B3vGRW5p.js.map} +1 -1
  15. package/dist/{console-BpHfWstv.cjs → console-ChfuJlf9.cjs} +2 -2
  16. package/dist/{console-BpHfWstv.cjs.map → console-ChfuJlf9.cjs.map} +1 -1
  17. package/dist/constants-Be83LICb.cjs +2 -0
  18. package/dist/constants-Be83LICb.cjs.map +1 -0
  19. package/dist/constants-CQ_D7jIW.js +144 -0
  20. package/dist/constants-CQ_D7jIW.js.map +1 -0
  21. package/dist/constants.d.ts +44 -11
  22. package/dist/core/diagnostics.d.ts +1 -1
  23. package/dist/core/drops.d.ts +29 -0
  24. package/dist/core/hold-buffer.d.ts +27 -0
  25. package/dist/core/meter.d.ts +45 -0
  26. package/dist/core/pipeline.d.ts +7 -19
  27. package/dist/core/record.d.ts +7 -0
  28. package/dist/core/runtime.d.ts +61 -8
  29. package/dist/core/sampling.d.ts +2 -0
  30. package/dist/core/sender.d.ts +6 -1
  31. package/dist/deadline-5_PecIl5.js +26 -0
  32. package/dist/deadline-5_PecIl5.js.map +1 -0
  33. package/dist/deadline-XSnm95pg.cjs +2 -0
  34. package/dist/deadline-XSnm95pg.cjs.map +1 -0
  35. package/dist/{errors-DH4QJS0u.js → errors-BGs5NOrw.js} +4 -4
  36. package/dist/{errors-DH4QJS0u.js.map → errors-BGs5NOrw.js.map} +1 -1
  37. package/dist/{errors-CpGRhhIf.cjs → errors-BMJm7KZZ.cjs} +2 -2
  38. package/dist/{errors-CpGRhhIf.cjs.map → errors-BMJm7KZZ.cjs.map} +1 -1
  39. package/dist/identity-DXyV86o-.cjs +2 -0
  40. package/dist/identity-DXyV86o-.cjs.map +1 -0
  41. package/dist/{deadline-B5DINjD5.js → identity-rpEyjvVg.js} +3 -26
  42. package/dist/identity-rpEyjvVg.js.map +1 -0
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.ts +19 -0
  46. package/dist/index.js +683 -369
  47. package/dist/index.js.map +1 -1
  48. package/dist/indexeddb-storage-BXaPVPyG.cjs +2 -0
  49. package/dist/indexeddb-storage-BXaPVPyG.cjs.map +1 -0
  50. package/dist/{indexeddb-storage-n1qkFBGA.js → indexeddb-storage-Q9fDYlyn.js} +76 -47
  51. package/dist/indexeddb-storage-Q9fDYlyn.js.map +1 -0
  52. package/dist/{interactions-OU94MPXs.js → interactions-B8zjCjga.js} +2 -2
  53. package/dist/{interactions-OU94MPXs.js.map → interactions-B8zjCjga.js.map} +1 -1
  54. package/dist/{interactions-31eHGwEQ.cjs → interactions-BAGRmtrv.cjs} +2 -2
  55. package/dist/{interactions-31eHGwEQ.cjs.map → interactions-BAGRmtrv.cjs.map} +1 -1
  56. package/dist/journey-BGSyy8Es.cjs +2 -0
  57. package/dist/journey-BGSyy8Es.cjs.map +1 -0
  58. package/dist/{journey-CeJ1QoT2.js → journey-_dQQ1eMP.js} +27 -26
  59. package/dist/{journey-CeJ1QoT2.js.map → journey-_dQQ1eMP.js.map} +1 -1
  60. package/dist/library-request-BIG3Xpx3.cjs +2 -0
  61. package/dist/library-request-BIG3Xpx3.cjs.map +1 -0
  62. package/dist/library-request-DX6ev9oG.js +25 -0
  63. package/dist/library-request-DX6ev9oG.js.map +1 -0
  64. package/dist/{long-frames-C_7OutLs.js → long-frames-B0tKuChx.js} +3 -3
  65. package/dist/{long-frames-C_7OutLs.js.map → long-frames-B0tKuChx.js.map} +1 -1
  66. package/dist/{long-frames-B8VdA_ny.cjs → long-frames-Cq2LgNnp.cjs} +2 -2
  67. package/dist/{long-frames-B8VdA_ny.cjs.map → long-frames-Cq2LgNnp.cjs.map} +1 -1
  68. package/dist/models/batch.d.ts +14 -0
  69. package/dist/models/config.d.ts +169 -0
  70. package/dist/models/drop.d.ts +39 -0
  71. package/dist/models/metric.d.ts +50 -0
  72. package/dist/models/storage.d.ts +15 -3
  73. package/dist/network-C6kJbW6K.cjs +2 -0
  74. package/dist/network-C6kJbW6K.cjs.map +1 -0
  75. package/dist/network-CMnEvGJB.js +211 -0
  76. package/dist/network-CMnEvGJB.js.map +1 -0
  77. package/dist/{platform-D4wu1eIF.cjs → platform-DNOJjpOm.cjs} +2 -2
  78. package/dist/{platform-D4wu1eIF.cjs.map → platform-DNOJjpOm.cjs.map} +1 -1
  79. package/dist/{platform-IHBZGqUe.js → platform-j0uMPwHi.js} +3 -3
  80. package/dist/{platform-IHBZGqUe.js.map → platform-j0uMPwHi.js.map} +1 -1
  81. package/dist/{remote-rules-kuDf5gbe.cjs → remote-rules-DgoBJxZL.cjs} +2 -2
  82. package/dist/{remote-rules-kuDf5gbe.cjs.map → remote-rules-DgoBJxZL.cjs.map} +1 -1
  83. package/dist/{remote-rules-Bt1XsdEQ.js → remote-rules-UggoZqfP.js} +11 -11
  84. package/dist/{remote-rules-Bt1XsdEQ.js.map → remote-rules-UggoZqfP.js.map} +1 -1
  85. package/dist/{sampling-o0VY1mqQ.js → sampling-BLMD8EGM.js} +28 -27
  86. package/dist/sampling-BLMD8EGM.js.map +1 -0
  87. package/dist/sampling-MthcVXXU.cjs +2 -0
  88. package/dist/sampling-MthcVXXU.cjs.map +1 -0
  89. package/dist/{sanitize-B9UheVKc.js → sanitize-BNwgPj_B.js} +2 -2
  90. package/dist/{sanitize-B9UheVKc.js.map → sanitize-BNwgPj_B.js.map} +1 -1
  91. package/dist/{sanitize-DSIP7amZ.cjs → sanitize-BqzPc4Jg.cjs} +2 -2
  92. package/dist/{sanitize-DSIP7amZ.cjs.map → sanitize-BqzPc4Jg.cjs.map} +1 -1
  93. package/dist/sender--0_VzPbN.js +1249 -0
  94. package/dist/sender--0_VzPbN.js.map +1 -0
  95. package/dist/sender-SPGMqZjD.cjs +3 -0
  96. package/dist/sender-SPGMqZjD.cjs.map +1 -0
  97. package/dist/storage/emergency-queue.d.ts +4 -1
  98. package/dist/storage/eviction.d.ts +40 -0
  99. package/dist/storage/idb-driver.d.ts +6 -0
  100. package/dist/storage/indexeddb-storage.d.ts +13 -5
  101. package/dist/storage/local-storage.d.ts +24 -1
  102. package/dist/storage/memory-storage.d.ts +7 -0
  103. package/dist/{storm-Y-yuBhvv.cjs → storm-CTy1dfvs.cjs} +2 -2
  104. package/dist/{storm-Y-yuBhvv.cjs.map → storm-CTy1dfvs.cjs.map} +1 -1
  105. package/dist/{storm-BTw0J6eE.js → storm-knaj4GUH.js} +2 -2
  106. package/dist/{storm-BTw0J6eE.js.map → storm-knaj4GUH.js.map} +1 -1
  107. package/dist/transport/custom-transport.d.ts +3 -2
  108. package/dist/transport/exit-flush.d.ts +19 -2
  109. package/dist/transport/http-transport.d.ts +6 -4
  110. package/dist/transport/retry-engine.d.ts +9 -3
  111. package/dist/transport/serializers/otlp-metrics.d.ts +3 -0
  112. package/dist/transport/serializers/otlp.d.ts +30 -0
  113. package/dist/transport/serializers/select.d.ts +20 -4
  114. package/dist/transport/status-transport.d.ts +23 -12
  115. package/dist/utils/console.d.ts +4 -1
  116. package/dist/utils/library-request.d.ts +12 -0
  117. package/package.json +1 -1
  118. package/dist/constants-Br3b89Wg.cjs +0 -2
  119. package/dist/constants-Br3b89Wg.cjs.map +0 -1
  120. package/dist/constants-DM94FjVX.js +0 -96
  121. package/dist/constants-DM94FjVX.js.map +0 -1
  122. package/dist/deadline-B5DINjD5.js.map +0 -1
  123. package/dist/deadline-Cbg2cbUw.cjs +0 -2
  124. package/dist/deadline-Cbg2cbUw.cjs.map +0 -1
  125. package/dist/indexeddb-storage-DNdf1fmL.cjs +0 -2
  126. package/dist/indexeddb-storage-DNdf1fmL.cjs.map +0 -1
  127. package/dist/indexeddb-storage-n1qkFBGA.js.map +0 -1
  128. package/dist/journey-CE2EcwHW.cjs +0 -2
  129. package/dist/journey-CE2EcwHW.cjs.map +0 -1
  130. package/dist/library-request-C9uJFlbq.cjs +0 -2
  131. package/dist/library-request-C9uJFlbq.cjs.map +0 -1
  132. package/dist/library-request-DvhuplAB.js +0 -14
  133. package/dist/library-request-DvhuplAB.js.map +0 -1
  134. package/dist/network-BAV7ipyn.cjs +0 -2
  135. package/dist/network-BAV7ipyn.cjs.map +0 -1
  136. package/dist/network-D_lloS5t.js +0 -174
  137. package/dist/network-D_lloS5t.js.map +0 -1
  138. package/dist/sampling-BI15ds9D.cjs +0 -2
  139. package/dist/sampling-BI15ds9D.cjs.map +0 -1
  140. package/dist/sampling-o0VY1mqQ.js.map +0 -1
  141. package/dist/sender-BnNj9bOX.js +0 -1050
  142. package/dist/sender-BnNj9bOX.js.map +0 -1
  143. package/dist/sender-D0OsyB1c.cjs +0 -3
  144. package/dist/sender-D0OsyB1c.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-Br3b89Wg.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./sampling-BI15ds9D.cjs"),r=require("./sanitize-DSIP7amZ.cjs"),i=require("./deadline-Cbg2cbUw.cjs"),a=require("./platform-D4wu1eIF.cjs"),o=require("./journey-CE2EcwHW.cjs");function s(t){return Math.round((performance.now()-t)*e.L)/e.L}function c(e,t,n,r,i){e.logMetric(`${t}.duration`,n,`ms`,`histogram`,{status:r,...i})}function l(e,t,n,r,i){let a=s(n);e.error(`${t} failed`,r,{"action.duration_ms":a,status:`FAILURE`,...i}),c(e,t,a,`FAILURE`,i)}function u(e,t,n,r){let i=performance.now();try{let a=n();return c(e,t,s(i),`SUCCESS`,r),a}catch(n){throw l(e,t,i,n,r),n}}async function d(e,t,n,r){let i=performance.now();try{let a=await n();return c(e,t,s(i),`SUCCESS`,r),a}catch(n){throw l(e,t,i,n,r),n}}var f=[e.T,e.in];function p(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 m(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function h(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 g(e){if(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function _(e){return f.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function v(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var y=class t{bind;namespace;options;levelType;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n,this.levelType=_(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.P,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={...v(a,this.bind().diagnostics),"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i};this.write(`INFO`,`metric`,t,o,!0)};timeSync=(e,t,n)=>u(this,e,t,n);timeAsync=(e,t,n)=>d(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:v(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.`,()=>g(r))??!1),c=s?r:i,l=s?void 0:r,u=l===void 0?void 0:p(l,a.diagnostics),d=u===void 0?void 0:m(l,u,a.diagnostics);if(!o){this.print(a,t,n,c,d,null);return}let f=u?h(l,a.diagnostics):void 0,{record:_,dropped:y}=a.builder.build({level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...v(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,_,y),a.emit(_)}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)}},b={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},x=class{settings;diagnostics;constructor(e,t){this.settings=e,this.diagnostics=t}update(e){this.settings=e}accepts(t){return this.settings.level===null||!Object.hasOwn(e.ct,this.settings.level)?!1:e.ct[t]>=e.ct[this.settings.level]}write(t,n,i,a,o){if(!this.accepts(n)||typeof console>`u`||r.a())return;let s=`%c[%s]%c[${n}]%c`,{styles:c}=this.settings,l=b[n];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${l}.`,()=>{let u=[];o!==void 0&&u.push(o),a!==void 0&&u.push(r.n(a,e.Et,this.diagnostics)),r.o(()=>{console[l](s,c.namespace,t,c[n],``,i,...u)})})}},S=class{value=0;next(){return++this.value}},ee=/^[0-9a-f]{32}$/,C=/^[0-9a-f]{16}$/,w=/[1-9a-f]/;function te(e){return ee.test(e.traceId)&&w.test(e.traceId)&&C.test(e.spanId)&&w.test(e.spanId)}function ne(){return i.l(16)}function re(){return i.l(8)}function T(){return{traceId:ne(),spanId:re(),traceFlags:1,startedAt:Date.now()}}function E(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var D=class{diagnostics;maxAgeMs;load;ambient=T();otel;constructor(t,n=e.hn,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`),E(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(te(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){return this.ambient=T(),E(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.mn]=`00-${n.traceId}-${n.spanId}-${r}`}return t}},O=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)}clear(){this.buffer=Array(this.capacity),this.pointer=0,this.filled=!1}},k=Object.keys(e.ct),ie=[`gzip`,`none`],ae=[`omit`,`same-origin`,`include`],oe=[`auto`,`indexeddb`,`localstorage`,`memory`,`none`],se=[`storage`,`memory`],ce=[`auto`,`sender`,`forwarder`,`off`],le=[`auto`,`provider`,`client`],ue=[`auto`,`context`,`tab`,`origin`],A=[`error`,`warn`,`info`,`log`],de=[`errors`,`rejections`,`resourceErrors`,`fetch`,`xhr`,`interactions`,`navigation`,`webVitals`,`longFrames`,`fullUrls`],fe=`null`,j=`a level name: ${N(k)}`,M=`true, false or a list of ${N(A)}`,pe=`a list of strings and RegExp patterns`,me=`a list of origin URLs such as "https://api.example" and RegExp patterns`,he=`a list of origin URLs such as "https://app.example". For a sandboxed frame, set bus.mode: "sender" in the frame`,ge=`a list of strings`;function N(e){let t=e.map(e=>`"${e}"`);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function P(e){return typeof e==`string`?`"${e}"`:typeof e==`function`?`a function`:typeof e==`object`&&e?`an object`:String(e)}function F(e,t,n,r,i){e.report(`config.invalid`,`${t} must be ${n}. The value is ${P(r)}. The library keeps ${i}.`)}function I(e,t,n,r,i){if(t===void 0)return r;let a=n.find(e=>e===t);return a===void 0?(F(i,e,N(n),t,`"${r}"`),r):a}function L(e,t,n,r){return t===void 0?n:typeof t==`boolean`?t:(F(r,e,`true or false`,t,String(n)),n)}function _e(e,t,n,r){return t===void 0?n:typeof t==`number`&&Number.isFinite(t)&&t>=0?t:(F(r,e,`a finite number of 0 or more`,t,String(n)),n)}function R(e){if(typeof e!=`string`)return;let t=e.toUpperCase();return k.find(e=>e===t)}function ve(e,t,n,r){if(t===void 0)return n;let i=R(t);return i===void 0?(F(r,e,j,t,`"${n}"`),n):i}function z(e,t,n,r,i,a){if(t===void 0)return n;if(!Array.isArray(t))return F(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 ${P(t)}. ${e} must be ${r}.`):o.push(n)}return o}function ye(e){return typeof e==`string`?e:void 0}function be(e){return typeof e==`string`||e instanceof RegExp?e:void 0}function xe(e){return A.find(t=>t===e)}function B(e){if(typeof e==`string`)try{let{origin:t}=new URL(e);return t===fe?void 0:t}catch{return}}function Se(e){return e instanceof RegExp?e:B(e)}function Ce(e){return typeof e!=`object`||!e||Array.isArray(e)?!1:Object.values(e).every(e=>typeof e==`string`)}function we(e,t,n){if(e!==void 0)return typeof e==`function`||Ce(e)?e:(F(n,`headers`,`an object of strings or a function`,e,`the headers in force`),t)}function Te(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function Ee(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||Te(t)?t:(r.report(`config.invalid`,`serializer must be "${e.Xt}", "ecs" or an implementation. The library uses "${e.Xt}".`),e.Xt)}var De=new Set(Object.keys(e.k));function Oe(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)De.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 ke(e,t,n){if(e===void 0)return t??`DEBUG`;let r=R(e);return r===void 0?(F(n,`console.level`,j,e,`the console level in force`),t):r}function Ae(t,n,r){if(t===void 0)return n;if(t===!1)return{level:null,styles:n.styles};if(t===!0)return{level:e.O,styles:n.styles};if(typeof t==`string`){let e=R(t);return e===void 0?(F(r,`console`,j,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:ke(t.level,n.level,r),styles:{...n.styles,...Oe(t.styles,r)}}}function je(e,t,n){let r=e??{};return{...t,...r,rates:{...t.rates,...r.rates},alwaysSampleTypes:z(`sampling.alwaysSampleTypes`,r.alwaysSampleTypes,t.alwaysSampleTypes,ge,ye,n),remote:L(`sampling.remote`,r.remote,t.remote,n)}}function Me(e,t,n){let r=e??{};return{mode:I(`bus.mode`,r.mode,ce,t.mode,n),trustedOrigins:z(`bus.trustedOrigins`,r.trustedOrigins,t.trustedOrigins,he,B,n),openFinRole:I(`bus.openFinRole`,r.openFinRole,le,t.openFinRole,n)}}function Ne(e,t,n){return{scope:I(`journey.scope`,(e??{}).scope,ue,t.scope,n)}}function Pe(e,t,n){return e===void 0?t:typeof e==`boolean`?e:Array.isArray(e)?z(`capture.console`,e,[],M,xe,n):(F(n,`capture.console`,M,e,`the value in force`),t)}function Fe(e,t,n){let r=e??{},i={...t,...r,console:Pe(r.console,t.console,n),longFrameThresholdMs:_e(`capture.longFrameThresholdMs`,r.longFrameThresholdMs,t.longFrameThresholdMs,n),ignoreUrls:z(`capture.ignoreUrls`,r.ignoreUrls,t.ignoreUrls,pe,be,n),propagateTraceHeaderTo:z(`capture.propagateTraceHeaderTo`,r.propagateTraceHeaderTo,t.propagateTraceHeaderTo,me,Se,n)};for(let e of de)i[e]=L(`capture.${e}`,r[e],t[e],n);return i}function V(t,n,r){let i=r??e.N,a={...i,...t,endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,enabled:L(`enabled`,t.enabled,i.enabled,n),minLevel:ve(`minLevel`,t.minLevel,i.minLevel,n),compression:I(`compression`,t.compression,ie,i.compression,n),credentials:I(`credentials`,t.credentials,ae,i.credentials,n),headers:`headers`in t?we(t.headers,i.headers,n):i.headers,storage:I(`storage`,t.storage,oe,i.storage,n),identity:I(`identity`,t.identity,se,i.identity,n),serializer:Ee(t.serializer,r?.serializer,n),console:Ae(t.console,i.console,n),sampling:je(t.sampling,i.sampling,n),bus:Me(t.bus,i.bus,n),journey:Ne(t.journey,i.journey,n),capture:Fe(t.capture,i.capture,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.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.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.yn}'.`),e.yn);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);return a.capture.ignoreUrls=a.capture.ignoreUrls.filter(e=>e!==r?.endpoint),a.endpoint&&!a.capture.ignoreUrls.includes(a.endpoint)&&(a.capture.ignoreUrls=[...a.capture.ignoreUrls,a.endpoint]),Ie(t,n),a}function Ie(t,n){let r=new Set([...Object.keys(e.N),...e._n]);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.D){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.N[r]),...e.vn[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 Le(t,n){for(let r of Object.keys(n))e.D.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.D)Object.assign(t[r],n[r])}var Re=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)}get(e){return this.map.get(e)}remove(e){this.map.delete(e)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},ze=class{handler;throttleMs;counters=new Map;lastEmitted=new Map;constructor(t,n=e.F){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,i,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:i,cause:a,at:s,count:o},{handler:l}=this;if(l)try{r.o(()=>{l(c)})}catch(t){this.count(`handler.threw`),typeof console<`u`&&r.o(()=>{console.warn(`${e.ut} 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)}reset(){this.counters.clear(),this.lastEmitted.clear()}},Be=`error.`,Ve=[e.f,e.s,e.c];function H(e){return e}var He=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.st.includes(n))return!0;let i=this.deps.remote.sampling?.minLevel()??r.minLevel;return e.ct[t]>=e.ct[i]}build(t){let{config:i,diagnostics:o,tracing:s,journey:c,sequence:l,limits:u,remote:d}=this.deps;if(!this.isEnabled(t.level,t.type))return o.count(`record.dropped_by_level`),{record:null,dropped:`level`};let f=s.resolve(),p=c.current();if(!n.r({level:t.level,type:t.type,namespace:t.namespace,journeyId:p?.id??``,traceId:f.traceId},i,d.sampling?.current()??null))return o.count(`record.dropped_by_sampling`),{record:null,dropped:`sampling`};let m=l.next(),h=a.t(o),g=i.capture.fullUrls?h:a.r(h),_,v=0;try{let e=r.r(this.deps.context.getAll(),u,o),n=r.r(t.scoped??{},u,o),i=r.r(t.payload??{},u,o);v=e.bytes+n.bytes+i.bytes,_={...H(e.value),...H(n.value),...H(i.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),_={[e.p]:!0}}_[e.d]=t.type,_[e.u]=m,_[e.n]=t.namespace,_[e.f]=g,p&&(_[e.s]=p.id,_[e.c]=p.name,p.parentId!==void 0&&(_[e.l]=p.parentId));let y=r.i(t.body,u.maxBodyChars);y!==t.body&&o.count(`record.truncated`);let b={timeUnixNano:n.o(),traceId:f.traceId,spanId:f.spanId,traceFlags:f.traceFlags,severityNumber:e.en[t.level],severityText:t.level,body:y,attributes:_,resource:this.resource()},x=i.redact;if(x){let t;try{t=x(b)}catch(e){return o.report(`record.dropped_by_redact`,`The redact hook threw an error. The library dropped the record.`,void 0,e),{record:null,dropped:`redact`}}if(t===null)return o.count(`record.dropped_by_redact`),{record:null,dropped:`redact`};let i=t??b;if(!n.a(i))return i===b?(o.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`}):(o.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(n.i(i.severityText)){if(i!==b){let e=r.r(i.attributes,u,o);b={...i,attributes:H(e.value)},v=e.bytes}b.severityNumber=e.en[b.severityText]}else return o.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){o.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 Ve)e in b.attributes&&(n[e]=b.attributes[e]);for(let[e,t]of Object.entries(b.attributes))e.startsWith(Be)&&(n[e]=t);let i=r.r(n,u,o).bytes;i>u.maxRecordBytes&&`error.data`in n&&(Reflect.deleteProperty(n,e.o),i=r.r(n,u,o).bytes);let a=b.attributes[e.a];if(a!==void 0){let t=r.r(a,u,o).bytes;i+t<=u.maxRecordBytes&&(n[e.a]=a)}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.Lt]:t.serviceName,[e.Rt]:t.serviceVersion,[e.Nt]:t.environment,[e.Ht]:e.fn,[e.Ut]:e.pn,[e.Vt]:e.dn,[e.Pt]:r.platform,[e.zt]:n.sessionId,[e.Bt]:n.tabId,[e.Mt]:n.contextId,[e.jt]:r.userAgent,...r.openfinUuid===void 0?{}:{[e.It]:r.openfinUuid},...r.openfinName===void 0?{}:{[e.Ft]:r.openfinName}},this.resourceCache}},Ue={errors:async()=>(await Promise.resolve().then(()=>require("./errors-CpGRhhIf.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-BAV7ipyn.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-31eHGwEQ.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-DFuoTQbZ.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-B8VdA_ny.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-BpHfWstv.cjs"))).ConsoleCapture},U=Symbol.for(e.qt),W=Symbol.for(e.Jt);function G(e){return JSON.stringify({...e,webVitalsLoader:e.webVitalsLoader!==void 0,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String)})}function K(e){return{...e,endpoint:null,transport:void 0,transportOnExit:void 0,bus:{...e.bus,mode:`off`}}}function q(t){return t.sdkVersion===e.pn}var J=class t{degraded;static local=null;sdkVersion=e.pn;diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new Re;breadcrumbs;tracing;sequence=new S;journey;builder;remote={sampling:null};console;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=[];captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1};bootBuffer=[];forwardBuffer=[];forwardScheduled=!1;roleResolved=!1;started=Promise.resolve();ready=!1;destroyed=!1;lastGapAt=0;constructor(t,n=!1){this.degraded=n,this.diagnostics=new ze(t.onDiagnostic),this.platform=a.n(this.diagnostics),this.config=V(t,this.diagnostics),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`?i.o():i.i,this.identity=i.u(this.diagnostics,this.stores),this.sessionTouch=new i.a(this.diagnostics,this.stores),this.breadcrumbs=new O(50),this.tracing=new D(this.diagnostics,void 0,this.config.otelLoader),this.tracing.loadOtel(),this.console=new x(this.config.console,this.diagnostics),this.journey=new o.n(o.t,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new He({remote:this.remote,config:this.config,limits:e.Et,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform})}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[U]??null}static current(){let e=t.local;if(e)return e.destroyed?null:e;let n=t.pinned();return n&&q(n)?n:null}static stopped(){let e=t.local;if(e?.destroyed)return e;let n=globalThis[W];return n&&q(n)?n:null}isDestroyed(){return this.destroyed}static configure(e){let n=t.local;if(n&&!n.destroyed)return n.reconfigure(K(e)),n;t.local=null;let r=t.pinned();if(r){if(!q(r))return t.startDegraded(e,r.sdkVersion);if(!r.destroyed)return r.reconfigure(e),r}let i=new t(e);return globalThis[U]=i,Reflect.deleteProperty(globalThis,W),i.init(),i}static startDegraded(n,r){let i=new t(K(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.pn}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:a,own:e.pn}),i.init(),i}reconfigure(e){let t=this.keepDestination(e),n=G(this.config.capture);Le(this.config,V(t,this.diagnostics,this.config)),this.diagnostics.setHandler(this.config.onDiagnostic),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),G(this.config.capture)!==n&&this.installCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}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-CtJWf9QN.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.config.endpoint||this.config.transport!==void 0)||this.role()!==`sender`?Promise.resolve():this.loadSender()}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-D0OsyB1c.cjs")),t=this.destroyed?null:await e.create({config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,remote:this.remote});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)}let e=this.pendingRecords;this.pendingRecords=[];for(let t of e)this.sender?.push(t)}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 y(()=>this,e.T),once:this.captureOnce};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.`,Ue[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.destroyed=!0,this.uninstallCaptures();let e=this.sender?.destroy();this.journey.destroy(),this.bus?.destroy(),this.forwardBuffer=[],this.pendingRecords=[],await e,await this.senderLoad,t.pinned()===this&&(Reflect.deleteProperty(globalThis,U),globalThis[W]=this)}emit(e){e&&!this.destroyed&&(this.sessionTouch.touch(this.identity.sessionId),this.ready?this.route(e):this.pushCapped(this.bootBuffer,e))}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){this.sender?this.sender.push(e):this.senderLoad?this.pushCapped(this.pendingRecords,e):this.diagnostics.count(`record.dropped_no_destination`)}pushCapped(e,t){e.length>=500&&(e.shift(),this.diagnostics.count(`record.dropped_boot_buffer_full`)),e.push(t)}forward(e){this.forwardBuffer.push(e),!this.forwardScheduled&&(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1;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)n.a(t)?n.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;this.bootBuffer=[];let 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)}reportGap=t=>{let n=Date.now();n-this.lastGapAt<6e4||(this.lastGapAt=n,new y(()=>this,e.in).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let e=i.s(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,i.c(e,this.diagnostics,this.stores),this.builder.invalidateResource()}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){if(this.ready||await this.started,this.role()===`forwarder`){let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus?.sendRecords(e)}else await this.senderLoad,await this.sender?.flush()}};function We(){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 Y=new Map;function X(){return(J.current()??J.stopped())||J.configure({})}function Ge(e){J.configure(e)}function Z(e,t){if(t)return new y(X,e,t);let n=Y.get(e);return n||(n=new y(X,e),Y.set(e,n)),n}function Q(){return Z(`app`)}function Ke(e,t){Q().trace(e,t)}function qe(e,t){Q().debug(e,t)}function Je(e,t){Q().info(e,t)}function Ye(e,t){Q().warn(e,t)}function Xe(e,t,n){Q().error(e,t,n)}function Ze(e,t,n){Q().fatal(e,t,n)}function Qe(e,t){Q().logAction(e,t)}function $e(e,t){Q().logEvent(e,t)}function et(e,t,n,r,i){Q().logMetric(e,t,n,r,i)}function tt(e,t,n){return Q().timeSync(e,t,n)}function $(e,t,n){return Q().timeAsync(e,t,n)}function nt(e,t){X().context.set(e,t)}function rt(e){X().context.setMany(e)}function it(e){X().context.remove(e)}function at(e,t){return X().journey.start(e,t)}function ot(){X().journey.end()}function st(){return X().journey.current()}function ct(){return X().journey.getToken()}function lt(e){return X().journey.adopt(e,`manual`,!0)}function ut(e){X().registerWorker(e)}function dt(){X().tracing.rotate(`explicit`)}function ft(){return X().tracing.headers()}function pt(){return X().flush()}function mt(){return X().queueDepth()}function ht(){return X().diagnostics.snapshot()}async function gt(){await J.current()?.destroy()}exports.OneLogger=y,exports.adoptJourney=lt,exports.configure=Ge,exports.createMemoryTransport=We,exports.currentJourney=st,exports.debug=qe,exports.endJourney=ot,exports.error=Xe,exports.fatal=Ze,exports.flush=pt,exports.getDiagnosticCounters=ht,exports.getJourneyToken=ct,exports.getLogger=Z,exports.getQueueDepth=mt,exports.getTraceHeaders=ft,exports.info=Je,exports.logAction=Qe,exports.logEvent=$e,exports.logMetric=et,exports.registerWorker=ut,exports.removeContext=it,exports.setContext=nt,exports.setContextMap=rt,exports.shutdown=gt,exports.startJourney=at,exports.startTrace=dt,exports.timeAsync=$,exports.timeSync=tt,exports.trace=Ke,exports.warn=Ye;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-Be83LICb.cjs"),t=require("./error-like-gGRx2s36.cjs"),n=require("./sampling-MthcVXXU.cjs"),r=require("./sanitize-BqzPc4Jg.cjs"),i=require("./identity-DXyV86o-.cjs"),a=require("./platform-DNOJjpOm.cjs"),o=require("./batch-cys7e53Q.cjs"),s=require("./library-request-BIG3Xpx3.cjs"),c=require("./deadline-XSnm95pg.cjs"),l=require("./journey-BGSyy8Es.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(typeof e!=`object`||!e||Array.isArray(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,i,a){if(!this.accepts(t)||typeof console>`u`||r.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),i!==void 0&&l.push(r.n(i,this.limits,this.diagnostics)),r.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 i.o(16)}function se(){return i.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)}clear(){this.buffer=Array(this.capacity),this.pointer=0,this.filled=!1}},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 typeof e!=`object`||!e||Array.isArray(e)?!1:Object.values(e).every(e=>typeof e==`string`)}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)}get(e){return this.map.get(e)}remove(e){this.map.delete(e)}clear(){this.map.clear()}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,i,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:i,cause:a,at:s,count:o},{handler:l}=this;if(l)try{r.o(()=>{l(c)})}catch(t){this.count(`handler.threw`),typeof console<`u`&&r.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)}reset(){this.counters.clear(),this.lastEmitted.clear()}};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=o.t(t,e.s);typeof n==`string`&&V(i.journeyIds,n);let r=o.n(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.`,()=>{s.r(()=>{r.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=o.n(e);if((t?this.actions:this.held.length-this.actions)<(t?2e3:500))this.actions+=+!!t;else{let e=this.held.findIndex(e=>o.n(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()),c.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:i,diagnostics:o,tracing:s,journey:c,sequence:l,limits:u,remote:d}=this.deps;if(!this.isEnabled(t.level,t.type))return o.count(`record.dropped_by_level`),{record:null,dropped:`level`};let f=s.resolve(),p=c.current();if(!n.r({level:t.level,type:t.type,namespace:t.namespace,journeyId:p?.id??``,traceId:f.traceId,aggregated:t.aggregated},i,d.sampling?.current()??null))return o.count(`record.dropped_by_sampling`),{record:null,dropped:`sampling`};let m=l.next(),h=a.t(o),g=i.capture.fullUrls?h:a.r(h),_,v=0;try{let e=r.r(this.deps.context.getAll(),u,o),n=r.r(t.scoped??{},u,o),i=r.r(t.payload??{},u,o);v=e.bytes+n.bytes+i.bytes,_={...U(e.value),...U(n.value),...U(i.value)}}catch(t){o.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=r.i(t.body,u.maxBodyChars);y!==t.body&&o.count(`record.truncated`);let b={timeUnixNano:n.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=i.redact;if(x){let i;try{i=x(b)}catch(e){return o.report(`record.dropped_by_redact`,`The redact hook threw an error. The library dropped the record.`,void 0,e),{record:null,dropped:`redact`}}if(i===null)return o.count(`record.dropped_by_redact`),{record:null,dropped:`redact`};let a=i??b;if(!n.a(a))return a===b?(o.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`}):(o.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(n.i(a.severityText)){if(a!==b){let e=r.r(a.attributes,u,o);b={...a,attributes:U(e.value)},v=e.bytes,Object.assign(b.attributes,t.fixed)}b.severityNumber=e.in[b.severityText]}else return o.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){o.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 i=r.r(n,u,o).bytes;i>u.maxRecordBytes&&`error.data`in n&&(Reflect.deleteProperty(n,e.o),i=r.r(n,u,o).bytes);let a=b.attributes[e.a];if(a!==void 0){let t=r.r(a,u,o).bytes;i+t<=u.maxRecordBytes&&(n[e.a]=a)}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-BMJm7KZZ.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-C6kJbW6K.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-BAGRmtrv.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-DFuoTQbZ.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-Cq2LgNnp.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-ChfuJlf9.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=a.n(this.diagnostics),this.config=B(e,this.diagnostics),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`?i.r():i.t,this.identity=i.s(this.diagnostics,this.stores),this.sessionTouch=new i.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-B6vzPmQM.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-SPGMqZjD.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)n.a(t)?n.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=i.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,i.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;
2
2
  //# sourceMappingURL=index.cjs.map