@utk09/ui-observability 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -1
- package/README.md +323 -113
- package/bin/uiobs.mjs +1 -1
- package/dist/{batch-BMdT9mKm.js → batch-BjQUwjA6.js} +5 -6
- package/dist/batch-BjQUwjA6.js.map +1 -0
- package/dist/{batch-BHXypM1j.cjs → batch-D5LlU4Q9.cjs} +2 -2
- package/dist/batch-D5LlU4Q9.cjs.map +1 -0
- package/dist/bus/bus.d.ts +48 -47
- package/dist/bus/links.d.ts +4 -4
- package/dist/bus/validation.d.ts +1 -1
- package/dist/bus-D_7pd7RN.cjs +2 -0
- package/dist/bus-D_7pd7RN.cjs.map +1 -0
- package/dist/{bus-DKfBaica.js → bus-ecxUNTja.js} +105 -109
- package/dist/bus-ecxUNTja.js.map +1 -0
- package/dist/capture/console.d.ts +10 -10
- package/dist/capture/errors.d.ts +6 -6
- package/dist/capture/interactions.d.ts +14 -14
- package/dist/capture/lifecycle.d.ts +3 -3
- package/dist/capture/long-frames.d.ts +6 -6
- package/dist/capture/network.d.ts +17 -17
- package/dist/capture/profiler-frames.d.ts +44 -0
- package/dist/capture/replay-buffer.d.ts +46 -0
- package/dist/capture/replay-upload.d.ts +74 -0
- package/dist/capture/replay.d.ts +114 -0
- package/dist/capture/reports.d.ts +2 -2
- package/dist/capture/resource-timing.d.ts +1 -1
- package/dist/capture/server-timing.d.ts +3 -3
- package/dist/capture/storm.d.ts +3 -3
- package/dist/capture/types.d.ts +45 -33
- package/dist/capture/unclean-exit.d.ts +8 -8
- package/dist/capture/user-timing.d.ts +3 -3
- package/dist/capture/web-socket.d.ts +11 -11
- package/dist/capture/web-vitals.d.ts +20 -7
- package/dist/compression-AJJCMBOa.js +11 -0
- package/dist/compression-AJJCMBOa.js.map +1 -0
- package/dist/compression-lD9abCcO.cjs +2 -0
- package/dist/compression-lD9abCcO.cjs.map +1 -0
- package/dist/console-CLz_PvFn.cjs +2 -0
- package/dist/console-CLz_PvFn.cjs.map +1 -0
- package/dist/{console-BX_0UCV7.js → console-cwgHKXvM.js} +14 -15
- package/dist/console-cwgHKXvM.js.map +1 -0
- package/dist/constants-Bwl_YtQi.js +349 -0
- package/dist/constants-Bwl_YtQi.js.map +1 -0
- package/dist/constants-DakMxVB2.cjs +2 -0
- package/dist/constants-DakMxVB2.cjs.map +1 -0
- package/dist/constants.d.ts +150 -103
- package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
- package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
- package/dist/context-storage-BzkoHzkQ.js.map +1 -0
- package/dist/core/breadcrumbs.d.ts +16 -15
- package/dist/core/config.d.ts +3 -3
- package/dist/core/context.d.ts +7 -7
- package/dist/core/debug-buffer.d.ts +10 -10
- package/dist/core/debug-bundle.d.ts +3 -3
- package/dist/core/deferred.d.ts +2 -2
- package/dist/core/diagnostics.d.ts +24 -21
- package/dist/core/drops.d.ts +7 -7
- package/dist/core/hold-buffer.d.ts +1 -1
- package/dist/core/journey.d.ts +22 -23
- package/dist/core/logger.d.ts +22 -21
- package/dist/core/measure.d.ts +7 -7
- package/dist/core/meter.d.ts +25 -21
- package/dist/core/pipeline.d.ts +42 -41
- package/dist/core/profile-buckets.d.ts +31 -0
- package/dist/core/profiler.d.ts +218 -0
- package/dist/core/record.d.ts +23 -23
- package/dist/core/remote-rules.d.ts +4 -4
- package/dist/core/remote-sampling.d.ts +21 -20
- package/dist/core/runtime.d.ts +206 -137
- package/dist/core/sampling.d.ts +18 -18
- package/dist/core/sender.d.ts +22 -20
- package/dist/core/spans.d.ts +5 -5
- package/dist/{deadline-5_PecIl5.js → deadline-C4ccAuk5.js} +4 -9
- package/dist/deadline-C4ccAuk5.js.map +1 -0
- package/dist/deadline-CUGbto-y.cjs +2 -0
- package/dist/deadline-CUGbto-y.cjs.map +1 -0
- package/dist/{debug-bundle-CZZ6SQQh.js → debug-bundle-BOdYmCeV.js} +12 -6
- package/dist/debug-bundle-BOdYmCeV.js.map +1 -0
- package/dist/debug-bundle-Ex4L_LSP.cjs +2 -0
- package/dist/debug-bundle-Ex4L_LSP.cjs.map +1 -0
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.cjs.map +1 -1
- package/dist/doctor.d.ts +16 -6
- package/dist/doctor.js +148 -54
- package/dist/doctor.js.map +1 -1
- package/dist/{emergency-queue-Cs8-i2xw.js → emergency-queue-B9WZxanZ.js} +15 -17
- package/dist/emergency-queue-B9WZxanZ.js.map +1 -0
- package/dist/{emergency-queue-CQ-9acZf.cjs → emergency-queue-HBpL5r3V.cjs} +2 -2
- package/dist/emergency-queue-HBpL5r3V.cjs.map +1 -0
- package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
- package/dist/error-like-B11pB4aL.js.map +1 -0
- package/dist/error-like-gGRx2s36.cjs.map +1 -1
- package/dist/{errors-oyxrpHjY.js → errors-D6bwgJtO.js} +5 -6
- package/dist/errors-D6bwgJtO.js.map +1 -0
- package/dist/{errors-CigX45pL.cjs → errors-DCOCRdSi.cjs} +2 -2
- package/dist/errors-DCOCRdSi.cjs.map +1 -0
- package/dist/{factory-BkjNzPYL.cjs → factory-DLFDjdLv.cjs} +2 -2
- package/dist/factory-DLFDjdLv.cjs.map +1 -0
- package/dist/{factory-Bgsky_e0.js → factory-e9Qo3K0z.js} +18 -22
- package/dist/factory-e9Qo3K0z.js.map +1 -0
- package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
- package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
- package/dist/fixed-window-Dq3MLUUv.js.map +1 -0
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
- package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
- package/dist/global-scope-D9I8s-oN.js.map +1 -0
- package/dist/{guards-CpvOpJL6.js → guards-Cidk71ME.js} +2 -3
- package/dist/guards-Cidk71ME.js.map +1 -0
- package/dist/guards-nJ70syPt.cjs.map +1 -1
- package/dist/{identity-BMlKGHUM.cjs → identity-BlvlgjrU.cjs} +2 -2
- package/dist/identity-BlvlgjrU.cjs.map +1 -0
- package/dist/{identity-DOaHdfhT.js → identity-BrQp_5J5.js} +20 -21
- package/dist/identity-BrQp_5J5.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +112 -79
- package/dist/index.js +797 -659
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-CaXGJqDD.cjs → indexeddb-storage-CtLvZH1r.cjs} +2 -2
- package/dist/indexeddb-storage-CtLvZH1r.cjs.map +1 -0
- package/dist/{indexeddb-storage-D-lUW_5P.js → indexeddb-storage-DLXQzAGh.js} +5 -6
- package/dist/indexeddb-storage-DLXQzAGh.js.map +1 -0
- package/dist/{interactions-CqDNrtIR.js → interactions-B6z2I4tU.js} +10 -11
- package/dist/interactions-B6z2I4tU.js.map +1 -0
- package/dist/{interactions-8DgxtmgO.cjs → interactions-P6pz08Jn.cjs} +2 -2
- package/dist/interactions-P6pz08Jn.cjs.map +1 -0
- package/dist/{journey-DgIjhrIc.js → journey-35yCMNFo.js} +21 -21
- package/dist/journey-35yCMNFo.js.map +1 -0
- package/dist/journey-DAGh5h9k.cjs +2 -0
- package/dist/journey-DAGh5h9k.cjs.map +1 -0
- package/dist/keys-BHhw_0Wh.cjs.map +1 -1
- package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
- package/dist/keys-BU9j5YqW.js.map +1 -0
- package/dist/{library-console-g_VU-wzP.cjs → library-console-BFWEuQsl.cjs} +2 -2
- package/dist/library-console-BFWEuQsl.cjs.map +1 -0
- package/dist/library-console-Dl_Ly6DQ.js +13 -0
- package/dist/library-console-Dl_Ly6DQ.js.map +1 -0
- package/dist/{library-request-FQaiWjCP.cjs → library-request-Da-CHKzT.cjs} +2 -2
- package/dist/library-request-Da-CHKzT.cjs.map +1 -0
- package/dist/{library-request-CyC-9IOk.js → library-request-nI6pvI6I.js} +4 -5
- package/dist/library-request-nI6pvI6I.js.map +1 -0
- package/dist/{lifecycle-C2z_d8OX.cjs → lifecycle-BGGOcN4N.cjs} +2 -2
- package/dist/lifecycle-BGGOcN4N.cjs.map +1 -0
- package/dist/{lifecycle-BLC4VU7c.js → lifecycle-CZ6RRXc6.js} +3 -4
- package/dist/lifecycle-CZ6RRXc6.js.map +1 -0
- package/dist/{log-record-DKvo-B-d.cjs → log-record-D7bA1RPb.cjs} +2 -2
- package/dist/log-record-D7bA1RPb.cjs.map +1 -0
- package/dist/{log-record-CndanC-p.js → log-record-DIA6McNr.js} +3 -4
- package/dist/log-record-DIA6McNr.js.map +1 -0
- package/dist/{long-frames-BQef9rXR.js → long-frames-430_85Da.js} +9 -8
- package/dist/long-frames-430_85Da.js.map +1 -0
- package/dist/long-frames-Dd8tsi2U.cjs +2 -0
- package/dist/long-frames-Dd8tsi2U.cjs.map +1 -0
- package/dist/models/batch.d.ts +14 -15
- package/dist/models/bus.d.ts +24 -24
- package/dist/models/config.d.ts +402 -216
- package/dist/models/drop.d.ts +13 -11
- package/dist/models/health.d.ts +13 -13
- package/dist/models/log-record.d.ts +13 -14
- package/dist/models/metric.d.ts +82 -17
- package/dist/models/plugin.d.ts +13 -13
- package/dist/models/replay.d.ts +60 -0
- package/dist/models/serializer.d.ts +2 -3
- package/dist/models/stats.d.ts +2 -2
- package/dist/models/storage.d.ts +12 -11
- package/dist/{network-CvkvYzRU.js → network-C7SkLf4v.js} +30 -32
- package/dist/network-C7SkLf4v.js.map +1 -0
- package/dist/{network-CqnQOqon.cjs → network-pEX3PAJv.cjs} +2 -2
- package/dist/network-pEX3PAJv.cjs.map +1 -0
- package/dist/openfin-Bxelt0yg.js +7 -0
- package/dist/openfin-Bxelt0yg.js.map +1 -0
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/otlp-2MCrC3kd.cjs +2 -0
- package/dist/otlp-2MCrC3kd.cjs.map +1 -0
- package/dist/{otlp-CYIL7MOE.js → otlp-COq033e3.js} +26 -35
- package/dist/otlp-COq033e3.js.map +1 -0
- package/dist/patch-BX8KrPCT.cjs.map +1 -1
- package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
- package/dist/patch-UdPz1ea8.js.map +1 -0
- package/dist/{platform-KMWkoI-v.cjs → platform-12uR7kBQ.cjs} +2 -2
- package/dist/platform-12uR7kBQ.cjs.map +1 -0
- package/dist/{platform-wcAkkv9F.js → platform-CVewe4wQ.js} +9 -10
- package/dist/platform-CVewe4wQ.js.map +1 -0
- package/dist/profiler-BVWIOgnq.js +310 -0
- package/dist/profiler-BVWIOgnq.js.map +1 -0
- package/dist/profiler-eVCknCzS.cjs +2 -0
- package/dist/profiler-eVCknCzS.cjs.map +1 -0
- package/dist/profiler-frames-CLXlT_xL.js +86 -0
- package/dist/profiler-frames-CLXlT_xL.js.map +1 -0
- package/dist/profiler-frames-Dg2OebB2.cjs +2 -0
- package/dist/profiler-frames-Dg2OebB2.cjs.map +1 -0
- package/dist/{remote-rules-CH_7PphT.js → remote-rules-BJGDJGwA.js} +29 -30
- package/dist/remote-rules-BJGDJGwA.js.map +1 -0
- package/dist/{remote-rules-BL8km4xk.cjs → remote-rules-CJD3ToVk.cjs} +2 -2
- package/dist/remote-rules-CJD3ToVk.cjs.map +1 -0
- package/dist/replay-0zAJv9T3.js +338 -0
- package/dist/replay-0zAJv9T3.js.map +1 -0
- package/dist/replay-DomJpXqW.cjs +2 -0
- package/dist/replay-DomJpXqW.cjs.map +1 -0
- package/dist/{reports-Bh_-KpZ2.cjs → reports-BsbqmP8h.cjs} +2 -2
- package/dist/reports-BsbqmP8h.cjs.map +1 -0
- package/dist/{reports-BOKyY3_A.js → reports-BuXekPOS.js} +4 -5
- package/dist/reports-BuXekPOS.js.map +1 -0
- package/dist/{resource-timing-BROnEJ0E.js → resource-timing-CXGHwFRD.js} +6 -7
- package/dist/resource-timing-CXGHwFRD.js.map +1 -0
- package/dist/{resource-timing-CbgwNpog.cjs → resource-timing-DkycFGDa.cjs} +2 -2
- package/dist/resource-timing-DkycFGDa.cjs.map +1 -0
- package/dist/{sampling-ECGVYiDD.cjs → sampling-Dd0wllyq.cjs} +2 -2
- package/dist/sampling-Dd0wllyq.cjs.map +1 -0
- package/dist/{sampling-BLO_pcV4.js → sampling-UUDbi3K0.js} +11 -12
- package/dist/sampling-UUDbi3K0.js.map +1 -0
- package/dist/{sanitize-DS0G4_ea.js → sanitize-CNmsD9r3.js} +4 -5
- package/dist/sanitize-CNmsD9r3.js.map +1 -0
- package/dist/{sanitize-Bsn8HQWC.cjs → sanitize-ChLn97Ch.cjs} +2 -2
- package/dist/sanitize-ChLn97Ch.cjs.map +1 -0
- package/dist/{select-DWO0-w8_.cjs → select-CTk-K5mG.cjs} +3 -3
- package/dist/select-CTk-K5mG.cjs.map +1 -0
- package/dist/{select-wqt9Wxio.js → select-DPv_j6wq.js} +64 -67
- package/dist/select-DPv_j6wq.js.map +1 -0
- package/dist/{sender-BkAVt-Rq.js → sender-15zEsZpr.js} +98 -101
- package/dist/sender-15zEsZpr.js.map +1 -0
- package/dist/sender-Bfpv9tad.cjs +2 -0
- package/dist/sender-Bfpv9tad.cjs.map +1 -0
- package/dist/storage/context-storage.d.ts +34 -33
- package/dist/storage/emergency-queue.d.ts +9 -9
- package/dist/storage/eviction.d.ts +12 -12
- package/dist/storage/factory.d.ts +8 -7
- package/dist/storage/gap.d.ts +6 -6
- package/dist/storage/idb-driver.d.ts +31 -32
- package/dist/storage/indexeddb-storage.d.ts +26 -27
- package/dist/storage/keys.d.ts +7 -7
- package/dist/storage/local-storage.d.ts +38 -38
- package/dist/storage/memory-storage.d.ts +21 -22
- package/dist/storage/persistence.d.ts +1 -1
- package/dist/storage-BA9RqRO-.cjs.map +1 -1
- package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
- package/dist/storage-DZwed89z.js.map +1 -0
- package/dist/{storm-DD4cUkoL.js → storm-BTSNTIWI.js} +4 -5
- package/dist/storm-BTSNTIWI.js.map +1 -0
- package/dist/{storm-DCEsqViG.cjs → storm-D0_qZOEg.cjs} +2 -2
- package/dist/storm-D0_qZOEg.cjs.map +1 -0
- package/dist/transport/compression.d.ts +2 -2
- package/dist/transport/errors.d.ts +7 -7
- package/dist/transport/exit-flush.d.ts +39 -39
- package/dist/transport/headers.d.ts +2 -2
- package/dist/transport/http-transport.d.ts +28 -27
- package/dist/transport/memory-transport.d.ts +6 -6
- package/dist/transport/retry-engine.d.ts +35 -34
- package/dist/transport/serializers/ecs.d.ts +1 -1
- package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
- package/dist/transport/serializers/otlp-traces.d.ts +1 -1
- package/dist/transport/serializers/otlp.d.ts +16 -16
- package/dist/transport/serializers/select.d.ts +7 -7
- package/dist/transport/status-transport.d.ts +20 -20
- package/dist/transport/worker-protocol.d.ts +3 -3
- package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
- package/dist/types-BAerHgCq.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-CwdpbUDg.cjs → unclean-exit-ClGzrc2A.cjs} +2 -2
- package/dist/unclean-exit-ClGzrc2A.cjs.map +1 -0
- package/dist/{unclean-exit-BYZ5yaSI.js → unclean-exit-Cob_jyTv.js} +3 -4
- package/dist/unclean-exit-Cob_jyTv.js.map +1 -0
- package/dist/unref-CU9Nyz_9.cjs +2 -0
- package/dist/unref-CU9Nyz_9.cjs.map +1 -0
- package/dist/unref-DgHPQeWv.js +7 -0
- package/dist/unref-DgHPQeWv.js.map +1 -0
- package/dist/user-timing-CdYqx3PF.cjs +2 -0
- package/dist/user-timing-CdYqx3PF.cjs.map +1 -0
- package/dist/{user-timing-Di2ra5DB.js → user-timing-DgHubxCI.js} +7 -6
- package/dist/user-timing-DgHubxCI.js.map +1 -0
- package/dist/utils/console.d.ts +2 -2
- package/dist/utils/deadline.d.ts +4 -4
- package/dist/utils/error-like.d.ts +7 -7
- package/dist/utils/fixed-window.d.ts +9 -8
- package/dist/utils/global-scope.d.ts +8 -8
- package/dist/utils/guards.d.ts +2 -2
- package/dist/utils/identity.d.ts +17 -17
- package/dist/utils/library-console.d.ts +4 -4
- package/dist/utils/library-request.d.ts +10 -10
- package/dist/utils/lock.d.ts +10 -9
- package/dist/utils/openfin.d.ts +5 -5
- package/dist/utils/patch.d.ts +6 -6
- package/dist/utils/platform.d.ts +13 -11
- package/dist/utils/sanitize.d.ts +4 -4
- package/dist/utils/timer.d.ts +1 -1
- package/dist/utils/tracing.d.ts +38 -38
- package/dist/utils/unref.d.ts +3 -3
- package/dist/{web-socket-DwBNhgre.cjs → web-socket-BTuvYoJI.cjs} +2 -2
- package/dist/web-socket-BTuvYoJI.cjs.map +1 -0
- package/dist/{web-socket-B-5qqPy7.js → web-socket-DthJuSAg.js} +14 -15
- package/dist/web-socket-DthJuSAg.js.map +1 -0
- package/dist/web-vitals-Ch5BpDmo.cjs +2 -0
- package/dist/web-vitals-Ch5BpDmo.cjs.map +1 -0
- package/dist/web-vitals-CsGCWnUr.js +77 -0
- package/dist/web-vitals-CsGCWnUr.js.map +1 -0
- package/dist/{worker-protocol-0HMf4-kY.js → worker-protocol-B0_8rWy5.js} +6 -7
- package/dist/worker-protocol-B0_8rWy5.js.map +1 -0
- package/dist/{worker-protocol-DXekoADQ.cjs → worker-protocol-BjzFORfq.cjs} +2 -2
- package/dist/worker-protocol-BjzFORfq.cjs.map +1 -0
- package/dist/worker-server-4en-Lt-3.cjs +2 -0
- package/dist/worker-server-4en-Lt-3.cjs.map +1 -0
- package/dist/{worker-server-CKcmX5m5.js → worker-server-Cne9MX9I.js} +25 -26
- package/dist/{worker-server-CKcmX5m5.js.map → worker-server-Cne9MX9I.js.map} +1 -1
- package/dist/worker-transport-B-GF4Aqn.cjs +2 -0
- package/dist/worker-transport-B-GF4Aqn.cjs.map +1 -0
- package/dist/{worker-transport-2220ghFZ.js → worker-transport-C3SjJAEC.js} +64 -65
- package/dist/worker-transport-C3SjJAEC.js.map +1 -0
- package/package.json +33 -41
- package/dist/batch-BHXypM1j.cjs.map +0 -1
- package/dist/batch-BMdT9mKm.js.map +0 -1
- package/dist/bus-DKfBaica.js.map +0 -1
- package/dist/bus-Dea9rVhy.cjs +0 -2
- package/dist/bus-Dea9rVhy.cjs.map +0 -1
- package/dist/console-BX_0UCV7.js.map +0 -1
- package/dist/console-DZEcs7FL.cjs +0 -2
- package/dist/console-DZEcs7FL.cjs.map +0 -1
- package/dist/constants-CL0ZdI2f.cjs +0 -2
- package/dist/constants-CL0ZdI2f.cjs.map +0 -1
- package/dist/constants-CU60FG4w.js +0 -305
- package/dist/constants-CU60FG4w.js.map +0 -1
- package/dist/context-storage-DxZf4Gfh.js.map +0 -1
- package/dist/deadline-5_PecIl5.js.map +0 -1
- package/dist/deadline-XSnm95pg.cjs +0 -2
- package/dist/deadline-XSnm95pg.cjs.map +0 -1
- package/dist/debug-bundle-CZZ6SQQh.js.map +0 -1
- package/dist/debug-bundle-yRkrU1ny.cjs +0 -2
- package/dist/debug-bundle-yRkrU1ny.cjs.map +0 -1
- package/dist/emergency-queue-CQ-9acZf.cjs.map +0 -1
- package/dist/emergency-queue-Cs8-i2xw.js.map +0 -1
- package/dist/error-like-Ywo5uRHo.js.map +0 -1
- package/dist/errors-CigX45pL.cjs.map +0 -1
- package/dist/errors-oyxrpHjY.js.map +0 -1
- package/dist/factory-Bgsky_e0.js.map +0 -1
- package/dist/factory-BkjNzPYL.cjs.map +0 -1
- package/dist/fixed-window-CtaFHanJ.js.map +0 -1
- package/dist/global-scope-dp2jADRl.js.map +0 -1
- package/dist/guards-CpvOpJL6.js.map +0 -1
- package/dist/identity-BMlKGHUM.cjs.map +0 -1
- package/dist/identity-DOaHdfhT.js.map +0 -1
- package/dist/indexeddb-storage-CaXGJqDD.cjs.map +0 -1
- package/dist/indexeddb-storage-D-lUW_5P.js.map +0 -1
- package/dist/interactions-8DgxtmgO.cjs.map +0 -1
- package/dist/interactions-CqDNrtIR.js.map +0 -1
- package/dist/journey-5tcxEbnG.cjs +0 -2
- package/dist/journey-5tcxEbnG.cjs.map +0 -1
- package/dist/journey-DgIjhrIc.js.map +0 -1
- package/dist/keys-D5r_GH9q.js.map +0 -1
- package/dist/library-console-CabK2j2-.js +0 -14
- package/dist/library-console-CabK2j2-.js.map +0 -1
- package/dist/library-console-g_VU-wzP.cjs.map +0 -1
- package/dist/library-request-CyC-9IOk.js.map +0 -1
- package/dist/library-request-FQaiWjCP.cjs.map +0 -1
- package/dist/lifecycle-BLC4VU7c.js.map +0 -1
- package/dist/lifecycle-C2z_d8OX.cjs.map +0 -1
- package/dist/log-record-CndanC-p.js.map +0 -1
- package/dist/log-record-DKvo-B-d.cjs.map +0 -1
- package/dist/long-frames-BQef9rXR.js.map +0 -1
- package/dist/long-frames-CV5ZG2cx.cjs +0 -2
- package/dist/long-frames-CV5ZG2cx.cjs.map +0 -1
- package/dist/network-CqnQOqon.cjs.map +0 -1
- package/dist/network-CvkvYzRU.js.map +0 -1
- package/dist/openfin-BwEN0uj4.js +0 -8
- package/dist/openfin-BwEN0uj4.js.map +0 -1
- package/dist/otlp-CYIL7MOE.js.map +0 -1
- package/dist/otlp-RVbkNQRh.cjs +0 -2
- package/dist/otlp-RVbkNQRh.cjs.map +0 -1
- package/dist/patch-CCWfuEY7.js.map +0 -1
- package/dist/platform-KMWkoI-v.cjs.map +0 -1
- package/dist/platform-wcAkkv9F.js.map +0 -1
- package/dist/remote-rules-BL8km4xk.cjs.map +0 -1
- package/dist/remote-rules-CH_7PphT.js.map +0 -1
- package/dist/reports-BOKyY3_A.js.map +0 -1
- package/dist/reports-Bh_-KpZ2.cjs.map +0 -1
- package/dist/resource-timing-BROnEJ0E.js.map +0 -1
- package/dist/resource-timing-CbgwNpog.cjs.map +0 -1
- package/dist/sampling-BLO_pcV4.js.map +0 -1
- package/dist/sampling-ECGVYiDD.cjs.map +0 -1
- package/dist/sanitize-Bsn8HQWC.cjs.map +0 -1
- package/dist/sanitize-DS0G4_ea.js.map +0 -1
- package/dist/select-DWO0-w8_.cjs.map +0 -1
- package/dist/select-wqt9Wxio.js.map +0 -1
- package/dist/sender-BkAVt-Rq.js.map +0 -1
- package/dist/sender-D82PxlCY.cjs +0 -2
- package/dist/sender-D82PxlCY.cjs.map +0 -1
- package/dist/storage-w7Tslvlq.js.map +0 -1
- package/dist/storm-DCEsqViG.cjs.map +0 -1
- package/dist/storm-DD4cUkoL.js.map +0 -1
- package/dist/types-BR9t_w28.js.map +0 -1
- package/dist/unclean-exit-BYZ5yaSI.js.map +0 -1
- package/dist/unclean-exit-CwdpbUDg.cjs.map +0 -1
- package/dist/user-timing-C1kB3JEg.cjs +0 -2
- package/dist/user-timing-C1kB3JEg.cjs.map +0 -1
- package/dist/user-timing-Di2ra5DB.js.map +0 -1
- package/dist/web-socket-B-5qqPy7.js.map +0 -1
- package/dist/web-socket-DwBNhgre.cjs.map +0 -1
- package/dist/web-vitals-Bflr5jSA.js +0 -53
- package/dist/web-vitals-Bflr5jSA.js.map +0 -1
- package/dist/web-vitals-DFuoTQbZ.cjs +0 -2
- package/dist/web-vitals-DFuoTQbZ.cjs.map +0 -1
- package/dist/worker-protocol-0HMf4-kY.js.map +0 -1
- package/dist/worker-protocol-DXekoADQ.cjs.map +0 -1
- package/dist/worker-server-BQK5z2yl.cjs +0 -2
- package/dist/worker-server-BQK5z2yl.cjs.map +0 -1
- package/dist/worker-transport-2220ghFZ.js.map +0 -1
- package/dist/worker-transport-Dj2yCQN5.cjs +0 -2
- package/dist/worker-transport-Dj2yCQN5.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-BrQp_5J5.js","names":["SESSION_ID_KEY","TAB_ID_KEY","SESSION_TOUCH_MS","SESSION_IDLE_MS","BROWSER_STORES","memoryStores","wrap","map","key","value","localStore","sessionStore","randomHex","bytes","byteLength","i","b","newId","safeRead","diagnostics","store","stores","safeWrite","liveSession","raw","parsed","idleMs","now","resolveIdentity","contextId","minted","sessionId","session","tabId","persistTabId","SessionTouch","touchMs","stored"],"sources":["../src/utils/identity.ts"],"sourcesContent":["// src/utils/identity.ts\n//\n// Creates and keeps the session, tab, and context correlation identifiers. In a sandboxed\n// iframe and in private mode, Storage throws instead of returning null, so an unguarded read\n// would break the library at import.\n\nimport {\n BYTE_VALUE_COUNT,\n ID_BYTE_LENGTH,\n SESSION_ID_KEY,\n SESSION_IDLE_MS,\n SESSION_TOUCH_MS,\n TAB_ID_KEY,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Correlation identifiers attached to log records across session, tab, and realm scopes. */\nexport interface Identity {\n /** Origin-wide user session identifier surviving across tabs until idle expiration. */\n sessionId: string;\n /** Browser tab or desktop window identifier surviving document reloads. */\n tabId: string;\n /** Unique execution realm identifier regenerated on every document load. */\n contextId: string;\n}\n\n/** The three Storage methods that identity and journey code use. */\nexport interface KeyValueStore {\n /**\n * Reads one value.\n * @param key Storage key.\n * @returns Stored value, or null.\n */\n getItem(key: string): string | null;\n /**\n * Writes one value.\n * @param key Storage key.\n * @param value Value to write.\n */\n setItem(key: string, value: string): void;\n /**\n * Removes one value.\n * @param key Storage key.\n */\n removeItem(key: string): void;\n}\n\n/** Stores for identity and journey keys. A getter can throw in a sandboxed frame. */\nexport interface IdentityStores {\n /** Store that lasts across tabs and reloads. */\n local(): KeyValueStore;\n /** Store that lasts for one tab. */\n session(): KeyValueStore;\n}\n\n/** Stores that write to the browser. Used by the `identity: \"storage\"` option. */\nexport const BROWSER_STORES: IdentityStores = {\n local: () => localStorage,\n session: () => sessionStorage,\n};\n\n/**\n * Creates stores that keep values in memory only. Used by the `identity: \"memory\"` option.\n * @returns Stores that write nothing to the browser.\n */\nexport function memoryStores(): IdentityStores {\n const wrap = (map: Map<string, string>): KeyValueStore => ({\n getItem: (key) => map.get(key) ?? null,\n setItem: (key, value) => {\n map.set(key, value);\n },\n removeItem: (key) => {\n map.delete(key);\n },\n });\n\n const localStore = wrap(new Map());\n const sessionStore = wrap(new Map());\n\n return { local: () => localStore, session: () => sessionStore };\n}\n\n/**\n * Generates a random lowercase hexadecimal string of the given byte length. Uses\n * crypto.getRandomValues when it is available, and Math.random otherwise.\n * @param byteLength Number of random bytes to generate.\n * @returns Hexadecimal string of length byteLength * 2.\n */\nexport function randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n if (typeof crypto !== \"undefined\" && typeof crypto.getRandomValues === \"function\") {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < byteLength; i++) {\n bytes[i] = Math.floor(Math.random() * BYTE_VALUE_COUNT);\n }\n }\n return Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\n/**\n * Generates a unique identifier with crypto.randomUUID, falling back to randomHex.\n * @param diagnostics Diagnostics reporter. Counts a blocked crypto.randomUUID call.\n * @returns A UUID or a random hex identifier.\n */\nexport function newId(diagnostics: Diagnostics): string {\n try {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n } catch {\n // A sandbox can block crypto.randomUUID with a SecurityError: the method exists but the\n // call throws. Count the fault, because a report for every id would be noise.\n diagnostics.count(\"platform.api_blocked\");\n }\n return randomHex(ID_BYTE_LENGTH);\n}\n\n/**\n * Reads a value from the local or session store, reporting any storage error to diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param diagnostics Diagnostics reporter.\n * @returns The stored string, or null if it is unreadable or absent.\n */\nfunction safeRead(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n diagnostics: Diagnostics,\n): string | null {\n return (\n diagnostics.guard(\"storage.unavailable\", `The library could not read ${store}Storage.`, () =>\n stores[store]().getItem(key),\n ) ?? null\n );\n}\n\n/**\n * Writes a key-value pair to the local or session store, reporting any storage error to\n * diagnostics.\n * @param stores Identity stores.\n * @param store Storage target (\"local\" or \"session\").\n * @param key Storage key.\n * @param value The string value to store.\n * @param diagnostics Diagnostics reporter.\n */\nfunction safeWrite(\n stores: IdentityStores,\n store: \"local\" | \"session\",\n key: string,\n value: string,\n diagnostics: Diagnostics,\n): void {\n diagnostics.guard(\n \"storage.unavailable\",\n `The library could not write to ${store}Storage.`,\n () => {\n stores[store]().setItem(key, value);\n },\n );\n}\n\n/**\n * Reads the session id from the local store. Reports a record that isn't valid JSON.\n * @param stores Identity stores.\n * @param diagnostics Diagnostics reporter.\n * @param now Epoch time in milliseconds.\n * @param idleMs Idle time after which the session expires, in milliseconds. 0 means never.\n * @returns The stored id, or undefined when it is absent or expired.\n */\nfunction liveSession(\n stores: IdentityStores,\n diagnostics: Diagnostics,\n now: number,\n idleMs: number,\n): string | undefined {\n const raw = safeRead(stores, \"local\", SESSION_ID_KEY, diagnostics);\n if (!raw) {\n return undefined;\n }\n\n try {\n const parsed = JSON.parse(raw) as { id?: string; lastSeenAt?: number };\n return parsed.id && (idleMs === 0 || now - (parsed.lastSeenAt ?? 0) < idleMs)\n ? parsed.id\n : undefined;\n } catch {\n diagnostics.report(\n \"storage.degraded\",\n \"The session record is not valid JSON. The library starts a new session.\",\n );\n return undefined;\n }\n}\n\n/**\n * Resolves or initializes the session, tab, and context identifiers for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n * @returns The populated Identity object.\n */\nexport function resolveIdentity(\n diagnostics: Diagnostics,\n stores: IdentityStores = BROWSER_STORES,\n idleMs = SESSION_IDLE_MS,\n): Identity {\n const contextId = newId(diagnostics);\n const now = Date.now();\n\n const minted = newId(diagnostics);\n const sessionId = liveSession(stores, diagnostics, now, idleMs) ?? minted;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(stores, \"local\", SESSION_ID_KEY, session, diagnostics);\n\n let tabId = safeRead(stores, \"session\", TAB_ID_KEY, diagnostics) ?? \"\";\n if (!tabId) {\n tabId = newId(diagnostics);\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n }\n\n return { sessionId, tabId, contextId };\n}\n\n/**\n * Writes a new tab id to the session store.\n * @param tabId New tab identifier.\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\nexport function persistTabId(\n tabId: string,\n diagnostics: Diagnostics,\n stores: IdentityStores,\n): void {\n safeWrite(stores, \"session\", TAB_ID_KEY, tabId, diagnostics);\n}\n\n/**\n * Writes the session's last-seen timestamp, throttled by `SESSION_TOUCH_MS`. The throttle\n * state lives on the instance, not the module, so two runtimes in one document don't block\n * each other's session writes.\n */\nexport class SessionTouch {\n /** Epoch milliseconds of the last write this instance made. */\n private lastTouchAt = 0;\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param stores Identity stores.\n */\n constructor(\n private diagnostics: Diagnostics,\n private readonly stores: IdentityStores = BROWSER_STORES,\n private readonly touchMs = SESSION_TOUCH_MS,\n private readonly idleMs = SESSION_IDLE_MS,\n ) {}\n\n /**\n * Writes the session activity time to the local store, at most once per throttle window.\n * @param sessionId The active session identifier.\n */\n touch(sessionId: string): void {\n const now = Date.now();\n\n if (now - this.lastTouchAt < this.touchMs) {\n return;\n }\n\n // Another tab can hold a newer session, for example after newSession(). Don't write the old\n // id back, or a reload would resume the old session.\n const stored = liveSession(this.stores, this.diagnostics, now, this.idleMs);\n if (stored !== undefined && stored !== sessionId) {\n this.lastTouchAt = now;\n return;\n }\n\n this.write(sessionId, now);\n }\n\n /**\n * Reads the live session id from the local store.\n * @returns The stored session id, or undefined if no session is live.\n */\n stored(): string | undefined {\n return liveSession(this.stores, this.diagnostics, Date.now(), this.idleMs);\n }\n\n /**\n * Writes a new session id to the local store right away, bypassing the throttle.\n * @param sessionId The new session identifier.\n */\n restart(sessionId: string): void {\n this.write(sessionId, Date.now());\n }\n\n /**\n * Writes the session record and starts a new throttle window.\n * @param sessionId Session identifier.\n * @param now Epoch time in milliseconds.\n */\n private write(sessionId: string, now: number): void {\n this.lastTouchAt = now;\n const session = JSON.stringify({ id: sessionId, lastSeenAt: now });\n safeWrite(this.stores, \"local\", SESSION_ID_KEY, session, this.diagnostics);\n }\n}\n"],"mappings":";;AAwDA,IAAaI,IAAiC;CAC5C,aAAa;CACb,eAAe;AACjB;AAMA,SAAgBC,IAA+B;CAC7C,IAAMC,KAAQ,OAA6C;EACzD,UAAU,MAAQC,EAAI,IAAIC,CAAG,KAAK;EAClC,UAAU,GAAK,MAAU;GACvB,EAAI,IAAIA,GAAKC,CAAK;EACpB;EACA,aAAa,MAAQ;GACnB,EAAI,OAAOD,CAAG;EAChB;CACF,IAEME,IAAaJ,kBAAK,IAAI,IAAI,CAAC,GAC3BK,IAAeL,kBAAK,IAAI,IAAI,CAAC;CAEnC,OAAO;EAAE,aAAaI;EAAY,eAAeC;CAAa;AAChE;AAQA,SAAgBC,EAAU,GAA4B;CACpD,IAAMC,IAAQ,IAAI,WAAWC,CAAU;CACvC,IAAI,OAAO,SAAW,OAAe,OAAO,OAAO,mBAAoB,YACrE,OAAO,gBAAgBD,CAAK;MAE5B,KAAK,IAAIE,IAAI,GAAGA,IAAID,GAAY,KAC9B,EAAMC,KAAK,KAAK,MAAM,KAAK,OAAO,IAAA,GAAoB;CAG1D,OAAO,MAAM,KAAKF,IAAQ,MAAMG,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AAC1E;AAOA,SAAgBC,EAAM,GAAkC;CACtD,IAAI;EACF,IAAI,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,YAChE,OAAO,OAAO,WAAW;CAE7B,QAAQ;EAGN,EAAY,MAAM,sBAAsB;CAC1C;CACA,OAAOL,EAAA,EAAwB;AACjC;AAUA,SAASM,EACP,GACA,GACA,GACA,GACe;CACf,OACEC,EAAY,MAAM,uBAAuB,8BAA8BC,EAAM,iBAC3EC,EAAOD,EAAM,CAAC,CAAC,CAAC,QAAQZ,CAAG,CAC7B,KAAK;AAET;AAWA,SAASc,EACP,GACA,GACA,GACA,GACA,GACM;CACN,EAAY,MACV,uBACA,kCAAkCF,EAAM,iBAClC;EACJ,EAAOA,EAAM,CAAC,CAAC,CAAC,QAAQZ,GAAKC,CAAK;CACpC,CACF;AACF;AAUA,SAASc,EACP,GACA,GACA,GACA,GACoB;CACpB,IAAMC,IAAMN,EAASG,GAAQ,SAASrB,GAAgBmB,CAAW;CACjE,IAAKK,GAIL,IAAI;EACF,IAAMC,IAAS,KAAK,MAAMD,CAAG;EAC7B,OAAOC,EAAO,OAAOC,MAAW,KAAKC,KAAOF,EAAO,cAAc,KAAKC,KAClED,EAAO,KACP,KAAA;CACN,QAAQ;EACN,EAAY,OACV,oBACA,yEACF;EACA;CACF;AACF;AAQA,SAAgBG,EACd,GACA,IAAyBxB,GACzB,IAASD,GACC;CACV,IAAM0B,IAAYZ,EAAME,CAAW,GAC7BQ,IAAM,KAAK,IAAI,GAEfG,IAASb,EAAME,CAAW,GAC1BY,IAAYR,EAAYF,GAAQF,GAAaQ,GAAKD,CAAM,KAAKI,GAC7DE,IAAU,KAAK,UAAU;EAAE,IAAID;EAAW,YAAYJ;CAAI,CAAC;CACjE,EAAUN,GAAQ,SAASrB,GAAgBgC,GAASb,CAAW;CAE/D,IAAIc,IAAQf,EAASG,GAAQ,WAAA,wBAAuBF,CAAW,KAAK;CAMpE,OALKc,MACH,IAAQhB,EAAME,CAAW,GACzBG,EAAUD,GAAQ,WAAWpB,GAAYgC,GAAOd,CAAW,IAGtD;EAAE;EAAW;EAAO;CAAU;AACvC;AAQA,SAAgBe,EACd,GACA,GACA,GACM;CACN,EAAUb,GAAQ,WAAWpB,GAAYgC,GAAOd,CAAW;AAC7D;AAOA,IAAagB,IAAb,MAA0B;CASd;CACS;CACA;CACA;CAVnB,cAAsB;CAMtB,YACE,GACA,IAA0C/B,GAC1C,IAA2BF,GAC3B,IAA0BC,GAC1B;EADiB,AAHT,KAAA,cAAAgB,GACS,KAAA,SAAAE,GACA,KAAA,UAAAe,GACA,KAAA,SAAAV;CAChB;CAMH,MAAM,GAAyB;EAC7B,IAAMC,IAAM,KAAK,IAAI;EAErB,IAAIA,IAAM,KAAK,cAAc,KAAK,SAChC;EAKF,IAAMU,IAASd,EAAY,KAAK,QAAQ,KAAK,aAAaI,GAAK,KAAK,MAAM;EAC1E,AAAIU,MAAW,KAAA,KAAaA,MAAWN,IACrC,KAAK,cAAcJ,IAIrB,KAAK,MAAMI,GAAWJ,CAAG;CAC3B;CAMA,SAA6B;EAC3B,OAAOJ,EAAY,KAAK,QAAQ,KAAK,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM;CAC3E;CAMA,QAAQ,GAAyB;EAC/B,KAAK,MAAMQ,GAAW,KAAK,IAAI,CAAC;CAClC;CAOA,MAAc,GAAmB,GAAmB;EAClD,KAAK,cAAcJ;EACnB,IAAMK,IAAU,KAAK,UAAU;GAAE,IAAID;GAAW,YAAYJ;EAAI,CAAC;EACjE,EAAU,KAAK,QAAQ,SAAS3B,GAAgBgC,GAAS,KAAK,WAAW;CAC3E;AACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-CL0ZdI2f.cjs"),t=require("./log-record-DKvo-B-d.cjs"),n=require("./error-like-gGRx2s36.cjs"),r=require("./guards-nJ70syPt.cjs"),i=require("./deadline-XSnm95pg.cjs"),a=require("./platform-KMWkoI-v.cjs"),o=require("./library-console-g_VU-wzP.cjs"),s=require("./sanitize-Bsn8HQWC.cjs"),c=require("./identity-BMlKGHUM.cjs"),l=require("./library-request-FQaiWjCP.cjs"),u=require("./batch-BHXypM1j.cjs"),d=require("./journey-5tcxEbnG.cjs"),f=require("./sampling-ECGVYiDD.cjs");function p(t){return Math.round((performance.now()-t)*e.X)/e.X}function m(e,t,n,r,i){e.logMetric(`${t}.duration`,n,`ms`,`histogram`,{status:r,...i})}function h(e,t,n,r,i){let a=p(n);e.error(`${t} failed`,r,{"action.duration_ms":a,status:`FAILURE`,...i}),m(e,t,a,`FAILURE`,i)}function g(e,t,n,r){let i=performance.now();try{let a=n();return m(e,t,p(i),`SUCCESS`,r),a}catch(n){throw h(e,t,i,n,r),n}}async function _(e,t,n,r){let i=performance.now();try{let a=await n();return m(e,t,p(i),`SUCCESS`,r),a}catch(n){throw h(e,t,i,n,r),n}}var v=new WeakMap;function y(e){let t=e.idle;t!==void 0&&(e.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be cancelled.`,()=>{cancelIdleCallback(t)}),e.idle=void 0),clearTimeout(e.timer),e.timer=void 0}function b(t,n){typeof requestIdleCallback==`function`&&typeof cancelIdleCallback==`function`&&(n.idle=n.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be scheduled.`,()=>requestIdleCallback(e=>{x(t,n,e)},{timeout:e.G})),n.idle!==void 0)||(n.timer=setTimeout(()=>{x(t,n)},0),i.r(n.timer))}function x(e,t,n){if(v.get(e)!==t||t.draining)return;y(t),t.draining=!0;let r=t.work;t.work=[];let i=0;for(;i<r.length&&(!n||n.didTimeout&&i===0||n.timeRemaining()>0);)if(t.diagnostics.guard(`pipeline.crashed`,`The library could not build a deferred record.`,r[i]),i++,v.get(e)!==t)return;t.work=[...r.slice(i),...t.work],t.draining=!1,t.work.length>0?b(e,t):v.delete(e)}function S(t,n,r,i){let a=v.get(t),o=i>0?Math.min(i,e.K):e.K;if(a&&a.work.length>=o&&!a.draining&&(x(t,a),a=v.get(t)),a){if(a.work.length>=o){r.count(`record.dropped_by_ceiling`);return}a.work.push(n)}else a={work:[n],diagnostics:r,draining:!1},v.set(t,a),b(t,a)}function C(e){let t=v.get(e);t&&x(e,t)}function w(e){let t=v.get(e);if(t){y(t),v.delete(e);for(let e of t.work)t.diagnostics.count(`record.dropped_by_ceiling`);t.work=[]}}var ee=[e.N,e.wn,e.q];function te(e,t){let r=t.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!n.r(e))return;let t=Error(e.message);return t.name=e.name,t.stack=e.stack,t});if(r)return r;let i=t.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function ne(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function re(e,t){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return t.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let t=e,r=n.r(e),i={},a=0;for(let e of Object.keys(t)){let o=t[e];(!r||!n.t.has(e))&&n.n(o)&&(i[e]=o,a++)}return a===0?void 0:i})}function ie(e){if(!r.t(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function ae(e){return ee.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function T(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var E=class n{bind;namespace;options;levelType;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n,this.levelType=ae(t)}child(e,t={}){return new n(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...t.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.W,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=this.bind();this.submit(o,`INFO`,`metric`,s=>{let c=T(a,o.diagnostics),l={...c,"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,[e.Nt.attributeKeys]:Object.keys(c)};this.writeNow(o,`INFO`,`metric`,t,l,!0,s)})};timeSync=(e,t,n)=>g(this,e,t,n);timeAsync=(e,t,n)=>_(this,e,t,n);write(e,t,n,r){let i=this.bind();this.submit(i,e,t,a=>{this.writeNow(i,e,t,n,r,!1,a)})}submit(e,n,r,i){if(!e.isDestroyed()){if(e.isRotating())e.diagnostics.count(`record.dropped_during_rotation`);else if(e.config.payloadMode===`defer`&&e.config.enabled&&!e.config.debugBuffer.enabled&&this.namespace!==`uiobs.diagnostics`){if(!e.builder.isEnabled(n,this.namespace,r)&&!this.mirrors(e,n))return;let o=e.journey.current(),s={timeUnixNano:t.r(),trace:e.tracing.resolve(),journey:o?{...o}:null,context:e.context.getAll(),url:a.t(e.diagnostics)};S(e,()=>{i(s)},e.diagnostics,e.config.buffering.maxPendingRecords)}else i()}}writeNow(e,t,n,r,i,a,o){if(!(e.config.enabled&&e.config.debugBuffer.enabled)&&!e.builder.isEnabled(t,this.namespace,n)){this.mirrors(e,t)&&this.print(e,t,r,i,void 0,null,void 0,o);return}let s={snapshot:o,level:t,type:n,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:a?i:T(i,e.diagnostics)},{record:c,dropped:l}=e.builder.build(s),u=!!e.config.redact||e.config.processors.length>0,d=n!==`metric`&&e.config.capturePolicy.breadcrumbs>0,f=l===`sampling`&&u&&d?e.builder.build(s,!0):void 0,p=c??f?.record??null,m=p?p.body:l===`sampling`&&!u?r:void 0;d&&m!==void 0&&e.breadcrumbs.push({t:o?Number(o.timeUnixNano.slice(0,-6)):Date.now(),category:n===`action`?`action`:n===`event`?`event`:`log`,message:m}),this.print(e,t,r,i,void 0,p,f?.dropped??l,o),e.emit(c)}writeError(e,t,n,r){let i=this.bind();this.submit(i,e,this.levelType,a=>{this.writeErrorNow(i,e,t,n,r,a)})}writeErrorNow(t,n,r,i,a,o){let s=t.builder.isEnabled(n,this.namespace);if(!s&&!this.mirrors(t,n))return;let c=a===void 0&&(t.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>ie(i))??!1),l=c?i:a,u=c?void 0:i,d=u===void 0?void 0:te(u,t.diagnostics),f=d===void 0?void 0:ne(u,d,t.diagnostics);if(!s){this.print(t,n,r,l,f,null,void 0,o);return}let p=d?re(u,t.diagnostics):void 0,{record:m,dropped:h}=t.builder.build({snapshot:o,level:n,type:this.levelType,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...T(l,t.diagnostics),...d?{"error.type":d.name,"error.message":d.message,"error.stack_trace":d.stack}:{},...p===void 0?{}:{[e.d]:p},[e.c]:t.breadcrumbs.snapshot()}});this.print(t,n,r,l,f,m,h,o),t.emit(m)}print(e,t,n,r,i,a,o,s){if(!e.config.redact&&e.config.processors.length===0){e.console.write(this.namespace,t,n,r,i);return}if(a){e.console.write(this.namespace,t,a.body,a.attributes);return}if(o===`processor`||o===`redact`||o===`malformed`||!e.config.enabled||!e.console.accepts(t))return;let c=e.builder.build({snapshot:s,level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...T(r,e.diagnostics),...i?{"error.type":i.name,"error.message":i.message,"error.stack_trace":i.stack}:{}}},!0).record;c&&e.console.write(this.namespace,t,c.body,c.attributes)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},oe=`overflow`,se=new Set([e.g,e.h,e.a,e.v,e.f,e.p,e.m]);function ce(e={}){let t={};for(let n of Object.keys(e).sort()){if(n.startsWith(`metric.`)||se.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 le(e,t){if(!Array.isArray(e))return null;let n=t===0?e.length:Math.min(e.length,t+1);return Array.from({length:n},(t,n)=>e[n])}function ue(e,t){return Array.isArray(e)&&(t===0||e.length<=t)&&e.every((t,n)=>typeof t==`number`&&Number.isFinite(t)&&(n===0||t>e[n-1]))}function de(t,n,r){let i={"metric.name":t.name,"metric.unit":t.unit,"metric.type":t.kind,[e.Nt.start]:r,[e.Nt.attributeKeys]:Object.keys(n.attributes)};return t.kind===`counter`?(i[`metric.value`]=n.sum,i):{...i,[e.Nt.count]:n.count,[e.Nt.sum]:n.sum,[e.Nt.min]:n.min,[e.Nt.max]:n.max,[e.Nt.bounds]:t.boundaries,[e.Nt.buckets]:n.buckets}}function fe(e,t,n){let r={name:e,kind:`counter`,unit:t.unit??`count`,boundaries:[]};return{add:(e,t)=>{n(r,e,t)}}}function pe(t,n,r){let i={name:t,kind:`histogram`,unit:n.unit??`count`,boundaries:n.boundaries??e.Mt};return{record:(e,t)=>{r(i,e,t)}}}var me=class{intervalMs;emit;diagnostics;policy;instruments=new Map;timer=null;startedAt=0;constructor(e,t,n,r={maxSeries:100,maxInstruments:1e3,maxHistogramBoundaries:50}){this.intervalMs=e,this.emit=t,this.diagnostics=n,this.policy=r}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,ce(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,de(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);if(this.policy.maxInstruments&&this.instruments.size>=this.policy.maxInstruments)return this.diagnostics.count(`record.dropped_by_ceiling`),null;let r=le(t.boundaries,this.policy.maxHistogramBoundaries),i=ue(r,this.policy.maxHistogramBoundaries);t.kind===`histogram`&&!i&&this.diagnostics.report(`config.invalid`,`The boundaries of the metric ${t.name} must meet metrics.maxHistogramBoundaries and contain finite numbers in ascending order. The library uses the default boundaries.`);let a={def:{...t,boundaries:i?r:[...e.Mt]},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&&this.policy.maxSeries>0&&t.series.size>=this.policy.maxSeries&&(i=oe,a=t.series.get(i),o={[e._]:!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()),i.r(this.timer))}},he={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},ge=class{settings;diagnostics;limits;constructor(t,n,r=e.Kt){this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!Object.hasOwn(e.wt,this.settings.level)?!1:e.wt[t]>=e.wt[this.settings.level]}write(e,t,n,r,i){if(!this.accepts(t)||typeof console>`u`||o.t())return;let a=`%c[%s]%c[${t}]%c`,{styles:c}=this.settings,l=he[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${l}.`,()=>{let u=[];i!==void 0&&u.push(i),r!==void 0&&u.push(s.n(r,this.limits,this.diagnostics)),o.n(()=>{console[l](a,c.namespace,e,c[t],``,n,...u)})})}},_e=class{value=0;next(){return++this.value}},ve=/^[0-9a-f]{32}$/,ye=/^[0-9a-f]{16}$/,be=/[1-9a-f]/;function xe(e){return ve.test(e.traceId)&&be.test(e.traceId)&&ye.test(e.spanId)&&be.test(e.spanId)}function Se(){return c.o(16)}function D(){return c.o(8)}function Ce(e){return{traceId:Se(),spanId:D(),traceFlags:1,startedAt:Date.now(),reason:e,ended:!1}}function we(e,t,n){return`00-${e}-${t}-${(n&255).toString(16).padStart(2,`0`)}`}function Te(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var Ee=class{diagnostics;maxAgeMs;load;spans;ambient=Ce(`start`);otel;constructor(t,n=e.Fn,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`),Te(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(xe(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){let t=this.ambient;this.ambient=Ce(e);let n=Te(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.Pn]=we(a.traceId,a.spanId,a.traceFlags),{headers:n};let s=o.keeps(a.traceId),c=s?a.traceFlags:a.traceFlags&-2,l=t?D():a.spanId;return n[e.Pn]=we(a.traceId,l,c),!t||!s?{headers:n}:{headers:n,span:{traceId:a.traceId,spanId:l,parentSpanId:a.spanId}}}},De=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=e===0?0:Math.max(e,1),this.buffer=Array(this.capacity)}resize(e){let t=this.snapshot().slice(-e);if(this.capacity=e,this.buffer=Array(e),this.pointer=0,this.filled=!1,e)for(let e of t)this.push(e)}push(e){this.capacity!==0&&(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)}},Oe=Object.keys(e.wt),ke=[`gzip`,`none`],Ae=[`omit`,`same-origin`,`include`],je=[`auto`,`indexeddb`,`localstorage`,`memory`,`none`],Me=[`storage`,`memory`],Ne=[`auto`,`sender`,`forwarder`,`off`],Pe=[`auto`,`provider`,`client`],Fe=[`auto`,`context`,`tab`,`origin`],Ie=[`error`,`warn`,`info`,`log`],Le=[`limited`,`until-delivered`],Re={logFlushIntervalMs:[100,6e4],logBatchSize:[1,1e3],metricFlushIntervalMs:[100,6e4],metricBatchSize:[1,1e3]},ze={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.D]},Ve=[6e4,864e5],O=[0,2147483647],k=[0,2**53-1],He=[1,2**53-1],Ue=[100,1e4],We={capturePolicy:{ranges:{breadcrumbs:[0,1e6],errorDedupeMs:O,maxErrorSignatures:k,errorsPerWindow:k,consolePerWindow:k,longFramesPerWindow:k,webSocketPerWindow:k,reportsPerWindow:k,resourcesPerWindow:k,lifecyclePerWindow:k,windowMs:O,errorCeiling:k}},metadata:{ranges:{}},persistence:{ranges:{}},diagnostics:{ranges:{throttleMs:O},custom:{records:ot}},correlation:{ranges:{sessionIdleMs:O,sessionTouchMs:O,traceMaxAgeMs:O}},metrics:{ranges:{maxSeries:k,maxInstruments:k,maxHistogramBoundaries:k}},buffering:{ranges:{maxPendingRecords:k,maxPendingBytes:k},choices:{overflow:[`drop-oldest`,`drop-newest`,`persist`]}},delivery:{ranges:{requestTimeoutMs:[1,O[1]],maxConcurrentRequests:He,retryBaseDelayMs:O,retryMaxDelayMs:O,retryIdleDelayMs:O,batchesPerDrain:He},choices:{priority:[`low`,`auto`,`high`]}},debugBuffer:{ranges:{maxRecords:[1,1e4],maxAgeMs:O}}},Ge=[`errors`,`rejections`,`resourceErrors`,`fetch`,`xhr`,`httpMetrics`,`navigation`,`webVitals`,`longFrames`,`fullUrls`,`webSocket`,`uncleanExit`,`userTiming`,`serverTiming`,`reports`,`lifecycle`],Ke=`null`,A=`a level name: ${j(Oe)}`,qe=`true, false or a list of ${j(Ie)}`,Je=`a list of strings and RegExp patterns`,Ye=`a list of origin URLs such as "https://api.example" and RegExp patterns`,Xe=`a list of origin URLs such as "https://app.example". For a sandboxed frame, set bus.mode: "sender" in the frame`,Ze=`a list of strings`,Qe=`true, false or a list of diagnostic codes`;function j(e){let t=e.map(e=>`"${e}"`);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function $e(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 ${$e(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,j(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 et(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 tt(e,t,n){return e===void 0?t:e===null?null:typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:(M(n,`loggerCache.maxEntries`,`a nonnegative safe integer or null`,e,String(t)),t)}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 Oe.find(e=>e===t)}function nt(e,t,n,r){if(t===void 0)return n;let i=L(t);return i===void 0?(M(r,e,A,t,`"${n}"`),n):i}function rt(e,t,n){if(e===void 0)return t;if(!r.t(e))return M(n,`minLevels`,`an object of level names`,e,`the value in force`),t;let i=[];for(let[t,r]of Object.entries(e)){let e=L(r);t!==``&&e!==void 0?i.push([t,e]):M(n,`minLevels["${t}"]`,A,r,`minLevel for it`)}return Object.fromEntries(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 ${$e(t)}. ${e} must be ${r}.`):o.push(n)}return o}function it(e){return typeof e==`function`?e:void 0}function at(e){return r.t(e)&&typeof e.name==`string`&&e.name!==``&&typeof e.install==`function`&&typeof e.uninstall==`function`?e:void 0}function ot(e,t,n,r){return t===void 0||typeof t==`boolean`?t??n:Array.isArray(t)?R(e,t,[],Qe,st,r):(M(r,e,Qe,t,`the value in force`),n)}function st(e){return typeof e==`string`?e:void 0}function ct(e){return typeof e==`string`||e instanceof RegExp?e:void 0}function lt(e){return Ie.find(t=>t===e)}function ut(e){if(typeof e==`string`)try{let{origin:t}=new URL(e);return t===Ke?void 0:t}catch{return}}function dt(e){return e instanceof RegExp?e:ut(e)}function ft(e){return r.t(e)?Object.values(e).every(e=>typeof e==`string`):!1}function pt(e,t,n){if(e!==void 0)return typeof e==`function`||ft(e)?e:(n.report(`config.invalid`,`headers must be an object of strings or a function. The library keeps the headers in force.`),t)}function mt(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function ht(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||mt(t)?t:(r.report(`config.invalid`,`serializer must be "${e.mn}", "ecs" or an implementation. The library uses "${e.mn}".`),e.mn)}var gt=new Set(Object.keys(e.L));function _t(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)gt.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 vt(e,t,n){if(e===void 0)return t??`DEBUG`;let r=L(e);return r===void 0?(M(n,`console.level`,A,e,`the console level in force`),t):r}function yt(t,n,r){if(t===void 0)return n;if(t===!1)return{level:null,styles:n.styles};if(t===!0)return{level:e.I,styles:n.styles};if(typeof t==`string`){let e=L(t);return e===void 0?(M(r,`console`,A,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:vt(t.level,n.level,r),styles:{...n.styles,..._t(t.styles,r)}}}function bt(e,t,n){let r=e??{};return{...t,...r,rates:{...t.rates,...r.rates},alwaysSampleTypes:R(`sampling.alwaysSampleTypes`,r.alwaysSampleTypes,t.alwaysSampleTypes,Ze,st,n),alwaysSampleFrom:nt(`sampling.alwaysSampleFrom`,r.alwaysSampleFrom,t.alwaysSampleFrom,n),remote:P(`sampling.remote`,r.remote,t.remote,n)}}function xt(e,t,n){let r=e??{};return{maxTrackedSources:F(`bus.maxTrackedSources`,r.maxTrackedSources,[0,2**53-1],t.maxTrackedSources,n),sourcePolicy:N(`bus.sourcePolicy`,r.sourcePolicy,[`registered`,`trusted-origin`],t.sourcePolicy,n),validation:N(`bus.validation`,r.validation,[`strict`,`envelope`],t.validation,n),maxMessageBytes:F(`bus.maxMessageBytes`,r.maxMessageBytes,[0,2**53-1],t.maxMessageBytes,n),maxRecordsPerMessage:F(`bus.maxRecordsPerMessage`,r.maxRecordsPerMessage,[0,2**53-1],t.maxRecordsPerMessage,n),maxMessagesPerSecond:F(`bus.maxMessagesPerSecond`,r.maxMessagesPerSecond,[0,2**53-1],t.maxMessagesPerSecond,n),mode:N(`bus.mode`,r.mode,Ne,t.mode,n),trustedOrigins:R(`bus.trustedOrigins`,r.trustedOrigins,t.trustedOrigins,Xe,ut,n),openFinRole:N(`bus.openFinRole`,r.openFinRole,Pe,t.openFinRole,n)}}function St(e,t,n){let r=e??{};return{scope:N(`journey.scope`,r.scope,Fe,t.scope,n),maxAgeMs:F(`journey.maxAgeMs`,r.maxAgeMs,Ve,t.maxAgeMs,n)}}function Ct(e,t,n){let r=e??{};return{mode:N(`retention.mode`,r.mode,Le,t.mode,n),...I(`retention`,r,t,ze,n)}}function wt(e,t,n){return e===void 0?t:typeof e==`boolean`?e:Array.isArray(e)?R(`capture.console`,e,[],qe,lt,n):(M(n,`capture.console`,qe,e,`the value in force`),t)}function Tt(t,n,r){let i=t??{},a={...n,...i,remoteToggles:R(`capture.remoteToggles`,i.remoteToggles,n.remoteToggles,`a list of capture switch names without privacy controls`,t=>e.qt.find(e=>e===t),r),resourceTiming:Et(i.resourceTiming,n.resourceTiming,r),interactions:Dt(i.interactions,n.interactions,r),console:wt(i.console,n.console,r),longFrameThresholdMs:et(`capture.longFrameThresholdMs`,i.longFrameThresholdMs,n.longFrameThresholdMs,r),ignoreUrls:R(`capture.ignoreUrls`,i.ignoreUrls,n.ignoreUrls,Je,ct,r),userTimingInclude:R(`capture.userTimingInclude`,i.userTimingInclude,n.userTimingInclude,Je,ct,r),propagateTraceHeaderTo:R(`capture.propagateTraceHeaderTo`,i.propagateTraceHeaderTo,n.propagateTraceHeaderTo,Ye,dt,r),plugins:R(`capture.plugins`,i.plugins,n.plugins,`a list of objects with a name, install() and uninstall()`,at,r)};for(let e of Ge)a[e]=P(`capture.${e}`,i[e],n[e],r);return a}function Et(t,n,i){return t===void 0?n:typeof t==`boolean`?t:r.t(t)?{slowMs:et(`capture.resourceTiming.slowMs`,t.slowMs,typeof n==`object`?n.slowMs??1e3:e.on,i)}:(i.report(`config.invalid`,`capture.resourceTiming must be a boolean or an options object.`),n)}function Dt(e,t,n){if(e===void 0)return t;if(typeof e==`boolean`)return e;if(!r.t(e))return n.report(`config.invalid`,`capture.interactions must be a boolean or an options object.`),t;let i=typeof t==`object`?t:{},a=e.ignoreSelector,o=a===void 0?i.ignoreSelector:a;if(o!=null)try{if(typeof o!=`string`)throw Error(`Invalid selector`);typeof document<`u`&&document.createElement(`div`).matches(o)}catch{n.report(`config.invalid`,`capture.interactions.ignoreSelector must be a valid CSS selector or null.`),o=i.ignoreSelector}let s=i.actionAttribute??`data-observability-action`;return e.actionAttribute!==void 0&&(typeof e.actionAttribute==`string`&&/^[a-z][\w-]*$/i.test(e.actionAttribute)?s=e.actionAttribute:M(n,`capture.interactions.actionAttribute`,`an attribute name of letters, digits, hyphens and underscores`,e.actionAttribute,`"${s}"`)),{actionAttribute:s,text:P(`capture.interactions.text`,e.text,i.text??!1,n),selector:P(`capture.interactions.selector`,e.selector,i.selector??!1,n),ignoreSelector:typeof o==`string`||o===null?o:void 0,maxTextChars:F(`capture.interactions.maxTextChars`,e.maxTextChars,[0,2**53-1],i.maxTextChars??50,n),rageClicks:P(`capture.interactions.rageClicks`,e.rageClicks,i.rageClicks??!1,n),rageClickCount:F(`capture.interactions.rageClickCount`,e.rageClickCount,[2,20],i.rageClickCount??3,n),rageClickWindowMs:F(`capture.interactions.rageClickWindowMs`,e.rageClickWindowMs,Ue,i.rageClickWindowMs??1e3,n),deadClicks:P(`capture.interactions.deadClicks`,e.deadClicks,i.deadClicks??!1,n),deadClickMs:F(`capture.interactions.deadClickMs`,e.deadClickMs,Ue,i.deadClickMs??1e3,n)}}var Ot={metricsEndpoint:`The library sends metric records as log records.`,tracesEndpoint:`The library sends no span.`};function kt(t,n,r,i,o){let s=r;if(typeof n==`string`&&n!==``)try{new URL(n),s=n}catch(e){o.report(`config.invalid`,`${t} is not a valid absolute URL: ${a.i(n,!1)}. The library keeps the value in force.`,void 0,e)}else n===``?s=``:n!==void 0&&M(o,t,`a URL string`,n,`the value in force`);return s!==``&&i!==`otlp`?(o.report(`config.invalid`,`${t} needs serializer "${e.mn}". ${Ot[t]}`),``):s}function At(e,t,n,r,i){let a={...n};for(let o of Object.keys(n)){let s=t?.[o],c=n[o],l=r.ranges[o],u=r.choices?.[o],d=r.custom?.[o],f=c;d?f=d(`${e}.${o}`,s,c,i):typeof c==`number`&&l?f=F(`${e}.${o}`,s,l,c,i):typeof c==`boolean`?f=P(`${e}.${o}`,s,c,i):u?f=N(`${e}.${o}`,s,u,String(c),i):s===void 0||typeof s==`string`?f=s??c:M(i,`${e}.${o}`,`a string`,s,String(c)),Object.assign(a,{[o]:f})}return a}function z(t,n,r){let i=r??e.U,o=Object.fromEntries(Object.keys(We).map(e=>[e,At(e,t[e],i[e],We[e],n)])),s={...i,...t,...o,lockConfiguration:P(`lockConfiguration`,t.lockConfiguration,i.lockConfiguration,n),loggerCache:{maxEntries:tt(t.loggerCache?.maxEntries,i.loggerCache.maxEntries,n)},securityContext:{id:typeof t.securityContext?.id==`string`&&t.securityContext.id||i.securityContext.id,isolation:P(`securityContext.isolation`,t.securityContext?.isolation,i.securityContext.isolation,n)},endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,enabled:P(`enabled`,t.enabled,i.enabled,n),payloadMode:N(`payloadMode`,t.payloadMode,[`copy`,`defer`],i.payloadMode,n),minLevel:nt(`minLevel`,t.minLevel,i.minLevel,n),minLevels:rt(t.minLevels,i.minLevels,n),processors:R(`processors`,t.processors,i.processors,`a list of functions`,it,n),compression:N(`compression`,t.compression,ke,i.compression,n),credentials:N(`credentials`,t.credentials,Ae,i.credentials,n),headers:`headers`in t?pt(t.headers,i.headers,n):i.headers,storage:N(`storage`,t.storage,je,i.storage,n),identity:N(`identity`,t.identity,Me,i.identity,n),serializer:ht(t.serializer,r?.serializer,n),console:yt(t.console,i.console,n),sampling:bt(t.sampling,i.sampling,n),bus:xt(t.bus,i.bus,n),batching:I(`batching`,t.batching,i.batching,Re,n),retention:Ct(t.retention,i.retention,n),limits:I(`limits`,t.limits,i.limits,Be,n),journey:St(t.journey,i.journey,n),capture:Tt(t.capture,i.capture,n)};for(let e of[`metricsEndpoint`,`tracesEndpoint`])s[e]=kt(e,t[e],i[e],s.serializer,n);if(s.transport!==void 0&&typeof s.transport!=`function`&&(n.report(`config.invalid`,`transport must be a function. The library ignores the value.`),s.transport=i.transport),s.onDrop!==void 0&&typeof s.onDrop!=`function`&&(n.report(`config.invalid`,`onDrop must be a function. The library ignores the value.`),s.onDrop=i.onDrop),s.contextProvider!==void 0&&typeof s.contextProvider!=`function`&&(n.report(`config.invalid`,`contextProvider must be a function. The library ignores the value.`),s.contextProvider=i.contextProvider),s.transportWorker!==void 0&&typeof s.transportWorker!=`function`&&(n.report(`config.invalid`,`transportWorker must be a function. The library keeps the value in force.`),s.transportWorker=i.transportWorker),s.transportOnExit!==void 0&&typeof s.transportOnExit!=`function`&&(n.report(`config.invalid`,`transportOnExit must be a function. The library ignores the value.`),s.transportOnExit=i.transportOnExit),s.endpoint===``)s.transport===void 0&&n.report(`config.invalid`,`endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.`);else if(s.endpoint!==null)try{new URL(s.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.i(s.endpoint,!1)}.`,void 0,e)}for(let e of[`metricsEndpoint`,`tracesEndpoint`])s[e]!==``&&s.endpoint===null&&!s.transport&&n.report(`config.invalid`,`${e} needs endpoint or transport. The library sends nothing to ${e}.`);s.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.Wn}'.`),e.Wn);let c=s.sampling.defaultRate;(typeof c!=`number`||c<0||c>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1. The value is ${String(c)}. The library uses 1.`),s.sampling.defaultRate=1);let l=s.sampling.remoteMaxRate;(typeof l!=`number`||!(l>=0&&l<=1))&&(n.report(`config.invalid`,`sampling.remoteMaxRate must be 0..1. The value is ${String(l)}. The library uses 1.`),s.sampling.remoteMaxRate=1);let u=Object.entries(s.sampling.rates);for(let[e,t]of u)(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.`),s.sampling.rates[e]=1);s.capture.ignoreUrls=s.capture.ignoreUrls.filter(e=>e!==r?.endpoint&&e!==r?.metricsEndpoint&&e!==r?.tracesEndpoint);for(let e of[s.endpoint,s.metricsEndpoint,s.tracesEndpoint])e&&!s.capture.ignoreUrls.includes(e)&&(s.capture.ignoreUrls=[...s.capture.ignoreUrls,e]);return s.delivery.retryMaxDelayMs<s.delivery.retryBaseDelayMs&&(n.report(`config.invalid`,`delivery.retryMaxDelayMs must be at least retryBaseDelayMs.`),s.delivery.retryBaseDelayMs=i.delivery.retryBaseDelayMs,s.delivery.retryMaxDelayMs=i.delivery.retryMaxDelayMs),s.capture.urlTransform!==void 0&&typeof s.capture.urlTransform!=`function`&&(n.report(`config.invalid`,`capture.urlTransform must be a function.`),s.capture.urlTransform=i.capture.urlTransform),jt(t,n),s}function jt(t,n){let r=new Set([...Object.keys(e.U),...e.Hn]);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.F){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.U[r]),...e.Un[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 Mt(t,n){for(let r of Object.keys(n))e.F.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.F)Object.assign(t[r],n[r])}var Nt=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)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},Pt=class{policy;kept=[];constructor(e){this.policy=e}push(e){let{enabled:t,maxRecords:n}=this.policy();t&&(this.kept.push({at:Date.now(),record:e}),this.kept.length>=n*2&&(this.kept=this.kept.slice(-n)))}drain(){let t=this.live();return this.kept=[],t.map(({record:t})=>({...t,attributes:{...t.attributes,[e.u]:!0}}))}snapshot(){return this.live().map(({record:e})=>e)}live(){let{enabled:e,maxRecords:t,maxAgeMs:n}=this.policy();if(!e)return this.kept=[],[];let r=n===0?-1/0:Date.now()-n;return this.kept.slice(-t).filter(e=>e.at>=r)}clear(){this.kept=[]}},B=class{handler;throttleMs;consoleFallback;counters=new Map;lastEmitted=new Map;constructor(t,n=e.J,r=!1){this.handler=t,this.throttleMs=n,this.consoleFallback=r}setPolicy(e,t){this.throttleMs=e,this.consoleFallback=t}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,i){let a=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:i,at:s,count:a},{handler:l}=this;if(l)try{o.n(()=>{l(c)})}catch{this.count(`handler.threw`),this.consoleFallback&&typeof console<`u`&&o.n(()=>{console.warn(`${e.Et} The onDiagnostic handler threw an error.`)})}}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 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)V(i.batchIds,e);for(let t of n){let n=u.t(t,e.f);typeof n==`string`&&V(i.journeyIds,n);let r=u.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.`,()=>{l.r(()=>{o.n(()=>{t(n)})})});this.reporting=!1}}},It=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=u.r(e);if((t?this.actions:this.held.length-this.actions)<(t?2e3:500))this.actions+=+!!t;else{let e=this.held.findIndex(e=>u.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}},Lt={name:`ui.measure.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Mt},Rt={name:`ui.measure.phase.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Mt};function zt(e,t,n,r){let i=String(e),a=Date.now(),o=performance.now(),s,c=!1,l=e=>a+e-o,u=(e,a)=>{s&&=(r.metric(Rt,e-s.at,{...t,"measure.name":i,"measure.phase":s.name}),n&&r.span({name:s.name,kind:`internal`,traceId:n.traceId,spanId:D(),parentSpanId:n.spanId,startMs:l(s.at),endMs:l(e),error:a,attributes:{"measure.name":i}}),void 0)};return{phase:e=>{if(c)return;let t=performance.now();u(t,!1),s={name:String(e),at:t}},end:(e=`ok`)=>{if(c)return;c=!0;let s=performance.now(),d=e===`error`;u(s,d);let f={...t,"measure.outcome":e};r.metric(Lt,s-o,{...f,"measure.name":i}),n&&r.span({...n,name:i,kind:`internal`,startMs:a,endMs:l(s),error:d,attributes:f})}}}var Bt=`error.`,Vt=[e.v,e.f,e.p],Ht={processor:{label:`A processor`,code:`record.dropped_by_processor`},redact:{label:`The redact hook`,code:`record.dropped_by_redact`}},Ut=[`metric.name`,`metric.unit`,`metric.type`,`metric.value`,...Object.values(e.Nt),...Object.values(e.xn)];function Wt(e){return Object.fromEntries(Ut.filter(t=>t in e).map(t=>[t,e[t]]))}function H(e){return e}var Gt=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t,n,r){let{config:i}=this.deps;if(!i.enabled)return!1;if(r!==void 0&&e.Ct.includes(r))return!0;let a=this.deps.remote.sampling?.minLevelFor(n)??f.n(n,i);return e.wt[t]>=e.wt[a]}keepForDebug(e){let{config:t,debug:n}=this.deps;if(!n||!t.enabled||!t.debugBuffer.enabled)return;let{record:r}=this.build(e,!0);r&&n.push(r)}build(n,r=!1){let{config:i,diagnostics:o,tracing:c,journey:l,sequence:u,limits:d,remote:p}=this.deps;if(!r&&!this.isEnabled(n.level,n.namespace,n.type))return o.count(`record.dropped_by_level`),this.keepForDebug(n),{record:null,dropped:`level`};let m=n.trace??n.snapshot?.trace??c.resolve(),h=n.snapshot?n.snapshot.journey:l.current(),g=f.o({level:n.level,type:n.type,namespace:n.namespace,journeyId:h?.id??``,traceId:m.traceId,aggregated:n.aggregated},i,p.sampling?.current()??null);if(!r&&!g)return o.count(`record.dropped_by_sampling`),this.keepForDebug(n),{record:null,dropped:`sampling`};let _=u.next(),v=n.snapshot?.url??a.t(o),y=i.metadata.pageUrl?a.i(v,i.capture.fullUrls,i.capture.urlTransform,o):``,b,x=0;try{let e=s.r(n.snapshot?.context??this.deps.context.getAll(),d,o),t=s.r(this.provided(),d,o),r=s.r(n.scoped??{},d,o),i=s.r(n.payload??{},d,o);x=e.bytes+t.bytes+r.bytes+i.bytes,b={...H(e.value),...H(t.value),...H(r.value),...H(i.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),b={[e.y]:!0}}Object.assign(b,n.fixed),b[e.g]=n.type,b[e.h]=_,b[e.a]=n.namespace,b[e.v]=y,h&&(b[e.f]=h.id,b[e.p]=h.name,h.parentId!==void 0&&(b[e.m]=h.parentId));let S=s.i(n.body,d.maxBodyChars);S!==n.body&&o.count(`record.truncated`);let C={timeUnixNano:n.snapshot?.timeUnixNano??t.r(),traceId:m.traceId,spanId:m.spanId,traceFlags:m.traceFlags,severityNumber:e.bn[n.level],severityText:n.level,body:S,attributes:b,resource:this.resource()},w=i.processors.map(e=>[e,`processor`]);if(i.redact&&w.push([i.redact,`redact`]),w.length>0){let e=this.applyHooks(C,w,n.fixed);if(typeof e==`string`)return{record:null,dropped:e};({record:C,bytes:x}=e)}if(x>d.maxRecordBytes){o.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:x,body:C.body});let t={[e.g]:n.type,[e.h]:_,[e.a]:n.namespace,[e.s]:!0,[e.o]:x};for(let e of Vt)e in C.attributes&&(t[e]=C.attributes[e]);for(let[e,n]of Object.entries(C.attributes))e.startsWith(Bt)&&(t[e]=n);let r=s.r(t,d,o).bytes;r>d.maxRecordBytes&&`error.data`in t&&(Reflect.deleteProperty(t,e.d),r=s.r(t,d,o).bytes);let i=C.attributes[e.c];if(i!==void 0){let n=s.r(i,d,o).bytes;r+n<=d.maxRecordBytes&&(t[e.c]=i)}Object.assign(t,n.fixed),C.attributes=t}return{record:C}}redactForwarded(e){let{redact:t}=this.deps.config;if(!t)return e;let n=[[t,`redact`]],r=this.applyHooks(e,n,Wt(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:i,limits:a}=this.deps,o=s.r(r.attributes,a,i),c=H(o.value);return Object.assign(c,n),{record:{...r,attributes:c},bytes:o.bytes}}runHook(n,r,i){let{diagnostics:a}=this.deps,{label:o,code:s}=Ht[r],c;try{c=n(i)}catch(e){return a.report(s,`${o} threw an error. The library dropped the record.`,void 0,e),r}if(c===null)return a.count(s),r;let l=c??i;return t.n(l)?t.t(l.severityText)?{...l,severityNumber:e.bn[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.`),r)}provided(){let e=this.deps.config.contextProvider;if(!e)return{};let{diagnostics:t}=this.deps,n=t.guard(`handler.threw`,`The contextProvider threw an error. The record has no attributes from it.`,()=>{let t=e();return t===void 0?{}:r.t(t)&&typeof t.then!=`function`?t:null});return n===null&&t.report(`config.invalid`,`contextProvider must return an object of attributes. The library ignores the value.`),n??{}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.rn]:t.serviceName,[e.in]:t.serviceVersion,[e.$t]:t.environment,[e.ln]:e.Mn,[e.un]:e.Nn,[e.cn]:e.jn,[e.en]:r.platform,[e.an]:n.sessionId,[e.sn]:n.tabId,[e.Qt]:n.contextId,...t.metadata.userAgent?{[e.Zt]:r.userAgent}:{},...!t.metadata.openfin||r.openfinUuid===void 0?{}:{[e.nn]:r.openfinUuid},...!t.metadata.openfin||r.openfinName===void 0?{}:{[e.tn]:r.openfinName}},this.resourceCache}},Kt=1e3,qt={start:`ui.start`,interaction:`ui.interaction`,navigation:`ui.navigation`,explicit:`ui.trace`,maxAge:`ui.trace`};function Jt(e){return`${String(Math.round(e*Kt))}000`}function Yt(e){return{name:qt[e.reason],kind:`internal`,traceId:e.traceId,spanId:e.spanId,parentSpanId:``,startMs:e.startedAt,endMs:e.endedAt,error:!1,attributes:{}}}function Xt(t){return{[e.xn.kind]:t.kind,[e.xn.parentId]:t.parentSpanId,[e.xn.start]:Jt(t.startMs),[e.xn.end]:Jt(t.endMs),[e.xn.status]:t.error?`error`:`unset`,...t.link?{[e.xn.linkTraceId]:t.link.traceId,[e.xn.linkSpanId]:t.link.spanId}:{}}}var Zt={errors:async()=>(await Promise.resolve().then(()=>require("./errors-CigX45pL.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-CqnQOqon.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-8DgxtmgO.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-DFuoTQbZ.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-CV5ZG2cx.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-DZEcs7FL.cjs"))).ConsoleCapture,uncleanExit:async()=>(await Promise.resolve().then(()=>require("./unclean-exit-CwdpbUDg.cjs"))).UncleanExitCapture,userTiming:async()=>(await Promise.resolve().then(()=>require("./user-timing-C1kB3JEg.cjs"))).UserTimingCapture,reports:async()=>(await Promise.resolve().then(()=>require("./reports-Bh_-KpZ2.cjs"))).ReportCapture,resourceTiming:async()=>(await Promise.resolve().then(()=>require("./resource-timing-CbgwNpog.cjs"))).ResourceTimingCapture,lifecycle:async()=>(await Promise.resolve().then(()=>require("./lifecycle-C2z_d8OX.cjs"))).LifecycleCapture},Qt=new WeakMap,$t=0;function en(e){let t=Qt.get(e);return t===void 0&&(t=++$t,Qt.set(e,t)),t}var U=Symbol.for(e.dn),W=Symbol.for(e.fn),tn=[`batching`,`retention`],G={endpoint:null,metricsEndpoint:``,tracesEndpoint:``,headers:void 0,credentials:`omit`,transport:void 0,transportOnExit:void 0,transportWorker:void 0},nn=Object.keys(G),rn=new Set([`bus.role_resolved`,`config.reconfigured`,`security.rotated`,`journey.adopted`,`journey.expired`]);function an(e){return JSON.stringify({...e,urlTransform:e.urlTransform?en(e.urlTransform):void 0,webVitalsLoader:e.webVitalsLoader!==void 0,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String),userTimingInclude:e.userTimingInclude.map(String),plugins:e.plugins.map(en)})}function on(e){if(!r.t(e))return e;let t={...e};for(let e of[`url`,`endpoint`]){let n=t[e];typeof n==`string`&&(t[e]=a.i(n,!1))}return t}function sn(e){return{...e,endpoint:null,metricsEndpoint:``,tracesEndpoint:``,transport:void 0,transportOnExit:void 0,transportWorker:void 0,bus:{...e.bus,mode:`off`}}}function cn(e){return!!e.endpoint||!!e.metricsEndpoint||!!e.tracesEndpoint||e.transport!==void 0||e.transportWorker!==void 0}function K(t){return t.sdkVersion===e.Nn}var q=class n{rotating=!1;closingContext=!1;mismatchVersion=null;contextMismatch=!1;rotation;memoryStorage;storagePersistence=`off`;recordingDiagnostic=!1;diagnosticLogger=new E(()=>this,e.q);debugBuffer=new Pt(()=>this.config.debugBuffer);explicitSecurityContext;ownerAdopted=!1;isRotating(){return this.rotating}setConfigurationLocked(e){typeof e==`boolean`&&(this.config.lockConfiguration=e)}static local=null;sdkVersion=e.Nn;diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new Nt;breadcrumbs;tracing;sequence=new _e;journey;builder;remote={sampling:null,changed:()=>{this.refreshCaptures()}};identityEpoch=0;remoteCaptureTimer;installedCaptureKey=``;console;drops;meter;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=new It(e=>{this.dropHeld(e)});captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1,uncleanExit:!1,userTiming:!1};bootBuffer=new It(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=()=>{C(this),this.role()===`forwarder`&&(this.tracing.end(),this.sendForwarded())};constructor(e,t=!1){this.diagnostics=new B(e.onDiagnostic),this.platform=a.n(this.diagnostics),this.degraded=t||this.onServer(),this.config=z(this.allowed(e),this.diagnostics),this.explicitSecurityContext=!!e.securityContext?.id,this.config.securityContext.id||=c.i(this.diagnostics),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`||this.onServer()?c.r():c.t,this.identity=c.s(this.diagnostics,this.stores,this.config.correlation.sessionIdleMs),this.sessionTouch=new c.n(this.diagnostics,this.stores,this.config.correlation.sessionTouchMs,this.config.correlation.sessionIdleMs),this.breadcrumbs=new De(this.config.capturePolicy.breadcrumbs);let n=e=>f.i(e,this.config.sampling.defaultRate);this.tracing=new Ee(this.diagnostics,this.config.correlation.traceMaxAgeMs||1/0,this.config.otelLoader,{enabled:()=>this.config.tracesEndpoint!==``,keeps:n,onEnd:e=>{n(e.traceId)&&this.recordSpan(Yt(e))}}),this.tracing.loadOtel(),this.limits={...this.config.limits},this.console=new ge(this.config.console,this.diagnostics,this.limits),this.drops=new Ft(this.config,this.diagnostics),this.journeyOptions={...d.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new d.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new Gt({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,debug:this.debugBuffer}),this.meter=new me(()=>this.config.batching.metricFlushIntervalMs,(e,t,n)=>{this.emitPoint(e,t,n)},this.diagnostics,this.config.metrics),this.diagnostics.setHandler(this.diagnosticHandler())}diagnosticHandler(){return this.config.diagnostics.records===!1?this.config.onDiagnostic:e=>{this.recordDiagnostic(e),this.config.onDiagnostic?.(e)}}recordDiagnostic(e){let{records:t}=this.config.diagnostics;if((t===!0||t!==!1&&t.includes(e.code))&&!this.recordingDiagnostic){this.recordingDiagnostic=!0;try{(rn.has(e.code)?this.diagnosticLogger.info:this.diagnosticLogger.warn)(e.message,{"diagnostic.code":e.code,"diagnostic.count":e.count,"diagnostic.detail":on(e.detail)})}finally{this.recordingDiagnostic=!1}}}addBreadcrumb(e,t){this.rotating||this.destroyed||this.diagnostics.guard(`record.sanitize_failed`,`The library could not add the breadcrumb.`,()=>{let n={t:Date.now(),category:`custom`,message:s.i(String(e),this.limits.maxBodyChars)};if(t!==void 0){let e=s.n(t,this.limits,this.diagnostics);n.data=r.t(e)?e:{value:e}}this.breadcrumbs.push(n)})}recordMetric(e,t,n){!this.destroyed&&!this.rotating&&this.meter.record(e,t,n)}startMeasure(e,t){let n=this.identityEpoch,r=()=>!this.destroyed&&!this.rotating&&(!this.config.securityContext.isolation||this.identityEpoch===n);return zt(e,this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the measure.`,()=>({...t}))??{},this.tracing.request().span,{metric:(e,t,n)=>{r()&&this.recordMetric(e,t,n)},span:e=>{r()&&this.recordSpan(e)}})}recordSpan(t){if(this.config.tracesEndpoint===``)return;let{record:n}=this.builder.build({level:`INFO`,type:`span`,body:t.name,namespace:e.In,payload:t.attributes,fixed:Xt(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.Pt,payload:n,fixed:r,aggregated:!0});this.emit(i)}busCanAccept=(e,t)=>this.bus?.isRegistered(e,t)??!1;busAccept=(e,t,n)=>{this.destroyed||this.ensureBus().then(r=>{r&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{r.acceptDirect(e,t,n)})})};static pinned(){return globalThis[U]??null}static current(){let e=n.local;if(e)return e.destroyed?null:e;let t=n.pinned();return t&&K(t)?t:null}static stopped(){let e=n.local;if(e?.destroyed)return e;let t=globalThis[W];return t&&K(t)?t:null}isDestroyed(){return this.destroyed}static configure(e,t=!1){let r=n.local;if(r&&!r.destroyed)return r.reconfigure(e),r;n.local=null;let i=n.pinned();if(i){if(!K(i))return n.startDegraded(e,i.sdkVersion);if(!i.destroyed)return i.reconfigure(e),i}let a=new n(e);return a.tunablesLocked=!t,globalThis[U]=a,Reflect.deleteProperty(globalThis,W),a.init(),a}static startDegraded(t,r){let i=new n(t,!0);n.local=i;let a=typeof r==`string`?r:`before 0.9.0`;return i.mismatchVersion=a,i.diagnostics.report(`runtime.version_mismatch`,`Another copy of the library, version ${a}, owns the page runtime. This copy, version ${e.Nn}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:a,own:e.Nn}),i.init(),i}reconfigure(e){if(this.rotating){this.diagnostics.report(`config.locked`,`Configuration cannot change during security-context rotation.`);return}if(this.config.lockConfiguration){let t=z(e,this.diagnostics,this.config);J(this.config,t)||this.diagnostics.report(`config.locked`,`Runtime configuration is locked. Use setConfigurationLocked(false) to unlock it explicitly.`);return}C(this);let t=this.keepDestination(this.keepRouting(this.allowed(e)));!this.tunablesLocked&&t.securityContext?.id&&(this.explicitSecurityContext=!0);for(let e of[`correlation`,`persistence`])(e!==`persistence`||this.tunablesLocked||this.senderLoad!==void 0)&&t[e]&&!J({...this.config[e],...t[e]},this.config[e])&&(this.diagnostics.report(`config.invalid`,`${e} cannot change after startup.`),Object.assign(t,{[e]:this.config[e]}));let n=z(t,this.diagnostics,this.config);this.keepStartupTunables(n);let{redact:r,processors:i}=this.config;Mt(this.config,n),(this.config.redact!==r||this.config.processors!==i)&&this.debugBuffer.clear(),this.breadcrumbs.resize(this.config.capturePolicy.breadcrumbs),this.diagnostics.setHandler(this.diagnosticHandler()),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),this.refreshCaptures(),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&&cn(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, transport and transportWorker.`)),sn(e)):e}keepRouting(e){if(!this.tunablesLocked||this.degraded||!this.config.securityContext.isolation)return e;let t=z(e,new B,this.config),n=nn.filter(e=>!J(t[e],this.config[e]));if(t.securityContext.id!==this.config.securityContext.id&&n.push(`securityContext.id`),n.length===0)return e;let r={...e};for(let e of nn)n.includes(e)&&Reflect.deleteProperty(r,e);if(n.includes(`securityContext.id`)){let t={...e.securityContext};Reflect.deleteProperty(t,`id`),r.securityContext=t}return this.diagnostics.report(`config.invalid`,`Isolation refuses changes to ${n.join(`, `)}. Use rotateSecurityContext() for these changes. To permit them, set securityContext.isolation: false in a separate configure() call. The other settings apply.`),r}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,tn),!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)J(e[n],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;for(let n of[`transport`,`transportWorker`])n in e&&e[n]===void 0!=(this.config[n]===void 0)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove ${n} after the delivery stack loads. The transport in force stays.`),t={...t},Reflect.deleteProperty(t,n));return(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-Dea9rVhy.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onSecurityContext:e=>{if(this.explicitSecurityContext&&this.config.securityContext.id!==e)return this.contextMismatch=!0,this.diagnostics.report(`security.context_mismatch`,`The configured security context differs from the upstream owner.`),!1;if(this.contextMismatch=!1,this.config.securityContext.id!==e){if(this.ownerAdopted){C(this),this.drops.add(`security_context`,[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer]),this.forwardBuffer=[],this.context.clear(),this.breadcrumbs.clear();let e=this.rotating;this.rotating=!0,this.meter.collect();let t=this.sessionTouch.stored();this.resetSession(t!==void 0&&t!==this.identity.sessionId?t:c.i(this.diagnostics)),this.rotating=e,this.identityEpoch++,this.remote.sampling=null,this.refreshCaptures()}this.config.securityContext.id=e}return this.ownerAdopted=!0,!0},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-D82PxlCY.cjs")),t=this.destroyed?null:await e.create({storage:this.memoryStorage,onStorage:e=>{e.name===`memory`&&(this.memoryStorage=e)},onPersistence:e=>{this.storagePersistence=e},config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote,beforeExit:()=>{C(this),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)}refreshCaptures(){if(clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 0,this.destroyed)return;let e=this.remote.sampling?.wire();e&&(this.remoteCaptureTimer=setTimeout(()=>{this.refreshCaptures()},e.ttlMs),i.r(this.remoteCaptureTimer)),an(this.effectiveCapture())!==this.installedCaptureKey&&this.installCaptures()}effectiveCapture(){let t={...this.config.capture},n=this.remote.sampling?.current()?.capture;for(let r of e.qt){let e=n?.[r];if(t.remoteToggles.includes(r)&&e!==void 0){if(e&&typeof t[r]==`object`)continue;t[r]=e}}return t}async installCaptures(){if(this.degraded)return;let t=++this.captureGeneration,n=this.effectiveCapture();this.installedCaptureKey=an(n);let 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`),n.uncleanExit&&r.push(`uncleanExit`),n.userTiming&&r.push(`userTiming`),n.reports&&r.push(`reports`),n.resourceTiming&&r.push(`resourceTiming`),n.lifecycle&&r.push(`lifecycle`);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={isActive:()=>!this.destroyed&&!this.rotating,config:Object.assign(Object.create(this.config),{capture:n}),diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new E(()=>this,e.N),once:this.captureOnce,recordMetric:(e,t,n)=>{this.recordMetric(e,t,n)},recordSpan:e=>{this.recordSpan(e)},sessionId:()=>this.identity.sessionId};for(let e of i)e&&this.captures.push(new e(o));let s=a?[...n.plugins,new a(this.diagnostics,o.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-DwBNhgre.cjs"))).WebSocketCapture)}pluginCapture(t){let{name:n}=t,r=(e,t,n)=>{this.recordMetric(e,t,n)},i={logger:new E(()=>this,`${e.N}.${n}`),counter:(e,t={})=>fe(e,t,r),histogram:(e,t={})=>pe(e,t,r),addBreadcrumb:(e,t)=>{this.addBreadcrumb(e,t)},ownRequest:l.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.`,Zt[e])}registerWorker(e,t={}){let n=!1,r;return this.destroyed?()=>void 0:(this.constructBus().then(i=>{!i||this.destroyed||n||(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{r=i.attachWorker(e,t)}),this.ensureBus())}),()=>{n=!0,r?.()})}registerFrame(e,t){let n=!1,r;return this.constructBus().then(i=>{!i||this.destroyed||n||(r=this.diagnostics.guard(`bus.send_failed`,`The frame could not be registered.`,()=>i.registerFrame(e,t)),this.ensureBus())}),()=>{n=!0,r?.()}}async destroy(){if(this.destroyed)return;C(this),this.meter.collect(),this.tracing.end(),this.destroyed=!0,w(this),clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 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,await this.rotation?.catch(()=>void 0),await this.memoryStorage?.close(),n.pinned()===this&&(Reflect.deleteProperty(globalThis,U),globalThis[W]=this)}emit(e){if(!e||this.destroyed||this.rotating&&!this.closingContext)return;this.sessionTouch.touch(this.identity.sessionId);let t=e.severityText===`ERROR`||e.severityText===`FATAL`?[...this.debugBuffer.drain(),e]:[e];for(let e of t)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(this.destroyed)return;if(!Array.isArray(e)){this.diagnostics.count(`record.dropped_malformed`);return}let n=[];for(let r of e){if(!t.n(r)){this.diagnostics.count(`record.dropped_malformed`);continue}if(r.attributes[`uiobs.debug_buffer`]!==!0&&!f.a(r,this.config,this.remote.sampling?.current()??null)){this.diagnostics.count(`record.dropped_by_sampling`);continue}let e=this.builder.redactForwarded(r);e&&n.push(e)}if(this.rotating)this.drops.add(`security_context`,n);else for(let e of n)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 E(()=>this,e.wn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let e=c.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,c.a(e,this.diagnostics,this.stores),this.builder.invalidateResource()}newSession(){this.destroyed||(C(this),this.resetSession(c.i(this.diagnostics)))}resetSession(e){this.meter.collect(),this.tracing.rotate(`explicit`),this.journey.end(),this.breadcrumbs.clear(),this.debugBuffer.clear(),this.identity.sessionId=e,this.sessionTouch.restart(e),this.builder.invalidateResource()}rotateSecurityContext(e,t={}){if(this.rotation)return Promise.reject(Error(`A security-context rotation is already running.`));let n=t.pending??`discard`,i=t.timeoutMs??5e3;return!r.t(e)||!r.t(e.delivery)||![`discard`,`flush`,`retain`,`carry`].includes(n)||!Number.isFinite(i)||i<0||e.id!==void 0&&(typeof e.id!=`string`||e.id.length===0)?Promise.reject(Error(`Invalid security-context rotation options.`)):this.destroyed?Promise.reject(Error(`The runtime has stopped.`)):(C(this),this.rotating=!0,this.rotation=this.rotateContext(e,n,i).finally(()=>{this.rotating=!1,this.rotation=void 0}),this.rotation)}async rotateContext(e,t,n){if(await this.started,this.role()===`forwarder`)throw Error(`Rotate the security context on the upstream owner, or use bus.mode: sender for an independent identity.`);await this.senderLoad;let r=this.config.securityContext.id,i=e.id??c.i(this.diagnostics);if(i===r)throw Error(`A rotation requires a different security-context id.`);let a={...G,...e.delivery},o=this.diagnostics.snapshot()[`config.invalid`]??0,s=z(this.allowed({...a,securityContext:{id:i}}),this.diagnostics,{...this.config,...G});if((this.diagnostics.snapshot()[`config.invalid`]??0)!==o)throw Error(`Invalid delivery settings for the next security context.`);let l=e.context?Object.fromEntries(Object.entries(e.context)):void 0,u=new Set([this.config.endpoint,this.config.metricsEndpoint,this.config.tracesEndpoint]),d=new Set([s.endpoint,s.metricsEndpoint,s.tracesEndpoint]);s.capture.ignoreUrls=s.capture.ignoreUrls.filter(e=>!u.has(e)||d.has(e)),this.closingContext=!0;try{this.meter.collect(),this.tracing.end(),this.journey.end()}finally{this.closingContext=!1}let f=[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer];this.forwardBuffer=[];let p=this.sender;this.sender=void 0,this.senderLoad=void 0;let m=await p?.retire(t,n,r)??{buffered:[],stored:[]};if(this.destroyed)return;let h=[...f,...m.buffered],g=m.stored.flatMap(e=>e.records);t!==`retain`&&t!==`carry`&&this.drops.add(`security_context`,[...h,...g]),s.lockConfiguration=this.config.lockConfiguration,Mt(this.config,s),this.identityEpoch++,this.remote.sampling=null,this.refreshCaptures(),this.context.clear(),l&&this.context.setMany(l),this.breadcrumbs.clear(),this.newSession(),this.builder.invalidateResource(),await this.syncSender(),this.bus?.rotateContext(),this.rotating=!1,t===`carry`&&await this.carry(h,m.stored),this.diagnostics.report(`security.rotated`,`The runtime rotated its security context.`,{pending:t})}async carry(e,t){for(let t of e)this.route(t);this.sender&&await this.sender.adopt(t,this.config.securityContext.id)}async debugBundle(t){let{configSummary:n}=await Promise.resolve().then(()=>require("./debug-bundle-yRkrU1ny.cjs")),{record:r}=this.builder.build({level:`INFO`,type:`system`,body:`debug bundle`,namespace:e.q,payload:{[e.c]:this.breadcrumbs.snapshot()}},!0),i=r?.attributes??{},a=i[e.c],o=i[e.v];return{createdAt:new Date().toISOString(),sdkVersion:this.sdkVersion,health:t,diagnostics:this.diagnostics.snapshot(),resource:r?.resource??{},pageUrl:typeof o==`string`?o:``,breadcrumbs:Array.isArray(a)?a:[],debugBuffer:this.debugBuffer.snapshot(),config:n(this.config,this.limits,this.diagnostics)}}async health(){let e=this.sender?.stats()??{pending:0,inFlight:0,lastSendAt:null},t=[];this.mismatchVersion&&t.push(`runtime.version_mismatch`),this.contextMismatch&&t.push(`security.context_mismatch`),this.ready&&this.hasDestination()&&this.role()===`sender`&&!this.sender&&t.push(`sender.unavailable`);let{sourcePolicy:n,validation:r,maxMessageBytes:i,maxRecordsPerMessage:a,maxMessagesPerSecond:o,maxTrackedSources:s}=this.config.bus;return{...e,pending:e.pending+this.bootBuffer.length+this.pendingRecords.length+this.forwardBuffer.length,stored:await this.sender?.queueDepth()??0,sdkVersion:this.sdkVersion,owningSdkVersion:this.mismatchVersion,status:this.destroyed?`stopped`:this.rotating?`rotating`:t.length?`degraded`:this.ready?`ready`:`starting`,mode:this.role()===`forwarder`?`forwarder`:this.hasDestination()?`sender`:`console-only`,senderReady:this.sender!==void 0&&!this.destroyed&&!this.rotating,configurationLocked:this.config.lockConfiguration,issues:t,securityContext:{...this.config.securityContext},storagePersistence:this.storagePersistence,bus:{sourcePolicy:n,validation:r,maxMessageBytes:i,maxRecordsPerMessage:a,maxMessagesPerSecond:o,maxTrackedSources:s}}}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 clearPersisted(e){if(await this.senderLoad,this.sender){await this.sender.clearPersisted(e,this.config.securityContext.id);return}let[{createStorage:t,storageName:n},{ContextStorage:r},{storageLimits:i},{clearEmergencyContext:a}]=await Promise.all([Promise.resolve().then(()=>require("./factory-BkjNzPYL.cjs")),Promise.resolve().then(()=>require("./context-storage-BjzeBSxH.cjs")),Promise.resolve().then(()=>require("./storage-BA9RqRO-.cjs")),Promise.resolve().then(()=>require("./emergency-queue-CQ-9acZf.cjs"))]),o=this.config.persistence.namespace,s=this.memoryStorage??await t(this.config.storage,n(o),i(this.config.retention),this.diagnostics,void 0,o),c=new r(s,this.config.securityContext,o);try{e===`namespace`?await c.clearNamespace():await c.clear(),a(this.config.securityContext.id,this.diagnostics,o,e===`namespace`)}finally{s!==this.memoryStorage&&await c.close()}}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){C(this),this.meter.collect(),this.ready||await this.started,this.role()===`forwarder`?this.sendForwarded():(await this.senderLoad,await this.sender?.flush())}};function J(e,t,n=new WeakMap){if(Object.is(e,t))return!0;if(e instanceof RegExp&&t instanceof RegExp)return String(e)===String(t);if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&J(Reflect.get(e,r),Reflect.get(t,r),n))}var Y;function ln(t={}){if(Y)return Y;let n=new B(t.onDiagnostic);if(typeof document<`u`||typeof addEventListener!=`function`)return n.report(`config.invalid`,`Call serveTransportWorker() in a dedicated worker.`),()=>void 0;let i=!1,a,o,s=t=>{n.guard(`transport.http_error`,`The transport worker could not read its connection.`,()=>{let s=t.data;if(!r.t(s)||s.p!==`ui-observability.transport/1`||s.t!==e.Bn.connect||t.ports.length===0)return;let c=t.ports[0];a||s.v!==`0.10.0`?(c.postMessage(e.zn),c.close()):(a=c,Promise.resolve().then(()=>require("./worker-server-BQK5z2yl.cjs")).then(e=>{i||(o=e.serveWorkerPort(c,n))}).catch(t=>{n.report(`transport.http_error`,`The transport worker delivery module could not load.`,void 0,t),n.guard(`transport.http_error`,`The failed transport port could not be closed.`,()=>{c.postMessage(e.zn),c.close()})}))})},c=()=>{i||(i=!0,Y=void 0,removeEventListener(`message`,s),o?.(),n.guard(`transport.http_error`,`The transport service could not close its port.`,()=>{a?.postMessage(e.zn)}),n.guard(`transport.http_error`,`The transport port could not close.`,()=>{a?.close()}))};return addEventListener(`message`,s),Y=c,c}function un(){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(q.current()??q.stopped())||q.configure({},!0)}function dn(e=`context`){return[`context`,`namespace`].includes(e)?Z().clearPersisted(e):Promise.reject(Error(`Invalid persistence scope.`))}function fn(e){q.configure(e),Q()}function pn(e){Z().setConfigurationLocked(e)}function mn(e,t){return Z().rotateSecurityContext(e,t)}async function hn(){let e=Z();return Q(),{...await e.health(),loggerCache:{...e.config.loggerCache,size:X.size}}}async function gn(){let e=await hn();return Z().debugBundle(e)}function Q(){let e=(q.current()??q.stopped())?.config.loggerCache.maxEntries,t=e===void 0?256:e;if(t!==null)for(let e of X.keys()){if(X.size<=t)break;X.delete(e)}return t}function _n(e,t){let n=Q();if(t||n===0)return new E(Z,e,t);let r=X.get(e);return r??=new E(Z,e),X.delete(e),X.set(e,r),Q(),r}function $(){return _n(`app`)}function vn(e,t){$().trace(e,t)}function yn(e,t){$().debug(e,t)}function bn(e,t){$().info(e,t)}function xn(e,t){$().warn(e,t)}function Sn(e,t,n){$().error(e,t,n)}function Cn(e,t,n){$().fatal(e,t,n)}function wn(e,t){$().logAction(e,t)}function Tn(e,t){$().logEvent(e,t)}function En(e,t,n,r,i){$().logMetric(e,t,n,r,i)}function Dn(e,t={}){return fe(e,t,(e,t,n)=>{Z().recordMetric(e,t,n)})}function On(e,t={}){return pe(e,t,(e,t,n)=>{Z().recordMetric(e,t,n)})}function kn(e,t){return Z().startMeasure(e,t)}function An(e,t,n){return $().timeSync(e,t,n)}function jn(e,t,n){return $().timeAsync(e,t,n)}function Mn(e,t){Z().addBreadcrumb(e,t)}function Nn(e,t){Z().context.set(e,t)}function Pn(e){Z().context.setMany(e)}function Fn(e){Z().context.remove(e)}function In(e,t){return Z().journey.start(e,t)}function Ln(){Z().journey.end()}function Rn(){return Z().journey.current()}function zn(){return Z().journey.getToken()}function Bn(e){return Z().journey.adopt(e,`manual`,!0)}function Vn(e,t){return Z().registerWorker(e,t)}function Hn(e,t){return Z().registerFrame(e,t)}function Un(){Z().tracing.rotate(`explicit`)}function Wn(){return Z().tracing.headers()}function Gn(){return Z().flush()}function Kn(){return Z().queueDepth()}function qn(){return Z().stats()}function Jn(){Z().newSession()}function Yn(){return Z().diagnostics.snapshot()}async function Xn(){await q.current()?.destroy()}exports.OneLogger=E,exports.addBreadcrumb=Mn,exports.adoptJourney=Bn,exports.clearPersistedLogs=dn,exports.collectDebugBundle=gn,exports.configure=fn,exports.counter=Dn,exports.createMemoryTransport=un,exports.currentJourney=Rn,exports.debug=yn,exports.endJourney=Ln,exports.error=Sn,exports.fatal=Cn,exports.flush=Gn,exports.getDiagnosticCounters=Yn,exports.getHealth=hn,exports.getJourneyToken=zn,exports.getLogger=_n,exports.getQueueDepth=Kn,exports.getStats=qn,exports.getTraceHeaders=Wn,exports.histogram=On,exports.info=bn,exports.logAction=wn,exports.logEvent=Tn,exports.logMetric=En,exports.newSession=Jn,exports.registerFrame=Hn,exports.registerWorker=Vn,exports.removeContext=Fn,exports.rotateSecurityContext=mn,exports.serveTransportWorker=ln,exports.setConfigurationLocked=pn,exports.setContext=Nn,exports.setContextMap=Pn,exports.shutdown=Xn,exports.startJourney=In,exports.startMeasure=kn,exports.startTrace=Un,exports.timeAsync=jn,exports.timeSync=An,exports.trace=vn,exports.warn=xn;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-DakMxVB2.cjs"),t=require("./log-record-D7bA1RPb.cjs"),n=require("./error-like-gGRx2s36.cjs"),r=require("./guards-nJ70syPt.cjs"),i=require("./unref-CU9Nyz_9.cjs"),a=require("./platform-12uR7kBQ.cjs"),o=require("./profiler-eVCknCzS.cjs"),s=require("./library-console-BFWEuQsl.cjs"),c=require("./sanitize-ChLn97Ch.cjs"),l=require("./identity-BlvlgjrU.cjs"),u=require("./library-request-Da-CHKzT.cjs"),d=require("./batch-D5LlU4Q9.cjs"),f=require("./journey-DAGh5h9k.cjs"),p=require("./sampling-Dd0wllyq.cjs");function m(t){return Math.round((performance.now()-t)*e.X)/e.X}function h(e,t,n,r,i){e.logMetric(`${t}.duration`,n,`ms`,`histogram`,{status:r,...i})}function g(e,t,n,r,i){let a=m(n);e.error(`${t} failed`,r,{"action.duration_ms":a,status:`FAILURE`,...i}),h(e,t,a,`FAILURE`,i)}function _(e,t,n,r){let i=performance.now();try{let a=n();return h(e,t,m(i),`SUCCESS`,r),a}catch(n){throw g(e,t,i,n,r),n}}async function ee(e,t,n,r){let i=performance.now();try{let a=await n();return h(e,t,m(i),`SUCCESS`,r),a}catch(n){throw g(e,t,i,n,r),n}}var v=new WeakMap;function y(e){let t=e.idle;t!==void 0&&(e.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be cancelled.`,()=>{cancelIdleCallback(t)}),e.idle=void 0),clearTimeout(e.timer),e.timer=void 0}function b(t,n){typeof requestIdleCallback==`function`&&typeof cancelIdleCallback==`function`&&(n.idle=n.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be scheduled.`,()=>requestIdleCallback(e=>{x(t,n,e)},{timeout:e.G})),n.idle!==void 0)||(n.timer=setTimeout(()=>{x(t,n)},0),i.t(n.timer))}function x(e,t,n){if(v.get(e)!==t||t.draining)return;y(t),t.draining=!0;let r=t.work;t.work=[];let i=0;for(;i<r.length&&(!n||n.didTimeout&&i===0||n.timeRemaining()>0);)if(t.diagnostics.guard(`pipeline.crashed`,`The library could not build a deferred record.`,r[i]),i++,v.get(e)!==t)return;t.work=[...r.slice(i),...t.work],t.draining=!1,t.work.length>0?b(e,t):v.delete(e)}function S(t,n,r,i){let a=v.get(t),o=i>0?Math.min(i,e.K):e.K;if(a&&a.work.length>=o&&!a.draining&&(x(t,a),a=v.get(t)),a){if(a.work.length>=o){r.count(`record.dropped_by_ceiling`);return}a.work.push(n)}else a={work:[n],diagnostics:r,draining:!1},v.set(t,a),b(t,a)}function C(e){let t=v.get(e);t&&x(e,t)}function te(e){let t=v.get(e);if(t){y(t),v.delete(e);for(let e of t.work)t.diagnostics.count(`record.dropped_by_ceiling`);t.work=[]}}var ne=[e.N,e.In,e.q];function re(e,t){let r=t.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!n.r(e))return;let t=Error(e.message);return t.name=e.name,t.stack=e.stack,t});if(r)return r;let i=t.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function ie(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function ae(e,t){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return t.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let t=e,r=n.r(e),i={},a=0;for(let e of Object.keys(t)){let o=t[e];r&&n.t.has(e)||!n.n(o)||(i[e]=o,a++)}return a===0?void 0:i})}function oe(e){if(!r.t(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function se(e){return ne.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function w(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var T=class n{bind;namespace;options;levelType;constructor(e,t,n={}){this.bind=e,this.namespace=t,this.options=n,this.levelType=se(t)}child(e,t={}){return new n(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...t.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.W,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=this.bind();this.submit(o,`INFO`,`metric`,s=>{let c=w(a,o.diagnostics),l={...c,"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,[e.Pt.attributeKeys]:Object.keys(c)};this.writeNow(o,`INFO`,`metric`,t,l,!0,s)})};timeSync=(e,t,n)=>_(this,e,t,n);timeAsync=(e,t,n)=>ee(this,e,t,n);write(e,t,n,r){let i=this.bind();this.submit(i,e,t,a=>{this.writeNow(i,e,t,n,r,!1,a)})}submit(e,n,r,i){if(!e.isDestroyed()){if(e.isRotating())e.diagnostics.count(`record.dropped_during_rotation`);else if(e.config.payloadMode===`defer`&&e.config.enabled&&!e.config.debugBuffer.enabled&&this.namespace!==`uiobs.diagnostics`){if(!e.builder.isEnabled(n,this.namespace,r)&&!this.mirrors(e,n))return;let o=e.journey.current(),s={timeUnixNano:t.r(),trace:e.tracing.resolve(),journey:o?{...o}:null,context:e.context.getAll(),url:a.t(e.diagnostics)};S(e,()=>{i(s)},e.diagnostics,e.config.buffering.maxPendingRecords)}else i()}}writeNow(e,t,n,r,i,a,o){if(!(e.config.enabled&&e.config.debugBuffer.enabled)&&!e.builder.isEnabled(t,this.namespace,n)){this.mirrors(e,t)&&this.print(e,t,r,i,void 0,null,void 0,o);return}let s={snapshot:o,level:t,type:n,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:a?i:w(i,e.diagnostics)},{record:c,dropped:l}=e.builder.build(s),u=!!e.config.redact||e.config.processors.length>0,d=n!==`metric`&&e.config.capturePolicy.breadcrumbs>0,f=l===`sampling`&&u&&d?e.builder.build(s,!0):void 0,p=c??f?.record??null,m=p?p.body:l===`sampling`&&!u?r:void 0;d&&m!==void 0&&e.breadcrumbs.push({t:o?Number(o.timeUnixNano.slice(0,-6)):Date.now(),category:n===`action`?`action`:n===`event`?`event`:`log`,message:m}),this.print(e,t,r,i,void 0,p,f?.dropped??l,o),e.emit(c)}writeError(e,t,n,r){let i=this.bind();this.submit(i,e,this.levelType,a=>{this.writeErrorNow(i,e,t,n,r,a)})}writeErrorNow(t,n,r,i,a,o){let s=t.builder.isEnabled(n,this.namespace);if(!s&&!this.mirrors(t,n))return;let c=a===void 0&&(t.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>oe(i))??!1),l=c?i:a,u=c?void 0:i,d=u===void 0?void 0:re(u,t.diagnostics),f=d===void 0?void 0:ie(u,d,t.diagnostics);if(!s){this.print(t,n,r,l,f,null,void 0,o);return}let p=d?ae(u,t.diagnostics):void 0,{record:m,dropped:h}=t.builder.build({snapshot:o,level:n,type:this.levelType,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...w(l,t.diagnostics),...d?{"error.type":d.name,"error.message":d.message,"error.stack_trace":d.stack}:{},...p===void 0?{}:{[e.d]:p},[e.c]:t.breadcrumbs.snapshot()}});this.print(t,n,r,l,f,m,h,o),t.emit(m)}print(e,t,n,r,i,a,o,s){if(!e.config.redact&&e.config.processors.length===0){e.console.write(this.namespace,t,n,r,i);return}if(a){e.console.write(this.namespace,t,a.body,a.attributes);return}if(o===`processor`||o===`redact`||o===`malformed`||!e.config.enabled||!e.console.accepts(t))return;let c=e.builder.build({snapshot:s,level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...w(r,e.diagnostics),...i?{"error.type":i.name,"error.message":i.message,"error.stack_trace":i.stack}:{}}},!0).record;c&&e.console.write(this.namespace,t,c.body,c.attributes)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},ce=`overflow`,le=new Set([e.g,e.h,e.a,e.v,e.f,e.p,e.m]);function ue(e={}){let t={};for(let n of Object.keys(e).sort()){if(n.startsWith(`metric.`)||le.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 de(e,t){if(!Array.isArray(e))return null;let n=t===0?e.length:Math.min(e.length,t+1);return Array.from({length:n},(t,n)=>e[n])}function fe(e,t){return Array.isArray(e)&&(t===0||e.length<=t)&&e.every((t,n)=>typeof t==`number`&&Number.isFinite(t)&&(n===0||t>e[n-1]))}function pe(t,n,r){let i={"metric.name":t.name,"metric.unit":t.unit,"metric.type":t.kind,[e.Pt.start]:r,[e.Pt.attributeKeys]:Object.keys(n.attributes)};return t.kind===`counter`?(i[`metric.value`]=n.sum,i):{...i,[e.Pt.count]:n.count,[e.Pt.sum]:n.sum,[e.Pt.min]:n.min,[e.Pt.max]:n.max,[e.Pt.bounds]:t.boundaries,[e.Pt.buckets]:n.buckets}}function me(e,t){try{return{unit:e.unit,boundaries:e.boundaries}}catch(e){return t(e),{unit:void 0,boundaries:void 0}}}function he(e,t,n,r){let i={name:e,kind:`counter`,unit:me(t,r).unit??`count`,boundaries:[]};return{add:(e,t)=>{n(i,e,t)}}}function ge(t,n,r,i){let{unit:a,boundaries:o}=me(n,i),s={name:t,kind:`histogram`,unit:a??`count`,boundaries:o??e.Nt};return{record:(e,t)=>{r(s,e,t)}}}var _e=class{intervalMs;emit;diagnostics;policy;instruments=new Map;timer=null;startedAt=0;constructor(e,t,n,r={maxSeries:100,maxInstruments:1e3,maxHistogramBoundaries:50}){this.intervalMs=e,this.emit=t,this.diagnostics=n,this.policy=r}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,ue(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,pe(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);if(this.policy.maxInstruments&&this.instruments.size>=this.policy.maxInstruments)return this.diagnostics.count(`record.dropped_by_ceiling`),null;let r=de(t.boundaries,this.policy.maxHistogramBoundaries),i=fe(r,this.policy.maxHistogramBoundaries);t.kind===`histogram`&&!i&&this.diagnostics.report(`config.invalid`,`The boundaries of the metric ${t.name} must meet metrics.maxHistogramBoundaries and contain finite numbers in ascending order. The library uses the default boundaries.`);let a={def:{...t,boundaries:i?r:[...e.Nt]},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&&this.policy.maxSeries>0&&t.series.size>=this.policy.maxSeries&&(i=ce,a=t.series.get(i),o={[e._]:!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()),i.t(this.timer))}},ve={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},ye=class{settings;diagnostics;limits;constructor(t,n,r=e.tn){this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!Object.hasOwn(e.Tt,this.settings.level)?!1:e.Tt[t]>=e.Tt[this.settings.level]}write(e,t,n,r,i){if(!this.accepts(t)||typeof console>`u`||s.t())return;let a=`%c[%s]%c[${t}]%c`,{styles:o}=this.settings,l=ve[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${l}.`,()=>{let u=[];i!==void 0&&u.push(i),r!==void 0&&u.push(c.n(r,this.limits,this.diagnostics)),s.n(()=>{console[l](a,o.namespace,e,o[t],``,n,...u)})})}},be=class{value=0;next(){return++this.value}},xe=/^[0-9a-f]{32}$/,Se=/^[0-9a-f]{16}$/,Ce=/[1-9a-f]/;function we(e){return xe.test(e.traceId)&&Ce.test(e.traceId)&&Se.test(e.spanId)&&Ce.test(e.spanId)}function Te(){return l.o(16)}function E(){return l.o(8)}function Ee(e){return{traceId:Te(),spanId:E(),traceFlags:1,startedAt:Date.now(),reason:e,ended:!1}}function De(e,t,n){return`00-${e}-${t}-${(n&255).toString(16).padStart(2,`0`)}`}function Oe(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var ke=class{diagnostics;maxAgeMs;load;spans;ambient=Ee(`start`);otel;constructor(t,n=e.qn,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`),Oe(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(we(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){let t=this.ambient;this.ambient=Ee(e);let n=Oe(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.Kn]=De(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.Kn]=De(a.traceId,l,c),!t||!s?{headers:n}:{headers:n,span:{traceId:a.traceId,spanId:l,parentSpanId:a.spanId}}}},Ae=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=e===0?0:Math.max(e,1),this.buffer=Array(this.capacity)}resize(e){let t=this.snapshot().slice(-e);if(this.capacity=e,this.buffer=Array(e),this.pointer=0,this.filled=!1,e)for(let e of t)this.push(e)}push(e){this.capacity!==0&&(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)}},je=Object.keys(e.Tt),Me=[`gzip`,`none`],Ne=[`omit`,`same-origin`,`include`],Pe=[`auto`,`indexeddb`,`localstorage`,`memory`,`none`],Fe=[`storage`,`memory`],Ie=[`auto`,`sender`,`forwarder`,`off`],Le=[`auto`,`provider`,`client`],Re=[`auto`,`context`,`tab`,`origin`],ze=[`error`,`warn`,`info`,`log`],Be=[`limited`,`until-delivered`],Ve={logFlushIntervalMs:[100,6e4],logBatchSize:[1,1e3],metricFlushIntervalMs:[100,6e4],metricBatchSize:[1,1e3]},He={maxBatches:[1,5e3],maxAgeMs:[6e4,6048e5],maxAttempts:[1,20]},Ue={maxBodyChars:[256,65536],maxAttributeChars:[256,65536],maxAttributeCount:[1,1024],maxStackChars:[256,65536],maxDepth:[1,16],maxArrayLength:[1,1e4],maxNodes:[100,1e5],maxRecordBytes:[1024,e.D]},We=[6e4,864e5],D=[0,2147483647],O=[0,2**53-1],Ge=[1,2**53-1],Ke=[100,1e4],qe=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),Je=e=>Array.isArray(e)&&e.every(e=>typeof e==`function`),k=e=>e===null||typeof e==`function`,Ye=e=>k(e)||Xe(e)&&Object.values(e).every(e=>typeof e==`string`),Xe=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function A(e,t){return(n,r,i,a)=>r===void 0?i:e(r)?r:(N(a,n,t,r,`the current value`),i)}var Ze={capturePolicy:{ranges:{breadcrumbs:[0,1e6],errorDedupeMs:D,maxErrorSignatures:O,errorsPerWindow:O,consolePerWindow:O,longFramesPerWindow:O,webSocketPerWindow:O,reportsPerWindow:O,resourcesPerWindow:O,lifecyclePerWindow:O,windowMs:D,errorCeiling:O}},metadata:{ranges:{}},persistence:{ranges:{}},diagnostics:{ranges:{throttleMs:D},custom:{records:pt}},correlation:{ranges:{sessionIdleMs:D,sessionTouchMs:D,traceMaxAgeMs:D}},metrics:{ranges:{maxSeries:O,maxInstruments:O,maxHistogramBoundaries:O}},buffering:{ranges:{maxPendingRecords:O,maxPendingBytes:O},choices:{overflow:[`drop-oldest`,`drop-newest`,`persist`]}},delivery:{ranges:{requestTimeoutMs:[1,D[1]],maxConcurrentRequests:Ge,retryBaseDelayMs:D,retryMaxDelayMs:D,retryIdleDelayMs:D,batchesPerDrain:Ge},choices:{priority:[`low`,`auto`,`high`]}},debugBuffer:{ranges:{maxRecords:[1,1e4],maxAgeMs:D}},profiler:{ranges:{flushIntervalMs:[1e3,6e5],maxProbes:[1,e.Gt]}},replay:{ranges:{bufferMs:[5e3,6e5],maxBufferBytes:[1e5,2e8],afterErrorMs:[0,6e5],uploadsPerWindow:O,batchSize:[1,1e4],batchBytes:[1e4,1e7],flushIntervalMs:[100,6e4],maxQueueBytes:[1e5,2e8],maxAttempts:[1,10]},choices:{mode:[`onError`]},custom:{maskSelectors:A(qe,`a list of strings`),blockSelectors:A(qe,`a list of strings`),loader:A(k,`a function or null`),onSegment:A(k,`a function or null`),headers:A(Ye,`an object of strings, a function or null`),plugins:A(Je,`a list of functions`),recordOptions:A(Xe,`an object`)}}},Qe=[`errors`,`rejections`,`resourceErrors`,`fetch`,`xhr`,`httpMetrics`,`navigation`,`webVitals`,`longFrames`,`fullUrls`,`webSocket`,`uncleanExit`,`userTiming`,`serverTiming`,`reports`,`lifecycle`],$e=`null`,j=`a level name: ${M(je)}`,et=`true, false or a list of ${M(ze)}`,tt=`a list of strings and RegExp patterns`,nt=`a list of origin URLs such as "https://api.example" and RegExp patterns`,rt=`a list of origin URLs such as "https://app.example". For a sandboxed frame, set bus.mode: "sender" in the frame`,it=`a list of strings`,at=`true, false or a list of diagnostic codes`;function M(e){let t=e.map(e=>`"${e}"`);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]}`}function ot(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 ${ot(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,M(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 st(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 ct(e,t,n){return e===void 0?t:e===null?null:typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:(N(n,`loggerCache.maxEntries`,`a nonnegative safe integer or null`,e,String(t)),t)}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 je.find(e=>e===t)}function lt(e,t,n,r){if(t===void 0)return n;let i=R(t);return i===void 0?(N(r,e,j,t,`"${n}"`),n):i}function ut(e,t,n){if(e===void 0)return t;if(!r.t(e))return N(n,`minLevels`,`an object of level names`,e,`the current value`),t;let i=[];for(let[t,r]of Object.entries(e)){let e=R(r);t!==``&&e!==void 0?i.push([t,e]):N(n,`minLevels["${t}"]`,j,r,`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 current list`),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 ${ot(t)}. ${e} must be ${r}.`):o.push(n)}return o}function dt(e){return typeof e==`function`?e:void 0}function ft(e){return r.t(e)&&typeof e.name==`string`&&e.name!==``&&typeof e.install==`function`&&typeof e.uninstall==`function`?e:void 0}function pt(e,t,n,r){return t===void 0||typeof t==`boolean`?t??n:Array.isArray(t)?z(e,t,[],at,mt,r):(N(r,e,at,t,`the current value`),n)}function mt(e){return typeof e==`string`?e:void 0}function ht(e){return typeof e==`string`||e instanceof RegExp?e:void 0}function gt(e){return ze.find(t=>t===e)}function _t(e){if(typeof e==`string`)try{let{origin:t}=new URL(e);return t===$e?void 0:t}catch{return}}function vt(e){return e instanceof RegExp?e:_t(e)}function yt(e){return r.t(e)?Object.values(e).every(e=>typeof e==`string`):!1}function bt(e,t,n){if(e!==void 0)return typeof e==`function`||yt(e)?e:(n.report(`config.invalid`,`headers must be an object of strings or a function. The library keeps the current headers.`),t)}function xt(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function St(t,n,r){return t===void 0?n??`otlp`:t===`otlp`||t===`ecs`||xt(t)?t:(r.report(`config.invalid`,`serializer must be "${e.En}", "ecs" or an implementation. The library uses "${e.En}".`),e.En)}var Ct=new Set(Object.keys(e.L));function wt(e,t){let n={},r=Object.entries(e??{});for(let[e,i]of r)Ct.has(e)?typeof i==`string`?n[e]=i:t.report(`config.invalid`,`console.styles.${e} must be a string. The library keeps the current style.`):t.report(`config.invalid`,`The library ignores the unknown console.styles key "${e}". Check the spelling.`);return n}function Tt(e,t,n){if(e===void 0)return t??`DEBUG`;let r=R(e);return r===void 0?(N(n,`console.level`,j,e,`the current console level`),t):r}function Et(t,n,r){if(t===void 0)return n;if(t===!1)return{level:null,styles:n.styles};if(t===!0)return{level:e.I,styles:n.styles};if(typeof t==`string`){let e=R(t);return e===void 0?(N(r,`console`,j,t,`the current console level`),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 current console settings stay.`),n):{level:Tt(t.level,n.level,r),styles:{...n.styles,...wt(t.styles,r)}}}function Dt(e,t,n){let r=e??{};return{...t,...r,rates:{...t.rates,...r.rates},alwaysSampleTypes:z(`sampling.alwaysSampleTypes`,r.alwaysSampleTypes,t.alwaysSampleTypes,it,mt,n),alwaysSampleFrom:lt(`sampling.alwaysSampleFrom`,r.alwaysSampleFrom,t.alwaysSampleFrom,n),remote:F(`sampling.remote`,r.remote,t.remote,n)}}function Ot(e,t,n){let r=e??{};return{maxTrackedSources:I(`bus.maxTrackedSources`,r.maxTrackedSources,[0,2**53-1],t.maxTrackedSources,n),sourcePolicy:P(`bus.sourcePolicy`,r.sourcePolicy,[`registered`,`trusted-origin`],t.sourcePolicy,n),validation:P(`bus.validation`,r.validation,[`strict`,`envelope`],t.validation,n),maxMessageBytes:I(`bus.maxMessageBytes`,r.maxMessageBytes,[0,2**53-1],t.maxMessageBytes,n),maxRecordsPerMessage:I(`bus.maxRecordsPerMessage`,r.maxRecordsPerMessage,[0,2**53-1],t.maxRecordsPerMessage,n),maxMessagesPerSecond:I(`bus.maxMessagesPerSecond`,r.maxMessagesPerSecond,[0,2**53-1],t.maxMessagesPerSecond,n),mode:P(`bus.mode`,r.mode,Ie,t.mode,n),trustedOrigins:z(`bus.trustedOrigins`,r.trustedOrigins,t.trustedOrigins,rt,_t,n),openFinRole:P(`bus.openFinRole`,r.openFinRole,Le,t.openFinRole,n)}}function kt(e,t,n){let r=e??{};return{scope:P(`journey.scope`,r.scope,Re,t.scope,n),maxAgeMs:I(`journey.maxAgeMs`,r.maxAgeMs,We,t.maxAgeMs,n)}}function At(e,t,n){let r=e??{};return{mode:P(`retention.mode`,r.mode,Be,t.mode,n),...L(`retention`,r,t,He,n)}}function jt(e,t,n){return e===void 0?t:typeof e==`boolean`?e:Array.isArray(e)?z(`capture.console`,e,[],et,gt,n):(N(n,`capture.console`,et,e,`the current value`),t)}function Mt(t,n,r){let i=t??{},a={...n,...i,remoteToggles:z(`capture.remoteToggles`,i.remoteToggles,n.remoteToggles,`a list of capture switch names without privacy controls`,t=>e.nn.find(e=>e===t),r),resourceTiming:Nt(i.resourceTiming,n.resourceTiming,r),interactions:Pt(i.interactions,n.interactions,r),console:jt(i.console,n.console,r),longFrameMs:st(`capture.longFrameMs`,i.longFrameMs,n.longFrameMs,r),ignoreUrls:z(`capture.ignoreUrls`,i.ignoreUrls,n.ignoreUrls,tt,ht,r),userTimingInclude:z(`capture.userTimingInclude`,i.userTimingInclude,n.userTimingInclude,tt,ht,r),propagateTraceHeaderTo:z(`capture.propagateTraceHeaderTo`,i.propagateTraceHeaderTo,n.propagateTraceHeaderTo,nt,vt,r),plugins:z(`capture.plugins`,i.plugins,n.plugins,`a list of objects with a name, install() and uninstall()`,ft,r)};for(let e of Qe)a[e]=F(`capture.${e}`,i[e],n[e],r);return a}function Nt(t,n,i){return t===void 0?n:typeof t==`boolean`?t:r.t(t)?{slowMs:st(`capture.resourceTiming.slowMs`,t.slowMs,typeof n==`object`?n.slowMs??1e3:e.vn,i)}:(i.report(`config.invalid`,`capture.resourceTiming must be a boolean or an options object.`),n)}function Pt(e,t,n){if(e===void 0)return t;if(typeof e==`boolean`)return e;if(!r.t(e))return n.report(`config.invalid`,`capture.interactions must be a boolean or an options object.`),t;let i=typeof t==`object`?t:{},a=e.ignoreSelector,o=a===void 0?i.ignoreSelector:a;if(o!=null)try{if(typeof o!=`string`)throw Error(`Invalid selector`);typeof document<`u`&&document.createElement(`div`).matches(o)}catch{n.report(`config.invalid`,`capture.interactions.ignoreSelector must be a valid CSS selector or null.`),o=i.ignoreSelector}let s=i.actionAttribute??`data-observability-action`;return e.actionAttribute!==void 0&&(typeof e.actionAttribute==`string`&&/^[a-z][\w-]*$/i.test(e.actionAttribute)?s=e.actionAttribute:N(n,`capture.interactions.actionAttribute`,`an attribute name of letters, digits, hyphens and underscores`,e.actionAttribute,`"${s}"`)),{actionAttribute:s,text:F(`capture.interactions.text`,e.text,i.text??!1,n),selector:F(`capture.interactions.selector`,e.selector,i.selector??!1,n),ignoreSelector:typeof o==`string`||o===null?o:void 0,maxTextChars:I(`capture.interactions.maxTextChars`,e.maxTextChars,[0,2**53-1],i.maxTextChars??50,n),rageClicks:F(`capture.interactions.rageClicks`,e.rageClicks,i.rageClicks??!1,n),rageClickCount:I(`capture.interactions.rageClickCount`,e.rageClickCount,[2,20],i.rageClickCount??3,n),rageClickWindowMs:I(`capture.interactions.rageClickWindowMs`,e.rageClickWindowMs,Ke,i.rageClickWindowMs??1e3,n),deadClicks:F(`capture.interactions.deadClicks`,e.deadClicks,i.deadClicks??!1,n),deadClickMs:I(`capture.interactions.deadClickMs`,e.deadClickMs,Ke,i.deadClickMs??1e3,n)}}var Ft={metricsEndpoint:`The library sends metric records as log records.`,tracesEndpoint:`The library sends no span.`};function It(t,n,r,i,o){let s=r;if(typeof n==`string`&&n!==``)try{new URL(n),s=n}catch(e){o.report(`config.invalid`,`${t} is not a valid absolute URL: ${a.i(n,!1)}. The library keeps the current value.`,void 0,e)}else n===``?s=``:n!==void 0&&N(o,t,`a URL string`,n,`the current value`);return s!==``&&i!==`otlp`?(o.report(`config.invalid`,`${t} needs serializer "${e.En}". ${Ft[t]}`),``):s}function Lt(e,t,n,r,i){let a={...n};for(let o of Object.keys(n)){let s=t?.[o],c=n[o],l=r.ranges[o],u=r.choices?.[o],d=r.custom?.[o],f=c;d?f=d(`${e}.${o}`,s,c,i):typeof c==`number`&&l?f=I(`${e}.${o}`,s,l,c,i):typeof c==`boolean`?f=F(`${e}.${o}`,s,c,i):u?f=P(`${e}.${o}`,s,u,String(c),i):s===void 0||typeof s==`string`?f=s??c:N(i,`${e}.${o}`,`a string`,s,String(c)),Object.assign(a,{[o]:f})}return a}function B(t,n,r){let i=r??e.U,o=Object.fromEntries(Object.keys(Ze).map(e=>[e,Lt(e,t[e],i[e],Ze[e],n)])),s={...i,...t,...o,lockConfiguration:F(`lockConfiguration`,t.lockConfiguration,i.lockConfiguration,n),loggerCache:{maxEntries:ct(t.loggerCache?.maxEntries,i.loggerCache.maxEntries,n)},securityContext:{id:typeof t.securityContext?.id==`string`&&t.securityContext.id||i.securityContext.id,isolation:F(`securityContext.isolation`,t.securityContext?.isolation,i.securityContext.isolation,n)},endpoint:t.endpoint===void 0?i.endpoint:t.endpoint,enabled:F(`enabled`,t.enabled,i.enabled,n),payloadMode:P(`payloadMode`,t.payloadMode,[`copy`,`defer`],i.payloadMode,n),minLevel:lt(`minLevel`,t.minLevel,i.minLevel,n),minLevels:ut(t.minLevels,i.minLevels,n),processors:z(`processors`,t.processors,i.processors,`a list of functions`,dt,n),compression:P(`compression`,t.compression,Me,i.compression,n),credentials:P(`credentials`,t.credentials,Ne,i.credentials,n),headers:`headers`in t?bt(t.headers,i.headers,n):i.headers,storage:P(`storage`,t.storage,Pe,i.storage,n),identity:P(`identity`,t.identity,Fe,i.identity,n),serializer:St(t.serializer,r?.serializer,n),console:Et(t.console,i.console,n),sampling:Dt(t.sampling,i.sampling,n),bus:Ot(t.bus,i.bus,n),batching:L(`batching`,t.batching,i.batching,Ve,n),retention:At(t.retention,i.retention,n),limits:L(`limits`,t.limits,i.limits,Ue,n),journey:kt(t.journey,i.journey,n),capture:Mt(t.capture,i.capture,n)};for(let e of[`metricsEndpoint`,`tracesEndpoint`])s[e]=It(e,t[e],i[e],s.serializer,n);if(s.transport!==void 0&&typeof s.transport!=`function`&&(n.report(`config.invalid`,`transport must be a function. The library ignores the value.`),s.transport=i.transport),s.onDrop!==void 0&&typeof s.onDrop!=`function`&&(n.report(`config.invalid`,`onDrop must be a function. The library ignores the value.`),s.onDrop=i.onDrop),s.contextProvider!==void 0&&typeof s.contextProvider!=`function`&&(n.report(`config.invalid`,`contextProvider must be a function. The library ignores the value.`),s.contextProvider=i.contextProvider),s.transportWorker!==void 0&&typeof s.transportWorker!=`function`&&(n.report(`config.invalid`,`transportWorker must be a function. The library keeps the current value.`),s.transportWorker=i.transportWorker),s.transportOnExit!==void 0&&typeof s.transportOnExit!=`function`&&(n.report(`config.invalid`,`transportOnExit must be a function. The library ignores the value.`),s.transportOnExit=i.transportOnExit),s.endpoint===``)s.transport===void 0&&n.report(`config.invalid`,`endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.`);else if(s.endpoint!==null)try{new URL(s.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.i(s.endpoint,!1)}.`,void 0,e)}for(let e of[`metricsEndpoint`,`tracesEndpoint`])s[e]!==``&&s.endpoint===null&&!s.transport&&n.report(`config.invalid`,`${e} needs endpoint or transport. The library sends nothing to ${e}.`);s.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record reports service.name as '${e.nr}'.`),e.nr);let c=s.sampling.defaultRate;(typeof c!=`number`||c<0||c>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1. The value is ${String(c)}. The library uses 1.`),s.sampling.defaultRate=1);let l=s.sampling.remoteMaxRate;typeof l==`number`&&l>=0&&l<=1||(n.report(`config.invalid`,`sampling.remoteMaxRate must be 0..1. The value is ${String(l)}. The library uses 1.`),s.sampling.remoteMaxRate=1);let u=Object.entries(s.sampling.rates);for(let[e,t]of u)(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.`),s.sampling.rates[e]=1);s.capture.ignoreUrls=s.capture.ignoreUrls.filter(e=>e!==r?.endpoint&&e!==r?.metricsEndpoint&&e!==r?.tracesEndpoint&&e!==r?.replay.endpoint);for(let e of[s.endpoint,s.metricsEndpoint,s.tracesEndpoint,s.replay.endpoint])e&&!s.capture.ignoreUrls.includes(e)&&(s.capture.ignoreUrls=[...s.capture.ignoreUrls,e]);return s.delivery.retryMaxDelayMs<s.delivery.retryBaseDelayMs&&(n.report(`config.invalid`,`delivery.retryMaxDelayMs must be at least retryBaseDelayMs.`),s.delivery.retryBaseDelayMs=i.delivery.retryBaseDelayMs,s.delivery.retryMaxDelayMs=i.delivery.retryMaxDelayMs),s.capture.urlTransform!==void 0&&typeof s.capture.urlTransform!=`function`&&(n.report(`config.invalid`,`capture.urlTransform must be a function.`),s.capture.urlTransform=i.capture.urlTransform),Rt(t,n),s}function Rt(t,n){let r=new Set([...Object.keys(e.U),...e.er]);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.F){let i=t[r];if(typeof i!=`object`||!i)continue;let a=new Set([...Object.keys(e.U[r]),...e.tr[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 zt(t,n){for(let r of Object.keys(n))e.F.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.F)Object.assign(t[r],n[r])}var Bt=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)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},Vt=class{policy;kept=[];constructor(e){this.policy=e}push(e){let{enabled:t,maxRecords:n}=this.policy();t&&(this.kept.push({at:Date.now(),record:e}),this.kept.length>=n*2&&(this.kept=this.kept.slice(-n)))}drain(){let t=this.live();return this.kept=[],t.map(({record:t})=>({...t,attributes:{...t.attributes,[e.u]:!0}}))}snapshot(){return this.live().map(({record:e})=>e)}live(){let{enabled:e,maxRecords:t,maxAgeMs:n}=this.policy();if(!e)return this.kept=[],[];let r=n===0?-1/0:Date.now()-n;return this.kept.slice(-t).filter(e=>e.at>=r)}clear(){this.kept=[]}},V=class{handler;throttleMs;consoleFallback;counters=new Map;lastEmitted=new Map;constructor(t,n=e.J,r=!1){this.handler=t,this.throttleMs=n,this.consoleFallback=r}setPolicy(e,t){this.throttleMs=e,this.consoleFallback=t}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,i){let a=this.count(t),o=Date.now();if(o-(this.lastEmitted.get(t)??0)<this.throttleMs)return!1;this.lastEmitted.set(t,o);let c={code:t,message:n,detail:r,cause:i,at:o,count:a},{handler:l}=this;if(!l)return!0;try{s.n(()=>{l(c)})}catch{this.count(`handler.threw`),this.consoleFallback&&typeof console<`u`&&s.n(()=>{console.warn(`${e.Dt} The onDiagnostic handler threw an error.`)})}return!0}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 Ht=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=d.t(t,e.f);typeof n==`string`&&H(i.journeyIds,n);let r=d.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.`,()=>{u.r(()=>{s.n(()=>{t(n)})})});this.reporting=!1}}},Ut=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=d.r(e);if((t?this.actions:this.held.length-this.actions)<(t?2e3:500))this.actions+=+!!t;else{let e=this.held.findIndex(e=>d.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}},Wt={name:`ui.measure.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Nt},Gt={name:`ui.measure.phase.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Nt};function Kt(e,t,n,r){let i=String(e),a=Date.now(),o=performance.now(),s,c=!1,l=e=>a+e-o,u=(e,a)=>{s&&=(r.metric(Gt,e-s.at,{...t,"measure.name":i,"measure.phase":s.name}),n&&r.span({name:s.name,kind:`internal`,traceId:n.traceId,spanId:E(),parentSpanId:n.spanId,startMs:l(s.at),endMs:l(e),error:a,attributes:{"measure.name":i}}),void 0)};return{phase:e=>{if(c)return;let t=performance.now();u(t,!1),s={name:String(e),at:t}},end:(e=`ok`)=>{if(c)return;c=!0;let s=performance.now(),d=e===`error`;u(s,d);let f={...t,"measure.outcome":e};r.metric(Wt,s-o,{...f,"measure.name":i}),n&&r.span({...n,name:i,kind:`internal`,startMs:a,endMs:l(s),error:d,attributes:f})}}}var qt=`error.`,Jt=[e.v,e.f,e.p],Yt={processor:{label:`A processor`,code:`record.dropped_by_processor`},redact:{label:`The redact hook`,code:`record.dropped_by_redact`}},Xt=[`metric.name`,`metric.unit`,`metric.type`,`metric.value`,...Object.values(e.Pt),...Object.values(e.Nn)];function Zt(e){return Object.fromEntries(Xt.filter(t=>t in e).map(t=>[t,e[t]]))}function U(e){return e}var Qt=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t,n,r){let{config:i}=this.deps;if(!i.enabled)return!1;if(r!==void 0&&e.wt.includes(r))return!0;let a=this.deps.remote.sampling?.minLevelFor(n)??p.n(n,i);return e.Tt[t]>=e.Tt[a]}keepForDebug(e){let{config:t,debug:n}=this.deps;if(!n||!t.enabled||!t.debugBuffer.enabled)return;let{record:r}=this.build(e,!0);r&&n.push(r)}build(n,r=!1){let{config:i,diagnostics:o,tracing:s,journey:l,sequence:u,limits:d,remote:f}=this.deps;if(!r&&!this.isEnabled(n.level,n.namespace,n.type))return o.count(`record.dropped_by_level`),this.keepForDebug(n),{record:null,dropped:`level`};let m=n.trace??n.snapshot?.trace??s.resolve(),h=n.snapshot?n.snapshot.journey:l.current(),g=p.o({level:n.level,type:n.type,namespace:n.namespace,journeyId:h?.id??``,traceId:m.traceId,aggregated:n.aggregated},i,f.sampling?.current()??null);if(!r&&!g)return o.count(`record.dropped_by_sampling`),this.keepForDebug(n),{record:null,dropped:`sampling`};let _=u.next(),ee=n.snapshot?.url??a.t(o),v=i.metadata.pageUrl?a.i(ee,i.capture.fullUrls,i.capture.urlTransform,o):``,y,b=0;try{let e=c.r(n.snapshot?.context??this.deps.context.getAll(),d,o),t=c.r(this.provided(),d,o),r=c.r(n.scoped??{},d,o),i=c.r(n.payload??{},d,o);b=e.bytes+t.bytes+r.bytes+i.bytes,y={...U(e.value),...U(t.value),...U(r.value),...U(i.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),y={[e.y]:!0}}Object.assign(y,n.fixed),y[e.g]=n.type,y[e.h]=_,y[e.a]=n.namespace,y[e.v]=v,h&&(y[e.f]=h.id,y[e.p]=h.name,h.parentId!==void 0&&(y[e.m]=h.parentId));let x=c.i(n.body,d.maxBodyChars);x!==n.body&&o.count(`record.truncated`);let S={timeUnixNano:n.snapshot?.timeUnixNano??t.r(),traceId:m.traceId,spanId:m.spanId,traceFlags:m.traceFlags,severityNumber:e.Mn[n.level],severityText:n.level,body:x,attributes:y,resource:this.resource()},C=i.processors.map(e=>[e,`processor`]);if(i.redact&&C.push([i.redact,`redact`]),C.length>0){let e=this.applyHooks(S,C,n.fixed);if(typeof e==`string`)return{record:null,dropped:e};({record:S,bytes:b}=e)}if(b>d.maxRecordBytes){o.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:b,body:S.body});let t={[e.g]:n.type,[e.h]:_,[e.a]:n.namespace,[e.s]:!0,[e.o]:b};for(let e of Jt)e in S.attributes&&(t[e]=S.attributes[e]);for(let[e,n]of Object.entries(S.attributes))e.startsWith(qt)&&(t[e]=n);let r=c.r(t,d,o).bytes;r>d.maxRecordBytes&&`error.data`in t&&(Reflect.deleteProperty(t,e.d),r=c.r(t,d,o).bytes);let i=S.attributes[e.c];if(i!==void 0){let n=c.r(i,d,o).bytes;r+n<=d.maxRecordBytes&&(t[e.c]=i)}Object.assign(t,n.fixed),S.attributes=t}return{record:S}}redactForwarded(e){let{redact:t}=this.deps.config;if(!t)return e;let n=[[t,`redact`]],r=this.applyHooks(e,n,Zt(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:i,limits:a}=this.deps,o=c.r(r.attributes,a,i),s=U(o.value);return Object.assign(s,n),{record:{...r,attributes:s},bytes:o.bytes}}runHook(n,r,i){let{diagnostics:a}=this.deps,{label:o,code:s}=Yt[r],c;try{c=n(i)}catch(e){return a.report(s,`${o} threw an error. The library dropped the record.`,void 0,e),r}if(c===null)return a.count(s),r;let l=c??i;return t.n(l)?t.t(l.severityText)?{...l,severityNumber:e.Mn[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.`),r)}provided(){let e=this.deps.config.contextProvider;if(!e)return{};let{diagnostics:t}=this.deps,n=t.guard(`handler.threw`,`The contextProvider threw an error. The record has no attributes from it.`,()=>{let t=e();return t===void 0?{}:r.t(t)&&typeof t.then!=`function`?t:null});return n===null&&t.report(`config.invalid`,`contextProvider must return an object of attributes. The library ignores the value.`),n??{}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.hn]:t.serviceName,[e.gn]:t.serviceVersion,[e.dn]:t.environment,[e.xn]:e.Wn,[e.Sn]:e.Gn,[e.bn]:e.Un,[e.fn]:r.platform,[e._n]:n.sessionId,[e.yn]:n.tabId,[e.un]:n.contextId,...t.metadata.userAgent?{[e.ln]:r.userAgent}:{},...!t.metadata.openfin||r.openfinUuid===void 0?{}:{[e.mn]:r.openfinUuid},...!t.metadata.openfin||r.openfinName===void 0?{}:{[e.pn]:r.openfinName}},this.resourceCache}},$t=1e3,en={start:`ui.start`,interaction:`ui.interaction`,navigation:`ui.navigation`,explicit:`ui.trace`,maxAge:`ui.trace`};function tn(e){return`${String(Math.round(e*$t))}000`}function nn(e){return{name:en[e.reason],kind:`internal`,traceId:e.traceId,spanId:e.spanId,parentSpanId:``,startMs:e.startedAt,endMs:e.endedAt,error:!1,attributes:{}}}function rn(t){return{[e.Nn.kind]:t.kind,[e.Nn.parentId]:t.parentSpanId,[e.Nn.start]:tn(t.startMs),[e.Nn.end]:tn(t.endMs),[e.Nn.status]:t.error?`error`:`unset`,...t.link?{[e.Nn.linkTraceId]:t.link.traceId,[e.Nn.linkSpanId]:t.link.spanId}:{}}}var an={errors:async()=>(await Promise.resolve().then(()=>require("./errors-DCOCRdSi.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-pEX3PAJv.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-P6pz08Jn.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-Ch5BpDmo.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-Dd8tsi2U.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-CLz_PvFn.cjs"))).ConsoleCapture,uncleanExit:async()=>(await Promise.resolve().then(()=>require("./unclean-exit-ClGzrc2A.cjs"))).UncleanExitCapture,userTiming:async()=>(await Promise.resolve().then(()=>require("./user-timing-CdYqx3PF.cjs"))).UserTimingCapture,reports:async()=>(await Promise.resolve().then(()=>require("./reports-BsbqmP8h.cjs"))).ReportCapture,resourceTiming:async()=>(await Promise.resolve().then(()=>require("./resource-timing-DkycFGDa.cjs"))).ResourceTimingCapture,lifecycle:async()=>(await Promise.resolve().then(()=>require("./lifecycle-BGGOcN4N.cjs"))).LifecycleCapture,framePhases:async()=>(await Promise.resolve().then(()=>require("./profiler-frames-Dg2OebB2.cjs"))).FramePhasesCapture,framePacing:async()=>(await Promise.resolve().then(()=>require("./profiler-frames-Dg2OebB2.cjs"))).FramePacingCapture,replay:async()=>(await Promise.resolve().then(()=>require("./replay-DomJpXqW.cjs"))).ReplayCapture},on=new WeakMap,sn=0;function W(e){let t=on.get(e);return t===void 0&&(t=++sn,on.set(e,t)),t}var G=Symbol.for(e.Cn),K=Symbol.for(e.wn),cn=[`batching`,`retention`],ln={endpoint:null,metricsEndpoint:``,tracesEndpoint:``,headers:void 0,credentials:`omit`,transport:void 0,transportOnExit:void 0,transportWorker:void 0},un=Object.keys(ln),dn=new Set([`bus.role_resolved`,`config.reconfigured`,`security.rotated`,`journey.adopted`,`journey.expired`]);function fn(e){return JSON.stringify({...e,urlTransform:e.urlTransform?W(e.urlTransform):void 0,webVitalsLoader:e.webVitalsLoader!==void 0,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String),userTimingInclude:e.userTimingInclude.map(String),plugins:e.plugins.map(W)})}function pn(e){if(!r.t(e))return e;let t={...e};for(let e of[`url`,`endpoint`]){let n=t[e];typeof n==`string`&&(t[e]=a.i(n,!1))}return t}function mn(e){return{...e,endpoint:null,metricsEndpoint:``,tracesEndpoint:``,transport:void 0,transportOnExit:void 0,transportWorker:void 0,bus:{...e.bus,mode:`off`}}}function hn(e){return!!e.endpoint||!!e.metricsEndpoint||!!e.tracesEndpoint||e.transport!==void 0||e.transportWorker!==void 0}function gn(t){return t.sdkVersion===e.Gn}var q=class n{rotating=!1;profilerOn=!1;closingContext=!1;mismatchVersion=null;contextMismatch=!1;rotation;memoryStorage;storagePersistence=`off`;recordingDiagnostic=!1;diagnosticLogger=new T(()=>this,e.q);debugBuffer=new Vt(()=>this.config.debugBuffer);explicitSecurityContext;ownerAdopted=!1;isRotating(){return this.rotating}setConfigurationLocked(e){typeof e==`boolean`&&(this.config.lockConfiguration=e)}static local=null;sdkVersion=e.Gn;diagnostics;config;platform;identity;stores;identityBuiltAs;sessionTouch;context=new Bt;breadcrumbs;tracing;sequence=new be;journey;builder;remote={sampling:null,changed:()=>{this.refreshCaptures()}};identityEpoch=0;errorHook;replayConsent;replay;remoteCaptureTimer;installedCaptureKey=``;replayBuiltKey=``;console;drops;meter;bus=null;busBuilt;busLoad;storageBuiltAs;sender;senderLoad;pendingRecords=new Ut(e=>{this.dropHeld(e)});captures=[];captureGeneration=0;captureOnce={webVitals:!1,navigationTiming:!1,longFrames:!1,uncleanExit:!1,userTiming:!1};bootBuffer=new Ut(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=()=>{C(this),this.role()===`forwarder`&&(this.tracing.end(),this.sendForwarded())};constructor(e,t=!1){this.diagnostics=new V(e.onDiagnostic),this.platform=a.n(this.diagnostics),this.degraded=t||this.onServer(),this.config=B(this.allowed(e),this.diagnostics),this.explicitSecurityContext=!!e.securityContext?.id,this.config.securityContext.id||=l.i(this.diagnostics),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.identityBuiltAs=this.config.identity,this.stores=this.identityBuiltAs===`memory`||this.onServer()?l.r():l.t,this.identity=l.s(this.diagnostics,this.stores,this.config.correlation.sessionIdleMs),this.sessionTouch=new l.n(this.diagnostics,this.stores,this.config.correlation.sessionTouchMs,this.config.correlation.sessionIdleMs),this.breadcrumbs=new Ae(this.config.capturePolicy.breadcrumbs);let n=e=>p.i(e,this.config.sampling.defaultRate);this.tracing=new ke(this.diagnostics,this.config.correlation.traceMaxAgeMs||1/0,this.config.otelLoader,{enabled:()=>this.config.tracesEndpoint!==``,keeps:n,onEnd:e=>{n(e.traceId)&&this.recordSpan(nn(e))}}),this.tracing.loadOtel(),this.limits={...this.config.limits},this.console=new ye(this.config.console,this.diagnostics,this.limits),this.drops=new Ht(this.config,this.diagnostics),this.journeyOptions={...f.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new f.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new Qt({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,debug:this.debugBuffer}),this.meter=new _e(()=>this.config.batching.metricFlushIntervalMs,(e,t,n)=>{this.emitPoint(e,t,n)},this.diagnostics,this.config.metrics),this.diagnostics.setHandler(this.diagnosticHandler()),this.syncProfiler()}diagnosticHandler(){return this.config.diagnostics.records===!1?this.config.onDiagnostic:e=>{this.recordDiagnostic(e),this.config.onDiagnostic?.(e)}}recordDiagnostic(e){let{records:t}=this.config.diagnostics;if((t===!0||t!==!1&&t.includes(e.code))&&!this.recordingDiagnostic){this.recordingDiagnostic=!0;try{(dn.has(e.code)?this.diagnosticLogger.info:this.diagnosticLogger.warn)(e.message,{"diagnostic.code":e.code,"diagnostic.count":e.count,"diagnostic.detail":pn(e.detail)})}finally{this.recordingDiagnostic=!1}}}addBreadcrumb(e,t){this.rotating||this.destroyed||this.diagnostics.guard(`record.sanitize_failed`,`The library could not add the breadcrumb.`,()=>{let n={t:Date.now(),category:`custom`,message:c.i(String(e),this.limits.maxBodyChars)};if(t!==void 0){let e=c.n(t,this.limits,this.diagnostics);n.data=r.t(e)?e:{value:e}}this.breadcrumbs.push(n)})}recordMetric(e,t,n){!this.destroyed&&!this.rotating&&this.meter.record(e,t,n)}startMeasure(e,t){let n=this.identityEpoch,r=()=>!this.destroyed&&!this.rotating&&(!this.config.securityContext.isolation||this.identityEpoch===n),i=this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the measure.`,()=>({...t}));return Kt(this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the name of the measure.`,()=>`${e}`)??``,i??{},this.tracing.request().span,{metric:(e,t,n)=>{r()&&this.recordMetric(e,t,n)},span:e=>{r()&&this.recordSpan(e)}})}recordSpan(t){if(this.config.tracesEndpoint===``)return;let{record:n}=this.builder.build({level:`INFO`,type:`span`,body:t.name,namespace:e.Jn,payload:t.attributes,fixed:rn(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.Ft,payload:n,fixed:r,aggregated:!0});this.emit(i)}syncProfiler(){let{enabled:e}=this.config.profiler;if(e===this.profilerOn)return;this.profilerOn=e;let t=o.t();if(!e){t.collect(!1),t.detach();return}let n={capacity:this.config.profiler.maxProbes,intervalMs:()=>this.config.profiler.flushIntervalMs,emit:(e,t,n)=>{this.emitPoint(e,t,n)},diagnostics:this.diagnostics,ready:()=>!this.rotating||this.closingContext,outlier:(e,t)=>{this.breadcrumbs.push({t:Date.now(),category:`profile`,message:`${e} ${String(Math.round(t))} ms`})}};t.attach(n)}setReplay(e){this.replayConsent=e,e?this.replay?.start():this.replay?.stop()}collectPoints(){this.meter.collect(),this.profilerOn&&o.t().collect(!1)}advanceIdentity(){this.identityEpoch++,this.profilerOn&&this.config.securityContext.isolation&&o.t().reset()}busCanAccept=(e,t)=>this.bus?.isRegistered(e,t)??!1;busAccept=(e,t,n)=>{this.destroyed||this.ensureBus().then(r=>{r&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{r.acceptDirect(e,t,n)})})};static pinned(){return globalThis[G]??null}static current(){let e=n.local;if(e)return e.destroyed?null:e;let t=n.pinned();return t&&gn(t)?t:null}static stopped(){let e=n.local;if(e?.destroyed)return e;let t=globalThis[K];return t&&gn(t)?t:null}isDestroyed(){return this.destroyed}static configure(e,t=!1){let r=n.local;if(r&&!r.destroyed)return r.reconfigure(e),r;n.local=null;let i=n.pinned();if(i){if(!gn(i))return n.startDegraded(e,i.sdkVersion);if(!i.destroyed)return i.reconfigure(e),i}let a=new n(e);return a.tunablesLocked=!t,globalThis[G]=a,Reflect.deleteProperty(globalThis,K),a.init(),a}static startDegraded(t,r){let i=new n(t,!0);n.local=i;let a=typeof r==`string`?r:`before 0.9.0`;return i.mismatchVersion=a,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){if(this.rotating){this.diagnostics.report(`config.locked`,`Configuration cannot change during security-context rotation.`);return}if(this.config.lockConfiguration){let t=B(e,this.diagnostics,this.config);J(this.config,t)||this.diagnostics.report(`config.locked`,`Runtime configuration is locked. Use setConfigurationLocked(false) to unlock it explicitly.`);return}C(this);let t=this.keepDestination(this.keepRouting(this.allowed(e)));!this.tunablesLocked&&t.securityContext?.id&&(this.explicitSecurityContext=!0);for(let e of[`correlation`,`persistence`])(e!==`persistence`||this.tunablesLocked||this.senderLoad!==void 0)&&t[e]&&!J({...this.config[e],...t[e]},this.config[e])&&(this.diagnostics.report(`config.invalid`,`${e} cannot change after startup.`),Object.assign(t,{[e]:this.config[e]}));let n=B(t,this.diagnostics,this.config);this.keepStartupTunables(n);let{redact:r,processors:i}=this.config;zt(this.config,n),(this.config.redact!==r||this.config.processors!==i)&&this.debugBuffer.clear(),this.breadcrumbs.resize(this.config.capturePolicy.breadcrumbs),this.diagnostics.setHandler(this.diagnosticHandler()),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.builder.invalidateResource(),this.console.update(this.config.console),this.keepBuiltStorage(),this.keepBuiltIdentity(),this.syncProfiler(),this.refreshCaptures(),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&&hn(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, transport and transportWorker.`)),mn(e)):e}keepRouting(e){if(!this.tunablesLocked||this.degraded||!this.config.securityContext.isolation)return e;let t=B(e,new V,this.config),n=un.filter(e=>!J(t[e],this.config[e]));if(t.securityContext.id!==this.config.securityContext.id&&n.push(`securityContext.id`),n.length===0)return e;let r={...e};for(let e of un)n.includes(e)&&Reflect.deleteProperty(r,e);if(n.includes(`securityContext.id`)){let t={...e.securityContext};Reflect.deleteProperty(t,`id`),r.securityContext=t}return this.diagnostics.report(`config.invalid`,`Isolation refuses changes to ${n.join(`, `)}. Use rotateSecurityContext() for these changes. To permit them, set securityContext.isolation: false in a separate configure() call. The other settings apply.`),r}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,cn),!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);let{maxProbes:n}=this.config.profiler;e.profiler.maxProbes!==n&&(this.diagnostics.report(`config.invalid`,`profiler.maxProbes cannot change after startup. It stays ${String(n)}.`,{requested:e.profiler.maxProbes}),e.profiler.maxProbes=n)}keepSections(e,t){for(let n of t)J(e[n],this.config[n])||(this.diagnostics.report(`config.invalid`,`${n} cannot change after startup. The current values 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;for(let n of[`transport`,`transportWorker`])n in e&&e[n]===void 0!=(this.config[n]===void 0)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove ${n} after the delivery stack loads. The current transport stays.`),t={...t},Reflect.deleteProperty(t,n));return(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 current endpoint 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-D_7pd7RN.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onSecurityContext:e=>{if(this.explicitSecurityContext&&this.config.securityContext.id!==e)return this.contextMismatch=!0,this.diagnostics.report(`security.context_mismatch`,`The configured security context differs from the upstream owner.`),!1;if(this.contextMismatch=!1,this.config.securityContext.id!==e){if(this.ownerAdopted){C(this),this.drops.add(`security_context`,[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer]),this.forwardBuffer=[],this.context.clear(),this.breadcrumbs.clear();let e=this.rotating;this.rotating=!0,this.collectPoints(),this.profilerOn&&o.t().reset();let t=this.sessionTouch.stored();this.resetSession(t!==void 0&&t!==this.identity.sessionId?t:l.i(this.diagnostics)),this.rotating=e,this.advanceIdentity(),this.remote.sampling=null,this.refreshCaptures()}this.config.securityContext.id=e}return this.ownerAdopted=!0,!0},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-Bfpv9tad.cjs")),t=this.destroyed?null:await e.create({storage:this.memoryStorage,onStorage:e=>{e.name===`memory`&&(this.memoryStorage=e)},onPersistence:e=>{this.storagePersistence=e},config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote,beforeExit:()=>{C(this),this.collectPoints(),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)}refreshCaptures(){if(clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 0,this.destroyed)return;let e=this.remote.sampling?.wire();e&&(this.remoteCaptureTimer=setTimeout(()=>{this.refreshCaptures()},e.ttlMs),i.t(this.remoteCaptureTimer)),this.captureState(this.effectiveCapture())!==this.installedCaptureKey&&this.installCaptures()}captureState(e){let{enabled:t,framePhases:n,framePacing:r}=this.config.profiler;return`${fn(e)}${String(t&&n)}${String(t&&r)}${this.replayState(e)}`}replayState(e){let{replay:t}=this.config;return t.enabled?JSON.stringify([t.loader&&W(t.loader),t.onSegment&&W(t.onSegment),W(t.recordOptions),t.endpoint,t.requireConsent,t.mode,t.maskText,t.maskInputs,t.maskSelectors,t.blockSelectors,t.recordCanvas,t.bufferMs,t.plugins.map(W),e.fullUrls,e.ignoreUrls.map(String)]):``}effectiveCapture(){let t={...this.config.capture},n=this.remote.sampling?.current()?.capture;for(let r of e.nn){let e=n?.[r];if(t.remoteToggles.includes(r)&&e!==void 0){if(e&&typeof t[r]==`object`)continue;t[r]=e}}return t}async installCaptures(){if(this.degraded)return;let t=++this.captureGeneration,n=this.effectiveCapture();this.installedCaptureKey=this.captureState(n);let r=this.replayState(n);r!==this.replayBuiltKey&&(this.replayBuiltKey=``);let i=r!==``&&r===this.replayBuiltKey?this.replay:void 0,a=[],{profiler:o}=this.config;(n.errors||n.rejections||n.resourceErrors)&&a.push(`errors`),(n.fetch||n.xhr)&&a.push(`network`),(n.interactions||n.navigation)&&a.push(`interactions`),n.webVitals&&a.push(`webVitals`),n.longFrames&&a.push(`longFrames`),(Array.isArray(n.console)?n.console.length>0:n.console)&&a.push(`console`),n.uncleanExit&&a.push(`uncleanExit`),n.userTiming&&a.push(`userTiming`),n.reports&&a.push(`reports`),n.resourceTiming&&a.push(`resourceTiming`),n.lifecycle&&a.push(`lifecycle`),o.enabled&&o.framePhases&&a.push(`framePhases`),o.enabled&&o.framePacing&&a.push(`framePacing`),this.config.replay.enabled&&!i&&a.push(`replay`);let[s,c]=await Promise.all([Promise.all(a.map(e=>this.loadCapture(e))),n.webSocket?this.loadWebSocket():void 0]);if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures(i);let l={isActive:()=>!this.destroyed&&!this.rotating,config:Object.assign(Object.create(this.config),{capture:n}),diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new T(()=>this,e.N),once:this.captureOnce,recordMetric:(e,t,n)=>{this.recordMetric(e,t,n)},recordSpan:e=>{this.recordSpan(e)},sessionId:()=>this.identity.sessionId,onError:e=>{this.errorHook=e},setContext:(e,t)=>{t===void 0?this.context.remove(e):this.context.set(e,t)},replayConsent:()=>this.replayConsent};s.forEach((e,t)=>{if(e){let n=new e(l);this.captures.push(n),a[t]===`replay`&&(this.replay=n,this.replayBuiltKey=r)}});let u=c?[...n.plugins,new c(this.diagnostics,l.config)]:n.plugins;for(let e of u)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(e){for(let t of this.captures)t!==e&&this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${t.name} capture.`,()=>{t.uninstall()});this.captures.length=0,this.replay=e,e&&this.captures.push(e)}loadWebSocket(){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the webSocket capture.`,async()=>(await Promise.resolve().then(()=>require("./web-socket-BTuvYoJI.cjs"))).WebSocketCapture)}pluginCapture(t){let{name:n}=t,r=(e,t,n)=>{this.recordMetric(e,t,n)},i=t=>{this.diagnostics.report(`config.invalid`,e._t,void 0,t)},a={logger:new T(()=>this,`${e.N}.${n}`),counter:(e,t={})=>he(e,t,r,i),histogram:(e,t={})=>ge(e,t,r,i),addBreadcrumb:(e,t)=>{this.addBreadcrumb(e,t)},ownRequest:u.r};return{name:n,install:()=>{t.install(a)},uninstall:()=>{t.uninstall()}}}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,an[e])}registerWorker(e,t={}){let n=!1,r;return this.destroyed?()=>void 0:(this.constructBus().then(i=>{!i||this.destroyed||n||(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{r=i.attachWorker(e,t)}),this.ensureBus())}),()=>{n=!0,r?.()})}registerFrame(e,t){let n=!1,r;return this.constructBus().then(i=>{!i||this.destroyed||n||(r=this.diagnostics.guard(`bus.send_failed`,`The frame could not be registered.`,()=>i.registerFrame(e,t)),this.ensureBus())}),()=>{n=!0,r?.()}}async destroy(){if(this.destroyed)return;C(this),this.collectPoints(),this.profilerOn&&(this.profilerOn=!1,o.t().detach()),this.tracing.end(),this.destroyed=!0,te(this),clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 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,await this.rotation?.catch(()=>void 0),await this.memoryStorage?.close(),n.pinned()===this&&(Reflect.deleteProperty(globalThis,G),globalThis[K]=this)}emit(e){if(!e||this.destroyed||this.rotating&&!this.closingContext)return;this.sessionTouch.touch(this.identity.sessionId);let t=e.severityText===`ERROR`||e.severityText===`FATAL`,n=t?[...this.debugBuffer.drain(),e]:[e];t&&this.errorHook?.(e);for(let e of n)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(this.destroyed)return;if(!Array.isArray(e)){this.diagnostics.count(`record.dropped_malformed`);return}let n=[];for(let r of e){if(!t.n(r)){this.diagnostics.count(`record.dropped_malformed`);continue}if(r.attributes[`uiobs.debug_buffer`]!==!0&&!p.a(r,this.config,this.remote.sampling?.current()??null)){this.diagnostics.count(`record.dropped_by_sampling`);continue}let e=this.builder.redactForwarded(r);e&&n.push(e)}if(this.rotating)this.drops.add(`security_context`,n);else for(let e of n)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 T(()=>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=l.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,l.a(e,this.diagnostics,this.stores),this.builder.invalidateResource()}newSession(){this.destroyed||(C(this),this.resetSession(l.i(this.diagnostics)))}resetSession(e){this.collectPoints(),this.tracing.rotate(`explicit`),this.journey.end(),this.breadcrumbs.clear(),this.debugBuffer.clear(),this.replay?.reset(),this.identity.sessionId=e,this.sessionTouch.restart(e),this.builder.invalidateResource()}rotateSecurityContext(e,t={}){if(this.rotation)return Promise.reject(Error(`A security-context rotation is already running.`));let n=t.pending??`discard`,i=t.timeoutMs??5e3;return!r.t(e)||!r.t(e.delivery)||![`discard`,`flush`,`retain`,`carry`].includes(n)||!Number.isFinite(i)||i<0||e.id!==void 0&&(typeof e.id!=`string`||e.id.length===0)?Promise.reject(Error(`Invalid security-context rotation options.`)):this.destroyed?Promise.reject(Error(`The runtime has stopped.`)):(C(this),this.rotating=!0,this.rotation=this.rotateContext(e,n,i).finally(()=>{this.rotating=!1,this.rotation=void 0}),this.rotation)}async rotateContext(e,t,n){if(await this.started,this.role()===`forwarder`)throw Error(`Rotate the security context on the upstream owner, or use bus.mode: sender for an independent identity.`);await this.senderLoad;let r=this.config.securityContext.id,i=e.id??l.i(this.diagnostics);if(i===r)throw Error(`A rotation requires a different security-context id.`);let a={...ln,...e.delivery},o=this.diagnostics.snapshot()[`config.invalid`]??0,s=B(this.allowed({...a,securityContext:{id:i}}),this.diagnostics,{...this.config,...ln});if((this.diagnostics.snapshot()[`config.invalid`]??0)!==o)throw Error(`Invalid delivery settings for the next security context.`);let c=e.context?Object.fromEntries(Object.entries(e.context)):void 0,u=new Set([this.config.endpoint,this.config.metricsEndpoint,this.config.tracesEndpoint]),d=new Set([s.endpoint,s.metricsEndpoint,s.tracesEndpoint]);s.capture.ignoreUrls=s.capture.ignoreUrls.filter(e=>!u.has(e)||d.has(e)),this.closingContext=!0;try{this.collectPoints(),this.tracing.end(),this.journey.end()}finally{this.closingContext=!1}let f=[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer];this.forwardBuffer=[];let p=this.sender;this.sender=void 0,this.senderLoad=void 0;let m=await p?.retire(t,n,r)??{buffered:[],stored:[]};if(this.destroyed)return;let h=[...f,...m.buffered],g=m.stored.flatMap(e=>e.records);t!==`retain`&&t!==`carry`&&this.drops.add(`security_context`,[...h,...g]),s.lockConfiguration=this.config.lockConfiguration,zt(this.config,s),this.advanceIdentity(),this.remote.sampling=null,this.refreshCaptures(),this.context.clear(),c&&this.context.setMany(c),this.breadcrumbs.clear(),this.newSession(),this.builder.invalidateResource(),await this.syncSender(),this.bus?.rotateContext(),this.rotating=!1,t===`carry`&&await this.carry(h,m.stored),this.diagnostics.report(`security.rotated`,`The runtime rotated its security context.`,{pending:t})}async carry(e,t){for(let t of e)this.route(t);this.sender&&await this.sender.adopt(t,this.config.securityContext.id)}async debugBundle(t){let{configSummary:n}=await Promise.resolve().then(()=>require("./debug-bundle-Ex4L_LSP.cjs")),{record:r}=this.builder.build({level:`INFO`,type:`system`,body:`debug bundle`,namespace:e.q,payload:{[e.c]:this.breadcrumbs.snapshot()}},!0),i=r?.attributes??{},a=i[e.c],o=i[e.v];return{createdAt:new Date().toISOString(),sdkVersion:this.sdkVersion,health:t,diagnostics:this.diagnostics.snapshot(),resource:r?.resource??{},pageUrl:typeof o==`string`?o:``,breadcrumbs:Array.isArray(a)?a:[],debugBuffer:this.debugBuffer.snapshot(),config:n(this.config,this.limits,this.diagnostics)}}async health(){let e=this.sender?.stats()??{pending:0,inFlight:0,lastSendAt:null},t=[];this.mismatchVersion&&t.push(`runtime.version_mismatch`),this.contextMismatch&&t.push(`security.context_mismatch`),this.ready&&this.hasDestination()&&this.role()===`sender`&&!this.sender&&t.push(`sender.unavailable`);let{sourcePolicy:n,validation:r,maxMessageBytes:i,maxRecordsPerMessage:a,maxMessagesPerSecond:o,maxTrackedSources:s}=this.config.bus;return{...e,pending:e.pending+this.bootBuffer.length+this.pendingRecords.length+this.forwardBuffer.length,stored:await this.sender?.queueDepth()??0,sdkVersion:this.sdkVersion,owningSdkVersion:this.mismatchVersion,status:this.destroyed?`stopped`:this.rotating?`rotating`:t.length?`degraded`:this.ready?`ready`:`starting`,mode:this.role()===`forwarder`?`forwarder`:this.hasDestination()?`sender`:`console-only`,senderReady:this.sender!==void 0&&!this.destroyed&&!this.rotating,configurationLocked:this.config.lockConfiguration,issues:t,securityContext:{...this.config.securityContext},storagePersistence:this.storagePersistence,bus:{sourcePolicy:n,validation:r,maxMessageBytes:i,maxRecordsPerMessage:a,maxMessagesPerSecond:o,maxTrackedSources:s}}}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 clearPersisted(e){if(await this.senderLoad,this.sender){await this.sender.clearPersisted(e,this.config.securityContext.id);return}let[{createStorage:t,storageName:n},{ContextStorage:r},{storageLimits:i},{clearEmergencyContext:a}]=await Promise.all([Promise.resolve().then(()=>require("./factory-DLFDjdLv.cjs")),Promise.resolve().then(()=>require("./context-storage-BjzeBSxH.cjs")),Promise.resolve().then(()=>require("./storage-BA9RqRO-.cjs")),Promise.resolve().then(()=>require("./emergency-queue-HBpL5r3V.cjs"))]),o=this.config.persistence.namespace,s=this.memoryStorage??await t(this.config.storage,n(o),i(this.config.retention),this.diagnostics,void 0,o),c=new r(s,this.config.securityContext,o);try{e===`namespace`?await c.clearNamespace():await c.clear(),a(this.config.securityContext.id,this.diagnostics,o,e===`namespace`)}finally{s!==this.memoryStorage&&await c.close()}}async queueDepth(){return await this.senderLoad,await this.sender?.queueDepth()??0}async flush(){C(this),this.collectPoints(),this.ready||await this.started,this.role()===`forwarder`?this.sendForwarded():(await this.senderLoad,await this.sender?.flush())}};function J(e,t,n=new WeakMap){if(Object.is(e,t))return!0;if(e instanceof RegExp&&t instanceof RegExp)return String(e)===String(t);if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&J(Reflect.get(e,r),Reflect.get(t,r),n))}var Y;function _n(t={}){if(Y)return Y;let n=new V(t.onDiagnostic);if(typeof document<`u`||typeof addEventListener!=`function`)return n.report(`config.invalid`,`Call serveTransportWorker() in a dedicated worker.`),()=>void 0;let i=!1,a,o,s=t=>{n.guard(`transport.http_error`,`The transport worker could not read its connection.`,()=>{let s=t.data;if(!r.t(s)||s.p!==`ui-observability.transport/1`||s.t!==e.Qn.connect||t.ports.length===0)return;let c=t.ports[0];a||s.v!==`0.12.0`?(c.postMessage(e.Zn),c.close()):(a=c,Promise.resolve().then(()=>require("./worker-server-4en-Lt-3.cjs")).then(e=>{i||(o=e.serveWorkerPort(c,n))}).catch(t=>{n.report(`transport.http_error`,`The transport worker delivery module could not load.`,void 0,t),n.guard(`transport.http_error`,`The failed transport port could not be closed.`,()=>{c.postMessage(e.Zn),c.close()})}))})},c=()=>{i||(i=!0,Y=void 0,removeEventListener(`message`,s),o?.(),n.guard(`transport.http_error`,`The transport service could not close its port.`,()=>{a?.postMessage(e.Zn)}),n.guard(`transport.http_error`,`The transport port could not close.`,()=>{a?.close()}))};return addEventListener(`message`,s),Y=c,c}function vn(){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(q.current()??q.stopped())||q.configure({},!0)}function yn(e=`context`){return[`context`,`namespace`].includes(e)?Z().clearPersisted(e):Promise.reject(Error(`Invalid persistence scope.`))}function bn(e){q.configure(e),Q()}function xn(e){Z().setConfigurationLocked(e)}function Sn(e,t){return Z().rotateSecurityContext(e,t)}async function Cn(){let e=Z();return Q(),{...await e.health(),loggerCache:{...e.config.loggerCache,size:X.size}}}async function wn(){let e=await Cn();return Z().debugBundle(e)}function Q(){let e=(q.current()??q.stopped())?.config.loggerCache.maxEntries,t=e===void 0?256:e;if(t!==null)for(let e of X.keys()){if(X.size<=t)break;X.delete(e)}return t}function Tn(e,t){let n=Q();if(t||n===0)return new T(Z,e,t);let r=X.get(e);return r??=new T(Z,e),X.delete(e),X.set(e,r),Q(),r}function $(){return Tn(`app`)}function En(e,t){$().trace(e,t)}function Dn(e,t){$().debug(e,t)}function On(e,t){$().info(e,t)}function kn(e,t){$().warn(e,t)}function An(e,t,n){$().error(e,t,n)}function jn(e,t,n){$().fatal(e,t,n)}function Mn(e,t){$().logAction(e,t)}function Nn(e,t){$().logEvent(e,t)}function Pn(e,t,n,r,i){$().logMetric(e,t,n,r,i)}function Fn(t){q.current()?.diagnostics.report(`config.invalid`,e._t,void 0,t)}function In(e,t={}){return he(e,t,(e,t,n)=>{Z().recordMetric(e,t,n)},Fn)}function Ln(e,t={}){return ge(e,t,(e,t,n)=>{Z().recordMetric(e,t,n)},Fn)}function Rn(e,t){return Z().startMeasure(e,t)}function zn(){Z().setReplay(!0)}function Bn(){Z().setReplay(!1)}var Vn={probe:(e,t)=>o.t().probe(e,t,q.current()?.diagnostics),time:(e,t)=>o.t().time(e,t,q.current()?.diagnostics)};function Hn(e,t,n){return $().timeSync(e,t,n)}function Un(e,t,n){return $().timeAsync(e,t,n)}function Wn(e,t){Z().addBreadcrumb(e,t)}function Gn(e,t){Z().context.set(e,t)}function Kn(e){Z().context.setMany(e)}function qn(e){Z().context.remove(e)}function Jn(e,t){return Z().journey.start(e,t)}function Yn(){Z().journey.end()}function Xn(){return Z().journey.current()}function Zn(){return Z().journey.getToken()}function Qn(e){return Z().journey.adopt(e,`manual`,!0)}function $n(e,t){return Z().registerWorker(e,t)}function er(e,t){return Z().registerFrame(e,t)}function tr(){Z().tracing.rotate(`explicit`)}function nr(){return Z().tracing.headers()}function rr(){return Z().flush()}function ir(){return Z().queueDepth()}function ar(){return Z().stats()}function or(){Z().newSession()}function sr(){return Z().diagnostics.snapshot()}async function cr(){await q.current()?.destroy()}exports.OneLogger=T,exports.addBreadcrumb=Wn,exports.adoptJourney=Qn,exports.clearPersistedLogs=yn,exports.collectDebugBundle=wn,exports.configure=bn,exports.counter=In,exports.createMemoryTransport=vn,exports.currentJourney=Xn,exports.debug=Dn,exports.endJourney=Yn,exports.error=An,exports.fatal=jn,exports.flush=rr,exports.getDiagnosticCounters=sr,exports.getHealth=Cn,exports.getJourneyToken=Zn,exports.getLogger=Tn,exports.getQueueDepth=ir,exports.getStats=ar,exports.getTraceHeaders=nr,exports.histogram=Ln,exports.info=On,exports.logAction=Mn,exports.logEvent=Nn,exports.logMetric=Pn,exports.newSession=or,exports.profiler=Vn,exports.registerFrame=er,exports.registerWorker=$n,exports.removeContext=qn,exports.rotateSecurityContext=Sn,exports.serveTransportWorker=_n,exports.setConfigurationLocked=xn,exports.setContext=Gn,exports.setContextMap=Kn,exports.shutdown=cr,exports.startJourney=Jn,exports.startMeasure=Rn,exports.startReplay=zn,exports.startTrace=tr,exports.stopReplay=Bn,exports.timeAsync=Un,exports.timeSync=Hn,exports.trace=En,exports.warn=kn;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|