@utk09/ui-observability 1.1.0 → 1.2.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 +42 -0
- package/dist/{batch-D3NHhF9L.js → batch-120Kc9jr.js} +3 -3
- package/dist/{batch-D3NHhF9L.js.map → batch-120Kc9jr.js.map} +1 -1
- package/dist/{batch-DnYRJqhU.cjs → batch-C3uNp5kU.cjs} +2 -2
- package/dist/{batch-DnYRJqhU.cjs.map → batch-C3uNp5kU.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +5 -0
- package/dist/bus/bus.d.ts +5 -0
- package/dist/bus-Dj8IEVcC.cjs +2 -0
- package/dist/bus-Dj8IEVcC.cjs.map +1 -0
- package/dist/{bus-dw7T92sO.js → bus-DyNafxZN.js} +104 -94
- package/dist/bus-DyNafxZN.js.map +1 -0
- package/dist/capture/errors.d.cts +10 -0
- package/dist/capture/errors.d.ts +10 -0
- package/dist/capture/replay.d.cts +1 -1
- package/dist/capture/replay.d.ts +1 -1
- package/dist/capture/types.d.cts +5 -0
- package/dist/capture/types.d.ts +5 -0
- package/dist/capture/web-vitals.d.cts +1 -0
- package/dist/capture/web-vitals.d.ts +1 -0
- package/dist/{compression-SHPAvS4U.js → compression-BWkDWY3v.js} +2 -2
- package/dist/{compression-SHPAvS4U.js.map → compression-BWkDWY3v.js.map} +1 -1
- package/dist/{compression-C0hUHKR-.cjs → compression-CEVe7NPX.cjs} +2 -2
- package/dist/{compression-C0hUHKR-.cjs.map → compression-CEVe7NPX.cjs.map} +1 -1
- package/dist/config-C0PtemvC.cjs +2 -0
- package/dist/config-C0PtemvC.cjs.map +1 -0
- package/dist/{config-CSNcS7OZ.js → config-DK1Zf7jn.js} +83 -85
- package/dist/config-DK1Zf7jn.js.map +1 -0
- package/dist/{console-BsM-fSCQ.js → console-CAyCQOpm.js} +5 -5
- package/dist/{console-BsM-fSCQ.js.map → console-CAyCQOpm.js.map} +1 -1
- package/dist/{console-Dkxs6IVQ.cjs → console-Dk6GH4yj.cjs} +2 -2
- package/dist/{console-Dkxs6IVQ.cjs.map → console-Dk6GH4yj.cjs.map} +1 -1
- package/dist/{constants-BwJDXzj6.js → constants-CEHN6KuY.js} +42 -21
- package/dist/constants-CEHN6KuY.js.map +1 -0
- package/dist/constants-NtiQDWL_.cjs +2 -0
- package/dist/constants-NtiQDWL_.cjs.map +1 -0
- package/dist/constants.d.cts +11 -0
- package/dist/constants.d.ts +11 -0
- package/dist/core/config.d.cts +9 -3
- package/dist/core/config.d.ts +9 -3
- package/dist/core/diagnostics.d.cts +1 -1
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/pipeline.d.cts +11 -0
- package/dist/core/pipeline.d.ts +11 -0
- package/dist/core/record.d.cts +2 -2
- package/dist/core/record.d.ts +2 -2
- package/dist/core/sender.d.cts +3 -2
- package/dist/core/sender.d.ts +3 -2
- package/dist/{debug-bundle-B2v6Cym-.cjs → debug-bundle-DMzUfiQc.cjs} +2 -2
- package/dist/{debug-bundle-B2v6Cym-.cjs.map → debug-bundle-DMzUfiQc.cjs.map} +1 -1
- package/dist/{debug-bundle-Cs_YWzTa.js → debug-bundle-w78W46zr.js} +4 -4
- package/dist/{debug-bundle-Cs_YWzTa.js.map → debug-bundle-w78W46zr.js.map} +1 -1
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.js +22 -22
- package/dist/doctor.js.map +1 -1
- package/dist/errors-07pmZ7VY.cjs +3 -0
- package/dist/errors-07pmZ7VY.cjs.map +1 -0
- package/dist/{errors-Q3Ng1ciC.js → errors-C-LYbqyB.js} +27 -24
- package/dist/errors-C-LYbqyB.js.map +1 -0
- package/dist/{factory-DV17sm2p.js → factory-BHYrcSaU.js} +42 -31
- package/dist/factory-BHYrcSaU.js.map +1 -0
- package/dist/factory-DsaNdcXp.cjs +2 -0
- package/dist/factory-DsaNdcXp.cjs.map +1 -0
- package/dist/{identity-BgtHyY4u.js → identity-Byh3gCdT.js} +11 -11
- package/dist/{identity-BgtHyY4u.js.map → identity-Byh3gCdT.js.map} +1 -1
- package/dist/{identity-CvuyqZk7.cjs → identity-BzAzdQyv.cjs} +2 -2
- package/dist/{identity-CvuyqZk7.cjs.map → identity-BzAzdQyv.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +539 -534
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-e-13ZLWm.js → indexeddb-storage-BYywz-v6.js} +4 -4
- package/dist/{indexeddb-storage-e-13ZLWm.js.map → indexeddb-storage-BYywz-v6.js.map} +1 -1
- package/dist/{indexeddb-storage-D4KVcqdD.cjs → indexeddb-storage-BfqGkLFe.cjs} +2 -2
- package/dist/{indexeddb-storage-D4KVcqdD.cjs.map → indexeddb-storage-BfqGkLFe.cjs.map} +1 -1
- package/dist/{interactions-OK85T-Dk.cjs → interactions-BXzEel4F.cjs} +2 -2
- package/dist/interactions-BXzEel4F.cjs.map +1 -0
- package/dist/{interactions-Byxf1C82.js → interactions-DdKPMWIN.js} +12 -12
- package/dist/interactions-DdKPMWIN.js.map +1 -0
- package/dist/{journey-nMbob3OB.cjs → journey-BUmsrgaw.cjs} +2 -2
- package/dist/{journey-nMbob3OB.cjs.map → journey-BUmsrgaw.cjs.map} +1 -1
- package/dist/{journey-C93FTYcs.js → journey-Nu655gEO.js} +3 -3
- package/dist/{journey-C93FTYcs.js.map → journey-Nu655gEO.js.map} +1 -1
- package/dist/{library-console-DJUQzcgM.cjs → library-console-DdIlzzph.cjs} +2 -2
- package/dist/{library-console-DJUQzcgM.cjs.map → library-console-DdIlzzph.cjs.map} +1 -1
- package/dist/{library-console-DklSmucS.js → library-console-amePMnP8.js} +2 -2
- package/dist/{library-console-DklSmucS.js.map → library-console-amePMnP8.js.map} +1 -1
- package/dist/{library-request-UGEwOHpf.js → library-request-Cv7C05jf.js} +2 -2
- package/dist/{library-request-UGEwOHpf.js.map → library-request-Cv7C05jf.js.map} +1 -1
- package/dist/{library-request-kY9iTpIF.cjs → library-request-DO3Ec7KE.cjs} +2 -2
- package/dist/{library-request-kY9iTpIF.cjs.map → library-request-DO3Ec7KE.cjs.map} +1 -1
- package/dist/{lifecycle-DaMdH_X7.cjs → lifecycle-B5yfH5is.cjs} +2 -2
- package/dist/{lifecycle-DaMdH_X7.cjs.map → lifecycle-B5yfH5is.cjs.map} +1 -1
- package/dist/{lifecycle-B2PlIuQu.js → lifecycle-CMHz2Zbs.js} +2 -2
- package/dist/{lifecycle-B2PlIuQu.js.map → lifecycle-CMHz2Zbs.js.map} +1 -1
- package/dist/{log-record-DSt2P-Sr.js → log-record-B_nSqxoe.js} +2 -2
- package/dist/{log-record-DSt2P-Sr.js.map → log-record-B_nSqxoe.js.map} +1 -1
- package/dist/{log-record-Bmx6etMh.cjs → log-record-Bdywwg0k.cjs} +2 -2
- package/dist/{log-record-Bmx6etMh.cjs.map → log-record-Bdywwg0k.cjs.map} +1 -1
- package/dist/{long-frames-Bamjs1WV.js → long-frames-6NGl1-uN.js} +3 -3
- package/dist/{long-frames-Bamjs1WV.js.map → long-frames-6NGl1-uN.js.map} +1 -1
- package/dist/{long-frames-lhtONgGt.cjs → long-frames-D9DfSWqv.cjs} +2 -2
- package/dist/{long-frames-lhtONgGt.cjs.map → long-frames-D9DfSWqv.cjs.map} +1 -1
- package/dist/models/config.d.cts +4 -3
- package/dist/models/config.d.ts +4 -3
- package/dist/{network-BCn8Gn47.cjs → network-BNHBI0Fc.cjs} +2 -2
- package/dist/{network-BCn8Gn47.cjs.map → network-BNHBI0Fc.cjs.map} +1 -1
- package/dist/{network-Cg1L2w2r.js → network-Cc3tSB7e.js} +13 -13
- package/dist/{network-Cg1L2w2r.js.map → network-Cc3tSB7e.js.map} +1 -1
- package/dist/{observed-windows-BrwaJNlj.js → observed-windows-8JtCsIr1.js} +3 -3
- package/dist/{observed-windows-BrwaJNlj.js.map → observed-windows-8JtCsIr1.js.map} +1 -1
- package/dist/{observed-windows-B3gJkdql.cjs → observed-windows-BlE25nrn.cjs} +2 -2
- package/dist/{observed-windows-B3gJkdql.cjs.map → observed-windows-BlE25nrn.cjs.map} +1 -1
- package/dist/openfin-Bxelt0yg.js.map +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/{otlp-D6dRZyB8.js → otlp-Btix3EBa.js} +7 -7
- package/dist/{otlp-D6dRZyB8.js.map → otlp-Btix3EBa.js.map} +1 -1
- package/dist/{otlp-CrAWkQdO.cjs → otlp-CFSW-Dno.cjs} +2 -2
- package/dist/{otlp-CrAWkQdO.cjs.map → otlp-CFSW-Dno.cjs.map} +1 -1
- package/dist/patch-DlcKzIi-.cjs +2 -0
- package/dist/patch-DlcKzIi-.cjs.map +1 -0
- package/dist/patch-Sr1wKg7W.js +9 -0
- package/dist/patch-Sr1wKg7W.js.map +1 -0
- package/dist/platform-BZjp9wp1.cjs +2 -0
- package/dist/platform-BZjp9wp1.cjs.map +1 -0
- package/dist/{platform-8DLhjddo.js → platform-Dba6R3Hp.js} +22 -9
- package/dist/platform-Dba6R3Hp.js.map +1 -0
- package/dist/{profiler-BaXSqCfz.js → profiler-DNKcqu09.js} +19 -19
- package/dist/{profiler-BaXSqCfz.js.map → profiler-DNKcqu09.js.map} +1 -1
- package/dist/{profiler-BvWW2kNM.cjs → profiler-DpoPi1hH.cjs} +2 -2
- package/dist/{profiler-BvWW2kNM.cjs.map → profiler-DpoPi1hH.cjs.map} +1 -1
- package/dist/{profiler-frames-DeaBiB-5.cjs → profiler-frames-C9zJNd8_.cjs} +2 -2
- package/dist/{profiler-frames-DeaBiB-5.cjs.map → profiler-frames-C9zJNd8_.cjs.map} +1 -1
- package/dist/{profiler-frames-C4ySHN0X.js → profiler-frames-CGXZeZ_3.js} +4 -4
- package/dist/{profiler-frames-C4ySHN0X.js.map → profiler-frames-CGXZeZ_3.js.map} +1 -1
- package/dist/{remote-rules-Dq9xe7Qn.js → remote-rules-DNK96vLa.js} +15 -15
- package/dist/{remote-rules-Dq9xe7Qn.js.map → remote-rules-DNK96vLa.js.map} +1 -1
- package/dist/{remote-rules-D7L6D_D2.cjs → remote-rules-DuMFRlit.cjs} +2 -2
- package/dist/{remote-rules-D7L6D_D2.cjs.map → remote-rules-DuMFRlit.cjs.map} +1 -1
- package/dist/replay-Cab-lSit.cjs +2 -0
- package/dist/replay-Cab-lSit.cjs.map +1 -0
- package/dist/{replay-B0M8kWz_.js → replay-Dy6OiaOZ.js} +89 -62
- package/dist/replay-Dy6OiaOZ.js.map +1 -0
- package/dist/{reports-ojuMKGO7.cjs → reports-CGK9YQch.cjs} +2 -2
- package/dist/{reports-ojuMKGO7.cjs.map → reports-CGK9YQch.cjs.map} +1 -1
- package/dist/{reports--8APRLa-.js → reports-CX57-S9s.js} +3 -3
- package/dist/{reports--8APRLa-.js.map → reports-CX57-S9s.js.map} +1 -1
- package/dist/{resource-timing-BzR05rE-.js → resource-timing-CWVDCbrY.js} +4 -4
- package/dist/{resource-timing-BzR05rE-.js.map → resource-timing-CWVDCbrY.js.map} +1 -1
- package/dist/{resource-timing-pAG3ZhB5.cjs → resource-timing-DalulXiR.cjs} +2 -2
- package/dist/{resource-timing-pAG3ZhB5.cjs.map → resource-timing-DalulXiR.cjs.map} +1 -1
- package/dist/response-body-Cpz5__4g.cjs +3 -0
- package/dist/response-body-Cpz5__4g.cjs.map +1 -0
- package/dist/{response-body-BWvwKQ2p.js → response-body-yi92Rpvo.js} +100 -100
- package/dist/response-body-yi92Rpvo.js.map +1 -0
- package/dist/{rotation-BylN1B9e.js → rotation-ChBbNDE2.js} +24 -24
- package/dist/rotation-ChBbNDE2.js.map +1 -0
- package/dist/rotation-fTnNJcfH.cjs +2 -0
- package/dist/rotation-fTnNJcfH.cjs.map +1 -0
- package/dist/{sampling-zXA6r-Nw.js → sampling-DZTOD28D.js} +6 -6
- package/dist/{sampling-zXA6r-Nw.js.map → sampling-DZTOD28D.js.map} +1 -1
- package/dist/{sampling-B46LW0cy.cjs → sampling-wAVJIZXp.cjs} +2 -2
- package/dist/{sampling-B46LW0cy.cjs.map → sampling-wAVJIZXp.cjs.map} +1 -1
- package/dist/{sanitize-DjnR6RXR.js → sanitize-B2GKlSFp.js} +2 -2
- package/dist/{sanitize-DjnR6RXR.js.map → sanitize-B2GKlSFp.js.map} +1 -1
- package/dist/{sanitize-Qj6LuZqp.cjs → sanitize-BZdhoghq.cjs} +2 -2
- package/dist/{sanitize-Qj6LuZqp.cjs.map → sanitize-BZdhoghq.cjs.map} +1 -1
- package/dist/{sender-Bdp-TAS4.js → sender-BRSpc7R8.js} +175 -161
- package/dist/sender-BRSpc7R8.js.map +1 -0
- package/dist/sender-CFu98DAB.cjs +2 -0
- package/dist/sender-CFu98DAB.cjs.map +1 -0
- package/dist/storage/emergency-queue.d.cts +3 -1
- package/dist/storage/emergency-queue.d.ts +3 -1
- package/dist/storage/stored-context.d.cts +3 -2
- package/dist/storage/stored-context.d.ts +3 -2
- package/dist/stored-context-CPLlzgpm.cjs +2 -0
- package/dist/stored-context-CPLlzgpm.cjs.map +1 -0
- package/dist/{stored-context-CSttrAsw.js → stored-context-df1dEnht.js} +10 -8
- package/dist/stored-context-df1dEnht.js.map +1 -0
- package/dist/{storm-DKlpv0FL.js → storm-U3_ek1nA.js} +2 -2
- package/dist/{storm-DKlpv0FL.js.map → storm-U3_ek1nA.js.map} +1 -1
- package/dist/{storm-BHgI12iS.cjs → storm-qiE_AMC7.cjs} +2 -2
- package/dist/{storm-BHgI12iS.cjs.map → storm-qiE_AMC7.cjs.map} +1 -1
- package/dist/transport/exit-flush.d.cts +23 -0
- package/dist/transport/exit-flush.d.ts +23 -0
- package/dist/transport/http-transport.d.cts +3 -2
- package/dist/transport/http-transport.d.ts +3 -2
- package/dist/transport/retry-engine.d.cts +11 -3
- package/dist/transport/retry-engine.d.ts +11 -3
- package/dist/types-BAerHgCq.js.map +1 -1
- package/dist/types-C7WNpnG1.cjs.map +1 -1
- package/dist/{unclean-exit-BcOB8A2e.js → unclean-exit-Bj6gYHeL.js} +2 -2
- package/dist/{unclean-exit-BcOB8A2e.js.map → unclean-exit-Bj6gYHeL.js.map} +1 -1
- package/dist/{unclean-exit-BYPYYkQ5.cjs → unclean-exit-CuBh-ee5.cjs} +2 -2
- package/dist/{unclean-exit-BYPYYkQ5.cjs.map → unclean-exit-CuBh-ee5.cjs.map} +1 -1
- package/dist/{user-timing-BsU2wQKE.cjs → user-timing-BWqzYF2Q.cjs} +2 -2
- package/dist/{user-timing-BsU2wQKE.cjs.map → user-timing-BWqzYF2Q.cjs.map} +1 -1
- package/dist/{user-timing-4KIJ74Vi.js → user-timing-Duz0d-OA.js} +2 -2
- package/dist/{user-timing-4KIJ74Vi.js.map → user-timing-Duz0d-OA.js.map} +1 -1
- package/dist/utils/lock.d.cts +3 -2
- package/dist/utils/lock.d.ts +3 -2
- package/dist/utils/openfin.d.cts +18 -6
- package/dist/utils/openfin.d.ts +18 -6
- package/dist/utils/patch.d.cts +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/platform.d.cts +6 -0
- package/dist/utils/platform.d.ts +6 -0
- package/dist/{web-socket-Zg0hj1LB.js → web-socket-CE_9Q22z.js} +5 -5
- package/dist/{web-socket-Zg0hj1LB.js.map → web-socket-CE_9Q22z.js.map} +1 -1
- package/dist/{web-socket-Cs1ZbmmN.cjs → web-socket-sm3rD-A_.cjs} +2 -2
- package/dist/{web-socket-Cs1ZbmmN.cjs.map → web-socket-sm3rD-A_.cjs.map} +1 -1
- package/dist/{web-vitals-4pWACwaR.js → web-vitals-CGwXGF-M.js} +4 -4
- package/dist/web-vitals-CGwXGF-M.js.map +1 -0
- package/dist/web-vitals-Df4Wsfx9.cjs +2 -0
- package/dist/web-vitals-Df4Wsfx9.cjs.map +1 -0
- package/dist/{worker-protocol-DFYXIFus.cjs → worker-protocol-D5VnCdWY.cjs} +2 -2
- package/dist/{worker-protocol-DFYXIFus.cjs.map → worker-protocol-D5VnCdWY.cjs.map} +1 -1
- package/dist/{worker-protocol-CYpAbrVl.js → worker-protocol-h4-tRWqy.js} +6 -6
- package/dist/{worker-protocol-CYpAbrVl.js.map → worker-protocol-h4-tRWqy.js.map} +1 -1
- package/dist/{worker-server--yGTadTA.cjs → worker-server-CF1yatXq.cjs} +2 -2
- package/dist/{worker-server--yGTadTA.cjs.map → worker-server-CF1yatXq.cjs.map} +1 -1
- package/dist/worker-server-FYfKHQhJ.js +94 -0
- package/dist/{worker-server-BokySIII.js.map → worker-server-FYfKHQhJ.js.map} +1 -1
- package/dist/{worker-transport-BdEvh_-a.cjs → worker-transport-COgY4RX8.cjs} +2 -2
- package/dist/{worker-transport-BdEvh_-a.cjs.map → worker-transport-COgY4RX8.cjs.map} +1 -1
- package/dist/{worker-transport-JK-Fby9J.js → worker-transport-jzX1IusG.js} +34 -34
- package/dist/{worker-transport-JK-Fby9J.js.map → worker-transport-jzX1IusG.js.map} +1 -1
- package/llms.txt +1 -2
- package/package.json +1 -1
- package/dist/bus-B__467mL.cjs +0 -2
- package/dist/bus-B__467mL.cjs.map +0 -1
- package/dist/bus-dw7T92sO.js.map +0 -1
- package/dist/config-CSNcS7OZ.js.map +0 -1
- package/dist/config-CybPP5VM.cjs +0 -2
- package/dist/config-CybPP5VM.cjs.map +0 -1
- package/dist/constants-BwJDXzj6.js.map +0 -1
- package/dist/constants-CtF52hIV.cjs +0 -2
- package/dist/constants-CtF52hIV.cjs.map +0 -1
- package/dist/errors-DP2RUm4V.cjs +0 -3
- package/dist/errors-DP2RUm4V.cjs.map +0 -1
- package/dist/errors-Q3Ng1ciC.js.map +0 -1
- package/dist/factory-DV17sm2p.js.map +0 -1
- package/dist/factory-K8O6gpux.cjs +0 -2
- package/dist/factory-K8O6gpux.cjs.map +0 -1
- package/dist/interactions-Byxf1C82.js.map +0 -1
- package/dist/interactions-OK85T-Dk.cjs.map +0 -1
- package/dist/patch-BX8KrPCT.cjs +0 -2
- package/dist/patch-BX8KrPCT.cjs.map +0 -1
- package/dist/patch-UdPz1ea8.js +0 -8
- package/dist/patch-UdPz1ea8.js.map +0 -1
- package/dist/platform-8DLhjddo.js.map +0 -1
- package/dist/platform-BqRc-7RO.cjs +0 -2
- package/dist/platform-BqRc-7RO.cjs.map +0 -1
- package/dist/replay-B0M8kWz_.js.map +0 -1
- package/dist/replay-QOFBpAXh.cjs +0 -2
- package/dist/replay-QOFBpAXh.cjs.map +0 -1
- package/dist/response-body-BWvwKQ2p.js.map +0 -1
- package/dist/response-body-CKEJ5itk.cjs +0 -3
- package/dist/response-body-CKEJ5itk.cjs.map +0 -1
- package/dist/rotation-BylN1B9e.js.map +0 -1
- package/dist/rotation-E2eKClIs.cjs +0 -2
- package/dist/rotation-E2eKClIs.cjs.map +0 -1
- package/dist/sender-Bdp-TAS4.js.map +0 -1
- package/dist/sender-DR7ZycZY.cjs +0 -2
- package/dist/sender-DR7ZycZY.cjs.map +0 -1
- package/dist/stored-context-BOu54M8Y.cjs +0 -2
- package/dist/stored-context-BOu54M8Y.cjs.map +0 -1
- package/dist/stored-context-CSttrAsw.js.map +0 -1
- package/dist/web-vitals-4pWACwaR.js.map +0 -1
- package/dist/web-vitals-__X7t4pj.cjs +0 -2
- package/dist/web-vitals-__X7t4pj.cjs.map +0 -1
- package/dist/worker-server-BokySIII.js +0 -94
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-Cg1L2w2r.js","names":["SERVER_TIMING_MAX_CHARS","SERVER_TIMING_HEADER","isErrorLike","isTransportPending","isLibraryRequest","patch","recordedUrl","matchesAny","_defineProperty","splitHeader","parts","start","quoted","escaped","i","text","char","separator","xhrServerTiming","headers","readServerTiming","result","header","part","rawName","params","name","entry","seen","param","equal","key","value","duration","match","MS_PER_SECOND","HTTP_DURATION","durationAttributes","base","attributes","method","url","status","error","xhrMethods","readUrl","input","readFetchMethod","requested","init","toMethod","isForeignInput","isEmptyInit","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","own","trace","rebuilt","ignored","propagates","meta","proto","restoreOpen","rest","originalOpen","restoreSend","args","addTraceHeaders","originalSend","routingContextId","timing","span","endMs","rounded"],"sources":["../src/capture/server-timing.ts","../src/capture/network.ts"],"sourcesContent":["import { SERVER_TIMING_MAX_CHARS, SERVER_TIMING_MAX_ENTRIES } from \"../constants\";\n\n/** One duration entry from the Server-Timing response header. */\ninterface ServerTimingEntry {\n name: string;\n duration: number;\n description: string;\n}\n\n/** Server duration entries, plus the server span they name. */\nexport interface ServerTiming {\n entries: ServerTimingEntry[];\n link?: { traceId: string; spanId: string };\n}\n\n/** Splits a header on separators outside quoted strings. An escaped quote doesn't end a string. */\nfunction splitHeader(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let quoted = false;\n let escaped = false;\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n if (escaped) {\n escaped = false;\n } else if (quoted && char === \"\\\\\") {\n escaped = true;\n } else if (char === '\"') {\n quoted = !quoted;\n } else if (!quoted && char === separator) {\n parts.push(text.slice(start, i));\n start = i + 1;\n }\n }\n\n parts.push(text.slice(start));\n return parts;\n}\n\n/** Finds the header in an XHR header list. Reading a hidden header directly logs a Chrome error. */\nexport function xhrServerTiming(headers: string): string | null {\n return /^server-timing:(.*)$/im.exec(headers)?.[1] ?? null;\n}\n\n/** Reads a bounded number of server duration entries. A missing header gives none. */\nexport function readServerTiming(header: string | null): ServerTiming {\n const result: ServerTiming = { entries: [] };\n if (!header) {\n return result;\n }\n\n for (const part of splitHeader(header.slice(0, SERVER_TIMING_MAX_CHARS), \",\").slice(\n 0,\n SERVER_TIMING_MAX_ENTRIES,\n )) {\n const [rawName, ...params] = splitHeader(part, \";\");\n const name = rawName.trim();\n if (!/^[!#$%&'*+.^_`|~\\da-z-]+$/i.test(name)) {\n continue;\n }\n\n const entry: ServerTimingEntry = { name, duration: 0, description: \"\" };\n const seen = new Set<string>();\n for (const param of params) {\n const equal = param.indexOf(\"=\");\n if (equal < 0) {\n continue;\n }\n\n const key = param.slice(0, equal).trim().toLowerCase();\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n\n let value = param.slice(equal + 1).trim();\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1).replace(/\\\\(.)/g, \"$1\");\n }\n\n if (key === \"dur\") {\n const duration = Number(value);\n if (Number.isFinite(duration) && duration >= 0) {\n entry.duration = duration;\n }\n } else if (key === \"desc\") {\n entry.description = value;\n }\n }\n\n result.entries.push(entry);\n if (name.toLowerCase() === \"traceparent\") {\n const match = /^00-([\\da-f]{32})-([\\da-f]{16})-[\\da-f]{2}$/.exec(entry.description);\n if (match && /[1-9a-f]/.test(match[1]) && /[1-9a-f]/.test(match[2])) {\n result.link = { traceId: match[1], spanId: match[2] };\n }\n }\n }\n\n return result;\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record the outcome and timing of network requests.\n\nimport { SERVER_TIMING_HEADER, TRACEPARENT_HEADER } from \"../constants\";\nimport { readServerTiming, xhrServerTiming } from \"./server-timing\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { isLibraryRequest, isTransportPending } from \"../utils/library-request\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { ClientSpan } from \"../utils/tracing\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** Milliseconds in one second. The histogram is in seconds, as its OpenTelemetry name says. */\nconst MS_PER_SECOND = 1000;\n\n/**\n * The HTTP client duration histogram from the OpenTelemetry semantic conventions, with the\n * boundaries the conventions recommend.\n */\nconst HTTP_DURATION: InstrumentDef = {\n name: \"http.client.request.duration\",\n kind: \"histogram\",\n unit: \"s\",\n boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n};\n\n/**\n * Builds the low-cardinality attributes for one request. The path and the query stay out,\n * because every distinct attribute value creates a new series in the backend.\n * @param method Uppercase HTTP method.\n * @param url Request URL.\n * @param status HTTP status code, or 0 when no response came.\n * @param error What failed, for a request with no response.\n * @returns The attribute set.\n */\nfunction durationAttributes(\n method: string,\n url: string,\n status: number,\n error: unknown,\n): MetricAttributes {\n // A relative URL needs the page URL as its base. A worker has a location too.\n const base = typeof location !== \"undefined\" ? location.href : undefined;\n const attributes: MetricAttributes = {\n \"http.request.method\": method,\n \"server.address\": new URL(url, base).hostname,\n };\n\n if (status === 0) {\n // A request with no response takes its error's type, for example TypeError.\n const name = isErrorLike(error) ? error.name : \"\";\n attributes[\"error.type\"] = name === \"\" ? \"_OTHER\" : name;\n return attributes;\n }\n\n attributes[\"http.response.status_code\"] = status;\n if (status >= 400) {\n attributes[\"error.type\"] = String(status);\n }\n\n return attributes;\n}\n\n/** Request data the XHR wrapper keeps from open to send. */\ninterface XhrMeta {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Performance timestamp at send. */\n startedAt: number;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/** An XMLHttpRequest with our tracking metadata attached. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: XhrMeta;\n};\n\n/** The XMLHttpRequest prototype methods we wrap, kept unbound. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** The fetch call to make, and the method and URL to record. */\ninterface FetchPlan {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Input to pass to the original fetch. */\n input: RequestInfo | URL;\n /** Init to pass to the original fetch. */\n init: RequestInit | undefined;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/**\n * Reads the URL from a fetch input or an XHR URL argument.\n * A Request from another realm fails `instanceof Request`, but its `url` property still works.\n * @param input String, URL, Request, or an object with a text form.\n * @returns The URL.\n * @throws TypeError when the input has no text form. Call it inside a diagnostics guard.\n */\nfunction readUrl(input: unknown): string {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const { url } = input as { url?: unknown };\n if (typeof url === \"string\") {\n return url;\n }\n }\n\n // fetch accepts anything with a text form.\n return String(input);\n}\n\n/**\n * Reads the method of a fetch call. The init's method wins over the Request's.\n * @param input Fetch input.\n * @param init Fetch init.\n * @returns Uppercase method. Defaults to GET.\n */\nfunction readFetchMethod(input: unknown, init: RequestInit | undefined): string {\n let requested: unknown = init?.method;\n\n if (requested === undefined && typeof input === \"object\" && input !== null) {\n requested = (input as { method?: unknown }).method;\n }\n\n return toMethod(requested ?? \"GET\");\n}\n\n/**\n * Checks whether a fetch input is an object that isn't a Request or a URL from this realm,\n * for example a Request from an iframe.\n * @param input Fetch input.\n * @returns True for a foreign object.\n */\nfunction isForeignInput(input: unknown): boolean {\n return typeof input === \"object\" && !(input instanceof URL) && !(input instanceof Request);\n}\n\n/**\n * Checks whether a fetch init sets nothing, for example {}. Like fetch(request), the call\n * fetch(request, {}) keeps the Request's referrer, and any other init resets it.\n * @param init The caller's fetch init.\n * @returns True when no member has a value.\n */\nfunction isEmptyInit(init: RequestInit | undefined): boolean {\n return init === undefined || Object.values(init).every((value) => value === undefined);\n}\n\n/**\n * Converts a method argument to text. Never throws on a method that isn't a string.\n * @param method The caller's method argument.\n * @returns The uppercase method for a string, or the text form of anything else.\n */\nfunction toMethod(method: unknown): string {\n return typeof method === \"string\" ? method.toUpperCase() : String(method);\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Guards against wrapping a function twice. */\n private installed = false;\n\n /** Restore functions for the installed wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** True once we've reported a request made during a custom transport call. Reported once. */\n private warnedTransport = false;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments the network APIs the configuration selects. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /**\n * Restores every host function that still holds this capture's wrapper.\n * A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n }\n\n /**\n * Checks whether a URL matches the ignore patterns.\n * @param url Request target URL.\n * @returns True if the URL must stay out of the telemetry.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Otherwise a failed POST becomes a\n // log record, the record causes a new POST, and the loop never stops.\n // A custom transport has no known URL, but its request starts inside the library scope.\n return isLibraryRequest() || matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /**\n * Checks whether a request gets the trace headers.\n * @param url Request target URL.\n * @returns True if the URL is in propagateTraceHeaderTo.\n */\n private propagates(url: string): boolean {\n // Only add headers to allowlisted URLs. A traceparent on a third-party request triggers\n // a CORS preflight that the third party doesn't answer, and its API stops working.\n const targets = this.ctx.config.capture.propagateTraceHeaderTo;\n if (targets.length === 0) {\n return false;\n }\n\n // A string target is an origin. A relative URL resolves against the page.\n const origin = this.ctx.diagnostics.guard(\n \"capture.header_failed\",\n \"The library could not read the origin of a request URL. Only a RegExp target can match it.\",\n () => new URL(url, location.href).origin,\n );\n\n return targets.some((target) =>\n typeof target === \"string\" ? target === origin : target.test(url),\n );\n }\n\n /** Wraps globalThis.fetch to inject the trace headers and log the outcome. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const prepare = (input: RequestInfo | URL, init: RequestInit | undefined) =>\n this.prepareFetch(input, init);\n const record = (\n plan: FetchPlan,\n status: number,\n durationMs: number,\n error: unknown,\n readTiming?: () => string | null,\n ): void => {\n this.record(\n plan.method,\n plan.url,\n status,\n durationMs,\n error,\n plan.span,\n plan.routingContextId,\n readTiming,\n );\n };\n\n const restore = patch(globalThis, \"fetch\", (original: FetchFn) => {\n const call = original.bind(globalThis);\n\n return async function instrumentedFetch(input, init) {\n const plan = active ? prepare(input, init) : undefined;\n if (!plan) {\n return call(input, init);\n }\n\n const startedAt = performance.now();\n try {\n const response = await call(plan.input, plan.init);\n record(plan, response.status, performance.now() - startedAt, undefined, () =>\n response.headers.get(SERVER_TIMING_HEADER),\n );\n return response;\n } catch (error) {\n record(plan, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n });\n\n this.restores.push(() => {\n active = false;\n restore();\n });\n }\n\n /**\n * Reads a fetch call and adds the trace headers to an allowlisted request.\n * @param input The caller's fetch input.\n * @param init The caller's fetch init.\n * @returns The plan, or undefined to send the request unchanged and record nothing.\n */\n private prepareFetch(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n ): FetchPlan | undefined {\n // This read runs inside the caller's fetch call, so a throw must not fail the request.\n const read = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a fetch request. It sends the request unchanged.\",\n (): { method: string; url: string; propagate: boolean } | undefined => {\n const url = readUrl(input);\n if (this.ignored(url)) {\n return undefined;\n }\n\n return { method: readFetchMethod(input, init), url, propagate: this.propagates(url) };\n },\n );\n\n if (!read) {\n return undefined;\n }\n\n const { method, url } = read;\n const plan: FetchPlan = {\n method,\n url,\n input,\n init,\n routingContextId: this.ctx.config.securityContext.id,\n };\n // An init with headers replaces every header on a foreign Request, Authorization\n // included. So a foreign input goes out without the trace headers.\n if (!read.propagate || isForeignInput(input)) {\n return plan;\n }\n\n try {\n // fetch(request, init) builds new Request(request, init), and init.headers then replaces\n // every header the Request had. So work on the headers that actually go out.\n const own = input instanceof Request ? input.headers : undefined;\n const headers = new Headers(init?.headers ?? own);\n\n // The caller runs its own trace, for example with OpenTelemetry, so don't break it.\n if (headers.has(TRACEPARENT_HEADER)) {\n this.ctx.diagnostics.report(\n \"capture.trace_header_kept\",\n \"The request already has a traceparent header. The library keeps it and records no \" +\n \"client span.\",\n { url },\n );\n return plan;\n }\n\n const trace = this.ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n headers.set(key, value);\n }\n\n if (input instanceof Request) {\n const rebuilt: RequestInit = { ...init, headers };\n // Our rebuild has headers, which resets the referrer, so keep it when the caller's didn't.\n if (isEmptyInit(init)) {\n rebuilt.referrer = input.referrer;\n rebuilt.referrerPolicy = input.referrerPolicy;\n }\n\n // Build the Request once with the caller's whole init, as fetch would, and pass no init\n // next to it. Otherwise fetch builds it again and reads the body twice, which throws.\n plan.input = new Request(input, rebuilt);\n plan.init = undefined;\n } else {\n plan.init = { ...init, headers };\n }\n\n // Only record the client span for a request that actually carries its traceparent.\n plan.span = trace.span;\n } catch (error) {\n // Send exactly what the caller gave us. A missing header is better than a failed\n // request.\n plan.input = input;\n plan.init = init;\n this.ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n\n return plan;\n }\n\n /** Wraps the open and send methods on the XMLHttpRequest prototype. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const propagates = (url: string): boolean => this.propagates(url);\n const record = (\n meta: XhrMeta,\n status: number,\n durationMs: number,\n readTiming: () => string | null,\n ): void => {\n this.record(\n meta.method,\n meta.url,\n status,\n durationMs,\n undefined,\n meta.span,\n meta.routingContextId,\n readTiming,\n );\n };\n\n const proto = xhrMethods();\n\n const restoreOpen = patch(\n proto,\n \"open\",\n (originalOpen) =>\n function (this: Tracked, method: unknown, url: unknown, ...rest: never[]) {\n if (active) {\n // This read runs inside the caller's open call, so a throw must not fail it.\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read an XMLHttpRequest. It does not record the request.\",\n () => {\n this.__uiobs = { method: toMethod(method), url: readUrl(url), startedAt: 0 };\n },\n );\n }\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n },\n );\n\n const restoreSend = patch(\n proto,\n \"send\",\n (originalSend) =>\n function (this: Tracked, ...args: never[]) {\n const meta = active ? this.__uiobs : undefined;\n if (meta) {\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${meta.method} ${meta.url}.`,\n () => {\n if (ignored(meta.url)) {\n return;\n }\n\n meta.startedAt = performance.now();\n meta.routingContextId = ctx.config.securityContext.id;\n // A reused XHR gets a new listener on every send, so the old one must not\n // fire again.\n this.addEventListener(\n \"loadend\",\n () => {\n record(meta, this.status, performance.now() - meta.startedAt, () =>\n xhrServerTiming(this.getAllResponseHeaders()),\n );\n },\n { once: true },\n );\n\n // setRequestHeader only works between open and send.\n if (propagates(meta.url)) {\n meta.span = addTraceHeaders(this, meta.url, ctx);\n }\n },\n );\n }\n originalSend.apply(this, args);\n },\n );\n\n this.restores.push(() => {\n active = false;\n restoreOpen();\n restoreSend();\n });\n }\n\n /**\n * Records the outcome of a request as attributes and a breadcrumb.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The query is removed here unless you set fullUrls.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error The caught error, for a failed request.\n * @param span The client span the request's traceparent names.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n span?: ClientSpan,\n routingContextId?: string,\n readTiming?: () => string | null,\n ): void {\n if (\n this.ctx.isActive?.() === false ||\n (this.ctx.config.securityContext.isolation &&\n routingContextId !== undefined &&\n routingContextId !== this.ctx.config.securityContext.id)\n ) {\n return;\n }\n\n const timing =\n this.ctx.config.capture.serverTiming && readTiming\n ? this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the Server-Timing response header.\",\n () => readServerTiming(readTiming()),\n )\n : undefined;\n\n // Strip the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL, and only the recorded URL loses its query string.\n const url = recordedUrl(\n target,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n // A transport request made after an await gets recorded, and that record causes the next\n // send.\n if (!this.warnedTransport && isTransportPending()) {\n this.warnedTransport = true;\n this.ctx.diagnostics.report(\n \"capture.transport_request\",\n `Network capture saw ${method} ${url} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`,\n );\n }\n\n // The histogram has its own guard, so a URL that doesn't parse can't stop the record.\n if (this.ctx.config.capture.httpMetrics) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the duration of ${method} ${url}.`,\n () => {\n const attributes = durationAttributes(method, target, status, error);\n this.ctx.recordMetric(HTTP_DURATION, durationMs / MS_PER_SECOND, attributes);\n },\n );\n }\n\n if (span) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the span of ${method} ${url}.`,\n () => {\n const endMs = Date.now();\n this.ctx.recordSpan({\n ...span,\n link: timing?.link,\n name: method,\n kind: \"client\",\n startMs: endMs - durationMs,\n endMs,\n error: status === 0 || status >= 400,\n attributes: { ...durationAttributes(method, target, status, error), \"url.full\": url },\n });\n },\n );\n }\n\n // This runs inside the caller's fetch call, so an error here must not fail the caller's\n // request.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n ...(timing && timing.entries.length > 0 ? { \"server.timing\": timing.entries } : {}),\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG, which the default minLevel of INFO drops. That way only\n // failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n\n/**\n * Adds the trace headers to an open XHR. If that fails, the request goes out without them.\n * @param xhr A request between open and send.\n * @param url Request target URL, for the diagnostic.\n * @param ctx Capture context with tracing and diagnostics.\n * @returns The client span the traceparent names, or undefined.\n */\nfunction addTraceHeaders(\n xhr: XMLHttpRequest,\n url: string,\n ctx: CaptureContext,\n): ClientSpan | undefined {\n try {\n const trace = ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n xhr.setRequestHeader(key, value);\n }\n return trace.span;\n } catch (error) {\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;AAgBA,SAASS,EAAY,GAAc,GAA6B;CAC9D,IAAMC,IAAkB,CAAC,GACrBC,IAAQ,GACRC,IAAS,IACTC,IAAU;CAEd,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAK,QAAQ,KAAK;EACpC,IAAMC,IAAOD,EAAKD;EAClB,AAAID,IACF,IAAU,KACDD,KAAUI,MAAS,OAC5B,IAAU,KACDA,MAAS,OAClB,IAAS,CAACJ,IACD,CAACA,KAAUI,MAASC,MAC7BP,EAAM,KAAKK,EAAK,MAAMJ,GAAOG,CAAC,CAAC,GAC/B,IAAQA,IAAI;CAEhB;CAGA,OADAJ,EAAM,KAAKK,EAAK,MAAMJ,CAAK,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GvB,EAAO,GAAGC,EAAI,GAAGC,MAAW,IAAI,WAAW,OAAOA,CAAM;IACpE,MAAM,EAAE,YAAY8C,EAAQ;GAC9B,CAAC;GAED,IAAMjD,IAAa;IACjB,uBAAuBC;IACvB,YAAYC;IACZ,6BAA6BC;IAC7B,oBAAoB8C;IACpB,GAAIH,KAAUA,EAAO,QAAQ,SAAS,IAAI,EAAE,iBAAiBA,EAAO,QAAQ,IAAI,CAAC;GACnF;GAEA,AAAI3C,MAAW,IACb,KAAK,IAAI,OAAO,MAAM,GAAGF,EAAO,GAAGC,EAAI,UAAUE,GAAOJ,CAAU,IAGhEG,KAAU,MACZ,KAAK,IAAI,OAAO,KAAK,GAAGF,EAAO,GAAGC,EAAI,YAAY,OAAOC,CAAM,KAAKH,CAAU,IAMhF,KAAK,IAAI,OAAO,MAAM,GAAGC,EAAO,GAAGC,KAAOF,CAAU;EACtD,CACF;CACF;AACF;AASA,SAAS2C,EACP,GACA,GACA,GACwB;CACxB,IAAI;EACF,IAAMX,IAAQjB,EAAI,QAAQ,QAAQ;EAClC,KAAK,IAAM,CAACvB,GAAKC,MAAU,OAAO,QAAQuC,EAAM,OAAO,GACrD,EAAI,iBAAiBxC,GAAKC,CAAK;EAEjC,OAAOuC,EAAM;CACf,SAAS5B,GAAO;EACd,EAAI,YAAY,OACd,yBACA,qFACA,EAAE,OAAI,GACNA,CACF;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"network-Cc3tSB7e.js","names":["SERVER_TIMING_HEADER","SERVER_TIMING_MAX_CHARS","isErrorLike","isTransportPending","isLibraryRequest","patch","recordedUrl","matchesAny","_defineProperty","splitHeader","parts","start","quoted","escaped","i","text","char","separator","xhrServerTiming","headers","readServerTiming","result","header","part","rawName","params","name","entry","seen","param","equal","key","value","duration","match","MS_PER_SECOND","HTTP_DURATION","durationAttributes","base","attributes","method","url","status","error","xhrMethods","readUrl","input","readFetchMethod","requested","init","toMethod","isForeignInput","isEmptyInit","NetworkCapture","ctx","restore","targets","origin","target","active","prepare","record","plan","durationMs","readTiming","call","original","startedAt","response","read","own","trace","rebuilt","ignored","propagates","meta","proto","restoreOpen","rest","originalOpen","restoreSend","args","addTraceHeaders","originalSend","routingContextId","timing","span","endMs","rounded"],"sources":["../src/capture/server-timing.ts","../src/capture/network.ts"],"sourcesContent":["import { SERVER_TIMING_MAX_CHARS, SERVER_TIMING_MAX_ENTRIES } from \"../constants\";\n\n/** One duration entry from the Server-Timing response header. */\ninterface ServerTimingEntry {\n name: string;\n duration: number;\n description: string;\n}\n\n/** Server duration entries, plus the server span they name. */\nexport interface ServerTiming {\n entries: ServerTimingEntry[];\n link?: { traceId: string; spanId: string };\n}\n\n/** Splits a header on separators outside quoted strings. An escaped quote doesn't end a string. */\nfunction splitHeader(text: string, separator: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let quoted = false;\n let escaped = false;\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n if (escaped) {\n escaped = false;\n } else if (quoted && char === \"\\\\\") {\n escaped = true;\n } else if (char === '\"') {\n quoted = !quoted;\n } else if (!quoted && char === separator) {\n parts.push(text.slice(start, i));\n start = i + 1;\n }\n }\n\n parts.push(text.slice(start));\n return parts;\n}\n\n/** Finds the header in an XHR header list. Reading a hidden header directly logs a Chrome error. */\nexport function xhrServerTiming(headers: string): string | null {\n return /^server-timing:(.*)$/im.exec(headers)?.[1] ?? null;\n}\n\n/** Reads a bounded number of server duration entries. A missing header gives none. */\nexport function readServerTiming(header: string | null): ServerTiming {\n const result: ServerTiming = { entries: [] };\n if (!header) {\n return result;\n }\n\n for (const part of splitHeader(header.slice(0, SERVER_TIMING_MAX_CHARS), \",\").slice(\n 0,\n SERVER_TIMING_MAX_ENTRIES,\n )) {\n const [rawName, ...params] = splitHeader(part, \";\");\n const name = rawName.trim();\n if (!/^[!#$%&'*+.^_`|~\\da-z-]+$/i.test(name)) {\n continue;\n }\n\n const entry: ServerTimingEntry = { name, duration: 0, description: \"\" };\n const seen = new Set<string>();\n for (const param of params) {\n const equal = param.indexOf(\"=\");\n if (equal < 0) {\n continue;\n }\n\n const key = param.slice(0, equal).trim().toLowerCase();\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n\n let value = param.slice(equal + 1).trim();\n if (value.startsWith('\"') && value.endsWith('\"')) {\n value = value.slice(1, -1).replace(/\\\\(.)/g, \"$1\");\n }\n\n if (key === \"dur\") {\n const duration = Number(value);\n if (Number.isFinite(duration) && duration >= 0) {\n entry.duration = duration;\n }\n } else if (key === \"desc\") {\n entry.description = value;\n }\n }\n\n result.entries.push(entry);\n if (name.toLowerCase() === \"traceparent\") {\n const match = /^00-([\\da-f]{32})-([\\da-f]{16})-[\\da-f]{2}$/.exec(entry.description);\n if (match && /[1-9a-f]/.test(match[1]) && /[1-9a-f]/.test(match[2])) {\n result.link = { traceId: match[1], spanId: match[2] };\n }\n }\n }\n\n return result;\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record the outcome and timing of network requests.\n\nimport { SERVER_TIMING_HEADER, TRACEPARENT_HEADER } from \"../constants\";\nimport { readServerTiming, xhrServerTiming } from \"./server-timing\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { isLibraryRequest, isTransportPending } from \"../utils/library-request\";\nimport { patch } from \"../utils/patch\";\nimport { recordedUrl } from \"../utils/platform\";\nimport type { ClientSpan } from \"../utils/tracing\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** Milliseconds in one second. The histogram is in seconds, as its OpenTelemetry name says. */\nconst MS_PER_SECOND = 1000;\n\n/**\n * The HTTP client duration histogram from the OpenTelemetry semantic conventions, with the\n * boundaries the conventions recommend.\n */\nconst HTTP_DURATION: InstrumentDef = {\n name: \"http.client.request.duration\",\n kind: \"histogram\",\n unit: \"s\",\n boundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n};\n\n/**\n * Builds the low-cardinality attributes for one request. The path and the query stay out,\n * because every distinct attribute value creates a new series in the backend.\n * @param method Uppercase HTTP method.\n * @param url Request URL.\n * @param status HTTP status code, or 0 when no response came.\n * @param error What failed, for a request with no response.\n * @returns The attribute set.\n */\nfunction durationAttributes(\n method: string,\n url: string,\n status: number,\n error: unknown,\n): MetricAttributes {\n // A relative URL needs the page URL as its base. A worker has a location too.\n const base = typeof location !== \"undefined\" ? location.href : undefined;\n const attributes: MetricAttributes = {\n \"http.request.method\": method,\n \"server.address\": new URL(url, base).hostname,\n };\n\n if (status === 0) {\n // A request with no response takes its error's type, for example TypeError.\n const name = isErrorLike(error) ? error.name : \"\";\n attributes[\"error.type\"] = name === \"\" ? \"_OTHER\" : name;\n return attributes;\n }\n\n attributes[\"http.response.status_code\"] = status;\n if (status >= 400) {\n attributes[\"error.type\"] = String(status);\n }\n\n return attributes;\n}\n\n/** Request data the XHR wrapper keeps from open to send. */\ninterface XhrMeta {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Performance timestamp at send. */\n startedAt: number;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/** An XMLHttpRequest with our tracking metadata attached. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: XhrMeta;\n};\n\n/** The XMLHttpRequest prototype methods we wrap, kept unbound. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** The fetch call to make, and the method and URL to record. */\ninterface FetchPlan {\n /** The delivery context when the request started. */\n routingContextId?: string;\n /** Uppercase HTTP method. */\n method: string;\n /** Request target URL. */\n url: string;\n /** Input to pass to the original fetch. */\n input: RequestInfo | URL;\n /** Init to pass to the original fetch. */\n init: RequestInit | undefined;\n /** The client span the traceparent names. */\n span?: ClientSpan;\n}\n\n/**\n * Reads the URL from a fetch input or an XHR URL argument.\n * A Request from another realm fails `instanceof Request`, but its `url` property still works.\n * @param input String, URL, Request, or an object with a text form.\n * @returns The URL.\n * @throws TypeError when the input has no text form. Call it inside a diagnostics guard.\n */\nfunction readUrl(input: unknown): string {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const { url } = input as { url?: unknown };\n if (typeof url === \"string\") {\n return url;\n }\n }\n\n // fetch accepts anything with a text form.\n return String(input);\n}\n\n/**\n * Reads the method of a fetch call. The init's method wins over the Request's.\n * @param input Fetch input.\n * @param init Fetch init.\n * @returns Uppercase method. Defaults to GET.\n */\nfunction readFetchMethod(input: unknown, init: RequestInit | undefined): string {\n let requested: unknown = init?.method;\n\n if (requested === undefined && typeof input === \"object\" && input !== null) {\n requested = (input as { method?: unknown }).method;\n }\n\n return toMethod(requested ?? \"GET\");\n}\n\n/**\n * Checks whether a fetch input is an object that isn't a Request or a URL from this realm,\n * for example a Request from an iframe.\n * @param input Fetch input.\n * @returns True for a foreign object.\n */\nfunction isForeignInput(input: unknown): boolean {\n return typeof input === \"object\" && !(input instanceof URL) && !(input instanceof Request);\n}\n\n/**\n * Checks whether a fetch init sets nothing, for example {}. Like fetch(request), the call\n * fetch(request, {}) keeps the Request's referrer, and any other init resets it.\n * @param init The caller's fetch init.\n * @returns True when no member has a value.\n */\nfunction isEmptyInit(init: RequestInit | undefined): boolean {\n return init === undefined || Object.values(init).every((value) => value === undefined);\n}\n\n/**\n * Converts a method argument to text. Never throws on a method that isn't a string.\n * @param method The caller's method argument.\n * @returns The uppercase method for a string, or the text form of anything else.\n */\nfunction toMethod(method: unknown): string {\n return typeof method === \"string\" ? method.toUpperCase() : String(method);\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Guards against wrapping a function twice. */\n private installed = false;\n\n /** Restore functions for the installed wrappers. */\n private readonly restores: (() => void)[] = [];\n\n /** True once we've reported a request made during a custom transport call. Reported once. */\n private warnedTransport = false;\n\n /**\n * @param ctx Capture context: configuration, diagnostics, logger, breadcrumbs and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments the network APIs the configuration selects. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /**\n * Restores every host function that still holds this capture's wrapper.\n * A wrapper that another script wrapped again stays in place and records nothing.\n */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n for (const restore of this.restores.splice(0)) {\n restore();\n }\n }\n\n /**\n * Checks whether a URL matches the ignore patterns.\n * @param url Request target URL.\n * @returns True if the URL must stay out of the telemetry.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Otherwise a failed POST becomes a\n // log record, the record causes a new POST, and the loop never stops.\n // A custom transport has no known URL, but its request starts inside the library scope.\n return isLibraryRequest() || matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /**\n * Checks whether a request gets the trace headers.\n * @param url Request target URL.\n * @returns True if the URL is in propagateTraceHeaderTo.\n */\n private propagates(url: string): boolean {\n // Only add headers to allowlisted URLs. A traceparent on a third-party request triggers\n // a CORS preflight that the third party doesn't answer, and its API stops working.\n const targets = this.ctx.config.capture.propagateTraceHeaderTo;\n if (targets.length === 0) {\n return false;\n }\n\n // A string target is an origin. A relative URL resolves against the page.\n const origin = this.ctx.diagnostics.guard(\n \"capture.header_failed\",\n \"The library could not read the origin of a request URL. Only a RegExp target can match it.\",\n () => new URL(url, location.href).origin,\n );\n\n return targets.some((target) =>\n typeof target === \"string\" ? target === origin : target.test(url),\n );\n }\n\n /** Wraps globalThis.fetch to inject the trace headers and log the outcome. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const prepare = (input: RequestInfo | URL, init: RequestInit | undefined) =>\n this.prepareFetch(input, init);\n const record = (\n plan: FetchPlan,\n status: number,\n durationMs: number,\n error: unknown,\n readTiming?: () => string | null,\n ): void => {\n this.record(\n plan.method,\n plan.url,\n status,\n durationMs,\n error,\n plan.span,\n plan.routingContextId,\n readTiming,\n );\n };\n\n const restore = patch(globalThis, \"fetch\", (original: FetchFn) => {\n const call = original.bind(globalThis);\n\n return async function instrumentedFetch(input, init) {\n const plan = active ? prepare(input, init) : undefined;\n if (!plan) {\n return call(input, init);\n }\n\n const startedAt = performance.now();\n try {\n const response = await call(plan.input, plan.init);\n record(plan, response.status, performance.now() - startedAt, undefined, () =>\n response.headers.get(SERVER_TIMING_HEADER),\n );\n return response;\n } catch (error) {\n record(plan, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n });\n\n this.restores.push(() => {\n active = false;\n restore();\n });\n }\n\n /**\n * Reads a fetch call and adds the trace headers to an allowlisted request.\n * @param input The caller's fetch input.\n * @param init The caller's fetch init.\n * @returns The plan, or undefined to send the request unchanged and record nothing.\n */\n private prepareFetch(\n input: RequestInfo | URL,\n init: RequestInit | undefined,\n ): FetchPlan | undefined {\n // This read runs inside the caller's fetch call, so a throw must not fail the request.\n const read = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a fetch request. It sends the request unchanged.\",\n (): { method: string; url: string; propagate: boolean } | undefined => {\n const url = readUrl(input);\n if (this.ignored(url)) {\n return undefined;\n }\n\n return { method: readFetchMethod(input, init), url, propagate: this.propagates(url) };\n },\n );\n\n if (!read) {\n return undefined;\n }\n\n const { method, url } = read;\n const plan: FetchPlan = {\n method,\n url,\n input,\n init,\n routingContextId: this.ctx.config.securityContext.id,\n };\n // An init with headers replaces every header on a foreign Request, Authorization\n // included. So a foreign input goes out without the trace headers.\n if (!read.propagate || isForeignInput(input)) {\n return plan;\n }\n\n try {\n // fetch(request, init) builds new Request(request, init), and init.headers then replaces\n // every header the Request had. So work on the headers that actually go out.\n const own = input instanceof Request ? input.headers : undefined;\n const headers = new Headers(init?.headers ?? own);\n\n // The caller runs its own trace, for example with OpenTelemetry, so don't break it.\n if (headers.has(TRACEPARENT_HEADER)) {\n this.ctx.diagnostics.report(\n \"capture.trace_header_kept\",\n \"The request already has a traceparent header. The library keeps it and records no \" +\n \"client span.\",\n { url },\n );\n return plan;\n }\n\n const trace = this.ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n headers.set(key, value);\n }\n\n if (input instanceof Request) {\n const rebuilt: RequestInit = { ...init, headers };\n // Our rebuild has headers, which resets the referrer, so keep it when the caller's didn't.\n if (isEmptyInit(init)) {\n rebuilt.referrer = input.referrer;\n rebuilt.referrerPolicy = input.referrerPolicy;\n }\n\n // Build the Request once with the caller's whole init, as fetch would, and pass no init\n // next to it. Otherwise fetch builds it again and reads the body twice, which throws.\n plan.input = new Request(input, rebuilt);\n plan.init = undefined;\n } else {\n plan.init = { ...init, headers };\n }\n\n // Only record the client span for a request that actually carries its traceparent.\n plan.span = trace.span;\n } catch (error) {\n // Send exactly what the caller gave us. A missing header is better than a failed\n // request.\n plan.input = input;\n plan.init = init;\n this.ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n\n return plan;\n }\n\n /** Wraps the open and send methods on the XMLHttpRequest prototype. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\") {\n return;\n }\n\n // Uninstall clears the flag, so a wrapper that stays in place only calls the original.\n let active = true;\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const propagates = (url: string): boolean => this.propagates(url);\n const record = (\n meta: XhrMeta,\n status: number,\n durationMs: number,\n readTiming: () => string | null,\n ): void => {\n this.record(\n meta.method,\n meta.url,\n status,\n durationMs,\n undefined,\n meta.span,\n meta.routingContextId,\n readTiming,\n );\n };\n\n const proto = xhrMethods();\n\n const restoreOpen = patch(\n proto,\n \"open\",\n (originalOpen) =>\n function (this: Tracked, method: unknown, url: unknown, ...rest: never[]) {\n if (active) {\n // This read runs inside the caller's open call, so a throw must not fail it.\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read an XMLHttpRequest. It does not record the request.\",\n () => {\n this.__uiobs = { method: toMethod(method), url: readUrl(url), startedAt: 0 };\n },\n );\n }\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n },\n );\n\n const restoreSend = patch(\n proto,\n \"send\",\n (originalSend) =>\n function (this: Tracked, ...args: never[]) {\n const meta = active ? this.__uiobs : undefined;\n if (meta) {\n ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${meta.method} ${meta.url}.`,\n () => {\n if (ignored(meta.url)) {\n return;\n }\n\n meta.startedAt = performance.now();\n meta.routingContextId = ctx.config.securityContext.id;\n // A reused XHR gets a new listener on every send, so the old one must not\n // fire again.\n this.addEventListener(\n \"loadend\",\n () => {\n record(meta, this.status, performance.now() - meta.startedAt, () =>\n xhrServerTiming(this.getAllResponseHeaders()),\n );\n },\n { once: true },\n );\n\n // setRequestHeader only works between open and send.\n if (propagates(meta.url)) {\n meta.span = addTraceHeaders(this, meta.url, ctx);\n }\n },\n );\n }\n originalSend.apply(this, args);\n },\n );\n\n this.restores.push(() => {\n active = false;\n restoreOpen();\n restoreSend();\n });\n }\n\n /**\n * Records the outcome of a request as attributes and a breadcrumb.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The query is removed here unless you set fullUrls.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error The caught error, for a failed request.\n * @param span The client span the request's traceparent names.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n span?: ClientSpan,\n routingContextId?: string,\n readTiming?: () => string | null,\n ): void {\n if (\n this.ctx.isActive?.() === false ||\n (this.ctx.config.securityContext.isolation &&\n routingContextId !== undefined &&\n routingContextId !== this.ctx.config.securityContext.id)\n ) {\n return;\n }\n\n const timing =\n this.ctx.config.capture.serverTiming && readTiming\n ? this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the Server-Timing response header.\",\n () => readServerTiming(readTiming()),\n )\n : undefined;\n\n // Strip the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL, and only the recorded URL loses its query string.\n const url = recordedUrl(\n target,\n this.ctx.config.capture.fullUrls,\n this.ctx.config.capture.urlTransform,\n this.ctx.diagnostics,\n );\n\n // A transport request made after an await gets recorded, and that record causes the next\n // send.\n if (!this.warnedTransport && isTransportPending()) {\n this.warnedTransport = true;\n this.ctx.diagnostics.report(\n \"capture.transport_request\",\n `Network capture saw ${method} ${url} during a custom transport call. If the transport sends this request, add its URL to capture.ignoreUrls.`,\n );\n }\n\n // The histogram has its own guard, so a URL that doesn't parse can't stop the record.\n if (this.ctx.config.capture.httpMetrics) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the duration of ${method} ${url}.`,\n () => {\n const attributes = durationAttributes(method, target, status, error);\n this.ctx.recordMetric(HTTP_DURATION, durationMs / MS_PER_SECOND, attributes);\n },\n );\n }\n\n if (span) {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record the span of ${method} ${url}.`,\n () => {\n const endMs = Date.now();\n this.ctx.recordSpan({\n ...span,\n link: timing?.link,\n name: method,\n kind: \"client\",\n startMs: endMs - durationMs,\n endMs,\n error: status === 0 || status >= 400,\n attributes: { ...durationAttributes(method, target, status, error), \"url.full\": url },\n });\n },\n );\n }\n\n // This runs inside the caller's fetch call, so an error here must not fail the caller's\n // request.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n ...(timing && timing.entries.length > 0 ? { \"server.timing\": timing.entries } : {}),\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG, which the default minLevel of INFO drops. That way only\n // failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n\n/**\n * Adds the trace headers to an open XHR. If that fails, the request goes out without them.\n * @param xhr A request between open and send.\n * @param url Request target URL, for the diagnostic.\n * @param ctx Capture context with tracing and diagnostics.\n * @returns The client span the traceparent names, or undefined.\n */\nfunction addTraceHeaders(\n xhr: XMLHttpRequest,\n url: string,\n ctx: CaptureContext,\n): ClientSpan | undefined {\n try {\n const trace = ctx.tracing.request();\n for (const [key, value] of Object.entries(trace.headers)) {\n xhr.setRequestHeader(key, value);\n }\n return trace.span;\n } catch (error) {\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;AAgBA,SAASS,EAAY,GAAc,GAA6B;CAC9D,IAAMC,IAAkB,CAAC,GACrBC,IAAQ,GACRC,IAAS,IACTC,IAAU;CAEd,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAK,QAAQ,KAAK;EACpC,IAAMC,IAAOD,EAAKD;EAClB,AAAID,IACF,IAAU,KACDD,KAAUI,MAAS,OAC5B,IAAU,KACDA,MAAS,OAClB,IAAS,CAACJ,IACD,CAACA,KAAUI,MAASC,MAC7BP,EAAM,KAAKK,EAAK,MAAMJ,GAAOG,CAAC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U;GAErC,KAAK,IAAI,YAAY,KAAK;IACxB,GAAG,KAAK,IAAI;IACZ,UAAU;IACV,SAAS,GAAGvB,EAAO,GAAGC,EAAI,GAAGC,MAAW,IAAI,WAAW,OAAOA,CAAM;IACpE,MAAM,EAAE,YAAY8C,EAAQ;GAC9B,CAAC;GAED,IAAMjD,IAAa;IACjB,uBAAuBC;IACvB,YAAYC;IACZ,6BAA6BC;IAC7B,oBAAoB8C;IACpB,GAAIH,KAAUA,EAAO,QAAQ,SAAS,IAAI,EAAE,iBAAiBA,EAAO,QAAQ,IAAI,CAAC;GACnF;GAEA,AAAI3C,MAAW,IACb,KAAK,IAAI,OAAO,MAAM,GAAGF,EAAO,GAAGC,EAAI,UAAUE,GAAOJ,CAAU,IAGhEG,KAAU,MACZ,KAAK,IAAI,OAAO,KAAK,GAAGF,EAAO,GAAGC,EAAI,YAAY,OAAOC,CAAM,KAAKH,CAAU,IAMhF,KAAK,IAAI,OAAO,MAAM,GAAGC,EAAO,GAAGC,KAAOF,CAAU;EACtD,CACF;CACF;AACF;AASA,SAAS2C,EACP,GACA,GACA,GACwB;CACxB,IAAI;EACF,IAAMX,IAAQjB,EAAI,QAAQ,QAAQ;EAClC,KAAK,IAAM,CAACvB,GAAKC,MAAU,OAAO,QAAQuC,EAAM,OAAO,GACrD,EAAI,iBAAiBxC,GAAKC,CAAK;EAEjC,OAAOuC,EAAM;CACf,SAAS5B,GAAO;EACd,EAAI,YAAY,OACd,yBACA,qFACA,EAAE,OAAI,GACNA,CACF;EACA;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ir as e, qt as t } from "./constants-CEHN6KuY.js";
|
|
2
2
|
// src/capture/observed-windows.ts
|
|
3
|
-
var n = Symbol.for(`${
|
|
3
|
+
var n = Symbol.for(`${t}@${e}`);
|
|
4
4
|
function r() {
|
|
5
5
|
let e = globalThis, t = e[n];
|
|
6
6
|
if (t?.windows instanceof Set && t.observers instanceof Set) return t;
|
|
@@ -61,4 +61,4 @@ function d(e) {
|
|
|
61
61
|
}
|
|
62
62
|
export { l as i, c as n, d as r, u as t };
|
|
63
63
|
|
|
64
|
-
//# sourceMappingURL=observed-windows-
|
|
64
|
+
//# sourceMappingURL=observed-windows-8JtCsIr1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observed-windows-
|
|
1
|
+
{"version":3,"file":"observed-windows-8JtCsIr1.js","names":["TELEMETRY_SDK_VERSION","OBSERVED_WINDOWS_KEY","REGISTRY_KEY","registry","scope","found","fresh","windowLike","value","document","addEventListener","isClosed","win","pruneClosed","forgetWindow","attachTo","observer","windows","observers","observedWindows","addWindowObserver","observeWindow","target"],"sources":["../src/capture/observed-windows.ts"],"sourcesContent":["// src/capture/observed-windows.ts\n//\n// Keeps the windows that the app asks the library to observe, for example a dockview popout\n// whose code runs in this page. The list lives outside the runtime and the capture, so a window\n// observed before configure() or across shutdown() gets attached when the click capture installs.\n// This module is in the main graph, so it must not import the lazy click capture.\n\nimport { OBSERVED_WINDOWS_KEY, TELEMETRY_SDK_VERSION } from \"../constants\";\n\n/** An installed click capture, as the registry sees it. */\nexport interface WindowObserver {\n /**\n * Starts listening in one window.\n * @param win The window.\n * @returns False when the window can't be observed, so the registry forgets it.\n */\n attach(win: Window): boolean;\n /**\n * Stops listening in one window.\n * @param win The window.\n */\n detach(win: Window): void;\n}\n\n/** The windows that the app observes now, and the click captures that are installed now. */\ninterface Registry {\n windows: Set<Window>;\n observers: Set<WindowObserver>;\n}\n\n/** The registry's global key. The version in it keeps another version's copy apart. */\nconst REGISTRY_KEY = Symbol.for(`${OBSERVED_WINDOWS_KEY}@${TELEMETRY_SDK_VERSION}`);\n\n/**\n * Returns the page's registry. Two copies of one version share one runtime, so they share this\n * too. Otherwise a copy's observeWindow() would never reach the other copy's click capture. Any\n * page script can write the key, so a value of another shape gets a fresh registry instead of a\n * throw in observeWindow() or install().\n * @returns The registry.\n */\nfunction registry(): Registry {\n const scope = globalThis as Record<symbol, unknown>;\n const found = scope[REGISTRY_KEY] as Partial<Registry> | null | undefined;\n if (found?.windows instanceof Set && found.observers instanceof Set) {\n return found as Registry;\n }\n\n const fresh: Registry = { windows: new Set(), observers: new Set() };\n scope[REGISTRY_KEY] = fresh;\n return fresh;\n}\n\n/**\n * Checks whether a value can be a window. A window from another origin throws on the read, and\n * that's the expected answer. The fallback is true, so the capture reports it at attach.\n * @param value The value the app passed.\n * @returns True for an object with a document and an addEventListener function, or for one that\n * blocks the read.\n */\nfunction windowLike(value: unknown): value is Window {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n try {\n const { document, addEventListener } = value as {\n document?: unknown;\n addEventListener?: unknown;\n };\n return (\n typeof document === \"object\" && document !== null && typeof addEventListener === \"function\"\n );\n } catch {\n return true;\n }\n}\n\n/**\n * Checks whether a window has closed. A window that throws on the read can't say, and that's the\n * expected answer. The fallback is false, so the capture tries it and reports it.\n * @param win The window.\n * @returns True if the window has closed.\n */\nfunction isClosed(win: Window): boolean {\n try {\n return win.closed;\n } catch {\n return false;\n }\n}\n\n/**\n * Forgets each closed window. Its pagehide can't do it while clicks are off, and a user-closed\n * about:blank popout still reads open at its pagehide.\n */\nfunction pruneClosed(): void {\n for (const win of registry().windows) {\n if (isClosed(win)) {\n forgetWindow(win);\n }\n }\n}\n\n/**\n * Attaches one window to one capture. A window that can't be observed leaves the list, so the\n * next install doesn't report it again.\n * @param observer The capture.\n * @param win The window.\n */\nfunction attachTo(observer: WindowObserver, win: Window): void {\n if (!observer.attach(win)) {\n registry().windows.delete(win);\n }\n}\n\n/**\n * Removes a window from the list and from each installed capture.\n * @param win The window.\n */\nexport function forgetWindow(win: Window): void {\n const { windows, observers } = registry();\n if (!windows.delete(win)) {\n return;\n }\n\n for (const observer of observers) {\n observer.detach(win);\n }\n}\n\n/**\n * Returns the windows that the app observes now. It forgets each closed window first, so a\n * dead click check never watches one.\n * @returns A copy of the list, so a caller can hold it while the list changes.\n */\nexport function observedWindows(): Window[] {\n pruneClosed();\n return [...registry().windows];\n}\n\n/**\n * Adds an installed click capture and attaches each window that's observed now.\n * @param observer The capture.\n * @returns Function that detaches each window from the capture and removes it.\n */\nexport function addWindowObserver(observer: WindowObserver): () => void {\n pruneClosed();\n const { windows, observers } = registry();\n observers.add(observer);\n for (const win of windows) {\n attachTo(observer, win);\n }\n\n return () => {\n observers.delete(observer);\n for (const win of windows) {\n observer.detach(win);\n }\n };\n}\n\n/**\n * Captures clicks in another window of this page, for example a popout whose code runs here.\n * The window gets click breadcrumbs, rage clicks and dead clicks, with the same rules as this\n * page. It gets no navigation capture. The window must have this page's origin. A window from\n * another origin reports `capture.install_failed` and records nothing. The result of\n * `window.open()` works at once, because the `pagehide` of its initial about:blank doesn't end\n * the capture while the window is open.\n *\n * The library listens only while `capture.interactions` is on, and it keeps the window across\n * `shutdown()` and the next `configure()`. The window leaves at the stop function. While\n * `capture.interactions` is on, it also leaves at its `pagehide`. A closed window, also a closed\n * about:blank popout, leaves at the next read of the list: a dead click check, an install or an\n * observeWindow() call. Observe the window again after it reloads, and after the app fills\n * about:blank and then loads a page in it. A window that opens to another origin and is observed\n * at once gets no report, and the library forgets it at its next dead click check. This page's\n * own window and a value that isn't a window do nothing. A call never throws.\n * @param target The window to observe, for example the result of `window.open()`.\n * @returns Function that stops observing the window. A second call does nothing.\n */\nexport function observeWindow(target: Window): () => void {\n if ((target as unknown) === globalThis || !windowLike(target)) {\n return () => undefined;\n }\n\n pruneClosed();\n const { windows, observers } = registry();\n // Attach a listed window again. A page that loads after the app filled about:blank can get a\n // new Window object behind the same handle, without our listeners. A repeat add does nothing.\n windows.add(target);\n for (const observer of observers) {\n attachTo(observer, target);\n }\n\n return () => {\n forgetWindow(target);\n };\n}\n"],"mappings":";;AA+BA,IAAME,IAAe,OAAO,IAAI,GAAGD,EAAqB,GAAGD,GAAuB;AASlF,SAASG,IAAqB;CAC5B,IAAMC,IAAQ,YACRC,IAAQD,EAAMF;CACpB,IAAIG,G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,GAA4B;CACxD,IAAKC,MAAuB,cAAc,CAACf,EAAWe,CAAM,GAC1D,aAAa,KAAA;CAGf,EAAY;CACZ,IAAM,EAAE,YAAS,iBAAcnB,EAAS;CAGxC,EAAQ,IAAImB,CAAM;CAClB,KAAK,IAAMN,KAAYE,GACrB,EAASF,GAAUM,CAAM;CAG3B,aAAa;EACX,EAAaA,CAAM;CACrB;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=observed-windows-
|
|
1
|
+
const e=require("./constants-NtiQDWL_.cjs");var t=Symbol.for(`${e.qt}@${e.ir}`);function n(){let e=globalThis,n=e[t];if(n?.windows instanceof Set&&n.observers instanceof Set)return n;let r={windows:new Set,observers:new Set};return e[t]=r,r}function r(e){if(typeof e!=`object`||!e)return!1;try{let{document:t,addEventListener:n}=e;return typeof t==`object`&&!!t&&typeof n==`function`}catch{return!0}}function i(e){try{return e.closed}catch{return!1}}function a(){for(let e of n().windows)i(e)&&s(e)}function o(e,t){e.attach(t)||n().windows.delete(t)}function s(e){let{windows:t,observers:r}=n();if(t.delete(e))for(let t of r)t.detach(e)}function c(){return a(),[...n().windows]}function l(e){a();let{windows:t,observers:r}=n();r.add(e);for(let n of t)o(e,n);return()=>{r.delete(e);for(let n of t)e.detach(n)}}function u(e){if(e===globalThis||!r(e))return()=>void 0;a();let{windows:t,observers:i}=n();t.add(e);for(let t of i)o(t,e);return()=>{s(e)}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
2
|
+
//# sourceMappingURL=observed-windows-BlE25nrn.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observed-windows-
|
|
1
|
+
{"version":3,"file":"observed-windows-BlE25nrn.cjs","names":["OBSERVED_WINDOWS_KEY","TELEMETRY_SDK_VERSION","require_constants","REGISTRY_KEY","registry","scope","found","fresh","windowLike","value","document","addEventListener","isClosed","win","pruneClosed","forgetWindow","attachTo","observer","windows","observers","observedWindows","addWindowObserver","observeWindow","target"],"sources":["../src/capture/observed-windows.ts"],"sourcesContent":["// src/capture/observed-windows.ts\n//\n// Keeps the windows that the app asks the library to observe, for example a dockview popout\n// whose code runs in this page. The list lives outside the runtime and the capture, so a window\n// observed before configure() or across shutdown() gets attached when the click capture installs.\n// This module is in the main graph, so it must not import the lazy click capture.\n\nimport { OBSERVED_WINDOWS_KEY, TELEMETRY_SDK_VERSION } from \"../constants\";\n\n/** An installed click capture, as the registry sees it. */\nexport interface WindowObserver {\n /**\n * Starts listening in one window.\n * @param win The window.\n * @returns False when the window can't be observed, so the registry forgets it.\n */\n attach(win: Window): boolean;\n /**\n * Stops listening in one window.\n * @param win The window.\n */\n detach(win: Window): void;\n}\n\n/** The windows that the app observes now, and the click captures that are installed now. */\ninterface Registry {\n windows: Set<Window>;\n observers: Set<WindowObserver>;\n}\n\n/** The registry's global key. The version in it keeps another version's copy apart. */\nconst REGISTRY_KEY = Symbol.for(`${OBSERVED_WINDOWS_KEY}@${TELEMETRY_SDK_VERSION}`);\n\n/**\n * Returns the page's registry. Two copies of one version share one runtime, so they share this\n * too. Otherwise a copy's observeWindow() would never reach the other copy's click capture. Any\n * page script can write the key, so a value of another shape gets a fresh registry instead of a\n * throw in observeWindow() or install().\n * @returns The registry.\n */\nfunction registry(): Registry {\n const scope = globalThis as Record<symbol, unknown>;\n const found = scope[REGISTRY_KEY] as Partial<Registry> | null | undefined;\n if (found?.windows instanceof Set && found.observers instanceof Set) {\n return found as Registry;\n }\n\n const fresh: Registry = { windows: new Set(), observers: new Set() };\n scope[REGISTRY_KEY] = fresh;\n return fresh;\n}\n\n/**\n * Checks whether a value can be a window. A window from another origin throws on the read, and\n * that's the expected answer. The fallback is true, so the capture reports it at attach.\n * @param value The value the app passed.\n * @returns True for an object with a document and an addEventListener function, or for one that\n * blocks the read.\n */\nfunction windowLike(value: unknown): value is Window {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n try {\n const { document, addEventListener } = value as {\n document?: unknown;\n addEventListener?: unknown;\n };\n return (\n typeof document === \"object\" && document !== null && typeof addEventListener === \"function\"\n );\n } catch {\n return true;\n }\n}\n\n/**\n * Checks whether a window has closed. A window that throws on the read can't say, and that's the\n * expected answer. The fallback is false, so the capture tries it and reports it.\n * @param win The window.\n * @returns True if the window has closed.\n */\nfunction isClosed(win: Window): boolean {\n try {\n return win.closed;\n } catch {\n return false;\n }\n}\n\n/**\n * Forgets each closed window. Its pagehide can't do it while clicks are off, and a user-closed\n * about:blank popout still reads open at its pagehide.\n */\nfunction pruneClosed(): void {\n for (const win of registry().windows) {\n if (isClosed(win)) {\n forgetWindow(win);\n }\n }\n}\n\n/**\n * Attaches one window to one capture. A window that can't be observed leaves the list, so the\n * next install doesn't report it again.\n * @param observer The capture.\n * @param win The window.\n */\nfunction attachTo(observer: WindowObserver, win: Window): void {\n if (!observer.attach(win)) {\n registry().windows.delete(win);\n }\n}\n\n/**\n * Removes a window from the list and from each installed capture.\n * @param win The window.\n */\nexport function forgetWindow(win: Window): void {\n const { windows, observers } = registry();\n if (!windows.delete(win)) {\n return;\n }\n\n for (const observer of observers) {\n observer.detach(win);\n }\n}\n\n/**\n * Returns the windows that the app observes now. It forgets each closed window first, so a\n * dead click check never watches one.\n * @returns A copy of the list, so a caller can hold it while the list changes.\n */\nexport function observedWindows(): Window[] {\n pruneClosed();\n return [...registry().windows];\n}\n\n/**\n * Adds an installed click capture and attaches each window that's observed now.\n * @param observer The capture.\n * @returns Function that detaches each window from the capture and removes it.\n */\nexport function addWindowObserver(observer: WindowObserver): () => void {\n pruneClosed();\n const { windows, observers } = registry();\n observers.add(observer);\n for (const win of windows) {\n attachTo(observer, win);\n }\n\n return () => {\n observers.delete(observer);\n for (const win of windows) {\n observer.detach(win);\n }\n };\n}\n\n/**\n * Captures clicks in another window of this page, for example a popout whose code runs here.\n * The window gets click breadcrumbs, rage clicks and dead clicks, with the same rules as this\n * page. It gets no navigation capture. The window must have this page's origin. A window from\n * another origin reports `capture.install_failed` and records nothing. The result of\n * `window.open()` works at once, because the `pagehide` of its initial about:blank doesn't end\n * the capture while the window is open.\n *\n * The library listens only while `capture.interactions` is on, and it keeps the window across\n * `shutdown()` and the next `configure()`. The window leaves at the stop function. While\n * `capture.interactions` is on, it also leaves at its `pagehide`. A closed window, also a closed\n * about:blank popout, leaves at the next read of the list: a dead click check, an install or an\n * observeWindow() call. Observe the window again after it reloads, and after the app fills\n * about:blank and then loads a page in it. A window that opens to another origin and is observed\n * at once gets no report, and the library forgets it at its next dead click check. This page's\n * own window and a value that isn't a window do nothing. A call never throws.\n * @param target The window to observe, for example the result of `window.open()`.\n * @returns Function that stops observing the window. A second call does nothing.\n */\nexport function observeWindow(target: Window): () => void {\n if ((target as unknown) === globalThis || !windowLike(target)) {\n return () => undefined;\n }\n\n pruneClosed();\n const { windows, observers } = registry();\n // Attach a listed window again. A page that loads after the app filled about:blank can get a\n // new Window object behind the same handle, without our listeners. A repeat add does nothing.\n windows.add(target);\n for (const observer of observers) {\n attachTo(observer, target);\n }\n\n return () => {\n forgetWindow(target);\n };\n}\n"],"mappings":"A,4CA+BA,IAAMG,EAAe,OAAO,IAAI,GAAGH,EAAAA,GAAqB,GAAGC,EAAAA,IAAuB,EASlF,SAASG,GAAqB,CAC5B,IAAMC,EAAQ,WACRC,EAAQD,EAAMF,GACpB,GAAIG,GAAO,mBAAmB,KAAOA,EAAM,qBAAqB,IAC9D,OAAOA,EAGT,IAAMC,EAAkB,CAAE,QAAS,IAAI,IAAO,UAAW,IAAI,GAAM,EAEnE,MADA,GAAMJ,GAAgBI,EACfA,CACT,CASA,SAASC,EAAW,EAAiC,CACnD,GAAI,OAAOC,GAAU,WAAYA,EAC/B,MAAO,GAGT,GAAI,CACF,GAAM,CAAE,WAAU,oBAA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
|
-
{"version":3,"file":"openfin-Bxelt0yg.js","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API without importing an OpenFin package. The types\n// list only the members that the library reads. Every member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n *
|
|
1
|
+
{"version":3,"file":"openfin-Bxelt0yg.js","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API without importing an OpenFin package. The types\n// list only the members that the library reads. Every member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n * Subscribes a listener to a topic for matching application identities.\n * @param identity Target application identity.\n * @param topic Topic name.\n * @param listener Message callback.\n */\n subscribe(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n\n /**\n * Sends a message to the topic subscribers of one application.\n * @param destination Target application identity.\n * @param topic Topic name.\n * @param message Message payload.\n */\n send(destination: { uuid: string }, topic: string, message: unknown): Promise<void>;\n\n /**\n * Removes a listener that subscribe() added. An older runtime may not have it.\n * @param identity The identity that subscribe() got.\n * @param topic The topic that subscribe() got.\n * @param listener The listener that subscribe() got.\n */\n unsubscribe?(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n}\n\n/** The fin.me members that the library reads. */\nexport interface FinMe {\n /** True in an OpenFin view. */\n isView?: boolean;\n /** Identity of the window or view. */\n identity?: { uuid?: string; name?: string };\n /** Resolves the window's creation options, including customData. */\n getOptions?: () => Promise<{ customData?: Record<string, unknown> }>;\n /** Adds a window event listener. */\n on?: (event: string, listener: () => void) => void;\n /** Removes a window event listener. */\n removeListener?: (event: string, listener: () => void) => void;\n}\n\n/** The members of the OpenFin global that the library reads. */\nexport interface FinLike {\n /** This document's window or view. */\n me?: FinMe;\n /** The OpenFin runtime's message bus. */\n InterApplicationBus?: FinIab;\n}\n\n/**\n * Returns the OpenFin global.\n * @returns The fin global, or undefined outside OpenFin.\n */\nexport function getFin(): FinLike | undefined {\n return (globalThis as { fin?: FinLike }).fin;\n}\n"],"mappings":";AAmEA,SAAgBA,IAA8B;CAC5C,OAAQ,WAAiC;AAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openfin-DtH2f7zX.cjs","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API without importing an OpenFin package. The types\n// list only the members that the library reads. Every member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n *
|
|
1
|
+
{"version":3,"file":"openfin-DtH2f7zX.cjs","names":["getFin"],"sources":["../src/utils/openfin.ts"],"sourcesContent":["// src/utils/openfin.ts\n//\n// Reads the optional OpenFin runtime API without importing an OpenFin package. The types\n// list only the members that the library reads. Every member is optional, because a test, an\n// older runtime or OpenFin web can leave it out.\n\n/** The InterApplicationBus operations that the bus link uses. */\nexport interface FinIab {\n /**\n * Subscribes a listener to a topic for matching application identities.\n * @param identity Target application identity.\n * @param topic Topic name.\n * @param listener Message callback.\n */\n subscribe(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n\n /**\n * Sends a message to the topic subscribers of one application.\n * @param destination Target application identity.\n * @param topic Topic name.\n * @param message Message payload.\n */\n send(destination: { uuid: string }, topic: string, message: unknown): Promise<void>;\n\n /**\n * Removes a listener that subscribe() added. An older runtime may not have it.\n * @param identity The identity that subscribe() got.\n * @param topic The topic that subscribe() got.\n * @param listener The listener that subscribe() got.\n */\n unsubscribe?(\n identity: { uuid: string },\n topic: string,\n listener: (message: unknown, uuid?: string, name?: string) => void,\n ): Promise<void>;\n}\n\n/** The fin.me members that the library reads. */\nexport interface FinMe {\n /** True in an OpenFin view. */\n isView?: boolean;\n /** Identity of the window or view. */\n identity?: { uuid?: string; name?: string };\n /** Resolves the window's creation options, including customData. */\n getOptions?: () => Promise<{ customData?: Record<string, unknown> }>;\n /** Adds a window event listener. */\n on?: (event: string, listener: () => void) => void;\n /** Removes a window event listener. */\n removeListener?: (event: string, listener: () => void) => void;\n}\n\n/** The members of the OpenFin global that the library reads. */\nexport interface FinLike {\n /** This document's window or view. */\n me?: FinMe;\n /** The OpenFin runtime's message bus. */\n InterApplicationBus?: FinIab;\n}\n\n/**\n * Returns the OpenFin global.\n * @returns The fin global, or undefined outside OpenFin.\n */\nexport function getFin(): FinLike | undefined {\n return (globalThis as { fin?: FinLike }).fin;\n}\n"],"mappings":"AAmEA,SAAgBA,GAA8B,CAC5C,OAAQ,WAAiC,GAC3C,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as e, rr as t, z as n, zn as r } from "./constants-CEHN6KuY.js";
|
|
2
2
|
// src/transport/serializers/otlp.ts
|
|
3
3
|
function i(e) {
|
|
4
4
|
return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isSafeInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(i).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: a(e) } } : null;
|
|
@@ -32,10 +32,10 @@ function c(e) {
|
|
|
32
32
|
}
|
|
33
33
|
return [...t.values()];
|
|
34
34
|
}
|
|
35
|
-
function l(
|
|
35
|
+
function l(n) {
|
|
36
36
|
let r = /* @__PURE__ */ new Map();
|
|
37
|
-
for (let i of
|
|
38
|
-
let
|
|
37
|
+
for (let i of n) {
|
|
38
|
+
let n = i.attributes[e], a = typeof n == "string" && n ? n : t, o = r.get(a);
|
|
39
39
|
o ? o.push(i) : r.set(a, [i]);
|
|
40
40
|
}
|
|
41
41
|
return [...r].map(([e, t]) => ({
|
|
@@ -44,7 +44,7 @@ function l(e) {
|
|
|
44
44
|
}));
|
|
45
45
|
}
|
|
46
46
|
var u = {
|
|
47
|
-
name:
|
|
47
|
+
name: r,
|
|
48
48
|
serialize(e) {
|
|
49
49
|
let t = c(e).map((e) => ({
|
|
50
50
|
resource: { attributes: a(e.resource) },
|
|
@@ -65,10 +65,10 @@ var u = {
|
|
|
65
65
|
}));
|
|
66
66
|
return {
|
|
67
67
|
body: JSON.stringify({ resourceLogs: t }),
|
|
68
|
-
contentType:
|
|
68
|
+
contentType: n
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
export { a as i, l as n, u as r, c as t };
|
|
73
73
|
|
|
74
|
-
//# sourceMappingURL=otlp-
|
|
74
|
+
//# sourceMappingURL=otlp-Btix3EBa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-
|
|
1
|
+
{"version":3,"file":"otlp-Btix3EBa.js","names":["items","nested","ATTR_APP_NAMESPACE","TELEMETRY_SDK_NAME","CONTENT_TYPE_JSON","SERIALIZER_NAME_OTLP","toAnyValue","value","item","toKeyValues","out","key","raw","source","resourceKeys","resourceKey","cached","resource","groupByResource","groups","record","records","group","groupByScope","namespace","name","scoped","otlpSerializer","resourceLogs","scope"],"sources":["../src/transport/serializers/otlp.ts"],"sourcesContent":["// src/transport/serializers/otlp.ts\n//\n// Serializes log batches as OTLP/JSON log records. Records are grouped by resource, and each\n// logger namespace gets its own instrumentation scope.\n// The OTLP metrics serializer reuses the value encoding and the resource grouping from here.\n\nimport {\n ATTR_APP_NAMESPACE,\n CONTENT_TYPE_JSON,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** An OTLP AnyValue with typed value wrappers. */\ntype AnyValue = Record<string, unknown>;\n\n/** An OTLP KeyValue pair. */\nexport interface KeyValue {\n /** The attribute key. */\n key: string;\n /** The typed AnyValue. */\n value: AnyValue;\n}\n\n/** Records that share the same resource attributes. */\nexport interface ResourceGroup {\n /** The resource attribute map. */\n resource: Record<string, unknown>;\n /** The resource's log records. */\n records: LogRecord[];\n}\n\n/**\n * Wraps a JavaScript value in an OTLP AnyValue.\n * @param value Raw attribute or resource value.\n * @returns Typed AnyValue object or null if unsupported.\n */\nfunction toAnyValue(value: unknown): AnyValue | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return { stringValue: value };\n }\n\n if (typeof value === \"boolean\") {\n return { boolValue: value };\n }\n\n // Encode int64 as a decimal string, as the OTLP protobuf JSON mapping requires. A conforming\n // collector answers a number with a 400 status, and the response doesn't give the cause.\n // An integer above MAX_SAFE_INTEGER goes to doubleValue, because its text can be \"1e+21\" or\n // overflow int64.\n if (typeof value === \"number\") {\n return Number.isSafeInteger(value) ? { intValue: String(value) } : { doubleValue: value };\n }\n\n // Convert a BigInt to a decimal string. JSON.stringify throws on a BigInt and would lose\n // the batch.\n if (typeof value === \"bigint\") {\n return { intValue: value.toString() };\n }\n\n if (Array.isArray(value)) {\n const items: readonly unknown[] = value;\n const values = items.map(toAnyValue).filter((item): item is AnyValue => item !== null);\n\n return { arrayValue: { values } };\n }\n\n if (typeof value === \"object\") {\n const nested = value as Record<string, unknown>;\n return { kvlistValue: { values: toKeyValues(nested) } };\n }\n\n return null;\n}\n\n/**\n * Converts a plain object to an array of OTLP KeyValue pairs.\n * @param source Key-value attribute object.\n * @returns Array of valid KeyValue pairs.\n */\nexport function toKeyValues(source: Record<string, unknown>): KeyValue[] {\n const out: KeyValue[] = [];\n\n for (const [key, raw] of Object.entries(source)) {\n const value = toAnyValue(raw);\n if (value) {\n out.push({ key, value });\n }\n }\n\n return out;\n}\n\n/** Caches the JSON key of every resource object, which avoids a repeated stringify. */\nconst resourceKeys = new WeakMap<object, string>();\n\n/**\n * Returns the stable JSON key of a resource object, and caches it.\n * @param resource Resource attribute object.\n * @returns JSON key string.\n */\nfunction resourceKey(resource: Record<string, unknown>): string {\n const cached = resourceKeys.get(resource);\n if (cached !== undefined) {\n return cached;\n }\n\n const key = JSON.stringify(resource);\n resourceKeys.set(resource, key);\n\n return key;\n}\n\n/**\n * Groups records by their resource attributes, keeping the record order within each group.\n * @param records Records to group.\n * @returns One group per resource.\n */\nexport function groupByResource(records: LogRecord[]): ResourceGroup[] {\n const groups = new Map<string, ResourceGroup>();\n\n for (const record of records) {\n const key = resourceKey(record.resource);\n const group = groups.get(key);\n\n if (group) {\n group.records.push(record);\n continue;\n }\n\n groups.set(key, { resource: record.resource, records: [record] });\n }\n\n return [...groups.values()];\n}\n\n/** The records of one instrumentation scope. */\nexport interface ScopeGroup {\n /** The scope name, which is the logger namespace. */\n name: string;\n /** The scope's records. */\n records: LogRecord[];\n}\n\n/**\n * Groups records by their logger namespace, keeping the record order within each group.\n * A record without a namespace goes to the library's own scope.\n * @param records Records of one resource.\n * @returns One group per namespace.\n */\nexport function groupByScope(records: LogRecord[]): ScopeGroup[] {\n const groups = new Map<string, LogRecord[]>();\n\n for (const record of records) {\n const namespace: unknown = record.attributes[ATTR_APP_NAMESPACE];\n const name = typeof namespace === \"string\" && namespace ? namespace : TELEMETRY_SDK_NAME;\n const group = groups.get(name);\n\n if (group) {\n group.push(record);\n continue;\n }\n\n groups.set(name, [record]);\n }\n\n return [...groups].map(([name, scoped]) => ({ name, records: scoped }));\n}\n\n/** Writes log records as OTLP/JSON payloads. */\nexport const otlpSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups records by resource and encodes them as an OTLP\n * ExportLogsServiceRequest JSON payload.\n * @param records Array of log records to serialize.\n * @returns Serialized JSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceLogs = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeLogs: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n logRecords: scope.records.map((record) => ({\n timeUnixNano: record.timeUnixNano,\n // Use timeUnixNano when observedTimeUnixNano is not set.\n observedTimeUnixNano: record.observedTimeUnixNano ?? record.timeUnixNano,\n severityNumber: record.severityNumber,\n severityText: record.severityText,\n body: { stringValue: record.body },\n traceId: record.traceId,\n spanId: record.spanId,\n flags: record.traceFlags,\n attributes: toKeyValues(record.attributes),\n })),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceLogs }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n"],"mappings":";;AAuCA,SAASM,EAAW,GAAiC;CAuCnD,OAtCIC,KAAU,OACL,OAGL,OAAOA,KAAU,WACZ,EAAE,aAAaA,EAAM,IAG1B,OAAOA,KAAU,YACZ,EAAE,WAAWA,EAAM,IAOxB,OAAOA,KAAU,WACZ,OAAO,cAAcA,CAAK,IAAI,EAAE,UAAU,OAAOA,CAAK,EAAE,IAAI,EAAE,aAAaA,EAAM,IAKtF,OAAOA,KAAU,WACZ,EAAE,UAAUA,EAAM,SAAS,EAAE,IAGlC,MAAM,QAAQA,CAAK,IAId,EAAE,YAAY,EAAE,QAFRP,EAAM,IAAIM,CAAU,CAAC,CAAC,QAAQ,MAA2BE,MAAS,IAE1D,EAAO,EAAE,IAG9B,OAAOD,KAAU,WAEZ,EAAE,aAAa,EAAE,QAAQE,EAAYR,CAAM,EAAE,EAAE,IAGjD;AACT;AAOA,SAAgBQ,EAAY,GAA6C;CACvE,IAAMC,IAAkB,CAAC;CAEzB,KAAK,IAAM,CAACC,GAAKC,MAAQ,OAAO,QAAQC,CAAM,GAAG;EAC/C,IAAMN,IAAQD,EAAWM,CAAG;EAC5B,AAAIL,KACFG,EAAI,KAAK;GAAE;GAAK;EAAM,CAAC;CAE3B;CAEA,OAAOA;AACT;AAGA,IAAMI,oBAAe,IAAI,QAAwB;AAOjD,SAAS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B,YAAYA,EAAM,QAAQ,KAAK,OAAY;KACzC,cAAcT,EAAO;KAErB,sBAAsBA,EAAO,wBAAwBA,EAAO;KAC5D,gBAAgBA,EAAO;KACvB,cAAcA,EAAO;KACrB,MAAM,EAAE,aAAaA,EAAO,KAAK;KACjC,SAASA,EAAO;KAChB,QAAQA,EAAO;KACf,OAAOA,EAAO;KACd,YAAYX,EAAYW,EAAO,UAAU;IAC3C,EAAE;GACJ,EAAE;EACJ,EAAE;EAEF,OAAO;GACL,MAAM,KAAK,UAAU,EAAE,gBAAa,CAAC;GACrC,aAAahB;EACf;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=otlp-
|
|
1
|
+
const e=require("./constants-NtiQDWL_.cjs");function t(e){return e==null?null:typeof e==`string`?{stringValue:e}:typeof e==`boolean`?{boolValue:e}:typeof e==`number`?Number.isSafeInteger(e)?{intValue:String(e)}:{doubleValue:e}:typeof e==`bigint`?{intValue:e.toString()}:Array.isArray(e)?{arrayValue:{values:e.map(t).filter(e=>e!==null)}}:typeof e==`object`?{kvlistValue:{values:n(e)}}:null}function n(e){let n=[];for(let[r,i]of Object.entries(e)){let e=t(i);e&&n.push({key:r,value:e})}return n}var r=new WeakMap;function i(e){let t=r.get(e);if(t!==void 0)return t;let n=JSON.stringify(e);return r.set(e,n),n}function a(e){let t=new Map;for(let n of e){let e=i(n.resource),r=t.get(e);r?r.records.push(n):t.set(e,{resource:n.resource,records:[n]})}return[...t.values()]}function o(t){let n=new Map;for(let r of t){let t=r.attributes[e.a],i=typeof t==`string`&&t?t:e.rr,a=n.get(i);a?a.push(r):n.set(i,[r])}return[...n].map(([e,t])=>({name:e,records:t}))}var s={name:e.zn,serialize(t){let r=a(t).map(e=>({resource:{attributes:n(e.resource)},scopeLogs:o(e.records).map(e=>({scope:{name:e.name},logRecords:e.records.map(e=>({timeUnixNano:e.timeUnixNano,observedTimeUnixNano:e.observedTimeUnixNano??e.timeUnixNano,severityNumber:e.severityNumber,severityText:e.severityText,body:{stringValue:e.body},traceId:e.traceId,spanId:e.spanId,flags:e.traceFlags,attributes:n(e.attributes)}))}))}));return{body:JSON.stringify({resourceLogs:r}),contentType:e.z}}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
+
//# sourceMappingURL=otlp-CFSW-Dno.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-
|
|
1
|
+
{"version":3,"file":"otlp-CFSW-Dno.cjs","names":["items","nested","ATTR_APP_NAMESPACE","TELEMETRY_SDK_NAME","SERIALIZER_NAME_OTLP","CONTENT_TYPE_JSON","require_constants","toAnyValue","value","item","toKeyValues","out","key","raw","source","resourceKeys","resourceKey","cached","resource","groupByResource","groups","record","records","group","groupByScope","namespace","name","scoped","otlpSerializer","resourceLogs","scope"],"sources":["../src/transport/serializers/otlp.ts"],"sourcesContent":["// src/transport/serializers/otlp.ts\n//\n// Serializes log batches as OTLP/JSON log records. Records are grouped by resource, and each\n// logger namespace gets its own instrumentation scope.\n// The OTLP metrics serializer reuses the value encoding and the resource grouping from here.\n\nimport {\n ATTR_APP_NAMESPACE,\n CONTENT_TYPE_JSON,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** An OTLP AnyValue with typed value wrappers. */\ntype AnyValue = Record<string, unknown>;\n\n/** An OTLP KeyValue pair. */\nexport interface KeyValue {\n /** The attribute key. */\n key: string;\n /** The typed AnyValue. */\n value: AnyValue;\n}\n\n/** Records that share the same resource attributes. */\nexport interface ResourceGroup {\n /** The resource attribute map. */\n resource: Record<string, unknown>;\n /** The resource's log records. */\n records: LogRecord[];\n}\n\n/**\n * Wraps a JavaScript value in an OTLP AnyValue.\n * @param value Raw attribute or resource value.\n * @returns Typed AnyValue object or null if unsupported.\n */\nfunction toAnyValue(value: unknown): AnyValue | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return { stringValue: value };\n }\n\n if (typeof value === \"boolean\") {\n return { boolValue: value };\n }\n\n // Encode int64 as a decimal string, as the OTLP protobuf JSON mapping requires. A conforming\n // collector answers a number with a 400 status, and the response doesn't give the cause.\n // An integer above MAX_SAFE_INTEGER goes to doubleValue, because its text can be \"1e+21\" or\n // overflow int64.\n if (typeof value === \"number\") {\n return Number.isSafeInteger(value) ? { intValue: String(value) } : { doubleValue: value };\n }\n\n // Convert a BigInt to a decimal string. JSON.stringify throws on a BigInt and would lose\n // the batch.\n if (typeof value === \"bigint\") {\n return { intValue: value.toString() };\n }\n\n if (Array.isArray(value)) {\n const items: readonly unknown[] = value;\n const values = items.map(toAnyValue).filter((item): item is AnyValue => item !== null);\n\n return { arrayValue: { values } };\n }\n\n if (typeof value === \"object\") {\n const nested = value as Record<string, unknown>;\n return { kvlistValue: { values: toKeyValues(nested) } };\n }\n\n return null;\n}\n\n/**\n * Converts a plain object to an array of OTLP KeyValue pairs.\n * @param source Key-value attribute object.\n * @returns Array of valid KeyValue pairs.\n */\nexport function toKeyValues(source: Record<string, unknown>): KeyValue[] {\n const out: KeyValue[] = [];\n\n for (const [key, raw] of Object.entries(source)) {\n const value = toAnyValue(raw);\n if (value) {\n out.push({ key, value });\n }\n }\n\n return out;\n}\n\n/** Caches the JSON key of every resource object, which avoids a repeated stringify. */\nconst resourceKeys = new WeakMap<object, string>();\n\n/**\n * Returns the stable JSON key of a resource object, and caches it.\n * @param resource Resource attribute object.\n * @returns JSON key string.\n */\nfunction resourceKey(resource: Record<string, unknown>): string {\n const cached = resourceKeys.get(resource);\n if (cached !== undefined) {\n return cached;\n }\n\n const key = JSON.stringify(resource);\n resourceKeys.set(resource, key);\n\n return key;\n}\n\n/**\n * Groups records by their resource attributes, keeping the record order within each group.\n * @param records Records to group.\n * @returns One group per resource.\n */\nexport function groupByResource(records: LogRecord[]): ResourceGroup[] {\n const groups = new Map<string, ResourceGroup>();\n\n for (const record of records) {\n const key = resourceKey(record.resource);\n const group = groups.get(key);\n\n if (group) {\n group.records.push(record);\n continue;\n }\n\n groups.set(key, { resource: record.resource, records: [record] });\n }\n\n return [...groups.values()];\n}\n\n/** The records of one instrumentation scope. */\nexport interface ScopeGroup {\n /** The scope name, which is the logger namespace. */\n name: string;\n /** The scope's records. */\n records: LogRecord[];\n}\n\n/**\n * Groups records by their logger namespace, keeping the record order within each group.\n * A record without a namespace goes to the library's own scope.\n * @param records Records of one resource.\n * @returns One group per namespace.\n */\nexport function groupByScope(records: LogRecord[]): ScopeGroup[] {\n const groups = new Map<string, LogRecord[]>();\n\n for (const record of records) {\n const namespace: unknown = record.attributes[ATTR_APP_NAMESPACE];\n const name = typeof namespace === \"string\" && namespace ? namespace : TELEMETRY_SDK_NAME;\n const group = groups.get(name);\n\n if (group) {\n group.push(record);\n continue;\n }\n\n groups.set(name, [record]);\n }\n\n return [...groups].map(([name, scoped]) => ({ name, records: scoped }));\n}\n\n/** Writes log records as OTLP/JSON payloads. */\nexport const otlpSerializer: LogSerializer = {\n /** The format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups records by resource and encodes them as an OTLP\n * ExportLogsServiceRequest JSON payload.\n * @param records Array of log records to serialize.\n * @returns Serialized JSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceLogs = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeLogs: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n logRecords: scope.records.map((record) => ({\n timeUnixNano: record.timeUnixNano,\n // Use timeUnixNano when observedTimeUnixNano is not set.\n observedTimeUnixNano: record.observedTimeUnixNano ?? record.timeUnixNano,\n severityNumber: record.severityNumber,\n severityText: record.severityText,\n body: { stringValue: record.body },\n traceId: record.traceId,\n spanId: record.spanId,\n flags: record.traceFlags,\n attributes: toKeyValues(record.attributes),\n })),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceLogs }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n"],"mappings":"A,4CAuCA,SAASO,EAAW,EAAiC,CAuCnD,OAtCIC,GAAU,KACL,KAGL,OAAOA,GAAU,SACZ,CAAE,YAAaA,CAAM,EAG1B,OAAOA,GAAU,UACZ,CAAE,UAAWA,CAAM,EAOxB,OAAOA,GAAU,SACZ,OAAO,cAAcA,CAAK,EAAI,CAAE,SAAU,OAAOA,CAAK,CAAE,EAAI,CAAE,YAAaA,CAAM,EAKtF,OAAOA,GAAU,SACZ,CAAE,SAAUA,EAAM,SAAS,CAAE,EAGlC,MAAM,QAAQA,CAAK,EAId,CAAE,WAAY,CAAE,OAFRR,EAAM,IAAIO,CAAU,CAAC,CAAC,OAAQ,GAA2BE,IAAS,IAE1D,CAAO,CAAE,EAG9B,OAAOD,GAAU,SAEZ,CAAE,YAAa,CAAE,OAAQE,EAAYT,CAAM,CAAE,CAAE,EAGjD,IACT,CAOA,SAAgBS,EAAY,EAA6C,CACvE,IAAMC,EAAkB,CAAC,EAEzB,IAAK,GAAM,CAACC,EAAKC,KAAQ,OAAO,QAAQC,CAAM,EAAG,CAC/C,IAAMN,EAAQD,EAAWM,CAAG,EACxBL,GACFG,EAAI,KAAK,CAAE,MAAK,OAAM,CAAC,CAE3B,CAEA,OAAOA,CACT,CAGA,IAAMI,EAAe,IAAI,QAOzB,SAASC,EAAY,EAA2C,CAC9D,IAAMC,EAASF,EAAa,IAAIG,CAAQ,EACxC,GAAID,IAAW,IAAA,GACb,OAAOA,EAGT,IAAML,EAAM,KAAK,UAAUM,CAAQ,EAGnC,OAFAH,EAAa,IAAIG,EAAUN,CAAG,EAEvBA,CACT,CAOA,SAAgBO,EAAgB,EAAuC,CACrE,IAAM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YX,EAAYW,EAAO,UAAU,CAC3C,EAAE,CACJ,EAAE,CACJ,EAAE,EAEF,MAAO,CACL,KAAM,KAAK,UAAU,CAAE,cAAa,CAAC,EACrC,YAAahB,EAAAA,CACf,CACF,CACF,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./guards-EjG3ahFp.cjs");function t(t,n,r){let i=t[n],a=e.t(t,n),o=r(i);return t[n]=o,()=>t[n]===o&&(a?t[n]=i:Reflect.deleteProperty(t,n),!0)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=patch-DlcKzIi-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-DlcKzIi-.cjs","names":["hasOwn","require_guards","patch","original","target","key","own","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and returns a safe restore. A router or a second\n// SDK can wrap the same function after we do, and a blind restore would remove that wrapper\n// and break the host page.\n\nimport { hasOwn } from \"./guards\";\n\n/**\n * Replaces `target[key]` with a wrapper around the current value.\n * @param target The object that holds the function, for example `console` or `globalThis`.\n * @param key The property to replace.\n * @param wrap Builds the wrapper from the original value.\n * @returns A restore function. It puts the original back and returns true only if the\n * property still holds the wrapper. Otherwise it changes nothing and returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n // history.pushState lives on the prototype. Writing it back as an own property would hide a\n // later patch of History.prototype from the page.\n const own = hasOwn(target, key);\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after us. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n if (own) {\n target[key] = original;\n } else {\n Reflect.deleteProperty(target, key);\n }\n\n return true;\n };\n}\n"],"mappings":"A,yCAgBA,SAAgBE,EACd,EACA,EACA,EACe,CACf,IAAMC,EAAWC,EAAOC,GAGlBC,EAAMN,EAAAA,EAAOI,EAAQC,CAAG,EACxBE,EAAUC,EAAKL,CAAQ,EAG7B,MAFA,GAAOE,GAAOE,MAIRH,EAAOC,KAASE,IAIhBD,EACF,EAAOD,GAAOF,EAEd,QAAQ,eAAeC,EAAQC,CAAG,EAG7B,GAEX,C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as e } from "./guards-BlYGRK4l.js";
|
|
2
|
+
// src/utils/patch.ts
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
let i = t[n], a = e(t, n), o = r(i);
|
|
5
|
+
return t[n] = o, () => t[n] === o && (a ? t[n] = i : Reflect.deleteProperty(t, n), !0);
|
|
6
|
+
}
|
|
7
|
+
export { t };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=patch-Sr1wKg7W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-Sr1wKg7W.js","names":["hasOwn","patch","original","target","key","own","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and returns a safe restore. A router or a second\n// SDK can wrap the same function after we do, and a blind restore would remove that wrapper\n// and break the host page.\n\nimport { hasOwn } from \"./guards\";\n\n/**\n * Replaces `target[key]` with a wrapper around the current value.\n * @param target The object that holds the function, for example `console` or `globalThis`.\n * @param key The property to replace.\n * @param wrap Builds the wrapper from the original value.\n * @returns A restore function. It puts the original back and returns true only if the\n * property still holds the wrapper. Otherwise it changes nothing and returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n // history.pushState lives on the prototype. Writing it back as an own property would hide a\n // later patch of History.prototype from the page.\n const own = hasOwn(target, key);\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after us. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n if (own) {\n target[key] = original;\n } else {\n Reflect.deleteProperty(target, key);\n }\n\n return true;\n };\n}\n"],"mappings":";;AAgBA,SAAgBC,EACd,GACA,GACA,GACe;CACf,IAAMC,IAAWC,EAAOC,IAGlBC,IAAML,EAAOG,GAAQC,CAAG,GACxBE,IAAUC,EAAKL,CAAQ;CAG7B,OAFA,EAAOE,KAAOE,SAIRH,EAAOC,OAASE,MAIhBD,IACF,EAAOD,KAAOF,IAEd,QAAQ,eAAeC,GAAQC,CAAG,GAG7B;AAEX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants-NtiQDWL_.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.Xt.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.i.test(t)?!0:(e.Ct.test(t)||e.Lt.test(t)&&e.Ut.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^(\s*(?:[a-z][a-z\d+.-]*:[/\\]+|[/\\]{2,}))(?![/\\])[^/?#\s]*@/i,l=/[\t\n\r]/g;function u(){return typeof document<`u`?document.baseURI:typeof location>`u`?void 0:location.href}function d(e){if(!e.includes(`@`))return e;let t;try{t=new URL(e,u())}catch{return e.replace(l,``).replace(c,`$1`)}return t.username===``&&t.password===``?e:(t.username=``,t.password=``,t.href)}function f(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=d(e);return t?i:p(i)}function p(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function m(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
2
|
+
//# sourceMappingURL=platform-BZjp9wp1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-BZjp9wp1.cjs","names":["getFin","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","require_openfin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","URL_DROPPED","pageBase","withoutUserInfo","url","parsed","recordedUrl","transform","value","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker execution\n// realms. The result is cached, because it doesn't change during the life of a realm. A\n// webview is also a browser, so test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Checks whether globalThis is an instance of the given global scope constructor.\n * @param g Global scope object.\n * @param name Name of the scope constructor to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Checks whether a user agent string belongs to an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if the user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Checks whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read, which proves a frame. Count it, but don't report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Reads the current document URL without caching.\n * @param diagnostics Diagnostics reporter. Counts a blocked read of location.href.\n * @returns The current location.href, or an empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault, because a report per record would be noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/**\n * Matches the user info after a URL's slashes or backslashes, with or without a scheme. A space\n * ends it (\"// step @ 3\" isn't a URL), and the lookahead keeps the match linear.\n */\nconst USER_INFO_PATTERN = /^(\\s*(?:[a-z][a-z\\d+.-]*:[/\\\\]+|[/\\\\]{2,}))(?![/\\\\])[^/?#\\s]*@/i;\n\n/** A browser drops these characters from a URL before it reads it. */\nconst URL_DROPPED = /[\\t\\n\\r]/g;\n\n/**\n * Returns the URL that a relative URL resolves against. A worker has no document, so it uses\n * its own location.\n * @returns The base URL, or undefined when the scope has neither.\n */\nexport function pageBase(): string | undefined {\n if (typeof document !== \"undefined\") {\n return document.baseURI;\n }\n\n return typeof location === \"undefined\" ? undefined : location.href;\n}\n\n/**\n * Removes the user name and the password from a URL. A browser also finds them in a URL with\n * no scheme, with backslashes or with a leading space, so the URL parser reads them.\n * @param url Absolute or relative URL.\n * @returns The URL without user info, or the URL as given when it has none.\n */\nfunction withoutUserInfo(url: string): string {\n // User info always ends in \"@\", so most URLs skip the parse, which runs on the log path.\n if (!url.includes(\"@\")) {\n return url;\n }\n\n let parsed: URL;\n try {\n parsed = new URL(url, pageBase());\n } catch {\n // The parser rejects the URL, or a blob: or about:blank base can't resolve it, so the\n // fallback is the pattern.\n return url.replace(URL_DROPPED, \"\").replace(USER_INFO_PATTERN, \"$1\");\n }\n\n if (parsed.username === \"\" && parsed.password === \"\") {\n return url;\n }\n\n parsed.username = \"\";\n parsed.password = \"\";\n return parsed.href;\n}\n\n/**\n * Returns the form of a URL that the library records. A transform's result is recorded as is,\n * or \"\" if it throws or returns no string. Without a transform, the user info is always\n * removed, because it is a credential, and without fullUrls the query and the fragment go too.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. Replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: ((url: string) => string | null) | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Otherwise every recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = withoutUserInfo(url);\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL. Cuts the string instead of parsing it,\n * because a relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Checks whether the browser can reach the network. A host without navigator.onLine counts as\n * online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"A,gFAkDA,IAAIQ,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CACvD,IAAMC,EAAQC,EAAEC,GAIhB,OAHIF,IAAU,IAAA,IAGPC,aAAcD,CACvB,CAOA,SAAgBG,EAAe,EAA4C,CACzE,GAAIL,EACF,OAAOA,EAET,IAAMG,EAAI,WAEJG,EAAMH,EAAE,WAAqC,WA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