@utk09/ui-observability 0.8.0 → 0.9.1

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 (191) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +75 -48
  3. package/dist/batch-DEK4bv9N.js +31 -0
  4. package/dist/batch-DEK4bv9N.js.map +1 -0
  5. package/dist/batch-DEVFs28i.cjs +2 -0
  6. package/dist/batch-DEVFs28i.cjs.map +1 -0
  7. package/dist/bus/bus.d.ts +46 -12
  8. package/dist/bus/links.d.ts +6 -3
  9. package/dist/bus-DNFvTkif.cjs +2 -0
  10. package/dist/bus-DNFvTkif.cjs.map +1 -0
  11. package/dist/{bus-DPDrlUBY.js → bus-HVQ8E72V.js} +128 -71
  12. package/dist/bus-HVQ8E72V.js.map +1 -0
  13. package/dist/capture/interactions.d.ts +7 -6
  14. package/dist/capture/network.d.ts +23 -9
  15. package/dist/capture/types.d.ts +3 -3
  16. package/dist/console-C9Y639mn.js +82 -0
  17. package/dist/console-C9Y639mn.js.map +1 -0
  18. package/dist/console-DssDxq1B.cjs +2 -0
  19. package/dist/console-DssDxq1B.cjs.map +1 -0
  20. package/dist/constants-N99w84xy.js +117 -0
  21. package/dist/constants-N99w84xy.js.map +1 -0
  22. package/dist/constants-X86IDwkC.cjs +2 -0
  23. package/dist/constants-X86IDwkC.cjs.map +1 -0
  24. package/dist/constants.d.ts +36 -18
  25. package/dist/core/diagnostics.d.ts +2 -2
  26. package/dist/core/drops.d.ts +29 -0
  27. package/dist/core/hold-buffer.d.ts +27 -0
  28. package/dist/core/journey.d.ts +16 -4
  29. package/dist/core/logger.d.ts +6 -2
  30. package/dist/core/pipeline.d.ts +20 -16
  31. package/dist/core/record.d.ts +11 -6
  32. package/dist/core/remote-sampling.d.ts +1 -1
  33. package/dist/core/runtime.d.ts +87 -23
  34. package/dist/core/sender.d.ts +19 -11
  35. package/dist/deadline-5_PecIl5.js +26 -0
  36. package/dist/deadline-5_PecIl5.js.map +1 -0
  37. package/dist/deadline-XSnm95pg.cjs +2 -0
  38. package/dist/deadline-XSnm95pg.cjs.map +1 -0
  39. package/dist/error-like-Ywo5uRHo.js +19 -0
  40. package/dist/error-like-Ywo5uRHo.js.map +1 -0
  41. package/dist/error-like-gGRx2s36.cjs +2 -0
  42. package/dist/error-like-gGRx2s36.cjs.map +1 -0
  43. package/dist/errors-BTWuVnHZ.cjs +3 -0
  44. package/dist/errors-BTWuVnHZ.cjs.map +1 -0
  45. package/dist/{errors-Dnc-X4Ec.js → errors-CQusIGWJ.js} +39 -20
  46. package/dist/errors-CQusIGWJ.js.map +1 -0
  47. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  48. package/dist/global-scope-dp2jADRl.js.map +1 -1
  49. package/dist/identity-B1GDS1Tb.cjs +2 -0
  50. package/dist/identity-B1GDS1Tb.cjs.map +1 -0
  51. package/dist/identity-D4DPjTM9.js +88 -0
  52. package/dist/identity-D4DPjTM9.js.map +1 -0
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.d.ts +12 -4
  56. package/dist/index.js +720 -446
  57. package/dist/index.js.map +1 -1
  58. package/dist/{indexeddb-storage-uD4oaRMc.js → indexeddb-storage-B8SGUzSV.js} +88 -59
  59. package/dist/indexeddb-storage-B8SGUzSV.js.map +1 -0
  60. package/dist/indexeddb-storage-ukzC82dm.cjs +2 -0
  61. package/dist/indexeddb-storage-ukzC82dm.cjs.map +1 -0
  62. package/dist/interactions-CcxrVzpg.cjs +2 -0
  63. package/dist/interactions-CcxrVzpg.cjs.map +1 -0
  64. package/dist/{interactions-igKTAJvj.js → interactions-CnjfQgw3.js} +22 -19
  65. package/dist/interactions-CnjfQgw3.js.map +1 -0
  66. package/dist/journey-DjvDzHyp.js +163 -0
  67. package/dist/journey-DjvDzHyp.js.map +1 -0
  68. package/dist/journey-DxlfdFJV.cjs +2 -0
  69. package/dist/journey-DxlfdFJV.cjs.map +1 -0
  70. package/dist/{library-request-Br_T09Bn.cjs → library-request-BZ1ekVtl.cjs} +2 -2
  71. package/dist/{library-request-Br_T09Bn.cjs.map → library-request-BZ1ekVtl.cjs.map} +1 -1
  72. package/dist/{library-request-Dt0fXhcn.js → library-request-C8kc5YWv.js} +2 -2
  73. package/dist/{library-request-Dt0fXhcn.js.map → library-request-C8kc5YWv.js.map} +1 -1
  74. package/dist/{long-frames-DahhqM6u.cjs → long-frames-BGik_Yhy.cjs} +2 -2
  75. package/dist/{long-frames-DahhqM6u.cjs.map → long-frames-BGik_Yhy.cjs.map} +1 -1
  76. package/dist/{long-frames-6pnjWSSR.js → long-frames-CZk3XOkH.js} +3 -3
  77. package/dist/{long-frames-6pnjWSSR.js.map → long-frames-CZk3XOkH.js.map} +1 -1
  78. package/dist/models/batch.d.ts +15 -1
  79. package/dist/models/bus.d.ts +7 -4
  80. package/dist/models/config.d.ts +189 -12
  81. package/dist/models/drop.d.ts +39 -0
  82. package/dist/models/log-record.d.ts +12 -6
  83. package/dist/models/storage.d.ts +15 -3
  84. package/dist/network-51iicpLl.js +174 -0
  85. package/dist/network-51iicpLl.js.map +1 -0
  86. package/dist/network-jBbjyAJP.cjs +2 -0
  87. package/dist/network-jBbjyAJP.cjs.map +1 -0
  88. package/dist/patch-BX8KrPCT.cjs +2 -0
  89. package/dist/patch-BX8KrPCT.cjs.map +1 -0
  90. package/dist/patch-CCWfuEY7.js +9 -0
  91. package/dist/patch-CCWfuEY7.js.map +1 -0
  92. package/dist/platform-Cjts-8k8.js +48 -0
  93. package/dist/platform-Cjts-8k8.js.map +1 -0
  94. package/dist/{platform-D_XkVIF6.cjs → platform-DW3GFIUE.cjs} +2 -2
  95. package/dist/platform-DW3GFIUE.cjs.map +1 -0
  96. package/dist/{remote-rules-rJJZKVG8.cjs → remote-rules-ByS34k4e.cjs} +2 -2
  97. package/dist/remote-rules-ByS34k4e.cjs.map +1 -0
  98. package/dist/{remote-rules-5UA23alm.js → remote-rules-M-XZ1xbe.js} +14 -14
  99. package/dist/remote-rules-M-XZ1xbe.js.map +1 -0
  100. package/dist/sampling-BN3Oi6SV.js +63 -0
  101. package/dist/sampling-BN3Oi6SV.js.map +1 -0
  102. package/dist/sampling-b2ck5X98.cjs +2 -0
  103. package/dist/sampling-b2ck5X98.cjs.map +1 -0
  104. package/dist/sanitize-DKp5MRsa.cjs +2 -0
  105. package/dist/sanitize-DKp5MRsa.cjs.map +1 -0
  106. package/dist/sanitize-Dwj9JCkI.js +123 -0
  107. package/dist/sanitize-Dwj9JCkI.js.map +1 -0
  108. package/dist/{sender-G6v4Uqi4.js → sender-BBY0IcUo.js} +439 -322
  109. package/dist/sender-BBY0IcUo.js.map +1 -0
  110. package/dist/sender-BXoAZKum.cjs +3 -0
  111. package/dist/sender-BXoAZKum.cjs.map +1 -0
  112. package/dist/storage/emergency-queue.d.ts +5 -2
  113. package/dist/storage/eviction.d.ts +40 -0
  114. package/dist/storage/factory.d.ts +1 -1
  115. package/dist/storage/idb-driver.d.ts +7 -1
  116. package/dist/storage/indexeddb-storage.d.ts +13 -5
  117. package/dist/storage/local-storage.d.ts +27 -4
  118. package/dist/storage/memory-storage.d.ts +10 -3
  119. package/dist/{storm-BtzgLOCX.cjs → storm-CKuaBp7i.cjs} +2 -2
  120. package/dist/{storm-BtzgLOCX.cjs.map → storm-CKuaBp7i.cjs.map} +1 -1
  121. package/dist/{storm-DJkEZP_8.js → storm-DhtL2eVr.js} +2 -2
  122. package/dist/{storm-DJkEZP_8.js.map → storm-DhtL2eVr.js.map} +1 -1
  123. package/dist/transport/compression.d.ts +1 -1
  124. package/dist/transport/exit-flush.d.ts +27 -17
  125. package/dist/transport/http-transport.d.ts +61 -7
  126. package/dist/transport/retry-engine.d.ts +12 -8
  127. package/dist/transport/status-transport.d.ts +8 -3
  128. package/dist/utils/console.d.ts +5 -2
  129. package/dist/utils/error-like.d.ts +25 -0
  130. package/dist/utils/global-scope.d.ts +1 -1
  131. package/dist/utils/identity.d.ts +1 -1
  132. package/dist/utils/library-console.d.ts +1 -1
  133. package/dist/utils/library-request.d.ts +1 -1
  134. package/dist/utils/patch.d.ts +9 -0
  135. package/dist/utils/platform.d.ts +3 -3
  136. package/dist/utils/sequence.d.ts +0 -5
  137. package/dist/utils/timer.d.ts +1 -1
  138. package/dist/utils/tracing.d.ts +3 -3
  139. package/dist/utils/unref.d.ts +2 -2
  140. package/dist/{web-vitals-DHZ0yA_H.js → web-vitals-Bflr5jSA.js} +4 -2
  141. package/dist/web-vitals-Bflr5jSA.js.map +1 -0
  142. package/dist/web-vitals-DFuoTQbZ.cjs +2 -0
  143. package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -0
  144. package/package.json +2 -2
  145. package/dist/bus-CUXRY0JR.cjs +0 -2
  146. package/dist/bus-CUXRY0JR.cjs.map +0 -1
  147. package/dist/bus-DPDrlUBY.js.map +0 -1
  148. package/dist/console-CNljJict.js +0 -81
  149. package/dist/console-CNljJict.js.map +0 -1
  150. package/dist/console-PKzc-FmR.cjs +0 -2
  151. package/dist/console-PKzc-FmR.cjs.map +0 -1
  152. package/dist/constants-B28fDv2F.cjs +0 -2
  153. package/dist/constants-B28fDv2F.cjs.map +0 -1
  154. package/dist/constants-Bu49bm39.js +0 -93
  155. package/dist/constants-Bu49bm39.js.map +0 -1
  156. package/dist/errors-C78ZTjet.cjs +0 -3
  157. package/dist/errors-C78ZTjet.cjs.map +0 -1
  158. package/dist/errors-Dnc-X4Ec.js.map +0 -1
  159. package/dist/indexeddb-storage-D0p3iMD0.cjs +0 -2
  160. package/dist/indexeddb-storage-D0p3iMD0.cjs.map +0 -1
  161. package/dist/indexeddb-storage-uD4oaRMc.js.map +0 -1
  162. package/dist/interactions-CsE2y_fQ.cjs +0 -2
  163. package/dist/interactions-CsE2y_fQ.cjs.map +0 -1
  164. package/dist/interactions-igKTAJvj.js.map +0 -1
  165. package/dist/network-CZ0aFUsy.cjs +0 -2
  166. package/dist/network-CZ0aFUsy.cjs.map +0 -1
  167. package/dist/network-aSNbwpue.js +0 -112
  168. package/dist/network-aSNbwpue.js.map +0 -1
  169. package/dist/platform-BwbMRwHm.js +0 -48
  170. package/dist/platform-BwbMRwHm.js.map +0 -1
  171. package/dist/platform-D_XkVIF6.cjs.map +0 -1
  172. package/dist/remote-rules-5UA23alm.js.map +0 -1
  173. package/dist/remote-rules-rJJZKVG8.cjs.map +0 -1
  174. package/dist/sampling-E4x92Nn2.cjs +0 -2
  175. package/dist/sampling-E4x92Nn2.cjs.map +0 -1
  176. package/dist/sampling-J1eahbfT.js +0 -160
  177. package/dist/sampling-J1eahbfT.js.map +0 -1
  178. package/dist/sanitize-BMhh8ghJ.cjs +0 -2
  179. package/dist/sanitize-BMhh8ghJ.cjs.map +0 -1
  180. package/dist/sanitize-UJ-4Lb0n.js +0 -114
  181. package/dist/sanitize-UJ-4Lb0n.js.map +0 -1
  182. package/dist/sender-B6ufz26f.cjs +0 -3
  183. package/dist/sender-B6ufz26f.cjs.map +0 -1
  184. package/dist/sender-G6v4Uqi4.js.map +0 -1
  185. package/dist/unref-16maCyKA.js +0 -8
  186. package/dist/unref-16maCyKA.js.map +0 -1
  187. package/dist/unref-CU9Nyz_9.cjs +0 -2
  188. package/dist/unref-CU9Nyz_9.cjs.map +0 -1
  189. package/dist/web-vitals-B2FYsEAU.cjs +0 -2
  190. package/dist/web-vitals-B2FYsEAU.cjs.map +0 -1
  191. package/dist/web-vitals-DHZ0yA_H.js.map +0 -1
@@ -14,6 +14,17 @@ import { JourneyEngine } from "./journey";
14
14
  import { RecordBuilder } from "./record";
15
15
  /** Manages subsystem lifecycles, bus coordination and record delivery. */
16
16
  export declare class ObservabilityRuntime {
17
+ private readonly degraded;
18
+ /**
19
+ * Runtime of this copy of the library when another version owns the page runtime.
20
+ * It stays off the global key.
21
+ */
22
+ private static local;
23
+ /**
24
+ * Library version of this runtime. Another copy reads it from the global key.
25
+ * Two versions with one runtime call methods that the other version does not have.
26
+ */
27
+ readonly sdkVersion: string;
17
28
  /** Diagnostics reporter for internal faults. */
18
29
  readonly diagnostics: Diagnostics;
19
30
  /** Active configuration instance. A reconfigure changes it in place. */
@@ -44,6 +55,8 @@ export declare class ObservabilityRuntime {
44
55
  private readonly remote;
45
56
  /** Console sink for local developer output. */
46
57
  readonly console: ConsoleSink;
58
+ /** Collects lost records into onDrop summaries. */
59
+ private readonly drops;
47
60
  /**
48
61
  * Cross-realm communication bus. It is null until its chunk loads.
49
62
  * In bus.mode "off", it loads only when a child frame or a worker needs it.
@@ -60,7 +73,7 @@ export declare class ObservabilityRuntime {
60
73
  /** Load of the delivery stack. It is undefined when nothing loads. A record then has no destination. */
61
74
  private senderLoad?;
62
75
  /** Records that arrive while the delivery stack loads. */
63
- private pendingRecords;
76
+ private readonly pendingRecords;
64
77
  /** Active auto-capture instrumentation modules. */
65
78
  private readonly captures;
66
79
  /** Count of capture installs. An install that a later install replaced stops after its load. */
@@ -68,23 +81,31 @@ export declare class ObservabilityRuntime {
68
81
  /** Capture work that a rebuild of the capture modules must not repeat. */
69
82
  private readonly captureOnce;
70
83
  /** Queue buffering records created before bus role resolution. */
71
- private bootBuffer;
84
+ private readonly bootBuffer;
72
85
  /** Batch buffer staging records for microtask forwarding. */
73
86
  private forwardBuffer;
74
- /** Indicates whether a microtask drain is scheduled for the forward buffer. */
87
+ /** True if a microtask drain of the forward buffer is pending. */
75
88
  private forwardScheduled;
76
- /** Indicates whether startup has decided the bus role. A sender load waits for it. */
89
+ /** True if startup has decided the bus role. A sender load waits for it. */
77
90
  private roleResolved;
78
91
  /** Resolves when startup releases the boot records. flush() waits for it. init() sets it. */
79
92
  private started;
80
- /** Indicates whether asynchronous initialization has completed. */
93
+ /** True if asynchronous initialization is complete. */
81
94
  private ready;
82
- /** Indicates whether shutdown stopped the runtime. */
95
+ /** True if shutdown stopped the runtime. */
83
96
  private destroyed;
84
97
  /** Timestamp of the last reported storage gap warning in epoch milliseconds. */
85
98
  private lastGapAt;
99
+ /** Record limits of the builder and the console. The first configure() of the app sets them. */
100
+ private readonly limits;
101
+ /** Lifetime rules of the journey engine. The first configure() of the app sets the age. */
102
+ private readonly journeyOptions;
103
+ /** False in a runtime that an early log call started. The first configure() then sets limits. */
104
+ private tunablesLocked;
86
105
  /**
87
106
  * @param input Initial consumer configuration options.
107
+ * @param degraded True for a console-only runtime next to another version. It installs
108
+ * no capture.
88
109
  */
89
110
  private constructor();
90
111
  /**
@@ -94,31 +115,59 @@ export declare class ObservabilityRuntime {
94
115
  */
95
116
  readonly busAccept: (message: BusMessage, reply: Receive) => void;
96
117
  /**
97
- * Returns the singleton runtime instance pinned to this realm.
118
+ * Returns the runtime on the global key of this realm. Another copy of the library can own it.
119
+ * @returns Pinned runtime instance or null.
120
+ */
121
+ private static pinned;
122
+ /**
123
+ * Returns the local runtime of this copy. Without one, it returns the pinned runtime.
124
+ * A pinned runtime of another version gives null. A log call then starts the local runtime.
98
125
  * @returns Active runtime instance or null.
99
126
  */
100
127
  static current(): ObservabilityRuntime | null;
101
128
  /**
102
129
  * Returns the runtime that shutdown() stopped, until the next configure().
130
+ * A stopped runtime of another version gives null.
103
131
  * @returns Stopped runtime instance or null.
104
132
  */
105
133
  static stopped(): ObservabilityRuntime | null;
106
134
  /**
107
- * Tests whether shutdown() stopped this runtime.
135
+ * Tests if shutdown() stopped this runtime.
108
136
  * @returns True after destroy() starts.
109
137
  */
110
138
  isDestroyed(): boolean;
111
139
  /**
112
140
  * Initializes a new runtime instance or updates the existing singleton.
113
141
  * @param input Consumer configuration options.
142
+ * @param implicit True for the default runtime that an early log call starts.
114
143
  * @returns Active runtime instance.
115
144
  */
116
- static configure(input: Partial<ObservabilityConfig>): ObservabilityRuntime;
145
+ static configure(input: Partial<ObservabilityConfig>, implicit?: boolean): ObservabilityRuntime;
146
+ /**
147
+ * Starts a console-only runtime next to the runtime of another version. It sends nothing,
148
+ * joins no bus and installs no capture. The other version keeps the page runtime.
149
+ * @param input Consumer configuration options.
150
+ * @param found sdkVersion of the pinned runtime. A runtime before 0.9.0 has none.
151
+ * @returns The local runtime.
152
+ */
153
+ private static startDegraded;
117
154
  /**
118
155
  * Updates runtime configuration and refreshes affected subsystems.
119
156
  * @param input Partial configuration to merge.
120
157
  */
121
158
  private reconfigure;
159
+ /**
160
+ * Restores the startup tunables in the next config. A part of the runtime reads each tunable
161
+ * one time. A later change has no effect. The runtime then refuses it.
162
+ * @param next Resolved config of a later configure() call.
163
+ */
164
+ private keepStartupTunables;
165
+ /**
166
+ * Refuses a change of config sections. It restores the values in force in the next config.
167
+ * @param next Resolved config of a later configure() call.
168
+ * @param sections Sections that cannot change.
169
+ */
170
+ private keepSections;
122
171
  /**
123
172
  * Restores the storage strategy of the built adapter. The runtime reads all other keys
124
173
  * live. It builds the adapter only one time. A new adapter strands the batches in the
@@ -126,7 +175,7 @@ export declare class ObservabilityRuntime {
126
175
  */
127
176
  private keepBuiltStorage;
128
177
  /**
129
- * Refuses a change that would leave the built delivery stack with nowhere to send.
178
+ * Refuses a change that leaves the built delivery stack with no destination.
130
179
  * Without a destination, the retry engine removes each stored batch as delivered.
131
180
  * @param input Partial configuration to merge.
132
181
  * @returns Input without the refused changes.
@@ -143,17 +192,17 @@ export declare class ObservabilityRuntime {
143
192
  private boot;
144
193
  /**
145
194
  * Starts the load of the bus one time.
146
- * @returns Promise resolving to the started bus, or null if it did not load.
195
+ * @returns Promise that resolves to the started bus, or null if it did not load.
147
196
  */
148
197
  private ensureBus;
149
198
  /**
150
199
  * Loads and constructs the bus one time. It does not call start().
151
- * @returns Promise resolving to the constructed bus, or null if it did not load.
200
+ * @returns Promise that resolves to the constructed bus, or null if it did not load.
152
201
  */
153
202
  private constructBus;
154
203
  /**
155
204
  * Starts the constructed bus. It never rejects.
156
- * @returns Promise resolving to the started bus, or null if it did not load or start.
205
+ * @returns Promise that resolves to the started bus, or null if it did not load or start.
157
206
  */
158
207
  private startBus;
159
208
  /** Imports and constructs the bus. It never rejects. */
@@ -165,12 +214,17 @@ export declare class ObservabilityRuntime {
165
214
  private role;
166
215
  /**
167
216
  * Loads the delivery stack if this context is the sender and has an endpoint.
168
- * @returns Promise resolving when the load completes, or immediately when nothing loads.
217
+ * @returns Promise that resolves when the load completes, or immediately when nothing loads.
169
218
  */
170
219
  private syncSender;
220
+ /**
221
+ * Tests if the config names a destination for the records.
222
+ * @returns True with an endpoint or a custom transport.
223
+ */
224
+ private hasDestination;
171
225
  /**
172
226
  * Starts the load of the delivery stack one time.
173
- * @returns Promise resolving when the load completes or fails.
227
+ * @returns Promise that resolves when the load completes or fails.
174
228
  */
175
229
  private loadSender;
176
230
  /** Imports and builds the delivery stack. It then moves the held records into it. It never rejects. */
@@ -182,7 +236,7 @@ export declare class ObservabilityRuntime {
182
236
  /**
183
237
  * Imports one capture module. A failed import reports and skips that module only.
184
238
  * @param name Capture module name.
185
- * @returns Promise resolving to the class, or undefined if the import failed.
239
+ * @returns Promise that resolves to the class, or undefined if the import failed.
186
240
  */
187
241
  private loadCapture;
188
242
  /**
@@ -210,16 +264,17 @@ export declare class ObservabilityRuntime {
210
264
  */
211
265
  private deliver;
212
266
  /**
213
- * Adds a record to a hold buffer. It drops the oldest record when the buffer is full.
214
- * @param buffer Hold buffer.
215
- * @param record Record to hold.
267
+ * Counts a record that a full hold buffer drops. It gives the record to the onDrop report.
268
+ * @param record Dropped record.
216
269
  */
217
- private pushCapped;
270
+ private dropHeld;
218
271
  /**
219
272
  * Batches records for asynchronous transmission to the upstream sender.
220
273
  * @param record Log record to forward.
221
274
  */
222
275
  private forward;
276
+ /** Gives the records of the forward buffer to the bus. */
277
+ private sendForwarded;
223
278
  /**
224
279
  * Validates, samples and queues records from child frames or workers.
225
280
  * A forwarded record arrives built. This is the first point in this context where
@@ -230,21 +285,30 @@ export declare class ObservabilityRuntime {
230
285
  /** Flushes the startup records. It adds the active journey to records without a journey. */
231
286
  private releaseBootBuffer;
232
287
  /**
233
- * Emits a warning record when storage evicts batches.
288
+ * Gives lost records to the onDrop report.
289
+ * @param reason Cause of the loss.
290
+ * @param records Lost records.
291
+ * @param batchIds Ids of the lost batches.
292
+ */
293
+ private readonly reportLoss;
294
+ /**
295
+ * Gives the evicted batches to the onDrop report. It also emits a warning record. A throttle
296
+ * limits the warning records.
234
297
  * @param result Storage prune summary metrics.
298
+ * @param dropped The evicted batches.
235
299
  */
236
300
  private readonly reportGap;
237
301
  /** Makes and stores a new tab ID after a tab ID collision. */
238
302
  private regenerateTabId;
239
303
  /**
240
304
  * Counts the batches held in storage after a failed or deferred delivery.
241
- * @returns Promise resolving to the number of stored batches. A forwarder stores
305
+ * @returns Promise that resolves to the number of stored batches. A forwarder stores
242
306
  * nothing and reports 0.
243
307
  */
244
308
  queueDepth(): Promise<number>;
245
309
  /**
246
310
  * Flushes all pending records in the pipeline or forward buffer.
247
- * @returns Promise resolving when queued records are transmitted or handed off.
311
+ * @returns Promise that resolves when the library sends or hands off the queued records.
248
312
  */
249
313
  flush(): Promise<void>;
250
314
  }
@@ -1,6 +1,7 @@
1
1
  import type { ResolvedConfig } from "../models/config";
2
+ import type { LossReporter } from "../models/drop";
2
3
  import type { LogRecord } from "../models/log-record";
3
- import type { GapReporter } from "../models/storage";
4
+ import { type GapReporter } from "../models/storage";
4
5
  import type { Diagnostics } from "./diagnostics";
5
6
  import type { RemoteSlot } from "./remote-sampling";
6
7
  /** Inputs to build the delivery stack. */
@@ -11,20 +12,20 @@ export interface SenderDeps {
11
12
  diagnostics: Diagnostics;
12
13
  /** Receives a report when storage drops batches before delivery. */
13
14
  onGap: GapReporter;
15
+ /** Receives the records that the transport, the retry engine and the exit flush lose. */
16
+ onLoss: LossReporter;
14
17
  /** Slot of the runtime for the sampling rules from the ingest server. */
15
18
  remote: RemoteSlot;
16
19
  }
17
20
  /** Delivery stack for one sender runtime. */
18
21
  export declare class Sender {
19
22
  private readonly storage;
20
- private readonly transport;
21
23
  private readonly retry;
22
24
  private readonly pipeline;
23
25
  private readonly exitFlush;
24
26
  private readonly diagnostics;
25
27
  /**
26
28
  * @param storage Storage adapter for undelivered batches.
27
- * @param transport HTTP transport for live delivery.
28
29
  * @param retry Retry engine for stored batches.
29
30
  * @param pipeline Pipeline that batches records.
30
31
  * @param exitFlush Handler that sends pending records on unload.
@@ -32,9 +33,10 @@ export declare class Sender {
32
33
  */
33
34
  private constructor();
34
35
  /**
35
- * Builds the delivery stack, drains the emergency queue and starts the retry loop.
36
+ * Builds the delivery stack and starts the retry loop. The emergency queue import runs
37
+ * after the start. A slow IndexedDB open then does not hold the boot buffer.
36
38
  * @param deps Configuration, diagnostics and gap reporter.
37
- * @returns Promise resolving to the started sender.
39
+ * @returns Promise that resolves to the started sender.
38
40
  */
39
41
  static create(deps: SenderDeps): Promise<Sender>;
40
42
  /**
@@ -43,19 +45,25 @@ export declare class Sender {
43
45
  */
44
46
  push(record: LogRecord): void;
45
47
  /**
46
- * Sends the records held in the stream buffers.
47
- * @returns Promise resolving when the batch is sent or stored for retry.
48
+ * Sends the records in the stream buffers. Then it waits for each batch in flight.
49
+ * @returns Promise that resolves when the pipeline sends or stores each batch.
48
50
  */
49
51
  flush(): Promise<void>;
50
52
  /**
51
53
  * Counts the batches held in storage.
52
- * @returns Promise resolving to the batch count, or 0 if storage fails.
54
+ * @returns Promise that resolves to the batch count, or 0 if storage fails.
53
55
  */
54
56
  queueDepth(): Promise<number>;
55
57
  /**
56
- * Sends pending records and stops all timers and listeners. Then it closes storage.
57
- * The synchronous steps run before the first await. The runtime relies on this order.
58
- * @returns Promise resolving when storage is closed.
58
+ * Sends pending records with a normal flush, then with the exit flush. Then it stops all
59
+ * timers and listeners. Then it closes storage. The normal flush keeps the headers, gzip
60
+ * and the retry. The exit flush takes the records that the normal flush did not confirm.
61
+ * @returns Promise that resolves when storage closes.
59
62
  */
60
63
  destroy(): Promise<void>;
64
+ /**
65
+ * Moves the batches of the emergency queue into storage, then wakes the retry engine.
66
+ * The previous page load parked them during its unload.
67
+ */
68
+ private importEmergency;
61
69
  }
@@ -0,0 +1,26 @@
1
+ //#region src/utils/unref.ts
2
+ function e(e) {
3
+ typeof e != "number" && e.unref?.();
4
+ }
5
+ //#endregion
6
+ //#region src/utils/deadline.ts
7
+ var t = class extends Error {
8
+ constructor(e) {
9
+ super(`The operation took longer than ${String(e)} ms.`), this.name = "DeadlineError";
10
+ }
11
+ };
12
+ function n(n, r) {
13
+ let i, a = new Promise((n, a) => {
14
+ let o = setTimeout(() => {
15
+ a(new t(r));
16
+ }, r);
17
+ i = o, e(o);
18
+ });
19
+ return Promise.race([n, a]).finally(() => {
20
+ clearTimeout(i);
21
+ });
22
+ }
23
+ //#endregion
24
+ export { n, e as r, t };
25
+
26
+ //# sourceMappingURL=deadline-5_PecIl5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deadline-5_PecIl5.js","names":["unrefTimer","timer","DeadlineError","ms","withDeadline","expire","deadline","work"],"sources":["../src/utils/unref.ts","../src/utils/deadline.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/** Timer handle. It is a number in a browser and a Timeout object in Node. */\nexport type TimerHandle = number | { unref?: () => void };\n\n/**\n * Unreferences a timer handle. A pending timer then does not keep 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","// src/utils/deadline.ts\n//\n// Sets a deadline for a promise that can stay pending. A pending promise raises no\n// diagnostics event. Without a deadline, its caller waits forever and keeps its slot.\n\nimport { unrefTimer } from \"./unref\";\n\n/** Error of a promise that did not settle before its deadline. */\nexport class DeadlineError extends Error {\n /**\n * @param ms Deadline in milliseconds.\n */\n constructor(ms: number) {\n super(`The operation took longer than ${String(ms)} ms.`);\n this.name = \"DeadlineError\";\n }\n}\n\n/**\n * Rejects when a promise does not settle within a deadline.\n * @param work Promise to bound.\n * @param ms Deadline in milliseconds.\n * @returns The value of the promise, or a rejection after the deadline.\n */\nexport function withDeadline<T>(work: Promise<T>, ms: number): Promise<T> {\n let expire: ReturnType<typeof setTimeout> | undefined;\n\n const deadline = new Promise<never>((_resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new DeadlineError(ms));\n }, ms);\n\n expire = timer;\n unrefTimer(timer);\n });\n\n // Clear the timer on success and on failure. If not, each storage call leaves an armed timer.\n return Promise.race([work, deadline]).finally(() => {\n clearTimeout(expire);\n });\n}\n"],"mappings":";AAYA,SAAgBA,EAAW,GAA0B;CACnD,AAAI,OAAOC,KAAU,YACnBA,EAAM,QAAQ;AAElB;;;ACRA,IAAaC,IAAb,cAAmC,MAAM;CAIvC,YAAY,GAAY;EAEtB,AADA,MAAM,kCAAkC,OAAOC,CAAE,EAAE,KAAK,GACxD,KAAK,OAAO;CACd;AACF;AAQA,SAAgBC,EAAgB,GAAkB,GAAwB;CACxE,IAAIC,GAEEC,IAAW,IAAI,SAAgB,GAAU,MAAW;EACxD,IAAML,IAAQ,iBAAiB;GAC7B,EAAO,IAAIC,EAAcC,CAAE,CAAC;EAC9B,GAAGA,CAAE;EAGL,AADA,IAASF,GACTD,EAAWC,CAAK;CAClB,CAAC;CAGD,OAAO,QAAQ,KAAK,CAACM,GAAMD,CAAQ,CAAC,CAAC,CAAC,cAAc;EAClD,aAAaD,CAAM;CACrB,CAAC;AACH"}
@@ -0,0 +1,2 @@
1
+ function e(e){typeof e!=`number`&&e.unref?.()}var t=class extends Error{constructor(e){super(`The operation took longer than ${String(e)} ms.`),this.name=`DeadlineError`}};function n(n,r){let i,a=new Promise((n,a)=>{let o=setTimeout(()=>{a(new t(r))},r);i=o,e(o)});return Promise.race([n,a]).finally(()=>{clearTimeout(i)})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
2
+ //# sourceMappingURL=deadline-XSnm95pg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deadline-XSnm95pg.cjs","names":["unrefTimer","timer","DeadlineError","ms","withDeadline","expire","deadline","reject","work"],"sources":["../src/utils/unref.ts","../src/utils/deadline.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/** Timer handle. It is a number in a browser and a Timeout object in Node. */\nexport type TimerHandle = number | { unref?: () => void };\n\n/**\n * Unreferences a timer handle. A pending timer then does not keep 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","// src/utils/deadline.ts\n//\n// Sets a deadline for a promise that can stay pending. A pending promise raises no\n// diagnostics event. Without a deadline, its caller waits forever and keeps its slot.\n\nimport { unrefTimer } from \"./unref\";\n\n/** Error of a promise that did not settle before its deadline. */\nexport class DeadlineError extends Error {\n /**\n * @param ms Deadline in milliseconds.\n */\n constructor(ms: number) {\n super(`The operation took longer than ${String(ms)} ms.`);\n this.name = \"DeadlineError\";\n }\n}\n\n/**\n * Rejects when a promise does not settle within a deadline.\n * @param work Promise to bound.\n * @param ms Deadline in milliseconds.\n * @returns The value of the promise, or a rejection after the deadline.\n */\nexport function withDeadline<T>(work: Promise<T>, ms: number): Promise<T> {\n let expire: ReturnType<typeof setTimeout> | undefined;\n\n const deadline = new Promise<never>((_resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new DeadlineError(ms));\n }, ms);\n\n expire = timer;\n unrefTimer(timer);\n });\n\n // Clear the timer on success and on failure. If not, each storage call leaves an armed timer.\n return Promise.race([work, deadline]).finally(() => {\n clearTimeout(expire);\n });\n}\n"],"mappings":"AAYA,SAAgBA,EAAW,EAA0B,CAC/C,OAAOC,GAAU,UACnBA,EAAM,QAAQ,CAElB,CCRA,IAAaC,EAAb,cAAmC,KAAM,CAIvC,YAAY,EAAY,CACtB,MAAM,kCAAkC,OAAOC,CAAE,EAAE,KAAK,EACxD,KAAK,KAAO,eACd,CACF,EAQA,SAAgBC,EAAgB,EAAkB,EAAwB,CACxE,IAAIC,EAEEC,EAAW,IAAI,SAAgB,EAAU,IAAW,CACxD,IAAML,EAAQ,eAAiB,CAC7BM,EAAO,IAAIL,EAAcC,CAAE,CAAC,CAC9B,EAAGA,CAAE,EAEL,EAASF,EACTD,EAAWC,CAAK,CAClB,CAAC,EAGD,OAAO,QAAQ,KAAK,CAACO,EAAMF,CAAQ,CAAC,CAAC,CAAC,YAAc,CAClD,aAAaD,CAAM,CACrB,CAAC,CACH"}
@@ -0,0 +1,19 @@
1
+ //#region src/utils/error-like.ts
2
+ var e = /* @__PURE__ */ new Set([
3
+ "name",
4
+ "message",
5
+ "stack",
6
+ "cause"
7
+ ]);
8
+ function t(e) {
9
+ return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
10
+ }
11
+ function n(e) {
12
+ if (typeof e != "object" || !e) return !1;
13
+ let t = e;
14
+ return typeof t.name == "string" && typeof t.message == "string" && (t.stack === void 0 || typeof t.stack == "string");
15
+ }
16
+ //#endregion
17
+ export { t as n, n as r, e as t };
18
+
19
+ //# sourceMappingURL=error-like-Ywo5uRHo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-like-Ywo5uRHo.js","names":["ERROR_OWN_KEYS","isDataField","value","isErrorLike","candidate"],"sources":["../src/utils/error-like.ts"],"sourcesContent":["// src/utils/error-like.ts\n//\n// Detects an error by its shape. An error from another realm, for example an iframe,\n// fails `instanceof Error`.\n\n/** Standard fields of an error. The library writes the other own fields as error data. */\nexport const ERROR_OWN_KEYS: ReadonlySet<string> = new Set([\"name\", \"message\", \"stack\", \"cause\"]);\n\n/**\n * Tests if a value is a field that error data keeps. An object field, for example the\n * config of an AxiosError, holds credentials and request bodies.\n * @param value Field value.\n * @returns True for a string, a number or a boolean.\n */\nexport function isDataField(value: unknown): boolean {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\n/** The fields of an error that the library reads. */\nexport interface ErrorLike {\n /** Error class name, for example \"TypeError\". */\n name: string;\n /** Error message. */\n message: string;\n /** Stack trace text. */\n stack?: string;\n}\n\n/**\n * Tests if a value has the shape of an error.\n * A getter on a hostile value can throw. Call this function inside a diagnostics guard.\n * @param value Value to test.\n * @returns True for an object with a string name, a string message and a string or no stack.\n */\nexport function isErrorLike(value: unknown): value is ErrorLike {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const candidate = value as Record<string, unknown>;\n return (\n typeof candidate.name === \"string\" &&\n typeof candidate.message === \"string\" &&\n (candidate.stack === undefined || typeof candidate.stack === \"string\")\n );\n}\n"],"mappings":";AAMA,IAAaA,oBAAsC,IAAI,IAAI;CAAC;CAAQ;CAAW;CAAS;AAAO,CAAC;AAQhG,SAAgBC,EAAY,GAAyB;CACnD,OAAO,OAAOC,KAAU,YAAY,OAAOA,KAAU,YAAY,OAAOA,KAAU;AACpF;AAkBA,SAAgBC,EAAY,GAAoC;CAC9D,IAAI,OAAOD,KAAU,aAAYA,GAC/B,OAAO;CAGT,IAAME,IAAYF;CAClB,OACE,OAAOE,EAAU,QAAS,YAC1B,OAAOA,EAAU,WAAY,aAC5BA,EAAU,UAAU,KAAA,KAAa,OAAOA,EAAU,SAAU;AAEjE"}
@@ -0,0 +1,2 @@
1
+ var e=new Set([`name`,`message`,`stack`,`cause`]);function t(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function n(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`&&typeof t.message==`string`&&(t.stack===void 0||typeof t.stack==`string`)}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
2
+ //# sourceMappingURL=error-like-gGRx2s36.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-like-gGRx2s36.cjs","names":["ERROR_OWN_KEYS","isDataField","value","isErrorLike","candidate"],"sources":["../src/utils/error-like.ts"],"sourcesContent":["// src/utils/error-like.ts\n//\n// Detects an error by its shape. An error from another realm, for example an iframe,\n// fails `instanceof Error`.\n\n/** Standard fields of an error. The library writes the other own fields as error data. */\nexport const ERROR_OWN_KEYS: ReadonlySet<string> = new Set([\"name\", \"message\", \"stack\", \"cause\"]);\n\n/**\n * Tests if a value is a field that error data keeps. An object field, for example the\n * config of an AxiosError, holds credentials and request bodies.\n * @param value Field value.\n * @returns True for a string, a number or a boolean.\n */\nexport function isDataField(value: unknown): boolean {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\n/** The fields of an error that the library reads. */\nexport interface ErrorLike {\n /** Error class name, for example \"TypeError\". */\n name: string;\n /** Error message. */\n message: string;\n /** Stack trace text. */\n stack?: string;\n}\n\n/**\n * Tests if a value has the shape of an error.\n * A getter on a hostile value can throw. Call this function inside a diagnostics guard.\n * @param value Value to test.\n * @returns True for an object with a string name, a string message and a string or no stack.\n */\nexport function isErrorLike(value: unknown): value is ErrorLike {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const candidate = value as Record<string, unknown>;\n return (\n typeof candidate.name === \"string\" &&\n typeof candidate.message === \"string\" &&\n (candidate.stack === undefined || typeof candidate.stack === \"string\")\n );\n}\n"],"mappings":"AAMA,IAAaA,EAAsC,IAAI,IAAI,CAAC,OAAQ,UAAW,QAAS,OAAO,CAAC,EAQhG,SAAgBC,EAAY,EAAyB,CACnD,OAAO,OAAOC,GAAU,UAAY,OAAOA,GAAU,UAAY,OAAOA,GAAU,SACpF,CAkBA,SAAgBC,EAAY,EAAoC,CAC9D,GAAI,OAAOD,GAAU,WAAYA,EAC/B,MAAO,GAGT,IAAME,EAAYF,EAClB,OACE,OAAOE,EAAU,MAAS,UAC1B,OAAOA,EAAU,SAAY,WAC5BA,EAAU,QAAU,IAAA,IAAa,OAAOA,EAAU,OAAU,SAEjE"}
@@ -0,0 +1,3 @@
1
+ require("./constants-X86IDwkC.cjs");const e=require("./error-like-gGRx2s36.cjs"),t=require("./platform-DW3GFIUE.cjs"),n=require("./storm-CKuaBp7i.cjs");function r(t){if(e.r(t)){let e=(t.stack??``).split(`
2
+ `)[1]??``;return{message:t.message,key:`${t.name}|${t.message}|${e}`}}let n=String(t);return{message:n,key:`${typeof t}|${n}|`}}var i=class{ctx;name=`errors`;installed=!1;seen=new Map;window={start:0,count:0};constructor(e){this.ctx=e}install(){this.installed||typeof addEventListener>`u`||(this.installed=!0,addEventListener(`error`,this.onError,!0),addEventListener(`unhandledrejection`,this.onRejection))}uninstall(){this.installed&&(this.installed=!1,removeEventListener(`error`,this.onError,!0),removeEventListener(`unhandledrejection`,this.onRejection),this.seen.clear())}onError=e=>{let n=e.target,r=n?.src??n?.href??``;if(n!==null&&n!==globalThis&&r!==``){if(!this.ctx.config.capture.resourceErrors)return;let e=this.ctx.config.capture.fullUrls?r:t.r(r);this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`resource failed: ${e}`}),this.ctx.logger.warn(`resource failed to load`,{"error.type":`resource`,"resource.url":e,"resource.tag":n.tagName.toLowerCase()});return}if(!this.ctx.config.capture.errors)return;let i=e,a=i.message===``?`unknown error`:i.message,o=i.error??Error(a);this.report(`window.onerror`,o,{"error.source":i.filename,"error.line":i.lineno,"error.column":i.colno})};onRejection=e=>{this.ctx.config.capture.rejections&&this.report(`unhandledrejection`,e.reason,{"error.type":`unhandledrejection`})};report(e,t,i){if(!n.t(this.window,20,this.ctx.diagnostics,`errors`))return;let a=Date.now(),{message:o,key:s}=this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not read the error reason. It records the error without its message.`,()=>r(t))??{message:``,key:`${typeof t}||`},c=this.seen.get(s);if(c&&a-c.at<5e3){c.count++,c.at=a;return}let l=c?c.count-1:0;if(this.seen.delete(s),this.seen.set(s,{at:a,count:1}),this.seen.size>200){let[e]=this.seen.keys();this.seen.delete(e)}let u=t===void 0?Error(o):t;this.ctx.logger.error(o===``?e:o,u,{...i,"error.captured_by":e,"error.suppressed_count":l})}};exports.ErrorCapture=i;
3
+ //# sourceMappingURL=errors-BTWuVnHZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BTWuVnHZ.cjs","names":["isErrorLike","stripUrlQuery","allowInWindow","require_error_like","require_platform","require_storm","signatureOf","value","frame","message","ErrorCapture","ctx","target","event","resourceUrl","url","errorEvent","fallback","error","now","previous","key","suppressed","oldest","reason","source","extra"],"sources":["../src/capture/errors.ts"],"sourcesContent":["// src/capture/errors.ts\n//\n// Captures uncaught errors, unhandled rejections and failed resource loads.\n\nimport {\n ERROR_DEDUPE_MS,\n ERROR_STORM_MAX_PER_WINDOW,\n MAX_TRACKED_ERROR_SIGNATURES,\n} from \"../constants\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { stripUrlQuery } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Tracking metadata for a deduplicated error signature. */\ninterface SeenError {\n /** Time of the last report for the signature, in epoch milliseconds. */\n at: number;\n /** Occurrences recorded since the last report. */\n count: number;\n}\n\n/** Message and deduplication key of a thrown value. */\ninterface Signature {\n /** Message of the record. */\n message: string;\n /** Deduplication key. */\n key: string;\n}\n\n/**\n * Reads the message and the deduplication key of a thrown value.\n * Duck typing reads an error from another realm. That error fails `instanceof Error`.\n * @param value Thrown value or rejection reason.\n * @returns The signature.\n * @throws When a getter or the text form of the value throws. Call it inside a guard.\n */\nfunction signatureOf(value: unknown): Signature {\n if (isErrorLike(value)) {\n const frame = (value.stack ?? \"\").split(\"\\n\")[1] ?? \"\";\n return { message: value.message, key: `${value.name}|${value.message}|${frame}` };\n }\n\n const message = String(value);\n return { message, key: `${typeof value}|${message}|` };\n}\n\n/** Captures uncaught exceptions, unhandled promise rejections, and failed resource loads. */\nexport class ErrorCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"errors\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Recently reported error signatures in LRU order. */\n private readonly seen = new Map<string, SeenError>();\n\n /** Rate limit of this capture. Console noise has its own window and cannot use it. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Subscribes to global error and unhandledrejection events. */\n install(): void {\n if (this.installed || typeof addEventListener === \"undefined\") {\n return;\n }\n this.installed = true;\n\n // Uses capture phase to observe non-bubbling resource load errors.\n addEventListener(\"error\", this.onError, true);\n addEventListener(\"unhandledrejection\", this.onRejection);\n }\n\n /** Removes event listeners and clears tracked error signatures. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"error\", this.onError, true);\n removeEventListener(\"unhandledrejection\", this.onRejection);\n this.seen.clear();\n }\n\n /** Routes resource load failures and uncaught script errors. */\n private readonly onError = (event: ErrorEvent | Event): void => {\n const target = event.target as (HTMLElement & { src?: string; href?: string }) | null;\n const resourceUrl = target?.src ?? target?.href ?? \"\";\n\n // Filters element-level resource load failures from script errors.\n if (\n target !== null &&\n target !== (globalThis as unknown as EventTarget) &&\n resourceUrl !== \"\"\n ) {\n if (!this.ctx.config.capture.resourceErrors) {\n return;\n }\n\n // A cache buster is noise. A signed URL is a credential.\n // The record keeps neither unless you set fullUrls.\n const url = this.ctx.config.capture.fullUrls ? resourceUrl : stripUrlQuery(resourceUrl);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `resource failed: ${url}`,\n });\n this.ctx.logger.warn(\"resource failed to load\", {\n \"error.type\": \"resource\",\n \"resource.url\": url,\n \"resource.tag\": target.tagName.toLowerCase(),\n });\n return;\n }\n\n if (!this.ctx.config.capture.errors) {\n return;\n }\n\n const errorEvent = event as ErrorEvent;\n const fallback = errorEvent.message === \"\" ? \"unknown error\" : errorEvent.message;\n const thrown: unknown = errorEvent.error;\n const error = thrown ?? new Error(fallback);\n\n this.report(\"window.onerror\", error, {\n \"error.source\": errorEvent.filename,\n \"error.line\": errorEvent.lineno,\n \"error.column\": errorEvent.colno,\n });\n };\n\n /** Captures unhandled promise rejections. */\n private readonly onRejection = (event: PromiseRejectionEvent): void => {\n if (!this.ctx.config.capture.rejections) {\n return;\n }\n\n this.report(\"unhandledrejection\", event.reason, {\n \"error.type\": \"unhandledrejection\",\n });\n };\n\n /**\n * Rate limits, deduplicates, and logs captured errors.\n * @param source Originating capture event name.\n * @param error Caught error instance or thrown value.\n * @param extra Contextual error attributes.\n */\n private report(source: string, error: unknown, extra: Record<string, unknown>): void {\n if (!allowInWindow(this.window, ERROR_STORM_MAX_PER_WINDOW, this.ctx.diagnostics, \"errors\")) {\n return;\n }\n\n const now = Date.now();\n // A reason with no text form, for example a null-prototype object, gets an empty message.\n // The record then uses the source as its message.\n const { message, key } = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the error reason. It records the error without its message.\",\n () => signatureOf(error),\n ) ?? { message: \"\", key: `${typeof error}||` };\n const previous = this.seen.get(key);\n\n if (previous && now - previous.at < ERROR_DEDUPE_MS) {\n previous.count++;\n previous.at = now;\n return;\n }\n\n // This is the number of occurrences that deduplication dropped since the last report.\n // Without this count, many errors look like few errors.\n const suppressed = previous ? previous.count - 1 : 0;\n\n // Delete, then set, to move the key to the end of the map. The map stays in\n // least-recently-reported order. The eviction below needs this order.\n this.seen.delete(key);\n this.seen.set(key, { at: now, count: 1 });\n\n // A page can throw with a new message at each render, for example from a template literal\n // in a loop. Without this cap, the map grows until the document closes.\n if (this.seen.size > MAX_TRACKED_ERROR_SIGNATURES) {\n const [oldest] = this.seen.keys();\n this.seen.delete(oldest);\n }\n\n // Give the original value to the logger. It converts the reason and keeps its data.\n // Without a reason, the record still needs error.message and error.stack_trace.\n const reason = error === undefined ? new Error(message) : error;\n this.ctx.logger.error(message === \"\" ? source : message, reason, {\n ...extra,\n \"error.captured_by\": source,\n \"error.suppressed_count\": suppressed,\n });\n }\n}\n"],"mappings":"wJAqCA,SAASM,EA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,GAAKgB,EAAShB,EAASe,EAAQ,CAC/D,GAAGE,EACH,oBAAqBD,EACrB,yBAA0BH,CAC5B,CAAC,CACH,CACF"}
@@ -1,8 +1,23 @@
1
- import "./constants-Bu49bm39.js";
2
- import { r as e } from "./platform-BwbMRwHm.js";
3
- import { t } from "./storm-DJkEZP_8.js";
1
+ import "./constants-N99w84xy.js";
2
+ import { r as e } from "./error-like-Ywo5uRHo.js";
3
+ import { r as t } from "./platform-Cjts-8k8.js";
4
+ import { t as n } from "./storm-DhtL2eVr.js";
4
5
  //#region src/capture/errors.ts
5
- var n = class {
6
+ function r(t) {
7
+ if (e(t)) {
8
+ let e = (t.stack ?? "").split("\n")[1] ?? "";
9
+ return {
10
+ message: t.message,
11
+ key: `${t.name}|${t.message}|${e}`
12
+ };
13
+ }
14
+ let n = String(t);
15
+ return {
16
+ message: n,
17
+ key: `${typeof t}|${n}|`
18
+ };
19
+ }
20
+ var i = class {
6
21
  ctx;
7
22
  name = "errors";
8
23
  installed = !1;
@@ -20,24 +35,24 @@ var n = class {
20
35
  uninstall() {
21
36
  this.installed && (this.installed = !1, removeEventListener("error", this.onError, !0), removeEventListener("unhandledrejection", this.onRejection), this.seen.clear());
22
37
  }
23
- onError = (t) => {
24
- let n = t.target, r = n?.src ?? n?.href ?? "";
38
+ onError = (e) => {
39
+ let n = e.target, r = n?.src ?? n?.href ?? "";
25
40
  if (n !== null && n !== globalThis && r !== "") {
26
41
  if (!this.ctx.config.capture.resourceErrors) return;
27
- let t = this.ctx.config.capture.fullUrls ? r : e(r);
42
+ let e = this.ctx.config.capture.fullUrls ? r : t(r);
28
43
  this.ctx.breadcrumbs.push({
29
44
  t: Date.now(),
30
45
  category: "http",
31
- message: `resource failed: ${t}`
46
+ message: `resource failed: ${e}`
32
47
  }), this.ctx.logger.warn("resource failed to load", {
33
48
  "error.type": "resource",
34
- "resource.url": t,
49
+ "resource.url": e,
35
50
  "resource.tag": n.tagName.toLowerCase()
36
51
  });
37
52
  return;
38
53
  }
39
54
  if (!this.ctx.config.capture.errors) return;
40
- let i = t, a = i.message === "" ? "unknown error" : i.message, o = i.error ?? Error(a);
55
+ let i = e, a = i.message === "" ? "unknown error" : i.message, o = i.error ?? Error(a);
41
56
  this.report("window.onerror", o, {
42
57
  "error.source": i.filename,
43
58
  "error.line": i.lineno,
@@ -47,29 +62,33 @@ var n = class {
47
62
  onRejection = (e) => {
48
63
  this.ctx.config.capture.rejections && this.report("unhandledrejection", e.reason, { "error.type": "unhandledrejection" });
49
64
  };
50
- report(e, n, r) {
51
- if (!t(this.window, 20, this.ctx.diagnostics, "errors")) return;
52
- let i = Date.now(), a = n instanceof Error ? n : Error(String(n)), o = (a.stack ?? "").split("\n")[1] ?? "", s = `${a.name}|${a.message}|${o}`, c = this.seen.get(s);
53
- if (c && i - c.at < 5e3) {
54
- c.count++, c.at = i;
65
+ report(e, t, i) {
66
+ if (!n(this.window, 20, this.ctx.diagnostics, "errors")) return;
67
+ let a = Date.now(), { message: o, key: s } = this.ctx.diagnostics.guard("capture.record_failed", "The library could not read the error reason. It records the error without its message.", () => r(t)) ?? {
68
+ message: "",
69
+ key: `${typeof t}||`
70
+ }, c = this.seen.get(s);
71
+ if (c && a - c.at < 5e3) {
72
+ c.count++, c.at = a;
55
73
  return;
56
74
  }
57
75
  let l = c ? c.count - 1 : 0;
58
76
  if (this.seen.delete(s), this.seen.set(s, {
59
- at: i,
77
+ at: a,
60
78
  count: 1
61
79
  }), this.seen.size > 200) {
62
80
  let [e] = this.seen.keys();
63
81
  this.seen.delete(e);
64
82
  }
65
- this.ctx.logger.error(a.message === "" ? e : a.message, a, {
66
- ...r,
83
+ let u = t === void 0 ? Error(o) : t;
84
+ this.ctx.logger.error(o === "" ? e : o, u, {
85
+ ...i,
67
86
  "error.captured_by": e,
68
87
  "error.suppressed_count": l
69
88
  });
70
89
  }
71
90
  };
72
91
  //#endregion
73
- export { n as ErrorCapture };
92
+ export { i as ErrorCapture };
74
93
 
75
- //# sourceMappingURL=errors-Dnc-X4Ec.js.map
94
+ //# sourceMappingURL=errors-CQusIGWJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CQusIGWJ.js","names":["isErrorLike","stripUrlQuery","allowInWindow","signatureOf","value","frame","message","ErrorCapture","ctx","target","event","resourceUrl","url","errorEvent","fallback","error","now","previous","key","suppressed","oldest","reason","source","extra"],"sources":["../src/capture/errors.ts"],"sourcesContent":["// src/capture/errors.ts\n//\n// Captures uncaught errors, unhandled rejections and failed resource loads.\n\nimport {\n ERROR_DEDUPE_MS,\n ERROR_STORM_MAX_PER_WINDOW,\n MAX_TRACKED_ERROR_SIGNATURES,\n} from \"../constants\";\nimport { isErrorLike } from \"../utils/error-like\";\nimport { stripUrlQuery } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Tracking metadata for a deduplicated error signature. */\ninterface SeenError {\n /** Time of the last report for the signature, in epoch milliseconds. */\n at: number;\n /** Occurrences recorded since the last report. */\n count: number;\n}\n\n/** Message and deduplication key of a thrown value. */\ninterface Signature {\n /** Message of the record. */\n message: string;\n /** Deduplication key. */\n key: string;\n}\n\n/**\n * Reads the message and the deduplication key of a thrown value.\n * Duck typing reads an error from another realm. That error fails `instanceof Error`.\n * @param value Thrown value or rejection reason.\n * @returns The signature.\n * @throws When a getter or the text form of the value throws. Call it inside a guard.\n */\nfunction signatureOf(value: unknown): Signature {\n if (isErrorLike(value)) {\n const frame = (value.stack ?? \"\").split(\"\\n\")[1] ?? \"\";\n return { message: value.message, key: `${value.name}|${value.message}|${frame}` };\n }\n\n const message = String(value);\n return { message, key: `${typeof value}|${message}|` };\n}\n\n/** Captures uncaught exceptions, unhandled promise rejections, and failed resource loads. */\nexport class ErrorCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"errors\";\n\n /** Prevents duplicate listener registration. */\n private installed = false;\n\n /** Recently reported error signatures in LRU order. */\n private readonly seen = new Map<string, SeenError>();\n\n /** Rate limit of this capture. Console noise has its own window and cannot use it. */\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, and breadcrumbs.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Subscribes to global error and unhandledrejection events. */\n install(): void {\n if (this.installed || typeof addEventListener === \"undefined\") {\n return;\n }\n this.installed = true;\n\n // Uses capture phase to observe non-bubbling resource load errors.\n addEventListener(\"error\", this.onError, true);\n addEventListener(\"unhandledrejection\", this.onRejection);\n }\n\n /** Removes event listeners and clears tracked error signatures. */\n uninstall(): void {\n if (!this.installed) {\n return;\n }\n this.installed = false;\n\n removeEventListener(\"error\", this.onError, true);\n removeEventListener(\"unhandledrejection\", this.onRejection);\n this.seen.clear();\n }\n\n /** Routes resource load failures and uncaught script errors. */\n private readonly onError = (event: ErrorEvent | Event): void => {\n const target = event.target as (HTMLElement & { src?: string; href?: string }) | null;\n const resourceUrl = target?.src ?? target?.href ?? \"\";\n\n // Filters element-level resource load failures from script errors.\n if (\n target !== null &&\n target !== (globalThis as unknown as EventTarget) &&\n resourceUrl !== \"\"\n ) {\n if (!this.ctx.config.capture.resourceErrors) {\n return;\n }\n\n // A cache buster is noise. A signed URL is a credential.\n // The record keeps neither unless you set fullUrls.\n const url = this.ctx.config.capture.fullUrls ? resourceUrl : stripUrlQuery(resourceUrl);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `resource failed: ${url}`,\n });\n this.ctx.logger.warn(\"resource failed to load\", {\n \"error.type\": \"resource\",\n \"resource.url\": url,\n \"resource.tag\": target.tagName.toLowerCase(),\n });\n return;\n }\n\n if (!this.ctx.config.capture.errors) {\n return;\n }\n\n const errorEvent = event as ErrorEvent;\n const fallback = errorEvent.message === \"\" ? \"unknown error\" : errorEvent.message;\n const thrown: unknown = errorEvent.error;\n const error = thrown ?? new Error(fallback);\n\n this.report(\"window.onerror\", error, {\n \"error.source\": errorEvent.filename,\n \"error.line\": errorEvent.lineno,\n \"error.column\": errorEvent.colno,\n });\n };\n\n /** Captures unhandled promise rejections. */\n private readonly onRejection = (event: PromiseRejectionEvent): void => {\n if (!this.ctx.config.capture.rejections) {\n return;\n }\n\n this.report(\"unhandledrejection\", event.reason, {\n \"error.type\": \"unhandledrejection\",\n });\n };\n\n /**\n * Rate limits, deduplicates, and logs captured errors.\n * @param source Originating capture event name.\n * @param error Caught error instance or thrown value.\n * @param extra Contextual error attributes.\n */\n private report(source: string, error: unknown, extra: Record<string, unknown>): void {\n if (!allowInWindow(this.window, ERROR_STORM_MAX_PER_WINDOW, this.ctx.diagnostics, \"errors\")) {\n return;\n }\n\n const now = Date.now();\n // A reason with no text form, for example a null-prototype object, gets an empty message.\n // The record then uses the source as its message.\n const { message, key } = this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read the error reason. It records the error without its message.\",\n () => signatureOf(error),\n ) ?? { message: \"\", key: `${typeof error}||` };\n const previous = this.seen.get(key);\n\n if (previous && now - previous.at < ERROR_DEDUPE_MS) {\n previous.count++;\n previous.at = now;\n return;\n }\n\n // This is the number of occurrences that deduplication dropped since the last report.\n // Without this count, many errors look like few errors.\n const suppressed = previous ? previous.count - 1 : 0;\n\n // Delete, then set, to move the key to the end of the map. The map stays in\n // least-recently-reported order. The eviction below needs this order.\n this.seen.delete(key);\n this.seen.set(key, { at: now, count: 1 });\n\n // A page can throw with a new message at each render, for example from a template literal\n // in a loop. Without this cap, the map grows until the document closes.\n if (this.seen.size > MAX_TRACKED_ERROR_SIGNATURES) {\n const [oldest] = this.seen.keys();\n this.seen.delete(oldest);\n }\n\n // Give the original value to the logger. It converts the reason and keeps its data.\n // Without a reason, the record still needs error.message and error.stack_trace.\n const reason = error === undefined ? new Error(message) : error;\n this.ctx.logger.error(message === \"\" ? source : message, reason, {\n ...extra,\n \"error.captured_by\": source,\n \"error.suppressed_count\": suppressed,\n });\n }\n}\n"],"mappings":";;;;;AAqCA,SAASG,EAAY,GAA2B;CAC9C,IA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AY,KAAKgB,IAAShB,GAASe,GAAQ;GAC/D,GAAGE;GACH,qBAAqBD;GACrB,0BAA0BH;EAC5B,CAAC;CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"global-scope-BN-Io_yv.cjs","names":["globalScope","symbol","key","store","depth","fn"],"sources":["../src/utils/global-scope.ts"],"sourcesContent":["// src/utils/global-scope.ts\n//\n// Counts open scopes on a global symbol. Two copies of the library on one page then share the\n// count. Without it, one copy captures the requests and the console lines of the other copy.\n\n/** Scope that a function runs inside. */\nexport interface GlobalScope {\n /**\n * Runs a function inside the scope. The scope covers only the synchronous part of the function.\n * @param fn Function to run.\n * @returns The return value of the function.\n */\n run<T>(fn: () => T): T;\n /**\n * Tests whether a scope is open.\n * @returns True while a function runs inside the scope.\n */\n open(): boolean;\n}\n\n/**\n * Makes a scope whose count is on a global symbol.\n * @param key Key of the global symbol.\n * @returns The scope.\n */\nexport function globalScope(key: string): GlobalScope {\n const symbol = Symbol.for(key);\n const store = globalThis as unknown as Record<symbol, number | undefined>;\n const depth = (): number => store[symbol] ?? 0;\n\n return {\n run(fn) {\n // A count stays correct when one scope opens inside another.\n store[symbol] = depth() + 1;\n\n try {\n return fn();\n } finally {\n store[symbol] = depth() - 1;\n }\n },\n open: () => depth() > 0,\n };\n}\n"],"mappings":"AAyBA,SAAgBA,EAAY,EAA0B,CACpD,IAAMC,EAAS,OAAO,IAAIC,CAAG,EACvBC,EAAQ,WACRC,MAAsBD,EAAMF,IAAW,EAE7C,MAAO,CACL,IAAI,EAAI,CAEN,EAAMA,GAAUG,EAAM,EAAI,EAE1B,GAAI,CACF,OAAOC,EAAG,CACZ,QAAU,CACR,EAAMJ,GAAUG,EAAM,EAAI,CAC5B,CACF,EACA,SAAYA,EAAM,EAAI,CACxB,CACF"}
1
+ {"version":3,"file":"global-scope-BN-Io_yv.cjs","names":["globalScope","symbol","key","store","depth","fn"],"sources":["../src/utils/global-scope.ts"],"sourcesContent":["// src/utils/global-scope.ts\n//\n// Counts open scopes on a global symbol. Two copies of the library on one page then share the\n// count. Without it, one copy captures the requests and the console lines of the other copy.\n\n/** Scope that a function runs inside. */\nexport interface GlobalScope {\n /**\n * Runs a function inside the scope. The scope covers only the synchronous part of the function.\n * @param fn Function to run.\n * @returns The return value of the function.\n */\n run<T>(fn: () => T): T;\n /**\n * Tests if a scope is open.\n * @returns True while a function runs inside the scope.\n */\n open(): boolean;\n}\n\n/**\n * Makes a scope whose count is on a global symbol.\n * @param key Key of the global symbol.\n * @returns The scope.\n */\nexport function globalScope(key: string): GlobalScope {\n const symbol = Symbol.for(key);\n const store = globalThis as unknown as Record<symbol, number | undefined>;\n const depth = (): number => store[symbol] ?? 0;\n\n return {\n run(fn) {\n // A count stays correct when one scope opens inside another.\n store[symbol] = depth() + 1;\n\n try {\n return fn();\n } finally {\n store[symbol] = depth() - 1;\n }\n },\n open: () => depth() > 0,\n };\n}\n"],"mappings":"AAyBA,SAAgBA,EAAY,EAA0B,CACpD,IAAMC,EAAS,OAAO,IAAIC,CAAG,EACvBC,EAAQ,WACRC,MAAsBD,EAAMF,IAAW,EAE7C,MAAO,CACL,IAAI,EAAI,CAEN,EAAMA,GAAUG,EAAM,EAAI,EAE1B,GAAI,CACF,OAAOC,EAAG,CACZ,QAAU,CACR,EAAMJ,GAAUG,EAAM,EAAI,CAC5B,CACF,EACA,SAAYA,EAAM,EAAI,CACxB,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"global-scope-dp2jADRl.js","names":["globalScope","symbol","key","store","depth","fn"],"sources":["../src/utils/global-scope.ts"],"sourcesContent":["// src/utils/global-scope.ts\n//\n// Counts open scopes on a global symbol. Two copies of the library on one page then share the\n// count. Without it, one copy captures the requests and the console lines of the other copy.\n\n/** Scope that a function runs inside. */\nexport interface GlobalScope {\n /**\n * Runs a function inside the scope. The scope covers only the synchronous part of the function.\n * @param fn Function to run.\n * @returns The return value of the function.\n */\n run<T>(fn: () => T): T;\n /**\n * Tests whether a scope is open.\n * @returns True while a function runs inside the scope.\n */\n open(): boolean;\n}\n\n/**\n * Makes a scope whose count is on a global symbol.\n * @param key Key of the global symbol.\n * @returns The scope.\n */\nexport function globalScope(key: string): GlobalScope {\n const symbol = Symbol.for(key);\n const store = globalThis as unknown as Record<symbol, number | undefined>;\n const depth = (): number => store[symbol] ?? 0;\n\n return {\n run(fn) {\n // A count stays correct when one scope opens inside another.\n store[symbol] = depth() + 1;\n\n try {\n return fn();\n } finally {\n store[symbol] = depth() - 1;\n }\n },\n open: () => depth() > 0,\n };\n}\n"],"mappings":";AAyBA,SAAgBA,EAAY,GAA0B;CACpD,IAAMC,IAAS,OAAO,IAAIC,CAAG,GACvBC,IAAQ,YACRC,UAAsBD,EAAMF,MAAW;CAE7C,OAAO;EACL,IAAI,GAAI;GAEN,EAAMA,KAAUG,EAAM,IAAI;GAE1B,IAAI;IACF,OAAOC,EAAG;GACZ,UAAU;IACR,EAAMJ,KAAUG,EAAM,IAAI;GAC5B;EACF;EACA,YAAYA,EAAM,IAAI;CACxB;AACF"}
1
+ {"version":3,"file":"global-scope-dp2jADRl.js","names":["globalScope","symbol","key","store","depth","fn"],"sources":["../src/utils/global-scope.ts"],"sourcesContent":["// src/utils/global-scope.ts\n//\n// Counts open scopes on a global symbol. Two copies of the library on one page then share the\n// count. Without it, one copy captures the requests and the console lines of the other copy.\n\n/** Scope that a function runs inside. */\nexport interface GlobalScope {\n /**\n * Runs a function inside the scope. The scope covers only the synchronous part of the function.\n * @param fn Function to run.\n * @returns The return value of the function.\n */\n run<T>(fn: () => T): T;\n /**\n * Tests if a scope is open.\n * @returns True while a function runs inside the scope.\n */\n open(): boolean;\n}\n\n/**\n * Makes a scope whose count is on a global symbol.\n * @param key Key of the global symbol.\n * @returns The scope.\n */\nexport function globalScope(key: string): GlobalScope {\n const symbol = Symbol.for(key);\n const store = globalThis as unknown as Record<symbol, number | undefined>;\n const depth = (): number => store[symbol] ?? 0;\n\n return {\n run(fn) {\n // A count stays correct when one scope opens inside another.\n store[symbol] = depth() + 1;\n\n try {\n return fn();\n } finally {\n store[symbol] = depth() - 1;\n }\n },\n open: () => depth() > 0,\n };\n}\n"],"mappings":";AAyBA,SAAgBA,EAAY,GAA0B;CACpD,IAAMC,IAAS,OAAO,IAAIC,CAAG,GACvBC,IAAQ,YACRC,UAAsBD,EAAMF,MAAW;CAE7C,OAAO;EACL,IAAI,GAAI;GAEN,EAAMA,KAAUG,EAAM,IAAI;GAE1B,IAAI;IACF,OAAOC,EAAG;GACZ,UAAU;IACR,EAAMJ,KAAUG,EAAM,IAAI;GAC5B;EACF;EACA,YAAYA,EAAM,IAAI;CACxB;AACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-X86IDwkC.cjs");var t={local:()=>localStorage,session:()=>sessionStorage};function n(){let e=e=>({getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}),t=e(new Map),n=e(new Map);return{local:()=>t,session:()=>n}}function r(e){let t=new Uint8Array(e);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function i(e){try{if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID()}catch{e.count(`platform.api_blocked`)}return r(16)}function a(e,t,n,r){return r.guard(`storage.unavailable`,`The library could not read ${t}Storage.`,()=>e[t]().getItem(n))??null}function o(e,t,n,r,i){i.guard(`storage.unavailable`,`The library could not write to ${t}Storage.`,()=>{e[t]().setItem(n,r)})}function s(n,r=t){let s=i(n),c=Date.now(),l=i(n),u=a(r,`local`,e.Qt,n);if(u)try{let e=JSON.parse(u);e.id&&c-(e.lastSeenAt??0)<18e5&&(l=e.id)}catch{n.report(`storage.degraded`,`The session record is not valid JSON. The library starts a new session.`)}let d=JSON.stringify({id:l,lastSeenAt:c});o(r,`local`,e.Qt,d,n);let f=a(r,`session`,`ui-observability.tab`,n)??``;return f||(f=i(n),o(r,`session`,e.ln,f,n)),{sessionId:l,tabId:f,contextId:s}}function c(t,n,r){o(r,`session`,e.ln,t,n)}var l=class{diagnostics;stores;lastTouchAt=0;constructor(e,n=t){this.diagnostics=e,this.stores=n}touch(t){let n=Date.now();if(n-this.lastTouchAt<6e4)return;this.lastTouchAt=n;let r=JSON.stringify({id:t,lastSeenAt:n});o(this.stores,`local`,e.Qt,r,this.diagnostics)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
2
+ //# sourceMappingURL=identity-B1GDS1Tb.cjs.map