@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
@@ -5,9 +5,16 @@ import type { LogSerializer } from "./serializer";
5
5
  export type StorageStrategy = "auto" | "indexeddb" | "localstorage" | "memory" | "none";
6
6
  /** Selects where the library keeps session, tab and journey ids. "storage" uses browser storage. "memory" writes nothing. */
7
7
  export type IdentityStrategy = "storage" | "memory";
8
- /** What this context does with its records: `sender` delivers its own, `forwarder` hands them to another context, `auto` decides, `off` does neither. */
8
+ /**
9
+ * What this context does with its records. `sender` delivers its own records.
10
+ * `forwarder` gives them to another context. `auto` selects a role at startup.
11
+ * `off` turns off the bus. The context then delivers its own records.
12
+ */
9
13
  export type BusMode = "auto" | "sender" | "forwarder" | "off";
10
- /** Structural type for the `web-vitals` package's metric shape, so this library has no hard dependency on the package. */
14
+ /**
15
+ * Structural type for the metric shape of the `web-vitals` package. With this type,
16
+ * the library has no hard dependency on the package.
17
+ */
11
18
  export interface WebVitalsMetric {
12
19
  /** Measurement value, in the metric's own unit. */
13
20
  value: number;
@@ -67,8 +74,8 @@ export interface OtelSpan {
67
74
  spanContext(): OtelSpanContext;
68
75
  }
69
76
  /**
70
- * The three `@opentelemetry/api` entry points this library uses, typed
71
- * structurally so the package stays an optional peer.
77
+ * The three `@opentelemetry/api` entry points that this library uses. The structural
78
+ * types keep the package an optional peer.
72
79
  */
73
80
  export interface OtelApi {
74
81
  /** Span lookup. */
@@ -83,7 +90,7 @@ export interface OtelApi {
83
90
  context: {
84
91
  /**
85
92
  * Reads the active context.
86
- * @returns Context, opaque to this library, understood by the propagator.
93
+ * @returns Context object that only the propagator reads.
87
94
  */
88
95
  active(): unknown;
89
96
  };
@@ -102,7 +109,7 @@ export interface OtelApi {
102
109
  * @returns A promise resolving to the module.
103
110
  */
104
111
  export type OtelLoader = () => Promise<OtelApi>;
105
- /** Sampling policy: which records survive. */
112
+ /** Sampling policy. It controls which records the library keeps. */
106
113
  export interface SamplingOptions {
107
114
  /**
108
115
  * Default fraction of records kept, 0 to 1.
@@ -110,7 +117,7 @@ export interface SamplingOptions {
110
117
  */
111
118
  defaultRate: number;
112
119
  /**
113
- * Per-namespace override, keyed by `app.namespace`. Most specific prefix wins.
120
+ * Rate override for each namespace, keyed by `app.namespace`. The most specific prefix applies.
114
121
  * @default {}
115
122
  */
116
123
  rates: Record<string, number>;
@@ -120,7 +127,7 @@ export interface SamplingOptions {
120
127
  */
121
128
  alwaysSampleTypes: string[];
122
129
  }
123
- /** Bus settings: how this context discovers, trusts, and messages the others. */
130
+ /** Bus settings. They control how this context finds, trusts, and sends messages to others. */
124
131
  export interface BusOptions {
125
132
  /**
126
133
  * This context's role.
@@ -128,20 +135,23 @@ export interface BusOptions {
128
135
  */
129
136
  mode: BusMode;
130
137
  /**
131
- * Origins allowed to send postMessage records to this document. Required for any document receiving them from a cross-origin iframe.
138
+ * Origins that can send postMessage records to this document.
139
+ * A document that gets records from a cross-origin iframe must list the iframe origin.
132
140
  * @default []
133
141
  */
134
142
  trustedOrigins: string[];
135
143
  /**
136
- * Which OpenFin context this is. Only the platform provider answers a
137
- * handshake, so setting this wrong makes every view send for itself.
138
- * "auto" treats the window whose name equals its application uuid as the
139
- * provider.
144
+ * Which OpenFin context this is. Only the platform provider answers a handshake.
145
+ * With an incorrect value, each view sends its own records. "auto" treats the
146
+ * window whose name equals its application uuid as the provider.
140
147
  * @default "auto"
141
148
  */
142
149
  openFinRole: "auto" | "provider" | "client";
143
150
  }
144
- /** What the library instruments automatically. Everything but errors and rejections is off by default. */
151
+ /**
152
+ * What the library instruments automatically. By default, only `errors` and `rejections`
153
+ * are on.
154
+ */
145
155
  export interface CaptureOptions {
146
156
  /**
147
157
  * Log uncaught errors from `window.onerror`.
@@ -159,7 +169,7 @@ export interface CaptureOptions {
159
169
  */
160
170
  resourceErrors: boolean;
161
171
  /**
162
- * Wrap `fetch` to log requests. The ingest endpoint itself is never logged.
172
+ * Wrap `fetch` to log requests. The library never logs requests to the ingest endpoint.
163
173
  * @default false
164
174
  */
165
175
  fetch: boolean;
@@ -179,23 +189,24 @@ export interface CaptureOptions {
179
189
  */
180
190
  navigation: boolean;
181
191
  /**
182
- * Report web vitals as metrics. Requires `webVitalsLoader`.
192
+ * Report web vitals as metrics. This option requires `webVitalsLoader`.
183
193
  * @default false
184
194
  */
185
195
  webVitals: boolean;
186
196
  /**
187
197
  * Keep the query string and fragment on every URL the library records.
188
- * Off strips them from page URLs, request targets and failed resource URLs.
198
+ * When off, the library removes them from page URLs, request targets and failed resource URLs.
189
199
  * @default false
190
200
  */
191
201
  fullUrls: boolean;
192
202
  /**
193
- * URLs excluded from logging. The ingest endpoint is always included.
203
+ * URLs that the library does not log. The library always adds the ingest endpoint.
194
204
  * @default []
195
205
  */
196
206
  ignoreUrls: (string | RegExp)[];
197
207
  /**
198
- * Targets that receive a `traceparent` header. A catch-all breaks CORS on third-party endpoints.
208
+ * Targets that receive a `traceparent` header. A pattern that matches all URLs breaks
209
+ * CORS on third-party endpoints.
199
210
  * @default []
200
211
  */
201
212
  propagateTraceHeaderTo: (string | RegExp)[];
@@ -207,28 +218,32 @@ export interface CaptureOptions {
207
218
  }
208
219
  /** Serializer option after resolution. A name stays a name. The transport selects the implementation. */
209
220
  export type SerializerChoice = "otlp" | "ecs" | LogSerializer;
210
- /** Console mirroring. `false` is off, `true` mirrors from DEBUG, a level mirrors from that level up. */
221
+ /**
222
+ * Console mirroring. `false` turns it off. `true` mirrors records at DEBUG and above.
223
+ * A level mirrors records at that level and above.
224
+ */
211
225
  export type ConsoleOption = boolean | LogLevel;
212
226
  /** Options passed to `configure()`. */
213
227
  export interface ObservabilityConfig {
214
228
  /**
215
229
  * Ingest endpoint URL. Set `null` for console-only mode.
216
- * In console-only mode, the library sends nothing. It writes records to the console if `console` is set.
230
+ * In console-only mode, the library sends nothing. It writes records to the console
231
+ * if you set `console`.
217
232
  * If the key is missing or `""`, the library reports `config.invalid`.
218
233
  */
219
234
  endpoint?: string | null;
220
235
  /**
221
- * Reported as `service.name`.
236
+ * The library reports this value as `service.name`.
222
237
  * @default ""
223
238
  */
224
239
  serviceName?: string;
225
240
  /**
226
- * Reported as `service.version`.
241
+ * The library reports this value as `service.version`.
227
242
  * @default ""
228
243
  */
229
244
  serviceVersion?: string;
230
245
  /**
231
- * Reported as `deployment.environment`.
246
+ * The library reports this value as `deployment.environment`.
232
247
  * @default ""
233
248
  */
234
249
  environment?: string;
@@ -238,22 +253,24 @@ export interface ObservabilityConfig {
238
253
  */
239
254
  enabled?: boolean;
240
255
  /**
241
- * Min level logged.
256
+ * Minimum level that the library logs.
242
257
  * @default "INFO"
243
258
  */
244
259
  minLevel?: LogLevel;
245
260
  /**
246
- * Whether to gzip a payload past the compression threshold. Set "none" for an ingest endpoint that rejects gzip.
261
+ * Whether to gzip a payload that is larger than the compression threshold.
262
+ * Set "none" for an ingest endpoint that rejects gzip.
247
263
  * @default "gzip"
248
264
  */
249
265
  compression?: "gzip" | "none";
250
266
  /**
251
- * Wire format: a name, or a custom implementation.
267
+ * Payload format. Give a name or a custom implementation.
252
268
  * @default "otlp"
253
269
  */
254
270
  serializer?: SerializerChoice;
255
271
  /**
256
- * Passed to `fetch`. Set "include" for an ingest endpoint that authenticates with cookies.
272
+ * The library passes this value to `fetch`. Set "include" for an ingest endpoint that
273
+ * authenticates with cookies.
257
274
  * @default "omit"
258
275
  */
259
276
  credentials?: RequestCredentials;
@@ -299,8 +316,8 @@ export interface ObservabilityConfig {
299
316
  */
300
317
  otelLoader?: OtelLoader;
301
318
  /**
302
- * Rewrites or drops a record before it's sent.
303
- * @param record The record about to be sent.
319
+ * Rewrites or drops a record before the library sends it.
320
+ * @param record The record that the library is about to send.
304
321
  * @returns The record to send, or `null` to drop it.
305
322
  */
306
323
  redact?: (record: LogRecord) => LogRecord | null;
@@ -310,23 +327,23 @@ export interface ObservabilityConfig {
310
327
  */
311
328
  onDiagnostic?: DiagnosticHandler;
312
329
  }
313
- /** Fully resolved config, held by the runtime. */
330
+ /** Fully resolved configuration that the runtime holds. */
314
331
  export interface ResolvedConfig {
315
332
  /** Ingest endpoint URL, or null in console-only mode. */
316
333
  endpoint: string | null;
317
- /** Reported as `service.name`. */
334
+ /** The library reports this value as `service.name`. */
318
335
  serviceName: string;
319
- /** Reported as `service.version`. */
336
+ /** The library reports this value as `service.version`. */
320
337
  serviceVersion: string;
321
- /** Reported as `deployment.environment`. */
338
+ /** The library reports this value as `deployment.environment`. */
322
339
  environment: string;
323
340
  /** Master switch. False makes every log call a no-op. */
324
341
  enabled: boolean;
325
- /** Min level logged. */
342
+ /** Minimum level that the library logs. */
326
343
  minLevel: LogLevel;
327
- /** Whether to gzip a payload past the compression threshold. */
344
+ /** Whether to gzip a payload that is larger than the compression threshold. */
328
345
  compression: "gzip" | "none";
329
- /** Passed to `fetch`. */
346
+ /** The library passes this value to `fetch`. */
330
347
  credentials: RequestCredentials;
331
348
  /** Backing store for undelivered records. */
332
349
  storage: StorageStrategy;
@@ -347,17 +364,17 @@ export interface ResolvedConfig {
347
364
  * @see {@link CaptureOptions}
348
365
  */
349
366
  capture: CaptureOptions;
350
- /** Min level mirrored to the console, or null when mirroring is off. */
367
+ /** Minimum level that the library mirrors to the console, or null when mirroring is off. */
351
368
  console: LogLevel | null;
352
- /** Wire format name, or a custom implementation. */
369
+ /** Payload format name, or a custom implementation. */
353
370
  serializer: SerializerChoice;
354
371
  /** Extra request headers, or a function returning them. */
355
372
  headers?: ObservabilityConfig["headers"];
356
373
  /** Supplies the `@opentelemetry/api` module in place of importing it. */
357
374
  otelLoader?: OtelLoader;
358
375
  /**
359
- * Rewrites or drops a record before it's sent.
360
- * @param record The record about to be sent.
376
+ * Rewrites or drops a record before the library sends it.
377
+ * @param record The record that the library is about to send.
361
378
  * @returns The record to send, or `null` to drop it.
362
379
  */
363
380
  redact?: ObservabilityConfig["redact"];
@@ -8,20 +8,23 @@ export type LogLevel = "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL";
8
8
  export type LogType = "action" | "event" | "metric" | "system";
9
9
  /** Metric value type: level, running total, or distribution. */
10
10
  export type MetricType = "gauge" | "counter" | "histogram";
11
- /** Internal record shape, converted to wire format by a serializer. */
11
+ /** Internal record shape. A serializer converts it to the payload format. */
12
12
  export interface LogRecord {
13
13
  /**
14
14
  * Event time, nanoseconds since epoch, as a decimal string.
15
15
  * @see {@link nowUnixNano}
16
16
  */
17
17
  timeUnixNano: string;
18
- /** Time this library received the event, if different from `timeUnixNano` (e.g. on a forwarded record). */
18
+ /**
19
+ * Time when this library received the event, if it differs from `timeUnixNano`.
20
+ * For example, a forwarded record can have a different time.
21
+ */
19
22
  observedTimeUnixNano?: string;
20
23
  /** Distributed trace id. */
21
24
  traceId: string;
22
25
  /** Span id within the trace. */
23
26
  spanId: string;
24
- /** OpenTelemetry trace flags. Only the sampled bit is used. */
27
+ /** OpenTelemetry trace flags. The library uses only the sampled bit. */
25
28
  traceFlags: number;
26
29
  /** OpenTelemetry severity number for `severityText`. */
27
30
  severityNumber: number;
@@ -36,18 +39,17 @@ export interface LogRecord {
36
39
  }
37
40
  /**
38
41
  * Returns the current time as a Unix nanosecond timestamp.
39
- * Concatenates rather than multiplies: `Date.now() * 1e6` overflows
40
- * `Number.MAX_SAFE_INTEGER` and silently corrupts digits. Trailing zeros are
41
- * unknown precision, not real.
42
+ * The function appends zeros and does not multiply. `Date.now() * 1e6` is larger
43
+ * than `Number.MAX_SAFE_INTEGER` and corrupts digits without an error. The trailing
44
+ * zeros show unknown precision. They are not measured digits.
42
45
  * @returns Epoch timestamp in nanoseconds, as a decimal string.
43
46
  */
44
47
  export declare function nowUnixNano(): string;
45
48
  /**
46
49
  * Checks whether a value has the shape `LogRecord` requires.
47
- * Used to validate records arriving from another realm, since a malformed
48
- * one throws during serialization. `severityText` is checked as a string,
49
- * not a known level, so an unrecognised level from a newer version still
50
- * passes.
50
+ * Use it to validate records from another realm. A malformed record throws
51
+ * during serialization. The check accepts any string as `severityText`, not only
52
+ * a known level. Thus an unknown level from a newer version passes.
51
53
  * @param value The value to check.
52
54
  * @returns Whether `value` has the shape `LogRecord` requires.
53
55
  */
@@ -14,8 +14,9 @@ export interface LogSerializer {
14
14
  /** Serializer name used in configuration. */
15
15
  name: string;
16
16
  /**
17
- * Serializes a batch of records to wire-format bytes.
18
- * Called once per delivery attempt, not once per batch, so a retry re-encodes.
17
+ * Serializes a batch of records to payload bytes.
18
+ * The transport calls it one time for each delivery attempt, not one time for each batch.
19
+ * Thus each retry encodes the records again.
19
20
  * @param records Batch records, in log order.
20
21
  * @returns Serialized batch ready for transport.
21
22
  */
@@ -15,7 +15,7 @@ export interface StorageAdapter {
15
15
  */
16
16
  take(limit: number): Promise<LogBatch[]>;
17
17
  /**
18
- * Removes a batch by ID. Non-existent IDs resolve without error.
18
+ * Removes a batch by ID. A call with an unknown ID resolves without error.
19
19
  * @param id Batch identifier.
20
20
  */
21
21
  remove(id: string): Promise<void>;
@@ -52,7 +52,7 @@ export interface PruneResult {
52
52
  batches: number;
53
53
  /** Total records dropped within evicted batches. */
54
54
  records: number;
55
- /** Eviction reason that triggered the prune. If more than one rule fired, this is the last one. */
55
+ /** Eviction reason for the prune. If more than one rule applies, this is the last rule. */
56
56
  reason: "expired" | "over_capacity" | "quota";
57
57
  }
58
58
  /**
@@ -1,4 +1,4 @@
1
- import { r as e } from "./platform-DMYo3AX3.js";
1
+ import { r as e } from "./platform-CY8S3hUs.js";
2
2
  //#region src/capture/types.ts
3
3
  function t(e, t) {
4
4
  return t.some((t) => typeof t == "string" ? e.includes(t) : t.test(e));
@@ -52,7 +52,7 @@ var r = class {
52
52
  };
53
53
  }
54
54
  } catch (e) {
55
- l = a, u = o, n.diagnostics.report("capture.header_failed", "could not attach traceparent, sending the request unchanged", { url: s }, e);
55
+ l = a, u = o, n.diagnostics.report("capture.header_failed", "The library could not add the traceparent header. It sends the request unchanged.", { url: s }, e);
56
56
  }
57
57
  let d = performance.now();
58
58
  try {
@@ -87,7 +87,7 @@ var r = class {
87
87
  }
88
88
  record(t, n, r, i, a) {
89
89
  let o = this.ctx.config.capture.fullUrls ? n : e(n);
90
- this.ctx.diagnostics.guard("capture.record_failed", `recording ${t} ${o}`, () => {
90
+ this.ctx.diagnostics.guard("capture.record_failed", `The library could not record ${t} ${o}.`, () => {
91
91
  let e = Math.round(i);
92
92
  this.ctx.breadcrumbs.push({
93
93
  t: Date.now(),
@@ -108,4 +108,4 @@ var r = class {
108
108
  //#endregion
109
109
  export { r as NetworkCapture };
110
110
 
111
- //# sourceMappingURL=network-au-Tqt1n.js.map
111
+ //# sourceMappingURL=network-C4d2uw2Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-C4d2uw2Z.js","names":["stripUrlQuery","matchesAny","patterns","pattern","url","xhrMethods","NetworkCapture","ctx","original","ignored","record","method","status","durationMs","error","input","init","fetchInput","fetchInit","injected","headers","key","value","startedAt","response","proto","originalOpen","originalSend","rest","args","meta","target","rounded","attributes"],"sources":["../src/capture/types.ts","../src/capture/network.ts"],"sourcesContent":["// src/capture/types.ts\n//\n// Shared interfaces, logger abstractions, and utility helpers for auto-capture modules.\n\nimport type { BreadcrumbBuffer } from \"../core/breadcrumbs\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { MetricType } from \"../models/log-record\";\nimport type { TraceEngine } from \"../utils/tracing\";\n\n/**\n * Logging interface that auto-capture modules use. A reference to the runtime class\n * here causes an import cycle. The runtime installs the capture modules.\n */\nexport interface CaptureLogger {\n /**\n * Logs an error event with an associated error instance or reason.\n * @param message Error description.\n * @param error Caught error instance or reason.\n * @param payload Optional attributes.\n */\n error(message: string, error?: unknown, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a warning event.\n * @param message Warning description.\n * @param payload Optional attributes.\n */\n warn(message: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a discrete lifecycle or user event.\n * @param name Event identifier.\n * @param payload Optional attributes.\n */\n logEvent(name: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a numerical metric measurement.\n * @param name Metric name.\n * @param value Numerical measurement.\n * @param unit Unit of measurement.\n * @param type Metric type classification.\n * @param attrs Optional metric attributes.\n */\n logMetric(\n name: string,\n value: number,\n unit?: string,\n type?: MetricType,\n attrs?: Record<string, unknown>,\n ): void;\n\n /**\n * Logs a diagnostic debug message.\n * @param message Debug message.\n * @param payload Optional attributes.\n */\n debug(message: string, payload?: Record<string, unknown>): void;\n}\n\n/**\n * Capture work that runs one time for each document, not one time for each\n * install. A reconfigure builds new capture instances. Thus instance state\n * cannot hold these flags. web-vitals has no unsubscribe. A second subscription\n * reports each metric two times.\n */\nexport interface CaptureOnce {\n /** True after the library subscribes the web-vitals reporters. */\n webVitals: boolean;\n /** True after the library reports navigation timing. */\n navigationTiming: boolean;\n}\n\n/** Shared runtime dependencies provided to auto-capture instances. */\nexport interface CaptureContext {\n /** Active runtime configuration. */\n config: ResolvedConfig;\n /** Diagnostics reporter for capture faults. */\n diagnostics: Diagnostics;\n /** Logger instance for recorded telemetry. */\n logger: CaptureLogger;\n /** Buffer for recording contextual breadcrumbs. */\n breadcrumbs: BreadcrumbBuffer;\n /** Active trace context provider. */\n tracing: TraceEngine;\n /** Guards for the capture work that a reinstall must not repeat. */\n once: CaptureOnce;\n}\n\n/** Lifecycle interface for browser instrumentation modules. */\nexport interface Capture {\n /** Module identifier used in diagnostics. */\n readonly name: string;\n /**\n * Attaches instrumentation listeners and patches target APIs. A second patch on a\n * patched function adds a second wrapper and doubles each record. A second call\n * must do nothing.\n */\n install(): void;\n /** Restores native APIs and removes registered listeners. */\n uninstall(): void;\n}\n\n/**\n * Evaluates whether a URL matches any string substring or regular expression pattern.\n * @param url Target URL to test.\n * @param patterns Substrings and regular expressions to test against.\n * @returns True if any pattern matches the URL.\n */\nexport function matchesAny(url: string, patterns: (string | RegExp)[]): boolean {\n return patterns.some((pattern) =>\n typeof pattern === \"string\" ? url.includes(pattern) : pattern.test(url),\n );\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record network request outcomes and timing.\n\nimport { stripUrlQuery } from \"../utils/platform\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** XMLHttpRequest extended with internal telemetry tracking metadata. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: { method: string; url: string; startedAt: number };\n};\n\n/** Unbound prototype methods intercepted on XMLHttpRequest. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Original uninstrumented fetch implementation. */\n private originalFetch: FetchFn | null = null;\n\n /** Original uninstrumented XMLHttpRequest.open implementation. */\n private originalOpen: XhrMethods[\"open\"] | null = null;\n\n /** Original uninstrumented XMLHttpRequest.send implementation. */\n private originalSend: XhrMethods[\"send\"] | null = null;\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, breadcrumbs, and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments configured network transport APIs. */\n install(): void {\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /** Restores native network transport implementations and clears references. */\n uninstall(): void {\n if (this.originalFetch) {\n globalThis.fetch = this.originalFetch;\n this.originalFetch = null;\n }\n if (this.originalOpen) {\n xhrMethods().open = this.originalOpen;\n this.originalOpen = null;\n }\n if (this.originalSend) {\n xhrMethods().send = this.originalSend;\n this.originalSend = null;\n }\n }\n\n /**\n * Evaluates whether a URL matches ignore patterns.\n * @param url Request target URL.\n * @returns True if telemetry must exclude the URL.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Without it, a failed POST\n // makes a log record. That record causes a new POST, and the loop does not stop.\n return matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /** Instruments globalThis.fetch with tracing injection and outcome logging. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\" || this.originalFetch) {\n return;\n }\n\n const original = globalThis.fetch.bind(globalThis);\n this.originalFetch = globalThis.fetch;\n\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const record = (\n method: string,\n url: string,\n status: number,\n durationMs: number,\n error: unknown,\n ): void => {\n this.record(method, url, status, durationMs, error);\n };\n\n globalThis.fetch = async function instrumentedFetch(input, init) {\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n const requested = init?.method ?? (input instanceof Request ? input.method : \"GET\");\n const method = requested.toUpperCase();\n\n if (ignored(url)) {\n return original(input, init);\n }\n\n let fetchInput = input;\n let fetchInit = init;\n\n // Add headers only to allowlisted URLs. A traceparent on a third-party request causes\n // a CORS preflight. The third party does not answer it, and its API stops working.\n if (matchesAny(url, ctx.config.capture.propagateTraceHeaderTo)) {\n try {\n const injected = Object.entries(ctx.tracing.headers());\n\n if (input instanceof Request) {\n // Do not spread a non-empty init with a Request input. That runs the Request\n // constructor on `input` again and reads its body. A body that was read\n // before causes a TypeError.\n const headers = new Headers(input.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n fetchInput = new Request(input, { headers });\n } else {\n const headers = new Headers(init?.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n fetchInit = { ...init, headers };\n }\n } catch (error) {\n // Send the request that the caller gave, without changes. A missing header is\n // better than a failed request.\n fetchInput = input;\n fetchInit = init;\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n }\n\n const startedAt = performance.now();\n try {\n const response = await original(fetchInput, fetchInit);\n record(method, url, response.status, performance.now() - startedAt, undefined);\n return response;\n } catch (error) {\n record(method, url, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n }\n\n /** Instruments XMLHttpRequest open and send prototype methods. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\" || this.originalOpen) {\n return;\n }\n\n const ignored = (url: string): boolean => this.ignored(url);\n const record = (method: string, url: string, status: number, durationMs: number): void => {\n this.record(method, url, status, durationMs, undefined);\n };\n\n const proto = xhrMethods();\n const originalOpen = proto.open;\n const originalSend = proto.send;\n this.originalOpen = originalOpen;\n this.originalSend = originalSend;\n\n proto.open = function (this: Tracked, method: string, url: string | URL, ...rest: never[]) {\n this.__uiobs = {\n method: method.toUpperCase(),\n url: String(url),\n startedAt: 0,\n };\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n };\n\n proto.send = function (this: Tracked, ...args: never[]) {\n const meta = this.__uiobs;\n if (meta && !ignored(meta.url)) {\n meta.startedAt = performance.now();\n this.addEventListener(\"loadend\", () => {\n record(meta.method, meta.url, this.status, performance.now() - meta.startedAt);\n });\n }\n originalSend.apply(this, args);\n };\n }\n\n /**\n * Records request outcome attributes and breadcrumb entry.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The method removes the query unless fullUrls is set.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error Caught error instance on failed requests.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n ): void {\n // Remove the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL. Only the recorded URL loses the query string.\n const url = this.ctx.config.capture.fullUrls ? target : stripUrlQuery(target);\n\n // This code runs inside the fetch call of the caller. An error here must not cause\n // the request of the caller to fail.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG. The default minLevel of INFO drops it.\n // Only failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n"],"mappings":";;AA8GA,SAAgBC,EAAW,GAAa,GAAwC;CAC9E,OAAOC,EAAS,MAAM,MACpB,OAAOC,KAAY,WAAWC,EAAI,SAASD,CAAO,IAAIA,EAAQ,KAAKC,CAAG,CACxE;AACF;;;AC5FA,SAASC,IAAyB;CAChC,OAAO,eAAe;AACxB;AAGA,IAAaC,IAAb,MAA+C;CAgBhB;CAd7B,OAAgB;CAGhB,gBAAwC;CAGxC,eAAkD;CAGlD,eAAkD;CAKlD,YAAY,GAAsC;EAArB,KAAA,MAAAC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C,GAAe;GACtD,IAAMC,IAAO,KAAK;GAOlB,AANIA,KAAQ,CAACrB,EAAQqB,EAAK,GAAG,MAC3B,EAAK,YAAY,YAAY,IAAI,GACjC,KAAK,iBAAiB,iBAAiB;IACrC,EAAOA,EAAK,QAAQA,EAAK,KAAK,KAAK,QAAQ,YAAY,IAAI,IAAIA,EAAK,SAAS;GAC/E,CAAC,IAEHH,EAAa,MAAM,MAAME,CAAI;EAC/B;CACF;CAUA,OACE,GACA,GACA,GACA,GACA,GACM;EAGN,IAAMzB,IAAM,KAAK,IAAI,OAAO,QAAQ,WAAW2B,IAAS/B,EAAc+B,CAAM;EAI5E,KAAK,IAAI,YAAY,MACnB,yBACA,gCAAgCpB,EAAO,GAAGP,EAAI,UACxC;GACJ,IAAM4B,IAAU,KAAK,MAAMnB,CAAU;GAErC,KAAK,IAAI,YAAY,KAAK;IACxB,GAAG,KAAK,IAAI;IACZ,UAAU;IACV,SAAS,GAAGF,EAAO,GAAGP,EAAI,GAAGQ,MAAW,IAAI,WAAW,OAAOA,CAAM;IACpE,MAAM,EAAE,YAAYoB,EAAQ;GAC9B,CAAC;GAED,IAAMC,IAAa;IACjB,uBAAuBtB;IACvB,YAAYP;IACZ,6BAA6BQ;IAC7B,oBAAoBoB;GACtB;GAEA,AAAIpB,MAAW,IACb,KAAK,IAAI,OAAO,MAAM,GAAGD,EAAO,GAAGP,EAAI,UAAUU,GAAOmB,CAAU,IAGhErB,KAAU,MACZ,KAAK,IAAI,OAAO,KAAK,GAAGD,EAAO,GAAGP,EAAI,YAAY,OAAOQ,CAAM,KAAKqB,CAAU,IAMhF,KAAK,IAAI,OAAO,MAAM,GAAGtB,EAAO,GAAGP,KAAO6B,CAAU;EACtD,CACF;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("./platform-CXio0W2n.cjs");function t(e,t){return t.some(t=>typeof t==`string`?e.includes(t):t.test(e))}function n(){return XMLHttpRequest.prototype}var r=class{ctx;name=`network`;originalFetch=null;originalOpen=null;originalSend=null;constructor(e){this.ctx=e}install(){this.ctx.config.capture.fetch&&this.installFetch(),this.ctx.config.capture.xhr&&this.installXhr()}uninstall(){this.originalFetch&&=(globalThis.fetch=this.originalFetch,null),this.originalOpen&&=(n().open=this.originalOpen,null),this.originalSend&&=(n().send=this.originalSend,null)}ignored(e){return t(e,this.ctx.config.capture.ignoreUrls)}installFetch(){if(typeof globalThis.fetch!=`function`||this.originalFetch)return;let e=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;let n=this.ctx,r=e=>this.ignored(e),i=(e,t,n,r,i)=>{this.record(e,t,n,r,i)};globalThis.fetch=async function(a,o){let s=typeof a==`string`?a:a instanceof URL?a.href:a.url,c=(o?.method??(a instanceof Request?a.method:`GET`)).toUpperCase();if(r(s))return e(a,o);let l=a,u=o;if(t(s,n.config.capture.propagateTraceHeaderTo))try{let e=Object.entries(n.tracing.headers());if(a instanceof Request){let t=new Headers(a.headers);for(let[n,r]of e)t.set(n,r);l=new Request(a,{headers:t})}else{let t=new Headers(o?.headers);for(let[n,r]of e)t.set(n,r);u={...o,headers:t}}}catch(e){l=a,u=o,n.diagnostics.report(`capture.header_failed`,`The library could not add the traceparent header. It sends the request unchanged.`,{url:s},e)}let d=performance.now();try{let t=await e(l,u);return i(c,s,t.status,performance.now()-d,void 0),t}catch(e){throw i(c,s,0,performance.now()-d,e),e}}}installXhr(){if(typeof XMLHttpRequest>`u`||this.originalOpen)return;let e=e=>this.ignored(e),t=(e,t,n,r)=>{this.record(e,t,n,r,void 0)},r=n(),i=r.open,a=r.send;this.originalOpen=i,this.originalSend=a,r.open=function(e,t,...n){this.__uiobs={method:e.toUpperCase(),url:String(t),startedAt:0},i.apply(this,[e,t,...n])},r.send=function(...n){let r=this.__uiobs;r&&!e(r.url)&&(r.startedAt=performance.now(),this.addEventListener(`loadend`,()=>{t(r.method,r.url,this.status,performance.now()-r.startedAt)})),a.apply(this,n)}}record(t,n,r,i,a){let o=this.ctx.config.capture.fullUrls?n:e.r(n);this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record ${t} ${o}.`,()=>{let e=Math.round(i);this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`${t} ${o} ${r===0?`failed`:String(r)}`,data:{durationMs:e}});let n={"http.request.method":t,"url.full":o,"http.response.status_code":r,"http.duration_ms":e};r===0?this.ctx.logger.error(`${t} ${o} failed`,a,n):r>=400?this.ctx.logger.warn(`${t} ${o} returned ${String(r)}`,n):this.ctx.logger.debug(`${t} ${o}`,n)})}};exports.NetworkCapture=r;
2
+ //# sourceMappingURL=network-CuqWadNn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-CuqWadNn.cjs","names":["stripUrlQuery","require_platform","matchesAny","patterns","pattern","url","xhrMethods","NetworkCapture","ctx","original","ignored","record","method","status","durationMs","error","input","init","fetchInput","fetchInit","injected","headers","key","value","startedAt","response","proto","originalOpen","originalSend","rest","args","meta","target","rounded","attributes"],"sources":["../src/capture/types.ts","../src/capture/network.ts"],"sourcesContent":["// src/capture/types.ts\n//\n// Shared interfaces, logger abstractions, and utility helpers for auto-capture modules.\n\nimport type { BreadcrumbBuffer } from \"../core/breadcrumbs\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { MetricType } from \"../models/log-record\";\nimport type { TraceEngine } from \"../utils/tracing\";\n\n/**\n * Logging interface that auto-capture modules use. A reference to the runtime class\n * here causes an import cycle. The runtime installs the capture modules.\n */\nexport interface CaptureLogger {\n /**\n * Logs an error event with an associated error instance or reason.\n * @param message Error description.\n * @param error Caught error instance or reason.\n * @param payload Optional attributes.\n */\n error(message: string, error?: unknown, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a warning event.\n * @param message Warning description.\n * @param payload Optional attributes.\n */\n warn(message: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a discrete lifecycle or user event.\n * @param name Event identifier.\n * @param payload Optional attributes.\n */\n logEvent(name: string, payload?: Record<string, unknown>): void;\n\n /**\n * Logs a numerical metric measurement.\n * @param name Metric name.\n * @param value Numerical measurement.\n * @param unit Unit of measurement.\n * @param type Metric type classification.\n * @param attrs Optional metric attributes.\n */\n logMetric(\n name: string,\n value: number,\n unit?: string,\n type?: MetricType,\n attrs?: Record<string, unknown>,\n ): void;\n\n /**\n * Logs a diagnostic debug message.\n * @param message Debug message.\n * @param payload Optional attributes.\n */\n debug(message: string, payload?: Record<string, unknown>): void;\n}\n\n/**\n * Capture work that runs one time for each document, not one time for each\n * install. A reconfigure builds new capture instances. Thus instance state\n * cannot hold these flags. web-vitals has no unsubscribe. A second subscription\n * reports each metric two times.\n */\nexport interface CaptureOnce {\n /** True after the library subscribes the web-vitals reporters. */\n webVitals: boolean;\n /** True after the library reports navigation timing. */\n navigationTiming: boolean;\n}\n\n/** Shared runtime dependencies provided to auto-capture instances. */\nexport interface CaptureContext {\n /** Active runtime configuration. */\n config: ResolvedConfig;\n /** Diagnostics reporter for capture faults. */\n diagnostics: Diagnostics;\n /** Logger instance for recorded telemetry. */\n logger: CaptureLogger;\n /** Buffer for recording contextual breadcrumbs. */\n breadcrumbs: BreadcrumbBuffer;\n /** Active trace context provider. */\n tracing: TraceEngine;\n /** Guards for the capture work that a reinstall must not repeat. */\n once: CaptureOnce;\n}\n\n/** Lifecycle interface for browser instrumentation modules. */\nexport interface Capture {\n /** Module identifier used in diagnostics. */\n readonly name: string;\n /**\n * Attaches instrumentation listeners and patches target APIs. A second patch on a\n * patched function adds a second wrapper and doubles each record. A second call\n * must do nothing.\n */\n install(): void;\n /** Restores native APIs and removes registered listeners. */\n uninstall(): void;\n}\n\n/**\n * Evaluates whether a URL matches any string substring or regular expression pattern.\n * @param url Target URL to test.\n * @param patterns Substrings and regular expressions to test against.\n * @returns True if any pattern matches the URL.\n */\nexport function matchesAny(url: string, patterns: (string | RegExp)[]): boolean {\n return patterns.some((pattern) =>\n typeof pattern === \"string\" ? url.includes(pattern) : pattern.test(url),\n );\n}\n","// src/capture/network.ts\n//\n// Instruments fetch and XMLHttpRequest to record network request outcomes and timing.\n\nimport { stripUrlQuery } from \"../utils/platform\";\nimport { type Capture, type CaptureContext, matchesAny } from \"./types\";\n\n/** Signature of the global fetch function. */\ntype FetchFn = typeof fetch;\n\n/** XMLHttpRequest extended with internal telemetry tracking metadata. */\ntype Tracked = XMLHttpRequest & {\n __uiobs?: { method: string; url: string; startedAt: number };\n};\n\n/** Unbound prototype methods intercepted on XMLHttpRequest. */\ninterface XhrMethods {\n open: (this: XMLHttpRequest, ...args: never[]) => void;\n send: (this: XMLHttpRequest, ...args: never[]) => void;\n}\n\n/** Returns the XMLHttpRequest prototype. */\nfunction xhrMethods(): XhrMethods {\n return XMLHttpRequest.prototype;\n}\n\n/** Instruments global fetch and XMLHttpRequest to capture request durations and outcomes. */\nexport class NetworkCapture implements Capture {\n /** Capture module identifier. */\n readonly name = \"network\";\n\n /** Original uninstrumented fetch implementation. */\n private originalFetch: FetchFn | null = null;\n\n /** Original uninstrumented XMLHttpRequest.open implementation. */\n private originalOpen: XhrMethods[\"open\"] | null = null;\n\n /** Original uninstrumented XMLHttpRequest.send implementation. */\n private originalSend: XhrMethods[\"send\"] | null = null;\n\n /**\n * @param ctx Capture context containing configuration, diagnostics, logger, breadcrumbs, and tracing.\n */\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Instruments configured network transport APIs. */\n install(): void {\n if (this.ctx.config.capture.fetch) {\n this.installFetch();\n }\n if (this.ctx.config.capture.xhr) {\n this.installXhr();\n }\n }\n\n /** Restores native network transport implementations and clears references. */\n uninstall(): void {\n if (this.originalFetch) {\n globalThis.fetch = this.originalFetch;\n this.originalFetch = null;\n }\n if (this.originalOpen) {\n xhrMethods().open = this.originalOpen;\n this.originalOpen = null;\n }\n if (this.originalSend) {\n xhrMethods().send = this.originalSend;\n this.originalSend = null;\n }\n }\n\n /**\n * Evaluates whether a URL matches ignore patterns.\n * @param url Request target URL.\n * @returns True if telemetry must exclude the URL.\n */\n private ignored(url: string): boolean {\n // resolveConfig always adds the endpoint to ignoreUrls. Without it, a failed POST\n // makes a log record. That record causes a new POST, and the loop does not stop.\n return matchesAny(url, this.ctx.config.capture.ignoreUrls);\n }\n\n /** Instruments globalThis.fetch with tracing injection and outcome logging. */\n private installFetch(): void {\n if (typeof globalThis.fetch !== \"function\" || this.originalFetch) {\n return;\n }\n\n const original = globalThis.fetch.bind(globalThis);\n this.originalFetch = globalThis.fetch;\n\n const ctx = this.ctx;\n const ignored = (url: string): boolean => this.ignored(url);\n const record = (\n method: string,\n url: string,\n status: number,\n durationMs: number,\n error: unknown,\n ): void => {\n this.record(method, url, status, durationMs, error);\n };\n\n globalThis.fetch = async function instrumentedFetch(input, init) {\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n const requested = init?.method ?? (input instanceof Request ? input.method : \"GET\");\n const method = requested.toUpperCase();\n\n if (ignored(url)) {\n return original(input, init);\n }\n\n let fetchInput = input;\n let fetchInit = init;\n\n // Add headers only to allowlisted URLs. A traceparent on a third-party request causes\n // a CORS preflight. The third party does not answer it, and its API stops working.\n if (matchesAny(url, ctx.config.capture.propagateTraceHeaderTo)) {\n try {\n const injected = Object.entries(ctx.tracing.headers());\n\n if (input instanceof Request) {\n // Do not spread a non-empty init with a Request input. That runs the Request\n // constructor on `input` again and reads its body. A body that was read\n // before causes a TypeError.\n const headers = new Headers(input.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n fetchInput = new Request(input, { headers });\n } else {\n const headers = new Headers(init?.headers);\n for (const [key, value] of injected) {\n headers.set(key, value);\n }\n fetchInit = { ...init, headers };\n }\n } catch (error) {\n // Send the request that the caller gave, without changes. A missing header is\n // better than a failed request.\n fetchInput = input;\n fetchInit = init;\n ctx.diagnostics.report(\n \"capture.header_failed\",\n \"The library could not add the traceparent header. It sends the request unchanged.\",\n { url },\n error,\n );\n }\n }\n\n const startedAt = performance.now();\n try {\n const response = await original(fetchInput, fetchInit);\n record(method, url, response.status, performance.now() - startedAt, undefined);\n return response;\n } catch (error) {\n record(method, url, 0, performance.now() - startedAt, error);\n throw error;\n }\n };\n }\n\n /** Instruments XMLHttpRequest open and send prototype methods. */\n private installXhr(): void {\n if (typeof XMLHttpRequest === \"undefined\" || this.originalOpen) {\n return;\n }\n\n const ignored = (url: string): boolean => this.ignored(url);\n const record = (method: string, url: string, status: number, durationMs: number): void => {\n this.record(method, url, status, durationMs, undefined);\n };\n\n const proto = xhrMethods();\n const originalOpen = proto.open;\n const originalSend = proto.send;\n this.originalOpen = originalOpen;\n this.originalSend = originalSend;\n\n proto.open = function (this: Tracked, method: string, url: string | URL, ...rest: never[]) {\n this.__uiobs = {\n method: method.toUpperCase(),\n url: String(url),\n startedAt: 0,\n };\n originalOpen.apply(this, [method, url, ...rest] as never[]);\n };\n\n proto.send = function (this: Tracked, ...args: never[]) {\n const meta = this.__uiobs;\n if (meta && !ignored(meta.url)) {\n meta.startedAt = performance.now();\n this.addEventListener(\"loadend\", () => {\n record(meta.method, meta.url, this.status, performance.now() - meta.startedAt);\n });\n }\n originalSend.apply(this, args);\n };\n }\n\n /**\n * Records request outcome attributes and breadcrumb entry.\n * @param method Uppercase HTTP method.\n * @param target Request target URL. The method removes the query unless fullUrls is set.\n * @param status HTTP response status code, or 0 on failure.\n * @param durationMs Request duration in milliseconds.\n * @param error Caught error instance on failed requests.\n */\n private record(\n method: string,\n target: string,\n status: number,\n durationMs: number,\n error: unknown,\n ): void {\n // Remove the query here, not at the call sites. ignoreUrls and propagateTraceHeaderTo\n // match on the full URL. Only the recorded URL loses the query string.\n const url = this.ctx.config.capture.fullUrls ? target : stripUrlQuery(target);\n\n // This code runs inside the fetch call of the caller. An error here must not cause\n // the request of the caller to fail.\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n `The library could not record ${method} ${url}.`,\n () => {\n const rounded = Math.round(durationMs);\n\n this.ctx.breadcrumbs.push({\n t: Date.now(),\n category: \"http\",\n message: `${method} ${url} ${status === 0 ? \"failed\" : String(status)}`,\n data: { durationMs: rounded },\n });\n\n const attributes = {\n \"http.request.method\": method,\n \"url.full\": url,\n \"http.response.status_code\": status,\n \"http.duration_ms\": rounded,\n };\n\n if (status === 0) {\n this.ctx.logger.error(`${method} ${url} failed`, error, attributes);\n return;\n }\n if (status >= 400) {\n this.ctx.logger.warn(`${method} ${url} returned ${String(status)}`, attributes);\n return;\n }\n\n // Log a success at DEBUG. The default minLevel of INFO drops it.\n // Only failures use bandwidth.\n this.ctx.logger.debug(`${method} ${url}`, attributes);\n },\n );\n }\n}\n"],"mappings":"2CA8GA,SAAgBE,EAAW,EAAa,EAAwC,CAC9E,OAAOC,EAAS,KAAM,GACpB,OAAOC,GAAY,SAAWC,EAAI,SAASD,CAAO,EAAIA,EAAQ,KAAKC,CAAG,CACxE,CACF,CC5FA,SAASC,GAAyB,CAChC,OAAO,eAAe,SACxB,CAGA,IAAaC,EAAb,KAA+C,CAgBhB,IAd7B,KAAgB,UAGhB,cAAwC,KAGxC,aAAkD,KAGlD,aAAkD,KAKlD,YAAY,EAAsC,CAArB,KAAA,IAAAC,CAAsB,CAGnD,SAAgB,CACV,KAAK,IAAI,OAAO,QAAQ,OAC1B,KAAK,aAAa,EAEhB,KAAK,IAAI,OAAO,QAAQ,KAC1B,KAAK,WAAW,CAEpB,CAGA,WAAkB,CAChB,AAEE,KAAK,iBADL,WAAW,MAAQ,KAAK,cACH,MAEvB,AAEE,KAAK,gBADL,EAAW,CAAC,CAAC,KAAO,KAAK,aACL,MAEtB,AAEE,KAAK,gBADL,EAAW,CAAC,CAAC,KAAO,KAAK,aACL,KAExB,CAOA,QAAgB,EAAsB,CAGpC,OAAON,EAAWG,EAAK,KAAK,IAAI,OAAO,QAAQ,UAAU,CAC3D,CAGA,cAA6B,CAC3B,GAAI,OAAO,WAAW,OAAU,YAAc,KAAK,cACjD,OAGF,IAAMI,EAAW,WAAW,MAAM,KAAK,UAAU,EACjD,KAAK,cAAgB,WAAW,MAEhC,IAAMD,EAAM,KAAK,IACXE,E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,GAAGP,EAAI,GAAGQ,IAAW,EAAI,SAAW,OAAOA,CAAM,IACpE,KAAM,CAAE,WAAYoB,CAAQ,CAC9B,CAAC,EAED,IAAMC,EAAa,CACjB,sBAAuBtB,EACvB,WAAYP,EACZ,4BAA6BQ,EAC7B,mBAAoBoB,CACtB,EAEIpB,IAAW,EACb,KAAK,IAAI,OAAO,MAAM,GAAGD,EAAO,GAAGP,EAAI,SAAUU,EAAOmB,CAAU,EAGhErB,GAAU,IACZ,KAAK,IAAI,OAAO,KAAK,GAAGD,EAAO,GAAGP,EAAI,YAAY,OAAOQ,CAAM,IAAKqB,CAAU,EAMhF,KAAK,IAAI,OAAO,MAAM,GAAGtB,EAAO,GAAGP,IAAO6B,CAAU,CACtD,CACF,CACF,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-TUFcy95w.cjs");var t=null;function n(e,t){let n=e[t];return n!==void 0&&e instanceof n}function r(r){if(t)return t;let o=globalThis,s=o.navigator?.userAgent??``,c=`browser`,l,u,d=!1,f=o.fin?.me;return n(o,`ServiceWorkerGlobalScope`)?(c=`service_worker`,d=!0):n(o,`SharedWorkerGlobalScope`)?(c=`shared_worker`,d=!0):n(o,`WorkerGlobalScope`)?(c=`web_worker`,d=!0):f===void 0?o.Capacitor!==void 0||o.Ionic!==void 0?c=`ionic`:o.cordova!==void 0||i(s)?c=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(c=`node`):(c=e.gt.test(s)?`openfin`:`openfin_web`,r.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=f.identity;l=e?.uuid,u=e?.name})),t={platform:c,openfinUuid:l,openfinName:u,userAgent:s,isWorker:d,isTopLevelDocument:a(r)},t}function i(t){return e.t.test(t)?!0:(e.et.test(t)||e.ct.test(t)&&e.dt.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function a(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function o(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}function s(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
2
+ //# sourceMappingURL=platform-CXio0W2n.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-CXio0W2n.cjs","names":["OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","stripUrlQuery","cut","url"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker\n// execution realms. The module caches the result. The result does not change during\n// the life of a realm. A webview is also a browser. Test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** Indicates whether execution occurs inside any worker realm. */\n isWorker: boolean;\n /** Indicates whether this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Evaluates whether globalThis is an instance of a specified global scope constructor.\n * @param g Global scope object.\n * @param name Scope constructor name to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/** Structural interface for OpenFin identity inspection. */\ninterface FinLike {\n me?: { identity?: { uuid?: string; name?: string } };\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = (g.fin as FinLike | undefined)?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Evaluates whether a user agent string represents an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Determines whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read. That proves a frame. Count it. Do not report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Retrieves the current document URL without caching.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of location.href.\n * @returns Current location.href or empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault. A report on each record is noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/**\n * Drops the query string and fragment from a URL.\n * It cuts the string and does not parse a URL. A relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"4CAiDA,IAAIM,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CACvD,IAAMC,EAAQC,EAAEC,GAIhB,OAHIF,IAAU,IAAA,IAGPC,aAAcD,CACvB,CAYA,SAAgBG,EAAe,EAA4C,CACzE,GAAIL,EACF,OAAOA,EAET,IAAMG,EAAI,WAEJG,EAAMH,EAAE,WAAqC,WAAa,GAC5DI,EAAyB,UACzBC,EACAC,EACAC,EAAW,GAETC,EAASR,EAAE,KAA6B,GAkC9C,OAhCIF,EAAcE,EAAG,0BAA0B,GAC7C,EAAW,iBACX,EAAW,IACFF,EAAcE,EAAG,yBAAyB,GACnD,EAAW,gBACX,EAAW,IACFF,EAAcE,EAAG,mBAAmB,GAC7C,EAAW,aACX,EAAW,IACFQ,IAAU,IAAA,GAOVR,EAAE,YAAc,IAAA,IAAaA,EAAE,QAAU,IAAA,GAClD,EAAW,QACFA,EAAE,UAAY,IAAA,IAAaS,EAAUN,CAAE,EAChD,EAAW,iBACF,OAAO,SAAa,KAAe,OAAO,QAAY,MAC/D,EAAW,SAXX,EAAWZ,EAAAA,GAAmB,KAAKY,CAAE,EAAI,UAAY,cACrDO,EAAY,MAAM,sBAAuB,kDAAqD,CAC5F,IAAMC,EAAWH,EAAM,SACvB,EAAcG,GAAU,KACxB,EAAcA,GAAU,IAC1B,CAAC,GASH,EAAS,CACP,WACA,cACA,cACA,UAAWR,EACX,WACA,mBAAoBS,EAAWF,CAAW,CAC5C,EACOb,CACT,CAOA,SAASY,EAAU,EAAqB,CAMtC,OALIjB,EAAAA,EAA2B,KAAKW,CAAE,EAC7B,IAGPV,EAAAA,GAAsB,KAAKU,CAAE,GAAMT,EAAAA,GAAqB,KAAKS,CAAE,GAAKR,EAAAA,GAAkB,KAAKQ,CAAE,IACjFA,EAAG,SAAA,aAAwB,GAAK,CAACA,EAAG,SAAA,SAAwB,CAC5E,CAOA,SAAgBS,EAAW,EAAmC,CAC5D,GAAI,OAAO,OAAW,IACpB,MAAO,GAET,GAAI,CACF,OAAO,OAAO,OAAS,OAAO,GAChC,MAAQ,CAGN,OADAF,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAOA,SAAgBG,EAAW,EAAkC,CAC3D,GAAI,CACF,OAAO,OAAO,SAAa,IAAc,SAAS,KAAO,EAC3D,MAAQ,CAGN,OADAH,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAQA,SAAgBI,EAAc,EAAqB,CACjD,IAAMC,EAAMC,EAAI,OAAO,MAAM,EAE7B,OAAOD,IAAQ,GAAKC,EAAMA,EAAI,MAAM,EAAGD,CAAG,CAC5C"}
@@ -1,4 +1,4 @@
1
- import { ct as e, dt as t, et as n, gt as r, t as i } from "./constants-B6kdsCzF.js";
1
+ import { ct as e, dt as t, et as n, gt as r, t as i } from "./constants-0-YchbAL.js";
2
2
  //#region src/utils/platform.ts
3
3
  var a = null;
4
4
  function o(e, t) {
@@ -8,7 +8,7 @@ function o(e, t) {
8
8
  function s(e) {
9
9
  if (a) return a;
10
10
  let t = globalThis, n = t.navigator?.userAgent ?? "", i = "browser", s, u, d = !1, f = t.fin?.me;
11
- return o(t, "ServiceWorkerGlobalScope") ? (i = "service_worker", d = !0) : o(t, "SharedWorkerGlobalScope") ? (i = "shared_worker", d = !0) : o(t, "WorkerGlobalScope") ? (i = "web_worker", d = !0) : f === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? i = "ionic" : t.cordova !== void 0 || c(n) ? i = "mobile_webview" : typeof document > "u" && typeof process < "u" && (i = "node") : (i = r.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "reading fin.me.identity", () => {
11
+ return o(t, "ServiceWorkerGlobalScope") ? (i = "service_worker", d = !0) : o(t, "SharedWorkerGlobalScope") ? (i = "shared_worker", d = !0) : o(t, "WorkerGlobalScope") ? (i = "web_worker", d = !0) : f === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? i = "ionic" : t.cordova !== void 0 || c(n) ? i = "mobile_webview" : typeof document > "u" && typeof process < "u" && (i = "node") : (i = r.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "The library could not read fin.me.identity.", () => {
12
12
  let e = f.identity;
13
13
  s = e?.uuid, u = e?.name;
14
14
  })), a = {
@@ -17,25 +17,25 @@ function s(e) {
17
17
  openfinName: u,
18
18
  userAgent: n,
19
19
  isWorker: d,
20
- isTopLevelDocument: l()
20
+ isTopLevelDocument: l(e)
21
21
  }, a;
22
22
  }
23
23
  function c(r) {
24
24
  return i.test(r) ? !0 : (n.test(r) || e.test(r) && t.test(r)) && r.includes("AppleWebKit") && !r.includes("Safari/");
25
25
  }
26
- function l() {
26
+ function l(e) {
27
27
  if (typeof window > "u") return !1;
28
28
  try {
29
29
  return window.self === window.top;
30
30
  } catch {
31
- return !1;
31
+ return e.count("platform.api_blocked"), !1;
32
32
  }
33
33
  }
34
- function u() {
34
+ function u(e) {
35
35
  try {
36
36
  return typeof location < "u" ? location.href : "";
37
37
  } catch {
38
- return "";
38
+ return e.count("platform.api_blocked"), "";
39
39
  }
40
40
  }
41
41
  function d(e) {
@@ -45,4 +45,4 @@ function d(e) {
45
45
  //#endregion
46
46
  export { s as n, d as r, u as t };
47
47
 
48
- //# sourceMappingURL=platform-DMYo3AX3.js.map
48
+ //# sourceMappingURL=platform-CY8S3hUs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-CY8S3hUs.js","names":["MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","IOS_DEVICE_UA_PATTERN","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","stripUrlQuery","cut","url"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker\n// execution realms. The module caches the result. The result does not change during\n// the life of a realm. A webview is also a browser. Test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** Indicates whether execution occurs inside any worker realm. */\n isWorker: boolean;\n /** Indicates whether this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Evaluates whether globalThis is an instance of a specified global scope constructor.\n * @param g Global scope object.\n * @param name Scope constructor name to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/** Structural interface for OpenFin identity inspection. */\ninterface FinLike {\n me?: { identity?: { uuid?: string; name?: string } };\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = (g.fin as FinLike | undefined)?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Evaluates whether a user agent string represents an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Determines whether the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read. That proves a frame. Count it. Do not report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Retrieves the current document URL without caching.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of location.href.\n * @returns Current location.href or empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault. A report on each record is noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/**\n * Drops the query string and fragment from a URL.\n * It cuts the string and does not parse a URL. A relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":";;AAiDA,IAAIK,IAAkC;AAWtC,SAASC,EAAc,GAAW,GAAuB;CACvD,IAAMC,IAAQC,EAAEC;CAIhB,OAHIF,MAAU,KAAA,KAGPC,aAAcD;AACvB;AAYA,SAAgBG,EAAe,GAA4C;CACzE,IAAIL,GACF,OAAOA;CAET,IAAMG,IAAI,YAEJG,IAAMH,EAAE,WAAqC,aAAa,IAC5DI,IAAyB,WACzBC,GACAC,GACAC,IAAW,IAETC,IAASR,EAAE,KAA6B;CAkC9C,OAhCIF,EAAcE,GAAG,0BAA0B,KAC7C,IAAW,kBACX,IAAW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+ const e=require("./constants-TUFcy95w.cjs"),t=require("./unref-CU9Nyz_9.cjs");function n(){return`${String(Date.now())}000000`}function r(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.body==`string`&&typeof t.severityText==`string`&&typeof t.timeUnixNano==`string`&&typeof t.attributes==`object`&&t.attributes!==null&&typeof t.resource==`object`&&t.resource!==null}function i(e,t){if(e.length<=t)return e;let n=a(e.charCodeAt(t-1))?t-1:t;return`${e.slice(0,n)}… [truncated ${String(e.length-n)} chars]`}function a(e){return e>=55296&&e<=56319}function o(e){return`[Element ${(e.nodeName??`NODE`).toLowerCase()}${e.id?`#${e.id}`:``}${typeof e.className==`string`&&e.className?`.${e.className.trim().split(/\s+/).slice(0,3).join(`.`)}`:``}]`}function s(e,t,n){return c(e,t,n).value}function c(e,t,n){let r={bytes:0,nodes:0,diagnostics:n};return{value:u(e,t,new WeakSet,0,r),bytes:r.bytes}}function l(e,t){return t.bytes+=d(e)+2,e}function u(e,t,n,r,a){if(a.nodes++,a.nodes>t.maxNodes)return l(`[MaxNodes]`,a);if(e==null)return a.bytes+=4,e;if(typeof e==`string`)return l(i(e,t.maxAttributeChars),a);if(typeof e==`number`)return a.bytes+=8,Number.isFinite(e)?e:String(e);if(typeof e==`boolean`)return a.bytes+=5,e;if(typeof e==`bigint`)return l(`${e.toString()}n`,a);if(typeof e==`symbol`)return l(e.toString(),a);if(typeof e==`function`)return l(`[Function ${e.name===``?`anonymous`:e.name}]`,a);if(r>=t.maxDepth)return l(`[MaxDepth]`,a);if(n.has(e))return l(`[Circular]`,a);n.add(e),a.bytes+=2;try{if(e instanceof Error)return{name:l(e.name,a),message:l(i(e.message,t.maxAttributeChars),a),stack:e.stack?l(i(e.stack,t.maxStackChars),a):void 0,cause:e.cause?u(e.cause,t,n,r+1,a):void 0};if(e instanceof Date)return l(e.toISOString(),a);if(e instanceof RegExp)return l(e.toString(),a);if(e instanceof Map){let i=e,o={},s=0;for(let[e,c]of i){if(s>=t.maxArrayLength){o[`…`]=l(`[${String(i.size-t.maxArrayLength)} more entries]`,a);break}s++;let f=String(e);a.bytes+=d(f)+4,o[f]=u(c,t,n,r+1,a)}return o}if(e instanceof Set)return u([...e].slice(0,t.maxArrayLength),t,n,r,a);if(ArrayBuffer.isView(e)){let t=e.length??0;return l(`[${e.constructor.name}(${String(t)})]`,a)}if(e instanceof Promise)return l(`[Promise]`,a);if(typeof Node<`u`&&e instanceof Node)return l(o(e),a);if(Array.isArray(e)){let i=e,o=i.slice(0,t.maxArrayLength).map(e=>u(e,t,n,r+1,a));return i.length>t.maxArrayLength&&o.push(l(`[${String(i.length-t.maxArrayLength)} more items]`,a)),o}let s=e.toJSON;if(typeof s==`function`)return u(s.call(e),t,n,r+1,a);let c=e,f=Object.keys(c),p={},m=0;for(let e of f){if(m>=t.maxAttributeCount){p[`…`]=l(`[${String(f.length-m)} more keys]`,a);break}m++,a.bytes+=d(e)+4,p[e]=u(c[e],t,n,r+1,a)}return p}catch(e){return a.diagnostics.count(`record.sanitize_failed`),l(`[Unserializable: ${e instanceof Error?e.name:`error`}]`,a)}finally{n.delete(e)}}function d(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=1:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}var f={local:()=>localStorage,session:()=>sessionStorage};function p(){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 m(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 h(e){try{if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID()}catch{e.count(`platform.api_blocked`)}return m(16)}function g(e,t,n,r){return r.guard(`storage.unavailable`,`The library could not read ${t}Storage.`,()=>e[t]().getItem(n))??null}function _(e,t,n,r,i){i.guard(`storage.unavailable`,`The library could not write to ${t}Storage.`,()=>{e[t]().setItem(n,r)})}function v(t,n=f){let r=h(t),i=Date.now(),a=h(t),o=g(n,`local`,e.Ut,t);if(o)try{let e=JSON.parse(o);e.id&&i-(e.lastSeenAt??0)<18e5&&(a=e.id)}catch{t.report(`storage.degraded`,`The session record is not valid JSON. The library starts a new session.`)}let s=JSON.stringify({id:a,lastSeenAt:i});_(n,`local`,e.Ut,s,t);let c=g(n,`session`,`ui-observability.tab`,t)??``;return c||(c=h(t),_(n,`session`,e.tn,c,t)),{sessionId:a,tabId:c,contextId:r}}function y(t,n,r){_(r,`session`,e.tn,t,n)}var b=class{diagnostics;stores;lastTouchAt=0;constructor(e,t=f){this.diagnostics=e,this.stores=t}touch(t){let n=Date.now();if(n-this.lastTouchAt<6e4)return;this.lastTouchAt=n;let r=JSON.stringify({id:t,lastSeenAt:n});_(this.stores,`local`,e.Ut,r,this.diagnostics)}};function x(e,n){let r,i=new Promise((e,i)=>{let a=setTimeout(()=>{i(Error(`The operation took longer than ${String(n)} ms.`))},n);r=a,t.t(a)});return Promise.race([e,i]).finally(()=>{clearTimeout(r)})}function S(t){let n=e.H;for(let r=0;r<t.length;r++)n^=t.charCodeAt(r),n=Math.imul(n,e.U);return n>>>0}function C(e,t){let n=e.attributes[t];return typeof n==`string`?n:``}function w(e,t){let{rates:n,defaultRate:r}=t.sampling,i,a=-1;for(let[t,r]of Object.entries(n))(e===t||e.startsWith(`${t}.`))&&t.length>a&&(i=r,a=t.length);return i??r}function T(t,n){if(t.level===`ERROR`||t.level===`FATAL`||n.sampling.alwaysSampleTypes.includes(t.type))return!0;let r=w(t.namespace,n);return r>=1?!0:r<=0?!1:S(t.journeyId||t.traceId)/e.sn<r}function E(t,n){return T({level:t.severityText,type:C(t,e.l),namespace:C(t,e.n),journeyId:C(t,e.a),traceId:t.traceId},n)}var D=class{windowStart=0;count=0;allow(e){if(e.severityText!==`ERROR`&&e.severityText!==`FATAL`)return!0;let t=Date.now();return t-this.windowStart>1e4&&(this.windowStart=t,this.count=0),this.count++,this.count<=500}};Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return m}});
2
+ //# sourceMappingURL=sampling-CEthcmEX.cjs.map