@utk09/ui-observability 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +58 -46
- package/dist/bus/bus.d.ts +11 -23
- package/dist/capture/network.d.ts +1 -1
- package/dist/constants-BmO0GRWM.cjs +2 -0
- package/dist/constants-BmO0GRWM.cjs.map +1 -0
- package/dist/constants-CQr0wwbQ.js +69 -0
- package/dist/constants-CQr0wwbQ.js.map +1 -0
- package/dist/constants.d.ts +80 -7
- package/dist/core/breadcrumbs.d.ts +1 -6
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/journey.d.ts +11 -1
- package/dist/core/pipeline.d.ts +56 -22
- package/dist/core/record.d.ts +10 -0
- package/dist/core/runtime.d.ts +3 -1
- package/dist/core/sampling.d.ts +42 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +645 -565
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-DeEh8Ag-.cjs +2 -0
- package/dist/indexeddb-storage-DeEh8Ag-.cjs.map +1 -0
- package/dist/indexeddb-storage-bibcl7ZS.js +154 -0
- package/dist/indexeddb-storage-bibcl7ZS.js.map +1 -0
- package/dist/models/config.d.ts +76 -253
- package/dist/storage/idb-driver.d.ts +67 -0
- package/dist/storage/indexeddb-storage.d.ts +1 -1
- package/dist/transport/exit-flush.d.ts +1 -1
- package/dist/utils/console.d.ts +5 -8
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/tracing.d.ts +17 -1
- package/package.json +10 -8
- package/dist/constants-CYedFKrL.js +0 -110
- package/dist/constants-CYedFKrL.js.map +0 -1
- package/dist/constants-CeqjB0Aa.cjs +0 -2
- package/dist/constants-CeqjB0Aa.cjs.map +0 -1
- package/dist/indexeddb-storage-3oT4si-p.js +0 -88
- package/dist/indexeddb-storage-3oT4si-p.js.map +0 -1
- package/dist/indexeddb-storage-K3DhJWgu.cjs +0 -2
- package/dist/indexeddb-storage-K3DhJWgu.cjs.map +0 -1
package/dist/models/config.d.ts
CHANGED
|
@@ -47,66 +47,59 @@ export interface WebVitalsModule {
|
|
|
47
47
|
*/
|
|
48
48
|
onTTFB: (report: WebVitalsReporter) => void;
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
export interface
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
50
|
+
/** W3C context an active OpenTelemetry span reports. */
|
|
51
|
+
export interface OtelSpanContext {
|
|
52
|
+
/** Hexadecimal 32-character W3C trace identifier. */
|
|
53
|
+
traceId: string;
|
|
54
|
+
/** Hexadecimal 16-character W3C span identifier. */
|
|
55
|
+
spanId: string;
|
|
56
|
+
/** Bitfield byte containing W3C trace flags. */
|
|
57
|
+
traceFlags: number;
|
|
56
58
|
}
|
|
57
|
-
/** The
|
|
58
|
-
export interface
|
|
59
|
-
/** Log stream batching. */
|
|
60
|
-
logs: StreamOptions;
|
|
61
|
-
/** Metric stream batching. */
|
|
62
|
-
metrics: StreamOptions;
|
|
63
|
-
}
|
|
64
|
-
/** Storage policy for undelivered records. */
|
|
65
|
-
export interface StorageOptions {
|
|
66
|
-
/**
|
|
67
|
-
* Backing store.
|
|
68
|
-
* @default "auto"
|
|
69
|
-
*/
|
|
70
|
-
strategy: StorageStrategy;
|
|
59
|
+
/** The span the host has made active. */
|
|
60
|
+
export interface OtelSpan {
|
|
71
61
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
62
|
+
* Reads this span's W3C context.
|
|
63
|
+
* @returns Trace and span ids with their flags.
|
|
74
64
|
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Max batches held at once. Oldest are evicted past this.
|
|
78
|
-
* @default 500
|
|
79
|
-
*/
|
|
80
|
-
maxBatches: number;
|
|
81
|
-
/**
|
|
82
|
-
* Max batch age before it is dropped rather than retried, in milliseconds.
|
|
83
|
-
* @default 24 * 60 * 60 * 1000
|
|
84
|
-
*/
|
|
85
|
-
maxAgeMs: number;
|
|
86
|
-
/**
|
|
87
|
-
* Max delivery attempts before a batch is dead-lettered.
|
|
88
|
-
* @default 5
|
|
89
|
-
*/
|
|
90
|
-
maxAttempts: number;
|
|
65
|
+
spanContext(): OtelSpanContext;
|
|
91
66
|
}
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The three `@opentelemetry/api` entry points this library uses, typed
|
|
69
|
+
* structurally so the package stays an optional peer.
|
|
70
|
+
*/
|
|
71
|
+
export interface OtelApi {
|
|
72
|
+
/** Span lookup. */
|
|
73
|
+
trace: {
|
|
74
|
+
/**
|
|
75
|
+
* Reads the span the host has made active.
|
|
76
|
+
* @returns Active span, or undefined when there is none.
|
|
77
|
+
*/
|
|
78
|
+
getActiveSpan(): OtelSpan | undefined;
|
|
79
|
+
};
|
|
80
|
+
/** Ambient context lookup. */
|
|
81
|
+
context: {
|
|
82
|
+
/**
|
|
83
|
+
* Reads the active context.
|
|
84
|
+
* @returns Context, opaque to this library, understood by the propagator.
|
|
85
|
+
*/
|
|
86
|
+
active(): unknown;
|
|
87
|
+
};
|
|
88
|
+
/** Header propagation. */
|
|
89
|
+
propagation: {
|
|
90
|
+
/**
|
|
91
|
+
* Writes the host's trace headers into a carrier.
|
|
92
|
+
* @param context Context to propagate.
|
|
93
|
+
* @param carrier Header map written in place.
|
|
94
|
+
*/
|
|
95
|
+
inject(context: unknown, carrier: Record<string, string>): void;
|
|
96
|
+
};
|
|
109
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Supplies the `@opentelemetry/api` module without a hard dependency on it.
|
|
100
|
+
* @returns A promise resolving to the module.
|
|
101
|
+
*/
|
|
102
|
+
export type OtelLoader = () => Promise<OtelApi>;
|
|
110
103
|
/** Sampling policy: which records survive. */
|
|
111
104
|
export interface SamplingOptions {
|
|
112
105
|
/**
|
|
@@ -120,29 +113,11 @@ export interface SamplingOptions {
|
|
|
120
113
|
*/
|
|
121
114
|
rates: Record<string, number>;
|
|
122
115
|
/**
|
|
123
|
-
* Log types always kept, regardless of sampling rate.
|
|
116
|
+
* Log types always kept, regardless of the sampling rate.
|
|
124
117
|
* @default ["action"]
|
|
125
118
|
*/
|
|
126
119
|
alwaysSampleTypes: string[];
|
|
127
120
|
}
|
|
128
|
-
/** Lifetime rules for a journey (one user task spanning several contexts). */
|
|
129
|
-
export interface JourneyOptions {
|
|
130
|
-
/**
|
|
131
|
-
* Max time a journey stays open before it's treated as abandoned, in milliseconds.
|
|
132
|
-
* @default 30 * 60 * 1000
|
|
133
|
-
*/
|
|
134
|
-
maxAgeMs: number;
|
|
135
|
-
/**
|
|
136
|
-
* Whether closing the owning context ends the journey for everyone.
|
|
137
|
-
* @default false
|
|
138
|
-
*/
|
|
139
|
-
endOnOwnerClose: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Query parameter checked at boot for a seeded journey token.
|
|
142
|
-
* @default "__uiobs_journey"
|
|
143
|
-
*/
|
|
144
|
-
urlParam: string;
|
|
145
|
-
}
|
|
146
121
|
/** Bus settings: how this context discovers, trusts, and messages the others. */
|
|
147
122
|
export interface BusOptions {
|
|
148
123
|
/**
|
|
@@ -150,26 +125,11 @@ export interface BusOptions {
|
|
|
150
125
|
* @default "auto"
|
|
151
126
|
*/
|
|
152
127
|
mode: BusMode;
|
|
153
|
-
/**
|
|
154
|
-
* BroadcastChannel name for the control plane.
|
|
155
|
-
* @default "ui_observability_control"
|
|
156
|
-
*/
|
|
157
|
-
channelName: string;
|
|
158
128
|
/**
|
|
159
129
|
* Origins allowed to send postMessage records to this document. Required for any document receiving them from a cross-origin iframe.
|
|
160
130
|
* @default []
|
|
161
131
|
*/
|
|
162
132
|
trustedOrigins: string[];
|
|
163
|
-
/**
|
|
164
|
-
* Max time a forwarder waits for an owner to answer before applying the orphan policy, in milliseconds.
|
|
165
|
-
* @default 1500
|
|
166
|
-
*/
|
|
167
|
-
handshakeTimeoutMs: number;
|
|
168
|
-
/**
|
|
169
|
-
* Which OpenFin context owns delivery.
|
|
170
|
-
* @default "provider"
|
|
171
|
-
*/
|
|
172
|
-
openFinHost: "provider" | "self";
|
|
173
133
|
/**
|
|
174
134
|
* Which OpenFin context this is. Only the platform provider answers a
|
|
175
135
|
* handshake, so setting this wrong makes every view send for itself.
|
|
@@ -178,25 +138,8 @@ export interface BusOptions {
|
|
|
178
138
|
* @default "auto"
|
|
179
139
|
*/
|
|
180
140
|
openFinRole: "auto" | "provider" | "client";
|
|
181
|
-
/**
|
|
182
|
-
* Max records a context buffers before its bus role is determined.
|
|
183
|
-
* @default 500
|
|
184
|
-
*/
|
|
185
|
-
maxBootBufferRecords: number;
|
|
186
|
-
/**
|
|
187
|
-
* Forwarder behavior when no owner answers: `auto` retries in a
|
|
188
|
-
* cross-origin frame and promotes elsewhere, `promote` becomes a sender
|
|
189
|
-
* immediately, `retry` retries then promotes as a last resort.
|
|
190
|
-
* @default "auto"
|
|
191
|
-
*/
|
|
192
|
-
orphanPolicy: "auto" | "promote" | "retry";
|
|
193
|
-
/**
|
|
194
|
-
* Handshake attempts allowed before promoting under the "retry" policy.
|
|
195
|
-
* @default 3
|
|
196
|
-
*/
|
|
197
|
-
maxHandshakeAttempts: number;
|
|
198
141
|
}
|
|
199
|
-
/** What the library instruments automatically. Everything but errors is off by default. */
|
|
142
|
+
/** What the library instruments automatically. Everything but errors and rejections is off by default. */
|
|
200
143
|
export interface CaptureOptions {
|
|
201
144
|
/**
|
|
202
145
|
* Log uncaught errors from `window.onerror`.
|
|
@@ -239,10 +182,11 @@ export interface CaptureOptions {
|
|
|
239
182
|
*/
|
|
240
183
|
webVitals: boolean;
|
|
241
184
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
185
|
+
* Keep the query string and fragment on every URL the library records.
|
|
186
|
+
* Off strips them from page URLs, request targets and failed resource URLs.
|
|
187
|
+
* @default false
|
|
244
188
|
*/
|
|
245
|
-
|
|
189
|
+
fullUrls: boolean;
|
|
246
190
|
/**
|
|
247
191
|
* URLs excluded from logging. The ingest endpoint is always included.
|
|
248
192
|
* @default []
|
|
@@ -253,68 +197,14 @@ export interface CaptureOptions {
|
|
|
253
197
|
* @default []
|
|
254
198
|
*/
|
|
255
199
|
propagateTraceHeaderTo: (string | RegExp)[];
|
|
256
|
-
/**
|
|
257
|
-
* Window within which identical errors are counted but not re-sent, in milliseconds.
|
|
258
|
-
* @default 5000
|
|
259
|
-
*/
|
|
260
|
-
errorDedupeMs: number;
|
|
261
200
|
/**
|
|
262
201
|
* Supplies the `web-vitals` module without a hard dependency on the package.
|
|
263
202
|
* @returns A promise resolving to the `web-vitals` module.
|
|
264
203
|
*/
|
|
265
204
|
webVitalsLoader?: () => Promise<WebVitalsModule>;
|
|
266
205
|
}
|
|
267
|
-
/**
|
|
268
|
-
export
|
|
269
|
-
/**
|
|
270
|
-
* Max record body length, in characters.
|
|
271
|
-
* @default 4096
|
|
272
|
-
*/
|
|
273
|
-
maxBodyChars: number;
|
|
274
|
-
/**
|
|
275
|
-
* Max length of a single string attribute, in characters.
|
|
276
|
-
* @default 8192
|
|
277
|
-
*/
|
|
278
|
-
maxAttributeChars: number;
|
|
279
|
-
/**
|
|
280
|
-
* Max attributes per record.
|
|
281
|
-
* @default 128
|
|
282
|
-
*/
|
|
283
|
-
maxAttributeCount: number;
|
|
284
|
-
/**
|
|
285
|
-
* Max stack trace length, in characters. Larger than `maxAttributeChars`.
|
|
286
|
-
* @default 8192
|
|
287
|
-
*/
|
|
288
|
-
maxStackChars: number;
|
|
289
|
-
/**
|
|
290
|
-
* Max depth walked into a nested value before truncating.
|
|
291
|
-
* @default 6
|
|
292
|
-
*/
|
|
293
|
-
maxDepth: number;
|
|
294
|
-
/**
|
|
295
|
-
* Max items kept from an array, set, or map.
|
|
296
|
-
* @default 100
|
|
297
|
-
*/
|
|
298
|
-
maxArrayLength: number;
|
|
299
|
-
/**
|
|
300
|
-
* Max total attribute bytes per record, checked after sanitize and redact.
|
|
301
|
-
* @default 32768
|
|
302
|
-
*/
|
|
303
|
-
maxRecordBytes: number;
|
|
304
|
-
}
|
|
305
|
-
/** Console mirroring, for development. */
|
|
306
|
-
export interface ConsoleOptions {
|
|
307
|
-
/**
|
|
308
|
-
* Whether to mirror at all.
|
|
309
|
-
* @default false
|
|
310
|
-
*/
|
|
311
|
-
enabled: boolean;
|
|
312
|
-
/**
|
|
313
|
-
* Min level to mirror. Independent of `minLevel`.
|
|
314
|
-
* @default "DEBUG"
|
|
315
|
-
*/
|
|
316
|
-
level: LogLevel;
|
|
317
|
-
}
|
|
206
|
+
/** Console mirroring. `false` is off, `true` mirrors from DEBUG, a level mirrors from that level up. */
|
|
207
|
+
export type ConsoleOption = boolean | LogLevel;
|
|
318
208
|
/** Options passed to `configure()`. Only `endpoint` is required. */
|
|
319
209
|
export interface ObservabilityConfig {
|
|
320
210
|
/** Ingest endpoint URL. Required. */
|
|
@@ -344,71 +234,33 @@ export interface ObservabilityConfig {
|
|
|
344
234
|
* @default "INFO"
|
|
345
235
|
*/
|
|
346
236
|
minLevel?: LogLevel;
|
|
347
|
-
/** Per-stream batching. */
|
|
348
|
-
streams?: {
|
|
349
|
-
/**
|
|
350
|
-
* Log stream batching.
|
|
351
|
-
* @default { flushIntervalMs: 2000, batchSize: 100 }
|
|
352
|
-
*/
|
|
353
|
-
logs?: Partial<StreamOptions>;
|
|
354
|
-
/**
|
|
355
|
-
* Metric stream batching.
|
|
356
|
-
* @default { flushIntervalMs: 10000, batchSize: 500 }
|
|
357
|
-
*/
|
|
358
|
-
metrics?: Partial<StreamOptions>;
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* Max concurrent ingest requests, across both streams.
|
|
362
|
-
* @default 2
|
|
363
|
-
*/
|
|
364
|
-
maxConcurrentRequests?: number;
|
|
365
237
|
/**
|
|
366
|
-
*
|
|
367
|
-
* @default 15000
|
|
368
|
-
*/
|
|
369
|
-
requestTimeoutMs?: number;
|
|
370
|
-
/**
|
|
371
|
-
* Whether to gzip a payload past `compressionThresholdBytes`.
|
|
238
|
+
* Whether to gzip a payload past the compression threshold. Set "none" for an ingest endpoint that rejects gzip.
|
|
372
239
|
* @default "gzip"
|
|
373
240
|
*/
|
|
374
241
|
compression?: "gzip" | "none";
|
|
375
|
-
/**
|
|
376
|
-
* Min payload size to compress, in bytes.
|
|
377
|
-
* @default 1024
|
|
378
|
-
*/
|
|
379
|
-
compressionThresholdBytes?: number;
|
|
380
242
|
/**
|
|
381
243
|
* Wire format: a name, or a custom implementation.
|
|
382
244
|
* @default "otlp"
|
|
383
245
|
*/
|
|
384
246
|
serializer?: "otlp" | "ecs" | LogSerializer;
|
|
385
247
|
/**
|
|
386
|
-
* Passed to `fetch`.
|
|
387
|
-
* @default "
|
|
248
|
+
* Passed to `fetch`. Set "include" for an ingest endpoint that authenticates with cookies.
|
|
249
|
+
* @default "omit"
|
|
388
250
|
*/
|
|
389
251
|
credentials?: RequestCredentials;
|
|
390
252
|
/** Extra request headers, or a function returning them. */
|
|
391
253
|
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
392
254
|
/**
|
|
393
|
-
*
|
|
394
|
-
* @
|
|
395
|
-
*/
|
|
396
|
-
storage?: Partial<StorageOptions>;
|
|
397
|
-
/**
|
|
398
|
-
* Backoff schedule for redelivering them.
|
|
399
|
-
* @see {@link RetryOptions}
|
|
255
|
+
* Backing store for undelivered records.
|
|
256
|
+
* @default "auto"
|
|
400
257
|
*/
|
|
401
|
-
|
|
258
|
+
storage?: StorageStrategy;
|
|
402
259
|
/**
|
|
403
260
|
* Sampling policy.
|
|
404
261
|
* @see {@link SamplingOptions}
|
|
405
262
|
*/
|
|
406
263
|
sampling?: Partial<SamplingOptions>;
|
|
407
|
-
/**
|
|
408
|
-
* Journey lifetime rules.
|
|
409
|
-
* @see {@link JourneyOptions}
|
|
410
|
-
*/
|
|
411
|
-
journey?: Partial<JourneyOptions>;
|
|
412
264
|
/**
|
|
413
265
|
* Bus discovery, trust, and messaging settings.
|
|
414
266
|
* @see {@link BusOptions}
|
|
@@ -420,15 +272,16 @@ export interface ObservabilityConfig {
|
|
|
420
272
|
*/
|
|
421
273
|
capture?: Partial<CaptureOptions>;
|
|
422
274
|
/**
|
|
423
|
-
*
|
|
424
|
-
* @
|
|
275
|
+
* Console mirroring, for development.
|
|
276
|
+
* @default false
|
|
425
277
|
*/
|
|
426
|
-
|
|
278
|
+
console?: ConsoleOption;
|
|
427
279
|
/**
|
|
428
|
-
*
|
|
429
|
-
*
|
|
280
|
+
* Supplies the `@opentelemetry/api` module. Omit it and the library imports
|
|
281
|
+
* the package itself when it is installed.
|
|
282
|
+
* @see {@link OtelLoader}
|
|
430
283
|
*/
|
|
431
|
-
|
|
284
|
+
otelLoader?: OtelLoader;
|
|
432
285
|
/**
|
|
433
286
|
* Rewrites or drops a record before it's sent.
|
|
434
287
|
* @param record The record about to be sent.
|
|
@@ -455,41 +308,17 @@ export interface ResolvedConfig {
|
|
|
455
308
|
enabled: boolean;
|
|
456
309
|
/** Min level logged. */
|
|
457
310
|
minLevel: LogLevel;
|
|
458
|
-
/**
|
|
459
|
-
* Per-stream batching.
|
|
460
|
-
* @see {@link StreamsOptions}
|
|
461
|
-
*/
|
|
462
|
-
streams: StreamsOptions;
|
|
463
|
-
/** Max concurrent ingest requests, across both streams. */
|
|
464
|
-
maxConcurrentRequests: number;
|
|
465
|
-
/** Max time one ingest request may take before it is aborted and retried, in milliseconds. */
|
|
466
|
-
requestTimeoutMs: number;
|
|
467
|
-
/** Whether to gzip a payload past `compressionThresholdBytes`. */
|
|
311
|
+
/** Whether to gzip a payload past the compression threshold. */
|
|
468
312
|
compression: "gzip" | "none";
|
|
469
|
-
/** Min payload size to compress, in bytes. */
|
|
470
|
-
compressionThresholdBytes: number;
|
|
471
313
|
/** Passed to `fetch`. */
|
|
472
314
|
credentials: RequestCredentials;
|
|
473
|
-
/**
|
|
474
|
-
|
|
475
|
-
* @see {@link StorageOptions}
|
|
476
|
-
*/
|
|
477
|
-
storage: StorageOptions;
|
|
478
|
-
/**
|
|
479
|
-
* Backoff schedule for redelivering a stored batch.
|
|
480
|
-
* @see {@link RetryOptions}
|
|
481
|
-
*/
|
|
482
|
-
retry: RetryOptions;
|
|
315
|
+
/** Backing store for undelivered records. */
|
|
316
|
+
storage: StorageStrategy;
|
|
483
317
|
/**
|
|
484
318
|
* Sampling policy.
|
|
485
319
|
* @see {@link SamplingOptions}
|
|
486
320
|
*/
|
|
487
321
|
sampling: SamplingOptions;
|
|
488
|
-
/**
|
|
489
|
-
* Journey lifetime rules.
|
|
490
|
-
* @see {@link JourneyOptions}
|
|
491
|
-
*/
|
|
492
|
-
journey: JourneyOptions;
|
|
493
322
|
/**
|
|
494
323
|
* Bus discovery, trust, and messaging settings.
|
|
495
324
|
* @see {@link BusOptions}
|
|
@@ -500,20 +329,14 @@ export interface ResolvedConfig {
|
|
|
500
329
|
* @see {@link CaptureOptions}
|
|
501
330
|
*/
|
|
502
331
|
capture: CaptureOptions;
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
* @see {@link LimitOptions}
|
|
506
|
-
*/
|
|
507
|
-
limits: LimitOptions;
|
|
508
|
-
/**
|
|
509
|
-
* Console mirroring.
|
|
510
|
-
* @see {@link ConsoleOptions}
|
|
511
|
-
*/
|
|
512
|
-
console: ConsoleOptions;
|
|
332
|
+
/** Min level mirrored to the console, or null when mirroring is off. */
|
|
333
|
+
console: LogLevel | null;
|
|
513
334
|
/** Wire format implementation, resolved from a name or passed directly. */
|
|
514
335
|
serializer: LogSerializer;
|
|
515
336
|
/** Extra request headers, or a function returning them. */
|
|
516
337
|
headers?: ObservabilityConfig["headers"];
|
|
338
|
+
/** Supplies the `@opentelemetry/api` module in place of importing it. */
|
|
339
|
+
otelLoader?: OtelLoader;
|
|
517
340
|
/**
|
|
518
341
|
* Rewrites or drops a record before it's sent.
|
|
519
342
|
* @param record The record about to be sent.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { LogBatch } from "../models/batch";
|
|
2
|
+
/** One IndexedDB database holding undelivered batches keyed by id. */
|
|
3
|
+
export declare class IdbDriver {
|
|
4
|
+
private readonly name;
|
|
5
|
+
/** Open in progress or completed, reused so one database is opened per driver. */
|
|
6
|
+
private connection;
|
|
7
|
+
/**
|
|
8
|
+
* @param name IndexedDB database name.
|
|
9
|
+
*/
|
|
10
|
+
constructor(name: string);
|
|
11
|
+
/**
|
|
12
|
+
* Writes a batch, replacing any batch already stored under the same id.
|
|
13
|
+
* @param batch Batch to persist.
|
|
14
|
+
*/
|
|
15
|
+
put(batch: LogBatch): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Reads the oldest batches by createdAt without removing them.
|
|
18
|
+
* @param limit Maximum number of batches to return.
|
|
19
|
+
* @returns Batches in ascending createdAt order.
|
|
20
|
+
*/
|
|
21
|
+
takeOldest(limit: number): Promise<LogBatch[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Reads every batch created strictly before a cutoff.
|
|
24
|
+
* @param cutoff Exclusive upper bound in epoch milliseconds.
|
|
25
|
+
* @returns Batches older than the cutoff.
|
|
26
|
+
*/
|
|
27
|
+
takeBefore(cutoff: number): Promise<LogBatch[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes one batch. An id that is not stored resolves without error.
|
|
30
|
+
* @param id Batch identifier.
|
|
31
|
+
*/
|
|
32
|
+
delete(id: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Deletes several batches in one transaction, so a partial failure leaves none
|
|
35
|
+
* of them deleted.
|
|
36
|
+
* @param ids Batch identifiers.
|
|
37
|
+
*/
|
|
38
|
+
deleteMany(ids: string[]): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Rewrites the attempt count of a stored batch. An id that is not stored is
|
|
41
|
+
* left alone: a batch already delivered and deleted must not be resurrected.
|
|
42
|
+
* @param id Batch identifier.
|
|
43
|
+
* @param attempts New absolute attempt count.
|
|
44
|
+
*/
|
|
45
|
+
bumpAttempts(id: string, attempts: number): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Counts stored batches.
|
|
48
|
+
* @returns Total batch count.
|
|
49
|
+
*/
|
|
50
|
+
count(): Promise<number>;
|
|
51
|
+
/** Deletes every stored batch. */
|
|
52
|
+
clear(): Promise<void>;
|
|
53
|
+
/** Closes the connection, if one was ever opened. */
|
|
54
|
+
close(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Opens the batch store in a fresh transaction. A transaction is only valid
|
|
57
|
+
* until control returns to the event loop, so every call takes a new one.
|
|
58
|
+
* @param mode Transaction mode.
|
|
59
|
+
* @returns The batch object store.
|
|
60
|
+
*/
|
|
61
|
+
private store;
|
|
62
|
+
/**
|
|
63
|
+
* Opens the database once and hands the same connection to every later call.
|
|
64
|
+
* @returns The open database.
|
|
65
|
+
*/
|
|
66
|
+
private open;
|
|
67
|
+
}
|
|
@@ -8,7 +8,7 @@ export declare class IndexedDbStorage implements StorageAdapter {
|
|
|
8
8
|
private readonly onGap?;
|
|
9
9
|
/** Storage adapter strategy name. */
|
|
10
10
|
readonly name = "indexeddb";
|
|
11
|
-
/**
|
|
11
|
+
/** IndexedDB mechanics for the batch store. */
|
|
12
12
|
private readonly db;
|
|
13
13
|
/**
|
|
14
14
|
* @param dbName Database name.
|
|
@@ -10,7 +10,7 @@ export interface ExitFlushDeps {
|
|
|
10
10
|
/** Diagnostics reporter instance. */
|
|
11
11
|
diagnostics: Diagnostics;
|
|
12
12
|
/** Callback draining all pending buffered and unconfirmed batches into a single LogBatch. */
|
|
13
|
-
|
|
13
|
+
drainForExit: () => LogBatch | null;
|
|
14
14
|
}
|
|
15
15
|
/** Flushes pending telemetry on document unload using sendBeacon, keepalive fetch, or emergency storage. */
|
|
16
16
|
export declare class ExitFlush {
|
package/dist/utils/console.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import type { LogLevel } from "../models/log-record";
|
|
2
2
|
/** Mirrors log records directly to browser or Node console methods based on severity. */
|
|
3
3
|
export declare class ConsoleSink {
|
|
4
|
-
private enabled;
|
|
5
4
|
private minLevel;
|
|
6
5
|
/**
|
|
7
|
-
* @param
|
|
8
|
-
* @param minLevel Minimum log level required to emit to the console.
|
|
6
|
+
* @param minLevel Minimum log level required to emit, or null to mirror nothing.
|
|
9
7
|
*/
|
|
10
|
-
constructor(
|
|
8
|
+
constructor(minLevel: LogLevel | null);
|
|
11
9
|
/**
|
|
12
|
-
* Updates console
|
|
13
|
-
* @param
|
|
14
|
-
* @param minLevel Minimum log level required to emit to the console.
|
|
10
|
+
* Updates the console mirroring threshold.
|
|
11
|
+
* @param minLevel Minimum log level required to emit, or null to mirror nothing.
|
|
15
12
|
*/
|
|
16
|
-
update(
|
|
13
|
+
update(minLevel: LogLevel | null): void;
|
|
17
14
|
/**
|
|
18
15
|
* Emits a styled log record to the console if severity clears the configured threshold.
|
|
19
16
|
* @param level Severity level of the record.
|
package/dist/utils/platform.d.ts
CHANGED
|
@@ -32,5 +32,12 @@ export declare function isTopLevel(): boolean;
|
|
|
32
32
|
* @returns Current location.href or empty string.
|
|
33
33
|
*/
|
|
34
34
|
export declare function currentUrl(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Drops the query string and fragment from a URL.
|
|
37
|
+
* A string cut, not a URL parse: a relative request target has no base to parse against.
|
|
38
|
+
* @param url Absolute or relative URL.
|
|
39
|
+
* @returns The URL up to the first "?" or "#".
|
|
40
|
+
*/
|
|
41
|
+
export declare function stripUrlQuery(url: string): string;
|
|
35
42
|
/** Resets the cached platform metadata for testing. */
|
|
36
43
|
export declare function resetPlatformCache(): void;
|
package/dist/utils/tracing.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Diagnostics } from "../core/diagnostics";
|
|
2
|
+
import type { OtelLoader } from "../models/config";
|
|
2
3
|
/** W3C trace context fields attached to log records and network headers. */
|
|
3
4
|
export interface TraceContext {
|
|
4
5
|
/** Hexadecimal 32-character W3C trace identifier. */
|
|
@@ -26,21 +27,36 @@ export declare function newSpanId(): string;
|
|
|
26
27
|
export declare class TraceEngine {
|
|
27
28
|
private readonly diagnostics;
|
|
28
29
|
private readonly maxAgeMs;
|
|
30
|
+
private readonly load;
|
|
29
31
|
/**
|
|
30
32
|
* Active ambient trace context. Instance state, never module state. Two runtimes
|
|
31
33
|
* in one document must not share a trace id.
|
|
32
34
|
*/
|
|
33
35
|
private ambient;
|
|
36
|
+
/** The optional peer once loaded. Undefined while it loads, and forever if it is absent. */
|
|
37
|
+
private otel;
|
|
34
38
|
/**
|
|
35
39
|
* @param diagnostics Diagnostics reporter.
|
|
36
40
|
* @param maxAgeMs Maximum lifetime of an un-rotated ambient trace in milliseconds.
|
|
41
|
+
* @param load Supplies the OpenTelemetry API.
|
|
37
42
|
*/
|
|
38
|
-
constructor(diagnostics: Diagnostics, maxAgeMs?: number);
|
|
43
|
+
constructor(diagnostics: Diagnostics, maxAgeMs?: number, load?: OtelLoader);
|
|
44
|
+
/**
|
|
45
|
+
* Loads the OpenTelemetry API. Records built before this resolves, and every
|
|
46
|
+
* record when the package is absent, carry the ambient trace instead.
|
|
47
|
+
* @returns Promise resolving once the attempt has settled.
|
|
48
|
+
*/
|
|
49
|
+
loadOtel(): Promise<void>;
|
|
39
50
|
/**
|
|
40
51
|
* Resolves trace context, prioritizing active OpenTelemetry spans over the ambient trace.
|
|
41
52
|
* @returns Active TraceContext.
|
|
42
53
|
*/
|
|
43
54
|
resolve(): TraceContext;
|
|
55
|
+
/**
|
|
56
|
+
* Reads the host's active span, if the peer is loaded and a span is running.
|
|
57
|
+
* @returns Trace context of the active span, or undefined.
|
|
58
|
+
*/
|
|
59
|
+
private activeSpanContext;
|
|
44
60
|
/**
|
|
45
61
|
* Rotates the ambient trace context to mark the start of a new logical operation.
|
|
46
62
|
* @param _reason Event reason triggering the rotation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utk09/ui-observability",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "UI observability and logging for browser, OpenFin and webview applications",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"node": ">=20.19.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"dist"
|
|
35
|
+
"dist",
|
|
36
|
+
"CHANGELOG.md"
|
|
36
37
|
],
|
|
37
38
|
"main": "./dist/index.cjs",
|
|
38
39
|
"module": "./dist/index.js",
|
|
@@ -70,24 +71,25 @@
|
|
|
70
71
|
"test:watch": "vitest",
|
|
71
72
|
"test:coverage": "vitest run --coverage",
|
|
72
73
|
"typecheck": "tsc --noEmit",
|
|
73
|
-
"
|
|
74
|
+
"check:version": "node tools/check-version-sync.mjs",
|
|
75
|
+
"verify": "npm run format:check && npm run check:version && npm run typecheck && npm run lint && npm run build && npm run test:coverage",
|
|
74
76
|
"prepublishOnly": "npm run verify"
|
|
75
77
|
},
|
|
76
|
-
"dependencies": {
|
|
77
|
-
"@opentelemetry/api": "1.9.1",
|
|
78
|
-
"dexie": "4.4.5",
|
|
79
|
-
"rxjs": "7.8.2"
|
|
80
|
-
},
|
|
81
78
|
"peerDependencies": {
|
|
79
|
+
"@opentelemetry/api": "^1",
|
|
82
80
|
"web-vitals": "^4 || ^5 || ^6"
|
|
83
81
|
},
|
|
84
82
|
"peerDependenciesMeta": {
|
|
83
|
+
"@opentelemetry/api": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
85
86
|
"web-vitals": {
|
|
86
87
|
"optional": true
|
|
87
88
|
}
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@eslint/js": "10.0.1",
|
|
92
|
+
"@opentelemetry/api": "1.9.1",
|
|
91
93
|
"@types/node": "26.2.0",
|
|
92
94
|
"@vitest/coverage-istanbul": "4.1.11",
|
|
93
95
|
"concurrently": "10.0.5",
|