@utk09/ui-observability 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -23
- package/README.md +86 -86
- package/dist/bus/bus.d.ts +9 -0
- package/dist/bus/links.d.ts +5 -4
- package/dist/capture/types.d.ts +14 -0
- package/dist/capture/web-vitals.d.ts +5 -2
- package/dist/constants-DVbpJ1tv.js +74 -0
- package/dist/constants-DVbpJ1tv.js.map +1 -0
- package/dist/constants-tQpoTzkY.cjs +2 -0
- package/dist/constants-tQpoTzkY.cjs.map +1 -0
- package/dist/constants.d.ts +18 -1
- package/dist/core/logger.d.ts +7 -5
- package/dist/core/pipeline.d.ts +10 -1
- package/dist/core/record.d.ts +11 -2
- package/dist/core/runtime.d.ts +12 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +675 -540
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-bibcl7ZS.js → indexeddb-storage-B6uqejZb.js} +32 -11
- package/dist/indexeddb-storage-B6uqejZb.js.map +1 -0
- package/dist/indexeddb-storage-CgT1GLYj.cjs +2 -0
- package/dist/indexeddb-storage-CgT1GLYj.cjs.map +1 -0
- package/dist/storage/idb-driver.d.ts +9 -1
- package/dist/storage/indexeddb-storage.d.ts +5 -0
- package/dist/storage/local-storage.d.ts +14 -0
- package/dist/transport/exit-flush.d.ts +11 -1
- package/dist/transport/retry-engine.d.ts +28 -3
- package/dist/utils/console.d.ts +4 -1
- package/dist/utils/deadline.d.ts +7 -0
- package/dist/utils/identity.d.ts +17 -6
- package/dist/utils/sanitize.d.ts +2 -0
- package/package.json +5 -5
- package/dist/constants-BmO0GRWM.cjs +0 -2
- package/dist/constants-BmO0GRWM.cjs.map +0 -1
- package/dist/constants-CQr0wwbQ.js +0 -69
- package/dist/constants-CQr0wwbQ.js.map +0 -1
- package/dist/indexeddb-storage-DeEh8Ag-.cjs +0 -2
- package/dist/indexeddb-storage-DeEh8Ag-.cjs.map +0 -1
- package/dist/indexeddb-storage-bibcl7ZS.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,44 +2,87 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
+
## [0.4.1] - 2026-09-09
|
|
6
|
+
|
|
7
|
+
### Fixed - v0.4.1
|
|
8
|
+
|
|
9
|
+
- A blocked IndexedDB upgrade never settled. Every storage call in the window waited with it. `IdbDriver` rejects on `onblocked`. An open connection closes on `versionchange`. A failed open is not cached.
|
|
10
|
+
- No storage call had a time limit. A hung adapter held a dispatch slot, the drain flag, or startup. Each call fails after `STORAGE_DEADLINE_MS` and reports `storage.degraded`.
|
|
11
|
+
- A refused beacon lost the batch. The keepalive fetch fallback drew on the same full budget. A refusal writes to the emergency queue. An absent `sendBeacon` still falls back to the fetch.
|
|
12
|
+
- `hidden` sent in-flight batches a second time under a new batch id. It drains the stream buffers only. `pagehide`, `freeze`, `openfin-close` and `shutdown` still take both.
|
|
13
|
+
- A `429` or `503` spent one of the five delivery attempts. A throttled answer schedules from `Retry-After`. The attempt count is unchanged.
|
|
14
|
+
- A same-origin frame two levels deep lost its records. The echo guard compared link kinds, and two direct links share a kind. A forwarder relays records from a direct link.
|
|
15
|
+
- Each `configure()` after startup added another set of web-vitals reporters and repeated the seven navigation timing metrics. `web-vitals` has no unsubscribe. Both run once per document.
|
|
16
|
+
- The IndexedDB probe tested presence, not operation. The factory opens the database before it keeps the adapter. A host that rejects `open()` gets localStorage.
|
|
17
|
+
- `bumpAttempts` read and wrote in two IndexedDB transactions. A prune in another window deleted the batch between them. One transaction holds both.
|
|
18
|
+
- The ingest contract did not list the request headers. A server built from the README failed every CORS preflight and received exit-flush records only. The README names `OPTIONS` and `Access-Control-Allow-Headers`.
|
|
19
|
+
|
|
20
|
+
### Performance - v0.4.1
|
|
21
|
+
|
|
22
|
+
- `prune()` parsed every stored batch to read `createdAt`. It reads `createdAt` from the key. Only a batch it drops is parsed.
|
|
23
|
+
- Click capture read `innerText`, which forces style and layout. It reads `textContent`. A click breadcrumb can carry text that CSS hides.
|
|
24
|
+
|
|
25
|
+
## [0.4.0] - 2026-09-09
|
|
26
|
+
|
|
27
|
+
### Breaking changes - v0.4.0
|
|
28
|
+
|
|
29
|
+
- The OpenFin bus topic is scoped to one application uuid. Upgrade all windows of an application together. A 0.3.0 window and a 0.4.0 window do not share a bus.
|
|
30
|
+
- ECS documents write each attribute under `labels` as a flat dotted key. A nested attribute was an object. Update saved queries.
|
|
31
|
+
- ECS `log.level` is `warning` for a WARN record. It was `warn`.
|
|
32
|
+
- `logger.error(message, payload)` reads a plain object in the error slot as the payload. It was the error reason. An array, an `Error` and a class instance stay error reasons.
|
|
33
|
+
- `configure({ storage })` after startup reports `config.invalid` and keeps the built adapter. The call was accepted before and did nothing.
|
|
34
|
+
- One record sanitizes to 10,000 nodes. Values past the cap become `[MaxNodes]`.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// ECS attributes
|
|
38
|
+
{ labels: { order: { id: "ORD-1" } } } // 0.3.0
|
|
39
|
+
{ labels: { "order.id": "ORD-1" } } // 0.4.0
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Fixed - v0.4.0
|
|
43
|
+
|
|
44
|
+
- A quota eviction dropped the write it made room for. Both persistent adapters retry the write. A failed retry counts a gap with `reason: "quota"`.
|
|
45
|
+
- Sampling dropped the breadcrumb with the record. A sampled-out record keeps its breadcrumb. A record dropped by `redact` does not.
|
|
46
|
+
- A typo inside a config section passed in silence. `capture: { webVital: true }` reports `unknown config key "capture.webVital"`. The guard reads one level into `sampling`, `bus` and `capture`.
|
|
47
|
+
- A console method that throws stopped the caller's log call. The mirror is guarded and reports `handler.threw`.
|
|
48
|
+
- The session touch throttle was module state. Two runtimes in one document silenced each other. Each runtime holds its own throttle.
|
|
49
|
+
|
|
5
50
|
## [0.3.0] - 2026-09-08
|
|
6
51
|
|
|
7
52
|
### Breaking changes - v0.3.0
|
|
8
53
|
|
|
9
|
-
- `credentials`
|
|
10
|
-
- A recorded URL
|
|
11
|
-
- `@opentelemetry/api` is
|
|
54
|
+
- `credentials` defaults to `"omit"`. The library sends no cookie to the ingest endpoint. Set `credentials: "include"` for cookie auth.
|
|
55
|
+
- A recorded URL holds no query string and no fragment. This covers `page.url`, `url.full`, `resource.url`, `page.url.previous` and their breadcrumbs. Set `capture.fullUrls: true` to keep the full URL.
|
|
56
|
+
- `@opentelemetry/api` is an optional peer dependency. Install it to put records on the traces your spans carry. Without it, the library mints its own `trace_id` and reports `trace.otel_failed` one time. Set `otelLoader` when your bundler cannot resolve the import.
|
|
12
57
|
- `getLogger(namespace, options)` builds a new logger on each call. Only `getLogger(namespace)` is cached. A per-call `scopedContext` no longer stays in memory for the life of the document.
|
|
13
58
|
|
|
14
59
|
```ts
|
|
15
|
-
// cookie auth,
|
|
60
|
+
// cookie auth, the default before 0.3.0
|
|
16
61
|
configure({ endpoint, credentials: "include" });
|
|
17
62
|
|
|
18
|
-
// query strings,
|
|
63
|
+
// query strings, always recorded before 0.3.0
|
|
19
64
|
configure({ endpoint, capture: { fullUrls: true } });
|
|
20
65
|
```
|
|
21
66
|
|
|
22
|
-
To join your own traces, install the peer: `npm install @opentelemetry/api`.
|
|
23
|
-
|
|
24
67
|
### Fixed - v0.3.0
|
|
25
68
|
|
|
26
|
-
- `flush()` sent in-flight
|
|
27
|
-
- The bus posted to a child frame with the target origin `"*"`. A frame that navigated away received the `journey.id` and the `tab.id`. The bus
|
|
28
|
-
- `ERROR` and `FATAL`
|
|
69
|
+
- `flush()` sent an in-flight batch again under a new `X-UiObs-Batch-Id`. The server could not deduplicate it. `flush()` takes the stream buffers only. The exit flush still takes both, because a closing document cannot confirm delivery.
|
|
70
|
+
- The bus posted to a child frame with the target origin `"*"`. A frame that navigated away received the `journey.id` and the `tab.id`. The bus posts to the origin the child last spoke from.
|
|
71
|
+
- An `ERROR` and a `FATAL` record bypass sampling and had no limit. A fixed window admits 500 of them per 10 seconds. It counts the rest as `record.dropped_by_ceiling`.
|
|
29
72
|
|
|
30
73
|
### Performance - v0.3.0
|
|
31
74
|
|
|
32
|
-
- Sampling runs before the library builds the record. A dropped record costs one hash. It
|
|
75
|
+
- Sampling runs before the library builds the record. A dropped record costs one hash. It does not pay for sanitize, the resource block, `redact` or truncation.
|
|
33
76
|
|
|
34
77
|
## [0.2.0] - 2026-09-08
|
|
35
78
|
|
|
36
79
|
### Breaking changes - v0.2.0
|
|
37
80
|
|
|
38
|
-
- Config
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- `storage` is
|
|
42
|
-
- `console` is
|
|
81
|
+
- Config holds 31 keys in 3 sections. It held 63 keys in 9 sections.
|
|
82
|
+
- A removed key is a fixed library default.
|
|
83
|
+
- An unknown key is ignored. `onDiagnostic` reports `config.invalid` with the message `unknown config key "<key>", ignored. Typo?`.
|
|
84
|
+
- `storage` is a strategy string. It was an object.
|
|
85
|
+
- `console` is a boolean or a level name. It was an object.
|
|
43
86
|
|
|
44
87
|
```ts
|
|
45
88
|
// 0.1.x
|
|
@@ -67,19 +110,19 @@ configure({ endpoint, console: "WARN" });
|
|
|
67
110
|
|
|
68
111
|
### Removed
|
|
69
112
|
|
|
70
|
-
- `rxjs`
|
|
71
|
-
- `dexie`
|
|
72
|
-
-
|
|
113
|
+
- The library replaces `rxjs` with its own buffering, batching, queueing and deferral.
|
|
114
|
+
- The library replaces `dexie` with raw IndexedDB behind `IdbDriver`.
|
|
115
|
+
- `@opentelemetry/api` is the only runtime dependency. `web-vitals` stays the optional peer.
|
|
73
116
|
|
|
74
117
|
### Changed - v0.2.0
|
|
75
118
|
|
|
76
|
-
- IndexedDB database version
|
|
119
|
+
- The IndexedDB database version is 11. The upgrade keeps a 0.1.x batch readable and retries it.
|
|
77
120
|
|
|
78
121
|
## [0.1.2] - 2026-08-30
|
|
79
122
|
|
|
80
123
|
### Fixed - v0.1.2
|
|
81
124
|
|
|
82
|
-
- `telemetry.sdk.version`
|
|
125
|
+
- `telemetry.sdk.version` reported `0.1.0` for a record from `0.1.1`. The version constant and the package version stay in sync now.
|
|
83
126
|
|
|
84
127
|
## [0.1.1] - 2026-08-30
|
|
85
128
|
|
|
@@ -91,5 +134,5 @@ configure({ endpoint, console: "WARN" });
|
|
|
91
134
|
|
|
92
135
|
### Added
|
|
93
136
|
|
|
94
|
-
-
|
|
95
|
-
- Batching, gzip compression, OTLP/JSON and ECS serialization,
|
|
137
|
+
- First release of `@utk09/ui-observability`.
|
|
138
|
+
- Batching, gzip compression, OTLP/JSON and ECS serialization, IndexedDB and localStorage storage, retry with backoff, `sendBeacon` exit flush, an iframe, worker and OpenFin bus, and auto-capture of errors, network, interactions, navigation and web vitals.
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @utk09/ui-observability
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Structured logging and UI observability for browsers, embedded webviews and OpenFin containers. The library imports no framework.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The library batches records and sends them over HTTP as OTLP/JSON. A failed send persists to storage and retries. A closing document flushes what is left. Iframes, workers and OpenFin windows share one sender through the bus. A log call never throws.
|
|
6
6
|
|
|
7
|
-
> **Status:
|
|
7
|
+
> **Status: early development.** A minor release can change a public API. Pin the exact version.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -16,9 +16,9 @@ npm install @utk09/ui-observability
|
|
|
16
16
|
|
|
17
17
|
### Peer Dependencies
|
|
18
18
|
|
|
19
|
-
Both peers are optional. The library has no runtime
|
|
19
|
+
Both peers are optional. The library has no runtime dependency.
|
|
20
20
|
|
|
21
|
-
`web-vitals` (`^4 || ^5 || ^6`)
|
|
21
|
+
Install `web-vitals` (`^4 || ^5 || ^6`) for `capture.webVitals`:
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
configure({
|
|
@@ -30,7 +30,7 @@ configure({
|
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
`@opentelemetry/api` (`^1`)
|
|
33
|
+
Install `@opentelemetry/api` (`^1`) to put records on the traces your spans carry. Without it, the library mints its own `trace_id` and reports `trace.otel_failed` one time. The library imports the package when it is installed. Set `otelLoader` when your bundler cannot resolve the import:
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
configure({
|
|
@@ -43,7 +43,7 @@ configure({
|
|
|
43
43
|
|
|
44
44
|
## Quick Start
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Call `configure()` one time at startup, before the first log call.
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
import { configure, getLogger } from "@utk09/ui-observability";
|
|
@@ -62,9 +62,9 @@ log.logAction("ORDER_SUBMIT", { orderId: "ORD-1001", qty: 100 });
|
|
|
62
62
|
log.error("pricing call failed", caughtError);
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
- `configure()` is idempotent.
|
|
66
|
-
-
|
|
67
|
-
-
|
|
65
|
+
- `configure()` is idempotent. A later call updates the runtime singleton in place. `storage` is fixed at startup. A later change to it is reported and ignored.
|
|
66
|
+
- One context per document calls `configure()`. A second call renames `service.name` on the records of every other context. In a composed page, the shell configures, and each microfrontend takes a namespace.
|
|
67
|
+
- A log call before `configure()` goes to an implicit runtime. It does not throw.
|
|
68
68
|
|
|
69
69
|
---
|
|
70
70
|
|
|
@@ -72,81 +72,81 @@ log.error("pricing call failed", caughtError);
|
|
|
72
72
|
|
|
73
73
|
### Lifecycle & Setup
|
|
74
74
|
|
|
75
|
-
| Function | Description
|
|
76
|
-
| ------------------- |
|
|
77
|
-
| `configure(config)` |
|
|
78
|
-
| `shutdown()` | Flushes pending records and
|
|
75
|
+
| Function | Description |
|
|
76
|
+
| ------------------- | -------------------------------------------------- |
|
|
77
|
+
| `configure(config)` | Starts the runtime singleton, or updates it. |
|
|
78
|
+
| `shutdown()` | Flushes pending records and stops every subsystem. |
|
|
79
79
|
|
|
80
80
|
### Logging Methods
|
|
81
81
|
|
|
82
|
-
| Function | Description
|
|
83
|
-
| ---------------------------------------------- |
|
|
84
|
-
| `getLogger(namespace, options?)` | Returns
|
|
85
|
-
| `trace(msg, payload?)` | Logs a TRACE
|
|
86
|
-
| `debug(msg, payload?)` | Logs a DEBUG
|
|
87
|
-
| `info(msg, payload?)` | Logs an INFO
|
|
88
|
-
| `warn(msg, payload?)` | Logs a WARN
|
|
89
|
-
| `error(msg, err?, payload?)` | Logs an ERROR record with error
|
|
90
|
-
| `logAction(name, payload?)` | Logs
|
|
91
|
-
| `logEvent(name, payload?)` | Logs
|
|
92
|
-
| `logMetric(name, value, unit?, type?, attrs?)` | Logs a
|
|
93
|
-
| `timeSync(label, fn, attrs?)` | Times a
|
|
94
|
-
| `timeAsync(label, fn, attrs?)` | Times
|
|
82
|
+
| Function | Description |
|
|
83
|
+
| ---------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
84
|
+
| `getLogger(namespace, options?)` | Returns the cached logger for a namespace. With `options`, returns a new one, uncached. |
|
|
85
|
+
| `trace(msg, payload?)` | Logs a TRACE record. |
|
|
86
|
+
| `debug(msg, payload?)` | Logs a DEBUG record. |
|
|
87
|
+
| `info(msg, payload?)` | Logs an INFO record. |
|
|
88
|
+
| `warn(msg, payload?)` | Logs a WARN record. |
|
|
89
|
+
| `error(msg, err?, payload?)` | Logs an ERROR record with the error and the breadcrumb trail. |
|
|
90
|
+
| `logAction(name, payload?)` | Logs one user action. |
|
|
91
|
+
| `logEvent(name, payload?)` | Logs one domain or lifecycle event. |
|
|
92
|
+
| `logMetric(name, value, unit?, type?, attrs?)` | Logs a measurement (`gauge`, `counter`, `histogram`). |
|
|
93
|
+
| `timeSync(label, fn, attrs?)` | Times a function and emits a duration histogram. |
|
|
94
|
+
| `timeAsync(label, fn, attrs?)` | Times a promise and emits a duration histogram. |
|
|
95
95
|
|
|
96
96
|
### Context & Correlation
|
|
97
97
|
|
|
98
98
|
| Function | Description |
|
|
99
99
|
| ------------------------------ | ------------------------------------------------------------- |
|
|
100
|
-
| `setContext(key, value)` | Sets
|
|
100
|
+
| `setContext(key, value)` | Sets one ambient attribute on every later record. |
|
|
101
101
|
| `setContextMap(values)` | Merges an attribute map into the ambient context. |
|
|
102
|
-
| `removeContext(key)` | Removes
|
|
103
|
-
| `startJourney(name, options?)` | Starts a
|
|
104
|
-
| `endJourney()` |
|
|
105
|
-
| `currentJourney()` | Returns the active `Journey
|
|
106
|
-
| `getJourneyToken()` | Serializes the active journey into a
|
|
107
|
-
| `adoptJourney(token)` | Adopts a
|
|
108
|
-
| `startTrace()` | Rotates the ambient
|
|
109
|
-
| `getTraceHeaders()` | Returns W3C `traceparent`
|
|
102
|
+
| `removeContext(key)` | Removes one attribute from the ambient context. |
|
|
103
|
+
| `startJourney(name, options?)` | Starts a journey across windows. |
|
|
104
|
+
| `endJourney()` | Ends the active journey. |
|
|
105
|
+
| `currentJourney()` | Returns the active `Journey`, or null. |
|
|
106
|
+
| `getJourneyToken()` | Serializes the active journey into a URL token. |
|
|
107
|
+
| `adoptJourney(token)` | Adopts a journey token into this context. |
|
|
108
|
+
| `startTrace()` | Rotates the ambient trace context. |
|
|
109
|
+
| `getTraceHeaders()` | Returns the W3C `traceparent` header for an outgoing request. |
|
|
110
110
|
| `registerWorker(worker)` | Attaches a Web Worker or MessagePort to the bus. |
|
|
111
111
|
|
|
112
112
|
### Delivery & Diagnostics
|
|
113
113
|
|
|
114
|
-
| Function | Description
|
|
115
|
-
| ------------------------- |
|
|
116
|
-
| `flush()` |
|
|
117
|
-
| `getQueueDepth()` | Returns the number of batches
|
|
118
|
-
| `getDiagnosticCounters()` | Returns
|
|
114
|
+
| Function | Description |
|
|
115
|
+
| ------------------------- | ------------------------------------------------------------- |
|
|
116
|
+
| `flush()` | Sends the records held in the pipeline or the forward buffer. |
|
|
117
|
+
| `getQueueDepth()` | Returns the number of batches in storage. |
|
|
118
|
+
| `getDiagnosticCounters()` | Returns the count of each diagnostic code. |
|
|
119
119
|
|
|
120
120
|
---
|
|
121
121
|
|
|
122
122
|
## Configuration Options
|
|
123
123
|
|
|
124
|
-
`endpoint` is the only required
|
|
125
|
-
|
|
126
|
-
| Key | Default | Description
|
|
127
|
-
| ---------------------------- | ------------ |
|
|
128
|
-
| `endpoint` | _required_ |
|
|
129
|
-
| `serviceName` | `""` |
|
|
130
|
-
| `serviceVersion` | `""` |
|
|
131
|
-
| `environment` | `""` |
|
|
132
|
-
| `enabled` | `true` |
|
|
133
|
-
| `minLevel` | `"INFO"` |
|
|
134
|
-
| `compression` | `"gzip"` |
|
|
135
|
-
| `serializer` | `"otlp"` |
|
|
136
|
-
| `credentials` | `"omit"` | Fetch credentials
|
|
137
|
-
| `headers` | `{}` | Static headers or
|
|
138
|
-
| `storage` | `"auto"` |
|
|
139
|
-
| `sampling.defaultRate` | `1` | Keep rate
|
|
140
|
-
| `sampling.rates` | `{}` |
|
|
141
|
-
| `sampling.alwaysSampleTypes` | `["action"]` | Record types
|
|
142
|
-
| `bus.mode` | `"auto"` |
|
|
143
|
-
| `bus.trustedOrigins` | `[]` | Origins
|
|
144
|
-
| `bus.openFinRole` | `"auto"` |
|
|
145
|
-
| `capture` | See below |
|
|
146
|
-
| `console` | `false` | Mirrors records to devtools. `true`
|
|
147
|
-
| `otelLoader()` | `undefined` | Supplies `@opentelemetry/api`. Omit it and the library imports the package.
|
|
148
|
-
| `redact(record)` | `undefined` |
|
|
149
|
-
| `onDiagnostic(event)` | `undefined` |
|
|
124
|
+
`endpoint` is the only required key.
|
|
125
|
+
|
|
126
|
+
| Key | Default | Description |
|
|
127
|
+
| ---------------------------- | ------------ | --------------------------------------------------------------------------------- |
|
|
128
|
+
| `endpoint` | _required_ | HTTP endpoint that receives the batches. |
|
|
129
|
+
| `serviceName` | `""` | `service.name` on every record. |
|
|
130
|
+
| `serviceVersion` | `""` | `service.version` on every record. |
|
|
131
|
+
| `environment` | `""` | `deployment.environment` on every record. |
|
|
132
|
+
| `enabled` | `true` | Kill switch. `false` makes every log call a no-op. |
|
|
133
|
+
| `minLevel` | `"INFO"` | Lowest level that ships (`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`). |
|
|
134
|
+
| `compression` | `"gzip"` | `gzip` or `none`. It applies above 1 KB. |
|
|
135
|
+
| `serializer` | `"otlp"` | `otlp`, `ecs`, or a custom `LogSerializer`. |
|
|
136
|
+
| `credentials` | `"omit"` | Fetch credentials mode. Set `"include"` for cookie auth. |
|
|
137
|
+
| `headers` | `{}` | Static headers, or a function that returns them. |
|
|
138
|
+
| `storage` | `"auto"` | `auto`, `indexeddb`, `localstorage`, `memory` or `none`. Fixed at startup. |
|
|
139
|
+
| `sampling.defaultRate` | `1` | Keep rate for a namespace with no rule. |
|
|
140
|
+
| `sampling.rates` | `{}` | Keep rate per namespace. The longest matching prefix wins. |
|
|
141
|
+
| `sampling.alwaysSampleTypes` | `["action"]` | Record types that ignore the rate. |
|
|
142
|
+
| `bus.mode` | `"auto"` | `auto`, `sender`, `forwarder` or `off`. |
|
|
143
|
+
| `bus.trustedOrigins` | `[]` | Origins that may post records from a cross-origin frame. |
|
|
144
|
+
| `bus.openFinRole` | `"auto"` | `auto`, `provider` or `client`. |
|
|
145
|
+
| `capture` | See below | Auto-capture settings. |
|
|
146
|
+
| `console` | `false` | Mirrors records to devtools. `true` starts at `DEBUG`. A level name starts there. |
|
|
147
|
+
| `otelLoader()` | `undefined` | Supplies `@opentelemetry/api`. Omit it and the library imports the package. |
|
|
148
|
+
| `redact(record)` | `undefined` | Mutates a record before it ships. Return `null` to drop it. |
|
|
149
|
+
| `onDiagnostic(event)` | `undefined` | Receives this library's own faults. |
|
|
150
150
|
|
|
151
151
|
### Auto-Capture Options
|
|
152
152
|
|
|
@@ -166,31 +166,31 @@ capture: {
|
|
|
166
166
|
}
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
`fullUrls` is off
|
|
169
|
+
`fullUrls` is off. The library cuts a page URL, a request target and a failed resource URL at the first `?` or `#`. `ignoreUrls` and `propagateTraceHeaderTo` match the whole URL.
|
|
170
170
|
|
|
171
171
|
---
|
|
172
172
|
|
|
173
173
|
## Core Architecture
|
|
174
174
|
|
|
175
|
-
- **Document
|
|
176
|
-
- **
|
|
177
|
-
- **Five
|
|
178
|
-
- **Durability
|
|
179
|
-
- **
|
|
175
|
+
- **Document singleton:** The runtime pins to `globalThis[Symbol.for("ui-observability.runtime")]`. Federated microfrontends and separate bundles share one buffer, one sequence and one transport.
|
|
176
|
+
- **One sender:** Iframes, workers and OpenFin views find the nearest long-lived context. They forward their records to it over the bus. That context batches, stores and sends for all of them.
|
|
177
|
+
- **Five correlation ids:** Each record carries `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
|
|
178
|
+
- **Durability and exit flush:** A failed send persists to IndexedDB or localStorage, then retries with exponential jittered backoff. On `pagehide` or `freeze`, pending records go out with `navigator.sendBeacon` below 60 KB. A larger payload goes to the emergency queue.
|
|
179
|
+
- **Emergency queue:** The emergency queue is best effort. It writes to `localStorage` synchronously. No other storage works while the document unloads. A refused write reports `storage.quota_exceeded`. The library then loses the batch.
|
|
180
|
+
- **Configuration after startup:** A second `configure()` call merges the new options into the live runtime. The `storage` option is the exception. The runtime builds the storage adapter one time. A change leaves the stored batches in the old adapter. The runtime refuses the change. It reports `config.invalid`.
|
|
181
|
+
- **Deterministic sampling:** FNV-1a hashing applies one keep rate to a whole journey. An error and an explicit action bypass sampling.
|
|
180
182
|
|
|
181
183
|
---
|
|
182
184
|
|
|
183
185
|
## Ingest Server Requirements
|
|
184
186
|
|
|
185
|
-
|
|
187
|
+
The server must obey this contract:
|
|
186
188
|
|
|
187
|
-
1. **Protocol
|
|
188
|
-
2. **
|
|
189
|
-
3. **
|
|
190
|
-
4. **
|
|
191
|
-
|
|
192
|
-
- `413`: Payload too large. Prompts client batch splitting.
|
|
193
|
-
- `4xx`: Non-retryable client error. Drops batch.
|
|
189
|
+
1. **Protocol:** Accept `POST` with `Content-Type: application/json` or `text/plain;charset=UTF-8`. `sendBeacon` sends the second one to avoid a CORS preflight.
|
|
190
|
+
2. **Preflight:** Answer `OPTIONS` on the ingest path. The transport sends two headers with each batch: `X-UiObs-Batch-Id` and `X-UiObs-Attempt`. For a payload of more than 1 KiB, the transport also sends `Content-Encoding: gzip`. Each of these headers causes a CORS preflight. Allow the three headers with `Access-Control-Allow-Headers: content-type, content-encoding, x-uiobs-batch-id, x-uiobs-attempt`. If the server does not allow them, each preflight fails. The transport then gets a `TypeError`. The retry engine sends the batch five more times, then drops the batch. The exit flush sends no headers, so the exit flush continues to work. The server thus receives only the records from the exit flush.
|
|
191
|
+
3. **Deduplication:** Deduplicate on the `X-UiObs-Batch-Id` header and the `uiobs_batch_id` query parameter. Hold the ids for 24 hours minimum.
|
|
192
|
+
4. **Throttling:** Return `429` or `503` with `Retry-After`. Expose the header with `Access-Control-Expose-Headers: retry-after`.
|
|
193
|
+
5. **Status codes:** `200`, `202` and `204` accept the batch. `413` makes the client split the batch. Another `4xx` drops the batch.
|
|
194
194
|
|
|
195
195
|
---
|
|
196
196
|
|
|
@@ -198,8 +198,8 @@ Receiving servers must implement the following contract:
|
|
|
198
198
|
|
|
199
199
|
```bash
|
|
200
200
|
npm install
|
|
201
|
-
npm run dev #
|
|
202
|
-
npm run verify #
|
|
201
|
+
npm run dev # Playground, mock ingest server and iframe host
|
|
202
|
+
npm run verify # Format check, version sync, typecheck, lint, build and tests
|
|
203
203
|
```
|
|
204
204
|
|
|
205
205
|
- Vanilla playground: `http://localhost:5173/playground/vanilla/index.html`
|
|
@@ -207,20 +207,20 @@ npm run verify # Runs format check, typecheck, lint, build, and tests
|
|
|
207
207
|
|
|
208
208
|
### Example Applications
|
|
209
209
|
|
|
210
|
-
Build the package
|
|
210
|
+
Build the package first:
|
|
211
211
|
|
|
212
212
|
```bash
|
|
213
213
|
npm run build
|
|
214
214
|
npm run example:react # http://localhost:5180
|
|
215
215
|
npm run example:angular # http://localhost:4200
|
|
216
|
-
npm run example:microfrontend # Shell on http://localhost:5191, remotes on 5192
|
|
216
|
+
npm run example:microfrontend # Shell on http://localhost:5191, remotes on 5192 and 5193
|
|
217
217
|
```
|
|
218
218
|
|
|
219
219
|
---
|
|
220
220
|
|
|
221
221
|
## Changelog
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
[CHANGELOG.md](CHANGELOG.md) holds the released versions and their breaking changes.
|
|
224
224
|
|
|
225
225
|
---
|
|
226
226
|
|
package/dist/bus/bus.d.ts
CHANGED
|
@@ -97,6 +97,15 @@ export declare class Bus {
|
|
|
97
97
|
private postOver;
|
|
98
98
|
/** Routes incoming messages to registered handlers or upstream targets. */
|
|
99
99
|
private readonly receive;
|
|
100
|
+
/**
|
|
101
|
+
* Tells whether records from a link can go upstream. Posted back on the link
|
|
102
|
+
* they arrived on, the records echo to their sender. A direct link is an
|
|
103
|
+
* exception: it is one call into one parent, so two direct links in a chain are
|
|
104
|
+
* different links.
|
|
105
|
+
* @param link Kind of the link the records arrived on.
|
|
106
|
+
* @returns True if the relay is safe.
|
|
107
|
+
*/
|
|
108
|
+
private canRelay;
|
|
100
109
|
/** Returns whether this context can accept ownership over the given link type. */
|
|
101
110
|
private canOwn;
|
|
102
111
|
/** Resolves whether this context represents the OpenFin platform provider. */
|
package/dist/bus/links.d.ts
CHANGED
|
@@ -80,13 +80,14 @@ export declare function createChildrenLink(receive: Receive, trustedOrigins: str
|
|
|
80
80
|
*/
|
|
81
81
|
export declare function createBroadcastLink(channelName: string, receive: Receive, diagnostics: Diagnostics): Link | null;
|
|
82
82
|
/**
|
|
83
|
-
* Creates an OpenFin InterApplicationBus link
|
|
84
|
-
* @param topic InterApplicationBus topic
|
|
83
|
+
* Creates an OpenFin InterApplicationBus link scoped to one application.
|
|
84
|
+
* @param topic InterApplicationBus topic prefix.
|
|
85
|
+
* @param appUuid OpenFin application uuid owning this context.
|
|
85
86
|
* @param receive Callback for received topic messages.
|
|
86
87
|
* @param diagnostics Diagnostics reporter.
|
|
87
|
-
* @returns OpenFin link, or null if InterApplicationBus is unavailable.
|
|
88
|
+
* @returns OpenFin link, or null if InterApplicationBus or the identity is unavailable.
|
|
88
89
|
*/
|
|
89
|
-
export declare function createOpenFinLink(topic: string, receive: Receive, diagnostics: Diagnostics): Link | null;
|
|
90
|
+
export declare function createOpenFinLink(topic: string, appUuid: string | undefined, receive: Receive, diagnostics: Diagnostics): Link | null;
|
|
90
91
|
/**
|
|
91
92
|
* Creates the worker-side link pointing at the document that created this
|
|
92
93
|
* worker. Emits `kind: "owner"`.
|
package/dist/capture/types.d.ts
CHANGED
|
@@ -43,6 +43,18 @@ export interface CaptureLogger {
|
|
|
43
43
|
*/
|
|
44
44
|
debug(message: string, payload?: Record<string, unknown>): void;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Capture work that runs one time for each document, not one time for each
|
|
48
|
+
* install. A reconfigure builds new capture instances, so instance state cannot
|
|
49
|
+
* hold this. web-vitals has no unsubscribe, and a second subscription reports
|
|
50
|
+
* each metric two times.
|
|
51
|
+
*/
|
|
52
|
+
export interface CaptureOnce {
|
|
53
|
+
/** True once the web-vitals reporters are subscribed. */
|
|
54
|
+
webVitals: boolean;
|
|
55
|
+
/** True once navigation timing has been reported. */
|
|
56
|
+
navigationTiming: boolean;
|
|
57
|
+
}
|
|
46
58
|
/** Shared runtime dependencies provided to auto-capture instances. */
|
|
47
59
|
export interface CaptureContext {
|
|
48
60
|
/** Active runtime configuration. */
|
|
@@ -55,6 +67,8 @@ export interface CaptureContext {
|
|
|
55
67
|
breadcrumbs: BreadcrumbBuffer;
|
|
56
68
|
/** Active trace context provider. */
|
|
57
69
|
tracing: TraceEngine;
|
|
70
|
+
/** Guards for the capture work that a reinstall must not repeat. */
|
|
71
|
+
once: CaptureOnce;
|
|
58
72
|
}
|
|
59
73
|
/** Lifecycle interface for browser instrumentation modules. */
|
|
60
74
|
export interface Capture {
|
|
@@ -12,10 +12,13 @@ export declare class WebVitalsCapture implements Capture {
|
|
|
12
12
|
constructor(ctx: CaptureContext);
|
|
13
13
|
/** Reports navigation benchmarks and initiates web-vitals loading. */
|
|
14
14
|
install(): void;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Marks module uninstalled. The web-vitals reporters stay subscribed: the
|
|
17
|
+
* package has no unsubscribe. `ctx.once` prevents a second set.
|
|
18
|
+
*/
|
|
16
19
|
uninstall(): void;
|
|
17
20
|
/** Loads the web-vitals module and registers metric reporters. */
|
|
18
21
|
private loadWebVitals;
|
|
19
|
-
/** Extracts and logs PerformanceNavigationTiming benchmarks. */
|
|
22
|
+
/** Extracts and logs PerformanceNavigationTiming benchmarks one time for each document. */
|
|
20
23
|
private reportNavigationTiming;
|
|
21
24
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
var ee = "[ui-observability]", te = 1e3, e = "ui-observability.session", t = "ui-observability.tab", n = 18e5, r = 6e4, i = /OpenFin/i, a = /\bwv\b/, o = /\b(iPhone|iPad|iPod)\b/, s = /\bMacintosh\b/, c = /\bMobile\b/, l = "AppleWebKit", u = "Safari/", d = 55296, f = 56319, p = 2048, m = {
|
|
3
|
+
TRACE: 1,
|
|
4
|
+
DEBUG: 5,
|
|
5
|
+
INFO: 9,
|
|
6
|
+
WARN: 13,
|
|
7
|
+
ERROR: 17,
|
|
8
|
+
FATAL: 21
|
|
9
|
+
}, h = m, g = "log.type", _ = "log.seq", v = "app.namespace", y = "page.url", b = "url.full", x = "journey.id", S = "journey.name", C = "journey.parent_id", w = "uiobs.sanitize_failed", T = "uiobs.attributes_dropped", E = "uiobs.attributes_bytes", D = "service.name", O = "service.version", k = "deployment.environment", A = "telemetry.sdk.name", j = "telemetry.sdk.version", M = "telemetry.sdk.language", N = "host.platform", P = "session.id", F = "tab.id", I = "context.id", L = "browser.user_agent", R = "openfin.uuid", z = "openfin.name", B = "@utk09/ui-observability", V = "0.4.1", H = "webjs", U = "otlp", W = { WARN: "warning" }, G = "application/json", K = "application/x-ndjson", q = 1000000n, J = /^\d+$/, Y = "Content-Type", X = "Content-Encoding", Z = "Retry-After", Q = "X-UiObs-Batch-Id", ne = "X-UiObs-Attempt", re = "gzip", ie = 1e3, ae = 6e4, oe = "text/plain;charset=UTF-8", $ = "uiobs_batch_id", se = "uiobs_exit", ce = "ui-observability.batch.", le = "ui-observability.emergency.", ue = "ui-observability.probe", de = "QuotaExceededError", fe = "batches", pe = "createdAt", me = "indexeddb", he = "localstorage", ge = "memory", _e = "none", ve = "ui-observability.drain", ye = "ui-observability.emergency", be = "ui-observability.journey", xe = 2e3, Se = "uiObsJourney", Ce = /\+/g, we = /\//g, Te = /=+$/, Ee = /-/g, De = /_/g, Oe = 3e5, ke = "traceparent", Ae = 2166136261, je = 16777619, Me = 4294967295, Ne = "metric", Pe = "ui-observability/1", Fe = "ui-observability.runtime", Ie = 1e4, Le = "color:#888", Re = 1e3, ze = 6e4, Be = "uiobs.capture", Ve = "uiobs.storage", He = "count", Ue = "unknown-service", We = [
|
|
10
|
+
"redact",
|
|
11
|
+
"onDiagnostic",
|
|
12
|
+
"headers",
|
|
13
|
+
"serializer",
|
|
14
|
+
"otelLoader"
|
|
15
|
+
], Ge = [
|
|
16
|
+
"sampling",
|
|
17
|
+
"bus",
|
|
18
|
+
"capture"
|
|
19
|
+
], Ke = {
|
|
20
|
+
sampling: [],
|
|
21
|
+
bus: [],
|
|
22
|
+
capture: ["webVitalsLoader"]
|
|
23
|
+
}, qe = {
|
|
24
|
+
endpoint: "",
|
|
25
|
+
serviceName: "",
|
|
26
|
+
serviceVersion: "",
|
|
27
|
+
environment: "",
|
|
28
|
+
enabled: !0,
|
|
29
|
+
minLevel: "INFO",
|
|
30
|
+
compression: "gzip",
|
|
31
|
+
credentials: "omit",
|
|
32
|
+
storage: "auto",
|
|
33
|
+
sampling: {
|
|
34
|
+
defaultRate: 1,
|
|
35
|
+
rates: {},
|
|
36
|
+
alwaysSampleTypes: ["action"]
|
|
37
|
+
},
|
|
38
|
+
bus: {
|
|
39
|
+
mode: "auto",
|
|
40
|
+
trustedOrigins: [],
|
|
41
|
+
openFinRole: "auto"
|
|
42
|
+
},
|
|
43
|
+
capture: {
|
|
44
|
+
errors: !0,
|
|
45
|
+
rejections: !0,
|
|
46
|
+
resourceErrors: !1,
|
|
47
|
+
fetch: !1,
|
|
48
|
+
xhr: !1,
|
|
49
|
+
interactions: !1,
|
|
50
|
+
navigation: !1,
|
|
51
|
+
webVitals: !1,
|
|
52
|
+
fullUrls: !1,
|
|
53
|
+
ignoreUrls: [],
|
|
54
|
+
propagateTraceHeaderTo: []
|
|
55
|
+
},
|
|
56
|
+
console: null
|
|
57
|
+
}, Je = "DEBUG", Ye = 2e3, Xe = 1e4, Ze = 15e3, Qe = 1024, $e = "UiObservability", et = {
|
|
58
|
+
maxBatches: 500,
|
|
59
|
+
maxAgeMs: 864e5,
|
|
60
|
+
maxAttempts: 5
|
|
61
|
+
}, tt = 1e4, nt = 2e3, rt = 6e4, it = 3e4, at = 18e5, ot = "__uiobs_journey", st = "ui_observability_control", ct = 1500, lt = 5e3, ut = {
|
|
62
|
+
maxBodyChars: 4096,
|
|
63
|
+
maxAttributeChars: 8192,
|
|
64
|
+
maxAttributeCount: 128,
|
|
65
|
+
maxStackChars: 8192,
|
|
66
|
+
maxDepth: 6,
|
|
67
|
+
maxArrayLength: 100,
|
|
68
|
+
maxNodes: 1e4,
|
|
69
|
+
maxRecordBytes: 32768
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { fe as $, ue as $t, oe as A, P as At, lt as B, U as Bt, Be as C, I as Ct, Le as D, R as Dt, Je as E, z as Et, Re as F, nt as Ft, ne as G, $e as Gt, Ae as H, e as Ht, W as I, it as It, Y as J, Ve as Jt, Q as K, tt as Kt, ye as L, rt as Lt, He as M, M as Mt, te as N, A as Nt, G as O, D as Ot, ve as P, j as Pt, pe as Q, _e as Qt, le as R, Fe as Rt, Pe as S, L as St, Ge as T, N as Tt, je as U, r as Ut, Ie as V, n as Vt, ze as W, m as Wt, f as X, he as Xt, Z as Y, me as Yt, d as Z, ge as Zt, we as _, $ as _t, x as a, Oe as an, ee as at, st as b, ut as bt, _ as c, Ke as cn, s as ct, w as d, l as dn, c as dt, t as en, o as et, b as f, J as ft, Ce as g, i as gt, Te as h, xe as ht, T as i, ke as in, h as it, qe as j, F as jt, K as k, O as kt, g as l, Ue as ln, Xe as lt, De as m, Se as mt, v as n, B as nn, be as nt, S as o, Me as on, Ye as ot, Ee as p, q as pt, X as q, et as qt, E as r, V as rn, ot as rt, C as s, We as sn, Ne as st, a as t, H as tn, at as tt, y as u, p as un, ie as ut, ce as v, se as vt, Qe as w, k as wt, ct as x, Ze as xt, ae as y, de as yt, re as z, u as zt };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=constants-DVbpJ1tv.js.map
|