@utk09/ui-observability 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -219
- package/README.md +24 -26
- package/dist/{batch-CXmPmTse.js → batch-D3NHhF9L.js} +3 -3
- package/dist/{batch-CXmPmTse.js.map → batch-D3NHhF9L.js.map} +1 -1
- package/dist/{batch-mmPigCpi.cjs → batch-DnYRJqhU.cjs} +2 -2
- package/dist/{batch-mmPigCpi.cjs.map → batch-DnYRJqhU.cjs.map} +1 -1
- package/dist/bus/bus.d.cts +26 -2
- package/dist/bus/bus.d.ts +26 -2
- package/dist/bus-B__467mL.cjs +2 -0
- package/dist/bus-B__467mL.cjs.map +1 -0
- package/dist/{bus-C39wspFV.js → bus-dw7T92sO.js} +37 -24
- package/dist/bus-dw7T92sO.js.map +1 -0
- package/dist/capture/interactions.d.cts +35 -3
- package/dist/capture/interactions.d.ts +35 -3
- package/dist/capture/observed-windows.d.cts +51 -0
- package/dist/capture/observed-windows.d.ts +51 -0
- package/dist/{compression-CvED_Jel.cjs → compression-C0hUHKR-.cjs} +2 -2
- package/dist/{compression-CvED_Jel.cjs.map → compression-C0hUHKR-.cjs.map} +1 -1
- package/dist/{compression-tVtXwVjX.js → compression-SHPAvS4U.js} +2 -2
- package/dist/{compression-tVtXwVjX.js.map → compression-SHPAvS4U.js.map} +1 -1
- package/dist/{config-SgQcCP1_.js → config-CSNcS7OZ.js} +194 -196
- package/dist/config-CSNcS7OZ.js.map +1 -0
- package/dist/config-CybPP5VM.cjs +2 -0
- package/dist/config-CybPP5VM.cjs.map +1 -0
- package/dist/{console-BGgGnjSi.js → console-BsM-fSCQ.js} +4 -4
- package/dist/{console-BGgGnjSi.js.map → console-BsM-fSCQ.js.map} +1 -1
- package/dist/{console-CSZ5_Vx5.cjs → console-Dkxs6IVQ.cjs} +2 -2
- package/dist/{console-CSZ5_Vx5.cjs.map → console-Dkxs6IVQ.cjs.map} +1 -1
- package/dist/{constants-CUyd9cTZ.js → constants-BwJDXzj6.js} +23 -23
- package/dist/constants-BwJDXzj6.js.map +1 -0
- package/dist/constants-CtF52hIV.cjs +2 -0
- package/dist/constants-CtF52hIV.cjs.map +1 -0
- package/dist/constants.d.cts +12 -0
- package/dist/constants.d.ts +12 -0
- package/dist/core/diagnostics.d.cts +1 -1
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/rotation.d.cts +26 -2
- package/dist/core/rotation.d.ts +26 -2
- package/dist/core/runtime.d.cts +9 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/{debug-bundle-BXIlwDKM.cjs → debug-bundle-B2v6Cym-.cjs} +2 -2
- package/dist/{debug-bundle-BXIlwDKM.cjs.map → debug-bundle-B2v6Cym-.cjs.map} +1 -1
- package/dist/{debug-bundle-CRpYV_ui.js → debug-bundle-Cs_YWzTa.js} +4 -4
- package/dist/{debug-bundle-CRpYV_ui.js.map → debug-bundle-Cs_YWzTa.js.map} +1 -1
- package/dist/doctor.cjs +1 -1
- package/dist/doctor.js +31 -31
- package/dist/doctor.js.map +1 -1
- package/dist/{errors-CNPbesMs.cjs → errors-DP2RUm4V.cjs} +2 -2
- package/dist/{errors-CNPbesMs.cjs.map → errors-DP2RUm4V.cjs.map} +1 -1
- package/dist/{errors-BE_EZV7Q.js → errors-Q3Ng1ciC.js} +3 -3
- package/dist/{errors-BE_EZV7Q.js.map → errors-Q3Ng1ciC.js.map} +1 -1
- package/dist/{factory-CTi0Is3F.js → factory-DV17sm2p.js} +22 -22
- package/dist/{factory-CTi0Is3F.js.map → factory-DV17sm2p.js.map} +1 -1
- package/dist/{factory-hRrH32v5.cjs → factory-K8O6gpux.cjs} +2 -2
- package/dist/{factory-hRrH32v5.cjs.map → factory-K8O6gpux.cjs.map} +1 -1
- package/dist/{identity-DdhKgrpk.js → identity-BgtHyY4u.js} +38 -27
- package/dist/identity-BgtHyY4u.js.map +1 -0
- package/dist/identity-CvuyqZk7.cjs +2 -0
- package/dist/identity-CvuyqZk7.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +600 -569
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-CL9uqBCy.cjs → indexeddb-storage-D4KVcqdD.cjs} +2 -2
- package/dist/{indexeddb-storage-CL9uqBCy.cjs.map → indexeddb-storage-D4KVcqdD.cjs.map} +1 -1
- package/dist/{indexeddb-storage-GHdl0t8A.js → indexeddb-storage-e-13ZLWm.js} +17 -17
- package/dist/{indexeddb-storage-GHdl0t8A.js.map → indexeddb-storage-e-13ZLWm.js.map} +1 -1
- package/dist/interactions-Byxf1C82.js +207 -0
- package/dist/interactions-Byxf1C82.js.map +1 -0
- package/dist/interactions-OK85T-Dk.cjs +2 -0
- package/dist/interactions-OK85T-Dk.cjs.map +1 -0
- package/dist/{journey-D2_sia57.js → journey-C93FTYcs.js} +14 -14
- package/dist/{journey-D2_sia57.js.map → journey-C93FTYcs.js.map} +1 -1
- package/dist/{journey-B4Adltjm.cjs → journey-nMbob3OB.cjs} +2 -2
- package/dist/{journey-B4Adltjm.cjs.map → journey-nMbob3OB.cjs.map} +1 -1
- package/dist/{library-console-CPW6bvZH.cjs → library-console-DJUQzcgM.cjs} +2 -2
- package/dist/{library-console-CPW6bvZH.cjs.map → library-console-DJUQzcgM.cjs.map} +1 -1
- package/dist/{library-console-Btrzt814.js → library-console-DklSmucS.js} +2 -2
- package/dist/{library-console-Btrzt814.js.map → library-console-DklSmucS.js.map} +1 -1
- package/dist/{library-request-BJ9PLRaD.js → library-request-UGEwOHpf.js} +2 -2
- package/dist/{library-request-BJ9PLRaD.js.map → library-request-UGEwOHpf.js.map} +1 -1
- package/dist/{library-request-D7OvTxZV.cjs → library-request-kY9iTpIF.cjs} +2 -2
- package/dist/{library-request-D7OvTxZV.cjs.map → library-request-kY9iTpIF.cjs.map} +1 -1
- package/dist/{lifecycle-22CUCrc9.js → lifecycle-B2PlIuQu.js} +2 -2
- package/dist/{lifecycle-22CUCrc9.js.map → lifecycle-B2PlIuQu.js.map} +1 -1
- package/dist/{lifecycle-IaAm1mOC.cjs → lifecycle-DaMdH_X7.cjs} +2 -2
- package/dist/{lifecycle-IaAm1mOC.cjs.map → lifecycle-DaMdH_X7.cjs.map} +1 -1
- package/dist/{log-record-CkivuiEl.cjs → log-record-Bmx6etMh.cjs} +2 -2
- package/dist/{log-record-CkivuiEl.cjs.map → log-record-Bmx6etMh.cjs.map} +1 -1
- package/dist/{log-record-BNiLfqtL.js → log-record-DSt2P-Sr.js} +2 -2
- package/dist/{log-record-BNiLfqtL.js.map → log-record-DSt2P-Sr.js.map} +1 -1
- package/dist/{long-frames-DNFaRnC3.js → long-frames-Bamjs1WV.js} +3 -3
- package/dist/{long-frames-DNFaRnC3.js.map → long-frames-Bamjs1WV.js.map} +1 -1
- package/dist/{long-frames-BUUbXd-B.cjs → long-frames-lhtONgGt.cjs} +2 -2
- package/dist/{long-frames-BUUbXd-B.cjs.map → long-frames-lhtONgGt.cjs.map} +1 -1
- package/dist/models/bus.d.cts +6 -1
- package/dist/models/bus.d.ts +6 -1
- package/dist/models/config.d.cts +23 -8
- package/dist/models/config.d.ts +23 -8
- package/dist/models/serializer.d.cts +3 -1
- package/dist/models/serializer.d.ts +3 -1
- package/dist/{network-CGMLQ-mA.cjs → network-BCn8Gn47.cjs} +2 -2
- package/dist/{network-CGMLQ-mA.cjs.map → network-BCn8Gn47.cjs.map} +1 -1
- package/dist/{network-on2zZT6H.js → network-Cg1L2w2r.js} +12 -12
- package/dist/{network-on2zZT6H.js.map → network-Cg1L2w2r.js.map} +1 -1
- package/dist/observed-windows-B3gJkdql.cjs +2 -0
- package/dist/observed-windows-B3gJkdql.cjs.map +1 -0
- package/dist/observed-windows-BrwaJNlj.js +64 -0
- package/dist/observed-windows-BrwaJNlj.js.map +1 -0
- package/dist/{otlp-BENHf3g9.cjs → otlp-CrAWkQdO.cjs} +2 -2
- package/dist/{otlp-BENHf3g9.cjs.map → otlp-CrAWkQdO.cjs.map} +1 -1
- package/dist/{otlp-DimfrRor.js → otlp-D6dRZyB8.js} +6 -6
- package/dist/{otlp-DimfrRor.js.map → otlp-D6dRZyB8.js.map} +1 -1
- package/dist/{platform-BaaFIPCU.js → platform-8DLhjddo.js} +7 -7
- package/dist/{platform-BaaFIPCU.js.map → platform-8DLhjddo.js.map} +1 -1
- package/dist/{platform-CfA3-7sJ.cjs → platform-BqRc-7RO.cjs} +2 -2
- package/dist/{platform-CfA3-7sJ.cjs.map → platform-BqRc-7RO.cjs.map} +1 -1
- package/dist/{profiler-BAZoh7A4.js → profiler-BaXSqCfz.js} +59 -59
- package/dist/{profiler-BAZoh7A4.js.map → profiler-BaXSqCfz.js.map} +1 -1
- package/dist/{profiler-D4tJpDRc.cjs → profiler-BvWW2kNM.cjs} +2 -2
- package/dist/{profiler-D4tJpDRc.cjs.map → profiler-BvWW2kNM.cjs.map} +1 -1
- package/dist/{profiler-frames-cJMx9wNM.js → profiler-frames-C4ySHN0X.js} +16 -16
- package/dist/{profiler-frames-cJMx9wNM.js.map → profiler-frames-C4ySHN0X.js.map} +1 -1
- package/dist/{profiler-frames-C4xr7KfH.cjs → profiler-frames-DeaBiB-5.cjs} +2 -2
- package/dist/{profiler-frames-C4xr7KfH.cjs.map → profiler-frames-DeaBiB-5.cjs.map} +1 -1
- package/dist/{remote-rules-_tY0zj5o.cjs → remote-rules-D7L6D_D2.cjs} +2 -2
- package/dist/{remote-rules-_tY0zj5o.cjs.map → remote-rules-D7L6D_D2.cjs.map} +1 -1
- package/dist/{remote-rules-Dz9MRAsB.js → remote-rules-Dq9xe7Qn.js} +22 -22
- package/dist/{remote-rules-Dz9MRAsB.js.map → remote-rules-Dq9xe7Qn.js.map} +1 -1
- package/dist/{replay-Ds-ANH34.js → replay-B0M8kWz_.js} +24 -24
- package/dist/{replay-Ds-ANH34.js.map → replay-B0M8kWz_.js.map} +1 -1
- package/dist/{replay-B3gFXIZd.cjs → replay-QOFBpAXh.cjs} +2 -2
- package/dist/{replay-B3gFXIZd.cjs.map → replay-QOFBpAXh.cjs.map} +1 -1
- package/dist/{reports-C-thq-bk.js → reports--8APRLa-.js} +3 -3
- package/dist/{reports-C-thq-bk.js.map → reports--8APRLa-.js.map} +1 -1
- package/dist/{reports-BDSe4dFH.cjs → reports-ojuMKGO7.cjs} +2 -2
- package/dist/{reports-BDSe4dFH.cjs.map → reports-ojuMKGO7.cjs.map} +1 -1
- package/dist/{resource-timing-eUl2dNgC.js → resource-timing-BzR05rE-.js} +4 -4
- package/dist/{resource-timing-eUl2dNgC.js.map → resource-timing-BzR05rE-.js.map} +1 -1
- package/dist/{resource-timing-C576gFIQ.cjs → resource-timing-pAG3ZhB5.cjs} +2 -2
- package/dist/{resource-timing-C576gFIQ.cjs.map → resource-timing-pAG3ZhB5.cjs.map} +1 -1
- package/dist/{response-body-eoSQpLiH.js → response-body-BWvwKQ2p.js} +106 -106
- package/dist/{response-body-eoSQpLiH.js.map → response-body-BWvwKQ2p.js.map} +1 -1
- package/dist/{response-body-YdNl-HkR.cjs → response-body-CKEJ5itk.cjs} +3 -3
- package/dist/{response-body-YdNl-HkR.cjs.map → response-body-CKEJ5itk.cjs.map} +1 -1
- package/dist/{rotation-Cwct4ckk.js → rotation-BylN1B9e.js} +10 -11
- package/dist/rotation-BylN1B9e.js.map +1 -0
- package/dist/rotation-E2eKClIs.cjs +2 -0
- package/dist/rotation-E2eKClIs.cjs.map +1 -0
- package/dist/{sampling-mXt4dstx.cjs → sampling-B46LW0cy.cjs} +2 -2
- package/dist/{sampling-mXt4dstx.cjs.map → sampling-B46LW0cy.cjs.map} +1 -1
- package/dist/{sampling-BlrI8jor.js → sampling-zXA6r-Nw.js} +16 -16
- package/dist/{sampling-BlrI8jor.js.map → sampling-zXA6r-Nw.js.map} +1 -1
- package/dist/{sanitize-Ba0KqU06.js → sanitize-DjnR6RXR.js} +2 -2
- package/dist/{sanitize-Ba0KqU06.js.map → sanitize-DjnR6RXR.js.map} +1 -1
- package/dist/{sanitize-DQyiI_KY.cjs → sanitize-Qj6LuZqp.cjs} +2 -2
- package/dist/{sanitize-DQyiI_KY.cjs.map → sanitize-Qj6LuZqp.cjs.map} +1 -1
- package/dist/{sender-Dv8rAmpV.js → sender-Bdp-TAS4.js} +71 -71
- package/dist/{sender-Dv8rAmpV.js.map → sender-Bdp-TAS4.js.map} +1 -1
- package/dist/{sender-BdRuNVhF.cjs → sender-DR7ZycZY.cjs} +2 -2
- package/dist/{sender-BdRuNVhF.cjs.map → sender-DR7ZycZY.cjs.map} +1 -1
- package/dist/{stored-context-CXt7eHZL.cjs → stored-context-BOu54M8Y.cjs} +2 -2
- package/dist/{stored-context-CXt7eHZL.cjs.map → stored-context-BOu54M8Y.cjs.map} +1 -1
- package/dist/{stored-context-B2EzVuYm.js → stored-context-CSttrAsw.js} +6 -6
- package/dist/{stored-context-B2EzVuYm.js.map → stored-context-CSttrAsw.js.map} +1 -1
- package/dist/{storm-C-zYSdDX.cjs → storm-BHgI12iS.cjs} +2 -2
- package/dist/{storm-C-zYSdDX.cjs.map → storm-BHgI12iS.cjs.map} +1 -1
- package/dist/{storm-DjKetLKZ.js → storm-DKlpv0FL.js} +2 -2
- package/dist/{storm-DjKetLKZ.js.map → storm-DKlpv0FL.js.map} +1 -1
- package/dist/{unclean-exit-py99ApzT.cjs → unclean-exit-BYPYYkQ5.cjs} +2 -2
- package/dist/{unclean-exit-py99ApzT.cjs.map → unclean-exit-BYPYYkQ5.cjs.map} +1 -1
- package/dist/{unclean-exit-DQD1cT7c.js → unclean-exit-BcOB8A2e.js} +2 -2
- package/dist/{unclean-exit-DQD1cT7c.js.map → unclean-exit-BcOB8A2e.js.map} +1 -1
- package/dist/{user-timing-BePqb1uN.js → user-timing-4KIJ74Vi.js} +2 -2
- package/dist/{user-timing-BePqb1uN.js.map → user-timing-4KIJ74Vi.js.map} +1 -1
- package/dist/{user-timing-D6XTmpuM.cjs → user-timing-BsU2wQKE.cjs} +2 -2
- package/dist/{user-timing-D6XTmpuM.cjs.map → user-timing-BsU2wQKE.cjs.map} +1 -1
- package/dist/utils/identity.d.cts +5 -0
- package/dist/utils/identity.d.ts +5 -0
- package/dist/{web-socket-CoIUBM3C.cjs → web-socket-Cs1ZbmmN.cjs} +2 -2
- package/dist/{web-socket-CoIUBM3C.cjs.map → web-socket-Cs1ZbmmN.cjs.map} +1 -1
- package/dist/{web-socket-DSHgDiZ6.js → web-socket-Zg0hj1LB.js} +4 -4
- package/dist/{web-socket-DSHgDiZ6.js.map → web-socket-Zg0hj1LB.js.map} +1 -1
- package/dist/{worker-protocol-x074Rpet.js → worker-protocol-CYpAbrVl.js} +4 -4
- package/dist/{worker-protocol-x074Rpet.js.map → worker-protocol-CYpAbrVl.js.map} +1 -1
- package/dist/{worker-protocol-QbvqNazn.cjs → worker-protocol-DFYXIFus.cjs} +2 -2
- package/dist/{worker-protocol-QbvqNazn.cjs.map → worker-protocol-DFYXIFus.cjs.map} +1 -1
- package/dist/{worker-server-CFe4nvos.cjs → worker-server--yGTadTA.cjs} +2 -2
- package/dist/{worker-server-CFe4nvos.cjs.map → worker-server--yGTadTA.cjs.map} +1 -1
- package/dist/{worker-server-iUVSjH8L.js → worker-server-BokySIII.js} +25 -25
- package/dist/{worker-server-iUVSjH8L.js.map → worker-server-BokySIII.js.map} +1 -1
- package/dist/worker-transport-BdEvh_-a.cjs +2 -0
- package/dist/worker-transport-BdEvh_-a.cjs.map +1 -0
- package/dist/{worker-transport-Dy1KMA7t.js → worker-transport-JK-Fby9J.js} +23 -19
- package/dist/worker-transport-JK-Fby9J.js.map +1 -0
- package/llms.txt +13 -10
- package/package.json +13 -5
- package/dist/bus-C39wspFV.js.map +0 -1
- package/dist/bus-_EaOVPGq.cjs +0 -2
- package/dist/bus-_EaOVPGq.cjs.map +0 -1
- package/dist/config-DUs7uHHt.cjs +0 -2
- package/dist/config-DUs7uHHt.cjs.map +0 -1
- package/dist/config-SgQcCP1_.js.map +0 -1
- package/dist/constants-CUyd9cTZ.js.map +0 -1
- package/dist/constants-CqdJhTxH.cjs +0 -2
- package/dist/constants-CqdJhTxH.cjs.map +0 -1
- package/dist/identity-DdhKgrpk.js.map +0 -1
- package/dist/identity-DlWRIuwy.cjs +0 -2
- package/dist/identity-DlWRIuwy.cjs.map +0 -1
- package/dist/interactions-CUkzK8sR.cjs +0 -2
- package/dist/interactions-CUkzK8sR.cjs.map +0 -1
- package/dist/interactions-DiFvCosX.js +0 -111
- package/dist/interactions-DiFvCosX.js.map +0 -1
- package/dist/rotation-Cwct4ckk.js.map +0 -1
- package/dist/rotation-D4qUAHAu.cjs +0 -2
- package/dist/rotation-D4qUAHAu.cjs.map +0 -1
- package/dist/worker-transport-CRAX-09c.cjs +0 -2
- package/dist/worker-transport-CRAX-09c.cjs.map +0 -1
- package/dist/worker-transport-Dy1KMA7t.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=stored-context-
|
|
1
|
+
const e=require("./constants-CtF52hIV.cjs"),t=require("./factory-K8O6gpux.cjs"),n=require("./identity-CvuyqZk7.cjs");var r=[[`local`,e.Hn],[`session`,e.er],[`session`,e.Dt]];async function i(e,n){let{config:r,diagnostics:i,memory:a}=e,{backend:o,namespace:s}=r.storage,c=a??await t.t(o,t.n(s),t.p(r.retention),i,void 0,s),l=new t.f(c,r.securityContext,s);try{await n(l)}finally{c!==a&&await l.close()}}function a(e,a,o,s=!1){if(s)for(let[t,i]of r)e.diagnostics.guard(`storage.unavailable`,`The library could not remove ${i} from ${t}Storage.`,()=>{n.t[t]().removeItem(i)});return i(e,async n=>{for(let e of o)await n.remove(e);a===`namespace`?await n.clearNamespace():await n.clear();let{diagnostics:r,config:i}=e;t.s(i.securityContext.id,r,n.namespace,a===`namespace`)})}function o(e,t,r){return i(e,async i=>{let a=[...r];if(t.length>0){let r=n.i(e.diagnostics);a.push({id:r,records:[...t],createdAt:Date.now(),attempts:0})}for(let t of a)await i.save({...t,attempts:0,routingContextId:e.config.securityContext.id,persistenceNamespace:i.namespace})})}exports.clearStored=a,exports.keepStored=o;
|
|
2
|
+
//# sourceMappingURL=stored-context-BOu54M8Y.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stored-context-
|
|
1
|
+
{"version":3,"file":"stored-context-BOu54M8Y.cjs","names":["SESSION_ID_KEY","TAB_ID_KEY","JOURNEY_STORAGE_KEY","createStorage","storageName","storageLimits","ContextStorage","newId","require_constants","require_factory","require_identity","STORED_IDS","withStore","access","config","backing","memory","backend","namespace","diagnostics","store","work","clearStored","forgetIds","key","id","ids","scope","keepStored","all","batches","records","batch"],"sources":["../src/storage/stored-context.ts"],"sourcesContent":["// src/storage/stored-context.ts\n//\n// Reaches the configured store when no delivery stack runs. shutdown() with clearStorage and a\n// rotation with no old sender need it, because otherwise only a sender opens the store.\n\nimport { JOURNEY_STORAGE_KEY, SESSION_ID_KEY, TAB_ID_KEY } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { LogRecord } from \"../models/log-record\";\nimport { type StorageAdapter, storageLimits } from \"../models/storage\";\nimport { BROWSER_STORES, newId } from \"../utils/identity\";\nimport { ContextStorage } from \"./context-storage\";\nimport { clearEmergencyContext } from \"./emergency-queue\";\nimport { createStorage, storageName } from \"./factory\";\n\n/** The stored ids that a shutdown with clearStorage removes: the session, the tab and the journey. */\nconst STORED_IDS = [\n [\"local\", SESSION_ID_KEY],\n [\"session\", TAB_ID_KEY],\n [\"session\", JOURNEY_STORAGE_KEY],\n] as const;\n\n/** What opening the store needs. The active context is the one in `config.securityContext`. */\nexport interface StoreAccess {\n /** Active configuration instance. */\n config: ResolvedConfig;\n /** Diagnostics reporter. */\n diagnostics: Diagnostics;\n /** The memory store the runtime keeps across context changes, if it has one. */\n memory: StorageAdapter | undefined;\n}\n\n/**\n * Opens the store for the active context, runs the work, then closes the store again. The\n * memory store stays open, because it holds other contexts' records too.\n * @param access The config, the reporter and the kept memory store.\n * @param work What to do with the store.\n * @returns Promise that resolves once the work is done and the store is closed.\n */\nasync function withStore(\n access: StoreAccess,\n work: (store: ContextStorage) => Promise<void>,\n): Promise<void> {\n const { config, diagnostics, memory } = access;\n const { backend, namespace } = config.storage;\n const backing =\n memory ??\n (await createStorage(\n backend,\n storageName(namespace),\n storageLimits(config.retention),\n diagnostics,\n undefined,\n namespace,\n ));\n const store = new ContextStorage(backing, config.securityContext, namespace);\n try {\n await work(store);\n } finally {\n if (backing !== memory) {\n await store.close();\n }\n }\n}\n\n/**\n * Removes the active context's stored batches and its emergency entries, or the whole\n * namespace's. A discard rotation with no sender uses it, as Sender.retire() would, and so does\n * shutdown() with clearStorage.\n * @param access The config, the reporter and the kept memory store.\n * @param scope Whose stored records to remove: the context's or the namespace's.\n * @param ids More batches to remove by id, for example the ones a carry left under an older id.\n * @param forgetIds True to also remove the stored session id, tab id and journey.\n * @returns Promise that resolves once the batches are removed.\n */\nexport function clearStored(\n access: StoreAccess,\n scope: \"context\" | \"namespace\",\n ids: readonly string[],\n forgetIds = false,\n): Promise<void> {\n // The ids go first, so a store that won't open still leaves no session for the next user.\n if (forgetIds) {\n for (const [store, key] of STORED_IDS) {\n access.diagnostics.guard(\n \"storage.unavailable\",\n `The library could not remove ${key} from ${store}Storage.`,\n () => {\n BROWSER_STORES[store]().removeItem(key);\n },\n );\n }\n }\n\n return withStore(access, async (store) => {\n for (const id of ids) {\n await store.remove(id);\n }\n\n if (scope === \"namespace\") {\n await store.clearNamespace();\n } else {\n await store.clear();\n }\n\n const { diagnostics, config } = access;\n clearEmergencyContext(\n config.securityContext.id,\n diagnostics,\n store.namespace,\n scope === \"namespace\",\n );\n });\n}\n\n/**\n * Stores records and batches under the active context, as a retain rotation does with a sender.\n * The records go in one batch. A batch keeps its id, so its older copy is replaced.\n * @param access The config, the reporter and the kept memory store.\n * @param records Records that waited in memory.\n * @param batches Stored batches of an earlier context, for example the ones a carry left.\n * @returns Promise that resolves once each batch is stored.\n */\nexport function keepStored(\n access: StoreAccess,\n records: readonly LogRecord[],\n batches: readonly LogBatch[],\n): Promise<void> {\n return withStore(access, async (store) => {\n const all = [...batches];\n if (records.length > 0) {\n const id = newId(access.diagnostics);\n all.push({ id, records: [...records], createdAt: Date.now(), attempts: 0 });\n }\n\n for (const batch of all) {\n await store.save({\n ...batch,\n attempts: 0,\n routingContextId: access.config.securityContext.id,\n persistenceNamespace: store.namespace,\n });\n }\n });\n}\n"],"mappings":"A,qHAiBA,IAAMW,EAAa,CACjB,CAAC,QAASX,EAAAA,EAAc,EACxB,CAAC,UAAWC,EAAAA,EAAU,EACtB,CAAC,UAAWC,EAAAA,EAAmB,CACjC,EAmBA,eAAeU,EACb,EACA,EACe,CACf,GAAM,CAAE,SAAQ,cAAa,UAAWC,EAClC,CAAE,UAAS,aAAcC,EAAO,QAChCC,EACJC,GACC,MAAMb,EAAAA,EACLc,EACAb,EAAAA,EAAYc,CAAS,EACrBb,EAAAA,EAAcS,EAAO,SAAS,EAC9BK,EACA,IAAA,GACAD,CACF,EACIE,EAAQ,IAAId,EAAAA,EAAeS,EAASD,EAAO,gBAAiBI,CAAS,EAC3E,GAAI,CACF,MAAMG,EAAKD,CAAK,CAClB,QAAU,CACJL,IAAYC,GACd,MAAMI,EAAM,MAAM,CAEtB,CACF,CAYA,SAAgBE,EACd,EACA,EACA,EACA,EAAY,GACG,CAEf,GAAIC,EACF,IAAK,GAAM,CAACH,EAAOI,KAAQb,EACzBE,EAAO,YAAY,MACjB,sBACA,gCAAgCW,EAAI,QAAQJ,EAAM,cAC5C,CACJV,EAAA,EAAeU,EAAM,CAAC,CAAC,CAAC,WAAWI,CAAG,CACxC,CACF,EAIJ,OAAOZ,EAAUC,EAAQ,KAAO,IAAU,CACxC,IAAK,IAAMY,KAAMC,EACf,MAAMN,EAAM,OAAOK,CAAE,EAGnBE,IAAU,YACZ,MAAMP,EAAM,eAAe,EAE3B,MAAMA,EAAM,MAAM,EAGpB,GAAM,CAAE,cAAa,UAAWP,EAChCJ,EAAA,EACEK,EAAO,gBAAgB,GACvBK,EACAC,EAAM,UACNO,IAAU,WACZ,CACF,CAAC,CACH,CAUA,SAAgBC,EACd,EACA,EACA,EACe,CACf,OAAOhB,EAAUC,EAAQ,KAAO,IAAU,CACxC,IAAMgB,EAAM,CAAC,GAAGC,CAAO,EACvB,GAAIC,EAAQ,OAAS,EAAG,CACtB,IAAMN,EAAKlB,EAAAA,EAAMM,EAAO,WAAW,EACnCgB,EAAI,KAAK,CAAE,KAAI,QAAS,CAAC,GAAGE,CAAO,EAAG,UAAW,KAAK,IAAI,EAAG,SAAU,CAAE,CAAC,CAC5E,CAEA,IAAK,IAAMC,KAASH,EAClB,MAAMT,EAAM,KAAK,CACf,GAAGY,EACH,SAAU,EACV,iBAAkBnB,EAAO,OAAO,gBAAgB,GAChD,qBAAsBO,EAAM,SAC9B,CAAC,CAEL,CAAC,CACH,C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as r, n as i, p as a, s as o, t as s } from "./factory-
|
|
3
|
-
import { i as c, t as l } from "./identity-
|
|
1
|
+
import { Dt as e, Hn as t, er as n } from "./constants-BwJDXzj6.js";
|
|
2
|
+
import { f as r, n as i, p as a, s as o, t as s } from "./factory-DV17sm2p.js";
|
|
3
|
+
import { i as c, t as l } from "./identity-BgtHyY4u.js";
|
|
4
4
|
// src/storage/stored-context.ts
|
|
5
5
|
var u = [
|
|
6
|
-
["local",
|
|
7
|
-
["session",
|
|
6
|
+
["local", t],
|
|
7
|
+
["session", n],
|
|
8
8
|
["session", e]
|
|
9
9
|
];
|
|
10
10
|
async function d(e, t) {
|
|
@@ -48,4 +48,4 @@ function p(e, t, n) {
|
|
|
48
48
|
}
|
|
49
49
|
export { f as clearStored, p as keepStored };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=stored-context-
|
|
51
|
+
//# sourceMappingURL=stored-context-CSttrAsw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stored-context-
|
|
1
|
+
{"version":3,"file":"stored-context-CSttrAsw.js","names":["JOURNEY_STORAGE_KEY","SESSION_ID_KEY","TAB_ID_KEY","ContextStorage","storageName","storageLimits","clearEmergencyContext","createStorage","newId","BROWSER_STORES","STORED_IDS","withStore","access","config","backing","memory","backend","namespace","diagnostics","store","work","clearStored","forgetIds","key","id","ids","scope","keepStored","all","batches","records","batch"],"sources":["../src/storage/stored-context.ts"],"sourcesContent":["// src/storage/stored-context.ts\n//\n// Reaches the configured store when no delivery stack runs. shutdown() with clearStorage and a\n// rotation with no old sender need it, because otherwise only a sender opens the store.\n\nimport { JOURNEY_STORAGE_KEY, SESSION_ID_KEY, TAB_ID_KEY } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { LogRecord } from \"../models/log-record\";\nimport { type StorageAdapter, storageLimits } from \"../models/storage\";\nimport { BROWSER_STORES, newId } from \"../utils/identity\";\nimport { ContextStorage } from \"./context-storage\";\nimport { clearEmergencyContext } from \"./emergency-queue\";\nimport { createStorage, storageName } from \"./factory\";\n\n/** The stored ids that a shutdown with clearStorage removes: the session, the tab and the journey. */\nconst STORED_IDS = [\n [\"local\", SESSION_ID_KEY],\n [\"session\", TAB_ID_KEY],\n [\"session\", JOURNEY_STORAGE_KEY],\n] as const;\n\n/** What opening the store needs. The active context is the one in `config.securityContext`. */\nexport interface StoreAccess {\n /** Active configuration instance. */\n config: ResolvedConfig;\n /** Diagnostics reporter. */\n diagnostics: Diagnostics;\n /** The memory store the runtime keeps across context changes, if it has one. */\n memory: StorageAdapter | undefined;\n}\n\n/**\n * Opens the store for the active context, runs the work, then closes the store again. The\n * memory store stays open, because it holds other contexts' records too.\n * @param access The config, the reporter and the kept memory store.\n * @param work What to do with the store.\n * @returns Promise that resolves once the work is done and the store is closed.\n */\nasync function withStore(\n access: StoreAccess,\n work: (store: ContextStorage) => Promise<void>,\n): Promise<void> {\n const { config, diagnostics, memory } = access;\n const { backend, namespace } = config.storage;\n const backing =\n memory ??\n (await createStorage(\n backend,\n storageName(namespace),\n storageLimits(config.retention),\n diagnostics,\n undefined,\n namespace,\n ));\n const store = new ContextStorage(backing, config.securityContext, namespace);\n try {\n await work(store);\n } finally {\n if (backing !== memory) {\n await store.close();\n }\n }\n}\n\n/**\n * Removes the active context's stored batches and its emergency entries, or the whole\n * namespace's. A discard rotation with no sender uses it, as Sender.retire() would, and so does\n * shutdown() with clearStorage.\n * @param access The config, the reporter and the kept memory store.\n * @param scope Whose stored records to remove: the context's or the namespace's.\n * @param ids More batches to remove by id, for example the ones a carry left under an older id.\n * @param forgetIds True to also remove the stored session id, tab id and journey.\n * @returns Promise that resolves once the batches are removed.\n */\nexport function clearStored(\n access: StoreAccess,\n scope: \"context\" | \"namespace\",\n ids: readonly string[],\n forgetIds = false,\n): Promise<void> {\n // The ids go first, so a store that won't open still leaves no session for the next user.\n if (forgetIds) {\n for (const [store, key] of STORED_IDS) {\n access.diagnostics.guard(\n \"storage.unavailable\",\n `The library could not remove ${key} from ${store}Storage.`,\n () => {\n BROWSER_STORES[store]().removeItem(key);\n },\n );\n }\n }\n\n return withStore(access, async (store) => {\n for (const id of ids) {\n await store.remove(id);\n }\n\n if (scope === \"namespace\") {\n await store.clearNamespace();\n } else {\n await store.clear();\n }\n\n const { diagnostics, config } = access;\n clearEmergencyContext(\n config.securityContext.id,\n diagnostics,\n store.namespace,\n scope === \"namespace\",\n );\n });\n}\n\n/**\n * Stores records and batches under the active context, as a retain rotation does with a sender.\n * The records go in one batch. A batch keeps its id, so its older copy is replaced.\n * @param access The config, the reporter and the kept memory store.\n * @param records Records that waited in memory.\n * @param batches Stored batches of an earlier context, for example the ones a carry left.\n * @returns Promise that resolves once each batch is stored.\n */\nexport function keepStored(\n access: StoreAccess,\n records: readonly LogRecord[],\n batches: readonly LogBatch[],\n): Promise<void> {\n return withStore(access, async (store) => {\n const all = [...batches];\n if (records.length > 0) {\n const id = newId(access.diagnostics);\n all.push({ id, records: [...records], createdAt: Date.now(), attempts: 0 });\n }\n\n for (const batch of all) {\n await store.save({\n ...batch,\n attempts: 0,\n routingContextId: access.config.securityContext.id,\n persistenceNamespace: store.namespace,\n });\n }\n });\n}\n"],"mappings":";;;;AAiBA,IAAMU,IAAa;CACjB,CAAC,SAAST,CAAc;CACxB,CAAC,WAAWC,CAAU;CACtB,CAAC,WAAWF,CAAmB;AACjC;AAmBA,eAAeW,EACb,GACA,GACe;CACf,IAAM,EAAE,WAAQ,gBAAa,cAAWC,GAClC,EAAE,YAAS,iBAAcC,EAAO,SAChCC,IACJC,KACC,MAAMR,EACLS,GACAZ,EAAYa,CAAS,GACrBZ,EAAcQ,EAAO,SAAS,GAC9BK,GACA,KAAA,GACAD,CACF,GACIE,IAAQ,IAAIhB,EAAeW,GAASD,EAAO,iBAAiBI,CAAS;CAC3E,IAAI;EACF,MAAMG,EAAKD,CAAK;CAClB,UAAU;EACR,AAAIL,MAAYC,KACd,MAAMI,EAAM,MAAM;CAEtB;AACF;AAYA,SAAgBE,EACd,GACA,GACA,GACA,IAAY,IACG;CAEf,IAAIC,GACF,KAAK,IAAM,CAACH,GAAOI,MAAQb,GACzB,EAAO,YAAY,MACjB,uBACA,gCAAgCa,EAAI,QAAQJ,EAAM,iBAC5C;EACJ,EAAeA,EAAM,CAAC,CAAC,CAAC,WAAWI,CAAG;CACxC,CACF;CAIJ,OAAOZ,EAAUC,GAAQ,OAAO,MAAU;EACxC,KAAK,IAAMY,KAAMC,GACf,MAAMN,EAAM,OAAOK,CAAE;EAGvB,AAAIE,MAAU,cACZ,MAAMP,EAAM,eAAe,IAE3B,MAAMA,EAAM,MAAM;EAGpB,IAAM,EAAE,gBAAa,cAAWP;EAChC,EACEC,EAAO,gBAAgB,IACvBK,GACAC,EAAM,WACNO,MAAU,WACZ;CACF,CAAC;AACH;AAUA,SAAgBC,EACd,GACA,GACA,GACe;CACf,OAAOhB,EAAUC,GAAQ,OAAO,MAAU;EACxC,IAAMgB,IAAM,CAAC,GAAGC,CAAO;EACvB,IAAIC,EAAQ,SAAS,GAAG;GACtB,IAAMN,IAAKhB,EAAMI,EAAO,WAAW;GACnC,EAAI,KAAK;IAAE;IAAI,SAAS,CAAC,GAAGkB,CAAO;IAAG,WAAW,KAAK,IAAI;IAAG,UAAU;GAAE,CAAC;EAC5E;EAEA,KAAK,IAAMC,KAASH,GAClB,MAAMT,EAAM,KAAK;GACf,GAAGY;GACH,UAAU;GACV,kBAAkBnB,EAAO,OAAO,gBAAgB;GAChD,sBAAsBO,EAAM;EAC9B,CAAC;CAEL,CAAC;AACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=storm-
|
|
1
|
+
const e=require("./constants-CtF52hIV.cjs"),t=require("./fixed-window-CvESpFYV.cjs");function n(n,r,i,a,o=e.rt){return r===null||t.t(n,r,o)?!0:(i.report(`capture.rate_limited`,`More than ${String(r)} ${a} occurred in ${String(o)} ms. The library ignores the other ${a} in this window.`),!1)}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
|
2
|
+
//# sourceMappingURL=storm-BHgI12iS.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storm-
|
|
1
|
+
{"version":3,"file":"storm-BHgI12iS.cjs","names":["ERROR_STORM_WINDOW_MS","countInWindow","require_constants","require_fixed_window","allowInWindow","limit","window","windowMs","diagnostics","what"],"sources":["../src/capture/storm.ts"],"sourcesContent":["// src/capture/storm.ts\n//\n// Fixed-window rate limit for the capture modules. A render loop that throws or freezes\n// produces thousands of events a second, and sending them all would flood the ingest endpoint.\n\nimport { ERROR_STORM_WINDOW_MS } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { countInWindow, type StormWindow } from \"../utils/fixed-window\";\n\nexport type { StormWindow } from \"../utils/fixed-window\";\n\n/**\n * Counts one event in a fixed window and reports every event over the limit.\n * @param window Window state to update.\n * @param limit Maximum events per window. 0 allows none, and null means no limit.\n * @param diagnostics Diagnostics reporter.\n * @param what Plural name of the events, for the diagnostic message.\n * @param windowMs Rate limit window, in milliseconds.\n * @returns False when the window has no allowance left. The caller must drop the event.\n */\nexport function allowInWindow(\n window: StormWindow,\n limit: number | null,\n diagnostics: Diagnostics,\n what: string,\n windowMs = ERROR_STORM_WINDOW_MS,\n): boolean {\n if (limit === null || countInWindow(window, limit, windowMs)) {\n return true;\n }\n\n diagnostics.report(\n \"capture.rate_limited\",\n `More than ${String(limit)} ${what} occurred in ${String(windowMs)} ms. The library ignores the other ${what} in this window.`,\n );\n return false;\n}\n"],"mappings":"A,qFAoBA,SAAgBI,EACd,EACA,EACA,EACA,EACA,EAAWJ,EAAAA,GACF,CAST,OARIK,IAAU,MAAQJ,EAAAA,EAAcK,EAAQD,EAAOE,CAAQ,EAClD,IAGTC,EAAY,OACV,uBACA,aAAa,OAAOH,CAAK,EAAE,GAAGI,EAAK,eAAe,OAAOF,CAAQ,EAAE,qCAAqCE,EAAK,iBAC/G,EACO,GACT,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rt as e } from "./constants-BwJDXzj6.js";
|
|
2
2
|
import { t } from "./fixed-window-Dq3MLUUv.js";
|
|
3
3
|
// src/capture/storm.ts
|
|
4
4
|
function n(n, r, i, a, o = e) {
|
|
@@ -6,4 +6,4 @@ function n(n, r, i, a, o = e) {
|
|
|
6
6
|
}
|
|
7
7
|
export { n as t };
|
|
8
8
|
|
|
9
|
-
//# sourceMappingURL=storm-
|
|
9
|
+
//# sourceMappingURL=storm-DKlpv0FL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storm-
|
|
1
|
+
{"version":3,"file":"storm-DKlpv0FL.js","names":["ERROR_STORM_WINDOW_MS","allowInWindow","limit","countInWindow","window","windowMs","diagnostics","what"],"sources":["../src/capture/storm.ts"],"sourcesContent":["// src/capture/storm.ts\n//\n// Fixed-window rate limit for the capture modules. A render loop that throws or freezes\n// produces thousands of events a second, and sending them all would flood the ingest endpoint.\n\nimport { ERROR_STORM_WINDOW_MS } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { countInWindow, type StormWindow } from \"../utils/fixed-window\";\n\nexport type { StormWindow } from \"../utils/fixed-window\";\n\n/**\n * Counts one event in a fixed window and reports every event over the limit.\n * @param window Window state to update.\n * @param limit Maximum events per window. 0 allows none, and null means no limit.\n * @param diagnostics Diagnostics reporter.\n * @param what Plural name of the events, for the diagnostic message.\n * @param windowMs Rate limit window, in milliseconds.\n * @returns False when the window has no allowance left. The caller must drop the event.\n */\nexport function allowInWindow(\n window: StormWindow,\n limit: number | null,\n diagnostics: Diagnostics,\n what: string,\n windowMs = ERROR_STORM_WINDOW_MS,\n): boolean {\n if (limit === null || countInWindow(window, limit, windowMs)) {\n return true;\n }\n\n diagnostics.report(\n \"capture.rate_limited\",\n `More than ${String(limit)} ${what} occurred in ${String(windowMs)} ms. The library ignores the other ${what} in this window.`,\n );\n return false;\n}\n"],"mappings":";;;AAoBA,SAAgBC,EACd,GACA,GACA,GACA,GACA,IAAWD,GACF;CAST,OARIE,MAAU,QAAQC,EAAcC,GAAQF,GAAOG,CAAQ,IAClD,MAGTC,EAAY,OACV,wBACA,aAAa,OAAOJ,CAAK,EAAE,GAAGK,EAAK,eAAe,OAAOF,CAAQ,EAAE,qCAAqCE,EAAK,iBAC/G,GACO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-
|
|
2
|
-
//# sourceMappingURL=unclean-exit-
|
|
1
|
+
const e=require("./constants-CtF52hIV.cjs"),t=require("./defineProperty-X1c4tIPD.cjs");function n(e){let t=e===null?null:JSON.parse(e);if(typeof t!=`object`||!t)return null;let{sessionId:n,at:r,visibility:i}=t;return typeof n==`string`&&Number.isFinite(r)&&typeof i==`string`?{sessionId:n,at:r,visibility:i}:null}var r=class{constructor(n){t.t(this,`ctx`,void 0),t.t(this,`name`,`uncleanExit`),t.t(this,`installed`,!1),t.t(this,`timer`,void 0),t.t(this,`closing`,!1),t.t(this,`mark`,()=>{if(this.closing)return;let t={sessionId:this.ctx.sessionId(),at:Date.now(),visibility:document.visibilityState};this.ctx.diagnostics.guard(`storage.unavailable`,`The library could not write the alive marker to sessionStorage.`,()=>{sessionStorage.setItem(e.n,JSON.stringify(t))})}),t.t(this,`onPageHide`,()=>{this.closing=!0,this.clear()}),t.t(this,`onPageShow`,e=>{e.persisted&&(this.closing=!1,this.mark())}),this.ctx=n}install(){this.installed||typeof document>`u`||window.parent!==window||(this.ctx.config.identity===`memory`?this.ctx.diagnostics.report(`capture.install_failed`,`capture.uncleanExit needs sessionStorage. identity: "memory" turns it off.`):(this.installed=!0,this.ctx.once.uncleanExit||(this.ctx.once.uncleanExit=!0,window.opener||this.reportPrevious()),this.mark(),addEventListener(`pagehide`,this.onPageHide),addEventListener(`pageshow`,this.onPageShow),document.addEventListener(`visibilitychange`,this.mark),this.timer=setInterval(this.mark,e.r)))}uninstall(){this.installed&&(this.installed=!1,removeEventListener(`pagehide`,this.onPageHide),removeEventListener(`pageshow`,this.onPageShow),document.removeEventListener(`visibilitychange`,this.mark),clearInterval(this.timer),this.clear())}reportPrevious(){let t=this.ctx.diagnostics.guard(`storage.unavailable`,`The library could not read the alive marker in sessionStorage.`,()=>n(sessionStorage.getItem(e.n)));t&&this.ctx.logger.warn(`ui.unclean_exit`,{"exit.session_id":t.sessionId,"exit.last_seen_ms":t.at,"exit.visibility":t.visibility,"exit.discarded":document.wasDiscarded===!0})}clear(){this.ctx.diagnostics.guard(`storage.unavailable`,`The library could not remove the alive marker from sessionStorage.`,()=>{sessionStorage.removeItem(e.n)})}};exports.UncleanExitCapture=r;
|
|
2
|
+
//# sourceMappingURL=unclean-exit-BYPYYkQ5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unclean-exit-
|
|
1
|
+
{"version":3,"file":"unclean-exit-BYPYYkQ5.cjs","names":["ALIVE_KEY","ALIVE_UPDATE_MS","require_constants","require_defineProperty","readMarker","value","text","sessionId","at","visibility","UncleanExitCapture","marker","event","ctx"],"sources":["../src/capture/unclean-exit.ts"],"sourcesContent":["// src/capture/unclean-exit.ts\n//\n// Detects a page in this tab that ended without a clean close, for example after a crash. The\n// top document keeps a marker in sessionStorage and a clean close removes it, so if the tab's\n// next page finds a marker, it reports it.\n\nimport { ALIVE_KEY, ALIVE_UPDATE_MS } from \"../constants\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Marker left by a page that is alive. */\ninterface AliveMarker {\n /** The page's session id. */\n sessionId: string;\n /** When the marker was last updated, in epoch milliseconds. */\n at: number;\n /** The page's visibility at the last update. */\n visibility: string;\n}\n\n/** A document with the flag the browser sets on a page it discarded to free memory. */\ninterface DiscardDocument {\n wasDiscarded?: boolean;\n}\n\n/**\n * Reads a marker from its sessionStorage text.\n * @param text Stored text, or null when there is no marker.\n * @returns The marker, or null if there is none or it has the wrong shape.\n * @throws SyntaxError for text that isn't JSON. The caller reports it.\n */\nfunction readMarker(text: string | null): AliveMarker | null {\n const value: unknown = text === null ? null : JSON.parse(text);\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n\n const { sessionId, at, visibility } = value as Partial<Record<keyof AliveMarker, unknown>>;\n const valid =\n typeof sessionId === \"string\" && Number.isFinite(at) && typeof visibility === \"string\";\n\n return valid ? { sessionId, at: at as number, visibility } : null;\n}\n\n/** Reports the previous page's unclean exit, and maintains this page's marker. */\nexport class UncleanExitCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"uncleanExit\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Timer that updates the marker. */\n private timer: ReturnType<typeof setInterval> | undefined;\n\n /** True after pagehide. Needed because the browser fires visibilitychange after pagehide. */\n private closing = false;\n\n /**\n * @param ctx Capture context with the config, diagnostics, logger and session id.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Reports the previous page's marker once, then starts maintaining this page's own. */\n install(): void {\n // Only the top document keeps the marker, because a same-origin frame shares its\n // sessionStorage.\n if (this.installed || typeof document === \"undefined\" || window.parent !== window) {\n return;\n }\n\n // The marker holds the session id, and memory identity writes nothing to the device.\n if (this.ctx.config.identity === \"memory\") {\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n 'capture.uncleanExit needs sessionStorage. identity: \"memory\" turns it off.',\n );\n return;\n }\n this.installed = true;\n\n if (!this.ctx.once.uncleanExit) {\n this.ctx.once.uncleanExit = true;\n // A popup copies its live opener's sessionStorage, so that marker isn't a crash.\n if (!window.opener) {\n this.reportPrevious();\n }\n }\n\n this.mark();\n addEventListener(\"pagehide\", this.onPageHide);\n addEventListener(\"pageshow\", this.onPageShow);\n document.addEventListener(\"visibilitychange\", this.mark);\n this.timer = setInterval(this.mark, ALIVE_UPDATE_MS);\n }\n\n /** Removes the listeners, the timer and the marker, since the capture stopped without a crash. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"pagehide\", this.onPageHide);\n removeEventListener(\"pageshow\", this.onPageShow);\n document.removeEventListener(\"visibilitychange\", this.mark);\n clearInterval(this.timer);\n this.clear();\n }\n\n /** Logs WARN `ui.unclean_exit` if this tab's previous page left its marker behind. */\n private reportPrevious(): void {\n const marker = this.ctx.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the alive marker in sessionStorage.\",\n () => readMarker(sessionStorage.getItem(ALIVE_KEY)),\n );\n if (!marker) {\n return;\n }\n\n this.ctx.logger.warn(\"ui.unclean_exit\", {\n \"exit.session_id\": marker.sessionId,\n \"exit.last_seen_ms\": marker.at,\n \"exit.visibility\": marker.visibility,\n \"exit.discarded\": (document as DiscardDocument).wasDiscarded === true,\n });\n }\n\n /** Writes this page's marker with the current time and visibility. */\n private readonly mark = (): void => {\n if (this.closing) {\n return;\n }\n\n const marker: AliveMarker = {\n sessionId: this.ctx.sessionId(),\n at: Date.now(),\n visibility: document.visibilityState,\n };\n\n this.ctx.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not write the alive marker to sessionStorage.\",\n () => {\n sessionStorage.setItem(ALIVE_KEY, JSON.stringify(marker));\n },\n );\n };\n\n /** Removes this page's marker. */\n private clear(): void {\n this.ctx.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not remove the alive marker from sessionStorage.\",\n () => {\n sessionStorage.removeItem(ALIVE_KEY);\n },\n );\n }\n\n /** A clean close removes the marker. The page may still live on in the back-forward cache. */\n private readonly onPageHide = (): void => {\n this.closing = true;\n this.clear();\n };\n\n /** A page that comes back from the back-forward cache is alive again. */\n private readonly onPageShow = (event: Event): void => {\n if ((event as PageTransitionEvent).persisted) {\n this.closing = false;\n this.mark();\n }\n };\n}\n"],"mappings":"A,uFA8BA,SAASI,EAAW,EAAyC,CAC3D,IAAMC,EAAiBC,IAAS,KAAO,KAAO,KAAK,MAAMA,CAAI,EAC7D,GAAI,OAAOD,GAAU,WAAYA,EAC/B,OAAO,KAGT,GAAM,CAAE,YAAW,KAAI,cAAeA,EAItC,OAFE,OAAOE,GAAc,UAAY,OAAO,SAASC,CAAE,GAAK,OAAOC,GAAe,SAEjE,CAAE,YAAe,KAAc,YAAW,EAAI,IAC/D,CAGA,IAAaC,EAAb,KAAmD,CAgBjD,YAAY,EAAsC,CAArBP,EAAA,EAAA,KAAA,MAAA,IAAA,EAAA,EAd7BA,EAAA,EAAA,KAAA,OAAgB,aAAA,EAGhBA,EAAA,EAAA,KAAA,YAAoB,EAAA,EAGpBA,EAAA,EAAA,KAAA,QAAA,IAAA,EAAA,EAGAA,EAAA,EAAA,KAAA,UAAkB,EAAA,EA0ElBA,EAAA,EAAA,KAAA,WAAoC,CAClC,GAAI,KAAK,QACP,OAGF,IAAMQ,EAAsB,CAC1B,U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AAO,GAC5B,kBAAmBA,EAAO,WAC1B,iBAAmB,SAA6B,eAAiB,EACnE,CAAC,CACH,CAwBA,OAAsB,CACpB,KAAK,IAAI,YAAY,MACnB,sBACA,yEACM,CACJ,eAAe,WAAWX,EAAAA,CAAS,CACrC,CACF,CACF,CAeF,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, r as t } from "./constants-
|
|
1
|
+
import { n as e, r as t } from "./constants-BwJDXzj6.js";
|
|
2
2
|
import { t as n } from "./defineProperty-s2S8BXUc.js";
|
|
3
3
|
// src/capture/unclean-exit.ts
|
|
4
4
|
function r(e) {
|
|
@@ -52,4 +52,4 @@ var i = class {
|
|
|
52
52
|
};
|
|
53
53
|
export { i as UncleanExitCapture };
|
|
54
54
|
|
|
55
|
-
//# sourceMappingURL=unclean-exit-
|
|
55
|
+
//# sourceMappingURL=unclean-exit-BcOB8A2e.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unclean-exit-
|
|
1
|
+
{"version":3,"file":"unclean-exit-BcOB8A2e.js","names":["ALIVE_KEY","ALIVE_UPDATE_MS","_defineProperty","readMarker","value","text","sessionId","at","visibility","UncleanExitCapture","marker","event","ctx"],"sources":["../src/capture/unclean-exit.ts"],"sourcesContent":["// src/capture/unclean-exit.ts\n//\n// Detects a page in this tab that ended without a clean close, for example after a crash. The\n// top document keeps a marker in sessionStorage and a clean close removes it, so if the tab's\n// next page finds a marker, it reports it.\n\nimport { ALIVE_KEY, ALIVE_UPDATE_MS } from \"../constants\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Marker left by a page that is alive. */\ninterface AliveMarker {\n /** The page's session id. */\n sessionId: string;\n /** When the marker was last updated, in epoch milliseconds. */\n at: number;\n /** The page's visibility at the last update. */\n visibility: string;\n}\n\n/** A document with the flag the browser sets on a page it discarded to free memory. */\ninterface DiscardDocument {\n wasDiscarded?: boolean;\n}\n\n/**\n * Reads a marker from its sessionStorage text.\n * @param text Stored text, or null when there is no marker.\n * @returns The marker, or null if there is none or it has the wrong shape.\n * @throws SyntaxError for text that isn't JSON. The caller reports it.\n */\nfunction readMarker(text: string | null): AliveMarker | null {\n const value: unknown = text === null ? null : JSON.parse(text);\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n\n const { sessionId, at, visibility } = value as Partial<Record<keyof AliveMarker, unknown>>;\n const valid =\n typeof sessionId === \"string\" && Number.isFinite(at) && typeof visibility === \"string\";\n\n return valid ? { sessionId, at: at as number, visibility } : null;\n}\n\n/** Reports the previous page's unclean exit, and maintains this page's marker. */\nexport class UncleanExitCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"uncleanExit\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Timer that updates the marker. */\n private timer: ReturnType<typeof setInterval> | undefined;\n\n /** True after pagehide. Needed because the browser fires visibilitychange after pagehide. */\n private closing = false;\n\n /**\n * @param ctx Capture context with the config, diagnostics, logger and session id.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Reports the previous page's marker once, then starts maintaining this page's own. */\n install(): void {\n // Only the top document keeps the marker, because a same-origin frame shares its\n // sessionStorage.\n if (this.installed || typeof document === \"undefined\" || window.parent !== window) {\n return;\n }\n\n // The marker holds the session id, and memory identity writes nothing to the device.\n if (this.ctx.config.identity === \"memory\") {\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n 'capture.uncleanExit needs sessionStorage. identity: \"memory\" turns it off.',\n );\n return;\n }\n this.installed = true;\n\n if (!this.ctx.once.uncleanExit) {\n this.ctx.once.uncleanExit = true;\n // A popup copies its live opener's sessionStorage, so that marker isn't a crash.\n if (!window.opener) {\n this.reportPrevious();\n }\n }\n\n this.mark();\n addEventListener(\"pagehide\", this.onPageHide);\n addEventListener(\"pageshow\", this.onPageShow);\n document.addEventListener(\"visibilitychange\", this.mark);\n this.timer = setInterval(this.mark, ALIVE_UPDATE_MS);\n }\n\n /** Removes the listeners, the timer and the marker, since the capture stopped without a crash. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"pagehide\", this.onPageHide);\n removeEventListener(\"pageshow\", this.onPageShow);\n document.removeEventListener(\"visibilitychange\", this.mark);\n clearInterval(this.timer);\n this.clear();\n }\n\n /** Logs WARN `ui.unclean_exit` if this tab's previous page left its marker behind. */\n private reportPrevious(): void {\n const marker = this.ctx.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not read the alive marker in sessionStorage.\",\n () => readMarker(sessionStorage.getItem(ALIVE_KEY)),\n );\n if (!marker) {\n return;\n }\n\n this.ctx.logger.warn(\"ui.unclean_exit\", {\n \"exit.session_id\": marker.sessionId,\n \"exit.last_seen_ms\": marker.at,\n \"exit.visibility\": marker.visibility,\n \"exit.discarded\": (document as DiscardDocument).wasDiscarded === true,\n });\n }\n\n /** Writes this page's marker with the current time and visibility. */\n private readonly mark = (): void => {\n if (this.closing) {\n return;\n }\n\n const marker: AliveMarker = {\n sessionId: this.ctx.sessionId(),\n at: Date.now(),\n visibility: document.visibilityState,\n };\n\n this.ctx.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not write the alive marker to sessionStorage.\",\n () => {\n sessionStorage.setItem(ALIVE_KEY, JSON.stringify(marker));\n },\n );\n };\n\n /** Removes this page's marker. */\n private clear(): void {\n this.ctx.diagnostics.guard(\n \"storage.unavailable\",\n \"The library could not remove the alive marker from sessionStorage.\",\n () => {\n sessionStorage.removeItem(ALIVE_KEY);\n },\n );\n }\n\n /** A clean close removes the marker. The page may still live on in the back-forward cache. */\n private readonly onPageHide = (): void => {\n this.closing = true;\n this.clear();\n };\n\n /** A page that comes back from the back-forward cache is alive again. */\n private readonly onPageShow = (event: Event): void => {\n if ((event as PageTransitionEvent).persisted) {\n this.closing = false;\n this.mark();\n }\n };\n}\n"],"mappings":";;;AA8BA,SAASG,EAAW,GAAyC;CAC3D,IAAMC,IAAiBC,MAAS,OAAO,OAAO,KAAK,MAAMA,CAAI;CAC7D,IAAI,OAAOD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BAAiB,oBAAoB,KAAK,IAAI,GACvD,KAAK,QAAQ,YAAY,KAAK,MAAMX,CAAe;CACrD;CAGA,YAAkB;EAChB,AAAK,KAAK,cAGV,KAAK,YAAY,IAEjB,oBAAoB,YAAY,KAAK,UAAU,GAC/C,oBAAoB,YAAY,KAAK,UAAU,GAC/C,SAAS,oBAAoB,oBAAoB,KAAK,IAAI,GAC1D,cAAc,KAAK,KAAK,GACxB,KAAK,MAAM;CACb;CAGA,iBAA+B;EAC7B,IAAMS,IAAS,KAAK,IAAI,YAAY,MAClC,uBACA,wEACMP,EAAW,eAAe,QAAQH,CAAS,CAAC,CACpD;EACA,AAAKU,KAIL,KAAK,IAAI,OAAO,KAAK,mBAAmB;GACtC,mBAAmBA,EAAO;GAC1B,qBAAqBA,EAAO;GAC5B,mBAAmBA,EAAO;GAC1B,kBAAmB,SAA6B,iBAAiB;EACnE,CAAC;CACH;CAwBA,QAAsB;EACpB,KAAK,IAAI,YAAY,MACnB,uBACA,4EACM;GACJ,eAAe,WAAWV,CAAS;EACrC,CACF;CACF;AAeF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e } from "./platform-
|
|
1
|
+
import { i as e } from "./platform-8DLhjddo.js";
|
|
2
2
|
import { t } from "./types-BAerHgCq.js";
|
|
3
3
|
import { t as n } from "./defineProperty-s2S8BXUc.js";
|
|
4
4
|
// src/capture/user-timing.ts
|
|
@@ -60,4 +60,4 @@ var r = {
|
|
|
60
60
|
};
|
|
61
61
|
export { i as UserTimingCapture };
|
|
62
62
|
|
|
63
|
-
//# sourceMappingURL=user-timing-
|
|
63
|
+
//# sourceMappingURL=user-timing-4KIJ74Vi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-timing-
|
|
1
|
+
{"version":3,"file":"user-timing-4KIJ74Vi.js","names":["recordedUrl","_defineProperty","USER_TIMING_DURATION","UserTimingCapture","ctx","first","once","supported","list","include","userTiming","entry","entries","matchesAny","name","fullUrls"],"sources":["../src/capture/user-timing.ts"],"sourcesContent":["// src/capture/user-timing.ts\n//\n// Records the app's marks and measures from the User Timing API. A measure goes into a\n// histogram, and a mark adds a breadcrumb.\n\nimport type { InstrumentDef } from \"../models/metric\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Histogram of the app's measures, in milliseconds. */\nconst USER_TIMING_DURATION: InstrumentDef = {\n name: \"ui.user_timing.duration\",\n kind: \"histogram\",\n unit: \"ms\",\n boundaries: [1, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n};\n\n/** Observes the app's marks and measures. */\nexport class UserTimingCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"userTiming\";\n\n /** Observer for the mark and measure entries. */\n private observer: PerformanceObserver | undefined;\n\n /**\n * @param ctx Capture context with the config, the meter and the breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Observes marks and measures. Only the first install in a document reads buffered entries. */\n install(): void {\n if (this.observer) {\n return;\n }\n\n const { once } = this.ctx;\n const first = !once.userTiming;\n once.userTiming = true;\n\n // Older browsers have no supportedEntryTypes, and the capture stays off there.\n const supported: readonly string[] | undefined =\n typeof PerformanceObserver === \"undefined\"\n ? undefined\n : PerformanceObserver.supportedEntryTypes;\n if (!supported?.includes(\"measure\")) {\n if (first) {\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not report User Timing entries. The user timing capture is off.\",\n );\n }\n return;\n }\n\n this.observer = new PerformanceObserver((list) => {\n // The browser calls this directly, so anything we throw is an uncaught error on the page.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a user timing entry.\",\n () => {\n this.record(list.getEntries());\n },\n );\n });\n // Buffered entries include the marks and measures made before this chunk loaded.\n this.observer.observe({ type: \"measure\", buffered: first });\n if (supported.includes(\"mark\")) {\n this.observer.observe({ type: \"mark\", buffered: first });\n }\n }\n\n /** Disconnects the observer. */\n uninstall(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /**\n * Records the entries whose name `userTiming.include` selects.\n * @param entries Mark and measure entries.\n */\n private record(entries: PerformanceEntryList): void {\n if (this.ctx.isActive?.() === false) {\n return;\n }\n\n const { fullUrls, userTiming } = this.ctx.config.capture;\n const include = typeof userTiming === \"object\" ? userTiming.include : undefined;\n for (const entry of entries) {\n if (include !== undefined && include.length > 0 && !matchesAny(entry.name, include)) {\n continue;\n }\n\n // A third-party script can write any name, so a name can hold a URL with a token.\n const name = recordedUrl(entry.name, fullUrls);\n if (entry.entryType === \"measure\") {\n this.ctx.recordMetric(USER_TIMING_DURATION, entry.duration, { \"user_timing.name\": name });\n } else {\n this.ctx.breadcrumbs.push({\n // A buffered entry reaches the observer late, and the trail needs the mark's own time.\n t: Math.round(performance.timeOrigin + entry.startTime),\n category: \"event\",\n message: name.slice(0, this.ctx.config.limits.maxBodyChars),\n });\n }\n }\n }\n}\n"],"mappings":";;;;AAUA,IAAME,IAAsC;CAC1C,MAAM;CACN,MAAM;CACN,MAAM;CACN,YAAY;EAAC;EAAG;EAAG;EAAI;EAAI;EAAI;EAAK;EAAK;EAAK;EAAM;EAAM;EAAM;CAAK;AACvE,GAGaC,IAAb,MAAkD;CAUhD,YAAY,GAAsC;EAArB,AAAAF,EAAA,MAAA,OAAA,KAAA,CAAA,GAR7BA,EAAA,MAAA,QAAgB,YAAA,GAGhBA,EAAA,MAAA,YAAA,KAAA,CAAA,GAK6B,KAAA,MAAAG;CAAsB;CAGnD,UAAgB;EACd,IAAI,KAAK,UACP;EAGF,IAAM,EAAE,YAAS,KAAK,KAChBC,IAAQ,CAACC,EAAK;EACpB,EAAK,aAAa;EAGlB,IAAMC,IACJ,OAAO,sBAAwB,MAC3B,KAAA,IACA,oBAAoB;EAC1B,AAAKA,GAAW,SAAS,SAAS,KAUlC,KAAK,WAAW,IAAI,qBAAqB,MAAS;GAEhD,KAAK,IAAI,YAAY,MACnB,yBACA,2DACM;IACJ,KAAK,OAAOC,EAAK,WAAW,CAAC;GAC/B,CACF;EACF,CAAC,GAED,KAAK,SAAS,QAAQ;GAAE,MAAM;GAAW,UAAUH;EAAM,CAAC,GACtDE,EAAU,SAAS,MAAM,KAC3B,KAAK,SAAS,QAAQ;GAAE,MAAM;GAAQ,UAAUF;EAAM,CAAC,KAtBnDA,KACF,KAAK,IAAI,YAAY,OACnB,0BACA,kFACF;CAoBN;CAGA,YAAkB;EAEhB,AADA,KAAK,UAAU,WAAW,GAC1B,KAAK,WAAW,KAAA;CAClB;CAMA,OAAe,GAAqC;EAClD,IAAI,KAAK,IAAI,WAAW,MAAM,IAC5B;EAGF,IAAM,EAAE,aAAU,kBAAe,KAAK,IAAI,OAAO,SAC3CI,IAAU,OAAOC,KAAe,WAAWA,EAAW,UAAU,KAAA;EACtE,KAAK,IAAMC,KAASC,GAAS;GAC3B,IAAIH,MAAY,KAAA,KAAaA,EAAQ,SAAS,KAAK,CAACI,EAAWF,EAAM,MAAMF,CAAO,GAChF;GAIF,IAAMK,IAAOd,EAAYW,EAAM,MAAMI,CAAQ;GAC7C,AAAIJ,EAAM,cAAc,YACtB,KAAK,IAAI,aAAaT,GAAsBS,EAAM,UAAU,EAAE,oBAAoBG,EAAK,CAAC,IAExF,KAAK,IAAI,YAAY,KAAK;IAExB,GAAG,KAAK,MAAM,YAAY,aAAaH,EAAM,SAAS;IACtD,UAAU;IACV,SAASG,EAAK,MAAM,GAAG,KAAK,IAAI,OAAO,OAAO,YAAY;GAC5D,CAAC;EAEL;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./platform-
|
|
2
|
-
//# sourceMappingURL=user-timing-
|
|
1
|
+
const e=require("./platform-BqRc-7RO.cjs"),t=require("./types-C7WNpnG1.cjs"),n=require("./defineProperty-X1c4tIPD.cjs");var r={name:`ui.user_timing.duration`,kind:`histogram`,unit:`ms`,boundaries:[1,5,10,25,50,100,250,500,1e3,2500,5e3,1e4]},i=class{constructor(e){n.t(this,`ctx`,void 0),n.t(this,`name`,`userTiming`),n.t(this,`observer`,void 0),this.ctx=e}install(){if(this.observer)return;let{once:e}=this.ctx,t=!e.userTiming;e.userTiming=!0;let n=typeof PerformanceObserver>`u`?void 0:PerformanceObserver.supportedEntryTypes;n?.includes(`measure`)?(this.observer=new PerformanceObserver(e=>{this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a user timing entry.`,()=>{this.record(e.getEntries())})}),this.observer.observe({type:`measure`,buffered:t}),n.includes(`mark`)&&this.observer.observe({type:`mark`,buffered:t})):t&&this.ctx.diagnostics.report(`capture.install_failed`,`The browser does not report User Timing entries. The user timing capture is off.`)}uninstall(){this.observer?.disconnect(),this.observer=void 0}record(n){if(this.ctx.isActive?.()===!1)return;let{fullUrls:i,userTiming:a}=this.ctx.config.capture,o=typeof a==`object`?a.include:void 0;for(let a of n){if(o!==void 0&&o.length>0&&!t.t(a.name,o))continue;let n=e.i(a.name,i);a.entryType===`measure`?this.ctx.recordMetric(r,a.duration,{"user_timing.name":n}):this.ctx.breadcrumbs.push({t:Math.round(performance.timeOrigin+a.startTime),category:`event`,message:n.slice(0,this.ctx.config.limits.maxBodyChars)})}}};exports.UserTimingCapture=i;
|
|
2
|
+
//# sourceMappingURL=user-timing-BsU2wQKE.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-timing-
|
|
1
|
+
{"version":3,"file":"user-timing-BsU2wQKE.cjs","names":["matchesAny","recordedUrl","require_platform","require_types","require_defineProperty","USER_TIMING_DURATION","UserTimingCapture","ctx","first","once","supported","list","include","userTiming","entry","entries","name","fullUrls"],"sources":["../src/capture/user-timing.ts"],"sourcesContent":["// src/capture/user-timing.ts\n//\n// Records the app's marks and measures from the User Timing API. A measure goes into a\n// histogram, and a mark adds a breadcrumb.\n\nimport type { InstrumentDef } from \"../models/metric\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Histogram of the app's measures, in milliseconds. */\nconst USER_TIMING_DURATION: InstrumentDef = {\n name: \"ui.user_timing.duration\",\n kind: \"histogram\",\n unit: \"ms\",\n boundaries: [1, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n};\n\n/** Observes the app's marks and measures. */\nexport class UserTimingCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"userTiming\";\n\n /** Observer for the mark and measure entries. */\n private observer: PerformanceObserver | undefined;\n\n /**\n * @param ctx Capture context with the config, the meter and the breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Observes marks and measures. Only the first install in a document reads buffered entries. */\n install(): void {\n if (this.observer) {\n return;\n }\n\n const { once } = this.ctx;\n const first = !once.userTiming;\n once.userTiming = true;\n\n // Older browsers have no supportedEntryTypes, and the capture stays off there.\n const supported: readonly string[] | undefined =\n typeof PerformanceObserver === \"undefined\"\n ? undefined\n : PerformanceObserver.supportedEntryTypes;\n if (!supported?.includes(\"measure\")) {\n if (first) {\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not report User Timing entries. The user timing capture is off.\",\n );\n }\n return;\n }\n\n this.observer = new PerformanceObserver((list) => {\n // The browser calls this directly, so anything we throw is an uncaught error on the page.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a user timing entry.\",\n () => {\n this.record(list.getEntries());\n },\n );\n });\n // Buffered entries include the marks and measures made before this chunk loaded.\n this.observer.observe({ type: \"measure\", buffered: first });\n if (supported.includes(\"mark\")) {\n this.observer.observe({ type: \"mark\", buffered: first });\n }\n }\n\n /** Disconnects the observer. */\n uninstall(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /**\n * Records the entries whose name `userTiming.include` selects.\n * @param entries Mark and measure entries.\n */\n private record(entries: PerformanceEntryList): void {\n if (this.ctx.isActive?.() === false) {\n return;\n }\n\n const { fullUrls, userTiming } = this.ctx.config.capture;\n const include = typeof userTiming === \"object\" ? userTiming.include : undefined;\n for (const entry of entries) {\n if (include !== undefined && include.length > 0 && !matchesAny(entry.name, include)) {\n continue;\n }\n\n // A third-party script can write any name, so a name can hold a URL with a token.\n const name = recordedUrl(entry.name, fullUrls);\n if (entry.entryType === \"measure\") {\n this.ctx.recordMetric(USER_TIMING_DURATION, entry.duration, { \"user_timing.name\": name });\n } else {\n this.ctx.breadcrumbs.push({\n // A buffered entry reaches the observer late, and the trail needs the mark's own time.\n t: Math.round(performance.timeOrigin + entry.startTime),\n category: \"event\",\n message: name.slice(0, this.ctx.config.limits.maxBodyChars),\n });\n }\n }\n }\n}\n"],"mappings":"A,wHAUA,IAAMK,EAAsC,CAC1C,KAAM,0BACN,KAAM,YACN,KAAM,KACN,WAAY,CAAC,EAAG,EAAG,GAAI,GAAI,GAAI,IAAK,IAAK,IAAK,IAAM,KAAM,IAAM,GAAK,CACvE,EAGaC,EAAb,KAAkD,CAUhD,YAAY,EAAsC,CAArBF,EAAA,EAAA,KAAA,MAAA,IAAA,EAAA,EAR7BA,EAAA,EAAA,KAAA,OAAgB,YAAA,EAGhBA,EAAA,EAAA,KAAA,WAAA,IAAA,EAAA,EAK6B,KAAA,IAAAG,CAAsB,CAGnD,SAAgB,CACd,GAAI,KAAK,SACP,OAGF,GAAM,CAAE,QAAS,KAAK,IAChBC,EAAQ,CAACC,EAAK,WACpB,EAAK,WAAa,GAGlB,IAAMC,EACJ,OAAO,oBAAwB,IAC3B,IAAA,GACA,oBAAoB,oBACrBA,GAAW,SAAS,SAAS,GAUlC,KAAK,SAAW,IAAI,oBAAqB,GAAS,CAEhD,KAAK,IAAI,YAAY,MACnB,wBACA,wDACM,CACJ,KAAK,OAAOC,EAAK,WAAW,CAAC,CAC/B,CACF,CACF,CAAC,EAED,KAAK,SAAS,QAAQ,CAAE,KAAM,UAAW,SAAUH,CAAM,CAAC,EACtDE,EAAU,SAAS,MAAM,GAC3B,KAAK,SAAS,QAAQ,CAAE,KAAM,OAAQ,SAAUF,CAAM,CAAC,GAtBnDA,GACF,KAAK,IAAI,YAAY,OACnB,yBACA,kFACF,CAoBN,CAGA,WAAkB,CAChB,KAAK,UAAU,WAAW,EAC1B,KAAK,SAAW,IAAA,EAClB,CAMA,OAAe,EAAqC,CAClD,GAAI,KAAK,IAAI,WAAW,IAAM,GAC5B,OAGF,GAAM,CAAE,WAAU,cAAe,KAAK,IAAI,OAAO,QAC3CI,EAAU,OAAOC,GAAe,SAAWA,EAAW,QAAU,IAAA,GACtE,IAAK,IAAMC,KAASC,EAAS,CAC3B,GAAIH,IAAY,IAAA,IAAaA,EAAQ,OAAS,GAAK,CAACZ,EAAAA,EAAWc,EAAM,KAAMF,CAAO,EAChF,SAIF,IAAMI,EAAOf,EAAAA,EAAYa,EAAM,KAAMG,CAAQ,EACzCH,EAAM,YAAc,UACtB,KAAK,IAAI,aAAaT,EAAsBS,EAAM,SAAU,CAAE,mBAAoBE,CAAK,CAAC,EAExF,KAAK,IAAI,YAAY,KAAK,CAExB,EAAG,KAAK,MAAM,YAAY,WAAaF,EAAM,SAAS,EACtD,SAAU,QACV,QAASE,EAAK,MAAM,EAAG,KAAK,IAAI,OAAO,OAAO,YAAY,CAC5D,CAAC,CAEL,CACF,CACF,E"}
|
|
@@ -34,6 +34,11 @@ export interface IdentityStores {
|
|
|
34
34
|
local(): KeyValueStore;
|
|
35
35
|
/** Store that lasts for one tab. */
|
|
36
36
|
session(): KeyValueStore;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the live opener's tab store, or null without one. Memory stores leave it out,
|
|
39
|
+
* because they can't hold a copied tab id. A cross-origin opener throws.
|
|
40
|
+
*/
|
|
41
|
+
opener?(): KeyValueStore | null;
|
|
37
42
|
}
|
|
38
43
|
/** Stores that write to the browser. Used by the `identity: "storage"` option. */
|
|
39
44
|
export declare const BROWSER_STORES: IdentityStores;
|
package/dist/utils/identity.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ export interface IdentityStores {
|
|
|
34
34
|
local(): KeyValueStore;
|
|
35
35
|
/** Store that lasts for one tab. */
|
|
36
36
|
session(): KeyValueStore;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the live opener's tab store, or null without one. Memory stores leave it out,
|
|
39
|
+
* because they can't hold a copied tab id. A cross-origin opener throws.
|
|
40
|
+
*/
|
|
41
|
+
opener?(): KeyValueStore | null;
|
|
37
42
|
}
|
|
38
43
|
/** Stores that write to the browser. Used by the `identity: "storage"` option. */
|
|
39
44
|
export declare const BROWSER_STORES: IdentityStores;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./library-request-
|
|
2
|
-
//# sourceMappingURL=web-socket-
|
|
1
|
+
const e=require("./library-request-kY9iTpIF.cjs"),t=require("./platform-BqRc-7RO.cjs"),n=require("./patch-BX8KrPCT.cjs"),r=require("./storm-BHgI12iS.cjs"),i=require("./types-C7WNpnG1.cjs"),a=require("./defineProperty-X1c4tIPD.cjs");var o=`ui.websocket.messages`;function s(e,n,r){let i=new URL(e);return{target:t.i(e,!1,n.capture.urlTransform,r),server:i.hostname}}function c(t,n,r){let i=t.servers.get(n),a=r===`transmit`&&e.t();if(!t.active||i===void 0||a||t.config.securityContext.isolation&&t.contexts.get(n)!==t.config.securityContext.id)return;let o={"network.io.direction":r,"server.address":i};t.messages.add(1,o)}var l=class{constructor(e,t){a.t(this,`diagnostics`,void 0),a.t(this,`config`,void 0),a.t(this,`name`,`websocket`),a.t(this,`restore`,void 0),a.t(this,`state`,void 0),a.t(this,`window`,{start:0,count:0}),this.diagnostics=e,this.config=t}install(e){if(this.restore||typeof WebSocket>`u`)return;let t={active:!0,ctx:e,messages:e.counter(o),servers:new WeakMap,contexts:new WeakMap,config:this.config};this.state=t;let r=e=>{this.track(e,t)};this.restore=n.t(globalThis,`WebSocket`,e=>class extends e{static[Symbol.hasInstance](t){return t instanceof e}constructor(e,t){super(e,t),r(this)}send(e){super.send(e),c(t,this,`transmit`)}})}uninstall(){this.state&&(this.state.active=!1),this.restore&&!this.restore()&&this.diagnostics.report(`capture.install_failed`,`Another script wrapped WebSocket after the library. The library keeps that wrapper.`),this.restore=void 0,this.state=void 0}track(e,t){t.active&&this.diagnostics.guard(`capture.record_failed`,`The library could not track a WebSocket. The socket works without capture.`,()=>{if(i.t(e.url,this.config.capture.ignoreUrls))return;let{target:n,server:r}=s(e.url,this.config,this.diagnostics),a={"url.full":n,"server.address":r},{logger:o}=t.ctx;t.servers.set(e,r),t.contexts.set(e,this.config.securityContext.id);let l=n=>{(!this.config.securityContext.isolation||t.contexts.get(e)===this.config.securityContext.id)&&this.allow(t)&&n()};e.addEventListener(`open`,()=>{l(()=>{o.logEvent(`websocket.open`,a)})}),e.addEventListener(`error`,()=>{l(()=>{o.warn(`websocket.error`,a)})}),e.addEventListener(`close`,e=>{l(()=>{o.logEvent(`websocket.close`,{...a,"websocket.close.code":e.code,"websocket.close.clean":e.wasClean})})}),e.addEventListener(`message`,()=>{c(t,e,`receive`)})})}allow(e){return e.active&&r.t(this.window,this.config.captureLimits.webSocketPerWindow,this.diagnostics,`WebSocket events`,this.config.captureLimits.windowMs)}};exports.WebSocketCapture=l;
|
|
2
|
+
//# sourceMappingURL=web-socket-Cs1ZbmmN.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-socket-CoIUBM3C.cjs","names":["recordedUrl","isLibraryRequest","patch","matchesAny","allowInWindow","require_library_request","require_platform","require_patch","require_storm","require_types","require_defineProperty","MESSAGES_METRIC","socketTarget","parsed","url","config","diagnostics","count","server","state","socket","own","direction","attributes","WebSocketCapture","ctx","track","Original","value","protocols","data","target","lifecycle","write","logger","event"],"sources":["../src/capture/web-socket.ts"],"sourcesContent":["// src/capture/web-socket.ts\n//\n// Records the open, close and error events of every WebSocket, and counts messages by direction\n// and server. It never reads message content. This is a capture plugin, so the runtime loads it\n// as a separate chunk.\n\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { Counter, MetricAttributes } from \"../models/metric\";\nimport type { CapturePlugin, PluginContext } from \"../models/plugin\";\nimport { isLibraryRequest } from \"../utils/library-request\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { patch } from \"../utils/patch\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport { matchesAny } from \"./types\";\n\n/** Name of the message counter. */\nconst MESSAGES_METRIC = \"ui.websocket.messages\";\n\n/** The data argument of one WebSocket.send call. */\ntype SendData = Parameters<WebSocket[\"send\"]>[0];\n\n/** State of one install. A wrapper left behind after uninstall reads it and records nothing. */\ninterface InstallState {\n /** False after uninstall. */\n active: boolean;\n /** The plugin's tools. */\n ctx: PluginContext;\n /** Message counter. */\n messages: Counter;\n /** Server host name of every tracked socket. */\n servers: WeakMap<WebSocket, string>;\n /** The delivery context that was current when each socket opened. */\n contexts: WeakMap<WebSocket, string>;\n /** Active capture settings and isolation rule. */\n config: ResolvedConfig;\n}\n\n/**\n * Strips the user info, query and fragment from a socket URL, since any of them can hold a token.\n * @param url The socket's absolute URL.\n * @param config Active capture settings.\n * @param diagnostics Diagnostics reporter, for a URL transform that throws.\n * @returns The URL to record and the server's host name.\n */\nfunction socketTarget(\n url: string,\n config: ResolvedConfig,\n diagnostics: Diagnostics,\n): { target: string; server: string } {\n const parsed = new URL(url);\n\n return {\n // Ignore fullUrls. A browser can't set a header on a socket, so apps often put a token in\n // the query. Only urlTransform can record more of the URL.\n target: recordedUrl(url, false, config.capture.urlTransform, diagnostics),\n server: parsed.hostname,\n };\n}\n\n/**\n * Counts one message on a tracked socket.\n * @param state State of the install that created the socket.\n * @param socket The socket the message belongs to.\n * @param direction Direction of the message.\n */\nfunction count(state: InstallState, socket: WebSocket, direction: \"transmit\" | \"receive\"): void {\n const server = state.servers.get(socket);\n\n // Don't count the library's own sends, for example a custom transport's, or one send would\n // cause the next.\n const own = direction === \"transmit\" && isLibraryRequest();\n if (\n !state.active ||\n server === undefined ||\n own ||\n (state.config.securityContext.isolation &&\n state.contexts.get(socket) !== state.config.securityContext.id)\n ) {\n return;\n }\n\n const attributes: MetricAttributes = {\n \"network.io.direction\": direction,\n \"server.address\": server,\n };\n state.messages.add(1, attributes);\n}\n\n/** Records the lifecycle and message counts of every WebSocket the app opens. */\nexport class WebSocketCapture implements CapturePlugin {\n /** Capture module identifier. */\n readonly name = \"websocket\";\n\n /** Restores the WebSocket constructor. Undefined while the capture isn't installed. */\n private restore: (() => boolean) | undefined;\n\n /** State of the active install. */\n private state: InstallState | undefined;\n\n /** Rate limit for the lifecycle records, so a reconnect loop can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param config Active configuration. The capture reads `capture.ignoreUrls`.\n */\n constructor(\n private readonly diagnostics: Diagnostics,\n private readonly config: ResolvedConfig,\n ) {}\n\n /**\n * Replaces the WebSocket constructor with a subclass that tracks every socket.\n * @param ctx The plugin's tools.\n */\n install(ctx: PluginContext): void {\n if (this.restore || typeof WebSocket === \"undefined\") {\n return;\n }\n\n const state: InstallState = {\n active: true,\n ctx,\n messages: ctx.counter(MESSAGES_METRIC),\n servers: new WeakMap(),\n contexts: new WeakMap(),\n config: this.config,\n };\n this.state = state;\n\n const track = (socket: WebSocket): void => {\n this.track(socket, state);\n };\n\n this.restore = patch(\n globalThis,\n \"WebSocket\",\n (Original) =>\n class TrackedWebSocket extends Original {\n /**\n * Keeps instanceof true for a socket the app opened before the install.\n * @param value Value to test.\n * @returns True for every native socket.\n */\n static override [Symbol.hasInstance](value: unknown): boolean {\n return value instanceof Original;\n }\n\n /**\n * @param url The server's URL.\n * @param protocols The app's sub-protocols.\n */\n constructor(url: string | URL, protocols?: string | string[]) {\n super(url, protocols);\n track(this);\n }\n\n /**\n * Sends the data, then counts one message. A send that throws counts nothing.\n * @param data The app's data. We never read it.\n */\n override send(data: SendData): void {\n super.send(data);\n count(state, this, \"transmit\");\n }\n },\n );\n }\n\n /** Restores the WebSocket constructor and stops every tracked socket from recording. */\n uninstall(): void {\n if (this.state) {\n this.state.active = false;\n }\n\n // Another script may have wrapped the constructor after us. Keep its wrapper.\n if (this.restore && !this.restore()) {\n this.diagnostics.report(\n \"capture.install_failed\",\n \"Another script wrapped WebSocket after the library. The library keeps that wrapper.\",\n );\n }\n\n this.restore = undefined;\n this.state = undefined;\n }\n\n /**\n * Adds the listeners that record one socket's lifecycle and received messages.\n * @param socket The app's new socket.\n * @param state State of the install that created the socket.\n */\n private track(socket: WebSocket, state: InstallState): void {\n if (!state.active) {\n return;\n }\n\n // This read runs inside the app's constructor call, so a throw must not fail it.\n this.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not track a WebSocket. The socket works without capture.\",\n () => {\n // ignoreUrls matches the full URL. A custom transport may send over its own socket.\n if (matchesAny(socket.url, this.config.capture.ignoreUrls)) {\n return;\n }\n\n const { target, server } = socketTarget(socket.url, this.config, this.diagnostics);\n const attributes = { \"url.full\": target, \"server.address\": server };\n const { logger } = state.ctx;\n state.servers.set(socket, server);\n state.contexts.set(socket, this.config.securityContext.id);\n\n const lifecycle = (write: () => void): void => {\n if (\n (!this.config.securityContext.isolation ||\n state.contexts.get(socket) === this.config.securityContext.id) &&\n this.allow(state)\n ) {\n write();\n }\n };\n\n socket.addEventListener(\"open\", () => {\n lifecycle(() => {\n logger.logEvent(\"websocket.open\", attributes);\n });\n });\n socket.addEventListener(\"error\", () => {\n lifecycle(() => {\n logger.warn(\"websocket.error\", attributes);\n });\n });\n socket.addEventListener(\"close\", (event) => {\n lifecycle(() => {\n logger.logEvent(\"websocket.close\", {\n ...attributes,\n \"websocket.close.code\": event.code,\n \"websocket.close.clean\": event.wasClean,\n });\n });\n });\n socket.addEventListener(\"message\", () => {\n count(state, socket, \"receive\");\n });\n },\n );\n }\n\n /**\n * Checks whether a lifecycle record can go out.\n * @param state State of the install that created the socket.\n * @returns False after uninstall, or when the window has no allowance left.\n */\n private allow(state: InstallState): boolean {\n return (\n state.active &&\n allowInWindow(\n this.window,\n this.config.captureLimits.webSocketPerWindow,\n this.diagnostics,\n \"WebSocket events\",\n this.config.captureLimits.wind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gB,CACdE,EAAO,KAAK,kBAAmBX,CAAU,CAC3C,CAAC,CACH,CAAC,EACDH,EAAO,iBAAiB,QAAU,GAAU,CAC1CY,MAAgB,CACdE,EAAO,SAAS,kBAAmB,CACjC,GAAGX,EACH,uBAAwBY,EAAM,KAC9B,wBAAyBA,EAAM,QACjC,CAAC,CACH,CAAC,CACH,CAAC,EACDf,EAAO,iBAAiB,cAAiB,CACvCH,EAAME,EAAOC,EAAQ,SAAS,CAChC,CAAC,CACH,CACF,CACF,CAOA,MAAc,EAA8B,CAC1C,OACED,EAAM,QACNf,EAAAA,EACE,KAAK,OACL,KAAK,OAAO,cAAc,mBAC1B,KAAK,YACL,mBACA,KAAK,OAAO,cAAc,QAC5B,CAEJ,CACF,E"}
|
|
1
|
+
{"version":3,"file":"web-socket-Cs1ZbmmN.cjs","names":["recordedUrl","isLibraryRequest","patch","matchesAny","allowInWindow","require_library_request","require_platform","require_patch","require_storm","require_types","require_defineProperty","MESSAGES_METRIC","socketTarget","parsed","url","config","diagnostics","count","server","state","socket","own","direction","attributes","WebSocketCapture","ctx","track","Original","value","protocols","data","target","lifecycle","write","logger","event"],"sources":["../src/capture/web-socket.ts"],"sourcesContent":["// src/capture/web-socket.ts\n//\n// Records the open, close and error events of every WebSocket, and counts messages by direction\n// and server. It never reads message content. This is a capture plugin, so the runtime loads it\n// as a separate chunk.\n\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { Counter, MetricAttributes } from \"../models/metric\";\nimport type { CapturePlugin, PluginContext } from \"../models/plugin\";\nimport { isLibraryRequest } from \"../utils/library-request\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { patch } from \"../utils/patch\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport { matchesAny } from \"./types\";\n\n/** Name of the message counter. */\nconst MESSAGES_METRIC = \"ui.websocket.messages\";\n\n/** The data argument of one WebSocket.send call. */\ntype SendData = Parameters<WebSocket[\"send\"]>[0];\n\n/** State of one install. A wrapper left behind after uninstall reads it and records nothing. */\ninterface InstallState {\n /** False after uninstall. */\n active: boolean;\n /** The plugin's tools. */\n ctx: PluginContext;\n /** Message counter. */\n messages: Counter;\n /** Server host name of every tracked socket. */\n servers: WeakMap<WebSocket, string>;\n /** The delivery context that was current when each socket opened. */\n contexts: WeakMap<WebSocket, string>;\n /** Active capture settings and isolation rule. */\n config: ResolvedConfig;\n}\n\n/**\n * Strips the user info, query and fragment from a socket URL, since any of them can hold a token.\n * @param url The socket's absolute URL.\n * @param config Active capture settings.\n * @param diagnostics Diagnostics reporter, for a URL transform that throws.\n * @returns The URL to record and the server's host name.\n */\nfunction socketTarget(\n url: string,\n config: ResolvedConfig,\n diagnostics: Diagnostics,\n): { target: string; server: string } {\n const parsed = new URL(url);\n\n return {\n // Ignore fullUrls. A browser can't set a header on a socket, so apps often put a token in\n // the query. Only urlTransform can record more of the URL.\n target: recordedUrl(url, false, config.capture.urlTransform, diagnostics),\n server: parsed.hostname,\n };\n}\n\n/**\n * Counts one message on a tracked socket.\n * @param state State of the install that created the socket.\n * @param socket The socket the message belongs to.\n * @param direction Direction of the message.\n */\nfunction count(state: InstallState, socket: WebSocket, direction: \"transmit\" | \"receive\"): void {\n const server = state.servers.get(socket);\n\n // Don't count the library's own sends, for example a custom transport's, or one send would\n // cause the next.\n const own = direction === \"transmit\" && isLibraryRequest();\n if (\n !state.active ||\n server === undefined ||\n own ||\n (state.config.securityContext.isolation &&\n state.contexts.get(socket) !== state.config.securityContext.id)\n ) {\n return;\n }\n\n const attributes: MetricAttributes = {\n \"network.io.direction\": direction,\n \"server.address\": server,\n };\n state.messages.add(1, attributes);\n}\n\n/** Records the lifecycle and message counts of every WebSocket the app opens. */\nexport class WebSocketCapture implements CapturePlugin {\n /** Capture module identifier. */\n readonly name = \"websocket\";\n\n /** Restores the WebSocket constructor. Undefined while the capture isn't installed. */\n private restore: (() => boolean) | undefined;\n\n /** State of the active install. */\n private state: InstallState | undefined;\n\n /** Rate limit for the lifecycle records, so a reconnect loop can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param config Active configuration. The capture reads `capture.ignoreUrls`.\n */\n constructor(\n private readonly diagnostics: Diagnostics,\n private readonly config: ResolvedConfig,\n ) {}\n\n /**\n * Replaces the WebSocket constructor with a subclass that tracks every socket.\n * @param ctx The plugin's tools.\n */\n install(ctx: PluginContext): void {\n if (this.restore || typeof WebSocket === \"undefined\") {\n return;\n }\n\n const state: InstallState = {\n active: true,\n ctx,\n messages: ctx.counter(MESSAGES_METRIC),\n servers: new WeakMap(),\n contexts: new WeakMap(),\n config: this.config,\n };\n this.state = state;\n\n const track = (socket: WebSocket): void => {\n this.track(socket, state);\n };\n\n this.restore = patch(\n globalThis,\n \"WebSocket\",\n (Original) =>\n class TrackedWebSocket extends Original {\n /**\n * Keeps instanceof true for a socket the app opened before the install.\n * @param value Value to test.\n * @returns True for every native socket.\n */\n static override [Symbol.hasInstance](value: unknown): boolean {\n return value instanceof Original;\n }\n\n /**\n * @param url The server's URL.\n * @param protocols The app's sub-protocols.\n */\n constructor(url: string | URL, protocols?: string | string[]) {\n super(url, protocols);\n track(this);\n }\n\n /**\n * Sends the data, then counts one message. A send that throws counts nothing.\n * @param data The app's data. We never read it.\n */\n override send(data: SendData): void {\n super.send(data);\n count(state, this, \"transmit\");\n }\n },\n );\n }\n\n /** Restores the WebSocket constructor and stops every tracked socket from recording. */\n uninstall(): void {\n if (this.state) {\n this.state.active = false;\n }\n\n // Another script may have wrapped the constructor after us. Keep its wrapper.\n if (this.restore && !this.restore()) {\n this.diagnostics.report(\n \"capture.install_failed\",\n \"Another script wrapped WebSocket after the library. The library keeps that wrapper.\",\n );\n }\n\n this.restore = undefined;\n this.state = undefined;\n }\n\n /**\n * Adds the listeners that record one socket's lifecycle and received messages.\n * @param socket The app's new socket.\n * @param state State of the install that created the socket.\n */\n private track(socket: WebSocket, state: InstallState): void {\n if (!state.active) {\n return;\n }\n\n // This read runs inside the app's constructor call, so a throw must not fail it.\n this.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not track a WebSocket. The socket works without capture.\",\n () => {\n // ignoreUrls matches the full URL. A custom transport may send over its own socket.\n if (matchesAny(socket.url, this.config.capture.ignoreUrls)) {\n return;\n }\n\n const { target, server } = socketTarget(socket.url, this.config, this.diagnostics);\n const attributes = { \"url.full\": target, \"server.address\": server };\n const { logger } = state.ctx;\n state.servers.set(socket, server);\n state.contexts.set(socket, this.config.securityContext.id);\n\n const lifecycle = (write: () => void): void => {\n if (\n (!this.config.securityContext.isolation ||\n state.contexts.get(socket) === this.config.securityContext.id) &&\n this.allow(state)\n ) {\n write();\n }\n };\n\n socket.addEventListener(\"open\", () => {\n lifecycle(() => {\n logger.logEvent(\"websocket.open\", attributes);\n });\n });\n socket.addEventListener(\"error\", () => {\n lifecycle(() => {\n logger.warn(\"websocket.error\", attributes);\n });\n });\n socket.addEventListener(\"close\", (event) => {\n lifecycle(() => {\n logger.logEvent(\"websocket.close\", {\n ...attributes,\n \"websocket.close.code\": event.code,\n \"websocket.close.clean\": event.wasClean,\n });\n });\n });\n socket.addEventListener(\"message\", () => {\n count(state, socket, \"receive\");\n });\n },\n );\n }\n\n /**\n * Checks whether a lifecycle record can go out.\n * @param state State of the install that created the socket.\n * @returns False after uninstall, or when the window has no allowance left.\n */\n private allow(state: InstallState): boolean {\n return (\n state.active &&\n allowInWindow(\n this.window,\n this.config.captureLimits.webSocketPerWindow,\n this.diagnostics,\n \"WebSocket events\",\n this.config.captureLimits.windowMs,\n )\n );\n }\n}\n"],"mappings":"A,wOAiBA,IAAMW,EAAkB,wBA4BxB,SAASC,EACP,EACA,EACA,EACoC,CACpC,IAAMC,EAAS,IAAI,IAAIC,CAAG,EAE1B,MAAO,CAGL,OAAQd,EAAAA,EAAYc,EAAK,GAAOC,EAAO,QAAQ,aAAcC,CAAW,EACxE,OAAQH,EAAO,QACjB,CACF,CAQA,SAASI,EAAM,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,EAAME,EAAOC,EAAQ,SAAS,CAChC,CAAC,CACH,CACF,CACF,CAOA,MAAc,EAA8B,CAC1C,OACED,EAAM,QACNf,EAAAA,EACE,KAAK,OACL,KAAK,OAAO,cAAc,mBAC1B,KAAK,YACL,mBACA,KAAK,OAAO,cAAc,QAC5B,CAEJ,CACF,E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as e } from "./library-request-
|
|
2
|
-
import { i as t } from "./platform-
|
|
1
|
+
import { t as e } from "./library-request-UGEwOHpf.js";
|
|
2
|
+
import { i as t } from "./platform-8DLhjddo.js";
|
|
3
3
|
import { t as n } from "./patch-UdPz1ea8.js";
|
|
4
|
-
import { t as r } from "./storm-
|
|
4
|
+
import { t as r } from "./storm-DKlpv0FL.js";
|
|
5
5
|
import { t as i } from "./types-BAerHgCq.js";
|
|
6
6
|
import { t as a } from "./defineProperty-s2S8BXUc.js";
|
|
7
7
|
// src/capture/web-socket.ts
|
|
@@ -96,4 +96,4 @@ var l = class {
|
|
|
96
96
|
};
|
|
97
97
|
export { l as WebSocketCapture };
|
|
98
98
|
|
|
99
|
-
//# sourceMappingURL=web-socket-
|
|
99
|
+
//# sourceMappingURL=web-socket-Zg0hj1LB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-socket-DSHgDiZ6.js","names":["isLibraryRequest","recordedUrl","patch","allowInWindow","matchesAny","_defineProperty","MESSAGES_METRIC","socketTarget","parsed","url","config","diagnostics","count","server","state","socket","own","direction","attributes","WebSocketCapture","ctx","track","Original","value","protocols","data","target","lifecycle","write","event"],"sources":["../src/capture/web-socket.ts"],"sourcesContent":["// src/capture/web-socket.ts\n//\n// Records the open, close and error events of every WebSocket, and counts messages by direction\n// and server. It never reads message content. This is a capture plugin, so the runtime loads it\n// as a separate chunk.\n\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { Counter, MetricAttributes } from \"../models/metric\";\nimport type { CapturePlugin, PluginContext } from \"../models/plugin\";\nimport { isLibraryRequest } from \"../utils/library-request\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { patch } from \"../utils/patch\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport { matchesAny } from \"./types\";\n\n/** Name of the message counter. */\nconst MESSAGES_METRIC = \"ui.websocket.messages\";\n\n/** The data argument of one WebSocket.send call. */\ntype SendData = Parameters<WebSocket[\"send\"]>[0];\n\n/** State of one install. A wrapper left behind after uninstall reads it and records nothing. */\ninterface InstallState {\n /** False after uninstall. */\n active: boolean;\n /** The plugin's tools. */\n ctx: PluginContext;\n /** Message counter. */\n messages: Counter;\n /** Server host name of every tracked socket. */\n servers: WeakMap<WebSocket, string>;\n /** The delivery context that was current when each socket opened. */\n contexts: WeakMap<WebSocket, string>;\n /** Active capture settings and isolation rule. */\n config: ResolvedConfig;\n}\n\n/**\n * Strips the user info, query and fragment from a socket URL, since any of them can hold a token.\n * @param url The socket's absolute URL.\n * @param config Active capture settings.\n * @param diagnostics Diagnostics reporter, for a URL transform that throws.\n * @returns The URL to record and the server's host name.\n */\nfunction socketTarget(\n url: string,\n config: ResolvedConfig,\n diagnostics: Diagnostics,\n): { target: string; server: string } {\n const parsed = new URL(url);\n\n return {\n // Ignore fullUrls. A browser can't set a header on a socket, so apps often put a token in\n // the query. Only urlTransform can record more of the URL.\n target: recordedUrl(url, false, config.capture.urlTransform, diagnostics),\n server: parsed.hostname,\n };\n}\n\n/**\n * Counts one message on a tracked socket.\n * @param state State of the install that created the socket.\n * @param socket The socket the message belongs to.\n * @param direction Direction of the message.\n */\nfunction count(state: InstallState, socket: WebSocket, direction: \"transmit\" | \"receive\"): void {\n const server = state.servers.get(socket);\n\n // Don't count the library's own sends, for example a custom transport's, or one send would\n // cause the next.\n const own = direction === \"transmit\" && isLibraryRequest();\n if (\n !state.active ||\n server === undefined ||\n own ||\n (state.config.securityContext.isolation &&\n state.contexts.get(socket) !== state.config.securityContext.id)\n ) {\n return;\n }\n\n const attributes: MetricAttributes = {\n \"network.io.direction\": direction,\n \"server.address\": server,\n };\n state.messages.add(1, attributes);\n}\n\n/** Records the lifecycle and message counts of every WebSocket the app opens. */\nexport class WebSocketCapture implements CapturePlugin {\n /** Capture module identifier. */\n readonly name = \"websocket\";\n\n /** Restores the WebSocket constructor. Undefined while the capture isn't installed. */\n private restore: (() => boolean) | undefined;\n\n /** State of the active install. */\n private state: InstallState | undefined;\n\n /** Rate limit for the lifecycle records, so a reconnect loop can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param config Active configuration. The capture reads `capture.ignoreUrls`.\n */\n constructor(\n private readonly diagnostics: Diagnostics,\n private readonly config: ResolvedConfig,\n ) {}\n\n /**\n * Replaces the WebSocket constructor with a subclass that tracks every socket.\n * @param ctx The plugin's tools.\n */\n install(ctx: PluginContext): void {\n if (this.restore || typeof WebSocket === \"undefined\") {\n return;\n }\n\n const state: InstallState = {\n active: true,\n ctx,\n messages: ctx.counter(MESSAGES_METRIC),\n servers: new WeakMap(),\n contexts: new WeakMap(),\n config: this.config,\n };\n this.state = state;\n\n const track = (socket: WebSocket): void => {\n this.track(socket, state);\n };\n\n this.restore = patch(\n globalThis,\n \"WebSocket\",\n (Original) =>\n class TrackedWebSocket extends Original {\n /**\n * Keeps instanceof true for a socket the app opened before the install.\n * @param value Value to test.\n * @returns True for every native socket.\n */\n static override [Symbol.hasInstance](value: unknown): boolean {\n return value instanceof Original;\n }\n\n /**\n * @param url The server's URL.\n * @param protocols The app's sub-protocols.\n */\n constructor(url: string | URL, protocols?: string | string[]) {\n super(url, protocols);\n track(this);\n }\n\n /**\n * Sends the data, then counts one message. A send that throws counts nothing.\n * @param data The app's data. We never read it.\n */\n override send(data: SendData): void {\n super.send(data);\n count(state, this, \"transmit\");\n }\n },\n );\n }\n\n /** Restores the WebSocket constructor and stops every tracked socket from recording. */\n uninstall(): void {\n if (this.state) {\n this.state.active = false;\n }\n\n // Another script may have wrapped the constructor after us. Keep its wrapper.\n if (this.restore && !this.restore()) {\n this.diagnostics.report(\n \"capture.install_failed\",\n \"Another script wrapped WebSocket after the library. The library keeps that wrapper.\",\n );\n }\n\n this.restore = undefined;\n this.state = undefined;\n }\n\n /**\n * Adds the listeners that record one socket's lifecycle and received messages.\n * @param socket The app's new socket.\n * @param state State of the install that created the socket.\n */\n private track(socket: WebSocket, state: InstallState): void {\n if (!state.active) {\n return;\n }\n\n // This read runs inside the app's constructor call, so a throw must not fail it.\n this.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not track a WebSocket. The socket works without capture.\",\n () => {\n // ignoreUrls matches the full URL. A custom transport may send over its own socket.\n if (matchesAny(socket.url, this.config.capture.ignoreUrls)) {\n return;\n }\n\n const { target, server } = socketTarget(socket.url, this.config, this.diagnostics);\n const attributes = { \"url.full\": target, \"server.address\": server };\n const { logger } = state.ctx;\n state.servers.set(socket, server);\n state.contexts.set(socket, this.config.securityContext.id);\n\n const lifecycle = (write: () => void): void => {\n if (\n (!this.config.securityContext.isolation ||\n state.contexts.get(socket) === this.config.securityContext.id) &&\n this.allow(state)\n ) {\n write();\n }\n };\n\n socket.addEventListener(\"open\", () => {\n lifecycle(() => {\n logger.logEvent(\"websocket.open\", attributes);\n });\n });\n socket.addEventListener(\"error\", () => {\n lifecycle(() => {\n logger.warn(\"websocket.error\", attributes);\n });\n });\n socket.addEventListener(\"close\", (event) => {\n lifecycle(() => {\n logger.logEvent(\"websocket.close\", {\n ...attributes,\n \"websocket.close.code\": event.code,\n \"websocket.close.clean\": event.wasClean,\n });\n });\n });\n socket.addEventListener(\"message\", () => {\n count(state, socket, \"receive\");\n });\n },\n );\n }\n\n /**\n * Checks whether a lifecycle record can go out.\n * @param state State of the install that created the socket.\n * @returns False after uninstall, or when the window has no allowance left.\n */\n private allow(state: InstallState): boolean {\n return (\n state.active &&\n allowInWindow(\n this.window,\n this.config.captureLimits.webSocketPerWindow,\n this.diagnostics,\n \"WebSocket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AAe;IACrC,QAAgB;KACd,EAAO,KAAK,mBAAmBG,CAAU;IAC3C,CAAC;GACH,CAAC,GACDH,EAAO,iBAAiB,UAAU,MAAU;IAC1C,QAAgB;KACd,EAAO,SAAS,mBAAmB;MACjC,GAAGG;MACH,wBAAwBW,EAAM;MAC9B,yBAAyBA,EAAM;KACjC,CAAC;IACH,CAAC;GACH,CAAC,GACDd,EAAO,iBAAiB,iBAAiB;IACvC,EAAMD,GAAOC,GAAQ,SAAS;GAChC,CAAC;EACH,CACF;CACF;CAOA,MAAc,GAA8B;EAC1C,OACED,EAAM,UACNX,EACE,KAAK,QACL,KAAK,OAAO,cAAc,oBAC1B,KAAK,aACL,oBACA,KAAK,OAAO,cAAc,QAC5B;CAEJ;AACF"}
|
|
1
|
+
{"version":3,"file":"web-socket-Zg0hj1LB.js","names":["isLibraryRequest","recordedUrl","patch","allowInWindow","matchesAny","_defineProperty","MESSAGES_METRIC","socketTarget","parsed","url","config","diagnostics","count","server","state","socket","own","direction","attributes","WebSocketCapture","ctx","track","Original","value","protocols","data","target","lifecycle","write","event"],"sources":["../src/capture/web-socket.ts"],"sourcesContent":["// src/capture/web-socket.ts\n//\n// Records the open, close and error events of every WebSocket, and counts messages by direction\n// and server. It never reads message content. This is a capture plugin, so the runtime loads it\n// as a separate chunk.\n\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { Counter, MetricAttributes } from \"../models/metric\";\nimport type { CapturePlugin, PluginContext } from \"../models/plugin\";\nimport { isLibraryRequest } from \"../utils/library-request\";\nimport { recordedUrl } from \"../utils/platform\";\nimport { patch } from \"../utils/patch\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport { matchesAny } from \"./types\";\n\n/** Name of the message counter. */\nconst MESSAGES_METRIC = \"ui.websocket.messages\";\n\n/** The data argument of one WebSocket.send call. */\ntype SendData = Parameters<WebSocket[\"send\"]>[0];\n\n/** State of one install. A wrapper left behind after uninstall reads it and records nothing. */\ninterface InstallState {\n /** False after uninstall. */\n active: boolean;\n /** The plugin's tools. */\n ctx: PluginContext;\n /** Message counter. */\n messages: Counter;\n /** Server host name of every tracked socket. */\n servers: WeakMap<WebSocket, string>;\n /** The delivery context that was current when each socket opened. */\n contexts: WeakMap<WebSocket, string>;\n /** Active capture settings and isolation rule. */\n config: ResolvedConfig;\n}\n\n/**\n * Strips the user info, query and fragment from a socket URL, since any of them can hold a token.\n * @param url The socket's absolute URL.\n * @param config Active capture settings.\n * @param diagnostics Diagnostics reporter, for a URL transform that throws.\n * @returns The URL to record and the server's host name.\n */\nfunction socketTarget(\n url: string,\n config: ResolvedConfig,\n diagnostics: Diagnostics,\n): { target: string; server: string } {\n const parsed = new URL(url);\n\n return {\n // Ignore fullUrls. A browser can't set a header on a socket, so apps often put a token in\n // the query. Only urlTransform can record more of the URL.\n target: recordedUrl(url, false, config.capture.urlTransform, diagnostics),\n server: parsed.hostname,\n };\n}\n\n/**\n * Counts one message on a tracked socket.\n * @param state State of the install that created the socket.\n * @param socket The socket the message belongs to.\n * @param direction Direction of the message.\n */\nfunction count(state: InstallState, socket: WebSocket, direction: \"transmit\" | \"receive\"): void {\n const server = state.servers.get(socket);\n\n // Don't count the library's own sends, for example a custom transport's, or one send would\n // cause the next.\n const own = direction === \"transmit\" && isLibraryRequest();\n if (\n !state.active ||\n server === undefined ||\n own ||\n (state.config.securityContext.isolation &&\n state.contexts.get(socket) !== state.config.securityContext.id)\n ) {\n return;\n }\n\n const attributes: MetricAttributes = {\n \"network.io.direction\": direction,\n \"server.address\": server,\n };\n state.messages.add(1, attributes);\n}\n\n/** Records the lifecycle and message counts of every WebSocket the app opens. */\nexport class WebSocketCapture implements CapturePlugin {\n /** Capture module identifier. */\n readonly name = \"websocket\";\n\n /** Restores the WebSocket constructor. Undefined while the capture isn't installed. */\n private restore: (() => boolean) | undefined;\n\n /** State of the active install. */\n private state: InstallState | undefined;\n\n /** Rate limit for the lifecycle records, so a reconnect loop can't flood the pipeline. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param diagnostics Diagnostics reporter.\n * @param config Active configuration. The capture reads `capture.ignoreUrls`.\n */\n constructor(\n private readonly diagnostics: Diagnostics,\n private readonly config: ResolvedConfig,\n ) {}\n\n /**\n * Replaces the WebSocket constructor with a subclass that tracks every socket.\n * @param ctx The plugin's tools.\n */\n install(ctx: PluginContext): void {\n if (this.restore || typeof WebSocket === \"undefined\") {\n return;\n }\n\n const state: InstallState = {\n active: true,\n ctx,\n messages: ctx.counter(MESSAGES_METRIC),\n servers: new WeakMap(),\n contexts: new WeakMap(),\n config: this.config,\n };\n this.state = state;\n\n const track = (socket: WebSocket): void => {\n this.track(socket, state);\n };\n\n this.restore = patch(\n globalThis,\n \"WebSocket\",\n (Original) =>\n class TrackedWebSocket extends Original {\n /**\n * Keeps instanceof true for a socket the app opened before the install.\n * @param value Value to test.\n * @returns True for every native socket.\n */\n static override [Symbol.hasInstance](value: unknown): boolean {\n return value instanceof Original;\n }\n\n /**\n * @param url The server's URL.\n * @param protocols The app's sub-protocols.\n */\n constructor(url: string | URL, protocols?: string | string[]) {\n super(url, protocols);\n track(this);\n }\n\n /**\n * Sends the data, then counts one message. A send that throws counts nothing.\n * @param data The app's data. We never read it.\n */\n override send(data: SendData): void {\n super.send(data);\n count(state, this, \"transmit\");\n }\n },\n );\n }\n\n /** Restores the WebSocket constructor and stops every tracked socket from recording. */\n uninstall(): void {\n if (this.state) {\n this.state.active = false;\n }\n\n // Another script may have wrapped the constructor after us. Keep its wrapper.\n if (this.restore && !this.restore()) {\n this.diagnostics.report(\n \"capture.install_failed\",\n \"Another script wrapped WebSocket after the library. The library keeps that wrapper.\",\n );\n }\n\n this.restore = undefined;\n this.state = undefined;\n }\n\n /**\n * Adds the listeners that record one socket's lifecycle and received messages.\n * @param socket The app's new socket.\n * @param state State of the install that created the socket.\n */\n private track(socket: WebSocket, state: InstallState): void {\n if (!state.active) {\n return;\n }\n\n // This read runs inside the app's constructor call, so a throw must not fail it.\n this.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not track a WebSocket. The socket works without capture.\",\n () => {\n // ignoreUrls matches the full URL. A custom transport may send over its own socket.\n if (matchesAny(socket.url, this.config.capture.ignoreUrls)) {\n return;\n }\n\n const { target, server } = socketTarget(socket.url, this.config, this.diagnostics);\n const attributes = { \"url.full\": target, \"server.address\": server };\n const { logger } = state.ctx;\n state.servers.set(socket, server);\n state.contexts.set(socket, this.config.securityContext.id);\n\n const lifecycle = (write: () => void): void => {\n if (\n (!this.config.securityContext.isolation ||\n state.contexts.get(socket) === this.config.securityContext.id) &&\n this.allow(state)\n ) {\n write();\n }\n };\n\n socket.addEventListener(\"open\", () => {\n lifecycle(() => {\n logger.logEvent(\"websocket.open\", attributes);\n });\n });\n socket.addEventListener(\"error\", () => {\n lifecycle(() => {\n logger.warn(\"websocket.error\", attributes);\n });\n });\n socket.addEventListener(\"close\", (event) => {\n lifecycle(() => {\n logger.logEvent(\"websocket.close\", {\n ...attributes,\n \"websocket.close.code\": event.code,\n \"websocket.close.clean\": event.wasClean,\n });\n });\n });\n socket.addEventListener(\"message\", () => {\n count(state, socket, \"receive\");\n });\n },\n );\n }\n\n /**\n * Checks whether a lifecycle record can go out.\n * @param state State of the install that created the socket.\n * @returns False after uninstall, or when the window has no allowance left.\n */\n private allow(state: InstallState): boolean {\n return (\n state.active &&\n allowInWindow(\n this.window,\n this.config.captureLimits.webSocketPerWindow,\n this.diagnostics,\n \"WebSocket events\",\n this.config.captureLimits.windowMs,\n )\n );\n }\n}\n"],"mappings":";;;;;;;AAiBA,IAAMM,IAAkB;AA4BxB,SAASC,EACP,GACA,GACA,GACoC;CACpC,IAAMC,IAAS,IAAI,IAAIC,CAAG;CAE1B,OAAO;EAGL,QAAQR,EAAYQ,GAAK,IAAOC,EAAO,QAAQ,cAAcC,CAAW;EACxE,QAAQH,EAAO;CACjB;AACF;AAQA,SAASI,EAAM,GAAqB,GAAmB,GAAyC;CAC9F,IAAMC,IAAS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,CACF;CACF;CAOA,MAAc,GAA8B;EAC1C,OACED,EAAM,UACNX,EACE,KAAK,QACL,KAAK,OAAO,cAAc,oBAC1B,KAAK,aACL,oBACA,KAAK,OAAO,cAAc,QAC5B;CAEJ;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n } from "./log-record-
|
|
1
|
+
import { cr as e, rr as t } from "./constants-BwJDXzj6.js";
|
|
2
|
+
import { n } from "./log-record-DSt2P-Sr.js";
|
|
3
3
|
import { n as r } from "./guards-BlYGRK4l.js";
|
|
4
4
|
// src/transport/worker-protocol.ts
|
|
5
5
|
function i(n, r = {}) {
|
|
@@ -11,7 +11,7 @@ function i(n, r = {}) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function a(e) {
|
|
14
|
-
return r(e) && e.p === "ui-observability.transport/1" && e.v === "1.
|
|
14
|
+
return r(e) && e.p === "ui-observability.transport/1" && e.v === "1.1.0";
|
|
15
15
|
}
|
|
16
16
|
function o(e) {
|
|
17
17
|
return e === void 0 || typeof e == "number" && Number.isFinite(e) && e >= 0;
|
|
@@ -49,4 +49,4 @@ function u(e) {
|
|
|
49
49
|
}
|
|
50
50
|
export { i, a as n, l as r, u as t };
|
|
51
51
|
|
|
52
|
-
//# sourceMappingURL=worker-protocol-
|
|
52
|
+
//# sourceMappingURL=worker-protocol-CYpAbrVl.js.map
|