@utk09/ui-observability 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +56 -36
- package/dist/batch-DEK4bv9N.js +31 -0
- package/dist/batch-DEK4bv9N.js.map +1 -0
- package/dist/batch-DEVFs28i.cjs +2 -0
- package/dist/batch-DEVFs28i.cjs.map +1 -0
- package/dist/{bus-CtJWf9QN.cjs → bus-DNFvTkif.cjs} +2 -2
- package/dist/{bus-CtJWf9QN.cjs.map → bus-DNFvTkif.cjs.map} +1 -1
- package/dist/{bus-D8kH58tb.js → bus-HVQ8E72V.js} +8 -8
- package/dist/{bus-D8kH58tb.js.map → bus-HVQ8E72V.js.map} +1 -1
- package/dist/{console-DjLbryED.js → console-C9Y639mn.js} +3 -3
- package/dist/{console-DjLbryED.js.map → console-C9Y639mn.js.map} +1 -1
- package/dist/{console-BpHfWstv.cjs → console-DssDxq1B.cjs} +2 -2
- package/dist/{console-BpHfWstv.cjs.map → console-DssDxq1B.cjs.map} +1 -1
- package/dist/constants-N99w84xy.js +117 -0
- package/dist/constants-N99w84xy.js.map +1 -0
- package/dist/constants-X86IDwkC.cjs +2 -0
- package/dist/constants-X86IDwkC.cjs.map +1 -0
- package/dist/constants.d.ts +18 -11
- package/dist/core/drops.d.ts +29 -0
- package/dist/core/hold-buffer.d.ts +27 -0
- package/dist/core/pipeline.d.ts +2 -7
- package/dist/core/runtime.d.ts +44 -8
- package/dist/core/sender.d.ts +4 -1
- package/dist/deadline-5_PecIl5.js +26 -0
- package/dist/deadline-5_PecIl5.js.map +1 -0
- package/dist/deadline-XSnm95pg.cjs +2 -0
- package/dist/deadline-XSnm95pg.cjs.map +1 -0
- package/dist/{errors-CpGRhhIf.cjs → errors-BTWuVnHZ.cjs} +2 -2
- package/dist/{errors-CpGRhhIf.cjs.map → errors-BTWuVnHZ.cjs.map} +1 -1
- package/dist/{errors-DH4QJS0u.js → errors-CQusIGWJ.js} +4 -4
- package/dist/{errors-DH4QJS0u.js.map → errors-CQusIGWJ.js.map} +1 -1
- package/dist/{deadline-Cbg2cbUw.cjs → identity-B1GDS1Tb.cjs} +2 -2
- package/dist/identity-B1GDS1Tb.cjs.map +1 -0
- package/dist/{deadline-B5DINjD5.js → identity-D4DPjTM9.js} +3 -26
- package/dist/identity-D4DPjTM9.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +467 -318
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-n1qkFBGA.js → indexeddb-storage-B8SGUzSV.js} +79 -50
- package/dist/indexeddb-storage-B8SGUzSV.js.map +1 -0
- package/dist/indexeddb-storage-ukzC82dm.cjs +2 -0
- package/dist/indexeddb-storage-ukzC82dm.cjs.map +1 -0
- package/dist/{interactions-31eHGwEQ.cjs → interactions-CcxrVzpg.cjs} +2 -2
- package/dist/{interactions-31eHGwEQ.cjs.map → interactions-CcxrVzpg.cjs.map} +1 -1
- package/dist/{interactions-OU94MPXs.js → interactions-CnjfQgw3.js} +2 -2
- package/dist/{interactions-OU94MPXs.js.map → interactions-CnjfQgw3.js.map} +1 -1
- package/dist/{journey-CeJ1QoT2.js → journey-DjvDzHyp.js} +17 -16
- package/dist/{journey-CeJ1QoT2.js.map → journey-DjvDzHyp.js.map} +1 -1
- package/dist/journey-DxlfdFJV.cjs +2 -0
- package/dist/journey-DxlfdFJV.cjs.map +1 -0
- package/dist/{library-request-C9uJFlbq.cjs → library-request-BZ1ekVtl.cjs} +2 -2
- package/dist/{library-request-C9uJFlbq.cjs.map → library-request-BZ1ekVtl.cjs.map} +1 -1
- package/dist/{library-request-DvhuplAB.js → library-request-C8kc5YWv.js} +2 -2
- package/dist/{library-request-DvhuplAB.js.map → library-request-C8kc5YWv.js.map} +1 -1
- package/dist/{long-frames-B8VdA_ny.cjs → long-frames-BGik_Yhy.cjs} +2 -2
- package/dist/{long-frames-B8VdA_ny.cjs.map → long-frames-BGik_Yhy.cjs.map} +1 -1
- package/dist/{long-frames-C_7OutLs.js → long-frames-CZk3XOkH.js} +3 -3
- package/dist/{long-frames-C_7OutLs.js.map → long-frames-CZk3XOkH.js.map} +1 -1
- package/dist/models/batch.d.ts +14 -0
- package/dist/models/config.d.ts +146 -0
- package/dist/models/drop.d.ts +39 -0
- package/dist/models/storage.d.ts +15 -3
- package/dist/{network-D_lloS5t.js → network-51iicpLl.js} +19 -19
- package/dist/{network-D_lloS5t.js.map → network-51iicpLl.js.map} +1 -1
- package/dist/{network-BAV7ipyn.cjs → network-jBbjyAJP.cjs} +2 -2
- package/dist/{network-BAV7ipyn.cjs.map → network-jBbjyAJP.cjs.map} +1 -1
- package/dist/{platform-IHBZGqUe.js → platform-Cjts-8k8.js} +2 -2
- package/dist/{platform-IHBZGqUe.js.map → platform-Cjts-8k8.js.map} +1 -1
- package/dist/{platform-D4wu1eIF.cjs → platform-DW3GFIUE.cjs} +2 -2
- package/dist/{platform-D4wu1eIF.cjs.map → platform-DW3GFIUE.cjs.map} +1 -1
- package/dist/{remote-rules-kuDf5gbe.cjs → remote-rules-ByS34k4e.cjs} +2 -2
- package/dist/{remote-rules-kuDf5gbe.cjs.map → remote-rules-ByS34k4e.cjs.map} +1 -1
- package/dist/{remote-rules-Bt1XsdEQ.js → remote-rules-M-XZ1xbe.js} +2 -2
- package/dist/{remote-rules-Bt1XsdEQ.js.map → remote-rules-M-XZ1xbe.js.map} +1 -1
- package/dist/{sampling-o0VY1mqQ.js → sampling-BN3Oi6SV.js} +9 -9
- package/dist/{sampling-o0VY1mqQ.js.map → sampling-BN3Oi6SV.js.map} +1 -1
- package/dist/{sampling-BI15ds9D.cjs → sampling-b2ck5X98.cjs} +2 -2
- package/dist/{sampling-BI15ds9D.cjs.map → sampling-b2ck5X98.cjs.map} +1 -1
- package/dist/{sanitize-DSIP7amZ.cjs → sanitize-DKp5MRsa.cjs} +2 -2
- package/dist/{sanitize-DSIP7amZ.cjs.map → sanitize-DKp5MRsa.cjs.map} +1 -1
- package/dist/{sanitize-B9UheVKc.js → sanitize-Dwj9JCkI.js} +2 -2
- package/dist/{sanitize-B9UheVKc.js.map → sanitize-Dwj9JCkI.js.map} +1 -1
- package/dist/{sender-BnNj9bOX.js → sender-BBY0IcUo.js} +328 -269
- package/dist/sender-BBY0IcUo.js.map +1 -0
- package/dist/sender-BXoAZKum.cjs +3 -0
- package/dist/sender-BXoAZKum.cjs.map +1 -0
- package/dist/storage/emergency-queue.d.ts +4 -1
- package/dist/storage/eviction.d.ts +40 -0
- package/dist/storage/idb-driver.d.ts +6 -0
- package/dist/storage/indexeddb-storage.d.ts +13 -5
- package/dist/storage/local-storage.d.ts +24 -1
- package/dist/storage/memory-storage.d.ts +7 -0
- package/dist/{storm-Y-yuBhvv.cjs → storm-CKuaBp7i.cjs} +2 -2
- package/dist/{storm-Y-yuBhvv.cjs.map → storm-CKuaBp7i.cjs.map} +1 -1
- package/dist/{storm-BTw0J6eE.js → storm-DhtL2eVr.js} +2 -2
- package/dist/{storm-BTw0J6eE.js.map → storm-DhtL2eVr.js.map} +1 -1
- package/dist/transport/exit-flush.d.ts +6 -0
- package/dist/transport/retry-engine.d.ts +7 -3
- package/dist/transport/status-transport.d.ts +4 -1
- package/dist/utils/console.d.ts +4 -1
- package/package.json +1 -1
- package/dist/constants-Br3b89Wg.cjs +0 -2
- package/dist/constants-Br3b89Wg.cjs.map +0 -1
- package/dist/constants-DM94FjVX.js +0 -96
- package/dist/constants-DM94FjVX.js.map +0 -1
- package/dist/deadline-B5DINjD5.js.map +0 -1
- package/dist/deadline-Cbg2cbUw.cjs.map +0 -1
- package/dist/indexeddb-storage-DNdf1fmL.cjs +0 -2
- package/dist/indexeddb-storage-DNdf1fmL.cjs.map +0 -1
- package/dist/indexeddb-storage-n1qkFBGA.js.map +0 -1
- package/dist/journey-CE2EcwHW.cjs +0 -2
- package/dist/journey-CE2EcwHW.cjs.map +0 -1
- package/dist/sender-BnNj9bOX.js.map +0 -1
- package/dist/sender-D0OsyB1c.cjs +0 -3
- package/dist/sender-D0OsyB1c.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
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.9.1] - 2026-10-29
|
|
6
|
+
|
|
7
|
+
### Added - v0.9.1
|
|
8
|
+
|
|
9
|
+
- `batching` sets the batch size and the flush interval of the log stream and of the metric stream. The keys are `logFlushIntervalMs`, `logBatchSize`, `metricFlushIntervalMs` and `metricBatchSize`.
|
|
10
|
+
- `retention` sets `maxBatches`, `maxAgeMs` and `maxAttempts` for undelivered batches.
|
|
11
|
+
- With `retention.mode: "until-delivered"`, a stored batch has no age limit and no attempt limit. `maxBatches` still applies. A permanent error still drops the batch.
|
|
12
|
+
- With `retention.mode: "until-delivered"`, a batch that always gets a temporary error stays first in the queue. The batches behind it wait.
|
|
13
|
+
- `limits` sets the 8 size limits of each record: `maxBodyChars`, `maxAttributeChars`, `maxAttributeCount`, `maxStackChars`, `maxDepth`, `maxArrayLength`, `maxNodes` and `maxRecordBytes`. The console uses the same limits.
|
|
14
|
+
- `journey.maxAgeMs` sets the maximum open time of a journey.
|
|
15
|
+
- Each new key has a range. A value outside its range reports `config.invalid`. The value in force stays.
|
|
16
|
+
- `onDrop(summary)` receives a summary when the library loses records that it built. The summary has `reason`, `records`, `batchIds`, `journeyIds` and `actions`. Sampling, `minLevel` and `redact` do not cause a loss.
|
|
17
|
+
- The library joins the losses of one reason in one task into one summary. Each list holds at most 20 different values.
|
|
18
|
+
- The `onDrop` reasons are `buffer_full`, `expired`, `over_capacity`, `quota`, `max_attempts`, `rejected`, `unserializable`, `exit_queue_full`, `load_failed` and `not_stored`.
|
|
19
|
+
- `load_failed` covers the records that wait for the delivery stack when its load fails. It also covers these records when `shutdown()` comes before the load ends. After a failed load, each new record also reports `load_failed`.
|
|
20
|
+
- `not_stored` covers a failed send that storage did not keep. The cause is an IndexedDB write error or `storage: "none"`.
|
|
21
|
+
- The `onDrop` hook runs inside the library request scope and the library console scope. Network capture and console capture skip its requests and its console lines.
|
|
22
|
+
- Do not log through the library in the `onDrop` hook. A record from the hook can evict a stored batch.
|
|
23
|
+
- `onDrop` can report a batch that storage evicts during its send. The server can still receive that batch.
|
|
24
|
+
- The package exports the types `DropSummary` and `LossReason`.
|
|
25
|
+
|
|
26
|
+
### Changed - v0.9.1
|
|
27
|
+
|
|
28
|
+
- A later `configure()` cannot change `batching` or `retention` after the delivery stack loads. It cannot change `limits` or `journey.maxAgeMs` after the first `configure()`. It reports `config.invalid`. The values in force stay.
|
|
29
|
+
- A log call before `configure()` starts a runtime with defaults. The first `configure()` then sets `batching`, `retention`, `limits` and `journey.maxAgeMs` of that runtime.
|
|
30
|
+
- An action is an audit fact. When storage is over `retention.maxBatches` or over the quota of the browser, it removes the batches without an action first. `retention.maxAgeMs` still removes each old batch.
|
|
31
|
+
- The hold buffers keep up to 2000 actions before startup and while the delivery stack loads. The 500-record limit applies only to the other records.
|
|
32
|
+
- A prune that removes expired batches and batches over `retention.maxBatches` reports each group with its own reason. `storage.evicted` and the gap warning record come one time for each group.
|
|
33
|
+
- With `storage: "none"`, a failed send gives the gap warning record. A throttle limits that record.
|
|
34
|
+
- The gzip size budget of the main graph is 24,400 B. It was 23,700 B.
|
|
35
|
+
|
|
36
|
+
### Fixed - v0.9.1
|
|
37
|
+
|
|
38
|
+
- When a keepalive exit fetch fails or throws, the library puts the batch in the emergency queue. The next page load sends it. Before, the library lost the batch.
|
|
39
|
+
- `shutdown()` gives the forward buffer to the bus before the bus stops. Before, a forwarder lost the records that it logged in the same task as `shutdown()`.
|
|
40
|
+
|
|
5
41
|
## [0.9.0] - 2026-10-28
|
|
6
42
|
|
|
7
43
|
### Breaking changes - v0.9.0
|
package/README.md
CHANGED
|
@@ -64,10 +64,10 @@ log.logAction("ORDER_SUBMIT", { orderId: "ORD-1001", qty: 100 });
|
|
|
64
64
|
log.error("pricing call failed", caughtError);
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
- `configure()` is idempotent. A later call updates the runtime singleton in place. You cannot change `storage` or `
|
|
67
|
+
- `configure()` is idempotent. A later call updates the runtime singleton in place. You cannot change `storage`, `identity`, `batching`, `retention`, `limits` or `journey.maxAgeMs` after startup. The library reports that change and ignores it.
|
|
68
68
|
- Call `configure()` from one context in each document. A second call changes `service.name` on the records of every other context. In a composed page, the shell calls `configure()`. Each microfrontend uses its own namespace.
|
|
69
69
|
- You can call `getLogger()` at module top level, before `configure()`. The logger finds the runtime on its first write.
|
|
70
|
-
- A write before the first `configure()` starts a runtime with default settings. It does not throw.
|
|
70
|
+
- A write before the first `configure()` starts a runtime with default settings. It does not throw. The first `configure()` then sets `limits` and `journey.maxAgeMs` of that runtime.
|
|
71
71
|
- After `shutdown()`, every call does nothing until the next `configure()`.
|
|
72
72
|
|
|
73
73
|
### Console Only (No Network)
|
|
@@ -286,38 +286,56 @@ The level methods give records with `log.type: "log"`. Records of the library it
|
|
|
286
286
|
|
|
287
287
|
## Configuration Options
|
|
288
288
|
|
|
289
|
-
No key is required. Set `endpoint` to send records. A value of the wrong type reports `config.invalid
|
|
290
|
-
|
|
291
|
-
| Key
|
|
292
|
-
|
|
|
293
|
-
| `endpoint`
|
|
294
|
-
| `serviceName`
|
|
295
|
-
| `serviceVersion`
|
|
296
|
-
| `environment`
|
|
297
|
-
| `enabled`
|
|
298
|
-
| `minLevel`
|
|
299
|
-
| `compression`
|
|
300
|
-
| `serializer`
|
|
301
|
-
| `credentials`
|
|
302
|
-
| `headers`
|
|
303
|
-
| `storage`
|
|
304
|
-
| `identity`
|
|
305
|
-
| `sampling.defaultRate`
|
|
306
|
-
| `sampling.rates`
|
|
307
|
-
| `sampling.alwaysSampleTypes`
|
|
308
|
-
| `sampling.remote`
|
|
309
|
-
| `sampling.remoteMaxRate`
|
|
310
|
-
| `bus.mode`
|
|
311
|
-
| `bus.trustedOrigins`
|
|
312
|
-
| `bus.openFinRole`
|
|
313
|
-
| `journey.scope`
|
|
314
|
-
| `
|
|
315
|
-
| `
|
|
316
|
-
| `
|
|
317
|
-
| `
|
|
318
|
-
| `
|
|
319
|
-
| `
|
|
320
|
-
| `
|
|
289
|
+
No key is required. Set `endpoint` to send records. A value of the wrong type or outside its range reports `config.invalid`. The value in force stays. Level names can have any case. You cannot change `batching` and `retention` after the delivery stack loads. You cannot change `limits` and `journey.maxAgeMs` after the first `configure()`.
|
|
290
|
+
|
|
291
|
+
| Key | Default | Description |
|
|
292
|
+
| -------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
293
|
+
| `endpoint` | `""` | HTTP endpoint that receives the batches. `null` selects console-only mode. `""` reports `config.invalid`. |
|
|
294
|
+
| `serviceName` | `""` | `service.name` on every record. |
|
|
295
|
+
| `serviceVersion` | `""` | `service.version` on every record. |
|
|
296
|
+
| `environment` | `""` | `deployment.environment` on every record. |
|
|
297
|
+
| `enabled` | `true` | Set `false` to stop all logging. Every log call then does nothing. |
|
|
298
|
+
| `minLevel` | `"INFO"` | Lowest level that the library sends (`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`). It does not drop actions and metrics. |
|
|
299
|
+
| `compression` | `"gzip"` | `gzip` or `none`. The library compresses a payload above 1 KB only. |
|
|
300
|
+
| `serializer` | `"otlp"` | `otlp`, `ecs`, or a custom `LogSerializer`. |
|
|
301
|
+
| `credentials` | `"omit"` | Fetch credentials mode. Set `"include"` for cookie auth. |
|
|
302
|
+
| `headers` | `{}` | Static headers, or a function that returns them. After a 401 or 403, a function gets one more call and the batch one more send. The exit flush sends the last headers. Before a function gives its first result, the exit flush puts the batch in the emergency queue. `headers: undefined` removes the headers. |
|
|
303
|
+
| `storage` | `"auto"` | Store for undelivered batches: `auto`, `indexeddb`, `localstorage`, `memory` or `none`. Fixed at startup. |
|
|
304
|
+
| `identity` | `"storage"` | Store for session, tab and journey ids. `memory` writes no key. Fixed at startup. |
|
|
305
|
+
| `sampling.defaultRate` | `1` | Keep rate for a namespace with no rule. |
|
|
306
|
+
| `sampling.rates` | `{}` | Keep rate per namespace. The longest matching prefix wins. |
|
|
307
|
+
| `sampling.alwaysSampleTypes` | `["action"]` | Record types that ignore the rate. |
|
|
308
|
+
| `sampling.remote` | `false` | Reads sampling rules from the `X-UiObs-Sampling` header of each accepted batch (see Remote Sampling). |
|
|
309
|
+
| `sampling.remoteMaxRate` | `1` | Highest rate that a remote rule can set. It applies to the remote `defaultRate` and to each remote namespace rate. |
|
|
310
|
+
| `bus.mode` | `"auto"` | `auto`, `sender`, `forwarder` or `off`. With `off`, this context sends its own records and opens no link. A same-origin child frame can still forward to it. |
|
|
311
|
+
| `bus.trustedOrigins` | `[]` | Origins of other documents that this document trusts. A parent accepts records from a child frame on these origins. A cross-origin child frame forwards its records only to a parent on these origins. The library keeps the origin of each URL. For a sandboxed frame, set `bus.mode: "sender"` in the frame. |
|
|
312
|
+
| `bus.openFinRole` | `"auto"` | `auto`, `provider` or `client`. |
|
|
313
|
+
| `journey.scope` | `"auto"` | Which contexts adopt a journey. `context`: each context keeps its own. `tab`: a frame or a worker adopts the journey of its owner. `origin`: each context of the origin, also in other tabs. `auto` is `origin` in OpenFin and `tab` in a browser. |
|
|
314
|
+
| `journey.maxAgeMs` | `1800000` | Maximum open time of a journey, in milliseconds. Then the library ends it. The range is 60000 to 86400000. |
|
|
315
|
+
| `batching.logFlushIntervalMs` | `2000` | Maximum wait of a partial log batch, in milliseconds. The range is 100 to 60000. |
|
|
316
|
+
| `batching.logBatchSize` | `100` | Maximum records in one log batch. The range is 1 to 1000. |
|
|
317
|
+
| `batching.metricFlushIntervalMs` | `10000` | Maximum wait of a partial metric batch, in milliseconds. The range is 100 to 60000. |
|
|
318
|
+
| `batching.metricBatchSize` | `500` | Maximum records in one metric batch. The range is 1 to 1000. |
|
|
319
|
+
| `retention.mode` | `"limited"` | `limited` or `until-delivered`. With `until-delivered`, a stored batch has no age limit and no attempt limit. `retention.maxBatches` still applies. A permanent error still drops the batch. A batch that always gets a temporary error stays first. The batches behind it wait. |
|
|
320
|
+
| `retention.maxBatches` | `500` | Maximum stored batches. A new batch evicts the oldest batch without an action first. The range is 1 to 5000. |
|
|
321
|
+
| `retention.maxAgeMs` | `86400000` | Maximum age of a stored batch, in milliseconds. The range is 60000 to 604800000. |
|
|
322
|
+
| `retention.maxAttempts` | `5` | Maximum send attempts of a stored batch. The range is 1 to 20. |
|
|
323
|
+
| `limits.maxBodyChars` | `4096` | Maximum body length, in characters. The range is 256 to 65536. |
|
|
324
|
+
| `limits.maxAttributeChars` | `8192` | Maximum length of a string attribute, in characters. The range is 256 to 65536. |
|
|
325
|
+
| `limits.maxAttributeCount` | `128` | Maximum keys in one object. The range is 1 to 1024. |
|
|
326
|
+
| `limits.maxStackChars` | `8192` | Maximum length of an error stack, in characters. The range is 256 to 65536. |
|
|
327
|
+
| `limits.maxDepth` | `6` | Maximum depth of a nested value. The range is 1 to 16. |
|
|
328
|
+
| `limits.maxArrayLength` | `100` | Maximum items in one array, set or map. The range is 1 to 10000. |
|
|
329
|
+
| `limits.maxNodes` | `10000` | Maximum values in one sanitize pass. The range is 100 to 100000. |
|
|
330
|
+
| `limits.maxRecordBytes` | `32768` | Maximum attribute bytes of one record. Above it, the library drops the caller attributes. The range is 1024 to 60000. |
|
|
331
|
+
| `capture` | See below | Auto-capture settings. |
|
|
332
|
+
| `console` | `false` | Prints records to devtools. `true` prints from `DEBUG` up. A level name prints from that level up. An object sets `level` and `styles` (see Console Output). It does not depend on `minLevel`. |
|
|
333
|
+
| `transport(request)` | `undefined` | Sends batches through a channel of your app in place of HTTP (see Custom Transport). |
|
|
334
|
+
| `transportOnExit(request)` | `undefined` | Sends the last batch while the page closes. It must return a boolean and must not wait. |
|
|
335
|
+
| `otelLoader()` | `undefined` | Loads `@opentelemetry/api`. Without it, OTel is off. |
|
|
336
|
+
| `redact(record)` | `undefined` | Changes a record before the library sends or prints it. Return `null` to drop the record. If the hook throws or returns a value that is not a record, the library drops the record. It counts `record.dropped_by_redact`. |
|
|
337
|
+
| `onDiagnostic(event)` | `undefined` | Receives the faults of the library itself. |
|
|
338
|
+
| `onDrop(summary)` | `undefined` | Receives a summary when the library loses records that it built. The summary has `reason`, `records`, `batchIds`, `journeyIds` and `actions`. Sampling, `minLevel` and `redact` do not cause a loss. Do not log through the library in the hook. A record from the hook can evict a stored batch. A batch that storage evicts during its send can still reach the server. |
|
|
321
339
|
|
|
322
340
|
### Auto-Capture Options
|
|
323
341
|
|
|
@@ -384,12 +402,14 @@ IndexedDB holds undelivered batches with `storage: "auto"` or `"indexeddb"`.
|
|
|
384
402
|
- **Document singleton:** The library keeps the runtime at `globalThis[Symbol.for("ui-observability.runtime")]`. Federated microfrontends and separate bundles share one buffer, one sequence and one transport.
|
|
385
403
|
- **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.
|
|
386
404
|
- **Five correlation ids:** Each record carries `session.id`, `tab.id`, `context.id`, `journey.id` and `trace_id`.
|
|
387
|
-
- **Durability and exit flush:** The library stores a batch that fails to send, in IndexedDB or localStorage. It sends the batch again with exponential backoff and jitter. When the document becomes hidden, the library runs a normal flush with the headers, gzip and retry. While the document is hidden, a send of 60 KB or less uses `keepalive`. A mobile OS can stop a hidden page with no `pagehide`. On `pagehide`, `freeze` or OpenFin close, it sends pending records with `navigator.sendBeacon` if they are below 60 KB. With `headers`, it uses a keepalive fetch with the last headers, because a beacon cannot set a header. A larger payload goes to the emergency queue. `shutdown()` runs a normal flush before the exit flush.
|
|
405
|
+
- **Durability and exit flush:** The library stores a batch that fails to send, in IndexedDB or localStorage. It sends the batch again with exponential backoff and jitter. When the document becomes hidden, the library runs a normal flush with the headers, gzip and retry. While the document is hidden, a send of 60 KB or less uses `keepalive`. A mobile OS can stop a hidden page with no `pagehide`. On `pagehide`, `freeze` or OpenFin close, it sends pending records with `navigator.sendBeacon` if they are below 60 KB. With `headers`, it uses a keepalive fetch with the last headers, because a beacon cannot set a header. A larger payload goes to the emergency queue. `shutdown()` runs a normal flush before the exit flush. An action is an audit fact. When storage is over `retention.maxBatches` or over the quota of the browser, it removes the batches without an action first. Before startup, the hold buffers keep up to 2000 actions. The 500-record limit applies only to other records. `onDrop` tells the app about each loss.
|
|
388
406
|
- **One library version on a page:** If a copy of another version owns the page runtime, this copy runs console-only. It installs no capture and reports `runtime.version_mismatch`. Load one version of the library on the page.
|
|
389
407
|
- **Emergency queue:** The emergency queue is best effort. It writes to `localStorage` synchronously, because no other storage works while the page unloads. If the browser refuses the write, the library reports `storage.quota_exceeded`. The library then loses the batch.
|
|
390
|
-
- **Configuration after startup:** A second `configure()` call merges the new options into the live runtime. The runtime refuses
|
|
408
|
+
- **Configuration after startup:** A second `configure()` call merges the new options into the live runtime. The runtime refuses 5 changes and reports `config.invalid` for each:
|
|
391
409
|
- A change to `storage`. The stored batches stay in the adapter that the runtime built at startup.
|
|
392
410
|
- A change to `identity`. The ids exist from startup.
|
|
411
|
+
- A change to `batching` or `retention` after the delivery stack loads. The stack reads them one time.
|
|
412
|
+
- A change to `limits` or `journey.maxAgeMs` after the first `configure()`. The record builder and the journey engine read them one time.
|
|
393
413
|
- An `endpoint` change to `null` or `""` after the delivery stack loads. Without an endpoint, the stored batches would be lost. A change to another endpoint URL is accepted.
|
|
394
414
|
- **Deterministic sampling:** FNV-1a hashing applies one keep rate to a whole journey. An error and an explicit action are always kept.
|
|
395
415
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { d as e, pt as t } from "./constants-N99w84xy.js";
|
|
2
|
+
import { i as n } from "./identity-D4DPjTM9.js";
|
|
3
|
+
//#region src/models/batch.ts
|
|
4
|
+
function r(e) {
|
|
5
|
+
if (typeof e != "object" || !e) return !1;
|
|
6
|
+
let t = Reflect.get(e, "id"), n = Reflect.get(e, "createdAt"), r = Reflect.get(e, "attempts"), i = Reflect.get(e, "records");
|
|
7
|
+
return typeof t == "string" && typeof n == "number" && typeof r == "number" && Array.isArray(i);
|
|
8
|
+
}
|
|
9
|
+
function i(e, t) {
|
|
10
|
+
if (e.records.length < 2) return null;
|
|
11
|
+
let r = Math.floor(e.records.length / 2), i = (r) => ({
|
|
12
|
+
id: n(t),
|
|
13
|
+
records: r,
|
|
14
|
+
createdAt: e.createdAt,
|
|
15
|
+
attempts: e.attempts
|
|
16
|
+
});
|
|
17
|
+
return [i(e.records.slice(0, r)), i(e.records.slice(r))];
|
|
18
|
+
}
|
|
19
|
+
function a(e, t) {
|
|
20
|
+
let n = e;
|
|
21
|
+
if (typeof n != "object" || !n) return;
|
|
22
|
+
let r = Reflect.get(n, "attributes");
|
|
23
|
+
if (typeof r == "object" && r) return Reflect.get(r, t);
|
|
24
|
+
}
|
|
25
|
+
function o(n) {
|
|
26
|
+
return a(n, e) === t;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i, o as n, r, a as t };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=batch-DEK4bv9N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-DEK4bv9N.js","names":["ATTR_LOG_TYPE","LOG_TYPE_ACTION","newId","isLogBatch","value","id","createdAt","attempts","records","splitBatch","batch","middle","halve","diagnostics","attributeOf","record","attributes","key","isActionRecord"],"sources":["../src/models/batch.ts"],"sourcesContent":["// src/models/batch.ts\n//\n// A batch of log records for delivery to the ingest endpoint.\n\nimport { ATTR_LOG_TYPE, LOG_TYPE_ACTION } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { newId } from \"../utils/identity\";\nimport type { LogRecord } from \"./log-record\";\n\n/**\n * A batch of records with a stable id used for server-side deduplication across retries.\n * @see {@link splitBatch}\n */\nexport interface LogBatch {\n /** Deduplication key. It stays the same across retries and reloads. */\n id: string;\n /** Records to deliver, in log order. */\n records: LogRecord[];\n /** Batch creation time, in epoch milliseconds. */\n createdAt: number;\n /** Delivery attempts so far. */\n attempts: number;\n}\n\n/**\n * Tells if a value from storage has all fields of a batch. `keyOf` cannot match\n * an entry without `id` after delivery. The library then retries that entry with no\n * end, and the entry blocks each batch behind it. An entry without `attempts` counts\n * as NaN. That count never reaches `maxAttempts`. Thus the library never drops the\n * entry as a dead letter.\n * @param value Parsed storage entry.\n * @returns True when each required field is present and has the correct type.\n */\nexport function isLogBatch(value: unknown): value is LogBatch {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const id: unknown = Reflect.get(value, \"id\");\n const createdAt: unknown = Reflect.get(value, \"createdAt\");\n const attempts: unknown = Reflect.get(value, \"attempts\");\n const records: unknown = Reflect.get(value, \"records\");\n\n return (\n typeof id === \"string\" &&\n typeof createdAt === \"number\" &&\n typeof attempts === \"number\" &&\n Array.isArray(records)\n );\n}\n\n/**\n * Splits a batch that the server rejected as too large into two halves.\n * Each half gets a new id. Each half keeps the age and attempts of the original batch.\n * @param batch The rejected batch.\n * @param diagnostics Diagnostics reporter for the new batch ids.\n * @returns Two batches, or `null` if a single record is already over the limit.\n */\nexport function splitBatch(batch: LogBatch, diagnostics: Diagnostics): [LogBatch, LogBatch] | null {\n if (batch.records.length < 2) {\n return null;\n }\n\n const middle = Math.floor(batch.records.length / 2);\n const halve = (records: LogRecord[]): LogBatch => ({\n id: newId(diagnostics),\n records,\n createdAt: batch.createdAt,\n attempts: batch.attempts,\n });\n\n return [halve(batch.records.slice(0, middle)), halve(batch.records.slice(middle))];\n}\n\n/**\n * Reads one attribute of a record. A record from storage can be corrupt. It can be null or have\n * no attributes.\n * @param record Record to read.\n * @param key Attribute key.\n * @returns The attribute value, or undefined for a corrupt record.\n */\nexport function attributeOf(record: LogRecord, key: string): unknown {\n const value: unknown = record;\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const attributes: unknown = Reflect.get(value, \"attributes\");\n if (typeof attributes !== \"object\" || attributes === null) {\n return undefined;\n }\n\n return Reflect.get(attributes, key);\n}\n\n/**\n * Tests if a record is an action. A corrupt record from storage is not an action.\n * @param record Record to test.\n * @returns True for an action record.\n */\nexport function isActionRecord(record: LogRecord): boolean {\n return attributeOf(record, ATTR_LOG_TYPE) === LOG_TYPE_ACTION;\n}\n"],"mappings":";;;AAiCA,SAAgBG,EAAW,GAAmC;CAC5D,IAAI,OAAOC,KAAU,aAAYA,GAC/B,OAAO;CAGT,IAAMC,IAAc,QAAQ,IAAID,GAAO,IAAI,GACrCE,IAAqB,QAAQ,IAAIF,GAAO,WAAW,GACnDG,IAAoB,QAAQ,IAAIH,GAAO,UAAU,GACjDI,IAAmB,QAAQ,IAAIJ,GAAO,SAAS;CAErD,OACE,OAAOC,KAAO,YACd,OAAOC,KAAc,YACrB,OAAOC,KAAa,YACpB,MAAM,QAAQC,CAAO;AAEzB;AASA,SAAgBC,EAAW,GAAiB,GAAuD;CACjG,IAAIC,EAAM,QAAQ,SAAS,GACzB,OAAO;CAGT,IAAMC,IAAS,KAAK,MAAMD,EAAM,QAAQ,SAAS,CAAC,GAC5CE,KAAS,OAAoC;EACjD,IAAIV,EAAMW,CAAW;EACrB;EACA,WAAWH,EAAM;EACjB,UAAUA,EAAM;CAClB;CAEA,OAAO,CAACE,EAAMF,EAAM,QAAQ,MAAM,GAAGC,CAAM,CAAC,GAAGC,EAAMF,EAAM,QAAQ,MAAMC,CAAM,CAAC,CAAC;AACnF;AASA,SAAgBG,EAAY,GAAmB,GAAsB;CACnE,IAAMV,IAAiBW;CACvB,IAAI,OAAOX,KAAU,aAAYA,GAC/B;CAGF,IAAMY,IAAsB,QAAQ,IAAIZ,GAAO,YAAY;CAC3D,IAAI,OAAOY,KAAe,YAAYA,GAItC,OAAO,QAAQ,IAAIA,GAAYC,CAAG;AACpC;AAOA,SAAgBC,EAAe,GAA4B;CACzD,OAAOJ,EAAYC,GAAQf,CAAa,MAAMC;AAChD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants-X86IDwkC.cjs"),t=require("./identity-B1GDS1Tb.cjs");function n(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`id`),n=Reflect.get(e,`createdAt`),r=Reflect.get(e,`attempts`),i=Reflect.get(e,`records`);return typeof t==`string`&&typeof n==`number`&&typeof r==`number`&&Array.isArray(i)}function r(e,n){if(e.records.length<2)return null;let r=Math.floor(e.records.length/2),i=r=>({id:t.i(n),records:r,createdAt:e.createdAt,attempts:e.attempts});return[i(e.records.slice(0,r)),i(e.records.slice(r))]}function i(e,t){let n=e;if(typeof n!=`object`||!n)return;let r=Reflect.get(n,`attributes`);if(typeof r==`object`&&r)return Reflect.get(r,t)}function a(t){return i(t,e.d)===e.pt}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
|
2
|
+
//# sourceMappingURL=batch-DEVFs28i.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-DEVFs28i.cjs","names":["newId","ATTR_LOG_TYPE","LOG_TYPE_ACTION","require_constants","require_identity","isLogBatch","value","id","createdAt","attempts","records","splitBatch","batch","middle","halve","diagnostics","attributeOf","record","attributes","key","isActionRecord"],"sources":["../src/models/batch.ts"],"sourcesContent":["// src/models/batch.ts\n//\n// A batch of log records for delivery to the ingest endpoint.\n\nimport { ATTR_LOG_TYPE, LOG_TYPE_ACTION } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { newId } from \"../utils/identity\";\nimport type { LogRecord } from \"./log-record\";\n\n/**\n * A batch of records with a stable id used for server-side deduplication across retries.\n * @see {@link splitBatch}\n */\nexport interface LogBatch {\n /** Deduplication key. It stays the same across retries and reloads. */\n id: string;\n /** Records to deliver, in log order. */\n records: LogRecord[];\n /** Batch creation time, in epoch milliseconds. */\n createdAt: number;\n /** Delivery attempts so far. */\n attempts: number;\n}\n\n/**\n * Tells if a value from storage has all fields of a batch. `keyOf` cannot match\n * an entry without `id` after delivery. The library then retries that entry with no\n * end, and the entry blocks each batch behind it. An entry without `attempts` counts\n * as NaN. That count never reaches `maxAttempts`. Thus the library never drops the\n * entry as a dead letter.\n * @param value Parsed storage entry.\n * @returns True when each required field is present and has the correct type.\n */\nexport function isLogBatch(value: unknown): value is LogBatch {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const id: unknown = Reflect.get(value, \"id\");\n const createdAt: unknown = Reflect.get(value, \"createdAt\");\n const attempts: unknown = Reflect.get(value, \"attempts\");\n const records: unknown = Reflect.get(value, \"records\");\n\n return (\n typeof id === \"string\" &&\n typeof createdAt === \"number\" &&\n typeof attempts === \"number\" &&\n Array.isArray(records)\n );\n}\n\n/**\n * Splits a batch that the server rejected as too large into two halves.\n * Each half gets a new id. Each half keeps the age and attempts of the original batch.\n * @param batch The rejected batch.\n * @param diagnostics Diagnostics reporter for the new batch ids.\n * @returns Two batches, or `null` if a single record is already over the limit.\n */\nexport function splitBatch(batch: LogBatch, diagnostics: Diagnostics): [LogBatch, LogBatch] | null {\n if (batch.records.length < 2) {\n return null;\n }\n\n const middle = Math.floor(batch.records.length / 2);\n const halve = (records: LogRecord[]): LogBatch => ({\n id: newId(diagnostics),\n records,\n createdAt: batch.createdAt,\n attempts: batch.attempts,\n });\n\n return [halve(batch.records.slice(0, middle)), halve(batch.records.slice(middle))];\n}\n\n/**\n * Reads one attribute of a record. A record from storage can be corrupt. It can be null or have\n * no attributes.\n * @param record Record to read.\n * @param key Attribute key.\n * @returns The attribute value, or undefined for a corrupt record.\n */\nexport function attributeOf(record: LogRecord, key: string): unknown {\n const value: unknown = record;\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n const attributes: unknown = Reflect.get(value, \"attributes\");\n if (typeof attributes !== \"object\" || attributes === null) {\n return undefined;\n }\n\n return Reflect.get(attributes, key);\n}\n\n/**\n * Tests if a record is an action. A corrupt record from storage is not an action.\n * @param record Record to test.\n * @returns True for an action record.\n */\nexport function isActionRecord(record: LogRecord): boolean {\n return attributeOf(record, ATTR_LOG_TYPE) === LOG_TYPE_ACTION;\n}\n"],"mappings":"iFAiCA,SAAgBK,EAAW,EAAmC,CAC5D,GAAI,OAAOC,GAAU,WAAYA,EAC/B,MAAO,GAGT,IAAMC,EAAc,QAAQ,IAAID,EAAO,IAAI,EACrCE,EAAqB,QAAQ,IAAIF,EAAO,WAAW,EACnDG,EAAoB,QAAQ,IAAIH,EAAO,UAAU,EACjDI,EAAmB,QAAQ,IAAIJ,EAAO,SAAS,EAErD,OACE,OAAOC,GAAO,UACd,OAAOC,GAAc,UACrB,OAAOC,GAAa,UACpB,MAAM,QAAQC,CAAO,CAEzB,CASA,SAAgBC,EAAW,EAAiB,EAAuD,CACjG,GAAIC,EAAM,QAAQ,OAAS,EACzB,OAAO,KAGT,IAAMC,EAAS,KAAK,MAAMD,EAAM,QAAQ,OAAS,CAAC,EAC5CE,EAAS,IAAoC,CACjD,GAAId,EAAAA,EAAMe,CAAW,EACrB,UACA,UAAWH,EAAM,UACjB,SAAUA,EAAM,QAClB,GAEA,MAAO,CAACE,EAAMF,EAAM,QAAQ,MAAM,EAAGC,CAAM,CAAC,EAAGC,EAAMF,EAAM,QAAQ,MAAMC,CAAM,CAAC,CAAC,CACnF,CASA,SAAgBG,EAAY,EAAmB,EAAsB,CACnE,IAAMV,EAAiBW,EACvB,GAAI,OAAOX,GAAU,WAAYA,EAC/B,OAGF,IAAMY,EAAsB,QAAQ,IAAIZ,EAAO,YAAY,EAC3D,GAAI,OAAOY,GAAe,UAAYA,EAItC,OAAO,QAAQ,IAAIA,EAAYC,CAAG,CACpC,CAOA,SAAgBC,EAAe,EAA4B,CACzD,OAAOJ,EAAYC,EAAQhB,EAAAA,CAAa,IAAMC,EAAAA,EAChD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants-Br3b89Wg.cjs"),t=require("./deadline-Cbg2cbUw.cjs"),n=require("./journey-CE2EcwHW.cjs"),r=require("./remote-rules-kuDf5gbe.cjs");function i(t){return{p:e.w,m:t}}function a(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.p!==`ui-observability/1`||typeof t.m!=`object`||t.m===null)return null;let n=t.m;return typeof n.t==`string`?n:null}var o=Symbol.for(e.qt),s=`null`;function c(e,t){return e===s?`The bus ignored ${t} from a sandboxed frame. The frame has an opaque origin. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.`:`The bus ignored ${t} from ${e}. If you own this origin, add it to bus.trustedOrigins.`}function l(){let e=location.ancestorOrigins;if(e&&e.length>0)return e.item(0);let t=document.referrer;if(t===``)return null;try{return new URL(t).origin}catch{return null}}function u(e,t){if(typeof window>`u`||window.parent===window)return null;let n;try{n=window.parent[o]}catch{return null}if(typeof n?.busAccept!=`function`)return null;let r=n,i=!0;return{kind:`direct`,post(n){i&&t.guard(`bus.send_failed`,`The direct call into the parent runtime failed.`,()=>{r.busAccept(n,e)})},close(){i=!1}}}function d(e,t,n){if(typeof window>`u`||window.parent===window)return null;let r=location.origin;if(r===s)return n.report(`bus.untrusted_origin`,`This frame is sandboxed without allow-same-origin. It has an opaque origin. No parent can trust it. This context sends its own records. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.`,{origin:r,type:`parent`}),null;let o=new Set([r,...t]),u=l();if(u===null||!o.has(u))return n.report(`bus.untrusted_origin`,u===null?`The origin of the parent frame is unknown. This context sends its own records.`:`The parent frame is on ${u}. This origin is not in bus.trustedOrigins. This context sends its own records.`,{origin:u??``,type:`parent`}),null;let d=new Set,f=t=>{let r=a(t.data);r&&t.source===window.parent&&(o.has(t.origin)?e(r,{link:`parent`,origin:t.origin}):d.has(t.origin)||(d.add(t.origin),n.report(`bus.untrusted_origin`,c(t.origin,`a message`),{origin:t.origin,type:r.t.slice(0,32)})))};return addEventListener(`message`,f),{kind:`parent`,post(e){n.guard(`bus.send_failed`,`The postMessage call to the parent failed.`,()=>{window.parent.postMessage(i(e),u)})},close(){removeEventListener(`message`,f)}}}function f(e,t,n){if(typeof window>`u`)return null;let r=new Set([location.origin,...t]);r.delete(s);let o=new Map,l=t=>{let i=a(t.data);i&&(r.has(t.origin)?(t.source&&o.set(t.source,t.origin),e(i,{link:`children`,origin:t.origin})):n.report(`bus.untrusted_origin`,c(t.origin,`a message`),{origin:t.origin,type:i.t.slice(0,32)}))};return addEventListener(`message`,l),{kind:`children`,post(e){for(let[t,r]of o){let a=t;a.closed?o.delete(t):n.guard(`bus.send_failed`,`The postMessage call to a child frame failed.`,()=>{a.postMessage(i(e),r)})}},close(){removeEventListener(`message`,l),o.clear()}}}function p(e,t,n){let r=globalThis.BroadcastChannel;if(r===void 0)return null;let o=n.guard(`bus.send_failed`,`The library could not open the BroadcastChannel.`,()=>new r(e));return o?(o.onmessage=e=>{let n=a(e.data);n&&t(n,{link:`broadcast`,origin:`same-origin`})},{kind:`broadcast`,post(e){n.guard(`bus.send_failed`,`The BroadcastChannel.postMessage call failed.`,()=>{o.postMessage(i(e))})},close(){n.guard(`bus.send_failed`,`The library could not close the BroadcastChannel.`,()=>{o.close()})}}):null}function m(e,t,n,r){let o=globalThis.fin?.InterApplicationBus;if(!o)return null;if(!t)return r.report(`openfin.unavailable`,`OpenFin gives no application uuid. The InterApplicationBus link stays closed.`),null;let s=`${e}.${t}`;return r.guardAsync(`bus.send_failed`,`The InterApplicationBus.subscribe call failed.`,()=>o.subscribe({uuid:t},s,e=>{let t=a(e);t&&n(t,{link:`openfin`,origin:`openfin`})})),{kind:`openfin`,post(e){r.guardAsync(`bus.send_failed`,`The InterApplicationBus.publish call failed.`,()=>o.publish(s,i(e)))},close(){}}}function h(e,t){let n=globalThis,r=n.postMessage;return n.WorkerGlobalScope===void 0||!r?null:(n.addEventListener?.(`message`,t=>{let n=a(t.data);n&&e(n,{link:`owner`,origin:`same-origin`})}),{kind:`owner`,post(e){t.guard(`bus.send_failed`,`The postMessage call of the worker failed.`,()=>{r(i(e))})},close(){}})}function g(e,t,n){let r=e=>{let n=a(e.data);n&&t(n,{link:`worker`,origin:`same-origin`})};return e.addEventListener(`message`,r),e.start?.(),{kind:`worker`,post(t){n.guard(`bus.send_failed`,`The postMessage call to a worker failed.`,()=>{e.postMessage(i(t))})},close(){e.removeEventListener(`message`,r)}}}var _={timeoutMs:e.C,maxAttempts:3},v=[`children`,`direct`,`worker`],y=class{config;diagnostics;platform;contextId;tabId;handlers;handshakeOptions;role=`sender`;upstream=null;links=[];openFinLink=null;isOpenFinProvider=!1;resolved=!1;rulesPoll;destroyed=!1;ownerId=null;awaitingWelcome=null;constructor(e,t,n,r,i,a,o=_){this.config=e,this.diagnostics=t,this.platform=n,this.contextId=r,this.tabId=i,this.handlers=a,this.handshakeOptions=o}getRole(){return this.role}isResolved(){return this.resolved}async start(){let{bus:e}=this.config;if(e.mode===`off`)return this.role=`sender`,this.resolved=!0,this.role;if(this.isOpenFinProvider=this.resolveOpenFinProvider(),e.mode===`sender`||e.mode===`forwarder`)return this.role=e.mode,this.openControlLinks(),this.role===`forwarder`&&(this.upstream=this.candidateUpstream(),this.upstream||this.diagnostics.report(`bus.no_owner`,`bus.mode is "forwarder". No owner exists. The library drops the records of this context.`)),this.resolved=!0,this.announce(),this.role;this.openControlLinks();let t=u(this.receive,this.diagnostics);if(t)return this.role=`forwarder`,this.upstream=t,this.resolved=!0,this.diagnostics.report(`bus.role_resolved`,`This context attached directly to the runtime of its same-origin parent.`,{role:`forwarder`,via:`direct`}),this.announce(),this.role;let n=this.candidateUpstream();if(!n)return this.role=`sender`,this.resolved=!0,this.diagnostics.report(`bus.role_resolved`,`No owner exists. This context sends its own records.`,{role:`sender`}),this.announce(),this.role;let r=this.orphanPolicy()===`retry`?this.handshakeOptions.maxAttempts:1,i=!1;for(let e=0;e<r&&!i;e++)i=await this.handshake(n);return this.role=i?`forwarder`:`sender`,this.upstream=i?n:null,i||(n!==this.openFinLink&&n.close(),this.diagnostics.report(`bus.handshake_timeout`,`No owner answered after ${String(r)} attempt(s) of ${String(this.handshakeOptions.timeoutMs)} ms. This context becomes the sender.`,{via:n.kind,crossOrigin:this.isCrossOriginFrame()})),this.diagnostics.report(`bus.role_resolved`,`The bus role is ${this.role}.`,{role:this.role,via:i?n.kind:`none`}),this.resolved=!0,this.announce(),this.role}sendRecords(e){this.upstream?.post({t:`records`,from:this.contextId,records:e})}acceptDirect(e,t){if(e.from===this.contextId)return;let n={link:`direct`,origin:`same-origin`};if(e.t===`hello`)this.canOwn(`direct`)&&t({t:`welcome`,from:this.contextId,to:e.from,tabId:this.tabId},n);else if(e.t===`journey?`){let r=this.handlers.onJourneyRequest();r&&this.journeyLink(`direct`)&&t({t:`journey`,from:this.contextId,to:e.from,journey:r},n)}else e.t===`sampling?`?t(this.rulesAnswer(e.from),n):this.receive(e,n)}attachWorker(e){this.links.push(g(e,this.receive,this.diagnostics))}broadcastJourney(e){this.postJourney({t:`journey`,from:this.contextId,journey:e})}destroy(){this.destroyed=!0,clearInterval(this.rulesPoll),this.rulesPoll=void 0;for(let e of this.allLinks())e.close();this.links.length=0,this.upstream=null,this.ownerId=null,this.openFinLink=null}allLinks(){return!this.upstream||this.links.includes(this.upstream)?this.links:[...this.links,this.upstream]}postOver(e,t){for(let n of this.allLinks())n.kind===e&&n.post(t)}postJourney(e){for(let t of this.allLinks())this.journeyLink(t.kind)&&t.post(e)}receive=(e,t)=>{if(e.from!==this.contextId)switch(e.t){case`hello`:this.canOwn(t.link)&&this.postOver(t.link,{t:`welcome`,from:this.contextId,to:e.from,tabId:this.tabId});break;case`welcome`:if(e.to!==this.contextId)break;this.awaitingWelcome?.link===t.link&&(this.ownerId=e.from,this.awaitingWelcome.settle(!0));break;case`records`:this.role===`sender`?this.handlers.onRecords(e.records):this.upstream&&this.canRelay(t.link)&&this.upstream.post(e);break;case`journey`:this.acceptsJourney(e,t)&&this.applyJourney(e.journey);break;case`journey?`:{let n=this.handlers.onJourneyRequest();n&&this.journeyLink(t.link)&&this.postOver(t.link,{t:`journey`,from:this.contextId,to:e.from,journey:n});break}case`sampling?`:(this.role===`forwarder`?t.link!==this.upstream?.kind:this.canOwn(t.link))&&this.postOver(t.link,this.rulesAnswer(e.from));break;case`sampling`:this.acceptsRules(e.to,t)&&this.applyRules(e.rules);break;case`tab`:t.link===`broadcast`&&e.tabId===this.tabId&&this.contextId>e.from&&this.handlers.onTabConflict()}};canRelay(e){return e===`direct`||e!==this.upstream?.kind}canOwn(e){return this.role===`sender`?e===`openfin`?this.isOpenFinProvider:v.includes(e):!1}resolveOpenFinProvider(){let e=this.config.bus.openFinRole;if(e!==`auto`)return e===`provider`;if(this.platform.platform!==`openfin`&&this.platform.platform!==`openfin_web`)return!1;let t=globalThis.fin?.me;return!t?.identity||t.isView?!1:!!(t.identity.name&&t.identity.name===t.identity.uuid)}orphanPolicy(){return this.isCrossOriginFrame()?`retry`:`promote`}isCrossOriginFrame(){if(typeof window>`u`||window.parent===window)return!1;try{return Reflect.get(window.parent,`location`),!1}catch{return!0}}candidateUpstream(){return this.platform.isWorker?h(this.receive,this.diagnostics):this.platform.isTopLevelDocument?this.platform.platform===`openfin`&&!this.isOpenFinProvider?this.ensureOpenFinLink():null:d(this.receive,this.config.bus.trustedOrigins,this.diagnostics)}openControlLinks(){let t=e=>{e&&this.links.push(e)};this.platform.isTopLevelDocument&&(t(f(this.receive,this.config.bus.trustedOrigins,this.diagnostics)),t(p(e.S,this.receive,this.diagnostics))),(this.platform.platform===`openfin`||this.platform.platform===`openfin_web`)&&t(this.ensureOpenFinLink())}ensureOpenFinLink(){return this.openFinLink??=m(e.S,this.platform.openfinUuid,this.receive,this.diagnostics),this.openFinLink}handshake(e){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,this.awaitingWelcome=null,clearTimeout(a),n(e))};this.awaitingWelcome={link:e.kind,settle:i};let a=setTimeout(()=>{i(!1)},this.handshakeOptions.timeoutMs);t.r(a),e.post({t:`hello`,from:this.contextId,tabId:this.tabId})})}announce(){this.postOver(`broadcast`,{t:`tab`,from:this.contextId,tabId:this.tabId}),this.postJourney({t:`journey?`,from:this.contextId}),this.pollRules()}journeyScope(){let{scope:e}=this.config.journey;if(e!==`auto`)return e;let{platform:t}=this.platform;return t===`openfin`||t===`openfin_web`?`origin`:`tab`}journeyLink(e){let t=this.journeyScope();return t===`context`?!1:t===`origin`||e!==`broadcast`}acceptsJourney(e,t){return!this.journeyLink(t.link)||e.to!==void 0&&e.to!==this.contextId?!1:this.journeyScope()===`origin`||this.fromOwner(e.from,t.link)}fromOwner(e,t){return this.role!==`forwarder`||t!==this.upstream?.kind?!1:this.ownerId===null||e===this.ownerId}applyJourney(e){if(e===null){this.handlers.onJourney(null);return}let t=n.r(e);t===null?this.diagnostics.report(`record.dropped_malformed`,`The bus dropped a journey message. Its payload is not a journey.`,{type:`journey`}):this.handlers.onJourney(t)}rulesAnswer(e){let t=this.handlers.remote.sampling?.wire()??null;return{t:`sampling`,from:this.contextId,to:e,rules:t}}acceptsRules(e,t){if(this.role!==`forwarder`||e!==this.contextId||t.link!==this.upstream?.kind)return!1;let{origin:n}=t;return t.link===`parent`&&n!==location.origin&&!this.config.bus.trustedOrigins.includes(n)?(this.diagnostics.report(`bus.untrusted_origin`,`The bus ignored sampling rules from ${n}. If you own this origin, add it to bus.trustedOrigins.`,{origin:n,type:`sampling`}),!1):!0}applyRules(e){if(e===null){r.t(this.handlers.remote,this.config,null);return}let t=r.n(e,this.diagnostics);t&&r.t(this.handlers.remote,this.config,t)}pollRules(){let{upstream:n}=this;if(this.destroyed||this.role!==`forwarder`||!n)return;let r=()=>{this.config.sampling.remote&&n.post({t:`sampling?`,from:this.contextId})};r(),this.rulesPoll=setInterval(r,e.kt),t.r(this.rulesPoll)}};exports.Bus=y;
|
|
2
|
-
//# sourceMappingURL=bus-
|
|
1
|
+
const e=require("./constants-X86IDwkC.cjs"),t=require("./deadline-XSnm95pg.cjs"),n=require("./journey-DxlfdFJV.cjs"),r=require("./remote-rules-ByS34k4e.cjs");function i(t){return{p:e.T,m:t}}function a(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.p!==`ui-observability/1`||typeof t.m!=`object`||t.m===null)return null;let n=t.m;return typeof n.t==`string`?n:null}var o=Symbol.for(e.qt),s=`null`;function c(e,t){return e===s?`The bus ignored ${t} from a sandboxed frame. The frame has an opaque origin. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.`:`The bus ignored ${t} from ${e}. If you own this origin, add it to bus.trustedOrigins.`}function l(){let e=location.ancestorOrigins;if(e&&e.length>0)return e.item(0);let t=document.referrer;if(t===``)return null;try{return new URL(t).origin}catch{return null}}function u(e,t){if(typeof window>`u`||window.parent===window)return null;let n;try{n=window.parent[o]}catch{return null}if(typeof n?.busAccept!=`function`)return null;let r=n,i=!0;return{kind:`direct`,post(n){i&&t.guard(`bus.send_failed`,`The direct call into the parent runtime failed.`,()=>{r.busAccept(n,e)})},close(){i=!1}}}function d(e,t,n){if(typeof window>`u`||window.parent===window)return null;let r=location.origin;if(r===s)return n.report(`bus.untrusted_origin`,`This frame is sandboxed without allow-same-origin. It has an opaque origin. No parent can trust it. This context sends its own records. Set bus.mode: "sender" in the frame. Add allow-same-origin to the sandbox attribute only for content that you trust.`,{origin:r,type:`parent`}),null;let o=new Set([r,...t]),u=l();if(u===null||!o.has(u))return n.report(`bus.untrusted_origin`,u===null?`The origin of the parent frame is unknown. This context sends its own records.`:`The parent frame is on ${u}. This origin is not in bus.trustedOrigins. This context sends its own records.`,{origin:u??``,type:`parent`}),null;let d=new Set,f=t=>{let r=a(t.data);r&&t.source===window.parent&&(o.has(t.origin)?e(r,{link:`parent`,origin:t.origin}):d.has(t.origin)||(d.add(t.origin),n.report(`bus.untrusted_origin`,c(t.origin,`a message`),{origin:t.origin,type:r.t.slice(0,32)})))};return addEventListener(`message`,f),{kind:`parent`,post(e){n.guard(`bus.send_failed`,`The postMessage call to the parent failed.`,()=>{window.parent.postMessage(i(e),u)})},close(){removeEventListener(`message`,f)}}}function f(e,t,n){if(typeof window>`u`)return null;let r=new Set([location.origin,...t]);r.delete(s);let o=new Map,l=t=>{let i=a(t.data);i&&(r.has(t.origin)?(t.source&&o.set(t.source,t.origin),e(i,{link:`children`,origin:t.origin})):n.report(`bus.untrusted_origin`,c(t.origin,`a message`),{origin:t.origin,type:i.t.slice(0,32)}))};return addEventListener(`message`,l),{kind:`children`,post(e){for(let[t,r]of o){let a=t;a.closed?o.delete(t):n.guard(`bus.send_failed`,`The postMessage call to a child frame failed.`,()=>{a.postMessage(i(e),r)})}},close(){removeEventListener(`message`,l),o.clear()}}}function p(e,t,n){let r=globalThis.BroadcastChannel;if(r===void 0)return null;let o=n.guard(`bus.send_failed`,`The library could not open the BroadcastChannel.`,()=>new r(e));return o?(o.onmessage=e=>{let n=a(e.data);n&&t(n,{link:`broadcast`,origin:`same-origin`})},{kind:`broadcast`,post(e){n.guard(`bus.send_failed`,`The BroadcastChannel.postMessage call failed.`,()=>{o.postMessage(i(e))})},close(){n.guard(`bus.send_failed`,`The library could not close the BroadcastChannel.`,()=>{o.close()})}}):null}function m(e,t,n,r){let o=globalThis.fin?.InterApplicationBus;if(!o)return null;if(!t)return r.report(`openfin.unavailable`,`OpenFin gives no application uuid. The InterApplicationBus link stays closed.`),null;let s=`${e}.${t}`;return r.guardAsync(`bus.send_failed`,`The InterApplicationBus.subscribe call failed.`,()=>o.subscribe({uuid:t},s,e=>{let t=a(e);t&&n(t,{link:`openfin`,origin:`openfin`})})),{kind:`openfin`,post(e){r.guardAsync(`bus.send_failed`,`The InterApplicationBus.publish call failed.`,()=>o.publish(s,i(e)))},close(){}}}function h(e,t){let n=globalThis,r=n.postMessage;return n.WorkerGlobalScope===void 0||!r?null:(n.addEventListener?.(`message`,t=>{let n=a(t.data);n&&e(n,{link:`owner`,origin:`same-origin`})}),{kind:`owner`,post(e){t.guard(`bus.send_failed`,`The postMessage call of the worker failed.`,()=>{r(i(e))})},close(){}})}function g(e,t,n){let r=e=>{let n=a(e.data);n&&t(n,{link:`worker`,origin:`same-origin`})};return e.addEventListener(`message`,r),e.start?.(),{kind:`worker`,post(t){n.guard(`bus.send_failed`,`The postMessage call to a worker failed.`,()=>{e.postMessage(i(t))})},close(){e.removeEventListener(`message`,r)}}}var _={timeoutMs:e.C,maxAttempts:3},v=[`children`,`direct`,`worker`],y=class{config;diagnostics;platform;contextId;tabId;handlers;handshakeOptions;role=`sender`;upstream=null;links=[];openFinLink=null;isOpenFinProvider=!1;resolved=!1;rulesPoll;destroyed=!1;ownerId=null;awaitingWelcome=null;constructor(e,t,n,r,i,a,o=_){this.config=e,this.diagnostics=t,this.platform=n,this.contextId=r,this.tabId=i,this.handlers=a,this.handshakeOptions=o}getRole(){return this.role}isResolved(){return this.resolved}async start(){let{bus:e}=this.config;if(e.mode===`off`)return this.role=`sender`,this.resolved=!0,this.role;if(this.isOpenFinProvider=this.resolveOpenFinProvider(),e.mode===`sender`||e.mode===`forwarder`)return this.role=e.mode,this.openControlLinks(),this.role===`forwarder`&&(this.upstream=this.candidateUpstream(),this.upstream||this.diagnostics.report(`bus.no_owner`,`bus.mode is "forwarder". No owner exists. The library drops the records of this context.`)),this.resolved=!0,this.announce(),this.role;this.openControlLinks();let t=u(this.receive,this.diagnostics);if(t)return this.role=`forwarder`,this.upstream=t,this.resolved=!0,this.diagnostics.report(`bus.role_resolved`,`This context attached directly to the runtime of its same-origin parent.`,{role:`forwarder`,via:`direct`}),this.announce(),this.role;let n=this.candidateUpstream();if(!n)return this.role=`sender`,this.resolved=!0,this.diagnostics.report(`bus.role_resolved`,`No owner exists. This context sends its own records.`,{role:`sender`}),this.announce(),this.role;let r=this.orphanPolicy()===`retry`?this.handshakeOptions.maxAttempts:1,i=!1;for(let e=0;e<r&&!i;e++)i=await this.handshake(n);return this.role=i?`forwarder`:`sender`,this.upstream=i?n:null,i||(n!==this.openFinLink&&n.close(),this.diagnostics.report(`bus.handshake_timeout`,`No owner answered after ${String(r)} attempt(s) of ${String(this.handshakeOptions.timeoutMs)} ms. This context becomes the sender.`,{via:n.kind,crossOrigin:this.isCrossOriginFrame()})),this.diagnostics.report(`bus.role_resolved`,`The bus role is ${this.role}.`,{role:this.role,via:i?n.kind:`none`}),this.resolved=!0,this.announce(),this.role}sendRecords(e){this.upstream?.post({t:`records`,from:this.contextId,records:e})}acceptDirect(e,t){if(e.from===this.contextId)return;let n={link:`direct`,origin:`same-origin`};if(e.t===`hello`)this.canOwn(`direct`)&&t({t:`welcome`,from:this.contextId,to:e.from,tabId:this.tabId},n);else if(e.t===`journey?`){let r=this.handlers.onJourneyRequest();r&&this.journeyLink(`direct`)&&t({t:`journey`,from:this.contextId,to:e.from,journey:r},n)}else e.t===`sampling?`?t(this.rulesAnswer(e.from),n):this.receive(e,n)}attachWorker(e){this.links.push(g(e,this.receive,this.diagnostics))}broadcastJourney(e){this.postJourney({t:`journey`,from:this.contextId,journey:e})}destroy(){this.destroyed=!0,clearInterval(this.rulesPoll),this.rulesPoll=void 0;for(let e of this.allLinks())e.close();this.links.length=0,this.upstream=null,this.ownerId=null,this.openFinLink=null}allLinks(){return!this.upstream||this.links.includes(this.upstream)?this.links:[...this.links,this.upstream]}postOver(e,t){for(let n of this.allLinks())n.kind===e&&n.post(t)}postJourney(e){for(let t of this.allLinks())this.journeyLink(t.kind)&&t.post(e)}receive=(e,t)=>{if(e.from!==this.contextId)switch(e.t){case`hello`:this.canOwn(t.link)&&this.postOver(t.link,{t:`welcome`,from:this.contextId,to:e.from,tabId:this.tabId});break;case`welcome`:if(e.to!==this.contextId)break;this.awaitingWelcome?.link===t.link&&(this.ownerId=e.from,this.awaitingWelcome.settle(!0));break;case`records`:this.role===`sender`?this.handlers.onRecords(e.records):this.upstream&&this.canRelay(t.link)&&this.upstream.post(e);break;case`journey`:this.acceptsJourney(e,t)&&this.applyJourney(e.journey);break;case`journey?`:{let n=this.handlers.onJourneyRequest();n&&this.journeyLink(t.link)&&this.postOver(t.link,{t:`journey`,from:this.contextId,to:e.from,journey:n});break}case`sampling?`:(this.role===`forwarder`?t.link!==this.upstream?.kind:this.canOwn(t.link))&&this.postOver(t.link,this.rulesAnswer(e.from));break;case`sampling`:this.acceptsRules(e.to,t)&&this.applyRules(e.rules);break;case`tab`:t.link===`broadcast`&&e.tabId===this.tabId&&this.contextId>e.from&&this.handlers.onTabConflict()}};canRelay(e){return e===`direct`||e!==this.upstream?.kind}canOwn(e){return this.role===`sender`?e===`openfin`?this.isOpenFinProvider:v.includes(e):!1}resolveOpenFinProvider(){let e=this.config.bus.openFinRole;if(e!==`auto`)return e===`provider`;if(this.platform.platform!==`openfin`&&this.platform.platform!==`openfin_web`)return!1;let t=globalThis.fin?.me;return!t?.identity||t.isView?!1:!!(t.identity.name&&t.identity.name===t.identity.uuid)}orphanPolicy(){return this.isCrossOriginFrame()?`retry`:`promote`}isCrossOriginFrame(){if(typeof window>`u`||window.parent===window)return!1;try{return Reflect.get(window.parent,`location`),!1}catch{return!0}}candidateUpstream(){return this.platform.isWorker?h(this.receive,this.diagnostics):this.platform.isTopLevelDocument?this.platform.platform===`openfin`&&!this.isOpenFinProvider?this.ensureOpenFinLink():null:d(this.receive,this.config.bus.trustedOrigins,this.diagnostics)}openControlLinks(){let t=e=>{e&&this.links.push(e)};this.platform.isTopLevelDocument&&(t(f(this.receive,this.config.bus.trustedOrigins,this.diagnostics)),t(p(e.S,this.receive,this.diagnostics))),(this.platform.platform===`openfin`||this.platform.platform===`openfin_web`)&&t(this.ensureOpenFinLink())}ensureOpenFinLink(){return this.openFinLink??=m(e.S,this.platform.openfinUuid,this.receive,this.diagnostics),this.openFinLink}handshake(e){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,this.awaitingWelcome=null,clearTimeout(a),n(e))};this.awaitingWelcome={link:e.kind,settle:i};let a=setTimeout(()=>{i(!1)},this.handshakeOptions.timeoutMs);t.r(a),e.post({t:`hello`,from:this.contextId,tabId:this.tabId})})}announce(){this.postOver(`broadcast`,{t:`tab`,from:this.contextId,tabId:this.tabId}),this.postJourney({t:`journey?`,from:this.contextId}),this.pollRules()}journeyScope(){let{scope:e}=this.config.journey;if(e!==`auto`)return e;let{platform:t}=this.platform;return t===`openfin`||t===`openfin_web`?`origin`:`tab`}journeyLink(e){let t=this.journeyScope();return t===`context`?!1:t===`origin`||e!==`broadcast`}acceptsJourney(e,t){return!this.journeyLink(t.link)||e.to!==void 0&&e.to!==this.contextId?!1:this.journeyScope()===`origin`||this.fromOwner(e.from,t.link)}fromOwner(e,t){return this.role!==`forwarder`||t!==this.upstream?.kind?!1:this.ownerId===null||e===this.ownerId}applyJourney(e){if(e===null){this.handlers.onJourney(null);return}let t=n.r(e);t===null?this.diagnostics.report(`record.dropped_malformed`,`The bus dropped a journey message. Its payload is not a journey.`,{type:`journey`}):this.handlers.onJourney(t)}rulesAnswer(e){let t=this.handlers.remote.sampling?.wire()??null;return{t:`sampling`,from:this.contextId,to:e,rules:t}}acceptsRules(e,t){if(this.role!==`forwarder`||e!==this.contextId||t.link!==this.upstream?.kind)return!1;let{origin:n}=t;return t.link===`parent`&&n!==location.origin&&!this.config.bus.trustedOrigins.includes(n)?(this.diagnostics.report(`bus.untrusted_origin`,`The bus ignored sampling rules from ${n}. If you own this origin, add it to bus.trustedOrigins.`,{origin:n,type:`sampling`}),!1):!0}applyRules(e){if(e===null){r.t(this.handlers.remote,this.config,null);return}let t=r.n(e,this.diagnostics);t&&r.t(this.handlers.remote,this.config,t)}pollRules(){let{upstream:n}=this;if(this.destroyed||this.role!==`forwarder`||!n)return;let r=()=>{this.config.sampling.remote&&n.post({t:`sampling?`,from:this.contextId})};r(),this.rulesPoll=setInterval(r,e.kt),t.r(this.rulesPoll)}};exports.Bus=y;
|
|
2
|
+
//# sourceMappingURL=bus-DNFvTkif.cjs.map
|