@utk09/ui-observability 0.9.0 → 0.9.2

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