@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.
Files changed (118) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +56 -36
  3. package/dist/batch-DEK4bv9N.js +31 -0
  4. package/dist/batch-DEK4bv9N.js.map +1 -0
  5. package/dist/batch-DEVFs28i.cjs +2 -0
  6. package/dist/batch-DEVFs28i.cjs.map +1 -0
  7. package/dist/{bus-CtJWf9QN.cjs → bus-DNFvTkif.cjs} +2 -2
  8. package/dist/{bus-CtJWf9QN.cjs.map → bus-DNFvTkif.cjs.map} +1 -1
  9. package/dist/{bus-D8kH58tb.js → bus-HVQ8E72V.js} +8 -8
  10. package/dist/{bus-D8kH58tb.js.map → bus-HVQ8E72V.js.map} +1 -1
  11. package/dist/{console-DjLbryED.js → console-C9Y639mn.js} +3 -3
  12. package/dist/{console-DjLbryED.js.map → console-C9Y639mn.js.map} +1 -1
  13. package/dist/{console-BpHfWstv.cjs → console-DssDxq1B.cjs} +2 -2
  14. package/dist/{console-BpHfWstv.cjs.map → console-DssDxq1B.cjs.map} +1 -1
  15. package/dist/constants-N99w84xy.js +117 -0
  16. package/dist/constants-N99w84xy.js.map +1 -0
  17. package/dist/constants-X86IDwkC.cjs +2 -0
  18. package/dist/constants-X86IDwkC.cjs.map +1 -0
  19. package/dist/constants.d.ts +18 -11
  20. package/dist/core/drops.d.ts +29 -0
  21. package/dist/core/hold-buffer.d.ts +27 -0
  22. package/dist/core/pipeline.d.ts +2 -7
  23. package/dist/core/runtime.d.ts +44 -8
  24. package/dist/core/sender.d.ts +4 -1
  25. package/dist/deadline-5_PecIl5.js +26 -0
  26. package/dist/deadline-5_PecIl5.js.map +1 -0
  27. package/dist/deadline-XSnm95pg.cjs +2 -0
  28. package/dist/deadline-XSnm95pg.cjs.map +1 -0
  29. package/dist/{errors-CpGRhhIf.cjs → errors-BTWuVnHZ.cjs} +2 -2
  30. package/dist/{errors-CpGRhhIf.cjs.map → errors-BTWuVnHZ.cjs.map} +1 -1
  31. package/dist/{errors-DH4QJS0u.js → errors-CQusIGWJ.js} +4 -4
  32. package/dist/{errors-DH4QJS0u.js.map → errors-CQusIGWJ.js.map} +1 -1
  33. package/dist/{deadline-Cbg2cbUw.cjs → identity-B1GDS1Tb.cjs} +2 -2
  34. package/dist/identity-B1GDS1Tb.cjs.map +1 -0
  35. package/dist/{deadline-B5DINjD5.js → identity-D4DPjTM9.js} +3 -26
  36. package/dist/identity-D4DPjTM9.js.map +1 -0
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.js +467 -318
  41. package/dist/index.js.map +1 -1
  42. package/dist/{indexeddb-storage-n1qkFBGA.js → indexeddb-storage-B8SGUzSV.js} +79 -50
  43. package/dist/indexeddb-storage-B8SGUzSV.js.map +1 -0
  44. package/dist/indexeddb-storage-ukzC82dm.cjs +2 -0
  45. package/dist/indexeddb-storage-ukzC82dm.cjs.map +1 -0
  46. package/dist/{interactions-31eHGwEQ.cjs → interactions-CcxrVzpg.cjs} +2 -2
  47. package/dist/{interactions-31eHGwEQ.cjs.map → interactions-CcxrVzpg.cjs.map} +1 -1
  48. package/dist/{interactions-OU94MPXs.js → interactions-CnjfQgw3.js} +2 -2
  49. package/dist/{interactions-OU94MPXs.js.map → interactions-CnjfQgw3.js.map} +1 -1
  50. package/dist/{journey-CeJ1QoT2.js → journey-DjvDzHyp.js} +17 -16
  51. package/dist/{journey-CeJ1QoT2.js.map → journey-DjvDzHyp.js.map} +1 -1
  52. package/dist/journey-DxlfdFJV.cjs +2 -0
  53. package/dist/journey-DxlfdFJV.cjs.map +1 -0
  54. package/dist/{library-request-C9uJFlbq.cjs → library-request-BZ1ekVtl.cjs} +2 -2
  55. package/dist/{library-request-C9uJFlbq.cjs.map → library-request-BZ1ekVtl.cjs.map} +1 -1
  56. package/dist/{library-request-DvhuplAB.js → library-request-C8kc5YWv.js} +2 -2
  57. package/dist/{library-request-DvhuplAB.js.map → library-request-C8kc5YWv.js.map} +1 -1
  58. package/dist/{long-frames-B8VdA_ny.cjs → long-frames-BGik_Yhy.cjs} +2 -2
  59. package/dist/{long-frames-B8VdA_ny.cjs.map → long-frames-BGik_Yhy.cjs.map} +1 -1
  60. package/dist/{long-frames-C_7OutLs.js → long-frames-CZk3XOkH.js} +3 -3
  61. package/dist/{long-frames-C_7OutLs.js.map → long-frames-CZk3XOkH.js.map} +1 -1
  62. package/dist/models/batch.d.ts +14 -0
  63. package/dist/models/config.d.ts +146 -0
  64. package/dist/models/drop.d.ts +39 -0
  65. package/dist/models/storage.d.ts +15 -3
  66. package/dist/{network-D_lloS5t.js → network-51iicpLl.js} +19 -19
  67. package/dist/{network-D_lloS5t.js.map → network-51iicpLl.js.map} +1 -1
  68. package/dist/{network-BAV7ipyn.cjs → network-jBbjyAJP.cjs} +2 -2
  69. package/dist/{network-BAV7ipyn.cjs.map → network-jBbjyAJP.cjs.map} +1 -1
  70. package/dist/{platform-IHBZGqUe.js → platform-Cjts-8k8.js} +2 -2
  71. package/dist/{platform-IHBZGqUe.js.map → platform-Cjts-8k8.js.map} +1 -1
  72. package/dist/{platform-D4wu1eIF.cjs → platform-DW3GFIUE.cjs} +2 -2
  73. package/dist/{platform-D4wu1eIF.cjs.map → platform-DW3GFIUE.cjs.map} +1 -1
  74. package/dist/{remote-rules-kuDf5gbe.cjs → remote-rules-ByS34k4e.cjs} +2 -2
  75. package/dist/{remote-rules-kuDf5gbe.cjs.map → remote-rules-ByS34k4e.cjs.map} +1 -1
  76. package/dist/{remote-rules-Bt1XsdEQ.js → remote-rules-M-XZ1xbe.js} +2 -2
  77. package/dist/{remote-rules-Bt1XsdEQ.js.map → remote-rules-M-XZ1xbe.js.map} +1 -1
  78. package/dist/{sampling-o0VY1mqQ.js → sampling-BN3Oi6SV.js} +9 -9
  79. package/dist/{sampling-o0VY1mqQ.js.map → sampling-BN3Oi6SV.js.map} +1 -1
  80. package/dist/{sampling-BI15ds9D.cjs → sampling-b2ck5X98.cjs} +2 -2
  81. package/dist/{sampling-BI15ds9D.cjs.map → sampling-b2ck5X98.cjs.map} +1 -1
  82. package/dist/{sanitize-DSIP7amZ.cjs → sanitize-DKp5MRsa.cjs} +2 -2
  83. package/dist/{sanitize-DSIP7amZ.cjs.map → sanitize-DKp5MRsa.cjs.map} +1 -1
  84. package/dist/{sanitize-B9UheVKc.js → sanitize-Dwj9JCkI.js} +2 -2
  85. package/dist/{sanitize-B9UheVKc.js.map → sanitize-Dwj9JCkI.js.map} +1 -1
  86. package/dist/{sender-BnNj9bOX.js → sender-BBY0IcUo.js} +328 -269
  87. package/dist/sender-BBY0IcUo.js.map +1 -0
  88. package/dist/sender-BXoAZKum.cjs +3 -0
  89. package/dist/sender-BXoAZKum.cjs.map +1 -0
  90. package/dist/storage/emergency-queue.d.ts +4 -1
  91. package/dist/storage/eviction.d.ts +40 -0
  92. package/dist/storage/idb-driver.d.ts +6 -0
  93. package/dist/storage/indexeddb-storage.d.ts +13 -5
  94. package/dist/storage/local-storage.d.ts +24 -1
  95. package/dist/storage/memory-storage.d.ts +7 -0
  96. package/dist/{storm-Y-yuBhvv.cjs → storm-CKuaBp7i.cjs} +2 -2
  97. package/dist/{storm-Y-yuBhvv.cjs.map → storm-CKuaBp7i.cjs.map} +1 -1
  98. package/dist/{storm-BTw0J6eE.js → storm-DhtL2eVr.js} +2 -2
  99. package/dist/{storm-BTw0J6eE.js.map → storm-DhtL2eVr.js.map} +1 -1
  100. package/dist/transport/exit-flush.d.ts +6 -0
  101. package/dist/transport/retry-engine.d.ts +7 -3
  102. package/dist/transport/status-transport.d.ts +4 -1
  103. package/dist/utils/console.d.ts +4 -1
  104. package/package.json +1 -1
  105. package/dist/constants-Br3b89Wg.cjs +0 -2
  106. package/dist/constants-Br3b89Wg.cjs.map +0 -1
  107. package/dist/constants-DM94FjVX.js +0 -96
  108. package/dist/constants-DM94FjVX.js.map +0 -1
  109. package/dist/deadline-B5DINjD5.js.map +0 -1
  110. package/dist/deadline-Cbg2cbUw.cjs.map +0 -1
  111. package/dist/indexeddb-storage-DNdf1fmL.cjs +0 -2
  112. package/dist/indexeddb-storage-DNdf1fmL.cjs.map +0 -1
  113. package/dist/indexeddb-storage-n1qkFBGA.js.map +0 -1
  114. package/dist/journey-CE2EcwHW.cjs +0 -2
  115. package/dist/journey-CE2EcwHW.cjs.map +0 -1
  116. package/dist/sender-BnNj9bOX.js.map +0 -1
  117. package/dist/sender-D0OsyB1c.cjs +0 -3
  118. package/dist/sender-D0OsyB1c.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,52 +1,54 @@
1
- import { Bt as e, D as t, Et as n, F as r, Ft as i, Ht as a, It as o, Jt as s, L as c, Lt as l, Mt as u, N as d, Nt as f, O as p, P as m, Pt as h, Rt as g, T as _, Ut as ee, Vt as te, Xt as v, _n as ne, a as y, c as b, ct as x, d as S, dn as re, en as C, f as ie, fn as ae, hn as oe, i as se, in as ce, jt as le, k as ue, l as de, mn as fe, n as pe, o as me, p as he, pn as w, qt as ge, r as _e, s as ve, st as ye, u as T, ut as be, vn as xe, yn as E, zt as Se } from "./constants-DM94FjVX.js";
2
- import { n as Ce, r as D, t as we } from "./error-like-Ywo5uRHo.js";
3
- import { a as O, i as Te, n as Ee, o as De, r as Oe } from "./sampling-o0VY1mqQ.js";
4
- import { a as ke, i as Ae, n as je, o as k, r as A } from "./sanitize-B9UheVKc.js";
5
- import { a as Me, c as Ne, i as Pe, l as Fe, o as Ie, s as Le, u as Re } from "./deadline-B5DINjD5.js";
6
- import { n as ze, r as Be, t as Ve } from "./platform-IHBZGqUe.js";
7
- import { n as He, t as Ue } from "./journey-CeJ1QoT2.js";
1
+ import { A as e, Bt as t, E as n, Et as r, F as i, Ft as a, Ht as o, I as s, It as c, Jt as l, Lt as u, Mt as d, Nt as f, O as p, P as m, Pt as h, R as g, Rt as _, Ut as ee, Vt as te, Xt as v, _n as ne, a as y, c as re, ct as ie, d as b, dn as ae, dt as oe, en as x, f as se, fn as S, gn as ce, i as le, jt as ue, k as de, l as fe, lt as C, mn as pe, n as me, o as he, p as ge, pn as _e, qt as ve, r as ye, rn as be, s as w, u as T, un as xe, vn as E, x as Se, zt as Ce } from "./constants-N99w84xy.js";
2
+ import { n as we, r as Te, t as Ee } from "./error-like-Ywo5uRHo.js";
3
+ import { a as D, i as De, n as Oe, o as ke, r as Ae } from "./sampling-BN3Oi6SV.js";
4
+ import { a as je, i as Me, n as Ne, o as O, r as k } from "./sanitize-Dwj9JCkI.js";
5
+ import { a as Pe, i as Fe, n as Ie, o as A, r as Le, s as Re, t as ze } from "./identity-D4DPjTM9.js";
6
+ import { n as Be, r as Ve, t as He } from "./platform-Cjts-8k8.js";
7
+ import { n as j, t as Ue } from "./batch-DEK4bv9N.js";
8
+ import { n as We } from "./library-request-C8kc5YWv.js";
9
+ import { n as Ge, t as Ke } from "./journey-DjvDzHyp.js";
8
10
  //#region src/utils/timer.ts
9
- function j(e) {
10
- return Math.round((performance.now() - e) * c) / c;
11
+ function M(e) {
12
+ return Math.round((performance.now() - e) * g) / g;
11
13
  }
12
- function M(e, t, n, r, i) {
14
+ function N(e, t, n, r, i) {
13
15
  e.logMetric(`${t}.duration`, n, "ms", "histogram", {
14
16
  status: r,
15
17
  ...i
16
18
  });
17
19
  }
18
- function N(e, t, n, r, i) {
19
- let a = j(n);
20
+ function qe(e, t, n, r, i) {
21
+ let a = M(n);
20
22
  e.error(`${t} failed`, r, {
21
23
  "action.duration_ms": a,
22
24
  status: "FAILURE",
23
25
  ...i
24
- }), M(e, t, a, "FAILURE", i);
26
+ }), N(e, t, a, "FAILURE", i);
25
27
  }
26
- function We(e, t, n, r) {
28
+ function Je(e, t, n, r) {
27
29
  let i = performance.now();
28
30
  try {
29
31
  let a = n();
30
- return M(e, t, j(i), "SUCCESS", r), a;
32
+ return N(e, t, M(i), "SUCCESS", r), a;
31
33
  } catch (n) {
32
- throw N(e, t, i, n, r), n;
34
+ throw qe(e, t, i, n, r), n;
33
35
  }
34
36
  }
35
- async function Ge(e, t, n, r) {
37
+ async function Ye(e, t, n, r) {
36
38
  let i = performance.now();
37
39
  try {
38
40
  let a = await n();
39
- return M(e, t, j(i), "SUCCESS", r), a;
41
+ return N(e, t, M(i), "SUCCESS", r), a;
40
42
  } catch (n) {
41
- throw N(e, t, i, n, r), n;
43
+ throw qe(e, t, i, n, r), n;
42
44
  }
43
45
  }
44
46
  //#endregion
45
47
  //#region src/core/logger.ts
46
- var Ke = [_, ce];
47
- function qe(e, t) {
48
+ var Xe = [n, be];
49
+ function Ze(e, t) {
48
50
  let n = t.guard("record.sanitize_failed", "The library could not read the error reason.", () => {
49
- if (!(e instanceof Error) && !D(e)) return;
51
+ if (!(e instanceof Error) && !Te(e)) return;
50
52
  let t = Error(e.message);
51
53
  return t.name = e.name, t.stack = e.stack, t;
52
54
  });
@@ -54,27 +56,27 @@ function qe(e, t) {
54
56
  let r = t.guard("record.sanitize_failed", "The library could not convert the error reason to text.", () => String(e));
55
57
  return Error(r ?? typeof e);
56
58
  }
57
- function Je(e, t, n) {
59
+ function Qe(e, t, n) {
58
60
  return n.guard("record.sanitize_failed", "The library could not read the error reason.", () => e instanceof Error ? e : t) ?? t;
59
61
  }
60
- function Ye(e, t) {
62
+ function $e(e, t) {
61
63
  if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" || typeof e == "symbol") return e;
62
64
  if (typeof e == "object" && e) return t.guard("record.sanitize_failed", "The library could not read the properties of the error reason.", () => {
63
- let t = e, n = D(e), r = {}, i = 0;
65
+ let t = e, n = Te(e), r = {}, i = 0;
64
66
  for (let e of Object.keys(t)) {
65
67
  let a = t[e];
66
- (!n || !we.has(e)) && Ce(a) && (r[e] = a, i++);
68
+ (!n || !Ee.has(e)) && we(a) && (r[e] = a, i++);
67
69
  }
68
70
  return i === 0 ? void 0 : r;
69
71
  });
70
72
  }
71
- function Xe(e) {
73
+ function et(e) {
72
74
  if (typeof e != "object" || !e || Array.isArray(e) || e instanceof Error) return !1;
73
75
  let t = Object.getPrototypeOf(e);
74
76
  return t === null || Object.getPrototypeOf(t) === null;
75
77
  }
76
- function Ze(e) {
77
- return Ke.some((t) => e === t || e.startsWith(`${t}.`)) ? "system" : "log";
78
+ function tt(e) {
79
+ return Xe.some((t) => e === t || e.startsWith(`${t}.`)) ? "system" : "log";
78
80
  }
79
81
  function P(e, t) {
80
82
  return e === void 0 ? {} : t.guard("record.sanitize_failed", "The library could not read the payload.", () => ({ ...e })) ?? { "uiobs.sanitize_failed": !0 };
@@ -85,7 +87,7 @@ var F = class e {
85
87
  options;
86
88
  levelType;
87
89
  constructor(e, t, n = {}) {
88
- this.bind = e, this.namespace = t, this.options = n, this.levelType = Ze(t);
90
+ this.bind = e, this.namespace = t, this.options = n, this.levelType = tt(t);
89
91
  }
90
92
  child(t, n = {}) {
91
93
  return new e(this.bind, `${this.namespace}.${t}`, { scopedContext: {
@@ -117,22 +119,22 @@ var F = class e {
117
119
  logEvent = (e, t) => {
118
120
  this.write("INFO", "event", e, t);
119
121
  };
120
- logMetric = (e, t, n = m, r = "gauge", i) => {
122
+ logMetric = (e, t, n = i, r = "gauge", a) => {
121
123
  if (!Number.isFinite(t)) {
122
124
  this.bind().diagnostics.report("record.dropped_malformed", "The metric value is not a finite number. The library dropped the metric.", { "metric.name": e });
123
125
  return;
124
126
  }
125
- let a = {
126
- ...P(i, this.bind().diagnostics),
127
+ let o = {
128
+ ...P(a, this.bind().diagnostics),
127
129
  "metric.name": e,
128
130
  "metric.value": t,
129
131
  "metric.unit": n,
130
132
  "metric.type": r
131
133
  };
132
- this.write("INFO", "metric", e, a, !0);
134
+ this.write("INFO", "metric", e, o, !0);
133
135
  };
134
- timeSync = (e, t, n) => We(this, e, t, n);
135
- timeAsync = (e, t, n) => Ge(this, e, t, n);
136
+ timeSync = (e, t, n) => Je(this, e, t, n);
137
+ timeAsync = (e, t, n) => Ye(this, e, t, n);
136
138
  write(e, t, n, r, i = !1) {
137
139
  let a = this.bind();
138
140
  if (a.isDestroyed()) return;
@@ -159,12 +161,12 @@ var F = class e {
159
161
  if (i.isDestroyed()) return;
160
162
  let a = i.builder.isEnabled(e);
161
163
  if (!a && !this.mirrors(i, e)) return;
162
- let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () => Xe(n)) ?? !1), s = o ? n : r, c = o ? void 0 : n, l = c === void 0 ? void 0 : qe(c, i.diagnostics), u = l === void 0 ? void 0 : Je(c, l, i.diagnostics);
164
+ let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () => et(n)) ?? !1), s = o ? n : r, c = o ? void 0 : n, l = c === void 0 ? void 0 : Ze(c, i.diagnostics), u = l === void 0 ? void 0 : Qe(c, l, i.diagnostics);
163
165
  if (!a) {
164
166
  this.print(i, e, t, s, u, null);
165
167
  return;
166
168
  }
167
- let d = l ? Ye(c, i.diagnostics) : void 0, { record: f, dropped: p } = i.builder.build({
169
+ let d = l ? $e(c, i.diagnostics) : void 0, { record: f, dropped: p } = i.builder.build({
168
170
  level: e,
169
171
  type: this.levelType,
170
172
  body: t,
@@ -177,7 +179,7 @@ var F = class e {
177
179
  "error.message": l.message,
178
180
  "error.stack_trace": l.stack
179
181
  } : {},
180
- ...d === void 0 ? {} : { [me]: d },
182
+ ...d === void 0 ? {} : { [he]: d },
181
183
  [y]: i.breadcrumbs.snapshot()
182
184
  }
183
185
  });
@@ -189,72 +191,73 @@ var F = class e {
189
191
  mirrors(e, t) {
190
192
  return e.config.enabled && e.console.accepts(t);
191
193
  }
192
- }, Qe = {
194
+ }, nt = {
193
195
  TRACE: "debug",
194
196
  DEBUG: "debug",
195
197
  INFO: "info",
196
198
  WARN: "warn",
197
199
  ERROR: "error",
198
200
  FATAL: "error"
199
- }, $e = class {
201
+ }, rt = class {
200
202
  settings;
201
203
  diagnostics;
202
- constructor(e, t) {
203
- this.settings = e, this.diagnostics = t;
204
+ limits;
205
+ constructor(e, t, n = r) {
206
+ this.settings = e, this.diagnostics = t, this.limits = n;
204
207
  }
205
208
  update(e) {
206
209
  this.settings = e;
207
210
  }
208
211
  accepts(e) {
209
- return this.settings.level === null || !Object.hasOwn(x, this.settings.level) ? !1 : x[e] >= x[this.settings.level];
210
- }
211
- write(e, t, r, i, a) {
212
- if (!this.accepts(t) || typeof console > "u" || ke()) return;
213
- let o = `%c[%s]%c[${t}]%c`, { styles: s } = this.settings, c = Qe[t];
214
- this.diagnostics.guard("handler.threw", `The library could not print to console.${c}.`, () => {
215
- let l = [];
216
- a !== void 0 && l.push(a), i !== void 0 && l.push(je(i, n, this.diagnostics)), k(() => {
217
- console[c](o, s.namespace, e, s[t], "", r, ...l);
212
+ return this.settings.level === null || !Object.hasOwn(C, this.settings.level) ? !1 : C[e] >= C[this.settings.level];
213
+ }
214
+ write(e, t, n, r, i) {
215
+ if (!this.accepts(t) || typeof console > "u" || je()) return;
216
+ let a = `%c[%s]%c[${t}]%c`, { styles: o } = this.settings, s = nt[t];
217
+ this.diagnostics.guard("handler.threw", `The library could not print to console.${s}.`, () => {
218
+ let c = [];
219
+ i !== void 0 && c.push(i), r !== void 0 && c.push(Ne(r, this.limits, this.diagnostics)), O(() => {
220
+ console[s](a, o.namespace, e, o[t], "", n, ...c);
218
221
  });
219
222
  });
220
223
  }
221
- }, et = class {
224
+ }, it = class {
222
225
  value = 0;
223
226
  next() {
224
227
  return ++this.value;
225
228
  }
226
- }, tt = /^[0-9a-f]{32}$/, nt = /^[0-9a-f]{16}$/, rt = /[1-9a-f]/;
227
- function it(e) {
228
- return tt.test(e.traceId) && rt.test(e.traceId) && nt.test(e.spanId) && rt.test(e.spanId);
229
+ }, at = /^[0-9a-f]{32}$/, ot = /^[0-9a-f]{16}$/, st = /[1-9a-f]/;
230
+ function ct(e) {
231
+ return at.test(e.traceId) && st.test(e.traceId) && ot.test(e.spanId) && st.test(e.spanId);
229
232
  }
230
- function at() {
231
- return Fe(16);
233
+ function lt() {
234
+ return A(16);
232
235
  }
233
- function ot() {
234
- return Fe(8);
236
+ function ut() {
237
+ return A(8);
235
238
  }
236
- function st() {
239
+ function dt() {
237
240
  return {
238
- traceId: at(),
239
- spanId: ot(),
241
+ traceId: lt(),
242
+ spanId: ut(),
240
243
  traceFlags: 1,
241
244
  startedAt: Date.now()
242
245
  };
243
246
  }
244
- function ct(e) {
247
+ function ft(e) {
245
248
  return {
246
249
  traceId: e.traceId,
247
250
  spanId: e.spanId,
248
251
  traceFlags: e.traceFlags
249
252
  };
250
253
  }
251
- var lt = class {
254
+ var pt = class {
252
255
  diagnostics;
253
256
  maxAgeMs;
254
257
  load;
255
- ambient = st();
258
+ ambient = dt();
256
259
  otel;
257
- constructor(e, t = oe, n) {
260
+ constructor(e, t = pe, n) {
258
261
  this.diagnostics = e, this.maxAgeMs = t, this.load = n;
259
262
  }
260
263
  async loadOtel() {
@@ -266,7 +269,7 @@ var lt = class {
266
269
  }
267
270
  resolve() {
268
271
  let e = this.activeSpanContext();
269
- return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), ct(this.ambient)) : e;
272
+ return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), ft(this.ambient)) : e;
270
273
  }
271
274
  activeSpanContext() {
272
275
  let e = this.otel;
@@ -274,7 +277,7 @@ var lt = class {
274
277
  let t = e.trace.getActiveSpan();
275
278
  if (t === void 0) return;
276
279
  let n = t.spanContext();
277
- if (it(n)) return {
280
+ if (ct(n)) return {
278
281
  traceId: n.traceId,
279
282
  spanId: n.spanId,
280
283
  traceFlags: n.traceFlags
@@ -282,7 +285,7 @@ var lt = class {
282
285
  });
283
286
  }
284
287
  rotate(e) {
285
- return this.ambient = st(), ct(this.ambient);
288
+ return this.ambient = dt(), ft(this.ambient);
286
289
  }
287
290
  headers() {
288
291
  let e = {}, t = this.otel;
@@ -290,11 +293,11 @@ var lt = class {
290
293
  t.propagation.inject(t.context.active(), e);
291
294
  }), !e.traceparent) {
292
295
  let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
293
- e[fe] = `00-${t.traceId}-${t.spanId}-${n}`;
296
+ e[_e] = `00-${t.traceId}-${t.spanId}-${n}`;
294
297
  }
295
298
  return e;
296
299
  }
297
- }, ut = class {
300
+ }, mt = class {
298
301
  buffer;
299
302
  pointer = 0;
300
303
  filled = !1;
@@ -311,36 +314,54 @@ var lt = class {
311
314
  clear() {
312
315
  this.buffer = Array(this.capacity), this.pointer = 0, this.filled = !1;
313
316
  }
314
- }, I = Object.keys(x), dt = ["gzip", "none"], ft = [
317
+ }, ht = Object.keys(C), gt = ["gzip", "none"], _t = [
315
318
  "omit",
316
319
  "same-origin",
317
320
  "include"
318
- ], pt = [
321
+ ], vt = [
319
322
  "auto",
320
323
  "indexeddb",
321
324
  "localstorage",
322
325
  "memory",
323
326
  "none"
324
- ], mt = ["storage", "memory"], ht = [
327
+ ], yt = ["storage", "memory"], bt = [
325
328
  "auto",
326
329
  "sender",
327
330
  "forwarder",
328
331
  "off"
329
- ], gt = [
332
+ ], xt = [
330
333
  "auto",
331
334
  "provider",
332
335
  "client"
333
- ], _t = [
336
+ ], St = [
334
337
  "auto",
335
338
  "context",
336
339
  "tab",
337
340
  "origin"
338
- ], L = [
341
+ ], Ct = [
339
342
  "error",
340
343
  "warn",
341
344
  "info",
342
345
  "log"
343
- ], vt = [
346
+ ], wt = ["limited", "until-delivered"], Tt = {
347
+ logFlushIntervalMs: [100, 6e4],
348
+ logBatchSize: [1, 1e3],
349
+ metricFlushIntervalMs: [100, 6e4],
350
+ metricBatchSize: [1, 1e3]
351
+ }, Et = {
352
+ maxBatches: [1, 5e3],
353
+ maxAgeMs: [6e4, 6048e5],
354
+ maxAttempts: [1, 20]
355
+ }, Dt = {
356
+ maxBodyChars: [256, 65536],
357
+ maxAttributeChars: [256, 65536],
358
+ maxAttributeCount: [1, 1024],
359
+ maxStackChars: [256, 65536],
360
+ maxDepth: [1, 16],
361
+ maxArrayLength: [1, 1e4],
362
+ maxNodes: [100, 1e5],
363
+ maxRecordBytes: [1024, Se]
364
+ }, Ot = [6e4, 864e5], kt = [
344
365
  "errors",
345
366
  "rejections",
346
367
  "resourceErrors",
@@ -351,117 +372,126 @@ var lt = class {
351
372
  "webVitals",
352
373
  "longFrames",
353
374
  "fullUrls"
354
- ], yt = "null", R = `a level name: ${B(I)}`, z = `true, false or a list of ${B(L)}`, bt = "a list of strings and RegExp patterns", xt = "a list of origin URLs such as \"https://api.example\" and RegExp patterns", St = "a list of origin URLs such as \"https://app.example\". For a sandboxed frame, set bus.mode: \"sender\" in the frame", Ct = "a list of strings";
355
- function B(e) {
375
+ ], At = "null", I = `a level name: ${R(ht)}`, L = `true, false or a list of ${R(Ct)}`, jt = "a list of strings and RegExp patterns", Mt = "a list of origin URLs such as \"https://api.example\" and RegExp patterns", Nt = "a list of origin URLs such as \"https://app.example\". For a sandboxed frame, set bus.mode: \"sender\" in the frame", Pt = "a list of strings";
376
+ function R(e) {
356
377
  let t = e.map((e) => `"${e}"`);
357
378
  return `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
358
379
  }
359
- function V(e) {
380
+ function z(e) {
360
381
  return typeof e == "string" ? `"${e}"` : typeof e == "function" ? "a function" : typeof e == "object" && e ? "an object" : String(e);
361
382
  }
362
- function H(e, t, n, r, i) {
363
- e.report("config.invalid", `${t} must be ${n}. The value is ${V(r)}. The library keeps ${i}.`);
383
+ function B(e, t, n, r, i) {
384
+ e.report("config.invalid", `${t} must be ${n}. The value is ${z(r)}. The library keeps ${i}.`);
364
385
  }
365
- function U(e, t, n, r, i) {
386
+ function V(e, t, n, r, i) {
366
387
  if (t === void 0) return r;
367
388
  let a = n.find((e) => e === t);
368
- return a === void 0 ? (H(i, e, B(n), t, `"${r}"`), r) : a;
389
+ return a === void 0 ? (B(i, e, R(n), t, `"${r}"`), r) : a;
369
390
  }
370
- function W(e, t, n, r) {
371
- return t === void 0 ? n : typeof t == "boolean" ? t : (H(r, e, "true or false", t, String(n)), n);
391
+ function H(e, t, n, r) {
392
+ return t === void 0 ? n : typeof t == "boolean" ? t : (B(r, e, "true or false", t, String(n)), n);
372
393
  }
373
- function wt(e, t, n, r) {
374
- return t === void 0 ? n : typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : (H(r, e, "a finite number of 0 or more", t, String(n)), n);
394
+ function Ft(e, t, n, r) {
395
+ return t === void 0 ? n : typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : (B(r, e, "a finite number of 0 or more", t, String(n)), n);
396
+ }
397
+ function It(e, t, n, r, i) {
398
+ if (t === void 0) return r;
399
+ let [a, o] = n;
400
+ return typeof t == "number" && Number.isInteger(t) && t >= a && t <= o ? t : (B(i, e, `an integer from ${String(a)} to ${String(o)}`, t, String(r)), r);
375
401
  }
376
- function G(e) {
402
+ function U(e, t, n, r, i) {
403
+ let a = t ?? {}, o = Object.keys(r);
404
+ return Object.fromEntries(o.map((t) => [t, It(`${e}.${t}`, a[t], r[t], n[t], i)]));
405
+ }
406
+ function W(e) {
377
407
  if (typeof e != "string") return;
378
408
  let t = e.toUpperCase();
379
- return I.find((e) => e === t);
409
+ return ht.find((e) => e === t);
380
410
  }
381
- function Tt(e, t, n, r) {
411
+ function Lt(e, t, n, r) {
382
412
  if (t === void 0) return n;
383
- let i = G(t);
384
- return i === void 0 ? (H(r, e, R, t, `"${n}"`), n) : i;
413
+ let i = W(t);
414
+ return i === void 0 ? (B(r, e, I, t, `"${n}"`), n) : i;
385
415
  }
386
- function K(e, t, n, r, i, a) {
416
+ function G(e, t, n, r, i, a) {
387
417
  if (t === void 0) return n;
388
- if (!Array.isArray(t)) return H(a, e, r, t, "the list in force"), n;
418
+ if (!Array.isArray(t)) return B(a, e, r, t, "the list in force"), n;
389
419
  let o = [], s = t;
390
420
  for (let t of s) {
391
421
  let n = i(t);
392
- n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${V(t)}. ${e} must be ${r}.`) : o.push(n);
422
+ n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${z(t)}. ${e} must be ${r}.`) : o.push(n);
393
423
  }
394
424
  return o;
395
425
  }
396
- function Et(e) {
426
+ function Rt(e) {
397
427
  return typeof e == "string" ? e : void 0;
398
428
  }
399
- function Dt(e) {
429
+ function zt(e) {
400
430
  return typeof e == "string" || e instanceof RegExp ? e : void 0;
401
431
  }
402
- function Ot(e) {
403
- return L.find((t) => t === e);
432
+ function Bt(e) {
433
+ return Ct.find((t) => t === e);
404
434
  }
405
- function kt(e) {
435
+ function Vt(e) {
406
436
  if (typeof e == "string") try {
407
437
  let { origin: t } = new URL(e);
408
- return t === yt ? void 0 : t;
438
+ return t === At ? void 0 : t;
409
439
  } catch {
410
440
  return;
411
441
  }
412
442
  }
413
- function At(e) {
414
- return e instanceof RegExp ? e : kt(e);
443
+ function Ht(e) {
444
+ return e instanceof RegExp ? e : Vt(e);
415
445
  }
416
- function jt(e) {
446
+ function Ut(e) {
417
447
  return typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.values(e).every((e) => typeof e == "string");
418
448
  }
419
- function Mt(e, t, n) {
420
- if (e !== void 0) return typeof e == "function" || jt(e) ? e : (H(n, "headers", "an object of strings or a function", e, "the headers in force"), t);
449
+ function Wt(e, t, n) {
450
+ if (e !== void 0) return typeof e == "function" || Ut(e) ? e : (B(n, "headers", "an object of strings or a function", e, "the headers in force"), t);
421
451
  }
422
- function Nt(e) {
452
+ function Gt(e) {
423
453
  return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
424
454
  }
425
- function Pt(e, t, n) {
426
- return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || Nt(e) ? e : (n.report("config.invalid", `serializer must be "${v}", "ecs" or an implementation. The library uses "${v}".`), v);
455
+ function Kt(e, t, n) {
456
+ return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || Gt(e) ? e : (n.report("config.invalid", `serializer must be "${v}", "ecs" or an implementation. The library uses "${v}".`), v);
427
457
  }
428
- var Ft = new Set(Object.keys(ue));
429
- function It(e, t) {
458
+ var qt = new Set(Object.keys(e));
459
+ function Jt(e, t) {
430
460
  let n = {}, r = Object.entries(e ?? {});
431
- for (let [e, i] of r) Ft.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.`);
461
+ for (let [e, i] of r) qt.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.`);
432
462
  return n;
433
463
  }
434
- function Lt(e, t, n) {
464
+ function Yt(e, t, n) {
435
465
  if (e === void 0) return t ?? "DEBUG";
436
- let r = G(e);
437
- return r === void 0 ? (H(n, "console.level", R, e, "the console level in force"), t) : r;
466
+ let r = W(e);
467
+ return r === void 0 ? (B(n, "console.level", I, e, "the console level in force"), t) : r;
438
468
  }
439
- function Rt(e, t, n) {
469
+ function Xt(e, t, n) {
440
470
  if (e === void 0) return t;
441
471
  if (e === !1) return {
442
472
  level: null,
443
473
  styles: t.styles
444
474
  };
445
475
  if (e === !0) return {
446
- level: p,
476
+ level: de,
447
477
  styles: t.styles
448
478
  };
449
479
  if (typeof e == "string") {
450
- let r = G(e);
451
- return r === void 0 ? (H(n, "console", R, e, "the console level in force"), t) : {
480
+ let r = W(e);
481
+ return r === void 0 ? (B(n, "console", I, e, "the console level in force"), t) : {
452
482
  level: r,
453
483
  styles: t.styles
454
484
  };
455
485
  }
456
486
  return typeof e != "object" || !e ? (n.report("config.invalid", "console must be a boolean, a level or an object. The console settings in force stay."), t) : {
457
- level: Lt(e.level, t.level, n),
487
+ level: Yt(e.level, t.level, n),
458
488
  styles: {
459
489
  ...t.styles,
460
- ...It(e.styles, n)
490
+ ...Jt(e.styles, n)
461
491
  }
462
492
  };
463
493
  }
464
- function zt(e, t, n) {
494
+ function Zt(e, t, n) {
465
495
  let r = e ?? {};
466
496
  return {
467
497
  ...t,
@@ -470,56 +500,70 @@ function zt(e, t, n) {
470
500
  ...t.rates,
471
501
  ...r.rates
472
502
  },
473
- alwaysSampleTypes: K("sampling.alwaysSampleTypes", r.alwaysSampleTypes, t.alwaysSampleTypes, Ct, Et, n),
474
- remote: W("sampling.remote", r.remote, t.remote, n)
503
+ alwaysSampleTypes: G("sampling.alwaysSampleTypes", r.alwaysSampleTypes, t.alwaysSampleTypes, Pt, Rt, n),
504
+ remote: H("sampling.remote", r.remote, t.remote, n)
475
505
  };
476
506
  }
477
- function Bt(e, t, n) {
507
+ function Qt(e, t, n) {
478
508
  let r = e ?? {};
479
509
  return {
480
- mode: U("bus.mode", r.mode, ht, t.mode, n),
481
- trustedOrigins: K("bus.trustedOrigins", r.trustedOrigins, t.trustedOrigins, St, kt, n),
482
- openFinRole: U("bus.openFinRole", r.openFinRole, gt, t.openFinRole, n)
510
+ mode: V("bus.mode", r.mode, bt, t.mode, n),
511
+ trustedOrigins: G("bus.trustedOrigins", r.trustedOrigins, t.trustedOrigins, Nt, Vt, n),
512
+ openFinRole: V("bus.openFinRole", r.openFinRole, xt, t.openFinRole, n)
483
513
  };
484
514
  }
485
- function Vt(e, t, n) {
486
- return { scope: U("journey.scope", (e ?? {}).scope, _t, t.scope, n) };
515
+ function $t(e, t, n) {
516
+ let r = e ?? {};
517
+ return {
518
+ scope: V("journey.scope", r.scope, St, t.scope, n),
519
+ maxAgeMs: It("journey.maxAgeMs", r.maxAgeMs, Ot, t.maxAgeMs, n)
520
+ };
521
+ }
522
+ function en(e, t, n) {
523
+ let r = e ?? {};
524
+ return {
525
+ mode: V("retention.mode", r.mode, wt, t.mode, n),
526
+ ...U("retention", r, t, Et, n)
527
+ };
487
528
  }
488
- function Ht(e, t, n) {
489
- return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ? K("capture.console", e, [], z, Ot, n) : (H(n, "capture.console", z, e, "the value in force"), t);
529
+ function tn(e, t, n) {
530
+ return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ? G("capture.console", e, [], L, Bt, n) : (B(n, "capture.console", L, e, "the value in force"), t);
490
531
  }
491
- function Ut(e, t, n) {
532
+ function nn(e, t, n) {
492
533
  let r = e ?? {}, i = {
493
534
  ...t,
494
535
  ...r,
495
- console: Ht(r.console, t.console, n),
496
- longFrameThresholdMs: wt("capture.longFrameThresholdMs", r.longFrameThresholdMs, t.longFrameThresholdMs, n),
497
- ignoreUrls: K("capture.ignoreUrls", r.ignoreUrls, t.ignoreUrls, bt, Dt, n),
498
- propagateTraceHeaderTo: K("capture.propagateTraceHeaderTo", r.propagateTraceHeaderTo, t.propagateTraceHeaderTo, xt, At, n)
536
+ console: tn(r.console, t.console, n),
537
+ longFrameThresholdMs: Ft("capture.longFrameThresholdMs", r.longFrameThresholdMs, t.longFrameThresholdMs, n),
538
+ ignoreUrls: G("capture.ignoreUrls", r.ignoreUrls, t.ignoreUrls, jt, zt, n),
539
+ propagateTraceHeaderTo: G("capture.propagateTraceHeaderTo", r.propagateTraceHeaderTo, t.propagateTraceHeaderTo, Mt, Ht, n)
499
540
  };
500
- for (let e of vt) i[e] = W(`capture.${e}`, r[e], t[e], n);
541
+ for (let e of kt) i[e] = H(`capture.${e}`, r[e], t[e], n);
501
542
  return i;
502
543
  }
503
- function Wt(e, t, n) {
504
- let r = n ?? d, i = {
544
+ function rn(e, t, n) {
545
+ let r = n ?? m, i = {
505
546
  ...r,
506
547
  ...e,
507
548
  endpoint: e.endpoint === void 0 ? r.endpoint : e.endpoint,
508
- enabled: W("enabled", e.enabled, r.enabled, t),
509
- minLevel: Tt("minLevel", e.minLevel, r.minLevel, t),
510
- compression: U("compression", e.compression, dt, r.compression, t),
511
- credentials: U("credentials", e.credentials, ft, r.credentials, t),
512
- headers: "headers" in e ? Mt(e.headers, r.headers, t) : r.headers,
513
- storage: U("storage", e.storage, pt, r.storage, t),
514
- identity: U("identity", e.identity, mt, r.identity, t),
515
- serializer: Pt(e.serializer, n?.serializer, t),
516
- console: Rt(e.console, r.console, t),
517
- sampling: zt(e.sampling, r.sampling, t),
518
- bus: Bt(e.bus, r.bus, t),
519
- journey: Vt(e.journey, r.journey, t),
520
- capture: Ut(e.capture, r.capture, t)
549
+ enabled: H("enabled", e.enabled, r.enabled, t),
550
+ minLevel: Lt("minLevel", e.minLevel, r.minLevel, t),
551
+ compression: V("compression", e.compression, gt, r.compression, t),
552
+ credentials: V("credentials", e.credentials, _t, r.credentials, t),
553
+ headers: "headers" in e ? Wt(e.headers, r.headers, t) : r.headers,
554
+ storage: V("storage", e.storage, vt, r.storage, t),
555
+ identity: V("identity", e.identity, yt, r.identity, t),
556
+ serializer: Kt(e.serializer, n?.serializer, t),
557
+ console: Xt(e.console, r.console, t),
558
+ sampling: Zt(e.sampling, r.sampling, t),
559
+ bus: Qt(e.bus, r.bus, t),
560
+ batching: U("batching", e.batching, r.batching, Tt, t),
561
+ retention: en(e.retention, r.retention, t),
562
+ limits: U("limits", e.limits, r.limits, Dt, t),
563
+ journey: $t(e.journey, r.journey, t),
564
+ capture: nn(e.capture, r.capture, t)
521
565
  };
522
- 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.");
566
+ 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.onDrop !== void 0 && typeof i.onDrop != "function" && (t.report("config.invalid", "onDrop must be a function. The library ignores the value."), i.onDrop = r.onDrop), 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.");
523
567
  else if (i.endpoint !== null) try {
524
568
  new URL(i.endpoint);
525
569
  } catch (e) {
@@ -532,25 +576,25 @@ function Wt(e, t, n) {
532
576
  (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);
533
577
  let s = Object.entries(i.sampling.rates);
534
578
  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);
535
- 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]), Gt(e, t), i;
579
+ 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]), an(e, t), i;
536
580
  }
537
- function Gt(e, n) {
538
- let r = /* @__PURE__ */ new Set([...Object.keys(d), ...ne]);
539
- for (let t of Object.keys(e)) r.has(t) || n.report("config.invalid", `The library ignores the unknown config key "${t}". Check the spelling.`);
540
- for (let r of t) {
541
- let t = e[r];
542
- if (typeof t != "object" || !t) continue;
543
- let i = /* @__PURE__ */ new Set([...Object.keys(d[r]), ...xe[r]]);
544
- for (let e of Object.keys(t)) i.has(e) || n.report("config.invalid", `The library ignores the unknown config key "${r}.${e}". Check the spelling.`);
581
+ function an(e, t) {
582
+ let n = /* @__PURE__ */ new Set([...Object.keys(m), ...ce]);
583
+ 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.`);
584
+ for (let n of p) {
585
+ let r = e[n];
586
+ if (typeof r != "object" || !r) continue;
587
+ let i = /* @__PURE__ */ new Set([...Object.keys(m[n]), ...ne[n]]);
588
+ 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.`);
545
589
  }
546
590
  }
547
- function Kt(e, n) {
548
- for (let r of Object.keys(n)) t.includes(r) || Object.assign(e, { [r]: n[r] });
549
- for (let r of t) Object.assign(e[r], n[r]);
591
+ function on(e, t) {
592
+ for (let n of Object.keys(t)) p.includes(n) || Object.assign(e, { [n]: t[n] });
593
+ for (let n of p) Object.assign(e[n], t[n]);
550
594
  }
551
595
  //#endregion
552
596
  //#region src/core/context.ts
553
- var qt = class {
597
+ var sn = class {
554
598
  map = /* @__PURE__ */ new Map();
555
599
  set(e, t) {
556
600
  this.map.set(e, t);
@@ -570,12 +614,12 @@ var qt = class {
570
614
  getAll() {
571
615
  return Object.fromEntries(this.map);
572
616
  }
573
- }, Jt = class {
617
+ }, cn = class {
574
618
  handler;
575
619
  throttleMs;
576
620
  counters = /* @__PURE__ */ new Map();
577
621
  lastEmitted = /* @__PURE__ */ new Map();
578
- constructor(e, t = r) {
622
+ constructor(e, t = s) {
579
623
  this.handler = e, this.throttleMs = t;
580
624
  }
581
625
  setHandler(e) {
@@ -598,12 +642,12 @@ var qt = class {
598
642
  count: i
599
643
  }, { handler: s } = this;
600
644
  if (s) try {
601
- k(() => {
645
+ O(() => {
602
646
  s(o);
603
647
  });
604
648
  } catch (e) {
605
- this.count("handler.threw"), typeof console < "u" && k(() => {
606
- console.warn(`${be} The onDiagnostic handler threw an error.`, e);
649
+ this.count("handler.threw"), typeof console < "u" && O(() => {
650
+ console.warn(`${oe} The onDiagnostic handler threw an error.`, e);
607
651
  });
608
652
  }
609
653
  }
@@ -629,15 +673,94 @@ var qt = class {
629
673
  reset() {
630
674
  this.counters.clear(), this.lastEmitted.clear();
631
675
  }
632
- }, Yt = "error.", Xt = [
633
- ie,
634
- ve,
635
- b
676
+ };
677
+ //#endregion
678
+ //#region src/core/drops.ts
679
+ function K(e, t) {
680
+ e.length < 20 && !e.includes(t) && e.push(t);
681
+ }
682
+ var ln = class {
683
+ config;
684
+ diagnostics;
685
+ pending = /* @__PURE__ */ new Map();
686
+ scheduled = !1;
687
+ reporting = !1;
688
+ constructor(e, t) {
689
+ this.config = e, this.diagnostics = t;
690
+ }
691
+ add(e, t, n = []) {
692
+ if (!this.config.onDrop || this.reporting || t.length === 0 && n.length === 0) return;
693
+ let r = this.pending.get(e);
694
+ r || (r = {
695
+ reason: e,
696
+ records: 0,
697
+ batchIds: [],
698
+ journeyIds: [],
699
+ actions: []
700
+ }, this.pending.set(e, r)), r.records += t.length;
701
+ for (let e of n) K(r.batchIds, e);
702
+ for (let e of t) {
703
+ let t = Ue(e, w);
704
+ typeof t == "string" && K(r.journeyIds, t);
705
+ let n = j(e) ? e.body : void 0;
706
+ typeof n == "string" && K(r.actions, n);
707
+ }
708
+ this.scheduled || (this.scheduled = !0, queueMicrotask(() => {
709
+ this.flush();
710
+ }));
711
+ }
712
+ flush() {
713
+ this.scheduled = !1;
714
+ let e = [...this.pending.values()];
715
+ this.pending.clear();
716
+ let t = this.config.onDrop;
717
+ if (t) {
718
+ this.reporting = !0;
719
+ for (let n of e) this.diagnostics.guard("handler.threw", "The onDrop hook threw an error.", () => {
720
+ We(() => {
721
+ O(() => {
722
+ t(n);
723
+ });
724
+ });
725
+ });
726
+ this.reporting = !1;
727
+ }
728
+ }
729
+ }, un = class {
730
+ onDrop;
731
+ held = [];
732
+ actions = 0;
733
+ constructor(e) {
734
+ this.onDrop = e;
735
+ }
736
+ get records() {
737
+ return this.held;
738
+ }
739
+ get length() {
740
+ return this.held.length;
741
+ }
742
+ push(e) {
743
+ let t = j(e);
744
+ if ((t ? this.actions : this.held.length - this.actions) < (t ? 2e3 : 500)) this.actions += +!!t;
745
+ else {
746
+ let e = this.held.findIndex((e) => j(e) === t), [n] = this.held.splice(e, 1);
747
+ this.onDrop(n);
748
+ }
749
+ this.held.push(e);
750
+ }
751
+ take() {
752
+ let e = this.held;
753
+ return this.held = [], this.actions = 0, e;
754
+ }
755
+ }, dn = "error.", fn = [
756
+ se,
757
+ w,
758
+ re
636
759
  ];
637
760
  function q(e) {
638
761
  return e;
639
762
  }
640
- var Zt = class {
763
+ var pn = class {
641
764
  deps;
642
765
  resourceCache = null;
643
766
  constructor(e) {
@@ -649,9 +772,9 @@ var Zt = class {
649
772
  isEnabled(e, t) {
650
773
  let { config: n } = this.deps;
651
774
  if (!n.enabled) return !1;
652
- if (t !== void 0 && ye.includes(t)) return !0;
775
+ if (t !== void 0 && ie.includes(t)) return !0;
653
776
  let r = this.deps.remote.sampling?.minLevel() ?? n.minLevel;
654
- return x[e] >= x[r];
777
+ return C[e] >= C[r];
655
778
  }
656
779
  build(e) {
657
780
  let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o, remote: s } = this.deps;
@@ -660,7 +783,7 @@ var Zt = class {
660
783
  dropped: "level"
661
784
  };
662
785
  let c = r.resolve(), l = i.current();
663
- if (!Oe({
786
+ if (!Ae({
664
787
  level: e.level,
665
788
  type: e.type,
666
789
  namespace: e.namespace,
@@ -670,26 +793,26 @@ var Zt = class {
670
793
  record: null,
671
794
  dropped: "sampling"
672
795
  };
673
- let u = a.next(), d = Ve(n), f = t.capture.fullUrls ? d : Be(d), p, m = 0;
796
+ let u = a.next(), d = He(n), f = t.capture.fullUrls ? d : Ve(d), p, m = 0;
674
797
  try {
675
- let t = A(this.deps.context.getAll(), o, n), r = A(e.scoped ?? {}, o, n), i = A(e.payload ?? {}, o, n);
798
+ let t = k(this.deps.context.getAll(), o, n), r = k(e.scoped ?? {}, o, n), i = k(e.payload ?? {}, o, n);
676
799
  m = t.bytes + r.bytes + i.bytes, p = {
677
800
  ...q(t.value),
678
801
  ...q(r.value),
679
802
  ...q(i.value)
680
803
  };
681
804
  } catch (e) {
682
- n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [he]: !0 };
805
+ n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [ge]: !0 };
683
806
  }
684
- p[S] = e.type, p[T] = u, p[pe] = e.namespace, p[ie] = f, l && (p[ve] = l.id, p[b] = l.name, l.parentId !== void 0 && (p[de] = l.parentId));
685
- let h = Ae(e.body, o.maxBodyChars);
807
+ p[b] = e.type, p[T] = u, p[me] = e.namespace, p[se] = f, l && (p[w] = l.id, p[re] = l.name, l.parentId !== void 0 && (p[fe] = l.parentId));
808
+ let h = Me(e.body, o.maxBodyChars);
686
809
  h !== e.body && n.count("record.truncated");
687
810
  let g = {
688
- timeUnixNano: De(),
811
+ timeUnixNano: ke(),
689
812
  traceId: c.traceId,
690
813
  spanId: c.spanId,
691
814
  traceFlags: c.traceFlags,
692
- severityNumber: C[e.level],
815
+ severityNumber: x[e.level],
693
816
  severityText: e.level,
694
817
  body: h,
695
818
  attributes: p,
@@ -710,22 +833,22 @@ var Zt = class {
710
833
  dropped: "redact"
711
834
  };
712
835
  let t = e ?? g;
713
- if (!O(t)) return t === g ? (n.report("record.dropped_malformed", "The redact hook changed the record to a shape that is not a record. The library dropped it."), {
836
+ if (!D(t)) return t === g ? (n.report("record.dropped_malformed", "The redact hook changed the record to a shape that is not a record. The library dropped it."), {
714
837
  record: null,
715
838
  dropped: "malformed"
716
839
  }) : (n.report("record.dropped_by_redact", "The redact hook returned a value that is not a record. The library dropped the record."), {
717
840
  record: null,
718
841
  dropped: "redact"
719
842
  });
720
- if (Te(t.severityText)) {
843
+ if (De(t.severityText)) {
721
844
  if (t !== g) {
722
- let e = A(t.attributes, o, n);
845
+ let e = k(t.attributes, o, n);
723
846
  g = {
724
847
  ...t,
725
848
  attributes: q(e.value)
726
849
  }, m = e.bytes;
727
850
  }
728
- g.severityNumber = C[g.severityText];
851
+ g.severityNumber = x[g.severityText];
729
852
  } else return n.report("record.dropped_malformed", "The redact hook set a severityText that is not a log level. The library dropped the record."), {
730
853
  record: null,
731
854
  dropped: "malformed"
@@ -737,19 +860,19 @@ var Zt = class {
737
860
  body: g.body
738
861
  });
739
862
  let t = {
740
- [S]: e.type,
863
+ [b]: e.type,
741
864
  [T]: u,
742
- [pe]: e.namespace,
743
- [se]: !0,
744
- [_e]: m
865
+ [me]: e.namespace,
866
+ [le]: !0,
867
+ [ye]: m
745
868
  };
746
- for (let e of Xt) e in g.attributes && (t[e] = g.attributes[e]);
747
- for (let [e, n] of Object.entries(g.attributes)) e.startsWith(Yt) && (t[e] = n);
748
- let r = A(t, o, n).bytes;
749
- r > o.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t, me), r = A(t, o, n).bytes);
869
+ for (let e of fn) e in g.attributes && (t[e] = g.attributes[e]);
870
+ for (let [e, n] of Object.entries(g.attributes)) e.startsWith(dn) && (t[e] = n);
871
+ let r = k(t, o, n).bytes;
872
+ r > o.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t, he), r = k(t, o, n).bytes);
750
873
  let i = g.attributes[y];
751
874
  if (i !== void 0) {
752
- let e = A(i, o, n).bytes;
875
+ let e = k(i, o, n).bytes;
753
876
  r + e <= o.maxRecordBytes && (t[y] = i);
754
877
  }
755
878
  g.attributes = t;
@@ -758,32 +881,32 @@ var Zt = class {
758
881
  }
759
882
  resource() {
760
883
  if (this.resourceCache) return this.resourceCache;
761
- let { config: t, identity: n, platform: r } = this.deps;
884
+ let { config: e, identity: n, platform: r } = this.deps;
762
885
  return this.resourceCache = {
763
- [l]: t.serviceName,
764
- [g]: t.serviceVersion,
765
- [f]: t.environment,
766
- [a]: ae,
767
- [ee]: w,
768
- [te]: re,
886
+ [u]: e.serviceName,
887
+ [_]: e.serviceVersion,
888
+ [f]: e.environment,
889
+ [o]: ae,
890
+ [ee]: S,
891
+ [te]: xe,
769
892
  [h]: r.platform,
770
- [Se]: n.sessionId,
771
- [e]: n.tabId,
772
- [u]: n.contextId,
773
- [le]: r.userAgent,
774
- ...r.openfinUuid === void 0 ? {} : { [o]: r.openfinUuid },
775
- ...r.openfinName === void 0 ? {} : { [i]: r.openfinName }
893
+ [Ce]: n.sessionId,
894
+ [t]: n.tabId,
895
+ [d]: n.contextId,
896
+ [ue]: r.userAgent,
897
+ ...r.openfinUuid === void 0 ? {} : { [c]: r.openfinUuid },
898
+ ...r.openfinName === void 0 ? {} : { [a]: r.openfinName }
776
899
  }, this.resourceCache;
777
900
  }
778
- }, Qt = {
779
- errors: async () => (await import("./errors-DH4QJS0u.js")).ErrorCapture,
780
- network: async () => (await import("./network-D_lloS5t.js")).NetworkCapture,
781
- interactions: async () => (await import("./interactions-OU94MPXs.js")).InteractionCapture,
901
+ }, mn = {
902
+ errors: async () => (await import("./errors-CQusIGWJ.js")).ErrorCapture,
903
+ network: async () => (await import("./network-51iicpLl.js")).NetworkCapture,
904
+ interactions: async () => (await import("./interactions-CnjfQgw3.js")).InteractionCapture,
782
905
  webVitals: async () => (await import("./web-vitals-Bflr5jSA.js")).WebVitalsCapture,
783
- longFrames: async () => (await import("./long-frames-C_7OutLs.js")).LongFrameCapture,
784
- console: async () => (await import("./console-DjLbryED.js")).ConsoleCapture
785
- }, J = Symbol.for(ge), Y = Symbol.for(s);
786
- function $t(e) {
906
+ longFrames: async () => (await import("./long-frames-CZk3XOkH.js")).LongFrameCapture,
907
+ console: async () => (await import("./console-C9Y639mn.js")).ConsoleCapture
908
+ }, J = Symbol.for(ve), Y = Symbol.for(l), hn = ["batching", "retention"];
909
+ function gn(e) {
787
910
  return JSON.stringify({
788
911
  ...e,
789
912
  webVitalsLoader: e.webVitalsLoader !== void 0,
@@ -791,7 +914,7 @@ function $t(e) {
791
914
  propagateTraceHeaderTo: e.propagateTraceHeaderTo.map(String)
792
915
  });
793
916
  }
794
- function en(e) {
917
+ function _n(e) {
795
918
  return {
796
919
  ...e,
797
920
  endpoint: null,
@@ -804,12 +927,12 @@ function en(e) {
804
927
  };
805
928
  }
806
929
  function X(e) {
807
- return e.sdkVersion === w;
930
+ return e.sdkVersion === S;
808
931
  }
809
932
  var Z = class e {
810
933
  degraded;
811
934
  static local = null;
812
- sdkVersion = w;
935
+ sdkVersion = S;
813
936
  diagnostics;
814
937
  config;
815
938
  platform;
@@ -817,21 +940,24 @@ var Z = class e {
817
940
  stores;
818
941
  identityBuiltAs;
819
942
  sessionTouch;
820
- context = new qt();
943
+ context = new sn();
821
944
  breadcrumbs;
822
945
  tracing;
823
- sequence = new et();
946
+ sequence = new it();
824
947
  journey;
825
948
  builder;
826
949
  remote = { sampling: null };
827
950
  console;
951
+ drops;
828
952
  bus = null;
829
953
  busBuilt;
830
954
  busLoad;
831
955
  storageBuiltAs;
832
956
  sender;
833
957
  senderLoad;
834
- pendingRecords = [];
958
+ pendingRecords = new un((e) => {
959
+ this.dropHeld(e);
960
+ });
835
961
  captures = [];
836
962
  captureGeneration = 0;
837
963
  captureOnce = {
@@ -839,7 +965,9 @@ var Z = class e {
839
965
  navigationTiming: !1,
840
966
  longFrames: !1
841
967
  };
842
- bootBuffer = [];
968
+ bootBuffer = new un((e) => {
969
+ this.dropHeld(e);
970
+ });
843
971
  forwardBuffer = [];
844
972
  forwardScheduled = !1;
845
973
  roleResolved = !1;
@@ -847,13 +975,19 @@ var Z = class e {
847
975
  ready = !1;
848
976
  destroyed = !1;
849
977
  lastGapAt = 0;
978
+ limits;
979
+ journeyOptions;
980
+ tunablesLocked = !0;
850
981
  constructor(e, t = !1) {
851
- this.degraded = t, this.diagnostics = new Jt(e.onDiagnostic), this.platform = ze(this.diagnostics), this.config = Wt(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Ie() : Pe, this.identity = Re(this.diagnostics, this.stores), this.sessionTouch = new Me(this.diagnostics, this.stores), this.breadcrumbs = new ut(50), this.tracing = new lt(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new $e(this.config.console, this.diagnostics), this.journey = new He(Ue, this.diagnostics, this.identity.contextId, (e) => {
982
+ this.degraded = t, this.diagnostics = new cn(e.onDiagnostic), this.platform = Be(this.diagnostics), this.config = rn(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Le() : ze, this.identity = Re(this.diagnostics, this.stores), this.sessionTouch = new Ie(this.diagnostics, this.stores), this.breadcrumbs = new mt(50), this.tracing = new pt(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.limits = { ...this.config.limits }, this.console = new rt(this.config.console, this.diagnostics, this.limits), this.drops = new ln(this.config, this.diagnostics), this.journeyOptions = {
983
+ ...Ke,
984
+ maxAgeMs: this.config.journey.maxAgeMs
985
+ }, this.journey = new Ge(this.journeyOptions, this.diagnostics, this.identity.contextId, (e) => {
852
986
  this.bus?.broadcastJourney(e);
853
- }, this.stores), this.builder = new Zt({
987
+ }, this.stores), this.builder = new pn({
854
988
  remote: this.remote,
855
989
  config: this.config,
856
- limits: n,
990
+ limits: this.limits,
857
991
  diagnostics: this.diagnostics,
858
992
  context: this.context,
859
993
  journey: this.journey,
@@ -888,30 +1022,42 @@ var Z = class e {
888
1022
  isDestroyed() {
889
1023
  return this.destroyed;
890
1024
  }
891
- static configure(t) {
892
- let n = e.local;
893
- if (n && !n.destroyed) return n.reconfigure(en(t)), n;
1025
+ static configure(t, n = !1) {
1026
+ let r = e.local;
1027
+ if (r && !r.destroyed) return r.reconfigure(_n(t)), r;
894
1028
  e.local = null;
895
- let r = e.pinned();
896
- if (r) {
897
- if (!X(r)) return e.startDegraded(t, r.sdkVersion);
898
- if (!r.destroyed) return r.reconfigure(t), r;
1029
+ let i = e.pinned();
1030
+ if (i) {
1031
+ if (!X(i)) return e.startDegraded(t, i.sdkVersion);
1032
+ if (!i.destroyed) return i.reconfigure(t), i;
899
1033
  }
900
- let i = new e(t);
901
- return globalThis[J] = i, Reflect.deleteProperty(globalThis, Y), i.init(), i;
1034
+ let a = new e(t);
1035
+ return a.tunablesLocked = !n, globalThis[J] = a, Reflect.deleteProperty(globalThis, Y), a.init(), a;
902
1036
  }
903
1037
  static startDegraded(t, n) {
904
- let r = new e(en(t), !0);
1038
+ let r = new e(_n(t), !0);
905
1039
  e.local = r;
906
1040
  let i = typeof n == "string" ? n : "before 0.9.0";
907
- return r.diagnostics.report("runtime.version_mismatch", `Another copy of the library, version ${i}, owns the page runtime. This copy, version ${w}, runs in console-only mode and installs no capture. Load one version of the library on the page.`, {
1041
+ return r.diagnostics.report("runtime.version_mismatch", `Another copy of the library, version ${i}, owns the page runtime. This copy, version ${S}, runs in console-only mode and installs no capture. Load one version of the library on the page.`, {
908
1042
  found: i,
909
- own: w
1043
+ own: S
910
1044
  }), r.init(), r;
911
1045
  }
912
1046
  reconfigure(e) {
913
- let t = this.keepDestination(e), n = $t(this.config.capture);
914
- Kt(this.config, Wt(t, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), $t(this.config.capture) !== n && this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
1047
+ let t = this.keepDestination(e), n = gn(this.config.capture), r = rn(t, this.diagnostics, this.config);
1048
+ this.keepStartupTunables(r), on(this.config, r), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), gn(this.config.capture) !== n && this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
1049
+ }
1050
+ keepStartupTunables(e) {
1051
+ if (this.senderLoad !== void 0 && this.keepSections(e, hn), !this.tunablesLocked) {
1052
+ this.tunablesLocked = !0, Object.assign(this.limits, e.limits), this.journeyOptions.maxAgeMs = e.journey.maxAgeMs;
1053
+ return;
1054
+ }
1055
+ this.keepSections(e, ["limits"]);
1056
+ let { maxAgeMs: t } = this.config.journey;
1057
+ e.journey.maxAgeMs !== t && (this.diagnostics.report("config.invalid", `journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`, { requested: e.journey.maxAgeMs }), e.journey.maxAgeMs = t);
1058
+ }
1059
+ keepSections(e, t) {
1060
+ for (let n of t) JSON.stringify(e[n]) !== JSON.stringify(this.config[n]) && (this.diagnostics.report("config.invalid", `${n} cannot change after startup. The values in force stay.`, { requested: e[n] }), Object.assign(e, { [n]: this.config[n] }));
915
1061
  }
916
1062
  keepBuiltStorage() {
917
1063
  let e = this.storageBuiltAs;
@@ -960,7 +1106,7 @@ var Z = class e {
960
1106
  }
961
1107
  async buildBus() {
962
1108
  try {
963
- let { Bus: e } = await import("./bus-D8kH58tb.js");
1109
+ let { Bus: e } = await import("./bus-HVQ8E72V.js");
964
1110
  if (this.destroyed) return null;
965
1111
  let t = new e(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
966
1112
  onRecords: (e) => {
@@ -984,7 +1130,10 @@ var Z = class e {
984
1130
  return this.bus?.getRole() ?? "sender";
985
1131
  }
986
1132
  syncSender() {
987
- return !(this.config.endpoint || this.config.transport !== void 0) || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
1133
+ return !this.hasDestination() || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
1134
+ }
1135
+ hasDestination() {
1136
+ return !!this.config.endpoint || this.config.transport !== void 0;
988
1137
  }
989
1138
  loadSender() {
990
1139
  return this.senderLoad ??= this.buildSender(), this.senderLoad;
@@ -992,10 +1141,11 @@ var Z = class e {
992
1141
  async buildSender() {
993
1142
  this.storageBuiltAs = this.config.storage;
994
1143
  try {
995
- let { Sender: e } = await import("./sender-BnNj9bOX.js"), t = this.destroyed ? null : await e.create({
1144
+ let { Sender: e } = await import("./sender-BBY0IcUo.js"), t = this.destroyed ? null : await e.create({
996
1145
  config: this.config,
997
1146
  diagnostics: this.diagnostics,
998
1147
  onGap: this.reportGap,
1148
+ onLoss: this.reportLoss,
999
1149
  remote: this.remote
1000
1150
  });
1001
1151
  if (!t || this.destroyed) {
@@ -1004,28 +1154,26 @@ var Z = class e {
1004
1154
  }
1005
1155
  this.sender = t;
1006
1156
  } catch (e) {
1007
- this.senderLoad = void 0, this.diagnostics.report("pipeline.crashed", "The delivery stack did not load. The library does not send records.", { held: this.pendingRecords.length }, e);
1157
+ this.senderLoad = void 0, this.diagnostics.report("pipeline.crashed", "The delivery stack did not load. The library does not send records.", { held: this.pendingRecords.length }, e), this.drops.add("load_failed", this.pendingRecords.records);
1008
1158
  }
1009
- let e = this.pendingRecords;
1010
- this.pendingRecords = [];
1011
- for (let t of e) this.sender?.push(t);
1159
+ for (let e of this.pendingRecords.take()) this.sender?.push(e);
1012
1160
  }
1013
1161
  async installCaptures() {
1014
1162
  if (this.degraded) return;
1015
- let e = ++this.captureGeneration, t = this.config.capture, n = [];
1016
- (t.errors || t.rejections || t.resourceErrors) && n.push("errors"), (t.fetch || t.xhr) && n.push("network"), (t.interactions || t.navigation) && n.push("interactions"), t.webVitals && n.push("webVitals"), t.longFrames && n.push("longFrames"), (Array.isArray(t.console) ? t.console.length > 0 : t.console) && n.push("console");
1017
- let r = await Promise.all(n.map((e) => this.loadCapture(e)));
1163
+ let e = ++this.captureGeneration, t = this.config.capture, r = [];
1164
+ (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");
1165
+ let i = await Promise.all(r.map((e) => this.loadCapture(e)));
1018
1166
  if (e !== this.captureGeneration || this.destroyed) return;
1019
1167
  this.uninstallCaptures();
1020
- let i = {
1168
+ let a = {
1021
1169
  config: this.config,
1022
1170
  diagnostics: this.diagnostics,
1023
1171
  breadcrumbs: this.breadcrumbs,
1024
1172
  tracing: this.tracing,
1025
- logger: new F(() => this, _),
1173
+ logger: new F(() => this, n),
1026
1174
  once: this.captureOnce
1027
1175
  };
1028
- for (let e of r) e && this.captures.push(new e(i));
1176
+ for (let e of i) e && this.captures.push(new e(a));
1029
1177
  for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `The library could not install the ${e.name} capture.`, () => {
1030
1178
  e.install();
1031
1179
  });
@@ -1037,7 +1185,7 @@ var Z = class e {
1037
1185
  this.captures.length = 0;
1038
1186
  }
1039
1187
  loadCapture(e) {
1040
- return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, Qt[e]);
1188
+ return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, mn[e]);
1041
1189
  }
1042
1190
  registerWorker(e) {
1043
1191
  this.destroyed || this.constructBus().then((t) => {
@@ -1050,65 +1198,66 @@ var Z = class e {
1050
1198
  if (this.destroyed) return;
1051
1199
  this.destroyed = !0, this.uninstallCaptures();
1052
1200
  let t = this.sender?.destroy();
1053
- this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.pinned() === this && (Reflect.deleteProperty(globalThis, J), globalThis[Y] = this);
1201
+ this.journey.destroy(), this.sendForwarded(), this.bus?.destroy(), this.drops.add("load_failed", this.pendingRecords.take()), await t, await this.senderLoad, e.pinned() === this && (Reflect.deleteProperty(globalThis, J), globalThis[Y] = this);
1054
1202
  }
1055
1203
  emit(e) {
1056
- e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.pushCapped(this.bootBuffer, e));
1204
+ e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.bootBuffer.push(e));
1057
1205
  }
1058
1206
  route(e) {
1059
1207
  this.role() === "forwarder" ? this.forward(e) : this.deliver(e);
1060
1208
  }
1061
1209
  deliver(e) {
1062
- this.sender ? this.sender.push(e) : this.senderLoad ? this.pushCapped(this.pendingRecords, e) : this.diagnostics.count("record.dropped_no_destination");
1210
+ this.sender ? this.sender.push(e) : this.senderLoad ? this.pendingRecords.push(e) : (this.diagnostics.count("record.dropped_no_destination"), this.hasDestination() && this.drops.add("load_failed", [e]));
1063
1211
  }
1064
- pushCapped(e, t) {
1065
- e.length >= 500 && (e.shift(), this.diagnostics.count("record.dropped_boot_buffer_full")), e.push(t);
1212
+ dropHeld(e) {
1213
+ this.diagnostics.count("record.dropped_boot_buffer_full"), this.drops.add("buffer_full", [e]);
1066
1214
  }
1067
1215
  forward(e) {
1068
1216
  this.forwardBuffer.push(e), !this.forwardScheduled && (this.forwardScheduled = !0, queueMicrotask(() => {
1069
- this.forwardScheduled = !1;
1070
- let e = this.forwardBuffer;
1071
- this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
1217
+ this.forwardScheduled = !1, this.sendForwarded();
1072
1218
  }));
1073
1219
  }
1220
+ sendForwarded() {
1221
+ let e = this.forwardBuffer;
1222
+ this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
1223
+ }
1074
1224
  ingestForwarded(e) {
1075
1225
  if (!Array.isArray(e)) this.diagnostics.count("record.dropped_malformed");
1076
- else for (let t of e) O(t) ? Ee(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
1226
+ else for (let t of e) D(t) ? Oe(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
1077
1227
  }
1078
1228
  releaseBootBuffer() {
1079
- let e = this.bootBuffer;
1080
- this.bootBuffer = [];
1081
- let t = this.journey.current();
1229
+ let e = this.bootBuffer.take(), t = this.journey.current();
1082
1230
  for (let n of e) t && !n.attributes["journey.id"] && (n.attributes["journey.id"] = t.id, n.attributes["journey.name"] = t.name), this.route(n);
1083
1231
  }
1084
- reportGap = (e) => {
1085
- let t = Date.now();
1086
- t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new F(() => this, ce).warn("stored records were dropped before delivery", {
1232
+ reportLoss = (e, t, n) => {
1233
+ this.drops.add(e, t, n);
1234
+ };
1235
+ reportGap = (e, t) => {
1236
+ this.drops.add(e.reason, t.flatMap((e) => e.records), t.map((e) => e.id));
1237
+ let n = Date.now();
1238
+ n - this.lastGapAt < 6e4 || (this.lastGapAt = n, new F(() => this, be).warn("stored records were dropped before delivery", {
1087
1239
  "gap.batches": e.batches,
1088
1240
  "gap.records": e.records,
1089
1241
  "gap.reason": e.reason
1090
1242
  }));
1091
1243
  };
1092
1244
  regenerateTabId() {
1093
- let e = Le(this.diagnostics);
1245
+ let e = Fe(this.diagnostics);
1094
1246
  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.", {
1095
1247
  was: this.identity.tabId,
1096
1248
  now: e
1097
- }), this.identity.tabId = e, Ne(e, this.diagnostics, this.stores), this.builder.invalidateResource();
1249
+ }), this.identity.tabId = e, Pe(e, this.diagnostics, this.stores), this.builder.invalidateResource();
1098
1250
  }
1099
1251
  async queueDepth() {
1100
1252
  return await this.senderLoad, await this.sender?.queueDepth() ?? 0;
1101
1253
  }
1102
1254
  async flush() {
1103
- if (this.ready || await this.started, this.role() === "forwarder") {
1104
- let e = this.forwardBuffer;
1105
- this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
1106
- } else await this.senderLoad, await this.sender?.flush();
1255
+ this.ready || await this.started, this.role() === "forwarder" ? this.sendForwarded() : (await this.senderLoad, await this.sender?.flush());
1107
1256
  }
1108
1257
  };
1109
1258
  //#endregion
1110
1259
  //#region src/transport/memory-transport.ts
1111
- function tn() {
1260
+ function vn() {
1112
1261
  let e = [], t = [], n = { status: 200 };
1113
1262
  return {
1114
1263
  transport: (r) => (e.push(r), n.status >= 200 && n.status < 300 && t.push(r), Promise.resolve({ ...n })),
@@ -1127,100 +1276,100 @@ function tn() {
1127
1276
  }
1128
1277
  //#endregion
1129
1278
  //#region src/index.ts
1130
- var nn = /* @__PURE__ */ new Map();
1279
+ var yn = /* @__PURE__ */ new Map();
1131
1280
  function Q() {
1132
- return (Z.current() ?? Z.stopped()) || Z.configure({});
1281
+ return (Z.current() ?? Z.stopped()) || Z.configure({}, !0);
1133
1282
  }
1134
- function rn(e) {
1283
+ function bn(e) {
1135
1284
  Z.configure(e);
1136
1285
  }
1137
- function an(e, t) {
1286
+ function xn(e, t) {
1138
1287
  if (t) return new F(Q, e, t);
1139
- let n = nn.get(e);
1140
- return n || (n = new F(Q, e), nn.set(e, n)), n;
1288
+ let n = yn.get(e);
1289
+ return n || (n = new F(Q, e), yn.set(e, n)), n;
1141
1290
  }
1142
1291
  function $() {
1143
- return an("app");
1292
+ return xn("app");
1144
1293
  }
1145
- function on(e, t) {
1294
+ function Sn(e, t) {
1146
1295
  $().trace(e, t);
1147
1296
  }
1148
- function sn(e, t) {
1297
+ function Cn(e, t) {
1149
1298
  $().debug(e, t);
1150
1299
  }
1151
- function cn(e, t) {
1300
+ function wn(e, t) {
1152
1301
  $().info(e, t);
1153
1302
  }
1154
- function ln(e, t) {
1303
+ function Tn(e, t) {
1155
1304
  $().warn(e, t);
1156
1305
  }
1157
- function un(e, t, n) {
1306
+ function En(e, t, n) {
1158
1307
  $().error(e, t, n);
1159
1308
  }
1160
- function dn(e, t, n) {
1309
+ function Dn(e, t, n) {
1161
1310
  $().fatal(e, t, n);
1162
1311
  }
1163
- function fn(e, t) {
1312
+ function On(e, t) {
1164
1313
  $().logAction(e, t);
1165
1314
  }
1166
- function pn(e, t) {
1315
+ function kn(e, t) {
1167
1316
  $().logEvent(e, t);
1168
1317
  }
1169
- function mn(e, t, n, r, i) {
1318
+ function An(e, t, n, r, i) {
1170
1319
  $().logMetric(e, t, n, r, i);
1171
1320
  }
1172
- function hn(e, t, n) {
1321
+ function jn(e, t, n) {
1173
1322
  return $().timeSync(e, t, n);
1174
1323
  }
1175
- function gn(e, t, n) {
1324
+ function Mn(e, t, n) {
1176
1325
  return $().timeAsync(e, t, n);
1177
1326
  }
1178
- function _n(e, t) {
1327
+ function Nn(e, t) {
1179
1328
  Q().context.set(e, t);
1180
1329
  }
1181
- function vn(e) {
1330
+ function Pn(e) {
1182
1331
  Q().context.setMany(e);
1183
1332
  }
1184
- function yn(e) {
1333
+ function Fn(e) {
1185
1334
  Q().context.remove(e);
1186
1335
  }
1187
- function bn(e, t) {
1336
+ function In(e, t) {
1188
1337
  return Q().journey.start(e, t);
1189
1338
  }
1190
- function xn() {
1339
+ function Ln() {
1191
1340
  Q().journey.end();
1192
1341
  }
1193
- function Sn() {
1342
+ function Rn() {
1194
1343
  return Q().journey.current();
1195
1344
  }
1196
- function Cn() {
1345
+ function zn() {
1197
1346
  return Q().journey.getToken();
1198
1347
  }
1199
- function wn(e) {
1348
+ function Bn(e) {
1200
1349
  return Q().journey.adopt(e, "manual", !0);
1201
1350
  }
1202
- function Tn(e) {
1351
+ function Vn(e) {
1203
1352
  Q().registerWorker(e);
1204
1353
  }
1205
- function En() {
1354
+ function Hn() {
1206
1355
  Q().tracing.rotate("explicit");
1207
1356
  }
1208
- function Dn() {
1357
+ function Un() {
1209
1358
  return Q().tracing.headers();
1210
1359
  }
1211
- function On() {
1360
+ function Wn() {
1212
1361
  return Q().flush();
1213
1362
  }
1214
- function kn() {
1363
+ function Gn() {
1215
1364
  return Q().queueDepth();
1216
1365
  }
1217
- function An() {
1366
+ function Kn() {
1218
1367
  return Q().diagnostics.snapshot();
1219
1368
  }
1220
- async function jn() {
1369
+ async function qn() {
1221
1370
  await Z.current()?.destroy();
1222
1371
  }
1223
1372
  //#endregion
1224
- export { F as OneLogger, wn as adoptJourney, rn as configure, tn as createMemoryTransport, Sn as currentJourney, sn as debug, xn as endJourney, un as error, dn as fatal, On as flush, An as getDiagnosticCounters, Cn as getJourneyToken, an as getLogger, kn as getQueueDepth, Dn as getTraceHeaders, cn as info, fn as logAction, pn as logEvent, mn as logMetric, Tn as registerWorker, yn as removeContext, _n as setContext, vn as setContextMap, jn as shutdown, bn as startJourney, En as startTrace, gn as timeAsync, hn as timeSync, on as trace, ln as warn };
1373
+ export { F as OneLogger, Bn as adoptJourney, bn as configure, vn as createMemoryTransport, Rn as currentJourney, Cn as debug, Ln as endJourney, En as error, Dn as fatal, Wn as flush, Kn as getDiagnosticCounters, zn as getJourneyToken, xn as getLogger, Gn as getQueueDepth, Un as getTraceHeaders, wn as info, On as logAction, kn as logEvent, An as logMetric, Vn as registerWorker, Fn as removeContext, Nn as setContext, Pn as setContextMap, qn as shutdown, In as startJourney, Hn as startTrace, Mn as timeAsync, jn as timeSync, Sn as trace, Tn as warn };
1225
1374
 
1226
1375
  //# sourceMappingURL=index.js.map