@utk09/ui-observability 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -1
- package/README.md +323 -113
- package/bin/uiobs.mjs +1 -1
- package/dist/{batch-BMdT9mKm.js → batch-BjQUwjA6.js} +5 -6
- package/dist/batch-BjQUwjA6.js.map +1 -0
- package/dist/{batch-BHXypM1j.cjs → batch-D5LlU4Q9.cjs} +2 -2
- package/dist/batch-D5LlU4Q9.cjs.map +1 -0
- package/dist/bus/bus.d.ts +48 -47
- package/dist/bus/links.d.ts +4 -4
- package/dist/bus/validation.d.ts +1 -1
- package/dist/bus-D_7pd7RN.cjs +2 -0
- package/dist/bus-D_7pd7RN.cjs.map +1 -0
- package/dist/{bus-DKfBaica.js → bus-ecxUNTja.js} +105 -109
- package/dist/bus-ecxUNTja.js.map +1 -0
- package/dist/capture/console.d.ts +10 -10
- package/dist/capture/errors.d.ts +6 -6
- package/dist/capture/interactions.d.ts +14 -14
- package/dist/capture/lifecycle.d.ts +3 -3
- package/dist/capture/long-frames.d.ts +6 -6
- package/dist/capture/network.d.ts +17 -17
- package/dist/capture/profiler-frames.d.ts +44 -0
- package/dist/capture/replay-buffer.d.ts +46 -0
- package/dist/capture/replay-upload.d.ts +74 -0
- package/dist/capture/replay.d.ts +114 -0
- package/dist/capture/reports.d.ts +2 -2
- package/dist/capture/resource-timing.d.ts +1 -1
- package/dist/capture/server-timing.d.ts +3 -3
- package/dist/capture/storm.d.ts +3 -3
- package/dist/capture/types.d.ts +45 -33
- package/dist/capture/unclean-exit.d.ts +8 -8
- package/dist/capture/user-timing.d.ts +3 -3
- package/dist/capture/web-socket.d.ts +11 -11
- package/dist/capture/web-vitals.d.ts +20 -7
- package/dist/compression-AJJCMBOa.js +11 -0
- package/dist/compression-AJJCMBOa.js.map +1 -0
- package/dist/compression-lD9abCcO.cjs +2 -0
- package/dist/compression-lD9abCcO.cjs.map +1 -0
- package/dist/console-CLz_PvFn.cjs +2 -0
- package/dist/console-CLz_PvFn.cjs.map +1 -0
- package/dist/{console-BX_0UCV7.js → console-cwgHKXvM.js} +14 -15
- package/dist/console-cwgHKXvM.js.map +1 -0
- package/dist/constants-Bwl_YtQi.js +349 -0
- package/dist/constants-Bwl_YtQi.js.map +1 -0
- package/dist/constants-DakMxVB2.cjs +2 -0
- package/dist/constants-DakMxVB2.cjs.map +1 -0
- package/dist/constants.d.ts +150 -103
- package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
- package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
- package/dist/context-storage-BzkoHzkQ.js.map +1 -0
- package/dist/core/breadcrumbs.d.ts +16 -15
- package/dist/core/config.d.ts +3 -3
- package/dist/core/context.d.ts +7 -7
- package/dist/core/debug-buffer.d.ts +10 -10
- package/dist/core/debug-bundle.d.ts +3 -3
- package/dist/core/deferred.d.ts +2 -2
- package/dist/core/diagnostics.d.ts +24 -21
- package/dist/core/drops.d.ts +7 -7
- package/dist/core/hold-buffer.d.ts +1 -1
- package/dist/core/journey.d.ts +22 -23
- package/dist/core/logger.d.ts +22 -21
- package/dist/core/measure.d.ts +7 -7
- package/dist/core/meter.d.ts +25 -21
- package/dist/core/pipeline.d.ts +42 -41
- package/dist/core/profile-buckets.d.ts +31 -0
- package/dist/core/profiler.d.ts +218 -0
- package/dist/core/record.d.ts +23 -23
- package/dist/core/remote-rules.d.ts +4 -4
- package/dist/core/remote-sampling.d.ts +21 -20
- package/dist/core/runtime.d.ts +206 -137
- package/dist/core/sampling.d.ts +18 -18
- package/dist/core/sender.d.ts +22 -20
- package/dist/core/spans.d.ts +5 -5
- package/dist/{deadline-5_PecIl5.js → deadline-C4ccAuk5.js} +4 -9
- package/dist/deadline-C4ccAuk5.js.map +1 -0
- package/dist/deadline-CUGbto-y.cjs +2 -0
- package/dist/deadline-CUGbto-y.cjs.map +1 -0
- package/dist/{debug-bundle-CZZ6SQQh.js → debug-bundle-BOdYmCeV.js} +12 -6
- package/dist/debug-bundle-BOdYmCeV.js.map +1 -0
- package/dist/debug-bundle-Ex4L_LSP.cjs +2 -0
- package/dist/debug-bundle-Ex4L_LSP.cjs.map +1 -0
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.cjs.map +1 -1
- package/dist/doctor.d.ts +16 -6
- package/dist/doctor.js +148 -54
- package/dist/doctor.js.map +1 -1
- package/dist/{emergency-queue-Cs8-i2xw.js → emergency-queue-B9WZxanZ.js} +15 -17
- package/dist/emergency-queue-B9WZxanZ.js.map +1 -0
- package/dist/{emergency-queue-CQ-9acZf.cjs → emergency-queue-HBpL5r3V.cjs} +2 -2
- package/dist/emergency-queue-HBpL5r3V.cjs.map +1 -0
- package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
- package/dist/error-like-B11pB4aL.js.map +1 -0
- package/dist/error-like-gGRx2s36.cjs.map +1 -1
- package/dist/{errors-oyxrpHjY.js → errors-D6bwgJtO.js} +5 -6
- package/dist/errors-D6bwgJtO.js.map +1 -0
- package/dist/{errors-CigX45pL.cjs → errors-DCOCRdSi.cjs} +2 -2
- package/dist/errors-DCOCRdSi.cjs.map +1 -0
- package/dist/{factory-BkjNzPYL.cjs → factory-DLFDjdLv.cjs} +2 -2
- package/dist/factory-DLFDjdLv.cjs.map +1 -0
- package/dist/{factory-Bgsky_e0.js → factory-e9Qo3K0z.js} +18 -22
- package/dist/factory-e9Qo3K0z.js.map +1 -0
- package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
- package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
- package/dist/fixed-window-Dq3MLUUv.js.map +1 -0
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
- package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
- package/dist/global-scope-D9I8s-oN.js.map +1 -0
- package/dist/{guards-CpvOpJL6.js → guards-Cidk71ME.js} +2 -3
- package/dist/guards-Cidk71ME.js.map +1 -0
- package/dist/guards-nJ70syPt.cjs.map +1 -1
- package/dist/{identity-BMlKGHUM.cjs → identity-BlvlgjrU.cjs} +2 -2
- package/dist/identity-BlvlgjrU.cjs.map +1 -0
- package/dist/{identity-DOaHdfhT.js → identity-BrQp_5J5.js} +20 -21
- package/dist/identity-BrQp_5J5.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +112 -79
- package/dist/index.js +797 -659
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-CaXGJqDD.cjs → indexeddb-storage-CtLvZH1r.cjs} +2 -2
- package/dist/indexeddb-storage-CtLvZH1r.cjs.map +1 -0
- package/dist/{indexeddb-storage-D-lUW_5P.js → indexeddb-storage-DLXQzAGh.js} +5 -6
- package/dist/indexeddb-storage-DLXQzAGh.js.map +1 -0
- package/dist/{interactions-CqDNrtIR.js → interactions-B6z2I4tU.js} +10 -11
- package/dist/interactions-B6z2I4tU.js.map +1 -0
- package/dist/{interactions-8DgxtmgO.cjs → interactions-P6pz08Jn.cjs} +2 -2
- package/dist/interactions-P6pz08Jn.cjs.map +1 -0
- package/dist/{journey-DgIjhrIc.js → journey-35yCMNFo.js} +21 -21
- package/dist/journey-35yCMNFo.js.map +1 -0
- package/dist/journey-DAGh5h9k.cjs +2 -0
- package/dist/journey-DAGh5h9k.cjs.map +1 -0
- package/dist/keys-BHhw_0Wh.cjs.map +1 -1
- package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
- package/dist/keys-BU9j5YqW.js.map +1 -0
- package/dist/{library-console-g_VU-wzP.cjs → library-console-BFWEuQsl.cjs} +2 -2
- package/dist/library-console-BFWEuQsl.cjs.map +1 -0
- package/dist/library-console-Dl_Ly6DQ.js +13 -0
- package/dist/library-console-Dl_Ly6DQ.js.map +1 -0
- package/dist/{library-request-FQaiWjCP.cjs → library-request-Da-CHKzT.cjs} +2 -2
- package/dist/library-request-Da-CHKzT.cjs.map +1 -0
- package/dist/{library-request-CyC-9IOk.js → library-request-nI6pvI6I.js} +4 -5
- package/dist/library-request-nI6pvI6I.js.map +1 -0
- package/dist/{lifecycle-C2z_d8OX.cjs → lifecycle-BGGOcN4N.cjs} +2 -2
- package/dist/lifecycle-BGGOcN4N.cjs.map +1 -0
- package/dist/{lifecycle-BLC4VU7c.js → lifecycle-CZ6RRXc6.js} +3 -4
- package/dist/lifecycle-CZ6RRXc6.js.map +1 -0
- package/dist/{log-record-DKvo-B-d.cjs → log-record-D7bA1RPb.cjs} +2 -2
- package/dist/log-record-D7bA1RPb.cjs.map +1 -0
- package/dist/{log-record-CndanC-p.js → log-record-DIA6McNr.js} +3 -4
- package/dist/log-record-DIA6McNr.js.map +1 -0
- package/dist/{long-frames-BQef9rXR.js → long-frames-430_85Da.js} +9 -8
- package/dist/long-frames-430_85Da.js.map +1 -0
- package/dist/long-frames-Dd8tsi2U.cjs +2 -0
- package/dist/long-frames-Dd8tsi2U.cjs.map +1 -0
- package/dist/models/batch.d.ts +14 -15
- package/dist/models/bus.d.ts +24 -24
- package/dist/models/config.d.ts +402 -216
- package/dist/models/drop.d.ts +13 -11
- package/dist/models/health.d.ts +13 -13
- package/dist/models/log-record.d.ts +13 -14
- package/dist/models/metric.d.ts +82 -17
- package/dist/models/plugin.d.ts +13 -13
- package/dist/models/replay.d.ts +60 -0
- package/dist/models/serializer.d.ts +2 -3
- package/dist/models/stats.d.ts +2 -2
- package/dist/models/storage.d.ts +12 -11
- package/dist/{network-CvkvYzRU.js → network-C7SkLf4v.js} +30 -32
- package/dist/network-C7SkLf4v.js.map +1 -0
- package/dist/{network-CqnQOqon.cjs → network-pEX3PAJv.cjs} +2 -2
- package/dist/network-pEX3PAJv.cjs.map +1 -0
- package/dist/openfin-Bxelt0yg.js +7 -0
- package/dist/openfin-Bxelt0yg.js.map +1 -0
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/otlp-2MCrC3kd.cjs +2 -0
- package/dist/otlp-2MCrC3kd.cjs.map +1 -0
- package/dist/{otlp-CYIL7MOE.js → otlp-COq033e3.js} +26 -35
- package/dist/otlp-COq033e3.js.map +1 -0
- package/dist/patch-BX8KrPCT.cjs.map +1 -1
- package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
- package/dist/patch-UdPz1ea8.js.map +1 -0
- package/dist/{platform-KMWkoI-v.cjs → platform-12uR7kBQ.cjs} +2 -2
- package/dist/platform-12uR7kBQ.cjs.map +1 -0
- package/dist/{platform-wcAkkv9F.js → platform-CVewe4wQ.js} +9 -10
- package/dist/platform-CVewe4wQ.js.map +1 -0
- package/dist/profiler-BVWIOgnq.js +310 -0
- package/dist/profiler-BVWIOgnq.js.map +1 -0
- package/dist/profiler-eVCknCzS.cjs +2 -0
- package/dist/profiler-eVCknCzS.cjs.map +1 -0
- package/dist/profiler-frames-CLXlT_xL.js +86 -0
- package/dist/profiler-frames-CLXlT_xL.js.map +1 -0
- package/dist/profiler-frames-Dg2OebB2.cjs +2 -0
- package/dist/profiler-frames-Dg2OebB2.cjs.map +1 -0
- package/dist/{remote-rules-CH_7PphT.js → remote-rules-BJGDJGwA.js} +29 -30
- package/dist/remote-rules-BJGDJGwA.js.map +1 -0
- package/dist/{remote-rules-BL8km4xk.cjs → remote-rules-CJD3ToVk.cjs} +2 -2
- package/dist/remote-rules-CJD3ToVk.cjs.map +1 -0
- package/dist/replay-0zAJv9T3.js +338 -0
- package/dist/replay-0zAJv9T3.js.map +1 -0
- package/dist/replay-DomJpXqW.cjs +2 -0
- package/dist/replay-DomJpXqW.cjs.map +1 -0
- package/dist/{reports-Bh_-KpZ2.cjs → reports-BsbqmP8h.cjs} +2 -2
- package/dist/reports-BsbqmP8h.cjs.map +1 -0
- package/dist/{reports-BOKyY3_A.js → reports-BuXekPOS.js} +4 -5
- package/dist/reports-BuXekPOS.js.map +1 -0
- package/dist/{resource-timing-BROnEJ0E.js → resource-timing-CXGHwFRD.js} +6 -7
- package/dist/resource-timing-CXGHwFRD.js.map +1 -0
- package/dist/{resource-timing-CbgwNpog.cjs → resource-timing-DkycFGDa.cjs} +2 -2
- package/dist/resource-timing-DkycFGDa.cjs.map +1 -0
- package/dist/{sampling-ECGVYiDD.cjs → sampling-Dd0wllyq.cjs} +2 -2
- package/dist/sampling-Dd0wllyq.cjs.map +1 -0
- package/dist/{sampling-BLO_pcV4.js → sampling-UUDbi3K0.js} +11 -12
- package/dist/sampling-UUDbi3K0.js.map +1 -0
- package/dist/{sanitize-DS0G4_ea.js → sanitize-CNmsD9r3.js} +4 -5
- package/dist/sanitize-CNmsD9r3.js.map +1 -0
- package/dist/{sanitize-Bsn8HQWC.cjs → sanitize-ChLn97Ch.cjs} +2 -2
- package/dist/sanitize-ChLn97Ch.cjs.map +1 -0
- package/dist/{select-DWO0-w8_.cjs → select-CTk-K5mG.cjs} +3 -3
- package/dist/select-CTk-K5mG.cjs.map +1 -0
- package/dist/{select-wqt9Wxio.js → select-DPv_j6wq.js} +64 -67
- package/dist/select-DPv_j6wq.js.map +1 -0
- package/dist/{sender-BkAVt-Rq.js → sender-15zEsZpr.js} +98 -101
- package/dist/sender-15zEsZpr.js.map +1 -0
- package/dist/sender-Bfpv9tad.cjs +2 -0
- package/dist/sender-Bfpv9tad.cjs.map +1 -0
- package/dist/storage/context-storage.d.ts +34 -33
- package/dist/storage/emergency-queue.d.ts +9 -9
- package/dist/storage/eviction.d.ts +12 -12
- package/dist/storage/factory.d.ts +8 -7
- package/dist/storage/gap.d.ts +6 -6
- package/dist/storage/idb-driver.d.ts +31 -32
- package/dist/storage/indexeddb-storage.d.ts +26 -27
- package/dist/storage/keys.d.ts +7 -7
- package/dist/storage/local-storage.d.ts +38 -38
- package/dist/storage/memory-storage.d.ts +21 -22
- package/dist/storage/persistence.d.ts +1 -1
- package/dist/storage-BA9RqRO-.cjs.map +1 -1
- package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
- package/dist/storage-DZwed89z.js.map +1 -0
- package/dist/{storm-DD4cUkoL.js → storm-BTSNTIWI.js} +4 -5
- package/dist/storm-BTSNTIWI.js.map +1 -0
- package/dist/{storm-DCEsqViG.cjs → storm-D0_qZOEg.cjs} +2 -2
- package/dist/storm-D0_qZOEg.cjs.map +1 -0
- package/dist/transport/compression.d.ts +2 -2
- package/dist/transport/errors.d.ts +7 -7
- package/dist/transport/exit-flush.d.ts +39 -39
- package/dist/transport/headers.d.ts +2 -2
- package/dist/transport/http-transport.d.ts +28 -27
- package/dist/transport/memory-transport.d.ts +6 -6
- package/dist/transport/retry-engine.d.ts +35 -34
- package/dist/transport/serializers/ecs.d.ts +1 -1
- package/dist/transport/serializers/otlp-metrics.d.ts +1 -1
- package/dist/transport/serializers/otlp-traces.d.ts +1 -1
- package/dist/transport/serializers/otlp.d.ts +16 -16
- package/dist/transport/serializers/select.d.ts +7 -7
- package/dist/transport/status-transport.d.ts +20 -20
- package/dist/transport/worker-protocol.d.ts +3 -3
- package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
- package/dist/types-BAerHgCq.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-CwdpbUDg.cjs → unclean-exit-ClGzrc2A.cjs} +2 -2
- package/dist/unclean-exit-ClGzrc2A.cjs.map +1 -0
- package/dist/{unclean-exit-BYZ5yaSI.js → unclean-exit-Cob_jyTv.js} +3 -4
- package/dist/unclean-exit-Cob_jyTv.js.map +1 -0
- package/dist/unref-CU9Nyz_9.cjs +2 -0
- package/dist/unref-CU9Nyz_9.cjs.map +1 -0
- package/dist/unref-DgHPQeWv.js +7 -0
- package/dist/unref-DgHPQeWv.js.map +1 -0
- package/dist/user-timing-CdYqx3PF.cjs +2 -0
- package/dist/user-timing-CdYqx3PF.cjs.map +1 -0
- package/dist/{user-timing-Di2ra5DB.js → user-timing-DgHubxCI.js} +7 -6
- package/dist/user-timing-DgHubxCI.js.map +1 -0
- package/dist/utils/console.d.ts +2 -2
- package/dist/utils/deadline.d.ts +4 -4
- package/dist/utils/error-like.d.ts +7 -7
- package/dist/utils/fixed-window.d.ts +9 -8
- package/dist/utils/global-scope.d.ts +8 -8
- package/dist/utils/guards.d.ts +2 -2
- package/dist/utils/identity.d.ts +17 -17
- package/dist/utils/library-console.d.ts +4 -4
- package/dist/utils/library-request.d.ts +10 -10
- package/dist/utils/lock.d.ts +10 -9
- package/dist/utils/openfin.d.ts +5 -5
- package/dist/utils/patch.d.ts +6 -6
- package/dist/utils/platform.d.ts +13 -11
- package/dist/utils/sanitize.d.ts +4 -4
- package/dist/utils/timer.d.ts +1 -1
- package/dist/utils/tracing.d.ts +38 -38
- package/dist/utils/unref.d.ts +3 -3
- package/dist/{web-socket-DwBNhgre.cjs → web-socket-BTuvYoJI.cjs} +2 -2
- package/dist/web-socket-BTuvYoJI.cjs.map +1 -0
- package/dist/{web-socket-B-5qqPy7.js → web-socket-DthJuSAg.js} +14 -15
- package/dist/web-socket-DthJuSAg.js.map +1 -0
- package/dist/web-vitals-Ch5BpDmo.cjs +2 -0
- package/dist/web-vitals-Ch5BpDmo.cjs.map +1 -0
- package/dist/web-vitals-CsGCWnUr.js +77 -0
- package/dist/web-vitals-CsGCWnUr.js.map +1 -0
- package/dist/{worker-protocol-0HMf4-kY.js → worker-protocol-B0_8rWy5.js} +6 -7
- package/dist/worker-protocol-B0_8rWy5.js.map +1 -0
- package/dist/{worker-protocol-DXekoADQ.cjs → worker-protocol-BjzFORfq.cjs} +2 -2
- package/dist/worker-protocol-BjzFORfq.cjs.map +1 -0
- package/dist/worker-server-4en-Lt-3.cjs +2 -0
- package/dist/worker-server-4en-Lt-3.cjs.map +1 -0
- package/dist/{worker-server-CKcmX5m5.js → worker-server-Cne9MX9I.js} +25 -26
- package/dist/{worker-server-CKcmX5m5.js.map → worker-server-Cne9MX9I.js.map} +1 -1
- package/dist/worker-transport-B-GF4Aqn.cjs +2 -0
- package/dist/worker-transport-B-GF4Aqn.cjs.map +1 -0
- package/dist/{worker-transport-2220ghFZ.js → worker-transport-C3SjJAEC.js} +64 -65
- package/dist/worker-transport-C3SjJAEC.js.map +1 -0
- package/package.json +33 -41
- package/dist/batch-BHXypM1j.cjs.map +0 -1
- package/dist/batch-BMdT9mKm.js.map +0 -1
- package/dist/bus-DKfBaica.js.map +0 -1
- package/dist/bus-Dea9rVhy.cjs +0 -2
- package/dist/bus-Dea9rVhy.cjs.map +0 -1
- package/dist/console-BX_0UCV7.js.map +0 -1
- package/dist/console-DZEcs7FL.cjs +0 -2
- package/dist/console-DZEcs7FL.cjs.map +0 -1
- package/dist/constants-CL0ZdI2f.cjs +0 -2
- package/dist/constants-CL0ZdI2f.cjs.map +0 -1
- package/dist/constants-CU60FG4w.js +0 -305
- package/dist/constants-CU60FG4w.js.map +0 -1
- package/dist/context-storage-DxZf4Gfh.js.map +0 -1
- package/dist/deadline-5_PecIl5.js.map +0 -1
- package/dist/deadline-XSnm95pg.cjs +0 -2
- package/dist/deadline-XSnm95pg.cjs.map +0 -1
- package/dist/debug-bundle-CZZ6SQQh.js.map +0 -1
- package/dist/debug-bundle-yRkrU1ny.cjs +0 -2
- package/dist/debug-bundle-yRkrU1ny.cjs.map +0 -1
- package/dist/emergency-queue-CQ-9acZf.cjs.map +0 -1
- package/dist/emergency-queue-Cs8-i2xw.js.map +0 -1
- package/dist/error-like-Ywo5uRHo.js.map +0 -1
- package/dist/errors-CigX45pL.cjs.map +0 -1
- package/dist/errors-oyxrpHjY.js.map +0 -1
- package/dist/factory-Bgsky_e0.js.map +0 -1
- package/dist/factory-BkjNzPYL.cjs.map +0 -1
- package/dist/fixed-window-CtaFHanJ.js.map +0 -1
- package/dist/global-scope-dp2jADRl.js.map +0 -1
- package/dist/guards-CpvOpJL6.js.map +0 -1
- package/dist/identity-BMlKGHUM.cjs.map +0 -1
- package/dist/identity-DOaHdfhT.js.map +0 -1
- package/dist/indexeddb-storage-CaXGJqDD.cjs.map +0 -1
- package/dist/indexeddb-storage-D-lUW_5P.js.map +0 -1
- package/dist/interactions-8DgxtmgO.cjs.map +0 -1
- package/dist/interactions-CqDNrtIR.js.map +0 -1
- package/dist/journey-5tcxEbnG.cjs +0 -2
- package/dist/journey-5tcxEbnG.cjs.map +0 -1
- package/dist/journey-DgIjhrIc.js.map +0 -1
- package/dist/keys-D5r_GH9q.js.map +0 -1
- package/dist/library-console-CabK2j2-.js +0 -14
- package/dist/library-console-CabK2j2-.js.map +0 -1
- package/dist/library-console-g_VU-wzP.cjs.map +0 -1
- package/dist/library-request-CyC-9IOk.js.map +0 -1
- package/dist/library-request-FQaiWjCP.cjs.map +0 -1
- package/dist/lifecycle-BLC4VU7c.js.map +0 -1
- package/dist/lifecycle-C2z_d8OX.cjs.map +0 -1
- package/dist/log-record-CndanC-p.js.map +0 -1
- package/dist/log-record-DKvo-B-d.cjs.map +0 -1
- package/dist/long-frames-BQef9rXR.js.map +0 -1
- package/dist/long-frames-CV5ZG2cx.cjs +0 -2
- package/dist/long-frames-CV5ZG2cx.cjs.map +0 -1
- package/dist/network-CqnQOqon.cjs.map +0 -1
- package/dist/network-CvkvYzRU.js.map +0 -1
- package/dist/openfin-BwEN0uj4.js +0 -8
- package/dist/openfin-BwEN0uj4.js.map +0 -1
- package/dist/otlp-CYIL7MOE.js.map +0 -1
- package/dist/otlp-RVbkNQRh.cjs +0 -2
- package/dist/otlp-RVbkNQRh.cjs.map +0 -1
- package/dist/patch-CCWfuEY7.js.map +0 -1
- package/dist/platform-KMWkoI-v.cjs.map +0 -1
- package/dist/platform-wcAkkv9F.js.map +0 -1
- package/dist/remote-rules-BL8km4xk.cjs.map +0 -1
- package/dist/remote-rules-CH_7PphT.js.map +0 -1
- package/dist/reports-BOKyY3_A.js.map +0 -1
- package/dist/reports-Bh_-KpZ2.cjs.map +0 -1
- package/dist/resource-timing-BROnEJ0E.js.map +0 -1
- package/dist/resource-timing-CbgwNpog.cjs.map +0 -1
- package/dist/sampling-BLO_pcV4.js.map +0 -1
- package/dist/sampling-ECGVYiDD.cjs.map +0 -1
- package/dist/sanitize-Bsn8HQWC.cjs.map +0 -1
- package/dist/sanitize-DS0G4_ea.js.map +0 -1
- package/dist/select-DWO0-w8_.cjs.map +0 -1
- package/dist/select-wqt9Wxio.js.map +0 -1
- package/dist/sender-BkAVt-Rq.js.map +0 -1
- package/dist/sender-D82PxlCY.cjs +0 -2
- package/dist/sender-D82PxlCY.cjs.map +0 -1
- package/dist/storage-w7Tslvlq.js.map +0 -1
- package/dist/storm-DCEsqViG.cjs.map +0 -1
- package/dist/storm-DD4cUkoL.js.map +0 -1
- package/dist/types-BR9t_w28.js.map +0 -1
- package/dist/unclean-exit-BYZ5yaSI.js.map +0 -1
- package/dist/unclean-exit-CwdpbUDg.cjs.map +0 -1
- package/dist/user-timing-C1kB3JEg.cjs +0 -2
- package/dist/user-timing-C1kB3JEg.cjs.map +0 -1
- package/dist/user-timing-Di2ra5DB.js.map +0 -1
- package/dist/web-socket-B-5qqPy7.js.map +0 -1
- package/dist/web-socket-DwBNhgre.cjs.map +0 -1
- package/dist/web-vitals-Bflr5jSA.js +0 -53
- package/dist/web-vitals-Bflr5jSA.js.map +0 -1
- package/dist/web-vitals-DFuoTQbZ.cjs +0 -2
- package/dist/web-vitals-DFuoTQbZ.cjs.map +0 -1
- package/dist/worker-protocol-0HMf4-kY.js.map +0 -1
- package/dist/worker-protocol-DXekoADQ.cjs.map +0 -1
- package/dist/worker-server-BQK5z2yl.cjs +0 -2
- package/dist/worker-server-BQK5z2yl.cjs.map +0 -1
- package/dist/worker-transport-2220ghFZ.js.map +0 -1
- package/dist/worker-transport-Dj2yCQN5.cjs +0 -2
- package/dist/worker-transport-Dj2yCQN5.cjs.map +0 -1
package/dist/core/sampling.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { LogLevel, LogRecord } from "../models/log-record";
|
|
|
3
3
|
import type { RemoteRules } from "./remote-sampling";
|
|
4
4
|
/** Value of the longest prefix that matches a namespace. */
|
|
5
5
|
interface PrefixMatch<T> {
|
|
6
|
-
/**
|
|
6
|
+
/** The prefix's value, for example a rate or a level. */
|
|
7
7
|
value: T;
|
|
8
8
|
/** Length of the prefix. */
|
|
9
9
|
length: number;
|
|
@@ -17,15 +17,15 @@ interface PrefixMatch<T> {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function longestPrefix<T>(namespace: string, values: Record<string, T>): PrefixMatch<T> | undefined;
|
|
19
19
|
/**
|
|
20
|
-
* Finds
|
|
21
|
-
* `minLevels` wins
|
|
20
|
+
* Finds a namespace's minimum level in the config. The longest matching prefix in
|
|
21
|
+
* `minLevels` wins, and a namespace with no match uses `minLevel`.
|
|
22
22
|
* @param namespace Target application namespace.
|
|
23
23
|
* @param config Active configuration instance.
|
|
24
|
-
* @returns The minimum level
|
|
24
|
+
* @returns The namespace's minimum level.
|
|
25
25
|
*/
|
|
26
26
|
export declare function levelFor(namespace: string, config: ResolvedConfig): LogLevel;
|
|
27
27
|
/**
|
|
28
|
-
* Decides
|
|
28
|
+
* Decides whether sampling keeps a key at a rate. The same key always gets the same result.
|
|
29
29
|
* @param key Journey ID or trace ID.
|
|
30
30
|
* @param rate Sampling rate, 0..1.
|
|
31
31
|
* @returns True if sampling keeps the key.
|
|
@@ -39,44 +39,44 @@ export interface SampleInput {
|
|
|
39
39
|
type: string;
|
|
40
40
|
/** Originating application namespace. */
|
|
41
41
|
namespace: string;
|
|
42
|
-
/** Active journey ID.
|
|
42
|
+
/** Active journey ID. Empty when no journey is running. */
|
|
43
43
|
journeyId: string;
|
|
44
|
-
/** Trace ID.
|
|
44
|
+
/** Trace ID. Used as the sampling key when no journey is running. */
|
|
45
45
|
traceId: string;
|
|
46
|
-
/** True for a
|
|
46
|
+
/** True for a counter or histogram point. Sampling a sum would give a false sum. */
|
|
47
47
|
aggregated?: boolean;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Decides
|
|
51
|
-
*
|
|
50
|
+
* Decides whether sampling keeps an entry. Reads fields, not a record, so the caller can
|
|
51
|
+
* drop an entry before the attribute walk runs.
|
|
52
52
|
* @param input Fields the sampling decision reads.
|
|
53
53
|
* @param config Active configuration instance.
|
|
54
|
-
* @param remote
|
|
54
|
+
* @param remote Current remote rules, or null.
|
|
55
55
|
* @returns True if the runtime keeps and sends the entry.
|
|
56
56
|
*/
|
|
57
57
|
export declare function shouldSampleInput(input: SampleInput, config: ResolvedConfig, remote: RemoteRules | null): boolean;
|
|
58
58
|
/**
|
|
59
|
-
* Decides
|
|
59
|
+
* Decides whether sampling keeps a built log record. The runtime uses it for records
|
|
60
60
|
* that a child context sends over the bus.
|
|
61
61
|
* @param record Record to evaluate.
|
|
62
62
|
* @param config Active configuration instance.
|
|
63
|
-
* @param remote
|
|
63
|
+
* @param remote Current remote rules, or null.
|
|
64
64
|
* @returns True if the runtime keeps and sends the record.
|
|
65
65
|
*/
|
|
66
66
|
export declare function shouldSample(record: LogRecord, config: ResolvedConfig, remote?: RemoteRules | null): boolean;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Puts a fixed-window limit on the records that bypass sampling because of their level.
|
|
69
69
|
*
|
|
70
|
-
* ErrorCapture already limits auto-captured errors. This class
|
|
71
|
-
*
|
|
70
|
+
* ErrorCapture already limits auto-captured errors. This class covers what is left, for
|
|
71
|
+
* example application code that calls logger.error in a render loop.
|
|
72
72
|
*/
|
|
73
73
|
export declare class ErrorCeiling {
|
|
74
74
|
/** Records at or above the threshold level admitted in the current window. */
|
|
75
75
|
private readonly window;
|
|
76
76
|
/**
|
|
77
|
-
* Checks a record against the limit.
|
|
77
|
+
* Checks a record against the limit. Only records at or above `from` are counted.
|
|
78
78
|
* @param record Record about to enter a stream.
|
|
79
|
-
* @param limit Maximum records in one window.
|
|
79
|
+
* @param limit Maximum records in one window. Pass 0 for no limit.
|
|
80
80
|
* @param windowMs Rate limit window, in milliseconds.
|
|
81
81
|
* @param from Lowest level that bypasses sampling.
|
|
82
82
|
* @returns False when the window has no allowance left. The caller must drop the record.
|
package/dist/core/sender.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface SenderDeps {
|
|
|
11
11
|
/** Memory store that this runtime keeps when the security context changes. */
|
|
12
12
|
storage?: StorageAdapter;
|
|
13
13
|
onStorage?: (storage: StorageAdapter) => void;
|
|
14
|
-
/** Receives the state of the
|
|
14
|
+
/** Receives the state of the persistent-storage request. */
|
|
15
15
|
onPersistence?: (state: StoragePersistence) => void;
|
|
16
16
|
/** Active configuration instance. */
|
|
17
17
|
config: ResolvedConfig;
|
|
@@ -19,11 +19,11 @@ export interface SenderDeps {
|
|
|
19
19
|
diagnostics: Diagnostics;
|
|
20
20
|
/** Receives a report when storage drops batches before delivery. */
|
|
21
21
|
onGap: GapReporter;
|
|
22
|
-
/** Receives the records
|
|
22
|
+
/** Receives the records lost by the transport, the retry engine and the exit flush. */
|
|
23
23
|
onLoss: LossReporter;
|
|
24
|
-
/**
|
|
24
|
+
/** The runtime's slot for the sampling rules from the ingest server. */
|
|
25
25
|
remote: RemoteSlot;
|
|
26
|
-
/** Sends the
|
|
26
|
+
/** Sends the open metric interval's points before the exit flush drains the buffers. */
|
|
27
27
|
beforeExit?: () => void;
|
|
28
28
|
}
|
|
29
29
|
/** Delivery stack for one sender runtime. */
|
|
@@ -34,9 +34,9 @@ export declare class Sender {
|
|
|
34
34
|
private readonly exitFlush;
|
|
35
35
|
private readonly diagnostics;
|
|
36
36
|
private readonly transport;
|
|
37
|
-
/** True after retire()
|
|
37
|
+
/** True after retire(), so a late emergency import doesn't wake the retry engine. */
|
|
38
38
|
private retired;
|
|
39
|
-
/** Emergency queue import. retire() waits for it before
|
|
39
|
+
/** Emergency queue import. retire() waits for it before reading storage. */
|
|
40
40
|
private emergencyImport;
|
|
41
41
|
/**
|
|
42
42
|
* @param storage Storage adapter for undelivered batches.
|
|
@@ -44,12 +44,12 @@ export declare class Sender {
|
|
|
44
44
|
* @param pipeline Pipeline that batches records.
|
|
45
45
|
* @param exitFlush Handler that sends pending records on unload.
|
|
46
46
|
* @param diagnostics Diagnostics reporter.
|
|
47
|
-
* @param transport
|
|
47
|
+
* @param transport The transport that the pipeline and the retry engine use.
|
|
48
48
|
*/
|
|
49
49
|
private constructor();
|
|
50
50
|
/**
|
|
51
51
|
* Builds the delivery stack and starts the retry loop. The emergency queue import runs
|
|
52
|
-
* after the start
|
|
52
|
+
* after the start, so a slow IndexedDB open doesn't hold up the boot buffer.
|
|
53
53
|
* @param deps Configuration, diagnostics and gap reporter.
|
|
54
54
|
* @returns Promise that resolves to the started sender.
|
|
55
55
|
*/
|
|
@@ -60,8 +60,8 @@ export declare class Sender {
|
|
|
60
60
|
*/
|
|
61
61
|
push(record: LogRecord): void;
|
|
62
62
|
/**
|
|
63
|
-
* Sends the records in the stream buffers
|
|
64
|
-
* @returns Promise that resolves
|
|
63
|
+
* Sends the records in the stream buffers, then waits for every batch in flight.
|
|
64
|
+
* @returns Promise that resolves once the pipeline has sent or stored every batch.
|
|
65
65
|
*/
|
|
66
66
|
flush(): Promise<void>;
|
|
67
67
|
/**
|
|
@@ -78,37 +78,39 @@ export declare class Sender {
|
|
|
78
78
|
queueDepth(): Promise<number>;
|
|
79
79
|
/**
|
|
80
80
|
* Reads the delivery state of the pipeline and the transport.
|
|
81
|
-
* @returns
|
|
81
|
+
* @returns Waiting records, records in requests and the last accepted send.
|
|
82
82
|
*/
|
|
83
83
|
stats(): Omit<DeliveryStats, "stored">;
|
|
84
84
|
/**
|
|
85
|
-
* Sends pending records with a normal flush, then with the exit flush
|
|
86
|
-
* timers and listeners
|
|
87
|
-
*
|
|
85
|
+
* Sends pending records with a normal flush, then with the exit flush, then stops all
|
|
86
|
+
* timers and listeners and closes storage. The normal flush keeps the headers, gzip and
|
|
87
|
+
* the retry. The exit flush picks up the records the normal flush didn't confirm.
|
|
88
88
|
* @returns Promise that resolves when storage closes.
|
|
89
89
|
*/
|
|
90
90
|
destroy(): Promise<void>;
|
|
91
91
|
/**
|
|
92
|
-
* Stops this sender before a new delivery identity takes effect.
|
|
92
|
+
* Stops this sender before a new delivery identity takes effect. Does not run exit delivery.
|
|
93
93
|
* @param policy Rule for the old records.
|
|
94
94
|
* @param timeoutMs Maximum wait for a flush, in milliseconds.
|
|
95
95
|
* @param contextId Identity of the old delivery context.
|
|
96
|
-
* @returns
|
|
96
|
+
* @returns The records that were in memory and the batches that were stored, after the
|
|
97
|
+
* delivery attempt.
|
|
97
98
|
*/
|
|
98
99
|
retire(policy: "discard" | "flush" | "retain" | "carry", timeoutMs: number, contextId: string): Promise<{
|
|
99
100
|
buffered: LogRecord[];
|
|
100
101
|
stored: LogBatch[];
|
|
101
102
|
}>;
|
|
102
103
|
/**
|
|
103
|
-
* Stores
|
|
104
|
-
*
|
|
105
|
-
*
|
|
104
|
+
* Stores an earlier context's batches under this context, and the retry engine then sends
|
|
105
|
+
* them. They don't go through the live buffer, because a large backlog would exceed its
|
|
106
|
+
* budget.
|
|
107
|
+
* @param batches The earlier context's stored batches.
|
|
106
108
|
* @param contextId Identity of this delivery context.
|
|
107
109
|
* @returns Promise that resolves when the batches are stored.
|
|
108
110
|
*/
|
|
109
111
|
adopt(batches: readonly LogBatch[], contextId: string): Promise<void>;
|
|
110
112
|
/**
|
|
111
|
-
* Moves the
|
|
113
|
+
* Moves the emergency queue's batches into storage, then wakes the retry engine.
|
|
112
114
|
* The previous page load parked them during its unload.
|
|
113
115
|
*/
|
|
114
116
|
private importEmergency;
|
package/dist/core/spans.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EndedTrace } from "../utils/tracing";
|
|
2
|
-
/** One span
|
|
2
|
+
/** One span recorded by the runtime. */
|
|
3
3
|
export interface SpanData {
|
|
4
4
|
/** Span name. */
|
|
5
5
|
name: string;
|
|
@@ -9,7 +9,7 @@ export interface SpanData {
|
|
|
9
9
|
traceId: string;
|
|
10
10
|
/** Span ID. */
|
|
11
11
|
spanId: string;
|
|
12
|
-
/**
|
|
12
|
+
/** The parent's span ID, or "" for a root span. */
|
|
13
13
|
parentSpanId: string;
|
|
14
14
|
/** Start time in epoch milliseconds. */
|
|
15
15
|
startMs: number;
|
|
@@ -17,7 +17,7 @@ export interface SpanData {
|
|
|
17
17
|
endMs: number;
|
|
18
18
|
/** True for a failed operation. */
|
|
19
19
|
error: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** The span's attributes. */
|
|
21
21
|
attributes: Record<string, unknown>;
|
|
22
22
|
/** Server span linked through a response traceparent entry. */
|
|
23
23
|
link?: {
|
|
@@ -26,13 +26,13 @@ export interface SpanData {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Builds the root span
|
|
29
|
+
* Builds the root span for an ambient trace that has ended.
|
|
30
30
|
* @param ended The trace.
|
|
31
31
|
* @returns The span data.
|
|
32
32
|
*/
|
|
33
33
|
export declare function rootSpan(ended: EndedTrace): SpanData;
|
|
34
34
|
/**
|
|
35
|
-
* Builds the span fields
|
|
35
|
+
* Builds the span fields for a span record. The record limits don't trim them.
|
|
36
36
|
* @param span The span data.
|
|
37
37
|
* @returns The fields.
|
|
38
38
|
*/
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
typeof e != "number" && e.unref?.();
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/utils/deadline.ts
|
|
1
|
+
import { t as e } from "./unref-DgHPQeWv.js";
|
|
2
|
+
// src/utils/deadline.ts
|
|
7
3
|
var t = class extends Error {
|
|
8
4
|
constructor(e) {
|
|
9
5
|
super(`The operation took longer than ${String(e)} ms.`), this.name = "DeadlineError";
|
|
@@ -20,7 +16,6 @@ function n(n, r) {
|
|
|
20
16
|
clearTimeout(i);
|
|
21
17
|
});
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
export { n, e as r, t };
|
|
19
|
+
export { n, t };
|
|
25
20
|
|
|
26
|
-
//# sourceMappingURL=deadline-
|
|
21
|
+
//# sourceMappingURL=deadline-C4ccAuk5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline-C4ccAuk5.js","names":["unrefTimer","DeadlineError","ms","withDeadline","expire","deadline","timer","work"],"sources":["../src/utils/deadline.ts"],"sourcesContent":["// src/utils/deadline.ts\n//\n// Puts a deadline on a promise that could stay pending. A pending promise raises no\n// diagnostics event, so without a deadline its caller waits forever and keeps its slot.\n\nimport { unrefTimer } from \"./unref\";\n\n/** The error for a promise that didn't settle before its deadline. */\nexport class DeadlineError extends Error {\n /**\n * @param ms Deadline in milliseconds.\n */\n constructor(ms: number) {\n super(`The operation took longer than ${String(ms)} ms.`);\n this.name = \"DeadlineError\";\n }\n}\n\n/**\n * Rejects when a promise doesn't settle within a deadline.\n * @param work The promise to bound.\n * @param ms Deadline in milliseconds.\n * @returns The promise's value, or a rejection after the deadline.\n */\nexport function withDeadline<T>(work: Promise<T>, ms: number): Promise<T> {\n let expire: ReturnType<typeof setTimeout> | undefined;\n\n const deadline = new Promise<never>((_resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new DeadlineError(ms));\n }, ms);\n\n expire = timer;\n unrefTimer(timer);\n });\n\n // Clear the timer on success and on failure. Otherwise every storage call leaves an armed timer.\n return Promise.race([work, deadline]).finally(() => {\n clearTimeout(expire);\n });\n}\n"],"mappings":";;AAQA,IAAaC,IAAb,cAAmC,MAAM;CAIvC,YAAY,GAAY;EAEtB,AADA,MAAM,kCAAkC,OAAOC,CAAE,EAAE,KAAK,GACxD,KAAK,OAAO;CACd;AACF;AAQA,SAAgBC,EAAgB,GAAkB,GAAwB;CACxE,IAAIC,GAEEC,IAAW,IAAI,SAAgB,GAAU,MAAW;EACxD,IAAMC,IAAQ,iBAAiB;GAC7B,EAAO,IAAIL,EAAcC,CAAE,CAAC;EAC9B,GAAGA,CAAE;EAGL,AADA,IAASI,GACTN,EAAWM,CAAK;CAClB,CAAC;CAGD,OAAO,QAAQ,KAAK,CAACC,GAAMF,CAAQ,CAAC,CAAC,CAAC,cAAc;EAClD,aAAaD,CAAM;CACrB,CAAC;AACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./unref-CU9Nyz_9.cjs");var t=class extends Error{constructor(e){super(`The operation took longer than ${String(e)} ms.`),this.name=`DeadlineError`}};function n(n,r){let i,a=new Promise((n,a)=>{let o=setTimeout(()=>{a(new t(r))},r);i=o,e.t(o)});return Promise.race([n,a]).finally(()=>{clearTimeout(i)})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=deadline-CUGbto-y.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline-CUGbto-y.cjs","names":["require_unref","DeadlineError","ms","withDeadline","expire","deadline","timer","reject","work"],"sources":["../src/utils/deadline.ts"],"sourcesContent":["// src/utils/deadline.ts\n//\n// Puts a deadline on a promise that could stay pending. A pending promise raises no\n// diagnostics event, so without a deadline its caller waits forever and keeps its slot.\n\nimport { unrefTimer } from \"./unref\";\n\n/** The error for a promise that didn't settle before its deadline. */\nexport class DeadlineError extends Error {\n /**\n * @param ms Deadline in milliseconds.\n */\n constructor(ms: number) {\n super(`The operation took longer than ${String(ms)} ms.`);\n this.name = \"DeadlineError\";\n }\n}\n\n/**\n * Rejects when a promise doesn't settle within a deadline.\n * @param work The promise to bound.\n * @param ms Deadline in milliseconds.\n * @returns The promise's value, or a rejection after the deadline.\n */\nexport function withDeadline<T>(work: Promise<T>, ms: number): Promise<T> {\n let expire: ReturnType<typeof setTimeout> | undefined;\n\n const deadline = new Promise<never>((_resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new DeadlineError(ms));\n }, ms);\n\n expire = timer;\n unrefTimer(timer);\n });\n\n // Clear the timer on success and on failure. Otherwise every storage call leaves an armed timer.\n return Promise.race([work, deadline]).finally(() => {\n clearTimeout(expire);\n });\n}\n"],"mappings":"A,wCAQA,IAAaC,EAAb,cAAmC,KAAM,CAIvC,YAAY,EAAY,CACtB,MAAM,kCAAkC,OAAOC,CAAE,EAAE,KAAK,EACxD,KAAK,KAAO,eACd,CACF,EAQA,SAAgBC,EAAgB,EAAkB,EAAwB,CACxE,IAAIC,EAEEC,EAAW,IAAI,SAAgB,EAAU,IAAW,CACxD,IAAMC,EAAQ,eAAiB,CAC7BC,EAAO,IAAIN,EAAcC,CAAE,CAAC,CAC9B,EAAGA,CAAE,EAEL,EAASI,EACTN,EAAA,EAAWM,CAAK,CAClB,CAAC,EAGD,OAAO,QAAQ,KAAK,CAACE,EAAMH,CAAQ,CAAC,CAAC,CAAC,YAAc,CAClD,aAAaD,CAAM,CACrB,CAAC,CACH,C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as e } from "./guards-
|
|
2
|
-
import { i as t } from "./platform-
|
|
3
|
-
import { n } from "./sanitize-
|
|
4
|
-
|
|
1
|
+
import { t as e } from "./guards-Cidk71ME.js";
|
|
2
|
+
import { i as t } from "./platform-CVewe4wQ.js";
|
|
3
|
+
import { n } from "./sanitize-CNmsD9r3.js";
|
|
4
|
+
// src/core/debug-bundle.ts
|
|
5
5
|
function r(n) {
|
|
6
6
|
return typeof n == "string" ? /^[a-z][a-z\d+.-]*:\/\//i.test(n) ? t(n, !1) : n : Array.isArray(n) ? n.map(r) : e(n) ? Object.fromEntries(Object.entries(n).map(([e, t]) => [e, r(t)])) : n;
|
|
7
7
|
}
|
|
@@ -16,11 +16,17 @@ function i(e, i, a) {
|
|
|
16
16
|
...s,
|
|
17
17
|
ignoreUrls: s.ignoreUrls.map(o),
|
|
18
18
|
plugins: s.plugins.map((e) => e.name)
|
|
19
|
+
},
|
|
20
|
+
replay: {
|
|
21
|
+
...e.replay,
|
|
22
|
+
endpoint: o(e.replay.endpoint),
|
|
23
|
+
headers: e.replay.headers !== null,
|
|
24
|
+
plugins: e.replay.plugins.length,
|
|
25
|
+
recordOptions: Object.keys(e.replay.recordOptions)
|
|
19
26
|
}
|
|
20
27
|
};
|
|
21
28
|
return Reflect.deleteProperty(l, "headers"), r(n(l, i, a));
|
|
22
29
|
}
|
|
23
|
-
//#endregion
|
|
24
30
|
export { i as configSummary };
|
|
25
31
|
|
|
26
|
-
//# sourceMappingURL=debug-bundle-
|
|
32
|
+
//# sourceMappingURL=debug-bundle-BOdYmCeV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-bundle-BOdYmCeV.js","names":["isObject","recordedUrl","stripUrls","value","key","entry","configSummary","cut","config","copy","serializer","capture","plugin","sanitize","limits","diagnostics"],"sources":["../src/core/debug-bundle.ts"],"sourcesContent":["// src/core/debug-bundle.ts\n//\n// Builds the config summary for a debug bundle. The runtime loads this module only when the\n// app asks for a bundle.\n\nimport type { ResolvedConfig } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { sanitize, type SanitizeLimits } from \"../utils/sanitize\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/**\n * Strips the user info, query and fragment from every absolute URL in a JSON-safe value. The\n * endpoints also end up in `capture.ignoreUrls`, where the library puts them.\n * @param value JSON-safe value.\n * @returns The value with every URL trimmed.\n */\nfunction stripUrls(value: unknown): unknown {\n if (typeof value === \"string\") {\n return /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value) ? recordedUrl(value, false) : value;\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUrls);\n }\n\n if (isObject(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stripUrls(entry)]));\n }\n\n return value;\n}\n\n/**\n * Copies the config for a support ticket, without the headers and with every URL trimmed. A\n * function becomes its name and a RegExp its text.\n * @param config Active configuration.\n * @param limits Limits for the copy, the same as for record attributes.\n * @param diagnostics Diagnostics reporter.\n * @returns JSON-safe copy of the config.\n */\nexport function configSummary(\n config: ResolvedConfig,\n limits: SanitizeLimits,\n diagnostics: Diagnostics,\n): Record<string, unknown> {\n // A relative endpoint has no scheme, so stripUrls() doesn't see it as a URL.\n const cut = (value: unknown): unknown =>\n typeof value === \"string\" ? recordedUrl(value, false) : value;\n const { capture, serializer } = config;\n const copy: Record<string, unknown> = {\n ...config,\n endpoint: cut(config.endpoint),\n metricsEndpoint: cut(config.metricsEndpoint),\n tracesEndpoint: cut(config.tracesEndpoint),\n // An object from the app can hold a key in any field, so only its name goes out.\n serializer: typeof serializer === \"string\" ? serializer : serializer.name,\n capture: {\n ...capture,\n ignoreUrls: capture.ignoreUrls.map(cut),\n plugins: capture.plugins.map((plugin) => plugin.name),\n },\n // The replay headers can carry a token, and recordOptions is the app's own object.\n replay: {\n ...config.replay,\n endpoint: cut(config.replay.endpoint),\n headers: config.replay.headers !== null,\n plugins: config.replay.plugins.length,\n recordOptions: Object.keys(config.replay.recordOptions),\n },\n };\n // Static headers can hold a token.\n Reflect.deleteProperty(copy, \"headers\");\n\n return stripUrls(sanitize(copy, limits, diagnostics)) as Record<string, unknown>;\n}\n"],"mappings":";;;;AAiBA,SAASE,EAAU,GAAyB;CAa1C,OAZI,OAAOC,KAAU,WACZ,0BAA0B,KAAKA,CAAK,IAAIF,EAAYE,GAAO,EAAK,IAAIA,IAGzE,MAAM,QAAQA,CAAK,IACdA,EAAM,IAAID,CAAS,IAGxBF,EAASG,CAAK,IACT,OAAO,YAAY,OAAO,QAAQA,CAAK,CAAC,CAAC,KAAK,CAACC,GAAKC,OAAW,CAACD,GAAKF,EAAUG,CAAK,CAAC,CAAC,CAAC,IAGzFF;AACT;AAUA,SAAgBG,EACd,GACA,GACA,GACyB;CAEzB,IAAMC,KAAO,MACX,OAAOJ,KAAU,WAAWF,EAAYE,GAAO,EAAK,IAAIA,GACpD,EAAE,YAAS,kBAAeK,GAC1BC,IAAgC;EACpC,GAAGD;EACH,UAAUD,EAAIC,EAAO,QAAQ;EAC7B,iBAAiBD,EAAIC,EAAO,eAAe;EAC3C,gBAAgBD,EAAIC,EAAO,cAAc;EAEzC,YAAY,OAAOE,KAAe,WAAWA,IAAaA,EAAW;EACrE,SAAS;GACP,GAAGC;GACH,YAAYA,EAAQ,WAAW,IAAIJ,CAAG;GACtC,SAASI,EAAQ,QAAQ,KAAK,MAAWC,EAAO,IAAI;EACtD;EAEA,QAAQ;GACN,GAAGJ,EAAO;GACV,UAAUD,EAAIC,EAAO,OAAO,QAAQ;GACpC,SAASA,EAAO,OAAO,YAAY;GACnC,SAASA,EAAO,OAAO,QAAQ;GAC/B,eAAe,OAAO,KAAKA,EAAO,OAAO,aAAa;EACxD;CACF;CAIA,OAFA,QAAQ,eAAeC,GAAM,SAAS,GAE/BP,EAAUW,EAASJ,GAAMK,GAAQC,CAAW,CAAC;AACtD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./guards-nJ70syPt.cjs"),t=require("./platform-12uR7kBQ.cjs"),n=require("./sanitize-ChLn97Ch.cjs");function r(n){return typeof n==`string`?/^[a-z][a-z\d+.-]*:\/\//i.test(n)?t.i(n,!1):n:Array.isArray(n)?n.map(r):e.t(n)?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,r(t)])):n}function i(e,i,a){let o=e=>typeof e==`string`?t.i(e,!1):e,{capture:s,serializer:c}=e,l={...e,endpoint:o(e.endpoint),metricsEndpoint:o(e.metricsEndpoint),tracesEndpoint:o(e.tracesEndpoint),serializer:typeof c==`string`?c:c.name,capture:{...s,ignoreUrls:s.ignoreUrls.map(o),plugins:s.plugins.map(e=>e.name)},replay:{...e.replay,endpoint:o(e.replay.endpoint),headers:e.replay.headers!==null,plugins:e.replay.plugins.length,recordOptions:Object.keys(e.replay.recordOptions)}};return Reflect.deleteProperty(l,`headers`),r(n.n(l,i,a))}exports.configSummary=i;
|
|
2
|
+
//# sourceMappingURL=debug-bundle-Ex4L_LSP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-bundle-Ex4L_LSP.cjs","names":["recordedUrl","isObject","sanitize","require_guards","require_platform","require_sanitize","stripUrls","value","key","entry","configSummary","cut","config","copy","serializer","capture","plugin","limits","diagnostics"],"sources":["../src/core/debug-bundle.ts"],"sourcesContent":["// src/core/debug-bundle.ts\n//\n// Builds the config summary for a debug bundle. The runtime loads this module only when the\n// app asks for a bundle.\n\nimport type { ResolvedConfig } from \"../models/config\";\nimport { isObject } from \"../utils/guards\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { sanitize, type SanitizeLimits } from \"../utils/sanitize\";\nimport type { Diagnostics } from \"./diagnostics\";\n\n/**\n * Strips the user info, query and fragment from every absolute URL in a JSON-safe value. The\n * endpoints also end up in `capture.ignoreUrls`, where the library puts them.\n * @param value JSON-safe value.\n * @returns The value with every URL trimmed.\n */\nfunction stripUrls(value: unknown): unknown {\n if (typeof value === \"string\") {\n return /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value) ? recordedUrl(value, false) : value;\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUrls);\n }\n\n if (isObject(value)) {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, stripUrls(entry)]));\n }\n\n return value;\n}\n\n/**\n * Copies the config for a support ticket, without the headers and with every URL trimmed. A\n * function becomes its name and a RegExp its text.\n * @param config Active configuration.\n * @param limits Limits for the copy, the same as for record attributes.\n * @param diagnostics Diagnostics reporter.\n * @returns JSON-safe copy of the config.\n */\nexport function configSummary(\n config: ResolvedConfig,\n limits: SanitizeLimits,\n diagnostics: Diagnostics,\n): Record<string, unknown> {\n // A relative endpoint has no scheme, so stripUrls() doesn't see it as a URL.\n const cut = (value: unknown): unknown =>\n typeof value === \"string\" ? recordedUrl(value, false) : value;\n const { capture, serializer } = config;\n const copy: Record<string, unknown> = {\n ...config,\n endpoint: cut(config.endpoint),\n metricsEndpoint: cut(config.metricsEndpoint),\n tracesEndpoint: cut(config.tracesEndpoint),\n // An object from the app can hold a key in any field, so only its name goes out.\n serializer: typeof serializer === \"string\" ? serializer : serializer.name,\n capture: {\n ...capture,\n ignoreUrls: capture.ignoreUrls.map(cut),\n plugins: capture.plugins.map((plugin) => plugin.name),\n },\n // The replay headers can carry a token, and recordOptions is the app's own object.\n replay: {\n ...config.replay,\n endpoint: cut(config.replay.endpoint),\n headers: config.replay.headers !== null,\n plugins: config.replay.plugins.length,\n recordOptions: Object.keys(config.replay.recordOptions),\n },\n };\n // Static headers can hold a token.\n Reflect.deleteProperty(copy, \"headers\");\n\n return stripUrls(sanitize(copy, limits, diagnostics)) as Record<string, unknown>;\n}\n"],"mappings":"A,mHAiBA,SAASM,EAAU,EAAyB,CAa1C,OAZI,OAAOC,GAAU,SACZ,0BAA0B,KAAKA,CAAK,EAAIP,EAAAA,EAAYO,EAAO,EAAK,EAAIA,EAGzE,MAAM,QAAQA,CAAK,EACdA,EAAM,IAAID,CAAS,EAGxBL,EAAAA,EAASM,CAAK,EACT,OAAO,YAAY,OAAO,QAAQA,CAAK,CAAC,CAAC,KAAK,CAACC,EAAKC,KAAW,CAACD,EAAKF,EAAUG,CAAK,CAAC,CAAC,CAAC,EAGzFF,CACT,CAUA,SAAgBG,EACd,EACA,EACA,EACyB,CAEzB,IAAMC,EAAO,GACX,OAAOJ,GAAU,SAAWP,EAAAA,EAAYO,EAAO,EAAK,EAAIA,EACpD,CAAE,UAAS,cAAeK,EAC1BC,EAAgC,CACpC,GAAGD,EACH,SAAUD,EAAIC,EAAO,QAAQ,EAC7B,gBAAiBD,EAAIC,EAAO,eAAe,EAC3C,eAAgBD,EAAIC,EAAO,cAAc,EAEzC,WAAY,OAAOE,GAAe,SAAWA,EAAaA,EAAW,KACrE,QAAS,CACP,GAAGC,EACH,WAAYA,EAAQ,WAAW,IAAIJ,CAAG,EACtC,QAASI,EAAQ,QAAQ,IAAK,GAAWC,EAAO,IAAI,CACtD,EAEA,OAAQ,CACN,GAAGJ,EAAO,OACV,SAAUD,EAAIC,EAAO,OAAO,QAAQ,EACpC,QAASA,EAAO,OAAO,UAAY,KACnC,QAASA,EAAO,OAAO,QAAQ,OAC/B,cAAe,OAAO,KAAKA,EAAO,OAAO,aAAa,CACxD,CACF,EAIA,OAFA,QAAQ,eAAeC,EAAM,SAAS,EAE/BP,EAAUJ,EAAAA,EAASW,EAAMI,EAAQC,CAAW,CAAC,CACtD,C"}
|
package/dist/doctor.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-DakMxVB2.cjs"),t=require("./compression-lD9abCcO.cjs"),n=require("./otlp-2MCrC3kd.cjs");var r=1e4,i=0,a=1,o=2,s=`Usage: uiobs doctor <url> --origin <origin> [--replay] [--header "Name: value"]. An origin has no path and no trailing slash. With --replay, the URL is a replay endpoint.`,c=`--header`,l=`--replay`,u=5e6,d=5,f=`uiobs-doctor`,p=/^([\w!#$%&'*+.^`|~-]+): *([\x20-\x7e]+)$/,m=`<hidden>`,h=`Access-Control-Expose-Headers`,g=[e.lt,e.ct,e.st,e.ot].map(e=>e.toLowerCase()),_=[...g,`origin`],v=[e.ft,e.ut].map(e=>e.toLowerCase());function y(){let t=crypto.randomUUID().replaceAll(`-`,``);return{timeUnixNano:`${String(Date.now())}000000`,traceId:t,spanId:t.slice(0,16),traceFlags:1,severityNumber:e.Mn.INFO,severityText:`INFO`,body:`uiobs doctor test record`,attributes:{},resource:{"service.name":f}}}async function b(e,t,n=r){try{return await fetch(e,{...t,redirect:`manual`,signal:AbortSignal.timeout(n)})}catch(e){let t=e instanceof Error?e.cause??e:e;return`The request failed. ${t instanceof Error?t.message:String(t)}`}}function x(e,t,n){let r=(e.headers.get(t)??``).toLowerCase().split(`,`).map(e=>e.trim());return r.includes(`*`)?[]:n.filter(e=>!r.includes(e))}var S=e=>e.ok?void 0:`The server returned ${String(e.status)}.`;function C(e,t,n,...r){let i=typeof t==`string`?t:r.map(e=>e(t)).find(e=>e!==void 0);return{rule:e,pass:i===void 0,detail:i??n}}function w(e,t,n){let r=Object.keys(n).map(e=>e.toLowerCase());return{url:e,origin:t,custom:n,requestHeaders:[...g,...r]}}function T(e){return t=>{let n=t.headers.get(`Access-Control-Allow-Origin`);return n===e||n===`*`?void 0:`Access-Control-Allow-Origin is ${String(n)}. It must allow ${e}.`}}function E({url:e,origin:t,requestHeaders:n}){return b(e,{method:`OPTIONS`,headers:{Origin:t,"Access-Control-Request-Method":`POST`,"Access-Control-Request-Headers":n.join(`, `)}})}function D(e,t){return[C(`preflight`,e,`The server permits POST from this origin.`,S,T(t.origin)),C(`allowed headers`,e,`The server allows each request header of the library.`,e=>{let n=x(e,`Access-Control-Allow-Headers`,t.requestHeaders);return n.length>0?`Access-Control-Allow-Headers must include ${n.join(`, `)}.`:void 0})]}function O({url:t,origin:n,custom:r},i,a){return(o,s,c,l={})=>b(t,{method:`POST`,headers:{...r,Origin:n,[e.lt]:i,[e.st]:o,[e.ot]:String(s),...l},body:c},a)}async function k(n,r,i){let a=await t.t(i);return a?n(r,0,a,{[e.ct]:e.tt}):`This Node version has no CompressionStream.`}async function A(t,r,i={}){let a=w(t,r,i),o=T(r),s=await E(a),{body:c,contentType:l}=n.r.serialize([y()]),u=O(a,l),d=crypto.randomUUID(),f=await u(d,0,c),p=await u(d,1,c),m=await k(u,crypto.randomUUID(),c),_=new URL(t);_.searchParams.set(e.Zt,crypto.randomUUID()),_.searchParams.set(e.Qt,`pagehide`);let A=a.requestHeaders.length>g.length?void 0:await b(_.toString(),{method:`POST`,headers:{Origin:r,[e.lt]:e.B},body:c}),j=typeof f==`string`?[]:x(f,h,v),M=j.length>0?` Optional headers stay hidden: ${j.join(`, `)}.`:``;return[...D(s,a),C(`test batch`,f,`The server accepted a test batch.`,S,o),C(`exposed headers`,f,`The server exposes Retry-After.${M}`,e=>x(e,h,[`retry-after`]).length>0?`${h} must include retry-after.`:void 0),C(`gzip`,m,`The server accepted a gzip batch.`,S),C(`deduplication`,p,`The server accepted a repeated batch id. A client cannot see if it stored the batch again.`,S),A===void 0?{rule:`beacon`,pass:!0,detail:`The library sends no beacon with custom headers. The tool sent no beacon.`}:C(`beacon`,A,`The server accepted a text/plain batch.`,S)]}async function j(t,n,r={}){let i=w(t,n,r),a=T(n),o=await E(i),s=crypto.randomUUID(),c={"replay.id":s,"session.id":crypto.randomUUID(),"tab.id":crypto.randomUUID(),"service.name":f},l=(e,t)=>{let n=[{type:d,timestamp:Date.now(),data:{tag:f,payload:t}}];return JSON.stringify({...c,sequence:e,bytes:JSON.stringify(n).length,events:n})},p=e=>`${s}-${String(e)}`,m=O(i,e.R),h=l(0,`uiobs doctor test event`),g=await m(p(0),0,h),_=await m(p(0),1,h),v=await k(m,p(1),l(1,`uiobs doctor gzip event`)),y=await O(i,e.R,e.cn)(p(2),0,l(2,`x`.repeat(u)));return[...D(o,i),C(`test segment`,g,`The server accepted a test segment.`,S,a),C(`gzip`,v,`The server accepted a gzip segment.`,S),C(`large segment`,y,`The server accepted a segment of ${String(u)} bytes without gzip.`,e=>e.ok?void 0:`The server returned ${String(e.status)} for a segment of ${String(u)} bytes. The first segment of an upload has a full snapshot of the page. Raise the body limit of the server.`),C(`deduplication`,_,`The server accepted a repeated batch id. A client cannot see if it stored the segment again.`,S)]}function M(e){let t=[];for(let n=0;n<e.length;n+=2){let r=e[n]===c?p.exec(e[n+1]):null;if(!r||_.includes(r[1].toLowerCase()))return;t.push([r[1],r[2]])}return Object.fromEntries(t)}function N(e){if(!/^https?:\/\//i.test(e)||!URL.canParse(e))return!1;let{username:t,password:n}=new URL(e);return t===``&&n===``}var P=[`doctor`,`--origin`,l,c];function F(e){if(P.includes(e))return e;if(/^https?:\/\//i.test(e)&&URL.canParse(e)){let{origin:t,pathname:n}=new URL(e);return`${t}${n===`/`&&!e.endsWith(`/`)?``:n}`}return m}function I(e){return URL.canParse(e)&&new URL(e).origin===e}async function L(e,t){let[n,r,c,u,...d]=e,f=d[0]===l,p=M(f?d.slice(1):d);if(n!==`doctor`||c!==`--origin`||!N(r)||!I(u)||!p)return t(s),t(`Received: ${JSON.stringify(e.map(F))}`),o;let m=await(f?j:A)(r,u,p);for(let{rule:e,pass:n,detail:r}of m)t(`${n?`PASS`:`FAIL`} ${e}: ${r}`);return m.every(({pass:e})=>e)?i:a}exports.main=L,exports.runDoctor=A,exports.runReplayDoctor=j;
|
|
2
2
|
//# sourceMappingURL=doctor.cjs.map
|
package/dist/doctor.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.cjs","names":["HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","HEADER_DATE","SEVERITY_NUMBER","otlpSerializer","gzip","ENCODING_GZIP","require_constants","require_otlp","REQUEST_TIMEOUT_MS","EXIT_PASS","EXIT_FAIL","EXIT_USAGE","USAGE","EXPOSE_HEADERS","REQUEST_HEADERS","name","OPTIONAL_EXPOSED","testRecord","traceId","request","url","init","error","reason","absent","values","response","value","wanted","statusProblem","judge","tests","problem","answer","test","found","passed","runDoctor","originProblem","allowed","origin","preflight","post","contentType","id","attempt","extra","payload","batchId","first","body","repeated","compressed","zipped","hidden","note","missing","isHttpUrl","isOrigin","main","command","flag","args","print","results","pass","rule","detail"],"sources":["../src/doctor.ts"],"sourcesContent":["// src/doctor.ts\n//\n// Checks an ingest server against the ingest contract in the README. The `uiobs doctor` command\n// calls main(). The code uses web APIs only. The browser build replaces each \"node:\" import.\n\nimport {\n ENCODING_GZIP,\n HEADER_ATTEMPT,\n HEADER_BATCH_ID,\n HEADER_CONTENT_ENCODING,\n HEADER_CONTENT_TYPE,\n HEADER_DATE,\n HEADER_RETRY_AFTER,\n HEADER_SAMPLING,\n SEVERITY_NUMBER,\n} from \"./constants\";\nimport type { LogRecord } from \"./models/log-record\";\nimport { gzip } from \"./transport/compression\";\nimport { otlpSerializer } from \"./transport/serializers/otlp\";\n\n/** Maximum wait for one answer, in milliseconds. */\nconst REQUEST_TIMEOUT_MS = 10000;\n\n/** Exit code when each rule passes. */\nconst EXIT_PASS = 0;\n\n/** Exit code when a rule fails. */\nconst EXIT_FAIL = 1;\n\n/** Exit code of a wrong command. */\nconst EXIT_USAGE = 2;\n\n/** Text of a wrong command. */\nconst USAGE =\n \"Usage: uiobs doctor <url> --origin <origin>. An origin has no path and no trailing slash.\";\n\n/** Response header that lists the headers a page can read. */\nconst EXPOSE_HEADERS = \"Access-Control-Expose-Headers\";\n\n/** Request headers of the library. The server must allow each one. */\nconst REQUEST_HEADERS = [\n HEADER_CONTENT_TYPE,\n HEADER_CONTENT_ENCODING,\n HEADER_BATCH_ID,\n HEADER_ATTEMPT,\n].map((name) => name.toLowerCase());\n\n/** Response headers that only an optional feature reads. */\nconst OPTIONAL_EXPOSED = [HEADER_SAMPLING, HEADER_DATE].map((name) => name.toLowerCase());\n\n/** Result of one rule of the ingest contract. */\nexport interface DoctorResult {\n /** Rule name. */\n rule: string;\n /** True when the server meets the rule. */\n pass: boolean;\n /** Reason of the result. */\n detail: string;\n}\n\n/** An HTTP answer, or the text of a failed request. */\ntype Answer = Response | string;\n\n/** Gives the text of a problem, or undefined when the answer meets the test. */\ntype AnswerTest = (response: Response) => string | undefined;\n\n/** Builds the test record. The server stores it as an ordinary record. */\nfunction testRecord(): LogRecord {\n const traceId = crypto.randomUUID().replaceAll(\"-\", \"\");\n\n return {\n timeUnixNano: `${String(Date.now())}000000`,\n traceId,\n spanId: traceId.slice(0, 16),\n traceFlags: 1,\n severityNumber: SEVERITY_NUMBER.INFO,\n severityText: \"INFO\",\n body: \"uiobs doctor test record\",\n attributes: {},\n resource: { \"service.name\": \"uiobs-doctor\" },\n };\n}\n\n/** Sends one request. The result line reports a failure. The tool has no diagnostics instance. */\nasync function request(url: string, init: RequestInit): Promise<Answer> {\n try {\n // A browser refuses a preflight that redirects. A redirect can also name another host.\n return await fetch(url, {\n ...init,\n redirect: \"manual\",\n signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),\n });\n } catch (error) {\n // Node gives only \"fetch failed\". The cause holds the reason, for example ECONNREFUSED.\n const reason: unknown = error instanceof Error ? (error.cause ?? error) : error;\n\n return `The request failed. ${reason instanceof Error ? reason.message : String(reason)}`;\n }\n}\n\n/** Gives the wanted values that a comma-separated header omits. A wildcard has each value. */\nfunction absent(response: Response, name: string, wanted: readonly string[]): string[] {\n const values = (response.headers.get(name) ?? \"\")\n .toLowerCase()\n .split(\",\")\n .map((value) => value.trim());\n\n return values.includes(\"*\") ? [] : wanted.filter((value) => !values.includes(value));\n}\n\n/** Tests the status of an answer. */\nconst statusProblem: AnswerTest = (response) =>\n response.ok ? undefined : `The server returned ${String(response.status)}.`;\n\n/** Builds the result of one rule. The first problem is the detail. */\nfunction judge(rule: string, answer: Answer, passed: string, ...tests: AnswerTest[]): DoctorResult {\n const problem =\n typeof answer === \"string\"\n ? answer\n : tests.map((test) => test(answer)).find((found) => found !== undefined);\n\n return { rule, pass: problem === undefined, detail: problem ?? passed };\n}\n\n/**\n * Sends the requests of each rule, one at a time. Two requests with one batch id must not overlap.\n * @param url Ingest URL.\n * @param origin Origin of the app.\n * @returns One result for each rule.\n */\nexport async function runDoctor(url: string, origin: string): Promise<DoctorResult[]> {\n const originProblem: AnswerTest = (response) => {\n const allowed = response.headers.get(\"Access-Control-Allow-Origin\");\n\n return allowed === origin || allowed === \"*\"\n ? undefined\n : `Access-Control-Allow-Origin is ${String(allowed)}. It must allow ${origin}.`;\n };\n\n const preflight = await request(url, {\n method: \"OPTIONS\",\n headers: {\n Origin: origin,\n \"Access-Control-Request-Method\": \"POST\",\n \"Access-Control-Request-Headers\": REQUEST_HEADERS.join(\", \"),\n },\n });\n\n const { body, contentType } = otlpSerializer.serialize([testRecord()]);\n const post = (\n id: string,\n attempt: number,\n payload: BodyInit,\n extra: Record<string, string> = {},\n ): Promise<Answer> =>\n request(url, {\n method: \"POST\",\n headers: {\n Origin: origin,\n [HEADER_CONTENT_TYPE]: contentType,\n [HEADER_BATCH_ID]: id,\n [HEADER_ATTEMPT]: String(attempt),\n ...extra,\n },\n body: payload,\n });\n\n const batchId = crypto.randomUUID();\n const first = await post(batchId, 0, body);\n const repeated = await post(batchId, 1, body);\n const compressed = await gzip(body);\n const zipped = compressed\n ? await post(crypto.randomUUID(), 0, compressed, {\n [HEADER_CONTENT_ENCODING]: ENCODING_GZIP,\n })\n : \"This Node version has no CompressionStream.\";\n\n const hidden = typeof first === \"string\" ? [] : absent(first, EXPOSE_HEADERS, OPTIONAL_EXPOSED);\n const note = hidden.length > 0 ? ` Optional headers stay hidden: ${hidden.join(\", \")}.` : \"\";\n\n return [\n judge(\n \"preflight\",\n preflight,\n \"The server permits POST from this origin.\",\n statusProblem,\n originProblem,\n ),\n judge(\n \"allowed headers\",\n preflight,\n \"The server allows each request header of the library.\",\n (response) => {\n const missing = absent(response, \"Access-Control-Allow-Headers\", REQUEST_HEADERS);\n\n return missing.length > 0\n ? `Access-Control-Allow-Headers must include ${missing.join(\", \")}.`\n : undefined;\n },\n ),\n judge(\"test batch\", first, \"The server accepted a test batch.\", statusProblem, originProblem),\n judge(\"exposed headers\", first, `The server exposes Retry-After.${note}`, (response) =>\n absent(response, EXPOSE_HEADERS, [HEADER_RETRY_AFTER.toLowerCase()]).length > 0\n ? `${EXPOSE_HEADERS} must include retry-after.`\n : undefined,\n ),\n judge(\"gzip\", zipped, \"The server accepted a gzip batch.\", statusProblem),\n judge(\n \"deduplication\",\n repeated,\n \"The server accepted a repeated batch id. A client cannot see if it stored the batch again.\",\n statusProblem,\n ),\n ];\n}\n\n/** Tests an HTTP URL. */\nfunction isHttpUrl(value: string): boolean {\n return /^https?:\\/\\//i.test(value) && URL.canParse(value);\n}\n\n/** Tests an exact browser origin. A path or a trailing slash does not match. */\nfunction isOrigin(value: string): boolean {\n return URL.canParse(value) && new URL(value).origin === value;\n}\n\n/**\n * Runs the command line tool.\n * @param args Arguments after the program name.\n * @param print Writes one line of output.\n * @returns The exit code.\n */\nexport async function main(\n args: readonly string[],\n print: (line: string) => void,\n): Promise<number> {\n const [command, url, flag, origin] = args;\n\n if (command !== \"doctor\" || flag !== \"--origin\" || !isHttpUrl(url) || !isOrigin(origin)) {\n print(USAGE);\n print(`Received: ${JSON.stringify(args)}`);\n return EXIT_USAGE;\n }\n\n const results = await runDoctor(url, origin);\n\n for (const { rule, pass, detail } of results) {\n print(`${pass ? \"PASS\" : \"FAIL\"} ${rule}: ${detail}`);\n }\n\n return results.every(({ pass }) => pass) ? EXIT_PASS : EXIT_FAIL;\n}\n"],"mappings":"gJAqBA,IAAMY,EAAqB,IAGrBC,EAAY,EAGZC,EAAY,EAGZC,EAAa,EAGbC,EACJ,4FAGIC,EAAiB,gCAGjBC,EAAkB,CACtBlB,EAAAA,GACAC,EAAAA,GACAC,EAAAA,GACAC,EAAAA,EACF,CAAC,CAAC,IAAK,GAASgB,EAAK,YAAY,CAAC,EAG5BC,EAAmB,CAAChB,EAAAA,GAAiBC,EAAAA,EAAW,CAAC,CAAC,IAAK,GAASc,EAAK,YAAY,CAAC,EAmBxF,SAASE,GAAwB,CAC/B,IAAMC,EAAU,OAAO,WAAW,CAAC,CAAC,WAAW,IAAK,EAAE,EAEtD,MAAO,CACL,aAAc,GAAG,OAAO,KAAK,IAAI,CAAC,EAAE,QACpC,UACA,OAAQA,EAAQ,MAAM,EAAG,EAAE,EAC3B,WAAY,EACZ,eAAgBhB,EAAAA,GAAgB,KAChC,aAAc,OACd,KAAM,2BACN,WAAY,CAAC,EACb,SAAU,CAAE,eAAgB,cAAe,CAC7C,CACF,CAGA,eAAeiB,EAAQ,EAAa,EAAoC,CACtE,GAAI,CAEF,OAAO,MAAM,MAAMC,EAAK,CACtB,GAAGC,EACH,SAAU,SACV,OAAQ,YAAY,QAAQb,CAAkB,CAChD,CAAC,CACH,OAASc,EAAO,CAEd,IAAMC,EAAkBD,aAAiB,MAASA,EAAM,OAASA,EAASA,EAE1E,MAAO,uBAAuBC,aAAkB,MAAQA,EAAO,QAAU,OAAOA,CAAM,GACxF,CACF,CAGA,SAASC,EAAO,EAAoB,EAAc,EAAqC,CACrF,IAAMC,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rB,GAAUsB,EAErC,GAAIF,IAAY,UAAYC,IAAS,YAAc,CAACJ,EAAUrC,CAAG,GAAK,CAACsC,EAASlB,CAAM,EAGpF,OAFAuB,EAAMnD,CAAK,EACXmD,EAAM,aAAa,KAAK,UAAUD,CAAI,GAAG,EAClCnD,EAGT,IAAMqD,EAAU,MAAM3B,EAAUjB,EAAKoB,CAAM,EAE3C,IAAK,GAAM,CAAE,OAAM,OAAM,YAAYwB,EACnCD,EAAM,GAAGE,EAAO,OAAS,OAAO,GAAGC,EAAK,IAAIC,GAAQ,EAGtD,OAAOH,EAAQ,OAAO,CAAE,UAAWC,CAAI,EAAIxD,EAAYC,CACzD"}
|
|
1
|
+
{"version":3,"file":"doctor.cjs","names":["HEADER_CONTENT_TYPE","HEADER_CONTENT_ENCODING","HEADER_BATCH_ID","HEADER_ATTEMPT","HEADER_SAMPLING","HEADER_DATE","SEVERITY_NUMBER","gzip","ENCODING_GZIP","otlpSerializer","QUERY_PARAM_BATCH_ID","QUERY_PARAM_EXIT_REASON","CONTENT_TYPE_TEXT_PLAIN","CONTENT_TYPE_JSON","LIBRARY_TIMEOUT_MS","require_constants","require_compression","require_otlp","REQUEST_TIMEOUT_MS","EXIT_PASS","EXIT_FAIL","EXIT_USAGE","USAGE","HEADER_FLAG","REPLAY_FLAG","LARGE_EVENT_CHARS","CUSTOM_EVENT","DOCTOR_NAME","HEADER_PATTERN","HIDDEN","EXPOSE_HEADERS","REQUEST_HEADERS","name","RESERVED_HEADERS","OPTIONAL_EXPOSED","testRecord","traceId","request","url","init","timeoutMs","error","reason","absent","values","response","value","wanted","statusProblem","judge","tests","problem","answer","test","found","passed","targetOf","customNames","custom","originTest","allowed","origin","sendPreflight","requestHeaders","preflightResults","preflight","target","missing","poster","contentType","id","attempt","extra","payload","postZipped","compressed","body","post","runDoctor","originProblem","batchId","first","repeated","zipped","beaconUrl","beacon","hidden","note","runReplayDoctor","replayId","head","segment","events","text","idOf","sequence","small","large","customHeaders","pairs","index","args","match","isHttpUrl","username","password","SHOWN_WORDS","shownArgument","arg","pathname","isOrigin","main","command","flag","rest","replay","headers","print","results","pass","rule","detail"],"sources":["../src/doctor.ts"],"sourcesContent":["// src/doctor.ts\n//\n// Checks an ingest server, or a replay endpoint, against its contract in the README. The\n// `uiobs doctor` command calls main(). Only web APIs are used here, and the browser build\n// replaces every \"node:\" import.\n\nimport {\n CONTENT_TYPE_JSON,\n CONTENT_TYPE_TEXT_PLAIN,\n ENCODING_GZIP,\n HEADER_ATTEMPT,\n HEADER_BATCH_ID,\n HEADER_CONTENT_ENCODING,\n HEADER_CONTENT_TYPE,\n HEADER_DATE,\n HEADER_RETRY_AFTER,\n HEADER_SAMPLING,\n QUERY_PARAM_BATCH_ID,\n QUERY_PARAM_EXIT_REASON,\n REQUEST_TIMEOUT_MS as LIBRARY_TIMEOUT_MS,\n SEVERITY_NUMBER,\n} from \"./constants\";\nimport type { LogRecord } from \"./models/log-record\";\nimport { gzip } from \"./transport/compression\";\nimport { otlpSerializer } from \"./transport/serializers/otlp\";\n\n/** How long to wait for one answer, in milliseconds. */\nconst REQUEST_TIMEOUT_MS = 10000;\n\n/** Exit code when every rule passes. */\nconst EXIT_PASS = 0;\n\n/** Exit code when a rule fails. */\nconst EXIT_FAIL = 1;\n\n/** Exit code for a wrong command. */\nconst EXIT_USAGE = 2;\n\n/** Printed for a wrong command. */\nconst USAGE =\n 'Usage: uiobs doctor <url> --origin <origin> [--replay] [--header \"Name: value\"]. An origin has no path and no trailing slash. With --replay, the URL is a replay endpoint.';\n\n/** Adds a request header, e.g. an Authorization header. */\nconst HEADER_FLAG = \"--header\";\n\n/** Says that the URL is a replay endpoint, so the tool sends segments instead of batches. */\nconst REPLAY_FLAG = \"--replay\";\n\n/**\n * Size of the event in the large test segment, in characters. The first segment of a real\n * upload holds a full snapshot, and one of a page with 35,000 table cells measured 4.7 MB.\n */\nconst LARGE_EVENT_CHARS = 5_000_000;\n\n/** The recorder's custom event type. A player skips a custom event it doesn't know. */\nconst CUSTOM_EVENT = 5;\n\n/** Marks everything the tool stores, so an operator can find and delete it. */\nconst DOCTOR_NAME = \"uiobs-doctor\";\n\n/** A header name, a colon, then a value of printable ASCII. */\nconst HEADER_PATTERN = /^([\\w!#$%&'*+.^`|~-]+): *([\\x20-\\x7e]+)$/;\n\n/** Printed in place of any argument that might contain a secret. */\nconst HIDDEN = \"<hidden>\";\n\n/** Response header that lists the headers a page can read. */\nconst EXPOSE_HEADERS = \"Access-Control-Expose-Headers\";\n\n/** The library's request headers. The server must allow every one of them. */\nconst REQUEST_HEADERS = [\n HEADER_CONTENT_TYPE,\n HEADER_CONTENT_ENCODING,\n HEADER_BATCH_ID,\n HEADER_ATTEMPT,\n].map((name) => name.toLowerCase());\n\n/** Headers the tool sets itself. A custom header can't reuse one of these names. */\nconst RESERVED_HEADERS = [...REQUEST_HEADERS, \"origin\"];\n\n/** Response headers that only an optional feature reads. */\nconst OPTIONAL_EXPOSED = [HEADER_SAMPLING, HEADER_DATE].map((name) => name.toLowerCase());\n\n/** The result of one ingest contract rule. */\nexport interface DoctorResult {\n /** Rule name. */\n rule: string;\n /** True when the server meets the rule. */\n pass: boolean;\n /** Why the rule passed or failed. */\n detail: string;\n}\n\n/** An HTTP answer, or the text of a failed request. */\ntype Answer = Response | string;\n\n/** Returns a description of the problem, or undefined when the answer passes the test. */\ntype AnswerTest = (response: Response) => string | undefined;\n\n/** Builds the test record. The server stores it like any other record. */\nfunction testRecord(): LogRecord {\n const traceId = crypto.randomUUID().replaceAll(\"-\", \"\");\n\n return {\n timeUnixNano: `${String(Date.now())}000000`,\n traceId,\n spanId: traceId.slice(0, 16),\n traceFlags: 1,\n severityNumber: SEVERITY_NUMBER.INFO,\n severityText: \"INFO\",\n body: \"uiobs doctor test record\",\n attributes: {},\n resource: { \"service.name\": DOCTOR_NAME },\n };\n}\n\n/** Sends one request. A failure shows up in the result line, as the tool has no diagnostics. */\nasync function request(\n url: string,\n init: RequestInit,\n timeoutMs = REQUEST_TIMEOUT_MS,\n): Promise<Answer> {\n try {\n // A browser refuses a preflight that redirects, and a redirect can also name another host.\n return await fetch(url, {\n ...init,\n redirect: \"manual\",\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n // Node only says \"fetch failed\". The cause holds the real reason, for example ECONNREFUSED.\n const reason: unknown = error instanceof Error ? (error.cause ?? error) : error;\n\n return `The request failed. ${reason instanceof Error ? reason.message : String(reason)}`;\n }\n}\n\n/** Returns the wanted values a comma-separated header leaves out. A wildcard covers them all. */\nfunction absent(response: Response, name: string, wanted: readonly string[]): string[] {\n const values = (response.headers.get(name) ?? \"\")\n .toLowerCase()\n .split(\",\")\n .map((value) => value.trim());\n\n return values.includes(\"*\") ? [] : wanted.filter((value) => !values.includes(value));\n}\n\n/** Checks an answer's status. */\nconst statusProblem: AnswerTest = (response) =>\n response.ok ? undefined : `The server returned ${String(response.status)}.`;\n\n/** Builds the result for one rule. The first problem found becomes the detail. */\nfunction judge(rule: string, answer: Answer, passed: string, ...tests: AnswerTest[]): DoctorResult {\n const problem =\n typeof answer === \"string\"\n ? answer\n : tests.map((test) => test(answer)).find((found) => found !== undefined);\n\n return { rule, pass: problem === undefined, detail: problem ?? passed };\n}\n\n/** One endpoint under test: where it is, who calls it and with which headers. */\ninterface Target {\n /** Endpoint URL. */\n url: string;\n /** The app's origin. */\n origin: string;\n /** The app's headers for each POST, e.g. an Authorization header. */\n custom: Readonly<Record<string, string>>;\n /** Lowercase names of every header a POST carries. The preflight asks for them. */\n requestHeaders: string[];\n}\n\n/** Sends one POST the way the library does. Extra headers go on top. */\ntype Post = (\n id: string,\n attempt: number,\n payload: BodyInit,\n extra?: Record<string, string>,\n) => Promise<Answer>;\n\n/** Builds the target for one run. */\nfunction targetOf(url: string, origin: string, custom: Readonly<Record<string, string>>): Target {\n const customNames = Object.keys(custom).map((name) => name.toLowerCase());\n\n return { url, origin, custom, requestHeaders: [...REQUEST_HEADERS, ...customNames] };\n}\n\n/** Builds the test that an answer lets the app's origin read it. */\nfunction originTest(origin: string): AnswerTest {\n return (response) => {\n const allowed = response.headers.get(\"Access-Control-Allow-Origin\");\n\n return allowed === origin || allowed === \"*\"\n ? undefined\n : `Access-Control-Allow-Origin is ${String(allowed)}. It must allow ${origin}.`;\n };\n}\n\n/** Sends the preflight a browser sends before the library's POST. */\nfunction sendPreflight({ url, origin, requestHeaders }: Target): Promise<Answer> {\n return request(url, {\n method: \"OPTIONS\",\n headers: {\n Origin: origin,\n \"Access-Control-Request-Method\": \"POST\",\n \"Access-Control-Request-Headers\": requestHeaders.join(\", \"),\n },\n });\n}\n\n/** Builds the two results every preflight gives. */\nfunction preflightResults(preflight: Answer, target: Target): DoctorResult[] {\n return [\n judge(\n \"preflight\",\n preflight,\n \"The server permits POST from this origin.\",\n statusProblem,\n originTest(target.origin),\n ),\n judge(\n \"allowed headers\",\n preflight,\n \"The server allows each request header of the library.\",\n (response) => {\n const missing = absent(response, \"Access-Control-Allow-Headers\", target.requestHeaders);\n\n return missing.length > 0\n ? `Access-Control-Allow-Headers must include ${missing.join(\", \")}.`\n : undefined;\n },\n ),\n ];\n}\n\n/** Builds the POST function for one target and content type. */\nfunction poster({ url, origin, custom }: Target, contentType: string, timeoutMs?: number): Post {\n return (id, attempt, payload, extra = {}) =>\n request(\n url,\n {\n method: \"POST\",\n headers: {\n ...custom,\n Origin: origin,\n [HEADER_CONTENT_TYPE]: contentType,\n [HEADER_BATCH_ID]: id,\n [HEADER_ATTEMPT]: String(attempt),\n ...extra,\n },\n body: payload,\n },\n timeoutMs,\n );\n}\n\n/** Sends a body with gzip. Gives the text of the problem if this Node can't compress. */\nasync function postZipped(post: Post, id: string, body: string): Promise<Answer> {\n const compressed = await gzip(body);\n\n return compressed\n ? post(id, 0, compressed, { [HEADER_CONTENT_ENCODING]: ENCODING_GZIP })\n : \"This Node version has no CompressionStream.\";\n}\n\n/**\n * Runs each rule's requests one at a time. Two requests with the same batch id must not overlap.\n * @param url Ingest URL.\n * @param origin The app's origin.\n * @param custom The app's headers for each batch, e.g. an Authorization header.\n * @returns One result per rule.\n */\nexport async function runDoctor(\n url: string,\n origin: string,\n custom: Readonly<Record<string, string>> = {},\n): Promise<DoctorResult[]> {\n const target = targetOf(url, origin, custom);\n const originProblem = originTest(origin);\n const preflight = await sendPreflight(target);\n\n const { body, contentType } = otlpSerializer.serialize([testRecord()]);\n const post = poster(target, contentType);\n\n const batchId = crypto.randomUUID();\n const first = await post(batchId, 0, body);\n const repeated = await post(batchId, 1, body);\n const zipped = await postZipped(post, crypto.randomUUID(), body);\n\n // sendBeacon can't set headers, so the id and the reason go in the query, like the exit flush.\n const beaconUrl = new URL(url);\n beaconUrl.searchParams.set(QUERY_PARAM_BATCH_ID, crypto.randomUUID());\n beaconUrl.searchParams.set(QUERY_PARAM_EXIT_REASON, \"pagehide\");\n\n // With custom headers the library's exit flush uses a keepalive fetch instead of a beacon.\n const beacon =\n target.requestHeaders.length > REQUEST_HEADERS.length\n ? undefined\n : await request(beaconUrl.toString(), {\n method: \"POST\",\n headers: { Origin: origin, [HEADER_CONTENT_TYPE]: CONTENT_TYPE_TEXT_PLAIN },\n body,\n });\n\n const hidden = typeof first === \"string\" ? [] : absent(first, EXPOSE_HEADERS, OPTIONAL_EXPOSED);\n const note = hidden.length > 0 ? ` Optional headers stay hidden: ${hidden.join(\", \")}.` : \"\";\n\n return [\n ...preflightResults(preflight, target),\n judge(\"test batch\", first, \"The server accepted a test batch.\", statusProblem, originProblem),\n judge(\"exposed headers\", first, `The server exposes Retry-After.${note}`, (response) =>\n absent(response, EXPOSE_HEADERS, [HEADER_RETRY_AFTER.toLowerCase()]).length > 0\n ? `${EXPOSE_HEADERS} must include retry-after.`\n : undefined,\n ),\n judge(\"gzip\", zipped, \"The server accepted a gzip batch.\", statusProblem),\n judge(\n \"deduplication\",\n repeated,\n \"The server accepted a repeated batch id. A client cannot see if it stored the batch again.\",\n statusProblem,\n ),\n beacon === undefined\n ? {\n rule: \"beacon\",\n pass: true,\n detail: \"The library sends no beacon with custom headers. The tool sent no beacon.\",\n }\n : judge(\"beacon\", beacon, \"The server accepted a text/plain batch.\", statusProblem),\n ];\n}\n\n/**\n * Checks a replay endpoint the way runDoctor() checks an ingest server. A segment has its own\n * body and its own batch id form, and its first one can be several megabytes.\n * @param url Replay endpoint URL, the value of replay.endpoint.\n * @param origin The app's origin.\n * @param custom The app's replay.headers, e.g. an Authorization header.\n * @returns One result per rule.\n */\nexport async function runReplayDoctor(\n url: string,\n origin: string,\n custom: Readonly<Record<string, string>> = {},\n): Promise<DoctorResult[]> {\n const target = targetOf(url, origin, custom);\n const originProblem = originTest(origin);\n const preflight = await sendPreflight(target);\n\n const replayId = crypto.randomUUID();\n const head = {\n \"replay.id\": replayId,\n \"session.id\": crypto.randomUUID(),\n \"tab.id\": crypto.randomUUID(),\n \"service.name\": DOCTOR_NAME,\n };\n // The body the uploader sends: the ids, the sequence, the JSON length of the events, and the\n // events themselves.\n const segment = (sequence: number, text: string): string => {\n const events = [\n { type: CUSTOM_EVENT, timestamp: Date.now(), data: { tag: DOCTOR_NAME, payload: text } },\n ];\n\n return JSON.stringify({ ...head, sequence, bytes: JSON.stringify(events).length, events });\n };\n // The uploader's batch id is the replay id plus the sequence.\n const idOf = (sequence: number): string => `${replayId}-${String(sequence)}`;\n const post = poster(target, CONTENT_TYPE_JSON);\n const small = segment(0, \"uiobs doctor test event\");\n\n const first = await post(idOf(0), 0, small);\n const repeated = await post(idOf(0), 1, small);\n const zipped = await postZipped(post, idOf(1), segment(1, \"uiobs doctor gzip event\"));\n // No gzip here. That is the worst case: compression off, or a browser without\n // CompressionStream. The library gives a segment delivery.requestTimeoutMs, so the tool\n // waits for the default of that. A shorter wait would fail a slow link the library can use.\n const large = await poster(target, CONTENT_TYPE_JSON, LIBRARY_TIMEOUT_MS)(\n idOf(2),\n 0,\n segment(2, \"x\".repeat(LARGE_EVENT_CHARS)),\n );\n\n return [\n ...preflightResults(preflight, target),\n judge(\n \"test segment\",\n first,\n \"The server accepted a test segment.\",\n statusProblem,\n originProblem,\n ),\n judge(\"gzip\", zipped, \"The server accepted a gzip segment.\", statusProblem),\n judge(\n \"large segment\",\n large,\n `The server accepted a segment of ${String(LARGE_EVENT_CHARS)} bytes without gzip.`,\n // The library drops a segment after a 413, so a low body limit loses every replay.\n (response) =>\n response.ok\n ? undefined\n : `The server returned ${String(response.status)} for a segment of ${String(LARGE_EVENT_CHARS)} bytes. The first segment of an upload has a full snapshot of the page. Raise the body limit of the server.`,\n ),\n judge(\n \"deduplication\",\n repeated,\n \"The server accepted a repeated batch id. A client cannot see if it stored the segment again.\",\n statusProblem,\n ),\n ];\n}\n\n/**\n * Parses the header options. Each one is the flag followed by a \"Name: value\" argument.\n * @param args The arguments after the origin.\n * @returns The headers, or undefined if an option is malformed.\n */\nfunction customHeaders(args: readonly string[]): Record<string, string> | undefined {\n const pairs: [string, string][] = [];\n\n for (let index = 0; index < args.length; index += 2) {\n // A flag without a value leaves undefined here, which exec() treats as text with no colon.\n const match = args[index] === HEADER_FLAG ? HEADER_PATTERN.exec(args[index + 1]) : null;\n\n if (!match || RESERVED_HEADERS.includes(match[1].toLowerCase())) {\n return undefined;\n }\n\n pairs.push([match[1], match[2]]);\n }\n\n return Object.fromEntries(pairs);\n}\n\n/** True for an HTTP URL without a user name or password. Result lines print the URL. */\nfunction isHttpUrl(value: string): boolean {\n if (!/^https?:\\/\\//i.test(value) || !URL.canParse(value)) {\n return false;\n }\n\n const { username, password } = new URL(value);\n return username === \"\" && password === \"\";\n}\n\n/** Command line words that are safe to print. */\nconst SHOWN_WORDS = [\"doctor\", \"--origin\", REPLAY_FLAG, HEADER_FLAG];\n\n/**\n * Turns an argument into something safe to print in the usage message. An argument can be a\n * token, a URL can carry one in its query or user info, and the output may land in a shared log.\n * @param arg Command line argument.\n * @returns The word itself, a URL without query or user info, or a placeholder.\n */\nfunction shownArgument(arg: string): string {\n if (SHOWN_WORDS.includes(arg)) {\n return arg;\n }\n\n if (/^https?:\\/\\//i.test(arg) && URL.canParse(arg)) {\n const { origin, pathname } = new URL(arg);\n return `${origin}${pathname === \"/\" && !arg.endsWith(\"/\") ? \"\" : pathname}`;\n }\n\n return HIDDEN;\n}\n\n/** Checks for an exact browser origin. A path or a trailing slash doesn't match. */\nfunction isOrigin(value: string): boolean {\n return URL.canParse(value) && new URL(value).origin === value;\n}\n\n/**\n * Runs the command line tool.\n * @param args Arguments after the program name.\n * @param print Writes one line of output.\n * @returns The exit code.\n */\nexport async function main(\n args: readonly string[],\n print: (line: string) => void,\n): Promise<number> {\n const [command, url, flag, origin, ...rest] = args;\n // The replay flag comes right after the origin, before any header option.\n const replay = rest[0] === REPLAY_FLAG;\n const headers = customHeaders(replay ? rest.slice(1) : rest);\n\n if (\n command !== \"doctor\" ||\n flag !== \"--origin\" ||\n !isHttpUrl(url) ||\n !isOrigin(origin) ||\n !headers\n ) {\n print(USAGE);\n print(`Received: ${JSON.stringify(args.map(shownArgument))}`);\n return EXIT_USAGE;\n }\n\n const results = await (replay ? runReplayDoctor : runDoctor)(url, origin, headers);\n\n for (const { rule, pass, detail } of results) {\n print(`${pass ? \"PASS\" : \"FAIL\"} ${rule}: ${detail}`);\n }\n\n return results.every(({ pass }) => pass) ? EXIT_PASS : EXIT_FAIL;\n}\n"],"mappings":"A,wLA2BA,IAAMkB,EAAqB,IAGrBC,EAAY,EAGZC,EAAY,EAGZC,EAAa,EAGbC,EACJ,6KAGIC,EAAc,WAGdC,EAAc,WAMdC,EAAoB,IAGpBC,EAAe,EAGfC,EAAc,eAGdC,EAAiB,2CAGjBC,EAAS,WAGTC,EAAiB,gCAGjBC,EAAkB,CACtB/B,EAAAA,GACAC,EAAAA,GACAC,EAAAA,GACAC,EAAAA,EACF,CAAC,CAAC,IAAK,GAAS6B,EAAK,YAAY,CAAC,EAG5BC,EAAmB,CAAC,GAAGF,EAAiB,QAAQ,EAGhDG,EAAmB,CAAC9B,EAAAA,GAAiBC,EAAAA,EAAW,CAAC,CAAC,IAAK,GAAS2B,EAAK,YAAY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B,OAAOA,EAGT,GAAI,gBAAgB,KAAKA,CAAG,GAAK,IAAI,SAASA,CAAG,EAAG,CAClD,GAAM,CAAE,SAAQ,YAAa,IAAI,IAAIA,CAAG,EACxC,MAAO,GAAG/C,IAASgD,IAAa,KAAO,CAACD,EAAI,SAAS,GAAG,EAAI,GAAKC,GACnE,CAEA,OAAOhF,CACT,CAGA,SAASiF,EAAS,EAAwB,CACxC,OAAO,IAAI,SAAShE,CAAK,GAAK,IAAI,IAAIA,CAAK,CAAC,CAAC,SAAWA,CAC1D,CAQA,eAAsBiE,EACpB,EACA,EACiB,CACjB,GAAM,CAACC,EAAS1E,EAAK2E,EAAMpD,EAAQ,GAAGqD,GAAQb,EAExCc,EAASD,EAAK,KAAO1F,EACrB4F,EAAUlB,EAAciB,EAASD,EAAK,MAAM,CAAC,EAAIA,CAAI,EAE3D,GACEF,IAAY,UACZC,IAAS,YACT,CAACV,EAAUjE,CAAG,GACd,CAACwE,EAASjD,CAAM,GAChB,CAACuD,EAID,OAFAC,EAAM/F,CAAK,EACX+F,EAAM,aAAa,KAAK,UAAUhB,EAAK,IAAIM,CAAa,CAAC,GAAG,EACrDtF,EAGT,IAAMiG,EAAU,MAAOH,EAAS3B,EAAkBV,EAAA,CAAWxC,EAAKuB,EAAQuD,CAAO,EAEjF,IAAK,GAAM,CAAE,OAAM,OAAM,YAAYE,EACnCD,EAAM,GAAGE,EAAO,OAAS,OAAO,GAAGC,EAAK,IAAIC,GAAQ,EAGtD,OAAOH,EAAQ,OAAO,CAAE,UAAWC,CAAI,EAAIpG,EAAYC,CACzD,C"}
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The result of one ingest contract rule. */
|
|
2
2
|
export interface DoctorResult {
|
|
3
3
|
/** Rule name. */
|
|
4
4
|
rule: string;
|
|
5
5
|
/** True when the server meets the rule. */
|
|
6
6
|
pass: boolean;
|
|
7
|
-
/**
|
|
7
|
+
/** Why the rule passed or failed. */
|
|
8
8
|
detail: string;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Runs each rule's requests one at a time. Two requests with the same batch id must not overlap.
|
|
12
12
|
* @param url Ingest URL.
|
|
13
|
-
* @param origin
|
|
14
|
-
* @
|
|
13
|
+
* @param origin The app's origin.
|
|
14
|
+
* @param custom The app's headers for each batch, e.g. an Authorization header.
|
|
15
|
+
* @returns One result per rule.
|
|
15
16
|
*/
|
|
16
|
-
export declare function runDoctor(url: string, origin: string): Promise<DoctorResult[]>;
|
|
17
|
+
export declare function runDoctor(url: string, origin: string, custom?: Readonly<Record<string, string>>): Promise<DoctorResult[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Checks a replay endpoint the way runDoctor() checks an ingest server. A segment has its own
|
|
20
|
+
* body and its own batch id form, and its first one can be several megabytes.
|
|
21
|
+
* @param url Replay endpoint URL, the value of replay.endpoint.
|
|
22
|
+
* @param origin The app's origin.
|
|
23
|
+
* @param custom The app's replay.headers, e.g. an Authorization header.
|
|
24
|
+
* @returns One result per rule.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runReplayDoctor(url: string, origin: string, custom?: Readonly<Record<string, string>>): Promise<DoctorResult[]>;
|
|
17
27
|
/**
|
|
18
28
|
* Runs the command line tool.
|
|
19
29
|
* @param args Arguments after the program name.
|