@utk09/ui-observability 0.12.0 → 1.1.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 +280 -10
- package/README.md +70 -839
- package/dist/{batch-BjQUwjA6.js → batch-D3NHhF9L.js} +4 -4
- package/dist/{batch-BjQUwjA6.js.map → batch-D3NHhF9L.js.map} +1 -1
- package/dist/{batch-D5LlU4Q9.cjs → batch-DnYRJqhU.cjs} +2 -2
- package/dist/{batch-D5LlU4Q9.cjs.map → batch-DnYRJqhU.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +355 -0
- package/dist/bus/bus.d.ts +86 -12
- 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-B__467mL.cjs +2 -0
- package/dist/bus-B__467mL.cjs.map +1 -0
- package/dist/bus-dw7T92sO.js +788 -0
- package/dist/bus-dw7T92sO.js.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 +80 -0
- package/dist/capture/interactions.d.ts +36 -4
- 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/observed-windows.d.cts +51 -0
- package/dist/capture/observed-windows.d.ts +51 -0
- 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-C0hUHKR-.cjs} +2 -2
- package/dist/{compression-lD9abCcO.cjs.map → compression-C0hUHKR-.cjs.map} +1 -1
- package/dist/{compression-AJJCMBOa.js → compression-SHPAvS4U.js} +2 -2
- package/dist/{compression-AJJCMBOa.js.map → compression-SHPAvS4U.js.map} +1 -1
- package/dist/config-CSNcS7OZ.js +558 -0
- package/dist/config-CSNcS7OZ.js.map +1 -0
- package/dist/config-CybPP5VM.cjs +2 -0
- package/dist/config-CybPP5VM.cjs.map +1 -0
- package/dist/console-BsM-fSCQ.js +81 -0
- package/dist/console-BsM-fSCQ.js.map +1 -0
- package/dist/console-Dkxs6IVQ.cjs +2 -0
- package/dist/console-Dkxs6IVQ.cjs.map +1 -0
- package/dist/constants-BwJDXzj6.js +357 -0
- package/dist/constants-BwJDXzj6.js.map +1 -0
- package/dist/constants-CtF52hIV.cjs +2 -0
- package/dist/constants-CtF52hIV.cjs.map +1 -0
- package/dist/constants.d.cts +763 -0
- package/dist/constants.d.ts +100 -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 +99 -0
- package/dist/core/rotation.d.ts +99 -0
- package/dist/core/runtime.d.cts +774 -0
- package/dist/core/runtime.d.ts +254 -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-B2v6Cym-.cjs +2 -0
- package/dist/debug-bundle-B2v6Cym-.cjs.map +1 -0
- package/dist/debug-bundle-Cs_YWzTa.js +35 -0
- package/dist/debug-bundle-Cs_YWzTa.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 +119 -87
- package/dist/doctor.js.map +1 -1
- package/dist/errors-DP2RUm4V.cjs +3 -0
- package/dist/errors-DP2RUm4V.cjs.map +1 -0
- package/dist/errors-Q3Ng1ciC.js +86 -0
- package/dist/errors-Q3Ng1ciC.js.map +1 -0
- package/dist/factory-DV17sm2p.js +404 -0
- package/dist/factory-DV17sm2p.js.map +1 -0
- package/dist/factory-K8O6gpux.cjs +2 -0
- package/dist/factory-K8O6gpux.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-BgtHyY4u.js} +33 -26
- package/dist/identity-BgtHyY4u.js.map +1 -0
- package/dist/identity-CvuyqZk7.cjs +2 -0
- package/dist/identity-CvuyqZk7.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +301 -0
- package/dist/index.d.ts +90 -98
- package/dist/index.js +1253 -1555
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-D4KVcqdD.cjs +2 -0
- package/dist/indexeddb-storage-D4KVcqdD.cjs.map +1 -0
- package/dist/{indexeddb-storage-DLXQzAGh.js → indexeddb-storage-e-13ZLWm.js} +61 -57
- package/dist/indexeddb-storage-e-13ZLWm.js.map +1 -0
- package/dist/interactions-Byxf1C82.js +207 -0
- package/dist/interactions-Byxf1C82.js.map +1 -0
- package/dist/interactions-OK85T-Dk.cjs +2 -0
- package/dist/interactions-OK85T-Dk.cjs.map +1 -0
- package/dist/{journey-35yCMNFo.js → journey-C93FTYcs.js} +46 -49
- package/dist/journey-C93FTYcs.js.map +1 -0
- package/dist/journey-nMbob3OB.cjs +2 -0
- package/dist/journey-nMbob3OB.cjs.map +1 -0
- package/dist/{library-console-BFWEuQsl.cjs → library-console-DJUQzcgM.cjs} +2 -2
- package/dist/{library-console-BFWEuQsl.cjs.map → library-console-DJUQzcgM.cjs.map} +1 -1
- package/dist/{library-console-Dl_Ly6DQ.js → library-console-DklSmucS.js} +2 -2
- package/dist/{library-console-Dl_Ly6DQ.js.map → library-console-DklSmucS.js.map} +1 -1
- package/dist/{library-request-nI6pvI6I.js → library-request-UGEwOHpf.js} +2 -2
- package/dist/{library-request-nI6pvI6I.js.map → library-request-UGEwOHpf.js.map} +1 -1
- package/dist/{library-request-Da-CHKzT.cjs → library-request-kY9iTpIF.cjs} +2 -2
- package/dist/{library-request-Da-CHKzT.cjs.map → library-request-kY9iTpIF.cjs.map} +1 -1
- package/dist/{lifecycle-CZ6RRXc6.js → lifecycle-B2PlIuQu.js} +21 -29
- package/dist/lifecycle-B2PlIuQu.js.map +1 -0
- package/dist/lifecycle-DaMdH_X7.cjs +2 -0
- package/dist/lifecycle-DaMdH_X7.cjs.map +1 -0
- package/dist/log-record-Bmx6etMh.cjs +2 -0
- package/dist/log-record-Bmx6etMh.cjs.map +1 -0
- package/dist/{log-record-DIA6McNr.js → log-record-DSt2P-Sr.js} +8 -7
- package/dist/log-record-DSt2P-Sr.js.map +1 -0
- package/dist/{long-frames-430_85Da.js → long-frames-Bamjs1WV.js} +18 -22
- package/dist/long-frames-Bamjs1WV.js.map +1 -0
- package/dist/long-frames-lhtONgGt.cjs +2 -0
- package/dist/long-frames-lhtONgGt.cjs.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 +163 -0
- package/dist/models/bus.d.ts +28 -3
- package/dist/models/config.d.cts +1555 -0
- package/dist/models/config.d.ts +377 -261
- 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 +25 -0
- package/dist/models/serializer.d.ts +4 -2
- package/dist/models/storage.d.cts +95 -0
- package/dist/models/storage.d.ts +7 -5
- package/dist/network-BCn8Gn47.cjs +2 -0
- package/dist/network-BCn8Gn47.cjs.map +1 -0
- package/dist/{network-C7SkLf4v.js → network-Cg1L2w2r.js} +57 -57
- package/dist/network-Cg1L2w2r.js.map +1 -0
- package/dist/observed-windows-B3gJkdql.cjs +2 -0
- package/dist/observed-windows-B3gJkdql.cjs.map +1 -0
- package/dist/observed-windows-BrwaJNlj.js +64 -0
- package/dist/observed-windows-BrwaJNlj.js.map +1 -0
- package/dist/{otlp-2MCrC3kd.cjs → otlp-CrAWkQdO.cjs} +2 -2
- package/dist/{otlp-2MCrC3kd.cjs.map → otlp-CrAWkQdO.cjs.map} +1 -1
- package/dist/{otlp-COq033e3.js → otlp-D6dRZyB8.js} +9 -9
- package/dist/{otlp-COq033e3.js.map → otlp-D6dRZyB8.js.map} +1 -1
- package/dist/{platform-CVewe4wQ.js → platform-8DLhjddo.js} +9 -9
- package/dist/{platform-CVewe4wQ.js.map → platform-8DLhjddo.js.map} +1 -1
- package/dist/{platform-12uR7kBQ.cjs → platform-BqRc-7RO.cjs} +2 -2
- package/dist/{platform-12uR7kBQ.cjs.map → platform-BqRc-7RO.cjs.map} +1 -1
- package/dist/{profiler-BVWIOgnq.js → profiler-BaXSqCfz.js} +78 -96
- package/dist/profiler-BaXSqCfz.js.map +1 -0
- package/dist/profiler-BvWW2kNM.cjs +2 -0
- package/dist/profiler-BvWW2kNM.cjs.map +1 -0
- package/dist/{profiler-frames-CLXlT_xL.js → profiler-frames-C4ySHN0X.js} +21 -29
- package/dist/profiler-frames-C4ySHN0X.js.map +1 -0
- package/dist/profiler-frames-DeaBiB-5.cjs +2 -0
- package/dist/profiler-frames-DeaBiB-5.cjs.map +1 -0
- package/dist/remote-rules-D7L6D_D2.cjs +2 -0
- package/dist/remote-rules-D7L6D_D2.cjs.map +1 -0
- package/dist/remote-rules-Dq9xe7Qn.js +95 -0
- package/dist/remote-rules-Dq9xe7Qn.js.map +1 -0
- package/dist/replay-B0M8kWz_.js +310 -0
- package/dist/replay-B0M8kWz_.js.map +1 -0
- package/dist/replay-QOFBpAXh.cjs +2 -0
- package/dist/replay-QOFBpAXh.cjs.map +1 -0
- package/dist/{reports-BuXekPOS.js → reports--8APRLa-.js} +25 -30
- package/dist/reports--8APRLa-.js.map +1 -0
- package/dist/reports-ojuMKGO7.cjs +2 -0
- package/dist/reports-ojuMKGO7.cjs.map +1 -0
- package/dist/{resource-timing-CXGHwFRD.js → resource-timing-BzR05rE-.js} +20 -23
- package/dist/resource-timing-BzR05rE-.js.map +1 -0
- package/dist/resource-timing-pAG3ZhB5.cjs +2 -0
- package/dist/resource-timing-pAG3ZhB5.cjs.map +1 -0
- package/dist/response-body-BWvwKQ2p.js +331 -0
- package/dist/response-body-BWvwKQ2p.js.map +1 -0
- package/dist/response-body-CKEJ5itk.cjs +3 -0
- package/dist/response-body-CKEJ5itk.cjs.map +1 -0
- package/dist/rotation-BylN1B9e.js +93 -0
- package/dist/rotation-BylN1B9e.js.map +1 -0
- package/dist/rotation-E2eKClIs.cjs +2 -0
- package/dist/rotation-E2eKClIs.cjs.map +1 -0
- package/dist/sampling-B46LW0cy.cjs +2 -0
- package/dist/sampling-B46LW0cy.cjs.map +1 -0
- package/dist/sampling-zXA6r-Nw.js +63 -0
- package/dist/sampling-zXA6r-Nw.js.map +1 -0
- package/dist/{sanitize-CNmsD9r3.js → sanitize-DjnR6RXR.js} +2 -2
- package/dist/sanitize-DjnR6RXR.js.map +1 -0
- package/dist/{sanitize-ChLn97Ch.cjs → sanitize-Qj6LuZqp.cjs} +2 -2
- package/dist/sanitize-Qj6LuZqp.cjs.map +1 -0
- package/dist/sender-Bdp-TAS4.js +979 -0
- package/dist/sender-Bdp-TAS4.js.map +1 -0
- package/dist/sender-DR7ZycZY.cjs +2 -0
- package/dist/sender-DR7ZycZY.cjs.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-BOu54M8Y.cjs +2 -0
- package/dist/stored-context-BOu54M8Y.cjs.map +1 -0
- package/dist/stored-context-CSttrAsw.js +51 -0
- package/dist/stored-context-CSttrAsw.js.map +1 -0
- package/dist/storm-BHgI12iS.cjs +2 -0
- package/dist/storm-BHgI12iS.cjs.map +1 -0
- package/dist/storm-DKlpv0FL.js +9 -0
- package/dist/storm-DKlpv0FL.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-BYPYYkQ5.cjs +2 -0
- package/dist/unclean-exit-BYPYYkQ5.cjs.map +1 -0
- package/dist/{unclean-exit-Cob_jyTv.js → unclean-exit-BcOB8A2e.js} +23 -30
- package/dist/unclean-exit-BcOB8A2e.js.map +1 -0
- package/dist/{user-timing-DgHubxCI.js → user-timing-4KIJ74Vi.js} +15 -17
- package/dist/user-timing-4KIJ74Vi.js.map +1 -0
- package/dist/user-timing-BsU2wQKE.cjs +2 -0
- package/dist/user-timing-BsU2wQKE.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 +114 -0
- package/dist/utils/identity.d.ts +8 -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-Cs1ZbmmN.cjs +2 -0
- package/dist/{web-socket-DthJuSAg.js.map → web-socket-Cs1ZbmmN.cjs.map} +1 -1
- package/dist/{web-socket-DthJuSAg.js → web-socket-Zg0hj1LB.js} +23 -28
- package/dist/web-socket-Zg0hj1LB.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-B0_8rWy5.js → worker-protocol-CYpAbrVl.js} +14 -11
- package/dist/worker-protocol-CYpAbrVl.js.map +1 -0
- package/dist/worker-protocol-DFYXIFus.cjs +2 -0
- package/dist/worker-protocol-DFYXIFus.cjs.map +1 -0
- package/dist/worker-server--yGTadTA.cjs +2 -0
- package/dist/worker-server--yGTadTA.cjs.map +1 -0
- package/dist/worker-server-BokySIII.js +94 -0
- package/dist/worker-server-BokySIII.js.map +1 -0
- package/dist/worker-transport-BdEvh_-a.cjs +2 -0
- package/dist/worker-transport-BdEvh_-a.cjs.map +1 -0
- package/dist/worker-transport-JK-Fby9J.js +194 -0
- package/dist/worker-transport-JK-Fby9J.js.map +1 -0
- package/llms.txt +400 -0
- package/package.json +65 -49
- package/dist/bus-D_7pd7RN.cjs +0 -2
- package/dist/bus-D_7pd7RN.cjs.map +0 -1
- package/dist/bus-ecxUNTja.js +0 -660
- 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 +0 -119
- 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
package/llms.txt
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# @utk09/ui-observability
|
|
2
|
+
|
|
3
|
+
> Framework-neutral structured logging and UI observability for browsers, embedded webviews and OpenFin containers. The library batches records and sends them over HTTP as OTLP/JSON. It stores a batch that fails to send and sends it again later. It sends the last records when the page closes. It has one entry point, no runtime dependency and three optional peers. A log call never throws.
|
|
4
|
+
|
|
5
|
+
This file is for a large language model that writes code with this package. The package does not include the `docs/` folder, so this file has the rules for the common tasks. Each function name, config key and default here comes from `src/index.ts`, `src/models/config.ts` and `src/constants.ts` of version 1.0.0. The links at the end go to the full reference.
|
|
6
|
+
|
|
7
|
+
## What the library does
|
|
8
|
+
|
|
9
|
+
- Writes log records with a namespace, a level, a message and a payload.
|
|
10
|
+
- Records user actions, domain events, metrics (counter, gauge, histogram), timed operations (measures) and profiler probes.
|
|
11
|
+
- Captures browser signals when you turn them on. Uncaught errors and unhandled rejections are on by default. Fetch, XHR, clicks, navigation, web vitals, long frames, console calls and WebSockets are off by default.
|
|
12
|
+
- Puts five correlation ids on each record: `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
|
|
13
|
+
- Sends OTLP/JSON by default, or ECS NDJSON. It gzips a body of 1 KiB or more. Metrics and spans can go to their own OTLP endpoints.
|
|
14
|
+
- Stores a failed batch in IndexedDB or `localStorage` and sends it again with backoff.
|
|
15
|
+
- Connects iframes, workers and OpenFin views to one sender in each tab, through a bus.
|
|
16
|
+
- Records the DOM for a session replay after an error, with the `@rrweb/record` package of the app. The replay is off by default.
|
|
17
|
+
|
|
18
|
+
## What the library does not do
|
|
19
|
+
|
|
20
|
+
- It imports no framework. It has no React, Angular or Vue adapter. The app writes that code. See the React recipe below.
|
|
21
|
+
- It does not remove personal data by default. Write a `redact` hook for that. Without hooks, the library only makes values safe to serialize.
|
|
22
|
+
- On Node, for example in server-side rendering, it sends nothing. It prints to the console only.
|
|
23
|
+
- It does not authenticate. The app gives `headers`, `credentials` or a custom `transport`.
|
|
24
|
+
- It is not an audit trail. A record can be lost. `onDrop` reports each loss of a built record.
|
|
25
|
+
- OpenFin support is not validated on a real OpenFin runtime.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install --save-exact @utk09/ui-observability
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| Peer | Version | Install it for | Set this key |
|
|
34
|
+
| -------------------- | ------------------ | ------------------------------------- | -------------------------- |
|
|
35
|
+
| `@opentelemetry/api` | `^1` | Records on your OpenTelemetry traces. | `otelLoader` |
|
|
36
|
+
| `@rrweb/record` | `^2` | Session replay. | `replay.loader` |
|
|
37
|
+
| `web-vitals` | `^4`, `^5` or `^6` | LCP, CLS, INP, FCP and TTFB. | `capture.webVitals.loader` |
|
|
38
|
+
|
|
39
|
+
Each peer is optional. Give each peer as a loader function with a dynamic `import()`. The library never imports a peer by name, so a missing peer cannot break the bundler.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
configure({
|
|
43
|
+
endpoint: "https://ingest.example/v1/logs",
|
|
44
|
+
serviceName: "orders",
|
|
45
|
+
otelLoader: () => import("@opentelemetry/api"),
|
|
46
|
+
capture: { webVitals: { loader: () => import("web-vitals") } },
|
|
47
|
+
replay: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
endpoint: "https://ingest.example/v1/replay",
|
|
50
|
+
loader: () => import("@rrweb/record"),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- Without `capture.webVitals.loader`, the library reports `config.invalid`. Only the navigation timing then runs.
|
|
56
|
+
- Without `otelLoader`, OpenTelemetry is off. The library then makes its own `trace_id`.
|
|
57
|
+
- Browsers: Chrome 85, Edge 85, Firefox 79, Safari 14.1 and later. Node 22 or later, console only. The package has no `engines` field.
|
|
58
|
+
- The package has an ES module entry and a CommonJS entry. They are separate copies with separate state. Use one format in one app.
|
|
59
|
+
|
|
60
|
+
## The start rule
|
|
61
|
+
|
|
62
|
+
- Nothing starts before the first `configure()` call that works. Call it one time, at module top level of the app entry, before the first render.
|
|
63
|
+
- Before that call, a log call does not throw. The record waits in memory, in the hold buffer. The library installs no capture, starts no bus, sends nothing and writes nothing to storage. `getHealth().status` is `"unconfigured"`. `flush()` returns the status `"inactive"`. `rotateSecurityContext()` rejects.
|
|
64
|
+
- The first call that works starts the runtime. The held records then get its `processors`, its `redact` and its identity. Then they go out.
|
|
65
|
+
- An app that never calls `configure()` sends nothing. The console output is off by default, so it also prints nothing.
|
|
66
|
+
- `getLogger()` at module top level is safe before `configure()`. The logger finds the runtime on its first write.
|
|
67
|
+
- `configure()` never throws. A value of the wrong type or outside its range reports `config.invalid`, and the current value stays. An unknown key also reports `config.invalid`.
|
|
68
|
+
- Set `endpoint` and `serviceName` in the first call. Set `endpoint: null` for console-only mode.
|
|
69
|
+
- A later call merges into the current settings. An omitted key or `undefined` keeps the current value. `null` removes a hook or turns off an endpoint. On a limit key, `null` means no limit and `0` means zero.
|
|
70
|
+
- These keys are fixed by the first call that works: `identity`, `correlation`, `limits`, `journey.maxAgeMs`, `profiler.maxProbes`, `storage`, `bus.mode` and `bus.openFinRole`. `batching` and `retention` are fixed when the delivery stack loads. A later change reports `config.invalid`.
|
|
71
|
+
- `otelLoader` is also fixed by the first call that works. A later change has no effect and reports nothing.
|
|
72
|
+
- With `securityContext.isolation: true` (the default), `configure()` refuses a change of `endpoint`, `metricsEndpoint`, `tracesEndpoint`, `headers`, `credentials`, `transport`, `transportOnExit`, `transportWorker` and `securityContext.id`. Use `rotateSecurityContext()` for these changes.
|
|
73
|
+
- `enabled: false` is a pause, not a stop. Log calls do nothing. The captures, the replay and the sender stop. The records in memory and in storage stay, and they go out after `enabled: true`. `getHealth().status` is `"disabled"`.
|
|
74
|
+
- `shutdown()` stops the runtime. After it, each call does nothing until the next `configure()`, which builds a new runtime. `rotateSecurityContext()` rejects until then.
|
|
75
|
+
- Call `configure()` in one context of each document. In a page with microfrontends, the shell calls it. Each microfrontend calls only `getLogger()` with its own namespace.
|
|
76
|
+
|
|
77
|
+
## Public functions
|
|
78
|
+
|
|
79
|
+
Import each function and type from `"@utk09/ui-observability"`. A call never throws.
|
|
80
|
+
|
|
81
|
+
Setup and lifecycle:
|
|
82
|
+
|
|
83
|
+
- `configure(config: Partial<ObservabilityConfig>): void`. Starts the runtime, or updates it.
|
|
84
|
+
- `setConfigurationLocked(locked: boolean): void`. Refuses later `configure()` changes. Call it after `configure()`.
|
|
85
|
+
- `rotateSecurityContext(update: SecurityContextUpdate, options?: SecurityContextRotationOptions): Promise<void>`. Changes the delivery identity and the routing settings together, at login, logout or a tenant change. `update` is `{ id?, routing, context? }`. A routing field that you omit resets to its default. An omitted `id` gives a new id. An omitted `context` removes the old context attributes. `options` is `{ pending?: "discard" | "flush" | "retain" | "carry", timeoutMs? }`, defaults `"discard"` and `5000`.
|
|
86
|
+
- `newSession(): void`. Starts a new `session.id` in this tab. It does not isolate the stored batches or the credentials.
|
|
87
|
+
- `shutdown(options?: ShutdownOptions): Promise<void>`. Stops each subsystem. `options` is `{ pending?: "flush" | "discard", clearStorage?: "context" | "namespace" | null }`. The default `"flush"` sends the records in memory, then runs the exit flush.
|
|
88
|
+
|
|
89
|
+
Logging:
|
|
90
|
+
|
|
91
|
+
- `getLogger(namespace: string, options?: { scopedContext?: Record<string, unknown> }): Logger`. Returns the cached logger of the namespace. With `options`, it returns a new logger that is not cached.
|
|
92
|
+
- `Logger` methods: `trace`, `debug`, `info`, `warn` take `(message: string, payload?: Record<string, unknown>)`. `error` and `fatal` take `(message: string, err?: unknown, payload?: Record<string, unknown>)` and add the breadcrumb trail. `logAction(name, payload?)` logs a user action. `logEvent(name, payload?)` logs a domain or lifecycle event. `child(namespace, options?)` returns a logger for `<namespace>.<child>`.
|
|
93
|
+
- `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `logAction`, `logEvent`. The same functions on the `"app"` logger.
|
|
94
|
+
- `addBreadcrumb(message: string, data?: Record<string, unknown>): void`. Adds a breadcrumb. The next error record carries the trail.
|
|
95
|
+
|
|
96
|
+
Metrics and timing:
|
|
97
|
+
|
|
98
|
+
- `counter(name: string, options?: { unit?: string }): Counter`. `add(value, attributes?)` sums values of 0 or more.
|
|
99
|
+
- `gauge(name: string, options?: { unit?: string }): Gauge`. `set(value, attributes?)` keeps the last value.
|
|
100
|
+
- `histogram(name: string, options?: { unit?: string; boundaries?: readonly number[] }): Histogram`. `record(value, attributes?)` counts values in buckets.
|
|
101
|
+
- `startMeasure(name: string, attributes?: MetricAttributes): Measure`. `phase(name)` starts a named phase. `end(outcome?)` records the total. The default outcome is `"ok"`.
|
|
102
|
+
- `measure<T>(name: string, fn: () => T, attributes?: MetricAttributes): T`. Times one call. A throw or a rejection gives the outcome `"error"` and goes to the caller. `measure()` does not log the error. The app logs it.
|
|
103
|
+
- `profiler.probe(name: string, options?: { sampleEvery?, slowMs?, async? }): Probe`. A low-cost timer for code that runs very often. `begin()` returns a token for `end(token)`. Needs `profiler.enabled: true`.
|
|
104
|
+
- `profiler.time<T>(name: string, fn: () => T): T`. Times one call with the probe of the name.
|
|
105
|
+
- Metric attribute values are strings, finite numbers or booleans. Each instrument sends one point for each attribute set at each `metrics.intervalMs`. Sampling and `minLevel` do not drop a point.
|
|
106
|
+
|
|
107
|
+
Context, journeys and traces:
|
|
108
|
+
|
|
109
|
+
- `setContext(values: Record<string, unknown>): void`. Merges attributes into each later record. A `null` value removes its key.
|
|
110
|
+
- `removeContext(key: string): void`. Removes one context attribute.
|
|
111
|
+
- `startJourney(name: string, options?: { parent?: boolean; id?: string }): Journey`. Starts a workflow id that spans windows. `Journey` has `id`, `name`, `startedAt`, `parentId?` and `ownerContextId`.
|
|
112
|
+
- `endJourney(): void`. Ends the active journey.
|
|
113
|
+
- `currentJourney(): Journey | null`. Returns the active journey.
|
|
114
|
+
- `getJourneyToken(): string | null`. Returns a URL token for the active journey, or `null`.
|
|
115
|
+
- `adoptJourney(token: string): boolean`. Adopts a journey token. Returns `true` when the token is valid.
|
|
116
|
+
- `newTrace(): void`. Starts a new trace. Later records and requests have the new `trace_id`.
|
|
117
|
+
- `getTraceHeaders(): Record<string, string>`. Returns the W3C `traceparent` header for an outgoing request.
|
|
118
|
+
|
|
119
|
+
Frames, workers and transports:
|
|
120
|
+
|
|
121
|
+
- `registerFrame(frame: HTMLIFrameElement | Window, options: { origin: string; permissions?: BusPermission[] }): () => void`. Lets a child frame on that exact origin forward its records. Returns a function that removes the registration.
|
|
122
|
+
- `registerWorker(worker: WorkerLike, options?: { permissions?: BusPermission[] }): () => void`. The same for a Web Worker or a `MessagePort`.
|
|
123
|
+
- `observeWindow(target: Window): () => void`. Captures clicks, rage clicks and dead clicks in another window of the page with the same origin, for example a popout. It needs `capture.interactions`. A window from another origin reports `capture.install_failed`. Returns a function that stops the observation. While `capture.interactions` is on, the window also leaves at its `pagehide`. The result of `window.open()` works at once, because the `pagehide` of its initial `about:blank` does not end the capture. A closed `about:blank` popout leaves at the next dead click check, install or `observeWindow()` call. After the app fills `about:blank` and loads a page in it, call `observeWindow()` again. A navigation to another origin ends the capture in that window. A window that opens to another origin and is observed at once gets no report. The library forgets it at its next dead click check.
|
|
124
|
+
- `BusPermission` is `"records"`, `"journey:read"`, `"journey:write"` or `"sampling:read"`. Without a list, the source can only send records.
|
|
125
|
+
- `serveTransportWorker(options?: { onDiagnostic? }): () => void`. Call it in the worker script of `transportWorker`. Returns a function that stops the service.
|
|
126
|
+
- `createMemoryTransport(): MemoryTransport`. A transport for tests. It has `transport`, `records()`, `batches()`, `clear()` and `respondWith(status, retryAfterMs?)`.
|
|
127
|
+
|
|
128
|
+
Delivery and health:
|
|
129
|
+
|
|
130
|
+
- `flush(options?: { timeoutMs?: number }): Promise<FlushResult>`. Sends the records in memory and waits until each one has a final state, or until `timeoutMs` (default 5000, range 0 to 600000). It never rejects. `FlushResult` is `{ status: "complete" | "timeout" | "inactive", accepted, stored, dropped, forwarded, pending }`. Each count is a number of records.
|
|
131
|
+
- `getHealth(): Promise<ObservabilityHealth>`. Returns `status` (`"unconfigured"`, `"disabled"`, `"starting"`, `"ready"`, `"rotating"`, `"degraded"` or `"stopped"`), `mode`, `issues`, `sdkVersion` and the `delivery` block `{ pending, inFlight, stored, lastSendAt, lastFailureAt, consecutiveFailures, throttledUntil, dropped }`.
|
|
132
|
+
- `getDiagnosticCounters(): Record<string, number>`. Returns the count of each diagnostic code.
|
|
133
|
+
- `collectDebugBundle(): Promise<DebugBundle>`. Returns a JSON-safe bundle for a support ticket. It has no headers and no URL query.
|
|
134
|
+
|
|
135
|
+
Session replay:
|
|
136
|
+
|
|
137
|
+
- `startReplay(): void`. Starts the recorder. With `replay.requireConsent: true`, nothing records before this call.
|
|
138
|
+
- `stopReplay(): void`. Stops the recorder and drops each replay event that is not sent.
|
|
139
|
+
|
|
140
|
+
## Configuration
|
|
141
|
+
|
|
142
|
+
Top-level keys of `ObservabilityConfig`, with their defaults:
|
|
143
|
+
|
|
144
|
+
| Key | Default | Use |
|
|
145
|
+
| ------------------- | ----------- | ------------------------------------------------------------------------------------------- |
|
|
146
|
+
| `endpoint` | not set | URL for the log batches. Required in the first call. `null` selects console-only mode. |
|
|
147
|
+
| `serviceName` | `""` | `service.name` on each record. |
|
|
148
|
+
| `serviceVersion` | `""` | `service.version` on each record. |
|
|
149
|
+
| `environment` | `""` | `deployment.environment` on each record. |
|
|
150
|
+
| `enabled` | `true` | `false` pauses the library. |
|
|
151
|
+
| `minLevel` | `"INFO"` | Lowest level that the library sends: `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`. |
|
|
152
|
+
| `minLevels` | `{}` | Lowest level for each namespace prefix, for example `{ "trading.ticks": "DEBUG" }`. |
|
|
153
|
+
| `consoleOutput` | `false` | `true` prints from `DEBUG` up. A level name prints from that level. Or `{ level, styles }`. |
|
|
154
|
+
| `metricsEndpoint` | `null` | OTLP metrics URL. Works with each `serializer`. Without it, a metric point is a log record on `endpoint`. |
|
|
155
|
+
| `tracesEndpoint` | `null` | OTLP traces URL. Works with each `serializer`. Without it, the library sends no span. No OpenTelemetry SDK is necessary. |
|
|
156
|
+
| `serializer` | `"otlp"` | `"otlp"`, `"ecs"` or a custom `LogSerializer`. Formats the batches for `endpoint` only. A `400` answer drops the whole batch. |
|
|
157
|
+
| `compression` | `"gzip"` | `"gzip"` or `"none"`. |
|
|
158
|
+
| `credentials` | `"omit"` | Fetch credentials mode. `"include"` for cookie authentication. |
|
|
159
|
+
| `headers` | not set | An object, or a function that returns one or a promise of one. |
|
|
160
|
+
| `identity` | `"storage"` | Where the ids live. `"memory"` writes no key to `localStorage` or `sessionStorage`. |
|
|
161
|
+
| `payloadMode` | `"copy"` | `"defer"` keeps the payload reference until idle time. |
|
|
162
|
+
| `redact` | not set | `(record: LogRecord) => LogRecord \| null`. The last privacy gate. |
|
|
163
|
+
| `processors` | `[]` | Functions with the contract of `redact`. They run before `redact`. |
|
|
164
|
+
| `contextProvider` | not set | Returns attributes for each record. Keep it fast and synchronous. |
|
|
165
|
+
| `onDrop` | not set | `(summary: DropSummary) => void`. Gets each loss of built records. |
|
|
166
|
+
| `onDiagnostic` | not set | `(event: DiagnosticEvent) => void`. Gets each fault of the library. |
|
|
167
|
+
| `transport` | not set | Sends a batch through a channel of the app. `endpoint` is then optional. |
|
|
168
|
+
| `transportOnExit` | not set | Sends the last batch while the page closes. Needs `transport`. Must not wait. |
|
|
169
|
+
| `transportWorker` | not set | `() => Worker`. Sends from a dedicated worker that calls `serveTransportWorker()`. |
|
|
170
|
+
| `otelLoader` | not set | `() => import("@opentelemetry/api")`. |
|
|
171
|
+
| `lockConfiguration` | `false` | Refuses changes through `configure()`. |
|
|
172
|
+
|
|
173
|
+
Sections and their keys. Each key is optional in `configure()`. A section takes an object only. For example, `storage: "memory"` reports `config.invalid`.
|
|
174
|
+
|
|
175
|
+
- `capture`: `errors: true`, `rejections: true`, `httpMetrics: true`. Each other switch is `false`: `resourceErrors`, `fetch`, `xhr`, `interactions`, `navigation`, `webVitals`, `longFrames`, `console`, `webSocket`, `uncleanExit`, `userTiming`, `serverTiming`, `reports`, `resourceTiming`, `lifecycle`. URL rules: `fullUrls: false`, `urlTransform` not set, `ignoreUrls: []`, `propagateTraceHeaderTo: []`. Also `remoteToggles: []` and `plugins: []`.
|
|
176
|
+
- Capture options objects. An object turns the capture on. `interactions: { text, selector, ignoreSelector, maxTextChars, actionAttribute, rageClicks, rageClickCount, rageClickWindowMs, deadClicks, deadClickMs, deadClickIgnoreSelector }`. `webVitals: { loader }`. `longFrames: { thresholdMs }` (default 100). `console: { levels }` (default `["error", "warn"]`). `userTiming: { include }` (default `[]`, each name). `resourceTiming: { slowMs }` (default 1000).
|
|
177
|
+
- `sampling`: `defaultRate: 1`, `rates: {}`, `alwaysSampleTypes: ["action"]`, `alwaysSampleFrom: "ERROR"`, `errorCeiling: 500`, `errorCeilingWindowMs: 10000`, `remote: false`, `remoteMaxRate: 1`.
|
|
178
|
+
- `storage`: `backend: "auto"` (`"auto"`, `"indexeddb"`, `"localstorage"`, `"memory"` or `"none"`), `namespace: ""`, `requestPersistent: false`.
|
|
179
|
+
- `bus`: `mode: "auto"` (`"auto"`, `"sender"`, `"forwarder"` or `"off"`), `trustedOrigins: []`, `sourcePolicy: "registered"` (or `"trusted-origin"`), `openFinRole: "auto"`, `maxMessageBytes: 262144`, `maxRecordsPerMessage: 100`, `maxMessagesPerSecond: 100`.
|
|
180
|
+
- `batching`: `logFlushIntervalMs: 2000`, `logBatchSize: 100`, `metricBatchSize: 500`.
|
|
181
|
+
- `retention`: `maxBatches: 500`, `maxAgeMs: 86400000`, `maxAttempts: 5`.
|
|
182
|
+
- `delivery`: `requestTimeoutMs: 15000`, `maxConcurrentRequests: 2`, `retryBaseDelayMs: 2000`, `retryMaxDelayMs: 60000`, `priority: "low"`.
|
|
183
|
+
- `buffering`: `maxPendingRecords: 10000`, `maxPendingBytes: 16777216`, `maxHeldRecords: 500`, `overflow: "drop-oldest"`.
|
|
184
|
+
- `limits`: `maxBodyChars: 4096`, `maxAttributeChars: 8192`, `maxAttributeCount: 128`, `maxStackChars: 8192`, `maxDepth: 6`, `maxArrayLength: 100`, `maxNodes: 10000`, `maxRecordBytes: 32768`.
|
|
185
|
+
- `metrics`: `intervalMs: 10000`, `maxSeries: 100`, `maxInstruments: 1000`, `maxHistogramBoundaries: 50`.
|
|
186
|
+
- `correlation`: `sessionIdleMs: 1800000`, `traceMaxAgeMs: 300000`.
|
|
187
|
+
- `journey`: `scope: "auto"`, `maxAgeMs: 1800000`.
|
|
188
|
+
- `securityContext`: `id` (generated when not set), `isolation: true`.
|
|
189
|
+
- `captureLimits`: `breadcrumbs: 50`, `errorDedupeMs: 5000`, `errorsPerWindow: 20`, `consolePerWindow: 20`, `longFramesPerWindow: 20`, `webSocketPerWindow: 20`, `reportsPerWindow: 20`, `resourcesPerWindow: 100`, `lifecyclePerWindow: 20`, `windowMs: 10000`.
|
|
190
|
+
- `metadata`: `pageUrl: true`, `userAgent: true`, `openfin: true`, `clockOffset: true`.
|
|
191
|
+
- `diagnostics`: `throttleMs: 1000`, `consoleFallback: false`, `records: false`.
|
|
192
|
+
- `debugBuffer`: `enabled: false`, `maxRecords: 200`, `maxAgeMs: 60000`.
|
|
193
|
+
- `profiler`: `enabled: false`, `maxProbes: 64`, `framePhases: false`, `framePacing: false`.
|
|
194
|
+
- `replay`: `enabled: false`, `mode: "onError"`, `endpoint: null`, `loader: null`, `requireConsent: false`, `bufferMs: 60000`, `maxBufferBytes: 10000000`, `afterErrorMs: 5000`, `uploadsPerWindow: 3`, `uploadWindowMs: 10000`, `maxSegmentEvents: 200`, `maxSegmentBytes: 512000`, `flushIntervalMs: 2000`, `maxQueueBytes: 20000000`, `maxAttempts: 3`, `maskText: true`, `maskInputs: true`, `recordCanvas: false`, `maskSelectors: []`, `blockSelectors: []`, `headers: null`, `onSegment: null`, `plugins: []`, `recordOptions: {}`. The replay needs `loader`, and `endpoint` or `onSegment`.
|
|
195
|
+
- `loggerCache`: `maxEntries: 256`.
|
|
196
|
+
|
|
197
|
+
## Recipes
|
|
198
|
+
|
|
199
|
+
Console only, with no network:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
configure({
|
|
203
|
+
endpoint: null,
|
|
204
|
+
serviceName: "orders",
|
|
205
|
+
identity: "memory",
|
|
206
|
+
storage: { backend: "none" },
|
|
207
|
+
bus: { mode: "off" },
|
|
208
|
+
consoleOutput: "DEBUG",
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Redact a field. `redact` runs on each record before the console, a callback or the network sees it. The sender also runs its `redact` on each record from a frame or a worker, so a second run must give the same result.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
configure({
|
|
216
|
+
endpoint: "https://ingest.example/v1/logs",
|
|
217
|
+
serviceName: "orders",
|
|
218
|
+
redact: (record) =>
|
|
219
|
+
"card" in record.attributes
|
|
220
|
+
? { ...record, attributes: { ...record.attributes, card: "[redacted]" } }
|
|
221
|
+
: record,
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
React error boundary. A render error that a React error boundary catches does not reach `window.onerror`, so the error capture does not see it. Log it in `componentDidCatch`. The library has no React code. The example app in `playground/react/src/observability/react.tsx` on GitHub has a boundary, a provider and hooks. Call `configure()` at module top level, not in a component.
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
componentDidCatch(error: Error, info: React.ErrorInfo): void {
|
|
229
|
+
getLogger("react").error("render failed", error, {
|
|
230
|
+
"react.component_stack": info.componentStack,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Frames. Register the frame in the parent before the frame loads its page. The frame also calls `configure()`. A cross-origin frame needs the parent origin in `bus.trustedOrigins`. The parent batches and sends the records of the frame, and the parent `redact` runs on them.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
// Parent page, after configure(). The iframe is in the document and has no src yet.
|
|
239
|
+
registerFrame(frame, { origin: "https://ticket.example", permissions: ["records"] });
|
|
240
|
+
await flush(); // Waits for the startup, so the registration is active.
|
|
241
|
+
frame.src = "https://ticket.example/";
|
|
242
|
+
|
|
243
|
+
// Frame on https://ticket.example.
|
|
244
|
+
configure({
|
|
245
|
+
endpoint: "https://ingest.example/v1/logs",
|
|
246
|
+
serviceName: "ticket",
|
|
247
|
+
bus: { trustedOrigins: ["https://app.example"] },
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A frame that starts before the parent runtime gets no owner. After 1,500 ms (4,500 ms for a cross-origin frame) it sends its own records with its own `redact`.
|
|
252
|
+
|
|
253
|
+
Workers. Register the worker in the page. The worker script calls `configure()` and logs as usual.
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
const worker = new Worker(new URL("./pricing.worker.ts", import.meta.url), { type: "module" });
|
|
257
|
+
registerWorker(worker);
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Logout on a shared device. Send nothing more, and remove the stored batches, the session id, the tab id and the journey. Then start a new runtime for the next user.
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
await shutdown({ pending: "discard", clearStorage: "context" });
|
|
264
|
+
configure(anonymousConfig);
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Logout that sends the old records with the old token first, then changes the routing:
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
await rotateSecurityContext(
|
|
271
|
+
{ routing: { endpoint: "https://ingest.example/v1/logs" } },
|
|
272
|
+
{ pending: "flush", timeoutMs: 3000 },
|
|
273
|
+
);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Flush with a time limit, for example before a navigation that the app controls. `status: "complete"` means only that no record waits. A dropped record and a stored record also count as complete. To confirm delivery, check `accepted`, `dropped` and `stored`.
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
const result = await flush({ timeoutMs: 2000 });
|
|
280
|
+
if (result.pending > 0) {
|
|
281
|
+
// These records have no final state yet. The library still sends or stores them.
|
|
282
|
+
}
|
|
283
|
+
if (result.dropped > 0 || result.stored > 0) {
|
|
284
|
+
// These records did not reach the server. A stored record goes out at a later retry.
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Custom transport. The status code has the meaning of the ingest contract. Put the transport URL in `capture.ignoreUrls`, or the network capture records each send, and the sends do not stop.
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
configure({
|
|
292
|
+
serviceName: "orders",
|
|
293
|
+
transport: async (request) => {
|
|
294
|
+
const response = await apiClient.post("/telemetry", request.body, {
|
|
295
|
+
headers: { "Content-Type": request.contentType, "X-UiObs-Batch-Id": request.batchId },
|
|
296
|
+
});
|
|
297
|
+
return { status: response.status };
|
|
298
|
+
},
|
|
299
|
+
capture: { ignoreUrls: ["/telemetry"] },
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Tests. Use the memory transport, and run the test in a DOM environment. In Node, the library is console-only, so the memory transport gets no batch. In Vitest, install `happy-dom` or `jsdom` and set the test environment.
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
// vitest.config.ts
|
|
307
|
+
import { defineConfig } from "vitest/config";
|
|
308
|
+
|
|
309
|
+
export default defineConfig({
|
|
310
|
+
test: { environment: "happy-dom" },
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Do not mock the library in each spec. Configure it one time in a Vitest setup file. Export the memory transport from a separate module. Import that module in the setup file and in each spec. See the Testing guide.
|
|
315
|
+
|
|
316
|
+
Set `storage: { backend: "none" }`, or `shutdown()` stores the unsent records for the next test. `memory.clear()` keeps the answer of `respondWith()`, so call `memory.respondWith(200)` in `afterEach` when a test changes the answer. Call `memory.clear()` after `await shutdown()`, because `shutdown()` sends the pending records.
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
const memory = createMemoryTransport();
|
|
320
|
+
configure({
|
|
321
|
+
serviceName: "orders",
|
|
322
|
+
transport: memory.transport,
|
|
323
|
+
storage: { backend: "none" },
|
|
324
|
+
bus: { mode: "off" },
|
|
325
|
+
identity: "memory",
|
|
326
|
+
});
|
|
327
|
+
getLogger("orders.ticket").logAction("ORDER_SUBMIT", { orderId: "ORD-1" });
|
|
328
|
+
expect(await flush()).toMatchObject({ status: "complete", dropped: 0, stored: 0 });
|
|
329
|
+
expect(memory.records()).toContainEqual(expect.objectContaining({ body: "ORDER_SUBMIT" }));
|
|
330
|
+
await shutdown();
|
|
331
|
+
memory.clear();
|
|
332
|
+
memory.respondWith(200);
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Metrics and measures:
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
counter("orders.submitted").add(1, { tier: "gold" });
|
|
339
|
+
gauge("queue.depth").set(queue.length);
|
|
340
|
+
histogram("price.latency", { unit: "ms" }).record(elapsedMs);
|
|
341
|
+
// measure() records the outcome "error" but writes no error record. Log the error yourself.
|
|
342
|
+
const rows = await measure("rows.fetch", () => fetchRows()).catch((err: unknown) => {
|
|
343
|
+
getLogger("app").error("rows.fetch failed", err);
|
|
344
|
+
throw err;
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Privacy rules
|
|
349
|
+
|
|
350
|
+
- `redact` is the last privacy gate. `processors` run first, then `redact`. Then the console, a callback or the network sees the record.
|
|
351
|
+
- A hook that throws, or returns a value that is not a record, drops the record.
|
|
352
|
+
- A `redact` value that is not a function keeps the current hook. With no current hook, the library drops each record until `redact` is a function or `null`.
|
|
353
|
+
- A server can never change a privacy setting. A remote rule in `X-UiObs-Sampling` changes only the sampling rates, the levels that the library sends and the capture switches in `capture.remoteToggles`. Each rule has a time limit.
|
|
354
|
+
- A recorded URL has no query and no fragment, unless `capture.fullUrls` is `true` or `urlTransform` is set.
|
|
355
|
+
- Click capture records no element text and no selector, unless `interactions.text` or `interactions.selector` is `true`.
|
|
356
|
+
- Set `redact` before you turn on `capture.console`, because a console argument can hold a header or a token.
|
|
357
|
+
- The replay masks text and input values by default. `redact` and `processors` do not apply to a replay event.
|
|
358
|
+
- `identity: "memory"` writes no id to the device.
|
|
359
|
+
|
|
360
|
+
## Ingest contract
|
|
361
|
+
|
|
362
|
+
- The server accepts `POST` with `Content-Type: application/json` (OTLP), `application/x-ndjson` (ECS, with `serializer: "ecs"`) or `text/plain;charset=UTF-8`. The exit batch to another origin uses `text/plain;charset=UTF-8`.
|
|
363
|
+
- Each batch has the headers `X-UiObs-Batch-Id` and `X-UiObs-Attempt`. A body of 1 KiB or more has `Content-Encoding: gzip`. The CORS preflight must allow `content-type, content-encoding, x-uiobs-batch-id, x-uiobs-attempt`, and the name of each header in `headers`.
|
|
364
|
+
- The exit batch has its batch id in the query `uiobs_batch_id` and the reason in `uiobs_exit`.
|
|
365
|
+
- The server deduplicates on the batch id for at least 24 hours. The library can send a batch more than one time.
|
|
366
|
+
- `200`, `202` and `204` accept the batch. `413` splits it into two halves. The halves need storage. With `storage.backend: "none"`, a `413` loses the batch. A `413` to an exit request also loses it. A JSON body `{"maxBytes": n}` goes only into the `transport.batch_split` diagnostic. `429` and `503` throttle, with `Retry-After`. `408` and `5xx` retry. With a `headers` function, `401` and `403` get one more send with new headers. Each other `4xx` drops the batch.
|
|
367
|
+
- Expose `Retry-After`, `X-UiObs-Sampling` and `Date` with `Access-Control-Expose-Headers`.
|
|
368
|
+
- The replay endpoint is a separate URL. It gets one JSON `POST` for each segment, with the batch id `<replay.id>-<sequence>` and only the `replay.headers`.
|
|
369
|
+
- Check a server with `pnpm dlx @utk09/ui-observability doctor https://ingest.example/v1/logs --origin https://app.example`.
|
|
370
|
+
|
|
371
|
+
## Common mistakes
|
|
372
|
+
|
|
373
|
+
- Do not import a peer by name to give it to the library. Give a loader: `() => import("web-vitals")`.
|
|
374
|
+
- Do not import a subpath, for example `@utk09/ui-observability/react` or a file in `dist/`. The package exports `.` only.
|
|
375
|
+
- Do not use `enabled: false` to stop the library or to withdraw consent. It is a pause, and the records go out after `enabled: true`. At a consent withdrawal, call `shutdown({ pending: "discard", clearStorage: "context" })`. Call `configure()` again only after the user agrees.
|
|
376
|
+
- Do not call `configure()` in a component body or an effect. Call it one time at module top level.
|
|
377
|
+
- Do not use `configure({ headers: null })` or `headers: undefined` at logout. With isolation on, the first is refused, and the second keeps the token. Use `rotateSecurityContext()` or `shutdown()` with `clearStorage`.
|
|
378
|
+
- Do not use `0` for "no limit". Use `null`. Do not use `""` to turn off an endpoint. Use `null`.
|
|
379
|
+
- Do not load child frames before the parent calls `configure()` and registers them.
|
|
380
|
+
- Do not log through the library in `onDrop`.
|
|
381
|
+
- Do not put a user id or a full URL in a metric attribute. Each value makes a new series.
|
|
382
|
+
- Do not expect `flush()` to reject. Check the counts of its result.
|
|
383
|
+
- Do not load two versions of the library on one page. A copy of another version runs console-only and reports `runtime.version_mismatch`. Use one module format in one app.
|
|
384
|
+
- Do not use the names that 1.0.0 removed. `logMetric` is `gauge`, `counter` or `histogram`. `timeSync` and `timeAsync` are `measure`, but `measure()` does not log the error. Catch the error and log it to keep the old ERROR record. `getStats()` is `(await getHealth()).delivery`. `getQueueDepth()` is `(await getHealth()).delivery.stored`. `clearPersistedLogs(scope)` is `shutdown({ pending: "discard", clearStorage: scope })`. Then call `configure()` again. `setContextMap(values)` is `setContext(values)`. `startTrace()` is `newTrace()`. The type `OneLogger` is `Logger`. The key `console` is `consoleOutput`. `capturePolicy` is `captureLimits`. `persistence` goes into `storage`.
|
|
385
|
+
|
|
386
|
+
## Reference documents
|
|
387
|
+
|
|
388
|
+
- [README](https://github.com/utk09-NCL/ui-observability/blob/main/README.md): install, quick start and the common recipes.
|
|
389
|
+
- [API Reference](https://github.com/utk09-NCL/ui-observability/blob/main/docs/api.md): each function, the delivery health, the flush result and the shutdown options.
|
|
390
|
+
- [Configuration Options](https://github.com/utk09-NCL/ui-observability/blob/main/docs/configuration.md): each key, its default and its rules.
|
|
391
|
+
- [Guides](https://github.com/utk09-NCL/ui-observability/blob/main/docs/guides.md): console output, custom transport, worker transport, testing and remote sampling.
|
|
392
|
+
- [Production recipes](https://github.com/utk09-NCL/ui-observability/blob/main/docs/production-recipes.md): login, logout, tenant rotation, token refresh and consent withdrawal.
|
|
393
|
+
- [Ingest Server Requirements](https://github.com/utk09-NCL/ui-observability/blob/main/docs/ingest-server.md): the full ingest contract and the `doctor` tool.
|
|
394
|
+
- [Migration to 1.0.0](https://github.com/utk09-NCL/ui-observability/blob/main/docs/migration-v1.md): each change from 0.12.x.
|
|
395
|
+
- [Delivery guarantees](https://github.com/utk09-NCL/ui-observability/blob/main/docs/delivery-guarantees.md): duplicates, order and each loss reason.
|
|
396
|
+
- [Attribute reference](https://github.com/utk09-NCL/ui-observability/blob/main/docs/attributes.md): each attribute that the library writes.
|
|
397
|
+
- [Browser support](https://github.com/utk09-NCL/ui-observability/blob/main/docs/browser-support.md): the browser APIs and the fallback for each.
|
|
398
|
+
- [Threat model](https://github.com/utk09-NCL/ui-observability/blob/main/docs/threat-model.md): the trust boundaries and the controls.
|
|
399
|
+
- [Release and support](https://github.com/utk09-NCL/ui-observability/blob/main/docs/release-and-support.md): the stable API contract.
|
|
400
|
+
- [React example](https://github.com/utk09-NCL/ui-observability/blob/main/playground/react/src/observability/react.tsx): an error boundary, a provider and hooks.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utk09/ui-observability",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "UI observability and logging for browser, OpenFin and webview applications",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -28,8 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"type": "module",
|
|
30
30
|
"sideEffects": false,
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"devEngines": {
|
|
32
|
+
"runtime": {
|
|
33
|
+
"name": "node",
|
|
34
|
+
"version": ">=22.22.3",
|
|
35
|
+
"onFail": "error"
|
|
36
|
+
}
|
|
33
37
|
},
|
|
34
38
|
"bin": {
|
|
35
39
|
"uiobs": "bin/uiobs.mjs"
|
|
@@ -37,29 +41,73 @@
|
|
|
37
41
|
"files": [
|
|
38
42
|
"dist",
|
|
39
43
|
"bin",
|
|
40
|
-
"CHANGELOG.md"
|
|
44
|
+
"CHANGELOG.md",
|
|
45
|
+
"llms.txt"
|
|
41
46
|
],
|
|
42
47
|
"main": "./dist/index.cjs",
|
|
43
48
|
"module": "./dist/index.js",
|
|
44
49
|
"types": "./dist/index.d.ts",
|
|
45
50
|
"exports": {
|
|
46
51
|
".": {
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
"import": {
|
|
53
|
+
"types": "./dist/index.d.ts",
|
|
54
|
+
"default": "./dist/index.js"
|
|
55
|
+
},
|
|
56
|
+
"require": {
|
|
57
|
+
"types": "./dist/index.d.cts",
|
|
58
|
+
"default": "./dist/index.cjs"
|
|
59
|
+
}
|
|
50
60
|
},
|
|
51
61
|
"./package.json": "./package.json"
|
|
52
62
|
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@opentelemetry/api": "^1",
|
|
65
|
+
"@rrweb/record": "^2",
|
|
66
|
+
"web-vitals": "^4 || ^5 || ^6"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@opentelemetry/api": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"@rrweb/record": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"web-vitals": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@eslint/js": "10.0.1",
|
|
81
|
+
"@opentelemetry/api": "1.10.0",
|
|
82
|
+
"@playwright/test": "1.58.2",
|
|
83
|
+
"@types/node": "26.6.6",
|
|
84
|
+
"@vitest/coverage-istanbul": "5.1.0",
|
|
85
|
+
"concurrently": "10.0.7",
|
|
86
|
+
"eslint": "10.15.0",
|
|
87
|
+
"eslint-config-prettier": "10.1.8",
|
|
88
|
+
"fake-indexeddb": "6.2.8",
|
|
89
|
+
"happy-dom": "21.0.4",
|
|
90
|
+
"prettier": "3.10.1",
|
|
91
|
+
"rimraf": "6.1.4",
|
|
92
|
+
"typescript": "6.0.3",
|
|
93
|
+
"typescript-eslint": "8.72.2",
|
|
94
|
+
"vite": "8.3.8",
|
|
95
|
+
"vitest": "5.1.0",
|
|
96
|
+
"web-vitals": "6.2.3",
|
|
97
|
+
"ws": "8.22.1"
|
|
98
|
+
},
|
|
53
99
|
"scripts": {
|
|
54
100
|
"dev": "concurrently -k \"pnpm run dev:vanilla\" \"pnpm run dev:ingest\" \"pnpm run dev:cross-origin\"",
|
|
55
101
|
"dev:vanilla": "pnpm --filter @example/vanilla run dev",
|
|
56
102
|
"dev:ingest": "node tools/mock-ingest-server.mjs",
|
|
103
|
+
"dev:app-api": "node tools/mock-app-api.mjs",
|
|
57
104
|
"dev:cross-origin": "vite --config vite.cross-origin.config.ts",
|
|
58
|
-
"example:react": "pnpm --filter @example/react run dev",
|
|
105
|
+
"example:react": "concurrently -k \"pnpm --filter @example/react run dev\" \"pnpm run dev:ingest\" \"pnpm run dev:app-api\" \"pnpm run dev:cross-origin\"",
|
|
106
|
+
"example:react-custom-backend": "concurrently -k \"pnpm --filter @example/react-custom-backend run dev\" \"pnpm run dev:ingest\" \"pnpm run dev:app-api\"",
|
|
59
107
|
"example:angular": "pnpm --filter @example/angular run dev",
|
|
60
108
|
"example:microfrontend": "concurrently -k \"pnpm --filter @example/mf-blotter run dev\" \"pnpm --filter @example/mf-ticket run dev\" \"pnpm --filter @example/mf-host run dev\"",
|
|
61
109
|
"example:console-only": "pnpm --filter @example/console-only run dev",
|
|
62
|
-
"build": "rimraf dist && tsc --project tsconfig.build.json && vite build",
|
|
110
|
+
"build": "rimraf dist && tsc --project tsconfig.build.json && node tools/finish-declarations.mjs && vite build",
|
|
63
111
|
"build:watch": "vite build --watch",
|
|
64
112
|
"lint": "eslint .",
|
|
65
113
|
"lint:fix": "eslint . --fix",
|
|
@@ -68,48 +116,16 @@
|
|
|
68
116
|
"test": "vitest run",
|
|
69
117
|
"test:watch": "vitest",
|
|
70
118
|
"test:coverage": "vitest run --coverage",
|
|
119
|
+
"test:e2e": "playwright test --config e2e/playwright.config.ts",
|
|
120
|
+
"test:playground": "playwright test --config e2e/playground/playwright.config.ts",
|
|
121
|
+
"test:collector": "node tools/check-collector.mjs",
|
|
122
|
+
"bench:release": "node tools/bench-release.mjs",
|
|
71
123
|
"typecheck": "tsc --noEmit",
|
|
72
124
|
"check:peers": "node tools/check-peer-imports.mjs",
|
|
73
125
|
"check:size": "node tools/check-size.mjs",
|
|
74
126
|
"check:dev": "node tools/check-dev-server.mjs",
|
|
75
|
-
"
|
|
127
|
+
"check:consumers": "node tools/check-consumers.mjs",
|
|
76
128
|
"fix": "pnpm run lint:fix && pnpm run format",
|
|
77
|
-
"verify": "pnpm run format:check && pnpm run typecheck && pnpm run build && pnpm run lint && pnpm run check:peers && pnpm run check:size && pnpm run check:dev && pnpm run test:coverage"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"peerDependencies": {
|
|
81
|
-
"@opentelemetry/api": "^1",
|
|
82
|
-
"@rrweb/record": "^2",
|
|
83
|
-
"web-vitals": "^4 || ^5 || ^6"
|
|
84
|
-
},
|
|
85
|
-
"peerDependenciesMeta": {
|
|
86
|
-
"@opentelemetry/api": {
|
|
87
|
-
"optional": true
|
|
88
|
-
},
|
|
89
|
-
"@rrweb/record": {
|
|
90
|
-
"optional": true
|
|
91
|
-
},
|
|
92
|
-
"web-vitals": {
|
|
93
|
-
"optional": true
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"devDependencies": {
|
|
97
|
-
"@eslint/js": "catalog:library",
|
|
98
|
-
"@opentelemetry/api": "catalog:library",
|
|
99
|
-
"@types/node": "catalog:library",
|
|
100
|
-
"@vitest/coverage-istanbul": "catalog:library",
|
|
101
|
-
"concurrently": "catalog:library",
|
|
102
|
-
"eslint": "catalog:library",
|
|
103
|
-
"eslint-config-prettier": "catalog:library",
|
|
104
|
-
"fake-indexeddb": "catalog:library",
|
|
105
|
-
"happy-dom": "catalog:library",
|
|
106
|
-
"prettier": "catalog:library",
|
|
107
|
-
"rimraf": "catalog:library",
|
|
108
|
-
"typescript": "catalog:library",
|
|
109
|
-
"typescript-eslint": "catalog:library",
|
|
110
|
-
"vite": "catalog:library",
|
|
111
|
-
"vitest": "catalog:library",
|
|
112
|
-
"web-vitals": "catalog:library"
|
|
113
|
-
},
|
|
114
|
-
"packageManager": "pnpm@12.21.0"
|
|
115
|
-
}
|
|
129
|
+
"verify": "pnpm run format:check && pnpm run typecheck && pnpm run build && pnpm run lint && pnpm run check:peers && pnpm run check:size && pnpm run check:dev && pnpm run check:consumers && pnpm run test:coverage"
|
|
130
|
+
}
|
|
131
|
+
}
|
package/dist/bus-D_7pd7RN.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./constants-DakMxVB2.cjs"),t=require("./journey-DAGh5h9k.cjs"),n=require("./remote-rules-CJD3ToVk.cjs"),r=require("./log-record-D7bA1RPb.cjs"),i=require("./openfin-DtH2f7zX.cjs"),a=require("./fixed-window-CvESpFYV.cjs"),o=require("./unref-CU9Nyz_9.cjs");function s(t){if(typeof t!=`object`||!t)return!1;let n=t;if(typeof n.from!=`string`||!n.from||typeof n.t!=`string`)return!1;let i=e=>typeof n[e]==`string`;switch(n.t){case e.M.hello:case e.M.tab:return i(`tabId`);case e.M.welcome:return i(`to`)&&i(`tabId`)&&(n.routingContextId===void 0||i(`routingContextId`));case e.M.journeyRequest:case e.M.samplingRequest:return!0;case e.M.securityContext:return i(`id`)&&n.id!==``;case e.M.journey:return(n.to===void 0||i(`to`))&&`journey`in n;case e.M.sampling:return i(`to`)&&`rules`in n;case e.M.records:return Array.isArray(n.records)&&(n.routingContextId===void 0||i(`routingContextId`))&&n.records.every(t=>!r.n(t)||!r.t(t.severityText)?!1:!Array.isArray(t.attributes)&&!Array.isArray(t.resource)&&/^\d+$/.test(t.timeUnixNano)&&(t.observedTimeUnixNano===void 0||/^\d+$/.test(t.observedTimeUnixNano))&&typeof t.traceId==`string`&&/^(?:[a-f\d]{32})?$/.test(t.traceId)&&typeof t.spanId==`string`&&/^(?:[a-f\d]{16})?$/.test(t.spanId)&&Number.isInteger(t.traceFlags)&&t.traceFlags>=0&&t.traceFlags<=255&&t.severityNumber===e.Mn[t.severityText]);default:return!1}}function c(t){return{p:e.j,m:t}}function l(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.p!==`ui-observability/2`||typeof t.m!=`object`||t.m===null)return null;let n=t.m;return typeof n.t==`string`?n:null}var u=Symbol.for(e.Cn),d=`null`;function f(e,t){return e===d?`The bus ignored ${t} from a sandboxed frame. The frame has an opaque origin. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.`:`The bus ignored ${t} from ${e}. If you own this origin, add it to bus.trustedOrigins.`}function p(){let e=location.ancestorOrigins;if(e&&e.length>0)return e.item(0);let t=document.referrer;if(t===``)return null;try{return new URL(t).origin}catch{return null}}function m(e,t){if(typeof window>`u`||window.parent===window)return null;let n;try{n=window.parent[u]}catch{return null}if(typeof n?.busAccept!=`function`||n.busCanAccept&&!n.busCanAccept(window,location.origin))return null;let r=n,i=!0;return{kind:`direct`,post(n){i&&t.guard(`bus.send_failed`,`The direct call into the parent runtime failed.`,()=>{r.busAccept(n,e,window)})},close(){i=!1}}}function h(e,t,n){if(typeof window>`u`||window.parent===window)return null;let r=location.origin;if(r===d)return n.report(`bus.untrusted_origin`,`This frame is sandboxed without allow-same-origin. It has an opaque origin. No parent can trust it. This context sends its own records. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.`,{origin:r,type:`parent`}),null;let i=new Set([r,...t]),a=p();if(a===null||!i.has(a))return n.report(`bus.untrusted_origin`,a===null?`The origin of the parent frame is unknown. This context sends its own records.`:`The parent frame is on ${a}. This origin is not in bus.trustedOrigins. This context sends its own records.`,{origin:a??``,type:`parent`}),null;let o=new Set,s=t=>{let r=l(t.data);r&&t.source===window.parent&&(i.has(t.origin)?e(r,{link:`parent`,origin:t.origin,peer:t.source}):o.has(t.origin)||(o.add(t.origin),n.report(`bus.untrusted_origin`,f(t.origin,`a message`),{origin:t.origin,type:r.t.slice(0,48)})))};return addEventListener(`message`,s),{kind:`parent`,post(e){n.guard(`bus.send_failed`,`The postMessage call to the parent failed.`,()=>{window.parent.postMessage(c(e),a)})},close(){removeEventListener(`message`,s)}}}function g(e,t,n,r,i){if(typeof window>`u`)return null;let a=new Set([location.origin,...t]);a.delete(d);let o=new Map,s=(e,t,a)=>{if(r&&!r(e,t)){o.delete(e);return}if(i&&!i(a,e))return;let s=e;s.closed?o.delete(e):n.guard(`bus.send_failed`,`The postMessage call to a child frame failed.`,()=>{s.postMessage(c(a),t)})},u=t=>{let i=l(t.data);if(!i||window.parent!==window&&t.source===window.parent)return;if(!r&&!a.has(t.origin)){n.report(`bus.untrusted_origin`,f(t.origin,`a message`),{origin:t.origin,type:i.t.slice(0,48)});return}if(r&&!r(t.source,t.origin))return;let{source:c,origin:u}=t;c&&o.set(c,u),e(i,{link:`children`,origin:u,peer:c??void 0,reply:c?e=>{s(c,u,e)}:void 0})};return addEventListener(`message`,u),{kind:`children`,post(e){for(let[t,n]of o)s(t,n,e)},close(){removeEventListener(`message`,u),o.clear()}}}function _(e,t,n){let r=globalThis.BroadcastChannel;if(r===void 0)return null;let i=n.guard(`bus.send_failed`,`The library could not open the BroadcastChannel.`,()=>new r(e));return i?(i.onmessage=e=>{let n=l(e.data);n&&t(n,{link:`broadcast`,origin:`same-origin`})},{kind:`broadcast`,post(e){n.guard(`bus.send_failed`,`The BroadcastChannel.postMessage call failed.`,()=>{i.postMessage(c(e))})},close(){n.guard(`bus.send_failed`,`The library could not close the BroadcastChannel.`,()=>{i.close()})}}):null}function v(e,t,n,r){let a=i.t()?.InterApplicationBus;if(!a)return null;if(!t)return r.report(`openfin.unavailable`,`OpenFin gives no application uuid. The InterApplicationBus link stays closed.`),null;let o=`${e}.${t}`;return r.guardAsync(`bus.send_failed`,`The InterApplicationBus.subscribe call failed.`,()=>a.subscribe({uuid:t},o,(e,t,r)=>{let i=l(e);i&&n(i,{link:`openfin`,origin:`openfin`,peer:t&&r?`${t}:${r}`:void 0})})),{kind:`openfin`,post(e){r.guardAsync(`bus.send_failed`,`The InterApplicationBus.publish call failed.`,()=>a.publish(o,c(e)))},close(){}}}function y(e,t){let n=globalThis,r=n.postMessage;return n.WorkerGlobalScope===void 0||!r?null:(n.addEventListener?.(`message`,t=>{let n=l(t.data);n&&e(n,{link:`owner`,origin:`same-origin`})}),{kind:`owner`,post(e){t.guard(`bus.send_failed`,`The postMessage call of the worker failed.`,()=>{r(c(e))})},close(){}})}function b(e,t,n){let r=n=>{let r=l(n.data);r&&t(r,{link:`worker`,origin:`same-origin`,peer:e})};return e.addEventListener(`message`,r),e.start?.(),{kind:`worker`,post(t){n.guard(`bus.send_failed`,`The postMessage call to a worker failed.`,()=>{e.postMessage(c(t))})},close(){e.removeEventListener(`message`,r)}}}var x={timeoutMs:e.k,maxAttempts:3},S=[`children`,`direct`,`worker`],C=class{config;diagnostics;platform;contextId;tabId;handlers;handshakeOptions;sources=new Map;rates=new WeakMap;channelRates=new Map;directReplies=new Map;mayPost(t,n){let r=this.sources.get(n)?.permissions;return r?t.t===e.M.journey?r.includes(`journey:read`):t.t===e.M.journeyRequest?r.includes(`journey:write`):t.t!==e.M.sampling||r.includes(`sampling:read`):this.config.bus.sourcePolicy===`trusted-origin`}registerFrame(e,t){let n=typeof HTMLIFrameElement>`u`?void 0:HTMLIFrameElement,r=n&&e instanceof n?e.contentWindow:e;if(!r||new URL(t.origin).origin!==t.origin||t.origin===`null`)throw Error(`A frame registration requires a window and an exact origin.`);let i={...t,permissions:[...t.permissions??[`records`]]};return this.sources.set(r,i),this.ensureChildrenLink(),()=>{this.sources.get(r)===i&&this.sources.delete(r)}}isRegistered(e,t){if(!e)return!1;let n=this.sources.get(e);return n?n.origin===t:this.config.bus.sourcePolicy!==`registered`&&t!==`null`&&(t===location.origin||this.config.bus.trustedOrigins.includes(t))}rotateContext(){this.passContext(this.role===`sender`)}passContext(t){let n={t:e.M.securityContext,from:this.contextId,id:this.config.securityContext.id};this.postOver(`children`,n),this.postOver(`worker`,n),this.postToDirectChildren(n),t&&this.postOver(`openfin`,n)}postToDirectChildren(e){for(let[t,n]of this.directReplies){let r=n.deref();!r||t.closed||!this.isRegistered(t,location.origin)?this.directReplies.delete(t):this.diagnostics.guard(`bus.send_failed`,`The reply to a direct child failed.`,()=>{r(e,{link:`direct`,origin:`same-origin`,peer:t})})}}keepDirectReply(e,t){for(let e of this.directReplies.keys())e.closed&&this.directReplies.delete(e);this.directReplies.set(e,new WeakRef(t))}role=`sender`;upstream=null;links=[];openFinLink=null;isOpenFinProvider=!1;rulesPoll;destroyed=!1;ownerId=null;ownerPeer;awaitingWelcome=null;constructor(e,t,n,r,i,a,o=x){this.config=e,this.diagnostics=t,this.platform=n,this.contextId=r,this.tabId=i,this.handlers=a,this.handshakeOptions=o}getRole(){return this.role}async start(){let{bus:e}=this.config;if(e.mode===`off`)return this.role=`sender`,this.role;if(this.isOpenFinProvider=this.resolveOpenFinProvider(),e.mode===`sender`||e.mode===`forwarder`)return this.role=e.mode,this.openControlLinks(),this.role===`forwarder`&&(this.upstream=this.candidateUpstream(),this.upstream||this.diagnostics.report(`bus.no_owner`,`bus.mode is "forwarder". No owner exists. The library drops the records of this context.`)),this.announce(),this.role;this.openControlLinks();let t=m(this.receive,this.diagnostics);if(t)return this.role=`forwarder`,this.upstream=t,await this.handshake(t),this.diagnostics.report(`bus.role_resolved`,`This context attached directly to the runtime of its same-origin parent.`,{role:`forwarder`,via:`direct`}),this.announce(),this.role;let n=this.candidateUpstream();if(!n)return this.role=`sender`,this.diagnostics.report(`bus.role_resolved`,`No owner exists. This context sends its own records.`,{role:`sender`}),this.announce(),this.role;let r=this.orphanPolicy()===`retry`?this.handshakeOptions.maxAttempts:1,i=!1;for(let e=0;e<r&&!i;e++)i=await this.handshake(n);return this.role=i?`forwarder`:`sender`,this.upstream=i?n:null,i||(n!==this.openFinLink&&n.close(),this.diagnostics.report(`bus.handshake_timeout`,`No owner answered after ${String(r)} attempt(s) of ${String(this.handshakeOptions.timeoutMs)} ms. This context becomes the sender.`,{via:n.kind,crossOrigin:this.isCrossOriginFrame()})),this.diagnostics.report(`bus.role_resolved`,`The bus role is ${this.role}.`,{role:this.role,via:i?n.kind:`none`}),this.announce(),this.role}sendRecords(t){let{maxRecordsPerMessage:n,maxMessageBytes:r}=this.config.bus,i=new TextEncoder,a=e=>r?i.encode(JSON.stringify(e)).length:0,o=t=>({t:e.M.records,from:this.contextId,records:t,routingContextId:this.config.securityContext.id||void 0}),s=a(o([])),c=[],l=s;for(let e of t){let t=a(e);if(r&&s+t>r){this.diagnostics.count(`bus.rejected_message`);continue}let i=+(c.length>0);(n&&c.length>=n||r&&l+i+t>r)&&(this.upstream?.post(o(c)),c=[],l=s),l+=+(c.length>0)+t,c.push(e)}c.length>0&&this.upstream?.post(o(c))}acceptDirect(t,n,r){let i={link:`direct`,origin:`same-origin`,peer:r},a={...i,reply:e=>{n(e,i)}};this.acceptsMessage(t,a,!0)&&t.from!==this.contextId&&(r&&this.keepDirectReply(r,n),t.t===e.M.samplingRequest?n(this.rulesAnswer(t.from),i):(t.t===e.M.records&&!this.awaitingWelcome&&t.routingContextId!==this.config.securityContext.id&&n({t:e.M.securityContext,from:this.contextId,id:this.config.securityContext.id},i),this.routeMessage(t,a)))}attachWorker(e,t={}){let n={...t,permissions:[...t.permissions??[`records`]]};this.sources.set(e,n);let r=b(e,this.receive,this.diagnostics),i={...r,post:t=>{this.mayPost(t,e)&&r.post(t)}};return this.links.push(i),()=>{i.close();let t=this.links.indexOf(i);t>=0&&this.links.splice(t,1),this.sources.get(e)===n&&this.sources.delete(e)}}broadcastJourney(t){this.postJourney({t:e.M.journey,from:this.contextId,journey:t})}destroy(){this.sources.clear(),this.directReplies.clear(),this.destroyed=!0,clearInterval(this.rulesPoll),this.rulesPoll=void 0;for(let e of this.allLinks())e.close();this.links.length=0,this.upstream=null,this.ownerId=null,this.openFinLink=null}allLinks(){return!this.upstream||this.links.includes(this.upstream)?this.links:[...this.links,this.upstream]}postOver(e,t){for(let n of this.allLinks())n.kind===e&&n.post(t)}postJourney(e){for(let t of this.allLinks())this.journeyLink(t.kind)&&t.post(e)}receive=(e,t)=>{let n=t.link===`children`||t.link===`worker`;this.acceptsMessage(e,t,n)&&this.routeMessage(e,t)};acceptsMessage(e,t,n){if(this.destroyed)return!1;let r;try{r=this.passesChecks(e,t,n)}catch{r=!1}return r||this.diagnostics.count(`bus.rejected_message`),r}passesChecks(t,n,r){let{bus:i}=this.config,o=typeof n.peer==`object`?this.sources.get(n.peer):void 0;if(r&&i.sourcePolicy===`registered`&&!o)return!1;let c=typeof n.peer==`object`?n.peer:void 0,l=typeof n.peer==`string`?n.peer:n.link,u=Date.now(),d=(c?this.rates.get(c):this.channelRates.get(l))??{start:u,count:0};if(c)this.rates.set(c,d);else{for(let[e,t]of this.channelRates)a.n(t,1e3,u)&&this.channelRates.delete(e);if(i.maxTrackedSources&&this.channelRates.size>=i.maxTrackedSources&&!this.channelRates.has(l))return!1;this.channelRates.set(l,d)}if(!a.t(d,i.maxMessagesPerSecond||1/0,1e3))return!1;let f=JSON.stringify(t,(e,t)=>{if(i.validation===`strict`&&typeof t==`number`&&!Number.isFinite(t))throw Error(`Non-finite value`);return t});if(i.maxMessageBytes&&new TextEncoder().encode(f).length>i.maxMessageBytes||i.validation===`strict`&&!s(t)||t.t===e.M.records&&i.maxRecordsPerMessage&&t.records.length>i.maxRecordsPerMessage)return!1;if(o){let n=t.t===e.M.records?`records`:t.t===e.M.journey?`journey:write`:t.t===e.M.journeyRequest?`journey:read`:t.t===e.M.samplingRequest?`sampling:read`:void 0;if(n&&!o.permissions?.includes(n))return!1}return r&&(t.t===e.M.sampling||t.t===e.M.securityContext)?!1:i.sourcePolicy!==`registered`||n.link!==`broadcast`||t.t!==e.M.records}routeMessage(t,n){if(t.from!==this.contextId)switch(t.t){case e.M.hello:this.canOwn(n.link)&&this.answer(n,{t:e.M.welcome,from:this.contextId,to:t.from,tabId:this.tabId,routingContextId:this.awaitingWelcome?void 0:this.config.securityContext.id||void 0});break;case e.M.welcome:if(t.to!==this.contextId)break;if(this.awaitingWelcome?.link===n.link||this.upstream?.kind===n.link&&this.ownerId===null){this.ownerId=t.from,this.ownerPeer=n.peer;let e=this.config.securityContext.id;if(t.routingContextId&&this.handlers.onSecurityContext?.(t.routingContextId)===!1)break;this.config.securityContext.id!==e&&this.passContext(!1),this.awaitingWelcome?.settle(!0)}break;case e.M.records:if(this.config.securityContext.isolation&&this.config.securityContext.id&&t.routingContextId!==this.config.securityContext.id){this.diagnostics.count(`security.context_mismatch`);break}this.role===`sender`?this.handlers.onRecords(t.records):this.upstream&&this.canRelay(n.link)&&this.upstream.post(t);break;case e.M.securityContext:n.link===this.upstream?.kind&&this.ownerId===t.from&&this.ownerPeer===n.peer&&this.handlers.onSecurityContext?.(t.id)!==!1&&this.rotateContext();break;case e.M.journey:this.acceptsJourney(t,n)&&this.applyJourney(t.journey);break;case e.M.journeyRequest:{let r=this.handlers.onJourneyRequest();r&&this.journeyLink(n.link)&&this.answer(n,{t:e.M.journey,from:this.contextId,to:t.from,journey:r});break}case e.M.samplingRequest:(this.role===`forwarder`?n.link!==this.upstream?.kind:this.canOwn(n.link))&&this.answer(n,this.rulesAnswer(t.from));break;case e.M.sampling:this.acceptsRules(t.to,n)&&this.applyRules(t.rules);break;case e.M.tab:n.link===`broadcast`&&t.tabId===this.tabId&&this.contextId>t.from&&this.handlers.onTabConflict()}}answer(e,t){e.reply?e.reply(t):this.postOver(e.link,t)}canRelay(e){return e===`direct`||e!==this.upstream?.kind}canOwn(e){return this.role!==`sender`&&this.ownerId===null?!1:e===`openfin`?this.role===`sender`&&this.isOpenFinProvider:S.includes(e)}resolveOpenFinProvider(){let e=this.config.bus.openFinRole;if(e!==`auto`)return e===`provider`;if(this.platform.platform!==`openfin`&&this.platform.platform!==`openfin_web`)return!1;let t=i.t()?.me;return!t?.identity||t.isView?!1:!!(t.identity.name&&t.identity.name===t.identity.uuid)}orphanPolicy(){return this.isCrossOriginFrame()?`retry`:`promote`}isCrossOriginFrame(){if(typeof window>`u`||window.parent===window)return!1;try{return Reflect.get(window.parent,`location`),!1}catch{return!0}}candidateUpstream(){return this.platform.isWorker?y(this.receive,this.diagnostics):this.platform.isTopLevelDocument?this.platform.platform===`openfin`&&!this.isOpenFinProvider?this.ensureOpenFinLink():null:h(this.receive,this.config.bus.trustedOrigins,this.diagnostics)}openControlLinks(){let t=e=>{e&&this.links.push(e)};this.platform.isWorker||this.ensureChildrenLink(),this.platform.isTopLevelDocument&&t(_(e.O,this.receive,this.diagnostics)),(this.platform.platform===`openfin`||this.platform.platform===`openfin_web`)&&t(this.ensureOpenFinLink())}ensureChildrenLink(){if(this.links.some(e=>e.kind===`children`))return;let e=g(this.receive,this.config.bus.trustedOrigins,this.diagnostics,(e,t)=>{let n=this.isRegistered(e,t);if(!n){this.diagnostics.count(`bus.rejected_message`);let n=e!==null&&this.sources.has(e),r=t===location.origin||this.config.bus.trustedOrigins.includes(t);(n||!r)&&this.diagnostics.report(`bus.untrusted_origin`,`The bus rejected a message from an untrusted origin.`)}return n},(e,t)=>this.mayPost(e,t));e&&this.links.push(e)}ensureOpenFinLink(){return this.openFinLink??=v(e.O,this.platform.openfinUuid,this.receive,this.diagnostics),this.openFinLink}handshake(t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,this.awaitingWelcome=null,clearTimeout(a),n(e))};this.awaitingWelcome={link:t.kind,settle:i};let a=setTimeout(()=>{i(!1)},this.handshakeOptions.timeoutMs);o.t(a),t.post({t:e.M.hello,from:this.contextId,tabId:this.tabId})})}announce(){this.postOver(`broadcast`,{t:e.M.tab,from:this.contextId,tabId:this.tabId}),this.upstream&&this.ownerId===null&&this.upstream.post({t:e.M.hello,from:this.contextId,tabId:this.tabId}),this.postJourney({t:e.M.journeyRequest,from:this.contextId}),this.pollRules(),this.passContext(!1)}journeyScope(){let{scope:e}=this.config.journey;if(e!==`auto`)return e;let{platform:t}=this.platform;return t===`openfin`||t===`openfin_web`?`origin`:`tab`}journeyLink(e){let t=this.journeyScope();return t===`context`?!1:t===`origin`||e!==`broadcast`}acceptsJourney(e,t){return!this.journeyLink(t.link)||e.to!==void 0&&e.to!==this.contextId?!1:this.journeyScope()===`origin`||this.fromOwner(e.from,t.link)&&(this.ownerPeer===void 0||this.ownerPeer===t.peer)}fromOwner(e,t){return this.role!==`forwarder`||t!==this.upstream?.kind?!1:this.ownerId===null||e===this.ownerId}applyJourney(e){if(e===null){this.handlers.onJourney(null);return}let n=t.r(e);n===null?this.diagnostics.report(`record.dropped_malformed`,`The bus dropped a journey message. Its payload is not a journey.`,{type:`journey`}):this.handlers.onJourney(n)}rulesAnswer(t){let n=this.handlers.remote.sampling?.wire()??null;return{t:e.M.sampling,from:this.contextId,to:t,rules:n}}acceptsRules(e,t){if(this.role!==`forwarder`||e!==this.contextId||t.link!==this.upstream?.kind)return!1;let{origin:n}=t;return t.link===`parent`&&n!==location.origin&&!this.config.bus.trustedOrigins.includes(n)?(this.diagnostics.report(`bus.untrusted_origin`,`The bus ignored sampling rules from ${n}. If you own this origin, add it to bus.trustedOrigins.`,{origin:n,type:`sampling`}),!1):this.ownerPeer===void 0||this.ownerPeer===t.peer}applyRules(e){if(e===null){n.t(this.handlers.remote,this.config,null);return}let t=n.n(e,this.diagnostics);t&&n.t(this.handlers.remote,this.config,t)}pollRules(){let{upstream:t}=this;if(this.destroyed||this.role!==`forwarder`||!t)return;let n=()=>{this.config.sampling.remote&&t.post({t:e.M.samplingRequest,from:this.contextId})};n(),this.rulesPoll=setInterval(n,e.an),o.t(this.rulesPoll)}};exports.Bus=C;
|
|
2
|
-
//# sourceMappingURL=bus-D_7pd7RN.cjs.map
|