@utk09/ui-observability 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +122 -0
  3. package/dist/bus/bus.d.ts +30 -0
  4. package/dist/bus-CUXRY0JR.cjs +2 -0
  5. package/dist/bus-CUXRY0JR.cjs.map +1 -0
  6. package/dist/{bus-DfAbg_pg.js → bus-DPDrlUBY.js} +96 -50
  7. package/dist/bus-DPDrlUBY.js.map +1 -0
  8. package/dist/capture/console.d.ts +37 -0
  9. package/dist/capture/errors.d.ts +2 -4
  10. package/dist/capture/long-frames.d.ts +31 -0
  11. package/dist/capture/storm.d.ts +17 -0
  12. package/dist/capture/types.d.ts +2 -0
  13. package/dist/console-CNljJict.js +81 -0
  14. package/dist/console-CNljJict.js.map +1 -0
  15. package/dist/console-PKzc-FmR.cjs +2 -0
  16. package/dist/console-PKzc-FmR.cjs.map +1 -0
  17. package/dist/constants-B28fDv2F.cjs +2 -0
  18. package/dist/constants-B28fDv2F.cjs.map +1 -0
  19. package/dist/constants-Bu49bm39.js +93 -0
  20. package/dist/constants-Bu49bm39.js.map +1 -0
  21. package/dist/constants.d.ts +32 -2
  22. package/dist/core/breadcrumbs.d.ts +1 -1
  23. package/dist/core/pipeline.d.ts +2 -2
  24. package/dist/core/record.d.ts +3 -0
  25. package/dist/core/remote-rules.d.ts +17 -0
  26. package/dist/core/remote-sampling.d.ts +65 -0
  27. package/dist/core/runtime.d.ts +10 -4
  28. package/dist/core/sampling.d.ts +5 -2
  29. package/dist/core/sender.d.ts +3 -0
  30. package/dist/errors-C78ZTjet.cjs +3 -0
  31. package/dist/errors-C78ZTjet.cjs.map +1 -0
  32. package/dist/{errors-4MQyjZVj.js → errors-Dnc-X4Ec.js} +19 -20
  33. package/dist/errors-Dnc-X4Ec.js.map +1 -0
  34. package/dist/global-scope-BN-Io_yv.cjs +2 -0
  35. package/dist/global-scope-BN-Io_yv.cjs.map +1 -0
  36. package/dist/global-scope-dp2jADRl.js +19 -0
  37. package/dist/global-scope-dp2jADRl.js.map +1 -0
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.ts +2 -1
  41. package/dist/index.js +287 -242
  42. package/dist/index.js.map +1 -1
  43. package/dist/indexeddb-storage-D0p3iMD0.cjs +2 -0
  44. package/dist/{indexeddb-storage-CcEJlq2l.cjs.map → indexeddb-storage-D0p3iMD0.cjs.map} +1 -1
  45. package/dist/{indexeddb-storage-0LtUALBg.js → indexeddb-storage-uD4oaRMc.js} +10 -10
  46. package/dist/{indexeddb-storage-0LtUALBg.js.map → indexeddb-storage-uD4oaRMc.js.map} +1 -1
  47. package/dist/{interactions-BMNPQ3WH.cjs → interactions-CsE2y_fQ.cjs} +2 -2
  48. package/dist/{interactions-BMNPQ3WH.cjs.map → interactions-CsE2y_fQ.cjs.map} +1 -1
  49. package/dist/{interactions-BaCmoGLB.js → interactions-igKTAJvj.js} +2 -2
  50. package/dist/{interactions-BaCmoGLB.js.map → interactions-igKTAJvj.js.map} +1 -1
  51. package/dist/library-request-Br_T09Bn.cjs +2 -0
  52. package/dist/library-request-Br_T09Bn.cjs.map +1 -0
  53. package/dist/library-request-Dt0fXhcn.js +14 -0
  54. package/dist/library-request-Dt0fXhcn.js.map +1 -0
  55. package/dist/long-frames-6pnjWSSR.js +65 -0
  56. package/dist/long-frames-6pnjWSSR.js.map +1 -0
  57. package/dist/long-frames-DahhqM6u.cjs +2 -0
  58. package/dist/long-frames-DahhqM6u.cjs.map +1 -0
  59. package/dist/models/bus.d.ts +16 -0
  60. package/dist/models/config.d.ts +90 -0
  61. package/dist/network-CZ0aFUsy.cjs +2 -0
  62. package/dist/network-CZ0aFUsy.cjs.map +1 -0
  63. package/dist/{network-jQ2t8rU4.js → network-aSNbwpue.js} +16 -15
  64. package/dist/network-aSNbwpue.js.map +1 -0
  65. package/dist/{platform-YuByH8A5.js → platform-BwbMRwHm.js} +7 -7
  66. package/dist/{platform-YuByH8A5.js.map → platform-BwbMRwHm.js.map} +1 -1
  67. package/dist/{platform-ByQllE_W.cjs → platform-D_XkVIF6.cjs} +2 -2
  68. package/dist/{platform-ByQllE_W.cjs.map → platform-D_XkVIF6.cjs.map} +1 -1
  69. package/dist/remote-rules-5UA23alm.js +86 -0
  70. package/dist/remote-rules-5UA23alm.js.map +1 -0
  71. package/dist/remote-rules-rJJZKVG8.cjs +2 -0
  72. package/dist/remote-rules-rJJZKVG8.cjs.map +1 -0
  73. package/dist/sampling-E4x92Nn2.cjs +2 -0
  74. package/dist/sampling-E4x92Nn2.cjs.map +1 -0
  75. package/dist/sampling-J1eahbfT.js +160 -0
  76. package/dist/sampling-J1eahbfT.js.map +1 -0
  77. package/dist/sanitize-BMhh8ghJ.cjs +2 -0
  78. package/dist/sanitize-BMhh8ghJ.cjs.map +1 -0
  79. package/dist/sanitize-UJ-4Lb0n.js +114 -0
  80. package/dist/sanitize-UJ-4Lb0n.js.map +1 -0
  81. package/dist/sender-B6ufz26f.cjs +3 -0
  82. package/dist/sender-B6ufz26f.cjs.map +1 -0
  83. package/dist/{sender-BIob8eZz.js → sender-G6v4Uqi4.js} +304 -219
  84. package/dist/sender-G6v4Uqi4.js.map +1 -0
  85. package/dist/storm-BtzgLOCX.cjs +2 -0
  86. package/dist/storm-BtzgLOCX.cjs.map +1 -0
  87. package/dist/storm-DJkEZP_8.js +10 -0
  88. package/dist/storm-DJkEZP_8.js.map +1 -0
  89. package/dist/transport/custom-transport.d.ts +20 -0
  90. package/dist/transport/errors.d.ts +2 -1
  91. package/dist/transport/exit-flush.d.ts +15 -0
  92. package/dist/transport/http-transport.d.ts +2 -24
  93. package/dist/transport/memory-transport.d.ts +30 -0
  94. package/dist/transport/retry-engine.d.ts +2 -2
  95. package/dist/transport/serializers/select.d.ts +12 -1
  96. package/dist/transport/status-transport.d.ts +72 -0
  97. package/dist/utils/deadline.d.ts +7 -0
  98. package/dist/utils/global-scope.d.ts +20 -0
  99. package/dist/utils/library-console.d.ts +11 -0
  100. package/dist/utils/library-request.d.ts +12 -0
  101. package/package.json +1 -1
  102. package/dist/bus-DeZzr2bx.cjs +0 -2
  103. package/dist/bus-DeZzr2bx.cjs.map +0 -1
  104. package/dist/bus-DfAbg_pg.js.map +0 -1
  105. package/dist/constants-C8nZQBmQ.js +0 -86
  106. package/dist/constants-C8nZQBmQ.js.map +0 -1
  107. package/dist/constants-IBL_jd5R.cjs +0 -2
  108. package/dist/constants-IBL_jd5R.cjs.map +0 -1
  109. package/dist/errors-4MQyjZVj.js.map +0 -1
  110. package/dist/errors-CUdShXe7.cjs +0 -3
  111. package/dist/errors-CUdShXe7.cjs.map +0 -1
  112. package/dist/indexeddb-storage-CcEJlq2l.cjs +0 -2
  113. package/dist/network-DBNvxCE3.cjs +0 -2
  114. package/dist/network-DBNvxCE3.cjs.map +0 -1
  115. package/dist/network-jQ2t8rU4.js.map +0 -1
  116. package/dist/sampling-CbYySsZ1.js +0 -251
  117. package/dist/sampling-CbYySsZ1.js.map +0 -1
  118. package/dist/sampling-Cs50xsZl.cjs +0 -2
  119. package/dist/sampling-Cs50xsZl.cjs.map +0 -1
  120. package/dist/sender-BIob8eZz.js.map +0 -1
  121. package/dist/sender-iOjzcueM.cjs +0 -3
  122. package/dist/sender-iOjzcueM.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,55 +1,56 @@
1
- import { At as e, C as t, Ct as n, D as r, Dt as i, E as a, Et as o, F as s, Gt as c, M as l, Mt as u, N as d, Nt as f, Ot as p, Pt as m, Rt as h, St as g, T as _, Tt as ee, Vt as v, Yt as te, _ as ne, a as y, an as re, at as ie, bt as b, c as x, cn as ae, d as oe, g as se, h as ce, ht as le, i as ue, in as de, it as S, j as C, jt as fe, kt as pe, l as w, ln as me, m as he, mt as ge, n as T, nn as _e, nt as E, o as D, on as ve, p as ye, r as be, rn as xe, rt as Se, s as Ce, tt as we, u as O, un as k, wt as Te, zt as Ee } from "./constants-C8nZQBmQ.js";
2
- import { _ as De, a as A, c as j, d as Oe, g as M, h as ke, i as Ae, l as je, m as N, n as Me, o as Ne, p as Pe, r as Fe, s as Ie, u as P } from "./sampling-CbYySsZ1.js";
3
- import { n as Le, r as Re, t as ze } from "./platform-YuByH8A5.js";
4
- import { t as Be } from "./unref-16maCyKA.js";
1
+ import { At as e, Bt as t, C as n, Ct as r, D as i, E as a, F as o, Ft as s, Gt as c, It as l, Lt as u, M as d, Mt as f, N as p, Nt as m, Ot as h, Pt as g, Rt as _, T as v, Wt as ee, Zt as te, _ as ne, _t as re, a as y, at as b, c as x, cn as ie, d as ae, dn as oe, fn as se, g as ce, gn as S, h as le, hn as ue, i as de, it as fe, j as C, jt as pe, kt as me, l as w, ln as he, m as ge, mn as _e, n as T, nt as ve, o as E, p as ye, qt as D, r as be, rt as O, s as xe, st as Se, tn as Ce, u as k, un as we, vt as Te, zt as Ee } from "./constants-Bu49bm39.js";
2
+ import { a as De, c as Oe, d as A, f as ke, l as j, m as Ae, n as je, o as M, p as N, r as Me, s as Ne, u as Pe } from "./sampling-J1eahbfT.js";
3
+ import { a as Fe, i as Ie, n as Le, o as P, r as F } from "./sanitize-UJ-4Lb0n.js";
4
+ import { n as Re, r as ze, t as Be } from "./platform-BwbMRwHm.js";
5
+ import { t as Ve } from "./unref-16maCyKA.js";
5
6
  //#region src/utils/timer.ts
6
- function F(e) {
7
- return Math.round((performance.now() - e) * s) / s;
7
+ function I(e) {
8
+ return Math.round((performance.now() - e) * o) / o;
8
9
  }
9
- function I(e, t, n, r, i) {
10
- e.logMetric(`${t}.duration`, F(n), "ms", "histogram", {
10
+ function L(e, t, n, r, i) {
11
+ e.logMetric(`${t}.duration`, I(n), "ms", "histogram", {
11
12
  status: r,
12
13
  ...i
13
14
  });
14
15
  }
15
- function L(e, t, n, r, i) {
16
+ function R(e, t, n, r, i) {
16
17
  e.error(`${t} failed`, r, {
17
- "action.duration_ms": F(n),
18
+ "action.duration_ms": I(n),
18
19
  status: "FAILURE",
19
20
  ...i
20
21
  });
21
22
  }
22
- function Ve(e, t, n, r) {
23
+ function He(e, t, n, r) {
23
24
  let i = performance.now();
24
25
  try {
25
26
  let a = n();
26
- return I(e, t, i, "SUCCESS", r), a;
27
+ return L(e, t, i, "SUCCESS", r), a;
27
28
  } catch (n) {
28
- throw L(e, t, i, n, r), n;
29
+ throw R(e, t, i, n, r), n;
29
30
  }
30
31
  }
31
- async function He(e, t, n, r) {
32
+ async function Ue(e, t, n, r) {
32
33
  let i = performance.now();
33
34
  try {
34
35
  let a = await n();
35
- return I(e, t, i, "SUCCESS", r), a;
36
+ return L(e, t, i, "SUCCESS", r), a;
36
37
  } catch (n) {
37
- throw L(e, t, i, n, r), n;
38
+ throw R(e, t, i, n, r), n;
38
39
  }
39
40
  }
40
41
  //#endregion
41
42
  //#region src/core/logger.ts
42
- function Ue(e, t) {
43
+ function We(e, t) {
43
44
  if (e instanceof Error) return e;
44
45
  let n = t.guard("record.sanitize_failed", "The library could not convert the error reason to text.", () => String(e));
45
46
  return Error(n ?? typeof e);
46
47
  }
47
- function We(e) {
48
+ function Ge(e) {
48
49
  if (typeof e != "object" || !e || Array.isArray(e) || e instanceof Error) return !1;
49
50
  let t = Object.getPrototypeOf(e);
50
51
  return t === null || Object.getPrototypeOf(t) === null;
51
52
  }
52
- var R = class e {
53
+ var z = class e {
53
54
  bind;
54
55
  namespace;
55
56
  options;
@@ -86,7 +87,7 @@ var R = class e {
86
87
  logEvent = (e, t) => {
87
88
  this.write("INFO", "event", e, t);
88
89
  };
89
- logMetric = (e, t, n = l, r = "gauge", i) => {
90
+ logMetric = (e, t, n = d, r = "gauge", i) => {
90
91
  this.write("INFO", "metric", e, {
91
92
  "metric.name": e,
92
93
  "metric.value": t,
@@ -95,8 +96,8 @@ var R = class e {
95
96
  ...i
96
97
  });
97
98
  };
98
- timeSync = (e, t, n) => Ve(this, e, t, n);
99
- timeAsync = (e, t, n) => He(this, e, t, n);
99
+ timeSync = (e, t, n) => He(this, e, t, n);
100
+ timeAsync = (e, t, n) => Ue(this, e, t, n);
100
101
  write(e, t, n, r) {
101
102
  let i = this.bind();
102
103
  if (i.isDestroyed()) return;
@@ -123,7 +124,7 @@ var R = class e {
123
124
  if (i.isDestroyed()) return;
124
125
  let a = i.builder.isEnabled(e);
125
126
  if (!a && !this.mirrors(i, e)) return;
126
- let o = r === void 0 && We(n), s = o ? n : r, c = o || n === void 0 ? void 0 : Ue(n, i.diagnostics);
127
+ let o = r === void 0 && Ge(n), s = o ? n : r, c = o || n === void 0 ? void 0 : We(n, i.diagnostics);
127
128
  if (!a) {
128
129
  this.print(i, e, t, s, c, null);
129
130
  return;
@@ -152,14 +153,14 @@ var R = class e {
152
153
  mirrors(e, t) {
153
154
  return e.config.enabled && e.console.accepts(t);
154
155
  }
155
- }, Ge = {
156
+ }, Ke = {
156
157
  TRACE: "debug",
157
158
  DEBUG: "debug",
158
159
  INFO: "info",
159
160
  WARN: "warn",
160
161
  ERROR: "error",
161
162
  FATAL: "error"
162
- }, Ke = class {
163
+ }, qe = class {
163
164
  settings;
164
165
  diagnostics;
165
166
  constructor(e, t) {
@@ -169,17 +170,19 @@ var R = class e {
169
170
  this.settings = e;
170
171
  }
171
172
  accepts(e) {
172
- return this.settings.level !== null && S[e] >= S[this.settings.level];
173
- }
174
- write(e, t, n, r, i) {
175
- if (!this.accepts(t) || typeof console > "u") return;
176
- let a = `%c[%s]%c[${t}]%c`, { styles: o } = this.settings, s = Ge[t];
177
- this.diagnostics.guard("handler.threw", `The library could not print to console.${s}.`, () => {
178
- let c = [];
179
- i !== void 0 && c.push(i), r !== void 0 && c.push(Pe(r, b, this.diagnostics)), console[s](a, o.namespace, e, o[t], "", n, ...c);
173
+ return this.settings.level !== null && b[e] >= b[this.settings.level];
174
+ }
175
+ write(e, t, n, i, a) {
176
+ if (!this.accepts(t) || typeof console > "u" || Fe()) return;
177
+ let o = `%c[%s]%c[${t}]%c`, { styles: s } = this.settings, c = Ke[t];
178
+ this.diagnostics.guard("handler.threw", `The library could not print to console.${c}.`, () => {
179
+ let l = [];
180
+ a !== void 0 && l.push(a), i !== void 0 && l.push(Le(i, r, this.diagnostics)), P(() => {
181
+ console[c](o, s.namespace, e, s[t], "", n, ...l);
182
+ });
180
183
  });
181
184
  }
182
- }, qe = class {
185
+ }, Je = class {
183
186
  value = 0;
184
187
  next() {
185
188
  return ++this.value;
@@ -187,38 +190,38 @@ var R = class e {
187
190
  reset() {
188
191
  this.value = 0;
189
192
  }
190
- }, Je = /^[0-9a-f]{32}$/, Ye = /^[0-9a-f]{16}$/, z = /[1-9a-f]/;
191
- function Xe(e) {
192
- return Je.test(e.traceId) && z.test(e.traceId) && Ye.test(e.spanId) && z.test(e.spanId);
193
- }
194
- function Ze() {
195
- return P(16);
193
+ }, Ye = /^[0-9a-f]{32}$/, Xe = /^[0-9a-f]{16}$/, B = /[1-9a-f]/;
194
+ function Ze(e) {
195
+ return Ye.test(e.traceId) && B.test(e.traceId) && Xe.test(e.spanId) && B.test(e.spanId);
196
196
  }
197
197
  function Qe() {
198
- return P(8);
198
+ return A(16);
199
+ }
200
+ function $e() {
201
+ return A(8);
199
202
  }
200
- function B() {
203
+ function V() {
201
204
  return {
202
- traceId: Ze(),
203
- spanId: Qe(),
205
+ traceId: Qe(),
206
+ spanId: $e(),
204
207
  traceFlags: 1,
205
208
  startedAt: Date.now()
206
209
  };
207
210
  }
208
- function V(e) {
211
+ function H(e) {
209
212
  return {
210
213
  traceId: e.traceId,
211
214
  spanId: e.spanId,
212
215
  traceFlags: e.traceFlags
213
216
  };
214
217
  }
215
- var $e = class {
218
+ var et = class {
216
219
  diagnostics;
217
220
  maxAgeMs;
218
221
  load;
219
- ambient = B();
222
+ ambient = V();
220
223
  otel;
221
- constructor(e, t = ve, n) {
224
+ constructor(e, t = se, n) {
222
225
  this.diagnostics = e, this.maxAgeMs = t, this.load = n;
223
226
  }
224
227
  async loadOtel() {
@@ -230,7 +233,7 @@ var $e = class {
230
233
  }
231
234
  resolve() {
232
235
  let e = this.activeSpanContext();
233
- return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), V(this.ambient)) : e;
236
+ return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), H(this.ambient)) : e;
234
237
  }
235
238
  activeSpanContext() {
236
239
  let e = this.otel;
@@ -238,7 +241,7 @@ var $e = class {
238
241
  let t = e.trace.getActiveSpan();
239
242
  if (t === void 0) return;
240
243
  let n = t.spanContext();
241
- if (Xe(n)) return {
244
+ if (Ze(n)) return {
242
245
  traceId: n.traceId,
243
246
  spanId: n.spanId,
244
247
  traceFlags: n.traceFlags
@@ -246,7 +249,7 @@ var $e = class {
246
249
  });
247
250
  }
248
251
  rotate(e) {
249
- return this.ambient = B(), V(this.ambient);
252
+ return this.ambient = V(), H(this.ambient);
250
253
  }
251
254
  headers() {
252
255
  let e = {}, t = this.otel;
@@ -254,11 +257,11 @@ var $e = class {
254
257
  t.propagation.inject(t.context.active(), e);
255
258
  }), !e.traceparent) {
256
259
  let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
257
- e[re] = `00-${t.traceId}-${t.spanId}-${n}`;
260
+ e[oe] = `00-${t.traceId}-${t.spanId}-${n}`;
258
261
  }
259
262
  return e;
260
263
  }
261
- }, et = class {
264
+ }, tt = class {
262
265
  buffer;
263
266
  pointer = 0;
264
267
  filled = !1;
@@ -278,19 +281,19 @@ var $e = class {
278
281
  };
279
282
  //#endregion
280
283
  //#region src/core/config.ts
281
- function tt(e) {
284
+ function nt(e) {
282
285
  return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
283
286
  }
284
- function nt(e, t, n) {
285
- return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || tt(e) ? e : (n.report("config.invalid", `serializer must be "${v}", "ecs" or an implementation. The library uses "${v}".`), v);
287
+ function rt(e, t, n) {
288
+ return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || nt(e) ? e : (n.report("config.invalid", `serializer must be "${D}", "ecs" or an implementation. The library uses "${D}".`), D);
286
289
  }
287
- var rt = new Set(Object.keys(r));
288
- function it(e, t) {
290
+ var it = new Set(Object.keys(i));
291
+ function at(e, t) {
289
292
  let n = {}, r = Object.entries(e ?? {});
290
- for (let [e, i] of r) rt.has(e) ? typeof i == "string" ? n[e] = i : t.report("config.invalid", `console.styles.${e} must be a string. The library keeps the style in force.`) : t.report("config.invalid", `The library ignores the unknown console.styles key "${e}". Check the spelling.`);
293
+ for (let [e, i] of r) it.has(e) ? typeof i == "string" ? n[e] = i : t.report("config.invalid", `console.styles.${e} must be a string. The library keeps the style in force.`) : t.report("config.invalid", `The library ignores the unknown console.styles key "${e}". Check the spelling.`);
291
294
  return n;
292
295
  }
293
- function at(e, t, n) {
296
+ function ot(e, t, n) {
294
297
  return e === void 0 ? t : e === !1 ? {
295
298
  level: null,
296
299
  styles: t.styles
@@ -304,17 +307,17 @@ function at(e, t, n) {
304
307
  level: e.level ?? t.level ?? "DEBUG",
305
308
  styles: {
306
309
  ...t.styles,
307
- ...it(e.styles, n)
310
+ ...at(e.styles, n)
308
311
  }
309
312
  };
310
313
  }
311
- function H(e, t, n) {
314
+ function U(e, t, n) {
312
315
  let r = n ?? C, i = {
313
316
  ...r,
314
317
  ...e,
315
318
  endpoint: e.endpoint === void 0 ? r.endpoint : e.endpoint,
316
- serializer: nt(e.serializer, n?.serializer, t),
317
- console: at(e.console, r.console, t),
319
+ serializer: rt(e.serializer, n?.serializer, t),
320
+ console: ot(e.console, r.console, t),
318
321
  sampling: {
319
322
  ...r.sampling,
320
323
  ...e.sampling,
@@ -332,36 +335,38 @@ function H(e, t, n) {
332
335
  ...e.capture
333
336
  }
334
337
  };
335
- if (i.endpoint === "") t.report("config.invalid", "endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.");
338
+ if (i.transport !== void 0 && typeof i.transport != "function" && (t.report("config.invalid", "transport must be a function. The library ignores the value."), i.transport = r.transport), i.transportOnExit !== void 0 && typeof i.transportOnExit != "function" && (t.report("config.invalid", "transportOnExit must be a function. The library ignores the value."), i.transportOnExit = r.transportOnExit), i.endpoint === "") i.transport === void 0 && t.report("config.invalid", "endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.");
336
339
  else if (i.endpoint !== null) try {
337
340
  new URL(i.endpoint);
338
341
  } catch (e) {
339
342
  t.report("config.invalid", `endpoint is not a valid absolute URL: ${i.endpoint}.`, void 0, e);
340
343
  }
341
- i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${k}'.`), k);
344
+ i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${S}'.`), S);
342
345
  let a = i.sampling.defaultRate;
343
346
  (typeof a != "number" || a < 0 || a > 1) && (t.report("config.invalid", `sampling.defaultRate must be 0..1. The value is ${String(a)}. The library uses 1.`), i.sampling.defaultRate = 1);
344
- let o = Object.entries(i.sampling.rates);
345
- for (let [e, n] of o) (typeof n != "number" || n < 0 || n > 1) && (t.report("config.invalid", `sampling.rates["${e}"] must be 0..1. The value is ${String(n)}. The library uses 1.`), i.sampling.rates[e] = 1);
346
- return i.capture.ignoreUrls = i.capture.ignoreUrls.filter((e) => e !== n?.endpoint), i.endpoint && !i.capture.ignoreUrls.includes(i.endpoint) && (i.capture.ignoreUrls = [...i.capture.ignoreUrls, i.endpoint]), ot(e, t), i;
347
+ let o = i.sampling.remoteMaxRate;
348
+ (typeof o != "number" || !(o >= 0 && o <= 1)) && (t.report("config.invalid", `sampling.remoteMaxRate must be 0..1. The value is ${String(o)}. The library uses 1.`), i.sampling.remoteMaxRate = 1);
349
+ let s = Object.entries(i.sampling.rates);
350
+ for (let [e, n] of s) (typeof n != "number" || n < 0 || n > 1) && (t.report("config.invalid", `sampling.rates["${e}"] must be 0..1. The value is ${String(n)}. The library uses 1.`), i.sampling.rates[e] = 1);
351
+ return i.capture.ignoreUrls = i.capture.ignoreUrls.filter((e) => e !== n?.endpoint), i.endpoint && !i.capture.ignoreUrls.includes(i.endpoint) && (i.capture.ignoreUrls = [...i.capture.ignoreUrls, i.endpoint]), st(e, t), i;
347
352
  }
348
- function ot(e, t) {
349
- let n = /* @__PURE__ */ new Set([...Object.keys(C), ...ae]);
353
+ function st(e, t) {
354
+ let n = /* @__PURE__ */ new Set([...Object.keys(C), ..._e]);
350
355
  for (let r of Object.keys(e)) n.has(r) || t.report("config.invalid", `The library ignores the unknown config key "${r}". Check the spelling.`);
351
- for (let n of _) {
356
+ for (let n of v) {
352
357
  let r = e[n];
353
358
  if (typeof r != "object" || !r) continue;
354
- let i = /* @__PURE__ */ new Set([...Object.keys(C[n]), ...me[n]]);
359
+ let i = /* @__PURE__ */ new Set([...Object.keys(C[n]), ...ue[n]]);
355
360
  for (let e of Object.keys(r)) i.has(e) || t.report("config.invalid", `The library ignores the unknown config key "${n}.${e}". Check the spelling.`);
356
361
  }
357
362
  }
358
- function st(e, t) {
359
- for (let n of Object.keys(t)) _.includes(n) || Object.assign(e, { [n]: t[n] });
360
- for (let n of _) Object.assign(e[n], t[n]);
363
+ function ct(e, t) {
364
+ for (let n of Object.keys(t)) v.includes(n) || Object.assign(e, { [n]: t[n] });
365
+ for (let n of v) Object.assign(e[n], t[n]);
361
366
  }
362
367
  //#endregion
363
368
  //#region src/core/context.ts
364
- var ct = class {
369
+ var lt = class {
365
370
  map = /* @__PURE__ */ new Map();
366
371
  set(e, t) {
367
372
  this.map.set(e, t);
@@ -381,12 +386,12 @@ var ct = class {
381
386
  getAll() {
382
387
  return Object.fromEntries(this.map);
383
388
  }
384
- }, lt = class {
389
+ }, ut = class {
385
390
  handler;
386
391
  throttleMs;
387
392
  counters = /* @__PURE__ */ new Map();
388
393
  lastEmitted = /* @__PURE__ */ new Map();
389
- constructor(e, t = d) {
394
+ constructor(e, t = p) {
390
395
  this.handler = e, this.throttleMs = t;
391
396
  }
392
397
  setHandler(e) {
@@ -407,11 +412,15 @@ var ct = class {
407
412
  cause: r,
408
413
  at: a,
409
414
  count: i
410
- };
411
- if (this.handler) try {
412
- this.handler(o);
415
+ }, { handler: s } = this;
416
+ if (s) try {
417
+ P(() => {
418
+ s(o);
419
+ });
413
420
  } catch (e) {
414
- this.count("handler.threw"), typeof console < "u" && console.warn(`${ie} The onDiagnostic handler threw an error.`, e);
421
+ this.count("handler.threw"), typeof console < "u" && P(() => {
422
+ console.warn(`${Se} The onDiagnostic handler threw an error.`, e);
423
+ });
415
424
  }
416
425
  }
417
426
  guard(e, t, n) {
@@ -436,51 +445,51 @@ var ct = class {
436
445
  reset() {
437
446
  this.counters.clear(), this.lastEmitted.clear();
438
447
  }
439
- }, ut = {
440
- maxAgeMs: we,
448
+ }, dt = {
449
+ maxAgeMs: ve,
441
450
  endOnOwnerClose: !1,
442
- urlParam: Se
451
+ urlParam: fe
443
452
  };
444
- function U(e, t) {
453
+ function W(e, t) {
445
454
  let n = Reflect.get(e, t);
446
455
  return typeof n == "string" && n !== "" ? n : void 0;
447
456
  }
448
- function W(e, t) {
457
+ function G(e, t) {
449
458
  let n = Reflect.get(e, t);
450
459
  return typeof n == "number" && Number.isFinite(n) ? n : void 0;
451
460
  }
452
- function dt(e) {
461
+ function ft(e) {
453
462
  if (typeof e != "object" || !e) return null;
454
- let t = U(e, "id"), n = U(e, "name"), r = W(e, "startedAt");
463
+ let t = W(e, "id"), n = W(e, "name"), r = G(e, "startedAt");
455
464
  return t === void 0 || n === void 0 || r === void 0 ? null : {
456
465
  id: t,
457
466
  name: n,
458
467
  startedAt: r,
459
- parentId: U(e, "parentId"),
460
- ownerContextId: U(e, "ownerContextId") ?? ""
468
+ parentId: W(e, "parentId"),
469
+ ownerContextId: W(e, "ownerContextId") ?? ""
461
470
  };
462
471
  }
463
- function ft(e) {
472
+ function pt(e) {
464
473
  if (typeof e != "object" || !e) return null;
465
- let t = U(e, "i"), n = U(e, "n");
474
+ let t = W(e, "i"), n = W(e, "n");
466
475
  return t === void 0 || n === void 0 ? null : {
467
476
  id: t,
468
477
  name: n,
469
- startedAt: W(e, "s") ?? Date.now(),
478
+ startedAt: G(e, "s") ?? Date.now(),
470
479
  parentId: void 0,
471
480
  ownerContextId: ""
472
481
  };
473
482
  }
474
- function pt(e) {
483
+ function mt(e) {
475
484
  let t = JSON.stringify({
476
485
  i: e.id,
477
486
  n: e.name.slice(0, 64),
478
487
  s: e.startedAt
479
488
  }), n = new TextEncoder().encode(t), r = "";
480
489
  for (let e of n) r += String.fromCharCode(e);
481
- return btoa(r).replace(se, "-").replace(ne, "_").replace(ce, "");
490
+ return btoa(r).replace(ce, "-").replace(ne, "_").replace(le, "");
482
491
  }
483
- var mt = class {
492
+ var ht = class {
484
493
  options;
485
494
  diagnostics;
486
495
  contextId;
@@ -488,7 +497,7 @@ var mt = class {
488
497
  stores;
489
498
  journey = null;
490
499
  expiryTimer = null;
491
- constructor(e, t, n, r, i = A) {
500
+ constructor(e, t, n, r, i = M) {
492
501
  this.options = e, this.diagnostics = t, this.contextId = n, this.onLocalChange = r, this.stores = i;
493
502
  }
494
503
  current() {
@@ -497,7 +506,7 @@ var mt = class {
497
506
  async bootstrap() {
498
507
  let e = this.readUrlToken();
499
508
  if (e && this.adopt(e, "url")) return;
500
- let t = this.diagnostics.guard("storage.unavailable", "The library could not read the persisted journey.", () => this.stores.session().getItem(E));
509
+ let t = this.diagnostics.guard("storage.unavailable", "The library could not read the persisted journey.", () => this.stores.session().getItem(O));
501
510
  if (t && this.restore(t)) return;
502
511
  let n = await this.readOpenFinToken();
503
512
  n !== null && this.adopt(n, "openfin.customData");
@@ -522,7 +531,7 @@ var mt = class {
522
531
  getToken() {
523
532
  let e = this.journey;
524
533
  if (e === null) return;
525
- let t = pt(e);
534
+ let t = mt(e);
526
535
  if (t.length > 256) this.diagnostics.report("journey.token_too_large", "The journey token is larger than the size limit. The library does not issue it.", { length: t.length });
527
536
  else return t;
528
537
  }
@@ -543,7 +552,7 @@ var mt = class {
543
552
  this.clearTimer();
544
553
  }
545
554
  restore(e) {
546
- let t = dt(this.diagnostics.guard("storage.degraded", "The library could not parse the persisted journey.", () => JSON.parse(e)));
555
+ let t = ft(this.diagnostics.guard("storage.degraded", "The library could not parse the persisted journey.", () => JSON.parse(e)));
547
556
  return t === null ? !1 : Date.now() - t.startedAt > this.options.maxAgeMs ? (this.diagnostics.report("journey.expired", "The library discarded a persisted journey older than maxAgeMs.", { name: t.name }), this.clearStored(), !1) : (this.setJourney(t), this.diagnostics.report("journey.adopted", `The library resumed the journey "${t.name}".`, {
548
557
  source: "sessionStorage",
549
558
  journeyId: t.id
@@ -551,22 +560,22 @@ var mt = class {
551
560
  }
552
561
  decodeToken(e) {
553
562
  return this.diagnostics.guard("config.invalid", "The library could not decode a seeded journey token.", () => {
554
- let t = e.replace(ye, "+").replace(he, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
555
- return ft(JSON.parse(new TextDecoder().decode(i)));
563
+ let t = e.replace(ye, "+").replace(ge, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
564
+ return pt(JSON.parse(new TextDecoder().decode(i)));
556
565
  }) ?? null;
557
566
  }
558
567
  setJourney(e) {
559
568
  if (this.journey = e, this.clearTimer(), this.diagnostics.guard("storage.unavailable", "The library could not save the journey.", () => {
560
- e === null ? this.stores.session().removeItem(E) : this.stores.session().setItem(E, JSON.stringify(e));
569
+ e === null ? this.stores.session().removeItem(O) : this.stores.session().setItem(O, JSON.stringify(e));
561
570
  }), e === null) return;
562
571
  let t = Math.max(this.options.maxAgeMs - (Date.now() - e.startedAt), 0), n = setTimeout(() => {
563
572
  this.diagnostics.report("journey.expired", `The journey "${e.name}" reached maxAgeMs. The library ended it.`, { journeyId: e.id }), this.journey = null, this.expiryTimer = null, this.clearStored();
564
573
  }, t);
565
- this.expiryTimer = n, Be(n);
574
+ this.expiryTimer = n, Ve(n);
566
575
  }
567
576
  clearStored() {
568
577
  this.diagnostics.guard("storage.unavailable", "The library could not clear the persisted journey.", () => {
569
- this.stores.session().removeItem(E);
578
+ this.stores.session().removeItem(O);
570
579
  });
571
580
  }
572
581
  clearTimer() {
@@ -578,16 +587,16 @@ var mt = class {
578
587
  async readOpenFinToken() {
579
588
  let e = globalThis.fin?.me, t = e?.getOptions;
580
589
  if (t === void 0) return null;
581
- let n = (await this.diagnostics.guardAsync("openfin.unavailable", "The library could not read fin.me.getOptions().", () => Ae(t.call(e), le)))?.customData?.[ge];
590
+ let n = (await this.diagnostics.guardAsync("openfin.unavailable", "The library could not read fin.me.getOptions().", () => De(t.call(e), Te)))?.customData?.[re];
582
591
  return typeof n == "string" ? n : null;
583
592
  }
584
593
  };
585
594
  //#endregion
586
595
  //#region src/core/record.ts
587
- function G(e) {
596
+ function K(e) {
588
597
  return e;
589
598
  }
590
- var ht = class {
599
+ var gt = class {
591
600
  deps;
592
601
  resourceCache = null;
593
602
  constructor(e) {
@@ -598,45 +607,47 @@ var ht = class {
598
607
  }
599
608
  isEnabled(e) {
600
609
  let { config: t } = this.deps;
601
- return t.enabled ? S[e] >= S[t.minLevel] : !1;
610
+ if (!t.enabled) return !1;
611
+ let n = this.deps.remote.sampling?.minLevel() ?? t.minLevel;
612
+ return b[e] >= b[n];
602
613
  }
603
614
  build(e) {
604
- let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o } = this.deps;
615
+ let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o, remote: s } = this.deps;
605
616
  if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"), {
606
617
  record: null,
607
618
  dropped: "level"
608
619
  };
609
- let s = r.resolve(), l = i.current();
610
- if (!Fe({
620
+ let c = r.resolve(), l = i.current();
621
+ if (!Me({
611
622
  level: e.level,
612
623
  type: e.type,
613
624
  namespace: e.namespace,
614
625
  journeyId: l?.id ?? "",
615
- traceId: s.traceId
616
- }, t)) return n.count("record.dropped_by_sampling"), {
626
+ traceId: c.traceId
627
+ }, t, s.sampling?.current() ?? null)) return n.count("record.dropped_by_sampling"), {
617
628
  record: null,
618
629
  dropped: "sampling"
619
630
  };
620
- let u = a.next(), d = ze(n), f = t.capture.fullUrls ? d : Re(d), p, m = 0;
631
+ let u = a.next(), d = Be(n), f = t.capture.fullUrls ? d : ze(d), p, m = 0;
621
632
  try {
622
- let t = N(this.deps.context.getAll(), o, n), r = N(e.scoped ?? {}, o, n), i = N(e.payload ?? {}, o, n);
633
+ let t = F(this.deps.context.getAll(), o, n), r = F(e.scoped ?? {}, o, n), i = F(e.payload ?? {}, o, n);
623
634
  m = t.bytes + r.bytes + i.bytes, p = {
624
- ...G(t.value),
625
- ...G(r.value),
626
- ...G(i.value)
635
+ ...K(t.value),
636
+ ...K(r.value),
637
+ ...K(i.value)
627
638
  };
628
639
  } catch (e) {
629
- n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [oe]: !0 };
640
+ n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [ae]: !0 };
630
641
  }
631
- p[w] = e.type, p[x] = u, p[T] = e.namespace, p[O] = f, l && (p[y] = l.id, p[D] = l.name, l.parentId !== void 0 && (p[Ce] = l.parentId));
632
- let h = ke(e.body, o.maxBodyChars);
642
+ p[w] = e.type, p[x] = u, p[T] = e.namespace, p[k] = f, l && (p[y] = l.id, p[E] = l.name, l.parentId !== void 0 && (p[xe] = l.parentId));
643
+ let h = Ie(e.body, o.maxBodyChars);
633
644
  h !== e.body && n.count("record.truncated");
634
645
  let g = {
635
- timeUnixNano: De(),
636
- traceId: s.traceId,
637
- spanId: s.spanId,
638
- traceFlags: s.traceFlags,
639
- severityNumber: c[e.level],
646
+ timeUnixNano: Ae(),
647
+ traceId: c.traceId,
648
+ spanId: c.spanId,
649
+ traceFlags: c.traceFlags,
650
+ severityNumber: te[e.level],
640
651
  severityText: e.level,
641
652
  body: h,
642
653
  attributes: p,
@@ -649,11 +660,11 @@ var ht = class {
649
660
  dropped: "redact"
650
661
  };
651
662
  if (e !== void 0 && e !== g) {
652
- if (M(e)) {
653
- let t = N(e.attributes, o, n);
663
+ if (N(e)) {
664
+ let t = F(e.attributes, o, n);
654
665
  g = {
655
666
  ...e,
656
- attributes: G(t.value)
667
+ attributes: K(t.value)
657
668
  }, m = t.bytes;
658
669
  } else n.report("record.sanitize_failed", "The redact hook returned a value that is not a record. The library keeps the original record.");
659
670
  }
@@ -667,39 +678,41 @@ var ht = class {
667
678
  [w]: e.type,
668
679
  [x]: u,
669
680
  [T]: e.namespace,
670
- [O]: f,
671
- [ue]: !0,
681
+ [k]: f,
682
+ [de]: !0,
672
683
  [be]: m
673
684
  };
674
- l && (t[y] = l.id, t[D] = l.name), g.attributes = t;
685
+ l && (t[y] = l.id, t[E] = l.name), g.attributes = t;
675
686
  }
676
687
  return { record: g };
677
688
  }
678
689
  resource() {
679
690
  if (this.resourceCache) return this.resourceCache;
680
- let { config: t, identity: r, platform: a } = this.deps;
691
+ let { config: n, identity: r, platform: i } = this.deps;
681
692
  return this.resourceCache = {
682
- [p]: t.serviceName,
683
- [pe]: t.serviceVersion,
684
- [Te]: t.environment,
685
- [f]: xe,
686
- [m]: de,
687
- [u]: _e,
688
- [ee]: a.platform,
689
- [e]: r.sessionId,
690
- [fe]: r.tabId,
691
- [n]: r.contextId,
692
- [g]: a.userAgent,
693
- ...a.openfinUuid === void 0 ? {} : { [i]: a.openfinUuid },
694
- ...a.openfinName === void 0 ? {} : { [o]: a.openfinName }
693
+ [g]: n.serviceName,
694
+ [s]: n.serviceVersion,
695
+ [e]: n.environment,
696
+ [Ee]: he,
697
+ [t]: we,
698
+ [_]: ie,
699
+ [pe]: i.platform,
700
+ [l]: r.sessionId,
701
+ [u]: r.tabId,
702
+ [me]: r.contextId,
703
+ [h]: i.userAgent,
704
+ ...i.openfinUuid === void 0 ? {} : { [m]: i.openfinUuid },
705
+ ...i.openfinName === void 0 ? {} : { [f]: i.openfinName }
695
706
  }, this.resourceCache;
696
707
  }
697
- }, gt = {
698
- errors: async () => (await import("./errors-4MQyjZVj.js")).ErrorCapture,
699
- network: async () => (await import("./network-jQ2t8rU4.js")).NetworkCapture,
700
- interactions: async () => (await import("./interactions-BaCmoGLB.js")).InteractionCapture,
701
- webVitals: async () => (await import("./web-vitals-DHZ0yA_H.js")).WebVitalsCapture
702
- }, K = Symbol.for(h), q = Symbol.for(Ee), J = class e {
708
+ }, _t = {
709
+ errors: async () => (await import("./errors-Dnc-X4Ec.js")).ErrorCapture,
710
+ network: async () => (await import("./network-aSNbwpue.js")).NetworkCapture,
711
+ interactions: async () => (await import("./interactions-igKTAJvj.js")).InteractionCapture,
712
+ webVitals: async () => (await import("./web-vitals-DHZ0yA_H.js")).WebVitalsCapture,
713
+ longFrames: async () => (await import("./long-frames-6pnjWSSR.js")).LongFrameCapture,
714
+ console: async () => (await import("./console-CNljJict.js")).ConsoleCapture
715
+ }, q = Symbol.for(ee), J = Symbol.for(c), Y = class e {
703
716
  diagnostics;
704
717
  config;
705
718
  platform;
@@ -707,12 +720,13 @@ var ht = class {
707
720
  stores;
708
721
  identityBuiltAs;
709
722
  sessionTouch;
710
- context = new ct();
723
+ context = new lt();
711
724
  breadcrumbs;
712
725
  tracing;
713
- sequence = new qe();
726
+ sequence = new Je();
714
727
  journey;
715
728
  builder;
729
+ remote = { sampling: null };
716
730
  console;
717
731
  bus = null;
718
732
  busBuilt;
@@ -725,21 +739,24 @@ var ht = class {
725
739
  captureGeneration = 0;
726
740
  captureOnce = {
727
741
  webVitals: !1,
728
- navigationTiming: !1
742
+ navigationTiming: !1,
743
+ longFrames: !1
729
744
  };
730
745
  bootBuffer = [];
731
746
  forwardBuffer = [];
732
747
  forwardScheduled = !1;
733
748
  roleResolved = !1;
749
+ started = Promise.resolve();
734
750
  ready = !1;
735
751
  destroyed = !1;
736
752
  lastGapAt = 0;
737
753
  constructor(e) {
738
- this.diagnostics = new lt(e.onDiagnostic), this.platform = Le(this.diagnostics), this.config = H(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Ie() : A, this.identity = Oe(this.diagnostics, this.stores), this.sessionTouch = new Ne(this.diagnostics, this.stores), this.breadcrumbs = new et(50), this.tracing = new $e(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new Ke(this.config.console, this.diagnostics), this.journey = new mt(ut, this.diagnostics, this.identity.contextId, (e) => {
754
+ this.diagnostics = new ut(e.onDiagnostic), this.platform = Re(this.diagnostics), this.config = U(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Oe() : M, this.identity = ke(this.diagnostics, this.stores), this.sessionTouch = new Ne(this.diagnostics, this.stores), this.breadcrumbs = new tt(50), this.tracing = new et(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new qe(this.config.console, this.diagnostics), this.journey = new ht(dt, this.diagnostics, this.identity.contextId, (e) => {
739
755
  this.bus?.broadcastJourney(e);
740
- }, this.stores), this.builder = new ht({
756
+ }, this.stores), this.builder = new gt({
757
+ remote: this.remote,
741
758
  config: this.config,
742
- limits: b,
759
+ limits: r,
743
760
  diagnostics: this.diagnostics,
744
761
  context: this.context,
745
762
  journey: this.journey,
@@ -757,10 +774,10 @@ var ht = class {
757
774
  });
758
775
  };
759
776
  static current() {
760
- return globalThis[K] ?? null;
777
+ return globalThis[q] ?? null;
761
778
  }
762
779
  static stopped() {
763
- return globalThis[q] ?? null;
780
+ return globalThis[J] ?? null;
764
781
  }
765
782
  isDestroyed() {
766
783
  return this.destroyed;
@@ -769,21 +786,23 @@ var ht = class {
769
786
  let n = e.current();
770
787
  if (n && !n.destroyed) return n.reconfigure(t), n;
771
788
  let r = new e(t);
772
- return globalThis[K] = r, Reflect.deleteProperty(globalThis, q), r.init(), r;
789
+ return globalThis[q] = r, Reflect.deleteProperty(globalThis, J), r.init(), r;
773
790
  }
774
791
  reconfigure(e) {
775
- let t = this.keepEndpoint(e);
776
- st(this.config, H(t, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
792
+ let t = this.keepDestination(e);
793
+ ct(this.config, U(t, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
777
794
  }
778
795
  keepBuiltStorage() {
779
796
  let e = this.storageBuiltAs;
780
797
  e !== void 0 && this.config.storage !== e && (this.diagnostics.report("config.invalid", `storage cannot change after startup. It stays ${e}.`, { requested: this.config.storage }), this.config.storage = e);
781
798
  }
782
- keepEndpoint(e) {
783
- return this.senderLoad === void 0 || e.endpoint !== null && e.endpoint !== "" ? e : (this.diagnostics.report("config.invalid", "You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays."), {
784
- ...e,
799
+ keepDestination(e) {
800
+ if (this.senderLoad === void 0) return e;
801
+ let t = e;
802
+ return "transport" in e && e.transport === void 0 != (this.config.transport === void 0) && (this.diagnostics.report("config.invalid", "You cannot add or remove transport after the delivery stack loads. The transport in force stays."), t = { ...t }, delete t.transport), (t.endpoint === null || t.endpoint === "") && this.config.transport === void 0 && (this.diagnostics.report("config.invalid", "You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays."), t = {
803
+ ...t,
785
804
  endpoint: void 0
786
- });
805
+ }), t;
787
806
  }
788
807
  keepBuiltIdentity() {
789
808
  let e = this.identityBuiltAs;
@@ -791,6 +810,9 @@ var ht = class {
791
810
  }
792
811
  async init() {
793
812
  let e = this.installCaptures();
813
+ this.started = this.boot(), await this.started, await e;
814
+ }
815
+ async boot() {
794
816
  try {
795
817
  let e = this.journey.bootstrap();
796
818
  this.config.bus.mode !== "off" && await this.ensureBus(), this.roleResolved = !0, await this.syncSender(), await e;
@@ -799,7 +821,6 @@ var ht = class {
799
821
  } finally {
800
822
  this.ready = !0, this.releaseBootBuffer();
801
823
  }
802
- await e;
803
824
  }
804
825
  ensureBus() {
805
826
  return this.busLoad ??= this.startBus(), this.busLoad;
@@ -818,7 +839,7 @@ var ht = class {
818
839
  }
819
840
  async buildBus() {
820
841
  try {
821
- let { Bus: e } = await import("./bus-DfAbg_pg.js");
842
+ let { Bus: e } = await import("./bus-DPDrlUBY.js");
822
843
  if (this.destroyed) return null;
823
844
  let t = new e(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
824
845
  onRecords: (e) => {
@@ -830,7 +851,8 @@ var ht = class {
830
851
  onJourneyRequest: () => this.journey.current(),
831
852
  onTabConflict: () => {
832
853
  this.regenerateTabId();
833
- }
854
+ },
855
+ remote: this.remote
834
856
  });
835
857
  return this.bus = t, t;
836
858
  } catch (e) {
@@ -841,7 +863,7 @@ var ht = class {
841
863
  return this.bus?.getRole() ?? "sender";
842
864
  }
843
865
  syncSender() {
844
- return !this.config.endpoint || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
866
+ return !(this.config.endpoint || this.config.transport !== void 0) || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
845
867
  }
846
868
  loadSender() {
847
869
  return this.senderLoad ??= this.buildSender(), this.senderLoad;
@@ -849,10 +871,11 @@ var ht = class {
849
871
  async buildSender() {
850
872
  this.storageBuiltAs = this.config.storage;
851
873
  try {
852
- let { Sender: e } = await import("./sender-BIob8eZz.js"), t = this.destroyed ? null : await e.create({
874
+ let { Sender: e } = await import("./sender-G6v4Uqi4.js"), t = this.destroyed ? null : await e.create({
853
875
  config: this.config,
854
876
  diagnostics: this.diagnostics,
855
- onGap: this.reportGap
877
+ onGap: this.reportGap,
878
+ remote: this.remote
856
879
  });
857
880
  if (!t || this.destroyed) {
858
881
  await t?.destroy();
@@ -867,8 +890,8 @@ var ht = class {
867
890
  for (let t of e) this.sender?.push(t);
868
891
  }
869
892
  async installCaptures() {
870
- let e = ++this.captureGeneration, n = this.config.capture, r = [];
871
- (n.errors || n.rejections || n.resourceErrors) && r.push("errors"), (n.fetch || n.xhr) && r.push("network"), (n.interactions || n.navigation) && r.push("interactions"), n.webVitals && r.push("webVitals");
893
+ let e = ++this.captureGeneration, t = this.config.capture, r = [];
894
+ (t.errors || t.rejections || t.resourceErrors) && r.push("errors"), (t.fetch || t.xhr) && r.push("network"), (t.interactions || t.navigation) && r.push("interactions"), t.webVitals && r.push("webVitals"), t.longFrames && r.push("longFrames"), (Array.isArray(t.console) ? t.console.length > 0 : t.console) && r.push("console");
872
895
  let i = await Promise.all(r.map((e) => this.loadCapture(e)));
873
896
  if (e !== this.captureGeneration || this.destroyed) return;
874
897
  this.uninstallCaptures();
@@ -877,7 +900,7 @@ var ht = class {
877
900
  diagnostics: this.diagnostics,
878
901
  breadcrumbs: this.breadcrumbs,
879
902
  tracing: this.tracing,
880
- logger: new R(() => this, t),
903
+ logger: new z(() => this, n),
881
904
  once: this.captureOnce
882
905
  };
883
906
  for (let e of i) e && this.captures.push(new e(a));
@@ -892,7 +915,7 @@ var ht = class {
892
915
  this.captures.length = 0;
893
916
  }
894
917
  loadCapture(e) {
895
- return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, gt[e]);
918
+ return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, _t[e]);
896
919
  }
897
920
  registerWorker(e) {
898
921
  this.destroyed || this.constructBus().then((t) => {
@@ -905,7 +928,7 @@ var ht = class {
905
928
  if (this.destroyed) return;
906
929
  this.destroyed = !0, this.uninstallCaptures();
907
930
  let t = this.sender?.destroy();
908
- this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.current() === this && (Reflect.deleteProperty(globalThis, K), globalThis[q] = this);
931
+ this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.current() === this && (Reflect.deleteProperty(globalThis, q), globalThis[J] = this);
909
932
  }
910
933
  emit(e) {
911
934
  e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.pushCapped(this.bootBuffer, e));
@@ -928,7 +951,7 @@ var ht = class {
928
951
  }
929
952
  ingestForwarded(e) {
930
953
  if (!Array.isArray(e)) this.diagnostics.count("record.dropped_malformed");
931
- else for (let t of e) M(t) ? Me(t, this.config) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
954
+ else for (let t of e) N(t) ? je(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
932
955
  }
933
956
  releaseBootBuffer() {
934
957
  let e = this.bootBuffer;
@@ -938,7 +961,7 @@ var ht = class {
938
961
  }
939
962
  reportGap = (e) => {
940
963
  let t = Date.now();
941
- t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new R(() => this, te).warn("stored records were dropped before delivery", {
964
+ t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new z(() => this, Ce).warn("stored records were dropped before delivery", {
942
965
  "gap.batches": e.batches,
943
966
  "gap.records": e.records,
944
967
  "gap.reason": e.reason
@@ -949,108 +972,130 @@ var ht = class {
949
972
  this.diagnostics.report("bus.role_resolved", "Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.", {
950
973
  was: this.identity.tabId,
951
974
  now: e
952
- }), this.identity.tabId = e, je(e, this.diagnostics, this.stores), this.builder.invalidateResource();
975
+ }), this.identity.tabId = e, Pe(e, this.diagnostics, this.stores), this.builder.invalidateResource();
953
976
  }
954
977
  async queueDepth() {
955
978
  return await this.senderLoad, await this.sender?.queueDepth() ?? 0;
956
979
  }
957
980
  async flush() {
958
- if (this.role() === "forwarder") {
981
+ if (this.ready || await this.started, this.role() === "forwarder") {
959
982
  let e = this.forwardBuffer;
960
983
  this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
961
984
  } else await this.senderLoad, await this.sender?.flush();
962
985
  }
963
- }, Y = /* @__PURE__ */ new Map();
964
- function X() {
965
- return (J.current() ?? J.stopped()) || J.configure({});
966
- }
967
- function _t(e) {
968
- J.configure(e);
986
+ };
987
+ //#endregion
988
+ //#region src/transport/memory-transport.ts
989
+ function vt() {
990
+ let e = [], t = [], n = { status: 200 };
991
+ return {
992
+ transport: (r) => (e.push(r), n.status >= 200 && n.status < 300 && t.push(r), Promise.resolve({ ...n })),
993
+ records: () => t.flatMap((e) => [...e.records]),
994
+ batches: () => [...e],
995
+ clear: () => {
996
+ e.length = 0, t.length = 0;
997
+ },
998
+ respondWith: (e, t) => {
999
+ n = t === void 0 ? { status: e } : {
1000
+ status: e,
1001
+ retryAfterMs: t
1002
+ };
1003
+ }
1004
+ };
969
1005
  }
970
- function Z(e, t) {
971
- if (t) return new R(X, e, t);
972
- let n = Y.get(e);
973
- return n || (n = new R(X, e), Y.set(e, n)), n;
1006
+ //#endregion
1007
+ //#region src/index.ts
1008
+ var X = /* @__PURE__ */ new Map();
1009
+ function Z() {
1010
+ return (Y.current() ?? Y.stopped()) || Y.configure({});
974
1011
  }
975
- function Q() {
976
- return Z("app");
1012
+ function yt(e) {
1013
+ Y.configure(e);
977
1014
  }
978
- function vt(e, t) {
979
- Q().trace(e, t);
1015
+ function Q(e, t) {
1016
+ if (t) return new z(Z, e, t);
1017
+ let n = X.get(e);
1018
+ return n || (n = new z(Z, e), X.set(e, n)), n;
980
1019
  }
981
- function yt(e, t) {
982
- Q().debug(e, t);
1020
+ function $() {
1021
+ return Q("app");
983
1022
  }
984
1023
  function bt(e, t) {
985
- Q().info(e, t);
1024
+ $().trace(e, t);
986
1025
  }
987
1026
  function xt(e, t) {
988
- Q().warn(e, t);
1027
+ $().debug(e, t);
989
1028
  }
990
- function St(e, t, n) {
991
- Q().error(e, t, n);
1029
+ function St(e, t) {
1030
+ $().info(e, t);
992
1031
  }
993
1032
  function Ct(e, t) {
994
- Q().logAction(e, t);
1033
+ $().warn(e, t);
995
1034
  }
996
- function wt(e, t) {
997
- Q().logEvent(e, t);
1035
+ function wt(e, t, n) {
1036
+ $().error(e, t, n);
998
1037
  }
999
- function Tt(e, t, n, r, i) {
1000
- Q().logMetric(e, t, n, r, i);
1038
+ function Tt(e, t) {
1039
+ $().logAction(e, t);
1001
1040
  }
1002
- function Et(e, t, n) {
1003
- return Q().timeSync(e, t, n);
1041
+ function Et(e, t) {
1042
+ $().logEvent(e, t);
1004
1043
  }
1005
- function $(e, t, n) {
1006
- return Q().timeAsync(e, t, n);
1044
+ function Dt(e, t, n, r, i) {
1045
+ $().logMetric(e, t, n, r, i);
1007
1046
  }
1008
- function Dt(e, t) {
1009
- X().context.set(e, t);
1047
+ function Ot(e, t, n) {
1048
+ return $().timeSync(e, t, n);
1010
1049
  }
1011
- function Ot(e) {
1012
- X().context.setMany(e);
1013
- }
1014
- function kt(e) {
1015
- X().context.remove(e);
1050
+ function kt(e, t, n) {
1051
+ return $().timeAsync(e, t, n);
1016
1052
  }
1017
1053
  function At(e, t) {
1018
- return X().journey.start(e, t);
1054
+ Z().context.set(e, t);
1019
1055
  }
1020
- function jt() {
1021
- X().journey.end();
1056
+ function jt(e) {
1057
+ Z().context.setMany(e);
1022
1058
  }
1023
- function Mt() {
1024
- return X().journey.current();
1059
+ function Mt(e) {
1060
+ Z().context.remove(e);
1025
1061
  }
1026
- function Nt() {
1027
- return X().journey.getToken();
1062
+ function Nt(e, t) {
1063
+ return Z().journey.start(e, t);
1028
1064
  }
1029
- function Pt(e) {
1030
- return X().journey.adopt(e, "manual", !0);
1065
+ function Pt() {
1066
+ Z().journey.end();
1031
1067
  }
1032
- function Ft(e) {
1033
- X().registerWorker(e);
1068
+ function Ft() {
1069
+ return Z().journey.current();
1034
1070
  }
1035
1071
  function It() {
1036
- X().tracing.rotate("explicit");
1072
+ return Z().journey.getToken();
1037
1073
  }
1038
- function Lt() {
1039
- return X().tracing.headers();
1074
+ function Lt(e) {
1075
+ return Z().journey.adopt(e, "manual", !0);
1040
1076
  }
1041
- function Rt() {
1042
- return X().flush();
1077
+ function Rt(e) {
1078
+ Z().registerWorker(e);
1043
1079
  }
1044
1080
  function zt() {
1045
- return X().queueDepth();
1081
+ Z().tracing.rotate("explicit");
1046
1082
  }
1047
1083
  function Bt() {
1048
- return X().diagnostics.snapshot();
1084
+ return Z().tracing.headers();
1085
+ }
1086
+ function Vt() {
1087
+ return Z().flush();
1088
+ }
1089
+ function Ht() {
1090
+ return Z().queueDepth();
1091
+ }
1092
+ function Ut() {
1093
+ return Z().diagnostics.snapshot();
1049
1094
  }
1050
- async function Vt() {
1051
- await J.current()?.destroy();
1095
+ async function Wt() {
1096
+ await Y.current()?.destroy();
1052
1097
  }
1053
1098
  //#endregion
1054
- export { R as OneLogger, Pt as adoptJourney, _t as configure, Mt as currentJourney, yt as debug, jt as endJourney, St as error, Rt as flush, Bt as getDiagnosticCounters, Nt as getJourneyToken, Z as getLogger, zt as getQueueDepth, Lt as getTraceHeaders, bt as info, Ct as logAction, wt as logEvent, Tt as logMetric, Ft as registerWorker, kt as removeContext, Dt as setContext, Ot as setContextMap, Vt as shutdown, At as startJourney, It as startTrace, $ as timeAsync, Et as timeSync, vt as trace, xt as warn };
1099
+ export { z as OneLogger, Lt as adoptJourney, yt as configure, vt as createMemoryTransport, Ft as currentJourney, xt as debug, Pt as endJourney, wt as error, Vt as flush, Ut as getDiagnosticCounters, It as getJourneyToken, Q as getLogger, Ht as getQueueDepth, Bt as getTraceHeaders, St as info, Tt as logAction, Et as logEvent, Dt as logMetric, Rt as registerWorker, Mt as removeContext, At as setContext, jt as setContextMap, Wt as shutdown, Nt as startJourney, zt as startTrace, kt as timeAsync, Ot as timeSync, bt as trace, Ct as warn };
1055
1100
 
1056
1101
  //# sourceMappingURL=index.js.map