@utk09/ui-observability 0.12.0 → 1.0.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 +420 -0
- package/README.md +72 -839
- package/dist/{batch-BjQUwjA6.js → batch-CXmPmTse.js} +4 -4
- package/dist/{batch-BjQUwjA6.js.map → batch-CXmPmTse.js.map} +1 -1
- package/dist/{batch-D5LlU4Q9.cjs → batch-mmPigCpi.cjs} +2 -2
- package/dist/{batch-D5LlU4Q9.cjs.map → batch-mmPigCpi.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +331 -0
- package/dist/bus/bus.d.ts +60 -10
- package/dist/bus/links.d.cts +132 -0
- package/dist/bus/links.d.ts +18 -3
- package/dist/bus/validation.d.cts +16 -0
- package/dist/bus/validation.d.ts +10 -1
- package/dist/{bus-ecxUNTja.js → bus-C39wspFV.js} +308 -193
- package/dist/bus-C39wspFV.js.map +1 -0
- package/dist/bus-_EaOVPGq.cjs +2 -0
- package/dist/bus-_EaOVPGq.cjs.map +1 -0
- package/dist/capture/console.d.cts +37 -0
- package/dist/capture/console.d.ts +1 -1
- package/dist/capture/errors.d.cts +32 -0
- package/dist/capture/errors.d.ts +1 -1
- package/dist/capture/interactions.d.cts +48 -0
- package/dist/capture/interactions.d.ts +1 -1
- package/dist/capture/lifecycle.d.cts +20 -0
- package/dist/capture/lifecycle.d.ts +1 -1
- package/dist/capture/long-frames.d.cts +31 -0
- package/dist/capture/long-frames.d.ts +1 -1
- package/dist/capture/network.d.cts +57 -0
- package/dist/capture/network.d.ts +1 -1
- package/dist/capture/profiler-frames.d.cts +44 -0
- package/dist/capture/profiler-frames.d.ts +1 -1
- package/dist/capture/replay-buffer.d.cts +45 -0
- package/dist/capture/replay-buffer.d.ts +9 -10
- package/dist/capture/replay-upload.d.cts +79 -0
- package/dist/capture/replay-upload.d.ts +7 -2
- package/dist/capture/replay.d.cts +114 -0
- package/dist/capture/replay.d.ts +1 -1
- package/dist/capture/reports.d.cts +17 -0
- package/dist/capture/reports.d.ts +1 -1
- package/dist/capture/resource-timing.d.cts +14 -0
- package/dist/capture/resource-timing.d.ts +1 -1
- package/dist/capture/server-timing.d.cts +19 -0
- package/dist/capture/storm.d.cts +13 -0
- package/dist/capture/storm.d.ts +5 -5
- package/dist/capture/types.d.cts +128 -0
- package/dist/capture/types.d.ts +10 -9
- package/dist/capture/unclean-exit.d.cts +31 -0
- package/dist/capture/unclean-exit.d.ts +1 -1
- package/dist/capture/user-timing.d.cts +22 -0
- package/dist/capture/user-timing.d.ts +2 -2
- package/dist/capture/web-socket.d.cts +40 -0
- package/dist/capture/web-socket.d.ts +3 -3
- package/dist/capture/web-vitals.d.cts +40 -0
- package/dist/capture/web-vitals.d.ts +1 -1
- package/dist/{compression-lD9abCcO.cjs → compression-CvED_Jel.cjs} +2 -2
- package/dist/{compression-lD9abCcO.cjs.map → compression-CvED_Jel.cjs.map} +1 -1
- package/dist/{compression-AJJCMBOa.js → compression-tVtXwVjX.js} +2 -2
- package/dist/{compression-AJJCMBOa.js.map → compression-tVtXwVjX.js.map} +1 -1
- package/dist/config-DUs7uHHt.cjs +2 -0
- package/dist/config-DUs7uHHt.cjs.map +1 -0
- package/dist/config-SgQcCP1_.js +560 -0
- package/dist/config-SgQcCP1_.js.map +1 -0
- package/dist/console-BGgGnjSi.js +81 -0
- package/dist/console-BGgGnjSi.js.map +1 -0
- package/dist/console-CSZ5_Vx5.cjs +2 -0
- package/dist/console-CSZ5_Vx5.cjs.map +1 -0
- package/dist/constants-CUyd9cTZ.js +357 -0
- package/dist/constants-CUyd9cTZ.js.map +1 -0
- package/dist/constants-CqdJhTxH.cjs +2 -0
- package/dist/constants-CqdJhTxH.cjs.map +1 -0
- package/dist/constants.d.cts +751 -0
- package/dist/constants.d.ts +88 -20
- package/dist/core/breadcrumbs.d.cts +54 -0
- package/dist/core/breadcrumbs.d.ts +5 -0
- package/dist/core/config.d.cts +45 -0
- package/dist/core/config.d.ts +30 -2
- package/dist/core/context.d.cts +24 -0
- package/dist/core/context.d.ts +3 -8
- package/dist/core/debug-buffer.d.cts +34 -0
- package/dist/core/debug-buffer.d.ts +3 -3
- package/dist/core/debug-bundle.d.cts +12 -0
- package/dist/core/debug-bundle.d.ts +3 -3
- package/dist/core/deferred.d.cts +7 -0
- package/dist/core/deferred.d.ts +2 -2
- package/dist/core/diagnostics.d.cts +86 -0
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/drops.d.cts +39 -0
- package/dist/core/drops.d.ts +16 -6
- package/dist/core/hold-buffer.d.cts +36 -0
- package/dist/core/hold-buffer.d.ts +16 -7
- package/dist/core/journey.d.cts +148 -0
- package/dist/core/journey.d.ts +7 -7
- package/dist/core/logger.d.cts +141 -0
- package/dist/core/logger.d.ts +23 -30
- package/dist/core/measure.d.cts +30 -0
- package/dist/core/measure.d.ts +14 -3
- package/dist/core/meter.d.cts +78 -0
- package/dist/core/meter.d.ts +14 -8
- package/dist/core/pipeline.d.cts +227 -0
- package/dist/core/pipeline.d.ts +73 -10
- package/dist/core/profile-buckets.d.cts +31 -0
- package/dist/core/profiler.d.cts +218 -0
- package/dist/core/profiler.d.ts +2 -2
- package/dist/core/record.d.cts +190 -0
- package/dist/core/record.d.ts +44 -12
- package/dist/core/remote-rules.d.cts +17 -0
- package/dist/core/remote-rules.d.ts +3 -3
- package/dist/core/remote-sampling.d.cts +74 -0
- package/dist/core/remote-sampling.d.ts +3 -3
- package/dist/core/rotation.d.cts +75 -0
- package/dist/core/rotation.d.ts +75 -0
- package/dist/core/runtime.d.cts +765 -0
- package/dist/core/runtime.d.ts +245 -70
- package/dist/core/sampling.d.cts +86 -0
- package/dist/core/sampling.d.ts +5 -5
- package/dist/core/sender.d.cts +161 -0
- package/dist/core/sender.d.ts +59 -15
- package/dist/core/spans.d.cts +39 -0
- package/dist/core/spans.d.ts +1 -1
- package/dist/debug-bundle-BXIlwDKM.cjs +2 -0
- package/dist/debug-bundle-BXIlwDKM.cjs.map +1 -0
- package/dist/debug-bundle-CRpYV_ui.js +35 -0
- package/dist/debug-bundle-CRpYV_ui.js.map +1 -0
- package/dist/defineProperty-X1c4tIPD.cjs +1 -0
- package/dist/defineProperty-s2S8BXUc.js +35 -0
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.cjs.map +1 -1
- package/dist/doctor.d.cts +36 -0
- package/dist/doctor.d.ts +5 -2
- package/dist/doctor.js +121 -89
- package/dist/doctor.js.map +1 -1
- package/dist/errors-BE_EZV7Q.js +86 -0
- package/dist/errors-BE_EZV7Q.js.map +1 -0
- package/dist/errors-CNPbesMs.cjs +3 -0
- package/dist/errors-CNPbesMs.cjs.map +1 -0
- package/dist/factory-CTi0Is3F.js +404 -0
- package/dist/factory-CTi0Is3F.js.map +1 -0
- package/dist/factory-hRrH32v5.cjs +2 -0
- package/dist/factory-hRrH32v5.cjs.map +1 -0
- package/dist/guards-BlYGRK4l.js +10 -0
- package/dist/guards-BlYGRK4l.js.map +1 -0
- package/dist/guards-EjG3ahFp.cjs +2 -0
- package/dist/guards-EjG3ahFp.cjs.map +1 -0
- package/dist/{identity-BrQp_5J5.js → identity-DdhKgrpk.js} +20 -24
- package/dist/identity-DdhKgrpk.js.map +1 -0
- package/dist/identity-DlWRIuwy.cjs +2 -0
- package/dist/identity-DlWRIuwy.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +300 -0
- package/dist/index.d.ts +89 -98
- package/dist/index.js +1173 -1506
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-CL9uqBCy.cjs +2 -0
- package/dist/indexeddb-storage-CL9uqBCy.cjs.map +1 -0
- package/dist/{indexeddb-storage-DLXQzAGh.js → indexeddb-storage-GHdl0t8A.js} +51 -47
- package/dist/indexeddb-storage-GHdl0t8A.js.map +1 -0
- package/dist/interactions-CUkzK8sR.cjs +2 -0
- package/dist/interactions-CUkzK8sR.cjs.map +1 -0
- package/dist/{interactions-B6z2I4tU.js → interactions-DiFvCosX.js} +41 -49
- package/dist/interactions-DiFvCosX.js.map +1 -0
- package/dist/journey-B4Adltjm.cjs +2 -0
- package/dist/journey-B4Adltjm.cjs.map +1 -0
- package/dist/{journey-35yCMNFo.js → journey-D2_sia57.js} +45 -48
- package/dist/journey-D2_sia57.js.map +1 -0
- package/dist/{library-console-Dl_Ly6DQ.js → library-console-Btrzt814.js} +2 -2
- package/dist/{library-console-Dl_Ly6DQ.js.map → library-console-Btrzt814.js.map} +1 -1
- package/dist/{library-console-BFWEuQsl.cjs → library-console-CPW6bvZH.cjs} +2 -2
- package/dist/{library-console-BFWEuQsl.cjs.map → library-console-CPW6bvZH.cjs.map} +1 -1
- package/dist/{library-request-nI6pvI6I.js → library-request-BJ9PLRaD.js} +2 -2
- package/dist/{library-request-nI6pvI6I.js.map → library-request-BJ9PLRaD.js.map} +1 -1
- package/dist/{library-request-Da-CHKzT.cjs → library-request-D7OvTxZV.cjs} +2 -2
- package/dist/{library-request-Da-CHKzT.cjs.map → library-request-D7OvTxZV.cjs.map} +1 -1
- package/dist/{lifecycle-CZ6RRXc6.js → lifecycle-22CUCrc9.js} +21 -29
- package/dist/lifecycle-22CUCrc9.js.map +1 -0
- package/dist/lifecycle-IaAm1mOC.cjs +2 -0
- package/dist/lifecycle-IaAm1mOC.cjs.map +1 -0
- package/dist/{log-record-DIA6McNr.js → log-record-BNiLfqtL.js} +8 -7
- package/dist/log-record-BNiLfqtL.js.map +1 -0
- package/dist/log-record-CkivuiEl.cjs +2 -0
- package/dist/log-record-CkivuiEl.cjs.map +1 -0
- package/dist/long-frames-BUUbXd-B.cjs +2 -0
- package/dist/long-frames-BUUbXd-B.cjs.map +1 -0
- package/dist/{long-frames-430_85Da.js → long-frames-DNFaRnC3.js} +18 -22
- package/dist/long-frames-DNFaRnC3.js.map +1 -0
- package/dist/models/batch.d.cts +57 -0
- package/dist/models/batch.d.ts +2 -2
- package/dist/models/bus.d.cts +158 -0
- package/dist/models/bus.d.ts +22 -2
- package/dist/models/config.d.cts +1540 -0
- package/dist/models/config.d.ts +360 -259
- package/dist/models/drop.d.cts +54 -0
- package/dist/models/drop.d.ts +16 -3
- package/dist/models/health.d.cts +148 -0
- package/dist/models/health.d.ts +108 -12
- package/dist/models/log-record.d.cts +61 -0
- package/dist/models/metric.d.cts +139 -0
- package/dist/models/metric.d.ts +13 -2
- package/dist/models/plugin.d.cts +47 -0
- package/dist/models/plugin.d.ts +3 -3
- package/dist/models/replay.d.cts +60 -0
- package/dist/models/serializer.d.cts +23 -0
- package/dist/models/serializer.d.ts +1 -1
- package/dist/models/storage.d.cts +95 -0
- package/dist/models/storage.d.ts +7 -5
- package/dist/network-CGMLQ-mA.cjs +2 -0
- package/dist/network-CGMLQ-mA.cjs.map +1 -0
- package/dist/{network-C7SkLf4v.js → network-on2zZT6H.js} +51 -51
- package/dist/network-on2zZT6H.js.map +1 -0
- package/dist/{otlp-2MCrC3kd.cjs → otlp-BENHf3g9.cjs} +2 -2
- package/dist/{otlp-2MCrC3kd.cjs.map → otlp-BENHf3g9.cjs.map} +1 -1
- package/dist/{otlp-COq033e3.js → otlp-DimfrRor.js} +12 -12
- package/dist/{otlp-COq033e3.js.map → otlp-DimfrRor.js.map} +1 -1
- package/dist/{platform-CVewe4wQ.js → platform-BaaFIPCU.js} +10 -10
- package/dist/{platform-CVewe4wQ.js.map → platform-BaaFIPCU.js.map} +1 -1
- package/dist/{platform-12uR7kBQ.cjs → platform-CfA3-7sJ.cjs} +2 -2
- package/dist/{platform-12uR7kBQ.cjs.map → platform-CfA3-7sJ.cjs.map} +1 -1
- package/dist/{profiler-BVWIOgnq.js → profiler-BAZoh7A4.js} +89 -107
- package/dist/profiler-BAZoh7A4.js.map +1 -0
- package/dist/profiler-D4tJpDRc.cjs +2 -0
- package/dist/profiler-D4tJpDRc.cjs.map +1 -0
- package/dist/profiler-frames-C4xr7KfH.cjs +2 -0
- package/dist/profiler-frames-C4xr7KfH.cjs.map +1 -0
- package/dist/{profiler-frames-CLXlT_xL.js → profiler-frames-cJMx9wNM.js} +29 -37
- package/dist/profiler-frames-cJMx9wNM.js.map +1 -0
- package/dist/remote-rules-Dz9MRAsB.js +95 -0
- package/dist/remote-rules-Dz9MRAsB.js.map +1 -0
- package/dist/remote-rules-_tY0zj5o.cjs +2 -0
- package/dist/remote-rules-_tY0zj5o.cjs.map +1 -0
- package/dist/replay-B3gFXIZd.cjs +2 -0
- package/dist/replay-B3gFXIZd.cjs.map +1 -0
- package/dist/replay-Ds-ANH34.js +310 -0
- package/dist/replay-Ds-ANH34.js.map +1 -0
- package/dist/reports-BDSe4dFH.cjs +2 -0
- package/dist/reports-BDSe4dFH.cjs.map +1 -0
- package/dist/{reports-BuXekPOS.js → reports-C-thq-bk.js} +25 -30
- package/dist/reports-C-thq-bk.js.map +1 -0
- package/dist/resource-timing-C576gFIQ.cjs +2 -0
- package/dist/resource-timing-C576gFIQ.cjs.map +1 -0
- package/dist/{resource-timing-CXGHwFRD.js → resource-timing-eUl2dNgC.js} +20 -23
- package/dist/resource-timing-eUl2dNgC.js.map +1 -0
- package/dist/response-body-YdNl-HkR.cjs +3 -0
- package/dist/response-body-YdNl-HkR.cjs.map +1 -0
- package/dist/response-body-eoSQpLiH.js +331 -0
- package/dist/response-body-eoSQpLiH.js.map +1 -0
- package/dist/rotation-Cwct4ckk.js +94 -0
- package/dist/rotation-Cwct4ckk.js.map +1 -0
- package/dist/rotation-D4qUAHAu.cjs +2 -0
- package/dist/rotation-D4qUAHAu.cjs.map +1 -0
- package/dist/sampling-BlrI8jor.js +63 -0
- package/dist/sampling-BlrI8jor.js.map +1 -0
- package/dist/sampling-mXt4dstx.cjs +2 -0
- package/dist/sampling-mXt4dstx.cjs.map +1 -0
- package/dist/{sanitize-CNmsD9r3.js → sanitize-Ba0KqU06.js} +2 -2
- package/dist/sanitize-Ba0KqU06.js.map +1 -0
- package/dist/{sanitize-ChLn97Ch.cjs → sanitize-DQyiI_KY.cjs} +2 -2
- package/dist/sanitize-DQyiI_KY.cjs.map +1 -0
- package/dist/sender-BdRuNVhF.cjs +2 -0
- package/dist/sender-BdRuNVhF.cjs.map +1 -0
- package/dist/sender-Dv8rAmpV.js +979 -0
- package/dist/sender-Dv8rAmpV.js.map +1 -0
- package/dist/storage/context-storage.d.cts +90 -0
- package/dist/storage/context-storage.d.ts +5 -5
- package/dist/storage/emergency-queue.d.cts +27 -0
- package/dist/storage/emergency-queue.d.ts +4 -4
- package/dist/storage/eviction.d.cts +40 -0
- package/dist/storage/eviction.d.ts +1 -1
- package/dist/storage/factory.d.cts +21 -0
- package/dist/storage/factory.d.ts +3 -3
- package/dist/storage/gap.d.cts +20 -0
- package/dist/storage/gap.d.ts +3 -3
- package/dist/storage/idb-driver.d.cts +93 -0
- package/dist/storage/idb-driver.d.ts +1 -1
- package/dist/storage/indexeddb-storage.d.cts +97 -0
- package/dist/storage/indexeddb-storage.d.ts +12 -4
- package/dist/storage/keys.d.cts +17 -0
- package/dist/storage/keys.d.ts +2 -2
- package/dist/storage/local-storage.d.cts +139 -0
- package/dist/storage/local-storage.d.ts +11 -4
- package/dist/storage/memory-storage.d.cts +73 -0
- package/dist/storage/memory-storage.d.ts +4 -3
- package/dist/storage/persistence.d.cts +8 -0
- package/dist/storage/persistence.d.ts +2 -2
- package/dist/storage/stored-context.d.cts +34 -0
- package/dist/storage/stored-context.d.ts +34 -0
- package/dist/stored-context-B2EzVuYm.js +51 -0
- package/dist/stored-context-B2EzVuYm.js.map +1 -0
- package/dist/stored-context-CXt7eHZL.cjs +2 -0
- package/dist/stored-context-CXt7eHZL.cjs.map +1 -0
- package/dist/storm-C-zYSdDX.cjs +2 -0
- package/dist/storm-C-zYSdDX.cjs.map +1 -0
- package/dist/storm-DjKetLKZ.js +9 -0
- package/dist/storm-DjKetLKZ.js.map +1 -0
- package/dist/transport/compression.d.cts +7 -0
- package/dist/transport/custom-transport.d.cts +22 -0
- package/dist/transport/custom-transport.d.ts +6 -5
- package/dist/transport/errors.d.cts +31 -0
- package/dist/transport/exit-flush.d.cts +135 -0
- package/dist/transport/exit-flush.d.ts +30 -13
- package/dist/transport/headers.d.cts +8 -0
- package/dist/transport/headers.d.ts +2 -2
- package/dist/transport/http-transport.d.cts +116 -0
- package/dist/transport/http-transport.d.ts +20 -8
- package/dist/transport/memory-transport.d.cts +30 -0
- package/dist/transport/memory-transport.d.ts +2 -2
- package/dist/transport/response-body.d.cts +49 -0
- package/dist/transport/response-body.d.ts +49 -0
- package/dist/transport/retry-engine.d.cts +129 -0
- package/dist/transport/retry-engine.d.ts +27 -9
- package/dist/transport/serializers/ecs.d.cts +3 -0
- package/dist/transport/serializers/ecs.d.ts +1 -1
- package/dist/transport/serializers/otlp-metrics.d.cts +3 -0
- package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
- package/dist/transport/serializers/otlp-traces.d.cts +3 -0
- package/dist/transport/serializers/otlp-traces.d.ts +1 -1
- package/dist/transport/serializers/otlp.d.cts +47 -0
- package/dist/transport/serializers/otlp.d.ts +2 -2
- package/dist/transport/serializers/select.d.cts +38 -0
- package/dist/transport/serializers/select.d.ts +5 -5
- package/dist/transport/status-transport.d.cts +129 -0
- package/dist/transport/status-transport.d.ts +25 -8
- package/dist/transport/worker-client.d.cts +23 -0
- package/dist/transport/worker-client.d.ts +12 -3
- package/dist/transport/worker-entry.d.cts +5 -0
- package/dist/transport/worker-entry.d.ts +1 -1
- package/dist/transport/worker-protocol.d.cts +38 -0
- package/dist/transport/worker-protocol.d.ts +4 -2
- package/dist/transport/worker-server.d.cts +3 -0
- package/dist/transport/worker-server.d.ts +1 -1
- package/dist/transport/worker-transport.d.cts +10 -0
- package/dist/transport/worker-transport.d.ts +5 -4
- package/dist/types-BAerHgCq.js.map +1 -1
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-Cob_jyTv.js → unclean-exit-DQD1cT7c.js} +23 -30
- package/dist/unclean-exit-DQD1cT7c.js.map +1 -0
- package/dist/unclean-exit-py99ApzT.cjs +2 -0
- package/dist/unclean-exit-py99ApzT.cjs.map +1 -0
- package/dist/{user-timing-DgHubxCI.js → user-timing-BePqb1uN.js} +15 -17
- package/dist/user-timing-BePqb1uN.js.map +1 -0
- package/dist/user-timing-D6XTmpuM.cjs +2 -0
- package/dist/user-timing-D6XTmpuM.cjs.map +1 -0
- package/dist/utils/console.d.cts +36 -0
- package/dist/utils/console.d.ts +4 -4
- package/dist/utils/deadline.d.cts +14 -0
- package/dist/utils/error-like.d.cts +25 -0
- package/dist/utils/fixed-window.d.cts +25 -0
- package/dist/utils/global-scope.d.cts +20 -0
- package/dist/utils/guards.d.cts +14 -0
- package/dist/utils/guards.d.ts +8 -0
- package/dist/utils/identity.d.cts +109 -0
- package/dist/utils/identity.d.ts +3 -4
- package/dist/utils/library-console.d.cts +11 -0
- package/dist/utils/library-request.d.cts +24 -0
- package/dist/utils/lock.d.cts +24 -0
- package/dist/utils/lock.d.ts +1 -1
- package/dist/utils/openfin.d.cts +48 -0
- package/dist/utils/patch.d.cts +9 -0
- package/dist/utils/platform.d.cts +62 -0
- package/dist/utils/platform.d.ts +2 -2
- package/dist/utils/sanitize.d.cts +52 -0
- package/dist/utils/sanitize.d.ts +1 -1
- package/dist/utils/sequence.d.cts +10 -0
- package/dist/utils/tracing.d.cts +158 -0
- package/dist/utils/tracing.d.ts +11 -4
- package/dist/utils/unref.d.cts +9 -0
- package/dist/web-socket-CoIUBM3C.cjs +2 -0
- package/dist/{web-socket-DthJuSAg.js.map → web-socket-CoIUBM3C.cjs.map} +1 -1
- package/dist/{web-socket-DthJuSAg.js → web-socket-DSHgDiZ6.js} +23 -28
- package/dist/web-socket-DSHgDiZ6.js.map +1 -0
- package/dist/{web-vitals-CsGCWnUr.js → web-vitals-4pWACwaR.js} +15 -21
- package/dist/web-vitals-4pWACwaR.js.map +1 -0
- package/dist/web-vitals-__X7t4pj.cjs +2 -0
- package/dist/web-vitals-__X7t4pj.cjs.map +1 -0
- package/dist/worker-protocol-QbvqNazn.cjs +2 -0
- package/dist/worker-protocol-QbvqNazn.cjs.map +1 -0
- package/dist/{worker-protocol-B0_8rWy5.js → worker-protocol-x074Rpet.js} +14 -11
- package/dist/worker-protocol-x074Rpet.js.map +1 -0
- package/dist/worker-server-CFe4nvos.cjs +2 -0
- package/dist/worker-server-CFe4nvos.cjs.map +1 -0
- package/dist/worker-server-iUVSjH8L.js +94 -0
- package/dist/worker-server-iUVSjH8L.js.map +1 -0
- package/dist/worker-transport-CRAX-09c.cjs +2 -0
- package/dist/worker-transport-CRAX-09c.cjs.map +1 -0
- package/dist/worker-transport-Dy1KMA7t.js +190 -0
- package/dist/worker-transport-Dy1KMA7t.js.map +1 -0
- package/llms.txt +397 -0
- package/package.json +54 -46
- package/dist/bus-D_7pd7RN.cjs +0 -2
- package/dist/bus-D_7pd7RN.cjs.map +0 -1
- package/dist/bus-ecxUNTja.js.map +0 -1
- package/dist/console-CLz_PvFn.cjs +0 -2
- package/dist/console-CLz_PvFn.cjs.map +0 -1
- package/dist/console-cwgHKXvM.js +0 -82
- package/dist/console-cwgHKXvM.js.map +0 -1
- package/dist/constants-Bwl_YtQi.js +0 -349
- package/dist/constants-Bwl_YtQi.js.map +0 -1
- package/dist/constants-DakMxVB2.cjs +0 -2
- package/dist/constants-DakMxVB2.cjs.map +0 -1
- package/dist/context-storage-BjzeBSxH.cjs +0 -2
- package/dist/context-storage-BjzeBSxH.cjs.map +0 -1
- package/dist/context-storage-BzkoHzkQ.js +0 -51
- package/dist/context-storage-BzkoHzkQ.js.map +0 -1
- package/dist/debug-bundle-BOdYmCeV.js +0 -32
- package/dist/debug-bundle-BOdYmCeV.js.map +0 -1
- package/dist/debug-bundle-Ex4L_LSP.cjs +0 -2
- package/dist/debug-bundle-Ex4L_LSP.cjs.map +0 -1
- package/dist/emergency-queue-B9WZxanZ.js +0 -67
- package/dist/emergency-queue-B9WZxanZ.js.map +0 -1
- package/dist/emergency-queue-HBpL5r3V.cjs +0 -2
- package/dist/emergency-queue-HBpL5r3V.cjs.map +0 -1
- package/dist/errors-D6bwgJtO.js +0 -92
- package/dist/errors-D6bwgJtO.js.map +0 -1
- package/dist/errors-DCOCRdSi.cjs +0 -3
- package/dist/errors-DCOCRdSi.cjs.map +0 -1
- package/dist/factory-DLFDjdLv.cjs +0 -2
- package/dist/factory-DLFDjdLv.cjs.map +0 -1
- package/dist/factory-e9Qo3K0z.js +0 -276
- package/dist/factory-e9Qo3K0z.js.map +0 -1
- package/dist/guards-Cidk71ME.js +0 -7
- package/dist/guards-Cidk71ME.js.map +0 -1
- package/dist/guards-nJ70syPt.cjs +0 -2
- package/dist/guards-nJ70syPt.cjs.map +0 -1
- package/dist/identity-BlvlgjrU.cjs +0 -2
- package/dist/identity-BlvlgjrU.cjs.map +0 -1
- package/dist/identity-BrQp_5J5.js.map +0 -1
- package/dist/indexeddb-storage-CtLvZH1r.cjs +0 -2
- package/dist/indexeddb-storage-CtLvZH1r.cjs.map +0 -1
- package/dist/indexeddb-storage-DLXQzAGh.js.map +0 -1
- package/dist/interactions-B6z2I4tU.js.map +0 -1
- package/dist/interactions-P6pz08Jn.cjs +0 -2
- package/dist/interactions-P6pz08Jn.cjs.map +0 -1
- package/dist/journey-35yCMNFo.js.map +0 -1
- package/dist/journey-DAGh5h9k.cjs +0 -2
- package/dist/journey-DAGh5h9k.cjs.map +0 -1
- package/dist/keys-BHhw_0Wh.cjs +0 -2
- package/dist/keys-BHhw_0Wh.cjs.map +0 -1
- package/dist/keys-BU9j5YqW.js +0 -16
- package/dist/keys-BU9j5YqW.js.map +0 -1
- package/dist/lifecycle-BGGOcN4N.cjs +0 -2
- package/dist/lifecycle-BGGOcN4N.cjs.map +0 -1
- package/dist/lifecycle-CZ6RRXc6.js.map +0 -1
- package/dist/log-record-D7bA1RPb.cjs +0 -2
- package/dist/log-record-D7bA1RPb.cjs.map +0 -1
- package/dist/log-record-DIA6McNr.js.map +0 -1
- package/dist/long-frames-430_85Da.js.map +0 -1
- package/dist/long-frames-Dd8tsi2U.cjs +0 -2
- package/dist/long-frames-Dd8tsi2U.cjs.map +0 -1
- package/dist/models/stats.d.ts +0 -11
- package/dist/network-C7SkLf4v.js.map +0 -1
- package/dist/network-pEX3PAJv.cjs +0 -2
- package/dist/network-pEX3PAJv.cjs.map +0 -1
- package/dist/profiler-BVWIOgnq.js.map +0 -1
- package/dist/profiler-eVCknCzS.cjs +0 -2
- package/dist/profiler-eVCknCzS.cjs.map +0 -1
- package/dist/profiler-frames-CLXlT_xL.js.map +0 -1
- package/dist/profiler-frames-Dg2OebB2.cjs +0 -2
- package/dist/profiler-frames-Dg2OebB2.cjs.map +0 -1
- package/dist/remote-rules-BJGDJGwA.js +0 -98
- package/dist/remote-rules-BJGDJGwA.js.map +0 -1
- package/dist/remote-rules-CJD3ToVk.cjs +0 -2
- package/dist/remote-rules-CJD3ToVk.cjs.map +0 -1
- package/dist/replay-0zAJv9T3.js +0 -338
- package/dist/replay-0zAJv9T3.js.map +0 -1
- package/dist/replay-DomJpXqW.cjs +0 -2
- package/dist/replay-DomJpXqW.cjs.map +0 -1
- package/dist/reports-BsbqmP8h.cjs +0 -2
- package/dist/reports-BsbqmP8h.cjs.map +0 -1
- package/dist/reports-BuXekPOS.js.map +0 -1
- package/dist/resource-timing-CXGHwFRD.js.map +0 -1
- package/dist/resource-timing-DkycFGDa.cjs +0 -2
- package/dist/resource-timing-DkycFGDa.cjs.map +0 -1
- package/dist/sampling-Dd0wllyq.cjs +0 -2
- package/dist/sampling-Dd0wllyq.cjs.map +0 -1
- package/dist/sampling-UUDbi3K0.js +0 -60
- package/dist/sampling-UUDbi3K0.js.map +0 -1
- package/dist/sanitize-CNmsD9r3.js.map +0 -1
- package/dist/sanitize-ChLn97Ch.cjs.map +0 -1
- package/dist/select-CTk-K5mG.cjs +0 -3
- package/dist/select-CTk-K5mG.cjs.map +0 -1
- package/dist/select-DPv_j6wq.js +0 -270
- package/dist/select-DPv_j6wq.js.map +0 -1
- package/dist/sender-15zEsZpr.js +0 -857
- package/dist/sender-15zEsZpr.js.map +0 -1
- package/dist/sender-Bfpv9tad.cjs +0 -2
- package/dist/sender-Bfpv9tad.cjs.map +0 -1
- package/dist/storage-BA9RqRO-.cjs +0 -2
- package/dist/storage-BA9RqRO-.cjs.map +0 -1
- package/dist/storage-DZwed89z.js +0 -16
- package/dist/storage-DZwed89z.js.map +0 -1
- package/dist/storm-BTSNTIWI.js +0 -9
- package/dist/storm-BTSNTIWI.js.map +0 -1
- package/dist/storm-D0_qZOEg.cjs +0 -2
- package/dist/storm-D0_qZOEg.cjs.map +0 -1
- package/dist/unclean-exit-ClGzrc2A.cjs +0 -2
- package/dist/unclean-exit-ClGzrc2A.cjs.map +0 -1
- package/dist/unclean-exit-Cob_jyTv.js.map +0 -1
- package/dist/user-timing-CdYqx3PF.cjs +0 -2
- package/dist/user-timing-CdYqx3PF.cjs.map +0 -1
- package/dist/user-timing-DgHubxCI.js.map +0 -1
- package/dist/utils/timer.d.ts +0 -19
- package/dist/web-socket-BTuvYoJI.cjs +0 -2
- package/dist/web-socket-BTuvYoJI.cjs.map +0 -1
- package/dist/web-vitals-Ch5BpDmo.cjs +0 -2
- package/dist/web-vitals-Ch5BpDmo.cjs.map +0 -1
- package/dist/web-vitals-CsGCWnUr.js.map +0 -1
- package/dist/worker-protocol-B0_8rWy5.js.map +0 -1
- package/dist/worker-protocol-BjzFORfq.cjs +0 -2
- package/dist/worker-protocol-BjzFORfq.cjs.map +0 -1
- package/dist/worker-server-4en-Lt-3.cjs +0 -2
- package/dist/worker-server-4en-Lt-3.cjs.map +0 -1
- package/dist/worker-server-Cne9MX9I.js +0 -83
- package/dist/worker-server-Cne9MX9I.js.map +0 -1
- package/dist/worker-transport-B-GF4Aqn.cjs +0 -2
- package/dist/worker-transport-B-GF4Aqn.cjs.map +0 -1
- package/dist/worker-transport-C3SjJAEC.js +0 -200
- package/dist/worker-transport-C3SjJAEC.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-on2zZT6H.js","names":["SERVER_TIMING_HEADER","SERVER_TIMING_MAX_CHARS","isErrorLike","isTransportPending","isLibraryRequest","patch","recordedUrl","matchesAny","_defineProperty","splitHeader","parts","start","quoted","escaped","i","text","char","separator","xhrServerTiming","headers","readServerTiming","result","header","part","rawName","params","name","entry","seen","param","equal","key","value","duration","match","MS_PER_SECOND","HTTP_DURATION","durationAttributes","base","attributes","method","url","status","error","xhrMethods","readUrl","input","readFetchMethod","requested","init","toMethod","isForeignInput","isEmptyInit","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","own","trace","rebuilt","ignored","propagates","meta","proto","restoreOpen","rest","originalOpen","restoreSend","args","addTraceHeaders","originalSend","routingContextId","timing","span","endMs","rounded"],"sources":["../src/capture/server-timing.ts","../src/capture/network.ts"],"sourcesContent":["import { SERVER_TIMING_MAX_CHARS, SERVER_TIMING_MAX_ENTRIES } from \"../constants\";\n\n/** One duration entry from the Server-Timing response header. */\ninterface ServerTimingEntry {\n name: string;\n duration: number;\n description: string;\n}\n\n/** Server duration entries, plus the server span they name. */\nexport interface ServerTiming {\n entries: ServerTimingEntry[];\n link?: { traceId: string; spanId: string };\n}\n\n/** Splits a header on separators outside quoted strings. An escaped quote doesn't end a string. */\nfunction splitHeader(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let quoted = false;\n let escaped = false;\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n if (escaped) {\n escaped = false;\n } else if (quoted && char === \"\\\\\") {\n escaped = true;\n } else if (char === '\"') {\n quoted = !quoted;\n } else if (!quoted && char === separator) {\n parts.push(text.slice(start, i));\n start = i + 1;\n }\n }\n\n parts.push(text.slice(start));\n return parts;\n}\n\n/** Finds the header in an XHR header list. Reading a hidden header directly logs a Chrome error. */\nexport function xhrServerTiming(headers: string): string | null {\n return /^server-timing:(.*)$/im.exec(headers)?.[1] ?? null;\n}\n\n/** Reads a bounded number of server duration entries. A missing header gives none. */\nexport function readServerTiming(header: string | null): ServerTiming {\n const result: ServerTiming = { entries: [] };\n if (!header) {\n return result;\n }\n\n for (const part of splitHeader(header.slice(0, SERVER_TIMING_MAX_CHARS), \",\").slice(\n 0,\n SERVER_TIMING_MAX_ENTRIES,\n )) {\n const [rawName, ...params] = splitHeader(part, \";\");\n const name = rawName.trim();\n if (!/^[!#$%&'*+.^_`|~\\da-z-]+$/i.test(name)) {\n continue;\n }\n\n const entry: ServerTimingEntry = { name, duration: 0, description: \"\" };\n const seen = new Set<string>();\n for (const param of params) {\n const equal = param.indexOf(\"=\");\n if (equal < 0) {\n continue;\n }\n\n const key = param.slice(0, equal).trim().toLowerCase();\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n\n let value = param.slice(equal + 1).trim();\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1).replace(/\\\\(.)/g, \"$1\");\n }\n\n if (key === \"dur\") {\n const duration = Number(value);\n if (Number.isFinite(duration) && duration >= 0) {\n entry.duration = duration;\n }\n } else if (key === \"desc\") {\n entry.description = value;\n }\n }\n\n result.entries.push(entry);\n if (name.toLowerCase() === \"traceparent\") {\n const match = /^00-([\\da-f]{32})-([\\da-f]{16})-[\\da-f]{2}$/.exec(entry.description);\n if (match && /[1-9a-f]/.test(match[1]) && /[1-9a-f]/.test(match[2])) {\n result.link = { traceId: match[1], spanId: match[2] };\n }\n }\n }\n\n return result;\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record the outcome and timing of network requests.\n\nimport { SERVER_TIMING_HEADER, TRACEPARENT_HEADER } from \"../constants\";\nimport { readServerTiming, xhrServerTiming } from \"./server-timing\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { isLibraryRequest, isTransportPending } from \"../utils/library-request\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { ClientSpan } from \"../utils/tracing\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** Milliseconds in one second. The histogram is in seconds, as its OpenTelemetry name says. */\nconst MS_PER_SECOND = 1000;\n\n/**\n * The HTTP client duration histogram from the OpenTelemetry semantic conventions, with the\n * boundaries the conventions recommend.\n */\nconst HTTP_DURATION: InstrumentDef = {\n name: \"http.client.request.duration\",\n kind: \"histogram\",\n unit: \"s\",\n boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n};\n\n/**\n * Builds the low-cardinality attributes for one request. The path and the query stay out,\n * because every distinct attribute value creates a new series in the backend.\n * @param method Uppercase HTTP method.\n * @param url Request URL.\n * @param status HTTP status code, or 0 when no response came.\n * @param error What failed, for a request with no response.\n * @returns The attribute set.\n */\nfunction durationAttributes(\n method: string,\n url: string,\n status: number,\n error: unknown,\n): MetricAttributes {\n // A relative URL needs the page URL as its base. A worker has a location too.\n const base = typeof location !== \"undefined\" ? location.href : undefined;\n const attributes: MetricAttributes = {\n \"http.request.method\": method,\n \"server.address\": new URL(url, base).hostname,\n };\n\n if (status === 0) {\n // A request with no response takes its error's type, for example TypeError.\n const name = isErrorLike(error) ? error.name : \"\";\n attributes[\"error.type\"] = name === \"\" ? \"_OTHER\" : name;\n return attributes;\n }\n\n attributes[\"http.response.status_code\"] = status;\n if (status >= 400) {\n attributes[\"error.type\"] = String(status);\n }\n\n return attributes;\n}\n\n/** Request data the XHR wrapper keeps from open to send. */\ninterface XhrMeta {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Performance timestamp at send. */\n startedAt: number;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/** An XMLHttpRequest with our tracking metadata attached. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: XhrMeta;\n};\n\n/** The XMLHttpRequest prototype methods we wrap, kept unbound. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** The fetch call to make, and the method and URL to record. */\ninterface FetchPlan {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Input to pass to the original fetch. */\n input: RequestInfo | URL;\n /** Init to pass to the original fetch. */\n init: RequestInit | undefined;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/**\n * Reads the URL from a fetch input or an XHR URL argument.\n * A Request from another realm fails `instanceof Request`, but its `url` property still works.\n * @param input String, URL, Request, or an object with a text form.\n * @returns The URL.\n * @throws TypeError when the input has no text form. Call it inside a diagnostics guard.\n */\nfunction readUrl(input: unknown): string {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const { url } = input as { url?: unknown };\n if (typeof url === \"string\") {\n return url;\n }\n }\n\n // fetch accepts anything with a text form.\n return String(input);\n}\n\n/**\n * Reads the method of a fetch call. The init's method wins over the Request's.\n * @param input Fetch input.\n * @param init Fetch init.\n * @returns Uppercase method. Defaults to GET.\n */\nfunction readFetchMethod(input: unknown, init: RequestInit | undefined): string {\n let requested: unknown = init?.method;\n\n if (requested === undefined && typeof input === \"object\" && input !== null) {\n requested = (input as { method?: unknown }).method;\n }\n\n return toMethod(requested ?? \"GET\");\n}\n\n/**\n * Checks whether a fetch input is an object that isn't a Request or a URL from this realm,\n * for example a Request from an iframe.\n * @param input Fetch input.\n * @returns True for a foreign object.\n */\nfunction isForeignInput(input: unknown): boolean {\n return typeof input === \"object\" && !(input instanceof URL) && !(input instanceof Request);\n}\n\n/**\n * Checks whether a fetch init sets nothing, for example {}. Like fetch(request), the call\n * fetch(request, {}) keeps the Request's referrer, and any other init resets it.\n * @param init The caller's fetch init.\n * @returns True when no member has a value.\n */\nfunction isEmptyInit(init: RequestInit | undefined): boolean {\n return init === undefined || Object.values(init).every((value) => value === undefined);\n}\n\n/**\n * Converts a method argument to text. Never throws on a method that isn't a string.\n * @param method The caller's method argument.\n * @returns The uppercase method for a string, or the text form of anything else.\n */\nfunction toMethod(method: unknown): string {\n return typeof method === \"string\" ? method.toUpperCase() : String(method);\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Guards against wrapping a function twice. */\n private installed = false;\n\n /** Restore functions for the installed wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** True once we've reported a request made during a custom transport call. Reported once. */\n private warnedTransport = false;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments the network APIs the configuration selects. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /**\n * Restores every host function that still holds this capture's wrapper.\n * A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n }\n\n /**\n * Checks whether a URL matches the ignore patterns.\n * @param url Request target URL.\n * @returns True if the URL must stay out of the telemetry.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Otherwise a failed POST becomes a\n // log record, the record causes a new POST, and the loop never stops.\n // A custom transport has no known URL, but its request starts inside the library scope.\n return isLibraryRequest() || matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /**\n * Checks whether a request gets the trace headers.\n * @param url Request target URL.\n * @returns True if the URL is in propagateTraceHeaderTo.\n */\n private propagates(url: string): boolean {\n // Only add headers to allowlisted URLs. A traceparent on a third-party request triggers\n // a CORS preflight that the third party doesn't answer, and its API stops working.\n const targets = this.ctx.config.capture.propagateTraceHeaderTo;\n if (targets.length === 0) {\n return false;\n }\n\n // A string target is an origin. A relative URL resolves against the page.\n const origin = this.ctx.diagnostics.guard(\n \"capture.header_failed\",\n \"The library could not read the origin of a request URL. Only a RegExp target can match it.\",\n () => new URL(url, location.href).origin,\n );\n\n return targets.some((target) =>\n typeof target === \"string\" ? target === origin : target.test(url),\n );\n }\n\n /** Wraps globalThis.fetch to inject the trace headers and log the outcome. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const prepare = (input: RequestInfo | URL, init: RequestInit | undefined) =>\n this.prepareFetch(input, init);\n const record = (\n plan: FetchPlan,\n status: number,\n durationMs: number,\n error: unknown,\n readTiming?: () => string | null,\n ): void => {\n this.record(\n plan.method,\n plan.url,\n status,\n durationMs,\n error,\n plan.span,\n plan.routingContextId,\n readTiming,\n );\n };\n\n const restore = patch(globalThis, \"fetch\", (original: FetchFn) => {\n const call = original.bind(globalThis);\n\n return async function instrumentedFetch(input, init) {\n const plan = active ? prepare(input, init) : undefined;\n if (!plan) {\n return call(input, init);\n }\n\n const startedAt = performance.now();\n try {\n const response = await call(plan.input, plan.init);\n record(plan, response.status, performance.now() - startedAt, undefined, () =>\n response.headers.get(SERVER_TIMING_HEADER),\n );\n return response;\n } catch (error) {\n record(plan, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n });\n\n this.restores.push(() => {\n active = false;\n restore();\n });\n }\n\n /**\n * Reads a fetch call and adds the trace headers to an allowlisted request.\n * @param input The caller's fetch input.\n * @param init The caller's fetch init.\n * @returns The plan, or undefined to send the request unchanged and record nothing.\n */\n private prepareFetch(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n ): FetchPlan | undefined {\n // This read runs inside the caller's fetch call, so a throw must not fail the request.\n const read = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a fetch request. It sends the request unchanged.\",\n (): { method: string; url: string; propagate: boolean } | undefined => {\n const url = readUrl(input);\n if (this.ignored(url)) {\n return undefined;\n }\n\n return { method: readFetchMethod(input, init), url, propagate: this.propagates(url) };\n },\n );\n\n if (!read) {\n return undefined;\n }\n\n const { method, url } = read;\n const plan: FetchPlan = {\n method,\n url,\n input,\n init,\n routingContextId: this.ctx.config.securityContext.id,\n };\n // An init with headers replaces every header on a foreign Request, Authorization\n // included. So a foreign input goes out without the trace headers.\n if (!read.propagate || isForeignInput(input)) {\n return plan;\n }\n\n try {\n // fetch(request, init) builds new Request(request, init), and init.headers then replaces\n // every header the Request had. So work on the headers that actually go out.\n const own = input instanceof Request ? input.headers : undefined;\n const headers = new Headers(init?.headers ?? own);\n\n // The caller runs its own trace, for example with OpenTelemetry, so don't break it.\n if (headers.has(TRACEPARENT_HEADER)) {\n this.ctx.diagnostics.report(\n \"capture.trace_header_kept\",\n \"The request already has a traceparent header. The library keeps it and records no \" +\n \"client span.\",\n { url },\n );\n return plan;\n }\n\n const trace = this.ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n headers.set(key, value);\n }\n\n if (input instanceof Request) {\n const rebuilt: RequestInit = { ...init, headers };\n // Our rebuild has headers, which resets the referrer, so keep it when the caller's didn't.\n if (isEmptyInit(init)) {\n rebuilt.referrer = input.referrer;\n rebuilt.referrerPolicy = input.referrerPolicy;\n }\n\n // Build the Request once with the caller's whole init, as fetch would, and pass no init\n // next to it. Otherwise fetch builds it again and reads the body twice, which throws.\n plan.input = new Request(input, rebuilt);\n plan.init = undefined;\n } else {\n plan.init = { ...init, headers };\n }\n\n // Only record the client span for a request that actually carries its traceparent.\n plan.span = trace.span;\n } catch (error) {\n // Send exactly what the caller gave us. A missing header is better than a failed\n // request.\n plan.input = input;\n plan.init = init;\n this.ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n\n return plan;\n }\n\n /** Wraps the open and send methods on the XMLHttpRequest prototype. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const propagates = (url: string): boolean => this.propagates(url);\n const record = (\n meta: XhrMeta,\n status: number,\n durationMs: number,\n readTiming: () => string | null,\n ): void => {\n this.record(\n meta.method,\n meta.url,\n status,\n durationMs,\n undefined,\n meta.span,\n meta.routingContextId,\n readTiming,\n );\n };\n\n const proto = xhrMethods();\n\n const restoreOpen = patch(\n proto,\n \"open\",\n (originalOpen) =>\n function (this: Tracked, method: unknown, url: unknown, ...rest: never[]) {\n if (active) {\n // This read runs inside the caller's open call, so a throw must not fail it.\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read an XMLHttpRequest. It does not record the request.\",\n () => {\n this.__uiobs = { method: toMethod(method), url: readUrl(url), startedAt: 0 };\n },\n );\n }\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n },\n );\n\n const restoreSend = patch(\n proto,\n \"send\",\n (originalSend) =>\n function (this: Tracked, ...args: never[]) {\n const meta = active ? this.__uiobs : undefined;\n if (meta) {\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${meta.method} ${meta.url}.`,\n () => {\n if (ignored(meta.url)) {\n return;\n }\n\n meta.startedAt = performance.now();\n meta.routingContextId = ctx.config.securityContext.id;\n // A reused XHR gets a new listener on every send, so the old one must not\n // fire again.\n this.addEventListener(\n \"loadend\",\n () => {\n record(meta, this.status, performance.now() - meta.startedAt, () =>\n xhrServerTiming(this.getAllResponseHeaders()),\n );\n },\n { once: true },\n );\n\n // setRequestHeader only works between open and send.\n if (propagates(meta.url)) {\n meta.span = addTraceHeaders(this, meta.url, ctx);\n }\n },\n );\n }\n originalSend.apply(this, args);\n },\n );\n\n this.restores.push(() => {\n active = false;\n restoreOpen();\n restoreSend();\n });\n }\n\n /**\n * Records the outcome of a request as attributes and a breadcrumb.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The query is removed here unless you set fullUrls.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error The caught error, for a failed request.\n * @param span The client span the request's traceparent names.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n span?: ClientSpan,\n routingContextId?: string,\n readTiming?: () => string | null,\n ): void {\n if (\n this.ctx.isActive?.() === false ||\n (this.ctx.config.securityContext.isolation &&\n routingContextId !== undefined &&\n routingContextId !== this.ctx.config.securityContext.id)\n ) {\n return;\n }\n\n const timing =\n this.ctx.config.capture.serverTiming && readTiming\n ? this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the Server-Timing response header.\",\n () => readServerTiming(readTiming()),\n )\n : undefined;\n\n // Strip the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL, and only the recorded URL loses its query string.\n const url = recordedUrl(\n target,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n // A transport request made after an await gets recorded, and that record causes the next\n // send.\n if (!this.warnedTransport && isTransportPending()) {\n this.warnedTransport = true;\n this.ctx.diagnostics.report(\n \"capture.transport_request\",\n `Network capture saw ${method} ${url} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`,\n );\n }\n\n // The histogram has its own guard, so a URL that doesn't parse can't stop the record.\n if (this.ctx.config.capture.httpMetrics) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the duration of ${method} ${url}.`,\n () => {\n const attributes = durationAttributes(method, target, status, error);\n this.ctx.recordMetric(HTTP_DURATION, durationMs / MS_PER_SECOND, attributes);\n },\n );\n }\n\n if (span) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the span of ${method} ${url}.`,\n () => {\n const endMs = Date.now();\n this.ctx.recordSpan({\n ...span,\n link: timing?.link,\n name: method,\n kind: \"client\",\n startMs: endMs - durationMs,\n endMs,\n error: status === 0 || status >= 400,\n attributes: { ...durationAttributes(method, target, status, error), \"url.full\": url },\n });\n },\n );\n }\n\n // This runs inside the caller's fetch call, so an error here must not fail the caller's\n // request.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n ...(timing && timing.entries.length > 0 ? { \"server.timing\": timing.entries } : {}),\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG, which the default minLevel of INFO drops. That way only\n // failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n\n/**\n * Adds the trace headers to an open XHR. If that fails, the request goes out without them.\n * @param xhr A request between open and send.\n * @param url Request target URL, for the diagnostic.\n * @param ctx Capture context with tracing and diagnostics.\n * @returns The client span the traceparent names, or undefined.\n */\nfunction addTraceHeaders(\n xhr: XMLHttpRequest,\n url: string,\n ctx: CaptureContext,\n): ClientSpan | undefined {\n try {\n const trace = ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n xhr.setRequestHeader(key, value);\n }\n return trace.span;\n } catch (error) {\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;AAgBA,SAASS,EAAY,GAAc,GAA6B;CAC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AI,GACNA,CACF;EACA;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=otlp-
|
|
1
|
+
const e=require("./constants-CqdJhTxH.cjs");function t(e){return e==null?null:typeof e==`string`?{stringValue:e}:typeof e==`boolean`?{boolValue:e}:typeof e==`number`?Number.isSafeInteger(e)?{intValue:String(e)}:{doubleValue:e}:typeof e==`bigint`?{intValue:e.toString()}:Array.isArray(e)?{arrayValue:{values:e.map(t).filter(e=>e!==null)}}:typeof e==`object`?{kvlistValue:{values:n(e)}}:null}function n(e){let n=[];for(let[r,i]of Object.entries(e)){let e=t(i);e&&n.push({key:r,value:e})}return n}var r=new WeakMap;function i(e){let t=r.get(e);if(t!==void 0)return t;let n=JSON.stringify(e);return r.set(e,n),n}function a(e){let t=new Map;for(let n of e){let e=i(n.resource),r=t.get(e);r?r.records.push(n):t.set(e,{resource:n.resource,records:[n]})}return[...t.values()]}function o(t){let n=new Map;for(let r of t){let t=r.attributes[e.a],i=typeof t==`string`&&t?t:e.$n,a=n.get(i);a?a.push(r):n.set(i,[r])}return[...n].map(([e,t])=>({name:e,records:t}))}var s={name:e.Fn,serialize(t){let r=a(t).map(e=>({resource:{attributes:n(e.resource)},scopeLogs:o(e.records).map(e=>({scope:{name:e.name},logRecords:e.records.map(e=>({timeUnixNano:e.timeUnixNano,observedTimeUnixNano:e.observedTimeUnixNano??e.timeUnixNano,severityNumber:e.severityNumber,severityText:e.severityText,body:{stringValue:e.body},traceId:e.traceId,spanId:e.spanId,flags:e.traceFlags,attributes:n(e.attributes)}))}))}));return{body:JSON.stringify({resourceLogs:r}),contentType:e.z}}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
+
//# sourceMappingURL=otlp-BENHf3g9.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-
|
|
1
|
+
{"version":3,"file":"otlp-BENHf3g9.cjs","names":["items","nested","ATTR_APP_NAMESPACE","TELEMETRY_SDK_NAME","SERIALIZER_NAME_OTLP","CONTENT_TYPE_JSON","require_constants","toAnyValue","value","item","toKeyValues","out","key","raw","source","resourceKeys","resourceKey","cached","resource","groupByResource","groups","record","records","group","groupByScope","namespace","name","scoped","otlpSerializer","resourceLogs","scope"],"sources":["../src/transport/serializers/otlp.ts"],"sourcesContent":["// src/transport/serializers/otlp.ts\n//\n// Serializes log batches as OTLP/JSON log records. Records are grouped by resource, and each\n// logger namespace gets its own instrumentation scope.\n// The OTLP metrics serializer reuses the value encoding and the resource grouping from here.\n\nimport {\n ATTR_APP_NAMESPACE,\n CONTENT_TYPE_JSON,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** An OTLP AnyValue with typed value wrappers. */\ntype AnyValue = Record<string, unknown>;\n\n/** An OTLP KeyValue pair. */\nexport interface KeyValue {\n /** The attribute key. */\n key: string;\n /** The typed AnyValue. */\n value: AnyValue;\n}\n\n/** Records that share the same resource attributes. */\nexport interface ResourceGroup {\n /** The resource attribute map. */\n resource: Record<string, unknown>;\n /** The resource's log records. */\n records: LogRecord[];\n}\n\n/**\n * Wraps a JavaScript value in an OTLP AnyValue.\n * @param value Raw attribute or resource value.\n * @returns Typed AnyValue object or null if unsupported.\n */\nfunction toAnyValue(value: unknown): AnyValue | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return { stringValue: value };\n }\n\n if (typeof value === \"boolean\") {\n return { boolValue: value };\n }\n\n // Encode int64 as a decimal string, as the OTLP protobuf JSON mapping requires. A conforming\n // collector answers a number with a 400 status, and the response doesn't give the cause.\n // An integer above MAX_SAFE_INTEGER goes to doubleValue, because its text can be \"1e+21\" or\n // overflow int64.\n if (typeof value === \"number\") {\n return Number.isSafeInteger(value) ? { intValue: String(value) } : { doubleValue: value };\n }\n\n // Convert a BigInt to a decimal string. JSON.stringify throws on a BigInt and would lose\n // the batch.\n if (typeof value === \"bigint\") {\n return { intValue: value.toString() };\n }\n\n if (Array.isArray(value)) {\n const items: readonly unknown[] = value;\n const values = items.map(toAnyValue).filter((item): item is AnyValue => item !== null);\n\n return { arrayValue: { values } };\n }\n\n if (typeof value === \"object\") {\n const nested = value as Record<string, unknown>;\n return { kvlistValue: { values: toKeyValues(nested) } };\n }\n\n return null;\n}\n\n/**\n * Converts a plain object to an array of OTLP KeyValue pairs.\n * @param source Key-value attribute object.\n * @returns Array of valid KeyValue pairs.\n */\nexport function toKeyValues(source: Record<string, unknown>): KeyValue[] {\n const out: KeyValue[] = [];\n\n for (const [key, raw] of Object.entries(source)) {\n const value = toAnyValue(raw);\n if (value) {\n out.push({ key, value });\n }\n }\n\n return out;\n}\n\n/** Caches the JSON key of every resource object, which avoids a repeated stringify. */\nconst resourceKeys = new WeakMap<object, string>();\n\n/**\n * Returns the stable JSON key of a resource object, and caches it.\n * @param resource Resource attribute object.\n * @returns JSON key string.\n */\nfunction resourceKey(resource: Record<string, unknown>): string {\n const cached = resourceKeys.get(resource);\n if (cached !== undefined) {\n return cached;\n }\n\n const key = JSON.stringify(resource);\n resourceKeys.set(resource, key);\n\n return key;\n}\n\n/**\n * Groups records by their resource attributes, keeping the record order within each group.\n * @param records Records to group.\n * @returns One group per resource.\n */\nexport function groupByResource(records: LogRecord[]): ResourceGroup[] {\n const groups = new Map<string, ResourceGroup>();\n\n for (const record of records) {\n const key = resourceKey(record.resource);\n const group = groups.get(key);\n\n if (group) {\n group.records.push(record);\n continue;\n }\n\n groups.set(key, { resource: record.resource, records: [record] });\n }\n\n return [...groups.values()];\n}\n\n/** The records of one instrumentation scope. */\nexport interface ScopeGroup {\n /** The scope name, which is the logger namespace. */\n name: string;\n /** The scope's records. */\n records: LogRecord[];\n}\n\n/**\n * Groups records by their logger namespace, keeping the record order within each group.\n * A record without a namespace goes to the library's own scope.\n * @param records Records of one resource.\n * @returns One group per namespace.\n */\nexport function groupByScope(records: LogRecord[]): ScopeGroup[] {\n const groups = new Map<string, LogRecord[]>();\n\n for (const record of records) {\n const namespace: unknown = record.attributes[ATTR_APP_NAMESPACE];\n const name = typeof namespace === \"string\" && namespace ? namespace : TELEMETRY_SDK_NAME;\n const group = groups.get(name);\n\n if (group) {\n group.push(record);\n continue;\n }\n\n groups.set(name, [record]);\n }\n\n return [...groups].map(([name, scoped]) => ({ name, records: scoped }));\n}\n\n/** Writes log records as OTLP/JSON payloads. */\nexport const otlpSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups records by resource and encodes them as an OTLP\n * ExportLogsServiceRequest JSON payload.\n * @param records Array of log records to serialize.\n * @returns Serialized JSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceLogs = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeLogs: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n logRecords: scope.records.map((record) => ({\n timeUnixNano: record.timeUnixNano,\n // Use timeUnixNano when observedTimeUnixNano is not set.\n observedTimeUnixNano: record.observedTimeUnixNano ?? record.timeUnixNano,\n severityNumber: record.severityNumber,\n severityText: record.severityText,\n body: { stringValue: record.body },\n traceId: record.traceId,\n spanId: record.spanId,\n flags: record.traceFlags,\n attributes: toKeyValues(record.attributes),\n })),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceLogs }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n"],"mappings":"A,4CAuCA,SAASO,EAAW,EAAiC,CAuCnD,OAtCIC,GAAU,KACL,KAGL,OAAOA,GAAU,SACZ,CAAE,YAAaA,CAAM,EAG1B,OAAOA,GAAU,UACZ,CAAE,UAAW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AAS,IAAI,IAEnB,IAAK,IAAMC,KAAUC,EAAS,CAC5B,IAAMG,EAAqBJ,EAAO,WAAWnB,EAAAA,GACvCwB,EAAO,OAAOD,GAAc,UAAYA,EAAYA,EAAYtB,EAAAA,GAChEoB,EAAQH,EAAO,IAAIM,CAAI,EAEzBH,EACFA,EAAM,KAAKF,CAAM,EAInBD,EAAO,IAAIM,EAAM,CAACL,CAAM,CAAC,CAC3B,CAEA,MAAO,CAAC,GAAGD,CAAM,CAAC,CAAC,KAAK,CAACM,EAAMC,MAAa,CAAE,OAAM,QAASA,CAAO,EAAE,CACxE,CAGA,IAAaC,EAAgC,CAE3C,KAAMxB,EAAAA,GAQN,UAAU,EAAuC,CAC/C,IAAMyB,EAAeV,EAAgBG,CAAO,CAAC,CAAC,IAAK,IAAW,CAC5D,SAAU,CAAE,WAAYZ,EAAYa,EAAM,QAAQ,CAAE,EACpD,UAAWC,EAAaD,EAAM,OAAO,CAAC,CAAC,IAAK,IAAW,CACrD,MAAO,CAAE,KAAMO,EAAM,IAAK,EAC1B,WAAYA,EAAM,QAAQ,IAAK,IAAY,CACzC,aAAcT,EAAO,aAErB,qBAAsBA,EAAO,sBAAwBA,EAAO,aAC5D,eAAgBA,EAAO,eACvB,aAAcA,EAAO,aACrB,KAAM,CAAE,YAAaA,EAAO,IAAK,EACjC,QAASA,EAAO,QAChB,OAAQA,EAAO,OACf,MAAOA,EAAO,WACd,WAAYX,EAAYW,EAAO,UAAU,CAC3C,EAAE,CACJ,EAAE,CACJ,EAAE,EAEF,MAAO,CACL,KAAM,KAAK,UAAU,CAAE,cAAa,CAAC,EACrC,YAAahB,EAAAA,CACf,CACF,CACF,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $n as e, Fn as t, a as n, z as r } from "./constants-CUyd9cTZ.js";
|
|
2
2
|
// src/transport/serializers/otlp.ts
|
|
3
3
|
function i(e) {
|
|
4
4
|
return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isSafeInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(i).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: a(e) } } : null;
|
|
@@ -32,21 +32,21 @@ function c(e) {
|
|
|
32
32
|
}
|
|
33
33
|
return [...t.values()];
|
|
34
34
|
}
|
|
35
|
-
function l(
|
|
36
|
-
let
|
|
37
|
-
for (let i of
|
|
38
|
-
let
|
|
39
|
-
o ? o.push(i) :
|
|
35
|
+
function l(t) {
|
|
36
|
+
let r = /* @__PURE__ */ new Map();
|
|
37
|
+
for (let i of t) {
|
|
38
|
+
let t = i.attributes[n], a = typeof t == "string" && t ? t : e, o = r.get(a);
|
|
39
|
+
o ? o.push(i) : r.set(a, [i]);
|
|
40
40
|
}
|
|
41
|
-
return [...
|
|
41
|
+
return [...r].map(([e, t]) => ({
|
|
42
42
|
name: e,
|
|
43
43
|
records: t
|
|
44
44
|
}));
|
|
45
45
|
}
|
|
46
46
|
var u = {
|
|
47
|
-
name:
|
|
47
|
+
name: t,
|
|
48
48
|
serialize(e) {
|
|
49
|
-
let
|
|
49
|
+
let t = c(e).map((e) => ({
|
|
50
50
|
resource: { attributes: a(e.resource) },
|
|
51
51
|
scopeLogs: l(e.records).map((e) => ({
|
|
52
52
|
scope: { name: e.name },
|
|
@@ -64,11 +64,11 @@ var u = {
|
|
|
64
64
|
}))
|
|
65
65
|
}));
|
|
66
66
|
return {
|
|
67
|
-
body: JSON.stringify({ resourceLogs:
|
|
68
|
-
contentType:
|
|
67
|
+
body: JSON.stringify({ resourceLogs: t }),
|
|
68
|
+
contentType: r
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
export { a as i, l as n, u as r, c as t };
|
|
73
73
|
|
|
74
|
-
//# sourceMappingURL=otlp-
|
|
74
|
+
//# sourceMappingURL=otlp-DimfrRor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-
|
|
1
|
+
{"version":3,"file":"otlp-DimfrRor.js","names":["items","nested","TELEMETRY_SDK_NAME","SERIALIZER_NAME_OTLP","ATTR_APP_NAMESPACE","CONTENT_TYPE_JSON","toAnyValue","value","item","toKeyValues","out","key","raw","source","resourceKeys","resourceKey","cached","resource","groupByResource","groups","record","records","group","groupByScope","namespace","name","scoped","otlpSerializer","resourceLogs","scope"],"sources":["../src/transport/serializers/otlp.ts"],"sourcesContent":["// src/transport/serializers/otlp.ts\n//\n// Serializes log batches as OTLP/JSON log records. Records are grouped by resource, and each\n// logger namespace gets its own instrumentation scope.\n// The OTLP metrics serializer reuses the value encoding and the resource grouping from here.\n\nimport {\n ATTR_APP_NAMESPACE,\n CONTENT_TYPE_JSON,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** An OTLP AnyValue with typed value wrappers. */\ntype AnyValue = Record<string, unknown>;\n\n/** An OTLP KeyValue pair. */\nexport interface KeyValue {\n /** The attribute key. */\n key: string;\n /** The typed AnyValue. */\n value: AnyValue;\n}\n\n/** Records that share the same resource attributes. */\nexport interface ResourceGroup {\n /** The resource attribute map. */\n resource: Record<string, unknown>;\n /** The resource's log records. */\n records: LogRecord[];\n}\n\n/**\n * Wraps a JavaScript value in an OTLP AnyValue.\n * @param value Raw attribute or resource value.\n * @returns Typed AnyValue object or null if unsupported.\n */\nfunction toAnyValue(value: unknown): AnyValue | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return { stringValue: value };\n }\n\n if (typeof value === \"boolean\") {\n return { boolValue: value };\n }\n\n // Encode int64 as a decimal string, as the OTLP protobuf JSON mapping requires. A conforming\n // collector answers a number with a 400 status, and the response doesn't give the cause.\n // An integer above MAX_SAFE_INTEGER goes to doubleValue, because its text can be \"1e+21\" or\n // overflow int64.\n if (typeof value === \"number\") {\n return Number.isSafeInteger(value) ? { intValue: String(value) } : { doubleValue: value };\n }\n\n // Convert a BigInt to a decimal string. JSON.stringify throws on a BigInt and would lose\n // the batch.\n if (typeof value === \"bigint\") {\n return { intValue: value.toString() };\n }\n\n if (Array.isArray(value)) {\n const items: readonly unknown[] = value;\n const values = items.map(toAnyValue).filter((item): item is AnyValue => item !== null);\n\n return { arrayValue: { values } };\n }\n\n if (typeof value === \"object\") {\n const nested = value as Record<string, unknown>;\n return { kvlistValue: { values: toKeyValues(nested) } };\n }\n\n return null;\n}\n\n/**\n * Converts a plain object to an array of OTLP KeyValue pairs.\n * @param source Key-value attribute object.\n * @returns Array of valid KeyValue pairs.\n */\nexport function toKeyValues(source: Record<string, unknown>): KeyValue[] {\n const out: KeyValue[] = [];\n\n for (const [key, raw] of Object.entries(source)) {\n const value = toAnyValue(raw);\n if (value) {\n out.push({ key, value });\n }\n }\n\n return out;\n}\n\n/** Caches the JSON key of every resource object, which avoids a repeated stringify. */\nconst resourceKeys = new WeakMap<object, string>();\n\n/**\n * Returns the stable JSON key of a resource object, and caches it.\n * @param resource Resource attribute object.\n * @returns JSON key string.\n */\nfunction resourceKey(resource: Record<string, unknown>): string {\n const cached = resourceKeys.get(resource);\n if (cached !== undefined) {\n return cached;\n }\n\n const key = JSON.stringify(resource);\n resourceKeys.set(resource, key);\n\n return key;\n}\n\n/**\n * Groups records by their resource attributes, keeping the record order within each group.\n * @param records Records to group.\n * @returns One group per resource.\n */\nexport function groupByResource(records: LogRecord[]): ResourceGroup[] {\n const groups = new Map<string, ResourceGroup>();\n\n for (const record of records) {\n const key = resourceKey(record.resource);\n const group = groups.get(key);\n\n if (group) {\n group.records.push(record);\n continue;\n }\n\n groups.set(key, { resource: record.resource, records: [record] });\n }\n\n return [...groups.values()];\n}\n\n/** The records of one instrumentation scope. */\nexport interface ScopeGroup {\n /** The scope name, which is the logger namespace. */\n name: string;\n /** The scope's records. */\n records: LogRecord[];\n}\n\n/**\n * Groups records by their logger namespace, keeping the record order within each group.\n * A record without a namespace goes to the library's own scope.\n * @param records Records of one resource.\n * @returns One group per namespace.\n */\nexport function groupByScope(records: LogRecord[]): ScopeGroup[] {\n const groups = new Map<string, LogRecord[]>();\n\n for (const record of records) {\n const namespace: unknown = record.attributes[ATTR_APP_NAMESPACE];\n const name = typeof namespace === \"string\" && namespace ? namespace : TELEMETRY_SDK_NAME;\n const group = groups.get(name);\n\n if (group) {\n group.push(record);\n continue;\n }\n\n groups.set(name, [record]);\n }\n\n return [...groups].map(([name, scoped]) => ({ name, records: scoped }));\n}\n\n/** Writes log records as OTLP/JSON payloads. */\nexport const otlpSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups records by resource and encodes them as an OTLP\n * ExportLogsServiceRequest JSON payload.\n * @param records Array of log records to serialize.\n * @returns Serialized JSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceLogs = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeLogs: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n logRecords: scope.records.map((record) => ({\n timeUnixNano: record.timeUnixNano,\n // Use timeUnixNano when observedTimeUnixNano is not set.\n observedTimeUnixNano: record.observedTimeUnixNano ?? record.timeUnixNano,\n severityNumber: record.severityNumber,\n severityText: record.severityText,\n body: { stringValue: record.body },\n traceId: record.traceId,\n spanId: record.spanId,\n flags: record.traceFlags,\n attributes: toKeyValues(record.attributes),\n })),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceLogs }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n"],"mappings":";;AAuCA,SAASM,EAAW,GAAiC;CAuCnD,OAtCIC,KAAU,OACL,OAGL,OAAOA,KAAU,WACZ,EAAE,aAAaA,EAAM,IAG1B,OAAOA,KAAU,YACZ,EAAE,WAAWA,EAAM,IAOxB,OAA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/D,IAAMJ,oBAAS,IAAI,IAAyB;CAE5C,KAAK,IAAMC,KAAUC,GAAS;EAC5B,IAAMG,IAAqBJ,EAAO,WAAWhB,IACvCqB,IAAO,OAAOD,KAAc,YAAYA,IAAYA,IAAYtB,GAChEoB,IAAQH,EAAO,IAAIM,CAAI;EAE7B,AAAIH,IACFA,EAAM,KAAKF,CAAM,IAInBD,EAAO,IAAIM,GAAM,CAACL,CAAM,CAAC;CAC3B;CAEA,OAAO,CAAC,GAAGD,CAAM,CAAC,CAAC,KAAK,CAACM,GAAMC,QAAa;EAAE;EAAM,SAASA;CAAO,EAAE;AACxE;AAGA,IAAaC,IAAgC;CAE3C,MAAMxB;CAQN,UAAU,GAAuC;EAC/C,IAAMyB,IAAeV,EAAgBG,CAAO,CAAC,CAAC,KAAK,OAAW;GAC5D,UAAU,EAAE,YAAYZ,EAAYa,EAAM,QAAQ,EAAE;GACpD,WAAWC,EAAaD,EAAM,OAAO,CAAC,CAAC,KAAK,OAAW;IACrD,OAAO,EAAE,MAAMO,EAAM,KAAK;IAC1B,YAAYA,EAAM,QAAQ,KAAK,OAAY;KACzC,cAAcT,EAAO;KAErB,sBAAsBA,EAAO,wBAAwBA,EAAO;KAC5D,gBAAgBA,EAAO;KACvB,cAAcA,EAAO;KACrB,MAAM,EAAE,aAAaA,EAAO,KAAK;KACjC,SAASA,EAAO;KAChB,QAAQA,EAAO;KACf,OAAOA,EAAO;KACd,YAAYX,EAAYW,EAAO,UAAU;IAC3C,EAAE;GACJ,EAAE;EACJ,EAAE;EAEF,OAAO;GACL,MAAM,KAAK,UAAU,EAAE,gBAAa,CAAC;GACrC,aAAaf;EACf;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ht as e,
|
|
1
|
+
import { Ht as e, It as t, St as n, i as r, qt as i } from "./constants-CUyd9cTZ.js";
|
|
2
2
|
import { t as a } from "./openfin-Bxelt0yg.js";
|
|
3
3
|
// src/utils/platform.ts
|
|
4
4
|
var o = null;
|
|
@@ -6,23 +6,23 @@ function s(e, t) {
|
|
|
6
6
|
let n = e[t];
|
|
7
7
|
return n !== void 0 && e instanceof n;
|
|
8
8
|
}
|
|
9
|
-
function c(
|
|
9
|
+
function c(e) {
|
|
10
10
|
if (o) return o;
|
|
11
|
-
let
|
|
12
|
-
return s(
|
|
11
|
+
let t = globalThis, n = t.navigator?.userAgent ?? "", r = "browser", c, d, f = !1, p = a()?.me;
|
|
12
|
+
return s(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", f = !0) : s(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", f = !0) : s(t, "WorkerGlobalScope") ? (r = "web_worker", f = !0) : p === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 || l(n) ? r = "mobile_webview" : typeof document > "u" && typeof process < "u" && (r = "node") : (r = i.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "The library could not read fin.me.identity.", () => {
|
|
13
13
|
let e = p.identity;
|
|
14
14
|
c = e?.uuid, d = e?.name;
|
|
15
15
|
})), o = {
|
|
16
|
-
platform:
|
|
16
|
+
platform: r,
|
|
17
17
|
openfinUuid: c,
|
|
18
18
|
openfinName: d,
|
|
19
|
-
userAgent:
|
|
19
|
+
userAgent: n,
|
|
20
20
|
isWorker: f,
|
|
21
|
-
isTopLevelDocument: u(
|
|
21
|
+
isTopLevelDocument: u(e)
|
|
22
22
|
}, o;
|
|
23
23
|
}
|
|
24
|
-
function l(
|
|
25
|
-
return r.test(
|
|
24
|
+
function l(i) {
|
|
25
|
+
return r.test(i) ? !0 : (n.test(i) || t.test(i) && e.test(i)) && i.includes("AppleWebKit") && !i.includes("Safari/");
|
|
26
26
|
}
|
|
27
27
|
function u(e) {
|
|
28
28
|
if (typeof window > "u") return !1;
|
|
@@ -59,4 +59,4 @@ function h() {
|
|
|
59
59
|
}
|
|
60
60
|
export { p as i, c as n, h as r, d as t };
|
|
61
61
|
|
|
62
|
-
//# sourceMappingURL=platform-
|
|
62
|
+
//# sourceMappingURL=platform-BaaFIPCU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-CVewe4wQ.js","names":["OPENFIN_UA_PATTERN","MOBILE_UA_PATTERN","MACINTOSH_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","getFin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: (url: string) => string | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":";;;AAkDA,IAAIM,IAAkC;AAWtC,SAASC,EAAc,GAAW,GAAuB;CACvD,IAAMC,IAAQC,EAAEC;CAIhB,OAHIF,MAAU,KAAA,KAGPC,aAAcD;AACvB;AAOA,SAAgBG,EAAe,GAA4C;CACzE,IAAIL,GACF,OAAOA;CAET,IAAMG,IAAI,YAEJG,IAAMH,EAAE,WAAqC,aAAa,IAC5DI,IAAyB,WACzBC,GACAC,GACAC,IAAW,IAETC,IAAQZ,EAAO,CAAC,EAAE;CAkCxB,OAhCIE,EAAcE,GAAG,0BAA0B,KAC7C,IAAW,kBACX,IAAW,MACFF,EAAcE,GAAG,yBAAyB,KACnD,IAAW,iBACX,IAAW,MACFF,EAAcE,GAAG,m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O;CACT;CAEF,IAAMC,IAAOF,EAAI,QAAQJ,GAAmB,IAAI;CAChD,OAAOO,IAAWD,IAAOE,EAAcF,CAAI;AAC7C;AAQA,SAAgBE,EAAc,GAAqB;CACjD,IAAMC,IAAML,EAAI,OAAO,MAAM;CAE7B,OAAOK,MAAQ,KAAKL,IAAMA,EAAI,MAAM,GAAGK,CAAG;AAC5C;AAOA,SAAgBC,IAAoB;CAClC,OAAQ,WAAoD,WAAW,WAAW;AACpF"}
|
|
1
|
+
{"version":3,"file":"platform-BaaFIPCU.js","names":["MOBILE_UA_PATTERN","MACINTOSH_UA_PATTERN","IOS_DEVICE_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","OPENFIN_UA_PATTERN","getFin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: ((url: string) => string | null) | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":";;;AAkDA,IAAIM,IAAkC;AAWtC,SAASC,EAAc,GAAW,GAAuB;CACvD,IAAMC,IAAQC,EAAEC;CAIhB,OAHIF,MAAU,KAAA,KAGPC,aAAcD;AACvB;AAOA,SAAgBG,EAAe,GAA4C;CACzE,IAAIL,GACF,OAAOA;CAET,IAAMG,IAAI,YAEJG,IAAMH,E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A,IAAMI,IAAoB;AAY1B,SAAgBC,EACd,GACA,GACA,GACA,GACQ;CACR,IAAIC,GACF,IAAI;EACF,IAAMC,IAAQD,EAAUE,CAAG;EAC3B,OAAO,OAAOD,KAAU,WAAWA,IAAQ;CAC7C,SAASE,GAAO;EAQd,OANAT,GAAa,OACX,yBACA,0EACA,KAAA,GACAS,CACF,GACO;CACT;CAEF,IAAMC,IAAOF,EAAI,QAAQJ,GAAmB,IAAI;CAChD,OAAOO,IAAWD,IAAOE,EAAcF,CAAI;AAC7C;AAQA,SAAgBE,EAAc,GAAqB;CACjD,IAAMC,IAAML,EAAI,OAAO,MAAM;CAE7B,OAAOK,MAAQ,KAAKL,IAAMA,EAAI,MAAM,GAAGK,CAAG;AAC5C;AAOA,SAAgBC,IAAoB;CAClC,OAAQ,WAAoD,WAAW,WAAW;AACpF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=platform-
|
|
1
|
+
const e=require("./constants-CqdJhTxH.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.qt.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.i.test(t)?!0:(e.St.test(t)||e.It.test(t)&&e.Ht.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;function l(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=e.replace(c,`$1`);return t?i:u(i)}function u(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function d(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
2
|
+
//# sourceMappingURL=platform-CfA3-7sJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-12uR7kBQ.cjs","names":["getFin","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","require_openfin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: (url: string) => string | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"A,gFAkDA,IAAIQ,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CACvD,IAAMC,EAAQC,EAAEC,GAIhB,OAHIF,IAAU,IAAA,IAGPC,aAAcD,CACvB,CAOA,SAAgBG,EAAe,EAA4C,CACzE,GAAIL,EACF,OAAOA,EAET,IAAMG,EAAI,WAEJG,EAAMH,EAAE,WAAqC,WAAa,GAC5DI,EAAyB,UACzBC,EACAC,EACAC,EAAW,GAETC,EAAQnB,EAAAA,EAAO,CAAC,EAAE,GAkCxB,OAhCIS,EAAcE,EAAG,0BAA0B,GAC7C,EAAW,iBACX,EAAW,IACFF,EAAcE,EAAG,yBAAyB,GACnD,EAAW,gBACX,EAAW,IACFF,EAAcE,EAAG,mBAAmB,GAC7C,EAAW,aACX,EAAW,IACFQ,IAAU,IAAA,GAOVR,EAAE,YAAc,IAAA,IAAaA,EAAE,QAAU,IAAA,GAClD,EAAW,QACFA,EAAE,UAAY,IAAA,IAAaS,EAAUN,CAAE,EAChD,EAAW,iBACF,OAAO,SAAa,KAAe,OAAO,QAAY,MAC/D,EAAW,SAXX,EAAWb,EAAAA,GAAmB,KAAKa,CAAE,EAAI,UAAY,cACrDO,EAAY,MAAM,sBAAuB,kDAAqD,CAC5F,IAAMC,EAAWH,EAAM,SACvB,EAAcG,GAAU,KACxB,EAAcA,GAAU,IAC1B,CAAC,GASH,EAAS,CACP,WACA,cACA,cACA,UAAWR,EACX,WACA,mBAAoBS,EAAWF,CAAW,CAC5C,EACOb,CACT,CAOA,SAASY,EAAU,EAAqB,CAMtC,OALIlB,EAAAA,EAA2B,KAAKY,CAAE,EAC7B,IAGPX,EAAAA,GAAsB,KAAKW,CAAE,GAAMV,EAAAA,GAAqB,KAAKU,CAAE,GAAKT,EAAAA,GAAkB,KAAKS,CAAE,IACjFA,EAAG,SAAA,aAAwB,GAAK,CAACA,EAAG,SAAA,SAAwB,CAC5E,CAOA,SAAgBS,EAAW,EAAmC,CAC5D,GAAI,OAAO,OAAW,IACpB,MAAO,GAET,GAAI,CACF,OAAO,OAAO,OAAS,OAAO,GAChC,MAAQ,CAGN,OADAF,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAOA,SAAgBG,EAAW,EAAkC,CAC3D,GAAI,CACF,OAAO,OAAO,SAAa,IAAc,SAAS,KAAO,EAC3D,MAAQ,CAGN,OADAH,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAGA,IAAMI,EAAoB,oCAY1B,SAAgBC,EACd,EACA,EACA,EACA,EACQ,CACR,GAAIC,EACF,GAAI,CACF,IAAMC,EAAQD,EAAUE,CAAG,EAC3B,OAAO,OAAOD,GAAU,SAAWA,EAAQ,EAC7C,OAASE,EAAO,CAQd,OANAT,GAAa,OACX,wBACA,yEACA,IAAA,GACAS,CACF,EACO,EACT,CAEF,IAAMC,EAAOF,EAAI,QAAQJ,EAAmB,IAAI,EAChD,OAAOO,EAAWD,EAAOE,EAAcF,CAAI,CAC7C,CAQA,SAAgBE,EAAc,EAAqB,CACjD,IAAMC,EAAML,EAAI,OAAO,MAAM,EAE7B,OAAOK,IAAQ,GAAKL,EAAMA,EAAI,MAAM,EAAGK,CAAG,CAC5C,CAOA,SAAgBC,GAAoB,CAClC,OAAQ,WAAoD,WAAW,SAAW,EACpF,C"}
|
|
1
|
+
{"version":3,"file":"platform-CfA3-7sJ.cjs","names":["getFin","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","require_openfin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: ((url: string) => string | null) | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"A,gFAkDA,IAAIQ,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CACvD,IAAMC,EAAQC,EAAEC,GAIhB,OAHIF,IAAU,IAAA,IAGPC,aAAcD,CACvB,CAOA,SAAgBG,EAAe,EAA4C,CACzE,GAAIL,EACF,OAAOA,EAET,IAAMG,EAAI,WAEJG,EAAMH,EAAE,WAAqC,WAAa,GAC5DI,EAAyB,UACzBC,EACAC,EACAC,EAAW,GAETC,EAAQnB,EAAAA,EAAO,CAAC,EAAE,GAkCxB,OAhCIS,EAAcE,EAAG,0BAA0B,GAC7C,EAAW,iBACX,EAAW,IACFF,EAAcE,EAAG,yBAAyB,GACnD,EAAW,gBACX,EAAW,IACFF,EAAcE,EAAG,mBAAmB,GAC7C,EAAW,aACX,EAAW,IACFQ,IAAU,IAAA,GAOVR,EAAE,YAAc,IAAA,IAAaA,EAAE,QAAU,IAAA,GAClD,EAAW,QACFA,EAAE,UAAY,IAAA,IAAaS,EAAUN,CAAE,EAChD,EAAW,iBACF,OAAO,SAAa,KAAe,OAAO,QAAY,MAC/D,EAAW,SAXX,EAAWb,EAAAA,GAAmB,KAAKa,CAAE,EAAI,UAAY,cACrDO,EAAY,MAAM,sBAAuB,kDAAqD,CAC5F,IAA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