@utk09/ui-observability 0.9.3 → 0.9.5
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 +90 -0
- package/README.md +199 -96
- package/dist/batch-BQFtb3i5.cjs +2 -0
- package/dist/batch-BQFtb3i5.cjs.map +1 -0
- package/dist/{batch-DDgxg16_.js → batch-BUJh-1jZ.js} +6 -4
- package/dist/batch-BUJh-1jZ.js.map +1 -0
- package/dist/bus/bus.d.ts +76 -2
- package/dist/bus/links.d.ts +9 -2
- package/dist/bus/validation.d.ts +7 -0
- package/dist/bus-BW6N-pY8.cjs +2 -0
- package/dist/bus-BW6N-pY8.cjs.map +1 -0
- package/dist/bus-DeOPHWaD.js +647 -0
- package/dist/bus-DeOPHWaD.js.map +1 -0
- package/dist/capture/network.d.ts +1 -0
- package/dist/capture/storm.d.ts +2 -1
- package/dist/capture/types.d.ts +5 -0
- package/dist/capture/web-socket.d.ts +40 -0
- package/dist/{console-BSusX_M-.cjs → console-Ce6heqZZ.cjs} +2 -2
- package/dist/console-Ce6heqZZ.cjs.map +1 -0
- package/dist/{console-Dv5GfaNn.js → console-DbAZYJuy.js} +4 -4
- package/dist/console-DbAZYJuy.js.map +1 -0
- package/dist/constants-CN7GE1Lt.js +246 -0
- package/dist/constants-CN7GE1Lt.js.map +1 -0
- package/dist/constants-CW-MlHdY.cjs +2 -0
- package/dist/constants-CW-MlHdY.cjs.map +1 -0
- package/dist/constants.d.ts +63 -11
- package/dist/context-storage-BjzeBSxH.cjs +2 -0
- package/dist/context-storage-BjzeBSxH.cjs.map +1 -0
- package/dist/context-storage-DxZf4Gfh.js +52 -0
- package/dist/context-storage-DxZf4Gfh.js.map +1 -0
- package/dist/core/breadcrumbs.d.ts +10 -3
- package/dist/core/context.d.ts +2 -0
- package/dist/core/diagnostics.d.ts +11 -3
- package/dist/core/journey.d.ts +7 -0
- package/dist/core/meter.d.ts +25 -2
- package/dist/core/pipeline.d.ts +41 -6
- package/dist/core/record.d.ts +42 -9
- package/dist/core/remote-sampling.d.ts +7 -3
- package/dist/core/runtime.d.ts +153 -6
- package/dist/core/sampling.d.ts +35 -2
- package/dist/core/sender.d.ts +43 -1
- package/dist/core/spans.d.ts +34 -0
- package/dist/deadline-5_PecIl5.js +26 -0
- package/dist/deadline-5_PecIl5.js.map +1 -0
- package/dist/deadline-XSnm95pg.cjs +2 -0
- package/dist/deadline-XSnm95pg.cjs.map +1 -0
- package/dist/emergency-queue-BYUyDHGD.js +69 -0
- package/dist/emergency-queue-BYUyDHGD.js.map +1 -0
- package/dist/emergency-queue-Cs1hrjsC.cjs +2 -0
- package/dist/emergency-queue-Cs1hrjsC.cjs.map +1 -0
- package/dist/{errors-DCZWcHkd.js → errors-BhC7HTSt.js} +8 -9
- package/dist/errors-BhC7HTSt.js.map +1 -0
- package/dist/errors-CgY633cG.cjs +3 -0
- package/dist/errors-CgY633cG.cjs.map +1 -0
- package/dist/factory-C5TujXlU.js +280 -0
- package/dist/factory-C5TujXlU.js.map +1 -0
- package/dist/factory-CNj4DH3n.cjs +2 -0
- package/dist/factory-CNj4DH3n.cjs.map +1 -0
- package/dist/fixed-window-CtaFHanJ.js +12 -0
- package/dist/fixed-window-CtaFHanJ.js.map +1 -0
- package/dist/fixed-window-CvESpFYV.cjs +2 -0
- package/dist/fixed-window-CvESpFYV.cjs.map +1 -0
- package/dist/identity-8vKkyAWm.js +103 -0
- package/dist/identity-8vKkyAWm.js.map +1 -0
- package/dist/identity-Da9TkuKd.cjs +2 -0
- package/dist/identity-Da9TkuKd.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +66 -6
- package/dist/index.js +1253 -595
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-BTfIFRHF.cjs +2 -0
- package/dist/indexeddb-storage-BTfIFRHF.cjs.map +1 -0
- package/dist/{indexeddb-storage-T9YIYVYC.js → indexeddb-storage-CCA1LvtO.js} +45 -30
- package/dist/indexeddb-storage-CCA1LvtO.js.map +1 -0
- package/dist/{interactions-BLH_tX87.js → interactions-BUDLxbv1.js} +16 -12
- package/dist/interactions-BUDLxbv1.js.map +1 -0
- package/dist/interactions-NHbLKrqe.cjs +2 -0
- package/dist/interactions-NHbLKrqe.cjs.map +1 -0
- package/dist/{journey-yALMEWF7.js → journey-BUJ4WJxP.js} +37 -34
- package/dist/journey-BUJ4WJxP.js.map +1 -0
- package/dist/journey-B_tTnvac.cjs +2 -0
- package/dist/journey-B_tTnvac.cjs.map +1 -0
- package/dist/keys-BHhw_0Wh.cjs +2 -0
- package/dist/keys-BHhw_0Wh.cjs.map +1 -0
- package/dist/keys-D5r_GH9q.js +17 -0
- package/dist/keys-D5r_GH9q.js.map +1 -0
- package/dist/{library-request-CQD4HUiP.js → library-request-BKOcaKtQ.js} +3 -3
- package/dist/{library-request-CQD4HUiP.js.map → library-request-BKOcaKtQ.js.map} +1 -1
- package/dist/{library-request-BcAxuwsf.cjs → library-request-BaZOi4eg.cjs} +2 -2
- package/dist/{library-request-BcAxuwsf.cjs.map → library-request-BaZOi4eg.cjs.map} +1 -1
- package/dist/{long-frames-D4Bm3Zkz.cjs → long-frames-CF3qiSAX.cjs} +2 -2
- package/dist/long-frames-CF3qiSAX.cjs.map +1 -0
- package/dist/{long-frames-DD_Um9_4.js → long-frames-DI5ypfAF.js} +5 -5
- package/dist/long-frames-DI5ypfAF.js.map +1 -0
- package/dist/models/batch.d.ts +4 -0
- package/dist/models/bus.d.ts +32 -9
- package/dist/models/config.d.ts +401 -12
- package/dist/models/drop.d.ts +1 -1
- package/dist/models/health.d.ts +27 -0
- package/dist/models/log-record.d.ts +1 -1
- package/dist/models/plugin.d.ts +47 -0
- package/dist/models/stats.d.ts +11 -0
- package/dist/models/storage.d.ts +13 -0
- package/dist/network-CF8UO5PK.cjs +2 -0
- package/dist/network-CF8UO5PK.cjs.map +1 -0
- package/dist/{network--GoE7_Or.js → network-DdzXDI3J.js} +47 -31
- package/dist/network-DdzXDI3J.js.map +1 -0
- package/dist/openfin-BwEN0uj4.js.map +1 -1
- package/dist/openfin-DtH2f7zX.cjs.map +1 -1
- package/dist/{platform-GaM6h7XM.js → platform-Bw1btWCT.js} +21 -10
- package/dist/platform-Bw1btWCT.js.map +1 -0
- package/dist/platform-DBSKTvFn.cjs +2 -0
- package/dist/platform-DBSKTvFn.cjs.map +1 -0
- package/dist/remote-rules-DIcC5vVC.js +91 -0
- package/dist/remote-rules-DIcC5vVC.js.map +1 -0
- package/dist/remote-rules-DpFmOef2.cjs +2 -0
- package/dist/remote-rules-DpFmOef2.cjs.map +1 -0
- package/dist/sampling-BVjspJWu.cjs +2 -0
- package/dist/sampling-BVjspJWu.cjs.map +1 -0
- package/dist/sampling-Cm3WhI0a.js +76 -0
- package/dist/sampling-Cm3WhI0a.js.map +1 -0
- package/dist/{sanitize-DP0xDPrt.js → sanitize-C-ahCFsG.js} +2 -2
- package/dist/{sanitize-DP0xDPrt.js.map → sanitize-C-ahCFsG.js.map} +1 -1
- package/dist/{sanitize--_e4oOPX.cjs → sanitize-DHucKGdi.cjs} +2 -2
- package/dist/{sanitize--_e4oOPX.cjs.map → sanitize-DHucKGdi.cjs.map} +1 -1
- package/dist/sender-D3fRCR8d.cjs +3 -0
- package/dist/sender-D3fRCR8d.cjs.map +1 -0
- package/dist/sender-DUUmSglb.js +1163 -0
- package/dist/sender-DUUmSglb.js.map +1 -0
- package/dist/storage/context-storage.d.ts +89 -0
- package/dist/storage/emergency-queue.d.ts +9 -1
- package/dist/storage/factory.d.ts +7 -1
- package/dist/storage/idb-driver.d.ts +13 -0
- package/dist/storage/indexeddb-storage.d.ts +13 -0
- package/dist/storage/local-storage.d.ts +21 -1
- package/dist/storage/memory-storage.d.ts +13 -0
- package/dist/storage-BA9RqRO-.cjs +2 -0
- package/dist/storage-BA9RqRO-.cjs.map +1 -0
- package/dist/storage-w7Tslvlq.js +17 -0
- package/dist/storage-w7Tslvlq.js.map +1 -0
- package/dist/storm-CNZjsw4T.cjs +2 -0
- package/dist/storm-CNZjsw4T.cjs.map +1 -0
- package/dist/storm-Daq2jGHU.js +10 -0
- package/dist/storm-Daq2jGHU.js.map +1 -0
- package/dist/transport/exit-flush.d.ts +6 -0
- package/dist/transport/http-transport.d.ts +2 -1
- package/dist/transport/retry-engine.d.ts +7 -2
- package/dist/transport/serializers/otlp-traces.d.ts +3 -0
- package/dist/transport/serializers/select.d.ts +8 -5
- package/dist/transport/status-transport.d.ts +24 -0
- package/dist/types-BR9t_w28.js +8 -0
- package/dist/types-BR9t_w28.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs +2 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -0
- package/dist/utils/fixed-window.d.ts +9 -0
- package/dist/utils/identity.d.ts +20 -2
- package/dist/utils/lock.d.ts +8 -0
- package/dist/utils/openfin.d.ts +1 -1
- package/dist/utils/platform.d.ts +10 -0
- package/dist/utils/tracing.d.ts +82 -4
- package/dist/web-socket-BacvKOvD.cjs +2 -0
- package/dist/web-socket-BacvKOvD.cjs.map +1 -0
- package/dist/web-socket-CpsD8WAa.js +105 -0
- package/dist/web-socket-CpsD8WAa.js.map +1 -0
- package/package.json +1 -1
- package/dist/batch-D5qvsMQ_.cjs +0 -2
- package/dist/batch-D5qvsMQ_.cjs.map +0 -1
- package/dist/batch-DDgxg16_.js.map +0 -1
- package/dist/bus-C6RwKzPW.js +0 -478
- package/dist/bus-C6RwKzPW.js.map +0 -1
- package/dist/bus-WPVDFw2y.cjs +0 -2
- package/dist/bus-WPVDFw2y.cjs.map +0 -1
- package/dist/console-BSusX_M-.cjs.map +0 -1
- package/dist/console-Dv5GfaNn.js.map +0 -1
- package/dist/constants-Cb92egPS.cjs +0 -2
- package/dist/constants-Cb92egPS.cjs.map +0 -1
- package/dist/constants-DhH6VI5a.js +0 -144
- package/dist/constants-DhH6VI5a.js.map +0 -1
- package/dist/deadline-CUrH0Hd8.cjs +0 -2
- package/dist/deadline-CUrH0Hd8.cjs.map +0 -1
- package/dist/deadline-DeqXEliN.js +0 -31
- package/dist/deadline-DeqXEliN.js.map +0 -1
- package/dist/errors-DCZWcHkd.js.map +0 -1
- package/dist/errors-ERu-su8m.cjs +0 -3
- package/dist/errors-ERu-su8m.cjs.map +0 -1
- package/dist/fixed-window-BR0bu32Y.cjs +0 -2
- package/dist/fixed-window-BR0bu32Y.cjs.map +0 -1
- package/dist/fixed-window-Re7jIRJH.js +0 -9
- package/dist/fixed-window-Re7jIRJH.js.map +0 -1
- package/dist/identity-C1WLItSl.cjs +0 -2
- package/dist/identity-C1WLItSl.cjs.map +0 -1
- package/dist/identity-Di-QXGCC.js +0 -88
- package/dist/identity-Di-QXGCC.js.map +0 -1
- package/dist/indexeddb-storage-DX18p39D.cjs +0 -2
- package/dist/indexeddb-storage-DX18p39D.cjs.map +0 -1
- package/dist/indexeddb-storage-T9YIYVYC.js.map +0 -1
- package/dist/interactions-BLH_tX87.js.map +0 -1
- package/dist/interactions-_hfOerfC.cjs +0 -2
- package/dist/interactions-_hfOerfC.cjs.map +0 -1
- package/dist/journey-BRUj0hqD.cjs +0 -2
- package/dist/journey-BRUj0hqD.cjs.map +0 -1
- package/dist/journey-yALMEWF7.js.map +0 -1
- package/dist/long-frames-D4Bm3Zkz.cjs.map +0 -1
- package/dist/long-frames-DD_Um9_4.js.map +0 -1
- package/dist/network--GoE7_Or.js.map +0 -1
- package/dist/network-DcuS2H1P.cjs +0 -2
- package/dist/network-DcuS2H1P.cjs.map +0 -1
- package/dist/platform-GaM6h7XM.js.map +0 -1
- package/dist/platform-kIL5AZB7.cjs +0 -2
- package/dist/platform-kIL5AZB7.cjs.map +0 -1
- package/dist/remote-rules-6ePq8CrI.js +0 -84
- package/dist/remote-rules-6ePq8CrI.js.map +0 -1
- package/dist/remote-rules-CI3gbRCL.cjs +0 -2
- package/dist/remote-rules-CI3gbRCL.cjs.map +0 -1
- package/dist/sampling-C-M8p3FK.cjs +0 -2
- package/dist/sampling-C-M8p3FK.cjs.map +0 -1
- package/dist/sampling-Ud_WiuU9.js +0 -65
- package/dist/sampling-Ud_WiuU9.js.map +0 -1
- package/dist/sender-BESHz6my.cjs +0 -3
- package/dist/sender-BESHz6my.cjs.map +0 -1
- package/dist/sender-BUBWLn5i.js +0 -1244
- package/dist/sender-BUBWLn5i.js.map +0 -1
- package/dist/storm-DhHGHhOc.cjs +0 -2
- package/dist/storm-DhHGHhOc.cjs.map +0 -1
- package/dist/storm-OD5J6Ylm.js +0 -10
- package/dist/storm-OD5J6Ylm.js.map +0 -1
|
@@ -24,6 +24,19 @@ export declare class MemoryStorage implements StorageAdapter {
|
|
|
24
24
|
* @returns Promise that resolves to an array of batches.
|
|
25
25
|
*/
|
|
26
26
|
take(limit: number): Promise<LogBatch[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns up to `limit` batches of one context in FIFO order. It does not delete them.
|
|
29
|
+
* @param id Delivery context id.
|
|
30
|
+
* @param limit Maximum number of batches to retrieve.
|
|
31
|
+
* @returns Promise that resolves to the batches of this context.
|
|
32
|
+
*/
|
|
33
|
+
takeContext(id: string, limit: number): Promise<LogBatch[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Counts the stored batches of one context.
|
|
36
|
+
* @param id Delivery context id.
|
|
37
|
+
* @returns Promise that resolves to the batch count of this context.
|
|
38
|
+
*/
|
|
39
|
+
countContext(id: string): Promise<number>;
|
|
27
40
|
/**
|
|
28
41
|
* Deletes the batch with the given ID.
|
|
29
42
|
* @param id Batch identifier.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-BA9RqRO-.cjs","names":["storageLimits","retention"],"sources":["../src/models/storage.ts"],"sourcesContent":["// src/models/storage.ts\n//\n// Storage interface for undelivered batches, with adapters for IndexedDB,\n// localStorage, memory, and a fallback that does nothing.\n\nimport type { LogBatch } from \"./batch\";\nimport type { RetentionOptions } from \"./config\";\n\n/** Persistent batch storage interface. All methods must resolve and never throw. */\nexport interface StorageAdapter {\n /** Adapter identifier name. */\n readonly name: string;\n\n /**\n * Persists a batch to storage.\n * @param batch The batch to store.\n */\n save(batch: LogBatch): Promise<void>;\n\n /**\n * Reads up to `limit` batches in FIFO order without removing them.\n * @param limit Maximum number of batches to retrieve.\n * @returns Oldest persisted batches.\n */\n take(limit: number): Promise<LogBatch[]>;\n /**\n * Reads batches of one context without loading batches of other contexts.\n * @param id Delivery context id.\n * @param limit Maximum batches to return.\n * @returns Batches of this context, oldest first.\n */\n takeContext?(id: string, limit: number): Promise<LogBatch[]>;\n /**\n * Counts batches of one context without loading them.\n * @param id Delivery context id.\n * @returns Number of batches in this context.\n */\n countContext?(id: string): Promise<number>;\n\n /**\n * Removes a batch by ID. A call with an unknown ID resolves without error.\n * @param id Batch identifier.\n */\n remove(id: string): Promise<void>;\n\n /**\n * Updates the total delivery attempts for a batch.\n * @param id Batch identifier.\n * @param attempts Absolute attempt count.\n */\n bumpAttempts(id: string, attempts: number): Promise<void>;\n\n /**\n * Deletes expired and over-capacity batches.\n * @returns Prune summary metrics.\n */\n prune(): Promise<PruneResult>;\n\n /** Returns the total number of stored batches. */\n count(): Promise<number>;\n\n /** Deletes all batches in storage. */\n clear(): Promise<void>;\n\n /** Closes storage connections and releases resources. */\n close(): Promise<void>;\n}\n\n/** Capacity and retention thresholds enforced by a storage adapter. */\nexport interface StorageLimits {\n /** Maximum batch capacity before FIFO eviction. */\n maxBatches: number;\n /** Maximum time-to-live for a stored batch in milliseconds. */\n maxAgeMs: number;\n /** Maximum delivery attempts before dead-letter drop. */\n maxAttempts: number;\n}\n\n/**\n * Gives the storage limits of a retention setting. \"until-delivered\" has no age limit and no\n * attempt limit. The batch cap still applies.\n * @param retention Retention setting from the config.\n * @returns The limits for the storage adapters and the retry engine.\n */\nexport function storageLimits(retention: RetentionOptions): StorageLimits {\n const { maxBatches } = retention;\n\n if (retention.mode === \"until-delivered\") {\n return { maxBatches, maxAgeMs: Infinity, maxAttempts: Infinity };\n }\n\n return { maxBatches, maxAgeMs: retention.maxAgeMs, maxAttempts: retention.maxAttempts };\n}\n\n/** Metrics for batches and records dropped during storage pruning. */\nexport interface PruneResult {\n /** Total batches dropped. */\n batches: number;\n /** Total records dropped within evicted batches. */\n records: number;\n /**\n * Cause of the drop. If more than one rule applies, this is the last rule. \"not_stored\" means\n * that storage did not keep a batch after a failed send.\n */\n reason: \"expired\" | \"over_capacity\" | \"quota\" | \"not_stored\";\n}\n\n/**\n * Callback invoked when dropped records create a telemetry gap.\n * @param result Summary of evicted data.\n * @param dropped The dropped batches. A corrupt entry has no batch. The list then has none for it.\n */\nexport type GapReporter = (result: PruneResult, dropped: readonly LogBatch[]) => void;\n"],"mappings":"AAoFA,SAAgBA,EAAc,EAA4C,CACxE,GAAM,CAAE,cAAeC,EAMvB,OAJIA,EAAU,OAAS,kBACd,CAAE,aAAY,SAAU,IAAU,YAAa,GAAS,EAG1D,CAAE,aAAY,SAAUA,EAAU,SAAU,YAAaA,EAAU,WAAY,CACxF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/models/storage.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let { maxBatches: t } = e;
|
|
4
|
+
return e.mode === "until-delivered" ? {
|
|
5
|
+
maxBatches: t,
|
|
6
|
+
maxAgeMs: Infinity,
|
|
7
|
+
maxAttempts: Infinity
|
|
8
|
+
} : {
|
|
9
|
+
maxBatches: t,
|
|
10
|
+
maxAgeMs: e.maxAgeMs,
|
|
11
|
+
maxAttempts: e.maxAttempts
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { e as storageLimits };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=storage-w7Tslvlq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-w7Tslvlq.js","names":["storageLimits","retention"],"sources":["../src/models/storage.ts"],"sourcesContent":["// src/models/storage.ts\n//\n// Storage interface for undelivered batches, with adapters for IndexedDB,\n// localStorage, memory, and a fallback that does nothing.\n\nimport type { LogBatch } from \"./batch\";\nimport type { RetentionOptions } from \"./config\";\n\n/** Persistent batch storage interface. All methods must resolve and never throw. */\nexport interface StorageAdapter {\n /** Adapter identifier name. */\n readonly name: string;\n\n /**\n * Persists a batch to storage.\n * @param batch The batch to store.\n */\n save(batch: LogBatch): Promise<void>;\n\n /**\n * Reads up to `limit` batches in FIFO order without removing them.\n * @param limit Maximum number of batches to retrieve.\n * @returns Oldest persisted batches.\n */\n take(limit: number): Promise<LogBatch[]>;\n /**\n * Reads batches of one context without loading batches of other contexts.\n * @param id Delivery context id.\n * @param limit Maximum batches to return.\n * @returns Batches of this context, oldest first.\n */\n takeContext?(id: string, limit: number): Promise<LogBatch[]>;\n /**\n * Counts batches of one context without loading them.\n * @param id Delivery context id.\n * @returns Number of batches in this context.\n */\n countContext?(id: string): Promise<number>;\n\n /**\n * Removes a batch by ID. A call with an unknown ID resolves without error.\n * @param id Batch identifier.\n */\n remove(id: string): Promise<void>;\n\n /**\n * Updates the total delivery attempts for a batch.\n * @param id Batch identifier.\n * @param attempts Absolute attempt count.\n */\n bumpAttempts(id: string, attempts: number): Promise<void>;\n\n /**\n * Deletes expired and over-capacity batches.\n * @returns Prune summary metrics.\n */\n prune(): Promise<PruneResult>;\n\n /** Returns the total number of stored batches. */\n count(): Promise<number>;\n\n /** Deletes all batches in storage. */\n clear(): Promise<void>;\n\n /** Closes storage connections and releases resources. */\n close(): Promise<void>;\n}\n\n/** Capacity and retention thresholds enforced by a storage adapter. */\nexport interface StorageLimits {\n /** Maximum batch capacity before FIFO eviction. */\n maxBatches: number;\n /** Maximum time-to-live for a stored batch in milliseconds. */\n maxAgeMs: number;\n /** Maximum delivery attempts before dead-letter drop. */\n maxAttempts: number;\n}\n\n/**\n * Gives the storage limits of a retention setting. \"until-delivered\" has no age limit and no\n * attempt limit. The batch cap still applies.\n * @param retention Retention setting from the config.\n * @returns The limits for the storage adapters and the retry engine.\n */\nexport function storageLimits(retention: RetentionOptions): StorageLimits {\n const { maxBatches } = retention;\n\n if (retention.mode === \"until-delivered\") {\n return { maxBatches, maxAgeMs: Infinity, maxAttempts: Infinity };\n }\n\n return { maxBatches, maxAgeMs: retention.maxAgeMs, maxAttempts: retention.maxAttempts };\n}\n\n/** Metrics for batches and records dropped during storage pruning. */\nexport interface PruneResult {\n /** Total batches dropped. */\n batches: number;\n /** Total records dropped within evicted batches. */\n records: number;\n /**\n * Cause of the drop. If more than one rule applies, this is the last rule. \"not_stored\" means\n * that storage did not keep a batch after a failed send.\n */\n reason: \"expired\" | \"over_capacity\" | \"quota\" | \"not_stored\";\n}\n\n/**\n * Callback invoked when dropped records create a telemetry gap.\n * @param result Summary of evicted data.\n * @param dropped The dropped batches. A corrupt entry has no batch. The list then has none for it.\n */\nexport type GapReporter = (result: PruneResult, dropped: readonly LogBatch[]) => void;\n"],"mappings":";AAoFA,SAAgBA,EAAc,GAA4C;CACxE,IAAM,EAAE,kBAAeC;CAMvB,OAJIA,EAAU,SAAS,oBACd;EAAE;EAAY,UAAU;EAAU,aAAa;CAAS,IAG1D;EAAE;EAAY,UAAUA,EAAU;EAAU,aAAaA,EAAU;CAAY;AACxF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants-CW-MlHdY.cjs"),t=require("./fixed-window-CvESpFYV.cjs");function n(n,r,i,a,o=e.q){return r===0||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-CNZjsw4T.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storm-CNZjsw4T.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// makes thousands of events each second. Sending all of them floods 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. It reports each event over the limit.\n * @param window Window state to change.\n * @param limit Maximum events in each window.\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,\n diagnostics: Diagnostics,\n what: string,\n windowMs = ERROR_STORM_WINDOW_MS,\n): boolean {\n if (limit === 0 || 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":"qFAoBA,SAAgBI,EACd,EACA,EACA,EACA,EACA,EAAWJ,EAAAA,EACF,CAST,OARIK,IAAU,GAAKJ,EAAAA,EAAcK,EAAQD,EAAOE,CAAQ,EAC/C,IAGTC,EAAY,OACV,uBACA,aAAa,OAAOH,CAAK,EAAE,GAAGI,EAAK,eAAe,OAAOF,CAAQ,EAAE,qCAAqCE,EAAK,iBAC/G,EACO,GACT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { q as e } from "./constants-CN7GE1Lt.js";
|
|
2
|
+
import { t } from "./fixed-window-CtaFHanJ.js";
|
|
3
|
+
//#region src/capture/storm.ts
|
|
4
|
+
function n(n, r, i, a, o = e) {
|
|
5
|
+
return r === 0 || 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);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { n as t };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=storm-Daq2jGHU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storm-Daq2jGHU.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// makes thousands of events each second. Sending all of them floods 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. It reports each event over the limit.\n * @param window Window state to change.\n * @param limit Maximum events in each window.\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,\n diagnostics: Diagnostics,\n what: string,\n windowMs = ERROR_STORM_WINDOW_MS,\n): boolean {\n if (limit === 0 || 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,KAAKC,EAAcC,GAAQF,GAAOG,CAAQ,IAC/C,MAGTC,EAAY,OACV,wBACA,aAAa,OAAOJ,CAAK,EAAE,GAAGK,EAAK,eAAe,OAAOF,CAAQ,EAAE,qCAAqCE,EAAK,iBAC/G,GACO;AACT"}
|
|
@@ -77,6 +77,12 @@ export declare class ExitFlush {
|
|
|
77
77
|
* @param onExit Synchronous exit hook of the custom transport.
|
|
78
78
|
*/
|
|
79
79
|
private flushCustom;
|
|
80
|
+
/**
|
|
81
|
+
* Keeps a batch for the next page load in the emergency queue in localStorage. With storage
|
|
82
|
+
* "memory" or "none", the app wants nothing on the device. The batch is then lost.
|
|
83
|
+
* @param batch Batch that the exit flush cannot send.
|
|
84
|
+
*/
|
|
85
|
+
private park;
|
|
80
86
|
/**
|
|
81
87
|
* Serializes the exit batch. It reports a serializer that throws.
|
|
82
88
|
* @param batch Batch to serialize.
|
|
@@ -12,7 +12,8 @@ export declare class HttpTransport extends StatusTransport {
|
|
|
12
12
|
*/
|
|
13
13
|
private cachedHeaders;
|
|
14
14
|
/**
|
|
15
|
-
* Sends one log batch over HTTP. A metrics batch goes to metricsEndpoint.
|
|
15
|
+
* Sends one log batch over HTTP. A metrics batch goes to metricsEndpoint. A traces batch goes to
|
|
16
|
+
* tracesEndpoint. A batch without an endpoint goes nowhere.
|
|
16
17
|
* @param batch Batch to send.
|
|
17
18
|
* @param onKeepalive Runs when a request of the batch starts with keepalive.
|
|
18
19
|
* @throws TransportError on transient, throttled, 413, or permanent network failures.
|
|
@@ -13,7 +13,7 @@ export declare class RetryEngine {
|
|
|
13
13
|
private readonly transport;
|
|
14
14
|
private readonly diagnostics;
|
|
15
15
|
private readonly config;
|
|
16
|
-
private readonly batchesPerDrain
|
|
16
|
+
private readonly batchesPerDrain?;
|
|
17
17
|
private readonly onLoss;
|
|
18
18
|
/** This field holds the active retry timer handle. It is null when no timer runs. */
|
|
19
19
|
private timer;
|
|
@@ -35,7 +35,7 @@ export declare class RetryEngine {
|
|
|
35
35
|
* @param batchesPerDrain Maximum batches processed per drain tick.
|
|
36
36
|
* @param onLoss Receives the records of each batch that the engine drops.
|
|
37
37
|
*/
|
|
38
|
-
constructor(storage: StorageAdapter, transport: BatchTransport, diagnostics: Diagnostics, config: ResolvedConfig, batchesPerDrain?: number, onLoss?: LossReporter);
|
|
38
|
+
constructor(storage: StorageAdapter, transport: BatchTransport, diagnostics: Diagnostics, config: ResolvedConfig, batchesPerDrain?: number | undefined, onLoss?: LossReporter);
|
|
39
39
|
/** This method starts the engine. It listens for online events and arms the first timer. */
|
|
40
40
|
start(): void;
|
|
41
41
|
/** This method schedules an earlier retry when storage receives a new offline batch. */
|
|
@@ -50,6 +50,11 @@ export declare class RetryEngine {
|
|
|
50
50
|
storeFailed(batch: LogBatch, error: unknown): Promise<void>;
|
|
51
51
|
/** This method stops the engine. It removes the listener and clears the pending timer. */
|
|
52
52
|
stop(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Tries one delivery pass of stored batches before a context change. The caller sets the deadline.
|
|
55
|
+
* @returns Promise that resolves when this pass stops.
|
|
56
|
+
*/
|
|
57
|
+
flush(): Promise<void>;
|
|
53
58
|
/**
|
|
54
59
|
* Clears the pending timer. It then schedules a drain after the delay.
|
|
55
60
|
* @param delayMs Delay duration in milliseconds.
|
|
@@ -9,23 +9,26 @@ import type { LogSerializer, SerializedBatch } from "../../models/serializer";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function serializerFor(choice: SerializerChoice): LogSerializer;
|
|
11
11
|
/**
|
|
12
|
-
* Gives the kind of a batch. Only a batch of metric records goes to metricsEndpoint. A
|
|
13
|
-
*
|
|
12
|
+
* Gives the kind of a batch. Only a batch of metric records goes to metricsEndpoint. A batch of
|
|
13
|
+
* span records is always "traces". It must not go to endpoint as log records. A stored record
|
|
14
|
+
* can be corrupt. It then is not a metric or a span.
|
|
14
15
|
* @param batch Batch to test.
|
|
15
16
|
* @param config Active configuration.
|
|
16
|
-
* @returns "metrics" with metricsEndpoint set and only metric records,
|
|
17
|
+
* @returns "metrics" with metricsEndpoint set and only metric records, "traces" for only span
|
|
18
|
+
* records, else "logs".
|
|
17
19
|
*/
|
|
18
20
|
export declare function batchKind(batch: LogBatch, config: ResolvedConfig): BatchKind;
|
|
19
21
|
/**
|
|
20
22
|
* Gives the endpoint of a batch kind.
|
|
21
23
|
* @param kind Kind of the batch.
|
|
22
24
|
* @param config Active configuration.
|
|
23
|
-
* @returns metricsEndpoint for a metrics batch, else
|
|
25
|
+
* @returns metricsEndpoint for a metrics batch, tracesEndpoint for a traces batch, else
|
|
26
|
+
* endpoint. "" means that the batch has no destination.
|
|
24
27
|
*/
|
|
25
28
|
export declare function endpointFor(kind: BatchKind, config: ResolvedConfig): string | null;
|
|
26
29
|
/**
|
|
27
30
|
* Serializes a batch. It reports a serializer that throws, and the caller drops the batch.
|
|
28
|
-
* A metrics batch gets the OTLP metrics format.
|
|
31
|
+
* A metrics batch gets the OTLP metrics format. A traces batch gets the OTLP traces format.
|
|
29
32
|
* @param config Active configuration.
|
|
30
33
|
* @param batch Batch to serialize.
|
|
31
34
|
* @param diagnostics Diagnostics reporter.
|
|
@@ -35,11 +35,30 @@ export declare abstract class StatusTransport implements BatchTransport {
|
|
|
35
35
|
protected readonly diagnostics: Diagnostics;
|
|
36
36
|
private readonly onSampling;
|
|
37
37
|
private readonly onLoss;
|
|
38
|
+
/** Abort controller shared by the requests of this delivery context. */
|
|
39
|
+
protected readonly cancellation: AbortController;
|
|
40
|
+
/** Cancels work of this context. A custom transport receives the same abort signal. */
|
|
41
|
+
stop(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Checks the batch context after each asynchronous step and before a send.
|
|
44
|
+
* @param batch Batch to check.
|
|
45
|
+
* @throws TransportError if the context stopped or the context id does not match.
|
|
46
|
+
*/
|
|
47
|
+
protected assertContext(batch: LogBatch): void;
|
|
48
|
+
/**
|
|
49
|
+
* Ends the wait if this context stops before the work completes.
|
|
50
|
+
* @param work Work to wait for.
|
|
51
|
+
* @returns The result of the work.
|
|
52
|
+
* @throws TransportError if this context stops first.
|
|
53
|
+
*/
|
|
54
|
+
protected untilCancelled<T>(work: Promise<T>): Promise<T>;
|
|
38
55
|
/**
|
|
39
56
|
* Epoch time in milliseconds when the server throttle ends, for each endpoint. A 429 from
|
|
40
57
|
* metricsEndpoint must not stop the log batches.
|
|
41
58
|
*/
|
|
42
59
|
private readonly throttledUntil;
|
|
60
|
+
/** Epoch time in milliseconds when the server last accepted a batch, or null. */
|
|
61
|
+
private acceptedAt;
|
|
43
62
|
/**
|
|
44
63
|
* @param config Active configuration instance.
|
|
45
64
|
* @param diagnostics Diagnostics reporter.
|
|
@@ -60,6 +79,11 @@ export declare abstract class StatusTransport implements BatchTransport {
|
|
|
60
79
|
* @returns Milliseconds remaining in throttle window, or 0 if unthrottled.
|
|
61
80
|
*/
|
|
62
81
|
throttledForMs(batch: LogBatch): number;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the time when the server last accepted a batch.
|
|
84
|
+
* @returns Epoch time in milliseconds, or null before the first accepted batch.
|
|
85
|
+
*/
|
|
86
|
+
lastSendAt(): number | null;
|
|
63
87
|
/**
|
|
64
88
|
* Serializes a batch with the configured serializer. A metrics batch gets the OTLP metrics
|
|
65
89
|
* format. It reports a serializer that throws.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BR9t_w28.js","names":["matchesAny","url","patterns","pattern"],"sources":["../src/capture/types.ts"],"sourcesContent":["// src/capture/types.ts\n//\n// Shared interfaces, logger abstractions, and utility helpers for auto-capture modules.\n\nimport type { BreadcrumbBuffer } from \"../core/breadcrumbs\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { SpanData } from \"../core/spans\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { MetricType } from \"../models/log-record\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport type { TraceEngine } from \"../utils/tracing\";\n\n/**\n * Logging interface that auto-capture modules use. A reference to the runtime class\n * here causes an import cycle. The runtime installs the capture modules.\n */\nexport interface CaptureLogger {\n /**\n * Logs an error event with an associated error instance or reason.\n * @param message Error description.\n * @param error Caught error instance or reason.\n * @param payload Optional attributes.\n */\n error(message: string, error?: unknown, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a warning event.\n * @param message Warning description.\n * @param payload Optional attributes.\n */\n warn(message: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a discrete lifecycle or user event.\n * @param name Event identifier.\n * @param payload Optional attributes.\n */\n logEvent(name: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a numerical metric measurement.\n * @param name Metric name.\n * @param value Numerical measurement.\n * @param unit Unit of measurement.\n * @param type Metric type classification.\n * @param attrs Optional metric attributes.\n */\n logMetric(\n name: string,\n value: number,\n unit?: string,\n type?: MetricType,\n attrs?: Record<string, unknown>,\n ): void;\n\n /**\n * Logs a diagnostic debug message.\n * @param message Debug message.\n * @param payload Optional attributes.\n */\n debug(message: string, payload?: Record<string, unknown>): void;\n}\n\n/**\n * Capture work that runs one time for each document, not one time for each\n * install. A reconfigure builds new capture instances. Thus instance state\n * cannot hold these flags. web-vitals has no unsubscribe. A second subscription\n * reports each metric two times.\n */\nexport interface CaptureOnce {\n /** True after the library subscribes the web-vitals reporters. */\n webVitals: boolean;\n /** True after the library reports navigation timing. */\n navigationTiming: boolean;\n /** True after the first long frame install. Only that install reads buffered frames. */\n longFrames: boolean;\n}\n\n/** Shared runtime dependencies provided to auto-capture instances. */\nexport interface CaptureContext {\n /** False while the runtime stops or changes its security context. */\n isActive?: () => boolean;\n /** Active runtime configuration. */\n config: ResolvedConfig;\n /** Diagnostics reporter for capture faults. */\n diagnostics: Diagnostics;\n /** Logger instance for recorded telemetry. */\n logger: CaptureLogger;\n /** Buffer for recording contextual breadcrumbs. */\n breadcrumbs: BreadcrumbBuffer;\n /** Active trace context provider. */\n tracing: TraceEngine;\n /** Guards for the capture work that a reinstall must not repeat. */\n once: CaptureOnce;\n /** Adds a value to a counter or a histogram of the runtime. */\n recordMetric: (def: InstrumentDef, value: number, attributes?: MetricAttributes) => void;\n /** Records a span. The runtime drops it when spans are off. */\n recordSpan: (span: SpanData) => void;\n}\n\n/** Lifecycle interface for browser instrumentation modules. */\nexport interface Capture {\n /** Module identifier used in diagnostics. */\n readonly name: string;\n /**\n * Attaches instrumentation listeners and patches target APIs. A second patch on a\n * patched function adds a second wrapper and doubles each record. A second call\n * must do nothing.\n */\n install(): void;\n /** Restores native APIs and removes registered listeners. */\n uninstall(): void;\n}\n\n/**\n * Tests if a URL matches any string substring or regular expression pattern.\n * @param url Target URL to test. A value that is not a string matches nothing.\n * @param patterns Substrings and regular expressions to test against.\n * @returns True if any pattern matches the URL.\n */\nexport function matchesAny(url: unknown, patterns: (string | RegExp)[]): boolean {\n // Guard against a URL that is not a string. includes() on it throws in the call of the host.\n if (typeof url !== \"string\") {\n return false;\n }\n\n return patterns.some((pattern) =>\n typeof pattern === \"string\" ? url.includes(pattern) : pattern.test(url),\n );\n}\n"],"mappings":";AAwHA,SAAgBA,EAAW,GAAc,GAAwC;CAM/E,OAJI,OAAOC,KAAQ,YAIZC,EAAS,MAAM,MACpB,OAAOC,KAAY,WAAWF,EAAI,SAASE,CAAO,IAAIA,EAAQ,KAAKF,CAAG,CACxE;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-C7WNpnG1.cjs","names":["matchesAny","url","patterns","pattern"],"sources":["../src/capture/types.ts"],"sourcesContent":["// src/capture/types.ts\n//\n// Shared interfaces, logger abstractions, and utility helpers for auto-capture modules.\n\nimport type { BreadcrumbBuffer } from \"../core/breadcrumbs\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { SpanData } from \"../core/spans\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { MetricType } from \"../models/log-record\";\nimport type { InstrumentDef, MetricAttributes } from \"../models/metric\";\nimport type { TraceEngine } from \"../utils/tracing\";\n\n/**\n * Logging interface that auto-capture modules use. A reference to the runtime class\n * here causes an import cycle. The runtime installs the capture modules.\n */\nexport interface CaptureLogger {\n /**\n * Logs an error event with an associated error instance or reason.\n * @param message Error description.\n * @param error Caught error instance or reason.\n * @param payload Optional attributes.\n */\n error(message: string, error?: unknown, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a warning event.\n * @param message Warning description.\n * @param payload Optional attributes.\n */\n warn(message: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a discrete lifecycle or user event.\n * @param name Event identifier.\n * @param payload Optional attributes.\n */\n logEvent(name: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a numerical metric measurement.\n * @param name Metric name.\n * @param value Numerical measurement.\n * @param unit Unit of measurement.\n * @param type Metric type classification.\n * @param attrs Optional metric attributes.\n */\n logMetric(\n name: string,\n value: number,\n unit?: string,\n type?: MetricType,\n attrs?: Record<string, unknown>,\n ): void;\n\n /**\n * Logs a diagnostic debug message.\n * @param message Debug message.\n * @param payload Optional attributes.\n */\n debug(message: string, payload?: Record<string, unknown>): void;\n}\n\n/**\n * Capture work that runs one time for each document, not one time for each\n * install. A reconfigure builds new capture instances. Thus instance state\n * cannot hold these flags. web-vitals has no unsubscribe. A second subscription\n * reports each metric two times.\n */\nexport interface CaptureOnce {\n /** True after the library subscribes the web-vitals reporters. */\n webVitals: boolean;\n /** True after the library reports navigation timing. */\n navigationTiming: boolean;\n /** True after the first long frame install. Only that install reads buffered frames. */\n longFrames: boolean;\n}\n\n/** Shared runtime dependencies provided to auto-capture instances. */\nexport interface CaptureContext {\n /** False while the runtime stops or changes its security context. */\n isActive?: () => boolean;\n /** Active runtime configuration. */\n config: ResolvedConfig;\n /** Diagnostics reporter for capture faults. */\n diagnostics: Diagnostics;\n /** Logger instance for recorded telemetry. */\n logger: CaptureLogger;\n /** Buffer for recording contextual breadcrumbs. */\n breadcrumbs: BreadcrumbBuffer;\n /** Active trace context provider. */\n tracing: TraceEngine;\n /** Guards for the capture work that a reinstall must not repeat. */\n once: CaptureOnce;\n /** Adds a value to a counter or a histogram of the runtime. */\n recordMetric: (def: InstrumentDef, value: number, attributes?: MetricAttributes) => void;\n /** Records a span. The runtime drops it when spans are off. */\n recordSpan: (span: SpanData) => void;\n}\n\n/** Lifecycle interface for browser instrumentation modules. */\nexport interface Capture {\n /** Module identifier used in diagnostics. */\n readonly name: string;\n /**\n * Attaches instrumentation listeners and patches target APIs. A second patch on a\n * patched function adds a second wrapper and doubles each record. A second call\n * must do nothing.\n */\n install(): void;\n /** Restores native APIs and removes registered listeners. */\n uninstall(): void;\n}\n\n/**\n * Tests if a URL matches any string substring or regular expression pattern.\n * @param url Target URL to test. A value that is not a string matches nothing.\n * @param patterns Substrings and regular expressions to test against.\n * @returns True if any pattern matches the URL.\n */\nexport function matchesAny(url: unknown, patterns: (string | RegExp)[]): boolean {\n // Guard against a URL that is not a string. includes() on it throws in the call of the host.\n if (typeof url !== \"string\") {\n return false;\n }\n\n return patterns.some((pattern) =>\n typeof pattern === \"string\" ? url.includes(pattern) : pattern.test(url),\n );\n}\n"],"mappings":"AAwHA,SAAgBA,EAAW,EAAc,EAAwC,CAM/E,OAJI,OAAOC,GAAQ,UAIZC,EAAS,KAAM,GACpB,OAAOC,GAAY,SAAWF,EAAI,SAASE,CAAO,EAAIA,EAAQ,KAAKF,CAAG,CACxE,CACF"}
|
|
@@ -13,3 +13,12 @@ export interface StormWindow {
|
|
|
13
13
|
* @returns False when the window has no allowance left. The caller must drop the event.
|
|
14
14
|
*/
|
|
15
15
|
export declare function countInWindow(window: StormWindow, limit: number, windowMs: number): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Tells if a fixed window has ended. The bus uses the same rule to expire its source entries.
|
|
18
|
+
* @param window Window state.
|
|
19
|
+
* @param windowMs Length of the window, in milliseconds.
|
|
20
|
+
* @param now Current epoch time, in milliseconds.
|
|
21
|
+
* @returns True after the window length, or when the clock moved back. Without the second
|
|
22
|
+
* check, a clock that moves back keeps the window open.
|
|
23
|
+
*/
|
|
24
|
+
export declare function windowEnded(window: StormWindow, windowMs: number, now: number): boolean;
|
package/dist/utils/identity.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export declare function newId(diagnostics: Diagnostics): string;
|
|
|
61
61
|
* @param stores Identity stores.
|
|
62
62
|
* @returns Populated Identity object.
|
|
63
63
|
*/
|
|
64
|
-
export declare function resolveIdentity(diagnostics: Diagnostics, stores?: IdentityStores): Identity;
|
|
64
|
+
export declare function resolveIdentity(diagnostics: Diagnostics, stores?: IdentityStores, idleMs?: number): Identity;
|
|
65
65
|
/**
|
|
66
66
|
* Writes a new tab id to the session store.
|
|
67
67
|
* @param tabId New tab identifier.
|
|
@@ -77,16 +77,34 @@ export declare function persistTabId(tabId: string, diagnostics: Diagnostics, st
|
|
|
77
77
|
export declare class SessionTouch {
|
|
78
78
|
private diagnostics;
|
|
79
79
|
private readonly stores;
|
|
80
|
+
private readonly touchMs;
|
|
81
|
+
private readonly idleMs;
|
|
80
82
|
/** Epoch milliseconds of the last write this instance made. */
|
|
81
83
|
private lastTouchAt;
|
|
82
84
|
/**
|
|
83
85
|
* @param diagnostics Diagnostics reporter.
|
|
84
86
|
* @param stores Identity stores.
|
|
85
87
|
*/
|
|
86
|
-
constructor(diagnostics: Diagnostics, stores?: IdentityStores);
|
|
88
|
+
constructor(diagnostics: Diagnostics, stores?: IdentityStores, touchMs?: number, idleMs?: number);
|
|
87
89
|
/**
|
|
88
90
|
* Writes the session activity time to the local store. It writes one time in each throttle window.
|
|
89
91
|
* @param sessionId Active session identifier.
|
|
90
92
|
*/
|
|
91
93
|
touch(sessionId: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Reads the live session id in the local store.
|
|
96
|
+
* @returns The stored session id, or undefined if no session is live.
|
|
97
|
+
*/
|
|
98
|
+
stored(): string | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Writes a new session id to the local store now. The throttle does not apply.
|
|
101
|
+
* @param sessionId New session identifier.
|
|
102
|
+
*/
|
|
103
|
+
restart(sessionId: string): void;
|
|
104
|
+
/**
|
|
105
|
+
* Writes the session record and starts a new throttle window.
|
|
106
|
+
* @param sessionId Session identifier.
|
|
107
|
+
* @param now Epoch time in milliseconds.
|
|
108
|
+
*/
|
|
109
|
+
private write;
|
|
92
110
|
}
|
package/dist/utils/lock.d.ts
CHANGED
|
@@ -13,3 +13,11 @@ import type { Diagnostics } from "../core/diagnostics";
|
|
|
13
13
|
export declare function withDrainLock<T>(name: string, diagnostics: Diagnostics, fn: () => Promise<T>, { skipIfBusy }?: {
|
|
14
14
|
skipIfBusy?: boolean;
|
|
15
15
|
}): Promise<T | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Gives the lock name of one application namespace. Two namespaces on one origin then do not wait for each other.
|
|
18
|
+
* Without it, the retry pass of one application skips while the other holds the lock.
|
|
19
|
+
* @param name Base lock name.
|
|
20
|
+
* @param namespace Application storage namespace. An empty value keeps the base name.
|
|
21
|
+
* @returns Lock name for this namespace.
|
|
22
|
+
*/
|
|
23
|
+
export declare function lockName(name: string, namespace: string): string;
|
package/dist/utils/openfin.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface FinIab {
|
|
|
14
14
|
*/
|
|
15
15
|
subscribe(identity: {
|
|
16
16
|
uuid: string;
|
|
17
|
-
}, topic: string, listener: (message: unknown) => void): Promise<void>;
|
|
17
|
+
}, topic: string, listener: (message: unknown, uuid?: string, name?: string) => void): Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
/** The members of fin.me that the library reads. */
|
|
20
20
|
export interface FinMe {
|
package/dist/utils/platform.d.ts
CHANGED
|
@@ -34,6 +34,16 @@ export declare function isTopLevel(diagnostics: Diagnostics): boolean;
|
|
|
34
34
|
* @returns Current location.href or empty string.
|
|
35
35
|
*/
|
|
36
36
|
export declare function currentUrl(diagnostics: Diagnostics): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gives the form of a URL that the library records. It always removes the user info, which is a
|
|
39
|
+
* credential. Without fullUrls, it also removes the query and the fragment.
|
|
40
|
+
* @param url Absolute or relative URL.
|
|
41
|
+
* @param fullUrls Value of `capture.fullUrls`.
|
|
42
|
+
* @param transform Value of `capture.urlTransform`. It replaces the default rule.
|
|
43
|
+
* @param diagnostics Diagnostics reporter for a transform that throws.
|
|
44
|
+
* @returns The URL to record.
|
|
45
|
+
*/
|
|
46
|
+
export declare function recordedUrl(url: string, fullUrls: boolean, transform?: (url: string) => string | null, diagnostics?: Diagnostics): string;
|
|
37
47
|
/**
|
|
38
48
|
* Drops the query string and fragment from a URL.
|
|
39
49
|
* It cuts the string and does not parse a URL. A relative request target has no base URL.
|
package/dist/utils/tracing.d.ts
CHANGED
|
@@ -11,6 +11,54 @@ export interface TraceContext {
|
|
|
11
11
|
}
|
|
12
12
|
/** Cause of a rotation of the ambient trace context. */
|
|
13
13
|
export type RotateReason = "start" | "interaction" | "navigation" | "explicit" | "maxAge";
|
|
14
|
+
/** Ambient trace that ended. Its root span covers it. */
|
|
15
|
+
export interface EndedTrace {
|
|
16
|
+
/** Trace ID. */
|
|
17
|
+
traceId: string;
|
|
18
|
+
/** Span ID of the root span. */
|
|
19
|
+
spanId: string;
|
|
20
|
+
/** Cause of the start of the trace. */
|
|
21
|
+
reason: RotateReason;
|
|
22
|
+
/** Start time in epoch milliseconds. */
|
|
23
|
+
startedAt: number;
|
|
24
|
+
/** End time in epoch milliseconds. */
|
|
25
|
+
endedAt: number;
|
|
26
|
+
}
|
|
27
|
+
/** Client span that a traceparent header names. */
|
|
28
|
+
export interface ClientSpan {
|
|
29
|
+
/** Trace ID. */
|
|
30
|
+
traceId: string;
|
|
31
|
+
/** Span ID of the client span. */
|
|
32
|
+
spanId: string;
|
|
33
|
+
/** Span ID of the root span of the trace. */
|
|
34
|
+
parentSpanId: string;
|
|
35
|
+
}
|
|
36
|
+
/** Headers of one request, and the client span that they name. */
|
|
37
|
+
export interface RequestTrace {
|
|
38
|
+
/** Header map containing traceparent. */
|
|
39
|
+
headers: Record<string, string>;
|
|
40
|
+
/** Client span of the request. It is undefined when the library records no span for it. */
|
|
41
|
+
span?: ClientSpan;
|
|
42
|
+
}
|
|
43
|
+
/** Span decisions of the runtime. */
|
|
44
|
+
export interface SpanHooks {
|
|
45
|
+
/**
|
|
46
|
+
* Tests if the library records spans.
|
|
47
|
+
* @returns True with a traces endpoint.
|
|
48
|
+
*/
|
|
49
|
+
enabled(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Tests if sampling keeps the spans of a trace.
|
|
52
|
+
* @param traceId Trace ID.
|
|
53
|
+
* @returns True if the library sends the spans of the trace.
|
|
54
|
+
*/
|
|
55
|
+
keeps(traceId: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Receives an ambient trace that ended.
|
|
58
|
+
* @param ended The trace.
|
|
59
|
+
*/
|
|
60
|
+
onEnd(ended: EndedTrace): void;
|
|
61
|
+
}
|
|
14
62
|
/**
|
|
15
63
|
* Generates a random 32-character hex string in the W3C trace ID format.
|
|
16
64
|
* Use it to start your own trace. The backend drops an id with the wrong width
|
|
@@ -28,6 +76,7 @@ export declare class TraceEngine {
|
|
|
28
76
|
private readonly diagnostics;
|
|
29
77
|
private readonly maxAgeMs;
|
|
30
78
|
private readonly load?;
|
|
79
|
+
private readonly spans?;
|
|
31
80
|
/**
|
|
32
81
|
* Active ambient trace context. The instance keeps this state, not the module. Two
|
|
33
82
|
* runtimes in one document must not share a trace id.
|
|
@@ -40,8 +89,9 @@ export declare class TraceEngine {
|
|
|
40
89
|
* @param maxAgeMs Maximum lifetime of an un-rotated ambient trace in milliseconds.
|
|
41
90
|
* @param load Loader for the OpenTelemetry API. If it is not set, OTel is off.
|
|
42
91
|
* Do not import the peer by name. The Vite dev server fails if the peer is not installed.
|
|
92
|
+
* @param spans Span decisions of the runtime. Without them, the library records no span.
|
|
43
93
|
*/
|
|
44
|
-
constructor(diagnostics: Diagnostics, maxAgeMs?: number, load?: OtelLoader | undefined);
|
|
94
|
+
constructor(diagnostics: Diagnostics, maxAgeMs?: number, load?: OtelLoader | undefined, spans?: SpanHooks | undefined);
|
|
45
95
|
/**
|
|
46
96
|
* Loads the OpenTelemetry API. Until the load completes, records use the ambient trace.
|
|
47
97
|
* If there is no loader or the load fails, all records use the ambient trace.
|
|
@@ -53,21 +103,49 @@ export declare class TraceEngine {
|
|
|
53
103
|
* @returns Active TraceContext.
|
|
54
104
|
*/
|
|
55
105
|
resolve(): TraceContext;
|
|
106
|
+
/**
|
|
107
|
+
* Reads the ambient trace. It rotates a trace that is too old.
|
|
108
|
+
* @returns Ambient TraceContext.
|
|
109
|
+
*/
|
|
110
|
+
private ambientContext;
|
|
56
111
|
/**
|
|
57
112
|
* Reads the active span of the host if the peer module loaded and a span runs.
|
|
58
113
|
* @returns Trace context of the active span, or undefined.
|
|
59
114
|
*/
|
|
60
115
|
private activeSpanContext;
|
|
61
116
|
/**
|
|
62
|
-
* Rotates the ambient trace context to mark the start of a new logical operation.
|
|
63
|
-
*
|
|
117
|
+
* Rotates the ambient trace context to mark the start of a new logical operation. It ends the
|
|
118
|
+
* root span of the old trace.
|
|
119
|
+
* @param reason Event reason triggering the rotation.
|
|
64
120
|
* @returns Newly created TraceContext.
|
|
65
121
|
*/
|
|
66
|
-
rotate(
|
|
122
|
+
rotate(reason: RotateReason): TraceContext;
|
|
123
|
+
/**
|
|
124
|
+
* Ends the root span of the ambient trace one time. Later records can still use the trace.
|
|
125
|
+
* The exit flush calls it. A closing document has no later rotation.
|
|
126
|
+
*/
|
|
127
|
+
end(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Ends the root span of a trace one time.
|
|
130
|
+
* @param ambient Trace to end.
|
|
131
|
+
*/
|
|
132
|
+
private finish;
|
|
67
133
|
/**
|
|
68
134
|
* Generates W3C traceparent headers with the registered OpenTelemetry propagators.
|
|
69
135
|
* Without a traceparent from OpenTelemetry, it uses the ambient trace.
|
|
70
136
|
* @returns Header map containing traceparent.
|
|
71
137
|
*/
|
|
72
138
|
headers(): Record<string, string>;
|
|
139
|
+
/**
|
|
140
|
+
* Generates the headers of one request of the network capture. With spans on, the traceparent
|
|
141
|
+
* names a new client span of the ambient trace.
|
|
142
|
+
* @returns The headers, and the client span that the library records.
|
|
143
|
+
*/
|
|
144
|
+
request(): RequestTrace;
|
|
145
|
+
/**
|
|
146
|
+
* Generates the trace headers.
|
|
147
|
+
* @param client True to name a new client span in the traceparent.
|
|
148
|
+
* @returns The headers, and the client span that the library records.
|
|
149
|
+
*/
|
|
150
|
+
private trace;
|
|
73
151
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./library-request-BaZOi4eg.cjs"),t=require("./platform-DBSKTvFn.cjs"),n=require("./patch-BX8KrPCT.cjs"),r=require("./storm-CNZjsw4T.cjs"),i=require("./types-C7WNpnG1.cjs");var a=`ui.websocket.messages`;function o(e,n,r){let i=new URL(e);return{target:t.i(e,!1,n.capture.urlTransform,r),server:i.hostname}}function s(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 c=class{diagnostics;config;name=`websocket`;restore;state;window={start:0,count:0};constructor(e,t){this.diagnostics=e,this.config=t}install(e){if(this.restore||typeof WebSocket>`u`)return;let t={active:!0,ctx:e,messages:e.counter(a),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),s(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}=o(e.url,this.config,this.diagnostics),a={"url.full":n,"server.address":r},{logger:c}=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(()=>{c.logEvent(`websocket.open`,a)})}),e.addEventListener(`error`,()=>{l(()=>{c.warn(`websocket.error`,a)})}),e.addEventListener(`close`,e=>{l(()=>{c.logEvent(`websocket.close`,{...a,"websocket.close.code":e.code,"websocket.close.clean":e.wasClean})})}),e.addEventListener(`message`,()=>{s(t,e,`receive`)})})}allow(e){return e.active&&r.t(this.window,this.config.capturePolicy.webSocketPerWindow,this.diagnostics,`WebSocket events`,this.config.capturePolicy.windowMs)}};exports.WebSocketCapture=c;
|
|
2
|
+
//# sourceMappingURL=web-socket-BacvKOvD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-socket-BacvKOvD.cjs","names":["recordedUrl","isLibraryRequest","patch","matchesAny","allowInWindow","require_library_request","require_platform","require_patch","require_storm","require_types","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 each WebSocket. It counts the messages by direction\n// and server. It never reads the content of a message. It is a capture plugin, and the runtime\n// loads it 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/** Data of one WebSocket.send call. */\ntype SendData = Parameters<WebSocket[\"send\"]>[0];\n\n/** State of one install. A wrapper that stays after uninstall reads it and records nothing. */\ninterface InstallState {\n /** False after uninstall. */\n active: boolean;\n /** Tools of the plugin. */\n ctx: PluginContext;\n /** Counter of the messages. */\n messages: Counter;\n /** Server host name of each tracked socket. */\n servers: WeakMap<WebSocket, string>;\n /** Delivery context in force when each socket opened. */\n contexts: WeakMap<WebSocket, string>;\n /** Active capture settings and isolation rule. */\n config: ResolvedConfig;\n}\n\n/**\n * Removes the user info, the query and the fragment from a socket URL. They can hold a token.\n * @param url Absolute URL of the socket.\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 host name of the server.\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 cannot set a header on a socket. Thus 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 of a tracked socket.\n * @param state State of the install that made the socket.\n * @param socket Socket of the message.\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 // A send of the library, for example a custom transport, must not make the next send.\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 the message counts of each WebSocket that the app opens. */\nexport class WebSocketCapture implements CapturePlugin {\n /** Capture module identifier. */\n readonly name = \"websocket\";\n\n /** Restores the WebSocket constructor. Undefined when the capture is not installed. */\n private restore: (() => boolean) | undefined;\n\n /** State of the active install. */\n private state: InstallState | undefined;\n\n /** Rate limit of the lifecycle records. A reconnect loop must not 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 each socket.\n * @param ctx Tools of the plugin.\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 that the app opened before the install.\n * @param value Value to test.\n * @returns True for each native socket.\n */\n static override [Symbol.hasInstance](value: unknown): boolean {\n return value instanceof Original;\n }\n\n /**\n * @param url URL of the server.\n * @param protocols Sub-protocols of the app.\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 Data of the app. The library does not 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 each tracked socket from recording. */\n uninstall(): void {\n if (this.state) {\n this.state.active = false;\n }\n\n // Another script can wrap the constructor after the library. 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 the lifecycle and the received messages of one socket.\n * @param socket New socket of the app.\n * @param state State of the install that made the socket.\n */\n private track(socket: WebSocket, state: InstallState): void {\n if (!state.active) {\n return;\n }\n\n // A read here runs inside the constructor call of the app. 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 can 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 * Tests if a lifecycle record can go out.\n * @param state State of the install that made 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.capturePolicy.webSocketPerWindow,\n this.diagnostics,\n \"WebSocket events\",\n this.config.capturePolicy.windowMs,\n )\n );\n }\n}\n"],"mappings":"6LAiBA,IAAMU,EAAkB,wBA4BxB,SAASC,EACP,EACA,EACA,EACoC,CACpC,IAAMC,EAAS,IAAI,IAAIC,CAAG,EAE1B,MAAO,CAGL,OAAQb,EAAAA,EAAYa,EAAK,GAAOC,EAAO,QAAQ,aAAcC,CAAW,EACxE,OAAQH,EAAO,QACjB,CACF,CAQA,SAASI,EAAM,EAAqB,EAAmB,EAAyC,CAC9F,IAAMC,EAASC,EAAM,QAAQ,IAAIC,CAAM,EAGjCC,EAAMC,IAAc,YAAcpB,EAAAA,EAAiB,EACzD,GACE,CAACiB,EAAM,QACPD,IAAW,IAAA,IACXG,GACCF,EAAM,OAAO,gBAAgB,WAC5BA,EAAM,SAAS,IAAIC,CAAM,IAAMD,EAAM,OAAO,gBAAgB,GAE9D,OAGF,IAAMI,EAA+B,CACnC,uBAAwBD,EACxB,iBAAkBJ,CACpB,EACAC,EAAM,SAAS,IAAI,EAAGI,CAAU,CAClC,CAGA,IAAaC,EAAb,KAAuD,CAkBlC,YACA,OAjBnB,KAAgB,YAGhB,QAGA,MAGA,OAAuC,CAAE,MAAO,EAAG,MAAO,CAAE,EAM5D,YACE,EACA,EACA,CAFiB,KAAA,YAAAR,EACA,KAAA,OAAAD,CAChB,CAMH,QAAQ,EAA0B,CAChC,GAAI,KAAK,SAAW,OAAO,UAAc,IACvC,OAGF,IAAMI,EAAsB,CAC1B,OAAQ,GACR,MACA,SAAUM,EAAI,QAAQd,CAAe,EACrC,QAAS,IAAI,QACb,SAAU,IAAI,QACd,OAAQ,KAAK,MACf,EACA,KAAK,MAAQQ,EAEb,IAAMO,EAAS,GAA4B,CACzC,KAAK,MAAMN,EAAQD,CAAK,CAC1B,EAEA,KAAK,QAAUhB,EAAAA,EACb,WACA,YACC,GACC,cAA+BwB,CAAS,CAMtC,OAAiB,OAAO,aAAa,EAAyB,CAC5D,OAAOC,aAAiBD,CAC1B,CAMA,YAAY,EAAmB,EAA+B,CAC5D,MAAMb,EAAKe,CAAS,EACpBH,EAAM,IAAI,CACZ,CAMA,KAAc,EAAsB,CAClC,MAAM,KAAKI,CAAI,EACfb,EAAME,EAAO,KAAM,UAAU,CAC/B,CACF,CACJ,CACF,CAGA,WAAkB,CACZ,KAAK,QACP,KAAK,MAAM,OAAS,IAIlB,KAAK,SAAW,CAAC,KAAK,QAAQ,GAChC,KAAK,YAAY,OACf,yBACA,qFACF,EAGF,KAAK,QAAU,IAAA,GACf,KAAK,MAAQ,IAAA,EACf,CAOA,MAAc,EAAmB,EAA2B,CACrDA,EAAM,QAKX,KAAK,YAAY,MACf,wBACA,iFACM,CAEJ,GAAIf,EAAAA,EAAWgB,EAAO,IAAK,KAAK,OAAO,QAAQ,UAAU,EACvD,OAGF,GAAM,CAAE,SAAQ,UAAWR,EAAaQ,EAAO,IAAK,KAAK,OAAQ,KAAK,WAAW,EAC3EG,EAAa,CAAE,WAAYQ,EAAQ,iBAAkBb,CAAO,EAC5D,CAAE,UAAWC,EAAM,IACzBA,EAAM,QAAQ,IAAIC,EAAQF,CAAM,EAChCC,EAAM,SAAS,IAAIC,EAAQ,KAAK,OAAO,gBAAgB,EAAE,EAEzD,IAAMY,EAAa,GAA4B,EAE1C,CAAC,KAAK,OAAO,gBAAgB,WAC5Bb,EAAM,SAAS,IAAIC,CAAM,IAAM,KAAK,OAAO,gBAAgB,KAC7D,KAAK,MAAMD,CAAK,GAEhBc,EAAM,CAEV,EAEAb,EAAO,iBAAiB,WAAc,CACpCY,MAAgB,CACdE,EAAO,SAAS,iBAAkBX,CAAU,CAC9C,CAAC,CACH,CAAC,EACDH,EAAO,iBAAiB,YAAe,CACrCY,MAAgB,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,QACNd,EAAAA,EACE,KAAK,OACL,KAAK,OAAO,cAAc,mBAC1B,KAAK,YACL,mBACA,KAAK,OAAO,cAAc,QAC5B,CAEJ,CACF"}
|