@utk09/ui-observability 0.5.0 → 0.6.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +77 -60
  3. package/dist/bus/bus.d.ts +10 -10
  4. package/dist/bus/links.d.ts +1 -1
  5. package/dist/{bus-D3OO0OcL.js → bus-BTMuVkDk.js} +19 -19
  6. package/dist/bus-BTMuVkDk.js.map +1 -0
  7. package/dist/bus-ChIXDAWD.cjs +2 -0
  8. package/dist/bus-ChIXDAWD.cjs.map +1 -0
  9. package/dist/capture/network.d.ts +2 -2
  10. package/dist/capture/types.d.ts +10 -10
  11. package/dist/capture/web-vitals.d.ts +3 -3
  12. package/dist/{constants-B6kdsCzF.js → constants-0-YchbAL.js} +2 -2
  13. package/dist/constants-0-YchbAL.js.map +1 -0
  14. package/dist/{constants-DZH04585.cjs → constants-TUFcy95w.cjs} +2 -2
  15. package/dist/constants-TUFcy95w.cjs.map +1 -0
  16. package/dist/constants.d.ts +53 -40
  17. package/dist/core/breadcrumbs.d.ts +14 -14
  18. package/dist/core/config.d.ts +5 -4
  19. package/dist/core/context.d.ts +2 -2
  20. package/dist/core/diagnostics.d.ts +10 -9
  21. package/dist/core/journey.d.ts +23 -20
  22. package/dist/core/logger.d.ts +7 -7
  23. package/dist/core/pipeline.d.ts +34 -29
  24. package/dist/core/record.d.ts +6 -6
  25. package/dist/core/runtime.d.ts +20 -18
  26. package/dist/core/sampling.d.ts +15 -16
  27. package/dist/core/sender.d.ts +1 -1
  28. package/dist/{errors-DPju_xSI.cjs → errors-DRXBRqvm.cjs} +2 -2
  29. package/dist/errors-DRXBRqvm.cjs.map +1 -0
  30. package/dist/{errors-Dme9tz-6.js → errors-Dwm2SzBa.js} +4 -4
  31. package/dist/errors-Dwm2SzBa.js.map +1 -0
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.ts +6 -5
  35. package/dist/index.js +61 -61
  36. package/dist/index.js.map +1 -1
  37. package/dist/indexeddb-storage-B5dwq4hW.cjs +2 -0
  38. package/dist/indexeddb-storage-B5dwq4hW.cjs.map +1 -0
  39. package/dist/{indexeddb-storage-nxs_rxGx.js → indexeddb-storage-DjY4Ml6t.js} +16 -16
  40. package/dist/indexeddb-storage-DjY4Ml6t.js.map +1 -0
  41. package/dist/{interactions-DP0-rIPJ.cjs → interactions-DVom6eYn.cjs} +2 -2
  42. package/dist/interactions-DVom6eYn.cjs.map +1 -0
  43. package/dist/{interactions-C1romMpE.js → interactions-DZmLu7l2.js} +2 -2
  44. package/dist/interactions-DZmLu7l2.js.map +1 -0
  45. package/dist/models/batch.d.ts +12 -9
  46. package/dist/models/bus.d.ts +12 -13
  47. package/dist/models/config.d.ts +58 -41
  48. package/dist/models/log-record.d.ts +12 -10
  49. package/dist/models/serializer.d.ts +3 -2
  50. package/dist/models/storage.d.ts +2 -2
  51. package/dist/{network-au-Tqt1n.js → network-C4d2uw2Z.js} +4 -4
  52. package/dist/network-C4d2uw2Z.js.map +1 -0
  53. package/dist/network-CuqWadNn.cjs +2 -0
  54. package/dist/network-CuqWadNn.cjs.map +1 -0
  55. package/dist/platform-CXio0W2n.cjs +2 -0
  56. package/dist/platform-CXio0W2n.cjs.map +1 -0
  57. package/dist/{platform-DMYo3AX3.js → platform-CY8S3hUs.js} +8 -8
  58. package/dist/platform-CY8S3hUs.js.map +1 -0
  59. package/dist/sampling-CEthcmEX.cjs +2 -0
  60. package/dist/sampling-CEthcmEX.cjs.map +1 -0
  61. package/dist/{sampling-ByI5H44E.js → sampling-CJsI_24L.js} +21 -18
  62. package/dist/sampling-CJsI_24L.js.map +1 -0
  63. package/dist/sender-ByFAkXVd.cjs +3 -0
  64. package/dist/sender-ByFAkXVd.cjs.map +1 -0
  65. package/dist/{sender-R7lOpyNc.js → sender-dpvR_bHM.js} +60 -60
  66. package/dist/sender-dpvR_bHM.js.map +1 -0
  67. package/dist/storage/emergency-queue.d.ts +2 -2
  68. package/dist/storage/factory.d.ts +2 -1
  69. package/dist/storage/idb-driver.d.ts +19 -19
  70. package/dist/storage/indexeddb-storage.d.ts +18 -17
  71. package/dist/storage/keys.d.ts +1 -1
  72. package/dist/storage/local-storage.d.ts +19 -18
  73. package/dist/storage/memory-storage.d.ts +12 -11
  74. package/dist/transport/compression.d.ts +2 -2
  75. package/dist/transport/errors.d.ts +8 -7
  76. package/dist/transport/exit-flush.d.ts +27 -24
  77. package/dist/transport/http-transport.d.ts +18 -11
  78. package/dist/transport/retry-engine.d.ts +33 -28
  79. package/dist/transport/serializers/ecs.d.ts +1 -1
  80. package/dist/transport/serializers/otlp.d.ts +1 -1
  81. package/dist/unref-16maCyKA.js.map +1 -1
  82. package/dist/unref-CU9Nyz_9.cjs.map +1 -1
  83. package/dist/utils/identity.d.ts +6 -5
  84. package/dist/utils/lock.d.ts +4 -4
  85. package/dist/utils/platform.d.ts +5 -3
  86. package/dist/utils/sanitize.d.ts +5 -2
  87. package/dist/utils/sequence.d.ts +2 -2
  88. package/dist/utils/tracing.d.ts +8 -7
  89. package/dist/web-vitals-B2FYsEAU.cjs +2 -0
  90. package/dist/web-vitals-B2FYsEAU.cjs.map +1 -0
  91. package/dist/{web-vitals-DwWdLBq6.js → web-vitals-DHZ0yA_H.js} +4 -4
  92. package/dist/web-vitals-DHZ0yA_H.js.map +1 -0
  93. package/package.json +1 -1
  94. package/dist/bus-D3OO0OcL.js.map +0 -1
  95. package/dist/bus-OdRJVUzr.cjs +0 -2
  96. package/dist/bus-OdRJVUzr.cjs.map +0 -1
  97. package/dist/constants-B6kdsCzF.js.map +0 -1
  98. package/dist/constants-DZH04585.cjs.map +0 -1
  99. package/dist/errors-DPju_xSI.cjs.map +0 -1
  100. package/dist/errors-Dme9tz-6.js.map +0 -1
  101. package/dist/indexeddb-storage-lGdoHGHy.cjs +0 -2
  102. package/dist/indexeddb-storage-lGdoHGHy.cjs.map +0 -1
  103. package/dist/indexeddb-storage-nxs_rxGx.js.map +0 -1
  104. package/dist/interactions-C1romMpE.js.map +0 -1
  105. package/dist/interactions-DP0-rIPJ.cjs.map +0 -1
  106. package/dist/network-DDVIJSHd.cjs +0 -2
  107. package/dist/network-DDVIJSHd.cjs.map +0 -1
  108. package/dist/network-au-Tqt1n.js.map +0 -1
  109. package/dist/platform-DMYo3AX3.js.map +0 -1
  110. package/dist/platform-g99Kn755.cjs +0 -2
  111. package/dist/platform-g99Kn755.cjs.map +0 -1
  112. package/dist/sampling-ByI5H44E.js.map +0 -1
  113. package/dist/sampling-Dui-Fp3u.cjs +0 -2
  114. package/dist/sampling-Dui-Fp3u.cjs.map +0 -1
  115. package/dist/sender-R7lOpyNc.js.map +0 -1
  116. package/dist/sender-vLcbQhiB.cjs +0 -3
  117. package/dist/sender-vLcbQhiB.cjs.map +0 -1
  118. package/dist/web-vitals-DM2nvcMJ.cjs +0 -2
  119. package/dist/web-vitals-DM2nvcMJ.cjs.map +0 -1
  120. package/dist/web-vitals-DwWdLBq6.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  import type { Diagnostics } from "../core/diagnostics";
2
2
  import { type LogBatch } from "../models/batch";
3
3
  import type { GapReporter, PruneResult, StorageAdapter, StorageLimits } from "../models/storage";
4
- /** Persistent StorageAdapter implementation backed by localStorage. */
4
+ /** This StorageAdapter keeps batches in localStorage. */
5
5
  export declare class LocalStorageStorage implements StorageAdapter {
6
6
  private readonly limits;
7
7
  private readonly diagnostics;
8
8
  private readonly onGap?;
9
- /** Storage adapter strategy name. */
9
+ /** This field holds the storage strategy name. */
10
10
  readonly name = "localstorage";
11
11
  /**
12
12
  * @param limits Storage capacity and retention thresholds.
@@ -15,79 +15,80 @@ export declare class LocalStorageStorage implements StorageAdapter {
15
15
  */
16
16
  constructor(limits: StorageLimits, diagnostics: Diagnostics, onGap?: GapReporter | undefined);
17
17
  /**
18
- * Persists a batch to localStorage, evicting oldest entries on quota errors.
18
+ * Writes a batch to localStorage. It removes the oldest entries on a quota error.
19
19
  * @param batch Batch to store.
20
20
  */
21
21
  save(batch: LogBatch): Promise<void>;
22
22
  /**
23
- * Retrieves up to limit batches in chronological order without deletion.
23
+ * Returns up to `limit` batches in FIFO order. It does not delete them.
24
24
  * @param limit Maximum number of batches to retrieve.
25
25
  * @returns Promise resolving to an array of valid batches.
26
26
  */
27
27
  take(limit: number): Promise<LogBatch[]>;
28
28
  /**
29
- * Deletes a batch from localStorage by batch ID.
29
+ * Deletes the batch with the given ID from localStorage.
30
30
  * @param id Batch identifier.
31
31
  */
32
32
  remove(id: string): Promise<void>;
33
33
  /**
34
- * Updates delivery attempt count for a stored batch without changing its key.
34
+ * Sets the delivery attempt count of a stored batch. It does not change the key.
35
35
  * @param id Batch identifier.
36
36
  * @param attempts New absolute attempt count.
37
37
  */
38
38
  bumpAttempts(id: string, attempts: number): Promise<void>;
39
39
  /**
40
- * Deletes expired batches and evicts oldest entries exceeding capacity limits.
40
+ * Deletes expired batches. It then removes the oldest batches above the
41
+ * capacity limit.
41
42
  * @returns Promise resolving to prune summary metrics.
42
43
  */
43
44
  prune(): Promise<PruneResult>;
44
45
  /**
45
- * Returns total count of stored batch keys without deserialization.
46
+ * Returns the number of stored batch keys. It does not deserialize the batches.
46
47
  * @returns Promise resolving to batch count.
47
48
  */
48
49
  count(): Promise<number>;
49
- /** Deletes all matching batch keys from localStorage. */
50
+ /** This method deletes all batch keys from localStorage. */
50
51
  clear(): Promise<void>;
51
- /** No-op storage teardown method. */
52
+ /** This method does nothing. localStorage has no connection to close. */
52
53
  close(): Promise<void>;
53
54
  /**
54
55
  * Writes a batch to localStorage.
55
56
  * @param batch Batch to store.
56
- * @param context Description reported if the write is refused.
57
+ * @param context Text that diagnostics reports when the write fails.
57
58
  * @returns True if the write succeeded.
58
59
  */
59
60
  private write;
60
- /** Drops the oldest quarter of the store to free quota, counting the loss. */
61
+ /** This method removes the oldest quarter of the store to free quota. It counts the loss. */
61
62
  private evictForQuota;
62
63
  /**
63
- * Reports dropped records to diagnostics and registered gap handlers.
64
+ * Reports dropped records to diagnostics and to the gap handler.
64
65
  * @param result Eviction metrics.
65
66
  */
66
67
  private reportGap;
67
68
  /**
68
- * Deserializes and validates a stored batch from a key.
69
+ * Reads and validates the stored batch at a key.
69
70
  * @param key Storage key to read.
70
71
  * @returns Validated LogBatch or null if missing or malformed.
71
72
  */
72
73
  private read;
73
74
  /**
74
- * Resolves storage key containing the specified batch ID suffix.
75
+ * Finds the storage key that ends with the batch ID.
75
76
  * @param id Batch identifier.
76
77
  * @returns Matching storage key string or null.
77
78
  */
78
79
  private keyOf;
79
80
  /**
80
- * Deletes an array of storage keys.
81
+ * Deletes a list of storage keys.
81
82
  * @param keys Keys to delete.
82
83
  */
83
84
  private evict;
84
85
  /**
85
- * Deletes a single storage key with error guarding.
86
+ * Deletes one storage key inside a guard.
86
87
  * @param key Storage key to remove.
87
88
  */
88
89
  private removeKey;
89
90
  /**
90
- * Returns all sorted batch storage keys matching prefix.
91
+ * Returns all batch storage keys in sorted order.
91
92
  * @returns Sorted array of storage keys.
92
93
  */
93
94
  private keys;
@@ -1,12 +1,12 @@
1
1
  import type { LogBatch } from "../models/batch";
2
2
  import type { GapReporter, PruneResult, StorageAdapter, StorageLimits } from "../models/storage";
3
- /** In-memory StorageAdapter implementation retaining batches in volatile memory. */
3
+ /** This StorageAdapter keeps batches in volatile memory. */
4
4
  export declare class MemoryStorage implements StorageAdapter {
5
5
  private readonly limits;
6
6
  private readonly onGap?;
7
- /** Storage adapter strategy name. */
7
+ /** This field holds the storage strategy name. */
8
8
  readonly name = "memory";
9
- /** Internal array holding batches in chronological FIFO order. */
9
+ /** This array holds the batches in FIFO order. */
10
10
  private batches;
11
11
  /**
12
12
  * @param limits Storage capacity and retention thresholds.
@@ -14,39 +14,40 @@ export declare class MemoryStorage implements StorageAdapter {
14
14
  */
15
15
  constructor(limits: StorageLimits, onGap?: GapReporter | undefined);
16
16
  /**
17
- * Appends a batch to memory storage and applies retention pruning.
17
+ * Appends a batch and applies retention pruning.
18
18
  * @param batch Batch to store.
19
19
  */
20
20
  save(batch: LogBatch): Promise<void>;
21
21
  /**
22
- * Retrieves up to limit batches in chronological order without deletion.
22
+ * Returns up to `limit` batches in FIFO order. It does not delete them.
23
23
  * @param limit Maximum number of batches to retrieve.
24
24
  * @returns Promise resolving to an array of batches.
25
25
  */
26
26
  take(limit: number): Promise<LogBatch[]>;
27
27
  /**
28
- * Deletes a batch from memory storage by batch ID.
28
+ * Deletes the batch with the given ID.
29
29
  * @param id Batch identifier.
30
30
  */
31
31
  remove(id: string): Promise<void>;
32
32
  /**
33
- * Updates delivery attempt count for a stored batch.
33
+ * Sets the delivery attempt count of a stored batch.
34
34
  * @param id Batch identifier.
35
35
  * @param attempts New absolute attempt count.
36
36
  */
37
37
  bumpAttempts(id: string, attempts: number): Promise<void>;
38
38
  /**
39
- * Removes expired batches and evicts oldest entries exceeding capacity limits.
39
+ * Removes expired batches. It then removes the oldest batches above the
40
+ * capacity limit.
40
41
  * @returns Promise resolving to prune summary metrics.
41
42
  */
42
43
  prune(): Promise<PruneResult>;
43
44
  /**
44
- * Returns total count of stored batches.
45
+ * Returns the number of stored batches.
45
46
  * @returns Promise resolving to batch count.
46
47
  */
47
48
  count(): Promise<number>;
48
- /** Clears all stored batches from memory. */
49
+ /** This method deletes all stored batches. */
49
50
  clear(): Promise<void>;
50
- /** Clears stored batches on storage teardown. */
51
+ /** This method deletes all stored batches when the storage closes. */
51
52
  close(): Promise<void>;
52
53
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Compresses a string into a gzip-encoded byte array using CompressionStream.
3
- * Returns non-shared ArrayBuffer backed Uint8Array compatible with fetch BodyInit.
2
+ * Compresses a string to gzip bytes with CompressionStream. The result is a
3
+ * Uint8Array on a non-shared ArrayBuffer. fetch accepts this result as BodyInit.
4
4
  * @param text Raw serialized payload to compress.
5
5
  * @returns Promise resolving to compressed Uint8Array, or null if CompressionStream is unsupported.
6
6
  */
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Failure classification determining retry, backoff, or drop behavior. transient,
3
- * offline and timeout retry with backoff. throttled waits the server's delay.
4
- * too_large splits the batch. permanent drops it: it will never be accepted.
2
+ * The failure kind sets the retry, backoff or drop behavior. The engine retries transient,
3
+ * offline and timeout failures with backoff. A throttled failure waits for the server delay.
4
+ * A too_large failure splits the batch. The engine drops a permanent failure. The server
5
+ * never accepts that batch.
5
6
  */
6
7
  export type TransportFailureKind = "transient" | "throttled" | "too_large" | "permanent" | "timeout" | "offline";
7
- /** Error representing a failed transport attempt with failure classification and metadata. */
8
+ /** This error records a failed transport attempt, its failure kind and its metadata. */
8
9
  export declare class TransportError extends Error {
9
10
  readonly kind: TransportFailureKind;
10
11
  readonly status?: number | undefined;
@@ -20,9 +21,9 @@ export declare class TransportError extends Error {
20
21
  constructor(kind: TransportFailureKind, message: string, status?: number | undefined, retryAfterMs?: number | undefined, maxBytes?: number | undefined);
21
22
  }
22
23
  /**
23
- * Parses HTTP Retry-After header value (seconds or HTTP date) into millisecond
24
- * delay. Both forms are legal. A date already past clamps to zero.
25
- * Clamps negative delays to zero.
24
+ * Parses an HTTP Retry-After value into a delay in milliseconds. The value
25
+ * can be a number of seconds or an HTTP date. The function clamps a negative delay to zero.
26
+ * A date in the past gives a negative delay.
26
27
  * @param header Raw Retry-After header string or null.
27
28
  * @returns Non-negative delay in milliseconds, or undefined if invalid or missing.
28
29
  */
@@ -1,70 +1,73 @@
1
1
  import type { Diagnostics } from "../core/diagnostics";
2
2
  import type { LogBatch } from "../models/batch";
3
3
  import type { ResolvedConfig } from "../models/config";
4
- /** Document lifecycle event or manual action that triggered an exit flush. */
4
+ /** This type names the lifecycle event or manual action that starts an exit flush. */
5
5
  export type ExitReason = "hidden" | "pagehide" | "freeze" | "openfin-close" | "shutdown";
6
- /** Injected dependencies required by ExitFlush. */
6
+ /** This interface lists the dependencies of ExitFlush. */
7
7
  export interface ExitFlushDeps {
8
- /** Active configuration instance. */
8
+ /** This field holds the active configuration. */
9
9
  config: ResolvedConfig;
10
- /** Diagnostics reporter instance. */
10
+ /** This field holds the diagnostics reporter. */
11
11
  diagnostics: Diagnostics;
12
- /** Callback draining all pending buffered and unconfirmed batches into a single LogBatch. */
12
+ /** This callback drains all buffered and unconfirmed batches into one LogBatch. */
13
13
  drainForExit: () => LogBatch | null;
14
- /** Callback draining the buffered records only. An in-flight batch stays where it is. */
14
+ /** This callback drains only the buffered records. It does not touch an in-flight batch. */
15
15
  drainPending: () => LogBatch | null;
16
16
  }
17
- /** Flushes pending telemetry on document unload using sendBeacon, keepalive fetch, or emergency storage. */
17
+ /**
18
+ * This class flushes pending telemetry on document unload. It uses sendBeacon, a keepalive
19
+ * fetch or emergency storage.
20
+ */
18
21
  export declare class ExitFlush {
19
22
  private readonly deps;
20
- /** Indicates whether unload listeners are currently active. */
23
+ /** This flag is true while the unload listeners are attached. */
21
24
  private installed;
22
- /** Handles visibilitychange events when the document becomes hidden. */
25
+ /** This listener flushes on visibilitychange when the document becomes hidden. */
23
26
  private readonly onVisibility;
24
- /** Handles window pagehide events. */
27
+ /** This listener flushes on the window pagehide event. */
25
28
  private readonly onPageHide;
26
- /** Handles document freeze events. */
29
+ /** This listener flushes on the document freeze event. */
27
30
  private readonly onFreeze;
28
- /** Handles OpenFin close-requested events. */
31
+ /** This listener flushes on the OpenFin close-requested event. */
29
32
  private readonly onOpenFinClose;
30
33
  /**
31
34
  * @param deps Injected configuration, diagnostics, and drain callback.
32
35
  */
33
36
  constructor(deps: ExitFlushDeps);
34
- /** Attaches unload listeners across document, window, and OpenFin environments. */
37
+ /** This method attaches the unload listeners to the document, the window and OpenFin. */
35
38
  install(): void;
36
- /** Removes all registered unload listeners and subscriptions. */
39
+ /** This method removes all unload listeners and subscriptions. */
37
40
  uninstall(): void;
38
41
  /**
39
- * Synchronously drains pending records and transmits via beacon, keepalive, or
40
- * emergency storage. Never awaits and never throws. The caller is an unload
41
- * listener.
42
+ * Drains pending records synchronously. It sends them with a beacon, a
43
+ * keepalive fetch or emergency storage. It never awaits and never throws. The caller is an
44
+ * unload listener.
42
45
  * @param reason Trigger reason code.
43
46
  */
44
47
  flush(reason: ExitReason): void;
45
48
  /**
46
- * Selects the drain for the reason. `hidden` occurs at each tab switch, and the
47
- * document continues to run. Taken here, an in-flight batch goes out a second
48
- * time under a new id, which the server cannot deduplicate.
49
+ * Selects the drain for the reason. `hidden` occurs at each tab switch. The
50
+ * document continues to run after it. A drain of the in-flight batch here sends it again
51
+ * with a new id. The server cannot deduplicate that second send.
49
52
  * @param reason Trigger reason code.
50
53
  * @returns Combined LogBatch, or null if no records are pending.
51
54
  */
52
55
  private drain;
53
56
  /**
54
- * Resolves and parses the destination endpoint URL.
57
+ * Parses the configured endpoint URL.
55
58
  * @returns URL instance or null if missing or invalid.
56
59
  */
57
60
  private endpointUrl;
58
61
  /**
59
- * Attempts transmission via navigator.sendBeacon with text/plain payload.
62
+ * Sends the payload as text/plain with navigator.sendBeacon.
60
63
  * @param url Target endpoint URL with query parameters.
61
64
  * @param body Serialized payload string.
62
65
  * @returns The answer of the browser.
63
66
  */
64
67
  private beacon;
65
68
  /**
66
- * Fallback POST delivery using fetch with keepalive: true. keepalive outlives the
67
- * document. A plain fetch is cancelled as the page goes.
69
+ * Sends a fallback POST with fetch and `keepalive: true`. A keepalive request
70
+ * continues after the document closes. The browser cancels a plain fetch at page close.
68
71
  * @param url Target endpoint URL.
69
72
  * @param body Serialized payload string.
70
73
  * @param reason Trigger reason code.
@@ -1,11 +1,14 @@
1
1
  import type { Diagnostics } from "../core/diagnostics";
2
2
  import type { LogBatch } from "../models/batch";
3
3
  import type { ResolvedConfig } from "../models/config";
4
- /** HTTP transport delivering serialized log batches with header resolution, gzip compression, and error classification. */
4
+ /**
5
+ * This class sends serialized log batches over HTTP. It resolves headers, applies gzip
6
+ * compression and classifies errors.
7
+ */
5
8
  export declare class HttpTransport {
6
9
  private readonly config;
7
10
  private readonly diagnostics;
8
- /** Timestamp in epoch milliseconds until which requests are throttled. */
11
+ /** This field holds the epoch time in milliseconds when the server throttle ends. */
9
12
  private throttledUntil;
10
13
  /**
11
14
  * @param config Active configuration instance.
@@ -13,30 +16,34 @@ export declare class HttpTransport {
13
16
  */
14
17
  constructor(config: ResolvedConfig, diagnostics: Diagnostics);
15
18
  /**
16
- * Delivers a single log batch over HTTP.
19
+ * Sends one log batch over HTTP.
17
20
  * @param batch Batch to send.
18
21
  * @throws TransportError on transient, throttled, 413, or permanent network failures.
19
22
  */
20
23
  send(batch: LogBatch): Promise<void>;
21
24
  /**
22
- * Returns the remaining throttle backoff duration in milliseconds.
25
+ * Returns the remaining throttle delay in milliseconds.
23
26
  * @returns Milliseconds remaining in throttle window, or 0 if unthrottled.
24
27
  */
25
28
  throttledForMs(): number;
26
29
  /**
27
- * Serializes, encodes, and dispatches a batch, throwing a classified TransportError on failure.
30
+ * Serializes, encodes and sends a batch. It throws a classified TransportError
31
+ * on failure.
28
32
  * @param batch Batch to deliver.
29
- * @param endpoint Ingest URL. The caller reads it one time. A reconfigure during the send cannot change it.
33
+ * @param endpoint Ingest URL. The caller reads it one time. A reconfigure during the send
34
+ * cannot change it.
30
35
  */
31
36
  private post;
32
37
  /**
33
- * Compresses the serialized payload if gzip compression is enabled and size exceeds threshold.
38
+ * Compresses the serialized payload when gzip is enabled. The payload size must
39
+ * be at or above the threshold.
34
40
  * @param text Serialized payload string.
35
41
  * @returns Promise resolving to original string or compressed byte array.
36
42
  */
37
43
  private encodeBody;
38
44
  /**
39
- * Executes the HTTP POST request with timeout and network error mapping.
45
+ * Sends the HTTP POST request with a timeout. It maps network errors to
46
+ * TransportError.
40
47
  * @param endpoint Ingest URL.
41
48
  * @param headers HTTP request headers.
42
49
  * @param body Request body string or byte array.
@@ -45,20 +52,20 @@ export declare class HttpTransport {
45
52
  */
46
53
  private dispatch;
47
54
  /**
48
- * Classifies an HTTP error response into a structured TransportError.
55
+ * Converts an HTTP error response into a classified TransportError.
49
56
  * @param response Unsuccessful HTTP response.
50
57
  * @param batchId Identifier of the rejected batch.
51
58
  * @returns Classified TransportError instance.
52
59
  */
53
60
  private classify;
54
61
  /**
55
- * Extracts optional maxBytes payload limit from a 413 response body.
62
+ * Reads the optional maxBytes limit from a 413 response body.
56
63
  * @param response HTTP 413 Response instance.
57
64
  * @returns Promise resolving to maximum byte limit or undefined.
58
65
  */
59
66
  private readMaxBytes;
60
67
  /**
61
- * Evaluates configured static or dynamic request headers.
68
+ * Resolves the configured static or dynamic request headers.
62
69
  * @returns Promise resolving to resolved header map.
63
70
  */
64
71
  private resolveHeaders;
@@ -3,22 +3,25 @@ import { type LogBatch } from "../models/batch";
3
3
  import type { ResolvedConfig } from "../models/config";
4
4
  import type { StorageAdapter } from "../models/storage";
5
5
  import type { HttpTransport } from "./http-transport";
6
- /** Manages timed redelivery of persisted offline batches with backoff, lock coordination, and batch splitting. */
6
+ /**
7
+ * This class sends persisted offline batches again on a timer. It uses backoff, a cross-tab
8
+ * drain lock and batch splitting.
9
+ */
7
10
  export declare class RetryEngine {
8
11
  private readonly storage;
9
12
  private readonly transport;
10
13
  private readonly diagnostics;
11
14
  private readonly config;
12
15
  private readonly batchesPerDrain;
13
- /** Active retry timer handle or null if unreserved. */
16
+ /** This field holds the active retry timer handle. It is null when no timer is armed. */
14
17
  private timer;
15
- /** Consecutive failed delivery attempts for exponential backoff calculation. */
18
+ /** This field counts consecutive failed deliveries. The backoff calculation uses it. */
16
19
  private attempt;
17
- /** Indicates whether a storage drain operation is actively executing. */
20
+ /** This flag is true while a storage drain runs. */
18
21
  private draining;
19
- /** Indicates whether the engine is stopped. */
22
+ /** This flag is true when the engine is stopped. */
20
23
  private stopped;
21
- /** Online event listener resetting attempts and scheduling immediate drain. */
24
+ /** This listener runs on the online event. It resets the attempt count and starts a drain. */
22
25
  private readonly onOnline;
23
26
  /**
24
27
  * @param storage Storage adapter holding undelivered batches.
@@ -28,67 +31,69 @@ export declare class RetryEngine {
28
31
  * @param batchesPerDrain Maximum batches processed per drain tick.
29
32
  */
30
33
  constructor(storage: StorageAdapter, transport: HttpTransport, diagnostics: Diagnostics, config: ResolvedConfig, batchesPerDrain?: number);
31
- /** Starts the retry engine, listens for online events, and arms the initial timer. */
34
+ /** This method starts the engine. It listens for online events and arms the first timer. */
32
35
  start(): void;
33
- /** Triggers an accelerated retry schedule when a new batch is stored offline. */
36
+ /** This method schedules an earlier retry when storage receives a new offline batch. */
34
37
  nudge(): void;
35
38
  /**
36
- * Persists a batch that failed outside the drain loop, under the same rules the
37
- * drain applies. Storing it whole would spend another request on a payload the
38
- * server already refused.
39
+ * Stores a batch that failed outside the drain loop. It applies the same rules
40
+ * as the drain. It does not store a refused batch whole. A whole batch causes another request
41
+ * with a payload that the server refused.
39
42
  * @param batch Rejected batch, with its attempt already counted.
40
43
  * @param error Failure thrown by the transport.
41
44
  */
42
45
  storeFailed(batch: LogBatch, error: unknown): Promise<void>;
43
- /** Halts retry execution, removes listeners, and clears pending timers. */
46
+ /** This method stops the engine. It removes the listener and clears the pending timer. */
44
47
  stop(): void;
45
48
  /**
46
- * Clears existing timers and schedules a new drain execution after a delay.
49
+ * Clears the pending timer. It then schedules a drain after the delay.
47
50
  * @param delayMs Delay duration in milliseconds.
48
51
  */
49
52
  private schedule;
50
53
  /**
51
- * Bounds a storage call. A call that does not settle keeps `draining` set, and
52
- * this window then runs no more drains.
54
+ * Sets a deadline on a storage call. A call that does not settle keeps
55
+ * `draining` true. This window then runs no more drains.
53
56
  * @param work Storage promise to bound.
54
57
  * @returns The value of the promise, or a rejection after the deadline.
55
58
  */
56
59
  private bounded;
57
- /** Clears the pending timer handle if active. */
60
+ /** This method clears the pending timer when a timer is active. */
58
61
  private clearTimer;
59
62
  /**
60
- * Computes jittered exponential backoff delay based on consecutive failures. Full
61
- * jitter, not a fixed offset. Tabs reconnecting together stampede otherwise.
63
+ * Calculates the exponential backoff delay from consecutive failures. It applies
64
+ * full jitter, not a fixed offset. With a fixed offset, tabs that reconnect together send
65
+ * their requests at the same time.
62
66
  * @returns Backoff duration in milliseconds.
63
67
  */
64
68
  private backoffMs;
65
- /** Executes a drain operation protected by the origin-wide Web Lock. */
69
+ /** This method runs a drain under the origin-wide Web Lock. */
66
70
  private drain;
67
71
  /**
68
- * Processes batches while holding the Web Lock and schedules subsequent ticks.
69
- * Always resolves. A throw leaves the engine idle with no timer armed.
72
+ * Processes batches while it holds the Web Lock. It schedules the next tick.
73
+ * It always resolves. A throw leaves the engine idle with no armed timer.
70
74
  * @returns Promise resolving to true on completion.
71
75
  */
72
76
  private drainLocked;
73
77
  /**
74
- * Attempts delivery of a single batch, removing it on success or handling errors.
78
+ * Tries to deliver one batch. It removes the batch on success. It handles each
79
+ * failure kind on failure.
75
80
  * @param batch Log batch to deliver.
76
- * @returns True to continue processing next batch; false to halt current drain.
81
+ * @returns True to continue with the next batch. False to stop the current drain.
77
82
  */
78
83
  private deliver;
79
84
  /**
80
- * Replaces a stored batch with what survives its failure: the split halves, or
81
- * nothing when the server refuses the records for good.
85
+ * Replaces a stored batch with the parts that survive its failure. The parts
86
+ * are the split halves, or nothing after a permanent refusal.
82
87
  * @param batch Rejected log batch, already held in storage.
83
88
  * @param error Failure thrown by the transport.
84
89
  */
85
90
  private replaceStored;
86
91
  /**
87
- * Decides what a failed batch leaves behind. A 413 splits in two, a permanent
88
- * refusal keeps nothing, and every other failure keeps the batch whole.
92
+ * Selects the batches to keep after a failure. A 413 response splits the batch
93
+ * in two. A permanent refusal keeps nothing. Each other failure keeps the batch whole.
89
94
  * @param batch Rejected log batch.
90
95
  * @param error Failure thrown by the transport.
91
- * @returns Batches to persist, empty when the records are dropped.
96
+ * @returns Batches to persist. The array is empty when the engine drops the records.
92
97
  */
93
98
  private toStorable;
94
99
  }
@@ -1,3 +1,3 @@
1
1
  import type { LogSerializer } from "../../models/serializer";
2
- /** Serializer formatting log records into Elastic Common Schema (ECS) NDJSON documents. */
2
+ /** This serializer writes log records as Elastic Common Schema (ECS) NDJSON documents. */
3
3
  export declare const ecsSerializer: LogSerializer;
@@ -1,3 +1,3 @@
1
1
  import type { LogSerializer } from "../../models/serializer";
2
- /** Serializer formatting log records into OTLP/JSON payloads. */
2
+ /** This serializer writes log records as OTLP/JSON payloads. */
3
3
  export declare const otlpSerializer: LogSerializer;
@@ -1 +1 @@
1
- {"version":3,"file":"unref-16maCyKA.js","names":["unrefTimer","timer"],"sources":["../src/utils/unref.ts"],"sourcesContent":["// src/utils/unref.ts\n//\n// Utility for safely unreferencing timer handles across Node and browser\n// environments. A pending timer keeps a Node process alive under SSR and in\n// tests.\n\n/** Cross-platform timer handle representing browser numeric IDs or Node Timeout objects. */\nexport type TimerHandle = number | { unref?: () => void };\n\n/**\n * Unreferences a timer handle to prevent it from keeping a Node.js process alive.\n * @param timer Timer handle returned by setTimeout.\n */\nexport function unrefTimer(timer: TimerHandle): void {\n if (typeof timer !== \"number\") {\n timer.unref?.();\n }\n}\n"],"mappings":";AAaA,SAAgBA,EAAW,GAA0B;CACnD,AAAI,OAAOC,KAAU,YACnBA,EAAM,QAAQ;AAElB"}
1
+ {"version":3,"file":"unref-16maCyKA.js","names":["unrefTimer","timer"],"sources":["../src/utils/unref.ts"],"sourcesContent":["// src/utils/unref.ts\n//\n// Unreferences timer handles in Node and browser environments. A pending timer\n// keeps a Node process alive under SSR and in tests.\n\n/** Cross-platform timer handle representing browser numeric IDs or Node Timeout objects. */\nexport type TimerHandle = number | { unref?: () => void };\n\n/**\n * Unreferences a timer handle to prevent it from keeping a Node.js process alive.\n * @param timer Timer handle returned by setTimeout.\n */\nexport function unrefTimer(timer: TimerHandle): void {\n if (typeof timer !== \"number\") {\n timer.unref?.();\n }\n}\n"],"mappings":";AAYA,SAAgBA,EAAW,GAA0B;CACnD,AAAI,OAAOC,KAAU,YACnBA,EAAM,QAAQ;AAElB"}
@@ -1 +1 @@
1
- {"version":3,"file":"unref-CU9Nyz_9.cjs","names":["unrefTimer","timer"],"sources":["../src/utils/unref.ts"],"sourcesContent":["// src/utils/unref.ts\n//\n// Utility for safely unreferencing timer handles across Node and browser\n// environments. A pending timer keeps a Node process alive under SSR and in\n// tests.\n\n/** Cross-platform timer handle representing browser numeric IDs or Node Timeout objects. */\nexport type TimerHandle = number | { unref?: () => void };\n\n/**\n * Unreferences a timer handle to prevent it from keeping a Node.js process alive.\n * @param timer Timer handle returned by setTimeout.\n */\nexport function unrefTimer(timer: TimerHandle): void {\n if (typeof timer !== \"number\") {\n timer.unref?.();\n }\n}\n"],"mappings":"AAaA,SAAgBA,EAAW,EAA0B,CAC/C,OAAOC,GAAU,UACnBA,EAAM,QAAQ,CAElB"}
1
+ {"version":3,"file":"unref-CU9Nyz_9.cjs","names":["unrefTimer","timer"],"sources":["../src/utils/unref.ts"],"sourcesContent":["// src/utils/unref.ts\n//\n// Unreferences timer handles in Node and browser environments. A pending timer\n// keeps a Node process alive under SSR and in tests.\n\n/** Cross-platform timer handle representing browser numeric IDs or Node Timeout objects. */\nexport type TimerHandle = number | { unref?: () => void };\n\n/**\n * Unreferences a timer handle to prevent it from keeping a Node.js process alive.\n * @param timer Timer handle returned by setTimeout.\n */\nexport function unrefTimer(timer: TimerHandle): void {\n if (typeof timer !== \"number\") {\n timer.unref?.();\n }\n}\n"],"mappings":"AAYA,SAAgBA,EAAW,EAA0B,CAC/C,OAAOC,GAAU,UACnBA,EAAM,QAAQ,CAElB"}
@@ -44,16 +44,17 @@ export declare const BROWSER_STORES: IdentityStores;
44
44
  export declare function memoryStores(): IdentityStores;
45
45
  /**
46
46
  * Generates a random lowercase hexadecimal string of the specified byte length.
47
- * Uses crypto.getRandomValues when available, falling back to Math.random.
47
+ * It uses crypto.getRandomValues when it is available. Otherwise it uses Math.random.
48
48
  * @param byteLength Number of random bytes to generate.
49
49
  * @returns Hexadecimal string of length byteLength * 2.
50
50
  */
51
51
  export declare function randomHex(byteLength: number): string;
52
52
  /**
53
53
  * Generates a unique identifier string using crypto.randomUUID or randomHex fallback.
54
+ * @param diagnostics Diagnostics reporter. It counts a blocked crypto.randomUUID call.
54
55
  * @returns UUID or random hex identifier.
55
56
  */
56
- export declare function newId(): string;
57
+ export declare function newId(diagnostics: Diagnostics): string;
57
58
  /**
58
59
  * Resolves or initializes session, tab, and context identifiers for the active realm.
59
60
  * @param diagnostics Diagnostics reporter.
@@ -69,9 +70,9 @@ export declare function resolveIdentity(diagnostics: Diagnostics, stores?: Ident
69
70
  */
70
71
  export declare function persistTabId(tabId: string, diagnostics: Diagnostics, stores: IdentityStores): void;
71
72
  /**
72
- * Writes the session's last-seen timestamp, throttled by `SESSION_TOUCH_MS`.
73
- * The throttle is instance state, not module state: two runtimes in one document
74
- * must not silence each other's session writes.
73
+ * Writes the last-seen timestamp of the session. `SESSION_TOUCH_MS` sets the throttle.
74
+ * The instance keeps the throttle state, not the module. Two runtimes in one document
75
+ * must not block the session writes of each other.
75
76
  */
76
77
  export declare class SessionTouch {
77
78
  private diagnostics;
@@ -1,14 +1,14 @@
1
1
  import type { Diagnostics } from "../core/diagnostics";
2
2
  /**
3
3
  * Executes an asynchronous function under a Web Locks API origin-wide lock.
4
- * Falls back to direct execution in environments without Web Locks support.
4
+ * It runs the task directly when the Web Locks API is not available.
5
5
  * @param name Origin-scoped lock identifier.
6
6
  * @param diagnostics Diagnostics reporter.
7
7
  * @param fn Asynchronous task to execute while holding the lock.
8
8
  * @param options Lock acquisition options.
9
- * @param options.skipIfBusy Skips execution if lock is currently held by another context.
10
- * @returns Promise resolving to the task result, or undefined if the lock was held
11
- * and nothing ran. A caller that conflates the two stops rescheduling.
9
+ * @param options.skipIfBusy When true, the task does not run if another context holds the lock.
10
+ * @returns Promise of the task result. It resolves to undefined when another context holds the
11
+ * lock. A caller that reads undefined as a task result stops rescheduling.
12
12
  */
13
13
  export declare function withDrainLock<T>(name: string, diagnostics: Diagnostics, fn: () => Promise<T>, { skipIfBusy }?: {
14
14
  skipIfBusy?: boolean;