@utk09/ui-observability 0.9.3 → 0.9.5

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 (227) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +199 -96
  3. package/dist/batch-BQFtb3i5.cjs +2 -0
  4. package/dist/batch-BQFtb3i5.cjs.map +1 -0
  5. package/dist/{batch-DDgxg16_.js → batch-BUJh-1jZ.js} +6 -4
  6. package/dist/batch-BUJh-1jZ.js.map +1 -0
  7. package/dist/bus/bus.d.ts +76 -2
  8. package/dist/bus/links.d.ts +9 -2
  9. package/dist/bus/validation.d.ts +7 -0
  10. package/dist/bus-BW6N-pY8.cjs +2 -0
  11. package/dist/bus-BW6N-pY8.cjs.map +1 -0
  12. package/dist/bus-DeOPHWaD.js +647 -0
  13. package/dist/bus-DeOPHWaD.js.map +1 -0
  14. package/dist/capture/network.d.ts +1 -0
  15. package/dist/capture/storm.d.ts +2 -1
  16. package/dist/capture/types.d.ts +5 -0
  17. package/dist/capture/web-socket.d.ts +40 -0
  18. package/dist/{console-BSusX_M-.cjs → console-Ce6heqZZ.cjs} +2 -2
  19. package/dist/console-Ce6heqZZ.cjs.map +1 -0
  20. package/dist/{console-Dv5GfaNn.js → console-DbAZYJuy.js} +4 -4
  21. package/dist/console-DbAZYJuy.js.map +1 -0
  22. package/dist/constants-CN7GE1Lt.js +246 -0
  23. package/dist/constants-CN7GE1Lt.js.map +1 -0
  24. package/dist/constants-CW-MlHdY.cjs +2 -0
  25. package/dist/constants-CW-MlHdY.cjs.map +1 -0
  26. package/dist/constants.d.ts +63 -11
  27. package/dist/context-storage-BjzeBSxH.cjs +2 -0
  28. package/dist/context-storage-BjzeBSxH.cjs.map +1 -0
  29. package/dist/context-storage-DxZf4Gfh.js +52 -0
  30. package/dist/context-storage-DxZf4Gfh.js.map +1 -0
  31. package/dist/core/breadcrumbs.d.ts +10 -3
  32. package/dist/core/context.d.ts +2 -0
  33. package/dist/core/diagnostics.d.ts +11 -3
  34. package/dist/core/journey.d.ts +7 -0
  35. package/dist/core/meter.d.ts +25 -2
  36. package/dist/core/pipeline.d.ts +41 -6
  37. package/dist/core/record.d.ts +42 -9
  38. package/dist/core/remote-sampling.d.ts +7 -3
  39. package/dist/core/runtime.d.ts +153 -6
  40. package/dist/core/sampling.d.ts +35 -2
  41. package/dist/core/sender.d.ts +43 -1
  42. package/dist/core/spans.d.ts +34 -0
  43. package/dist/deadline-5_PecIl5.js +26 -0
  44. package/dist/deadline-5_PecIl5.js.map +1 -0
  45. package/dist/deadline-XSnm95pg.cjs +2 -0
  46. package/dist/deadline-XSnm95pg.cjs.map +1 -0
  47. package/dist/emergency-queue-BYUyDHGD.js +69 -0
  48. package/dist/emergency-queue-BYUyDHGD.js.map +1 -0
  49. package/dist/emergency-queue-Cs1hrjsC.cjs +2 -0
  50. package/dist/emergency-queue-Cs1hrjsC.cjs.map +1 -0
  51. package/dist/{errors-DCZWcHkd.js → errors-BhC7HTSt.js} +8 -9
  52. package/dist/errors-BhC7HTSt.js.map +1 -0
  53. package/dist/errors-CgY633cG.cjs +3 -0
  54. package/dist/errors-CgY633cG.cjs.map +1 -0
  55. package/dist/factory-C5TujXlU.js +280 -0
  56. package/dist/factory-C5TujXlU.js.map +1 -0
  57. package/dist/factory-CNj4DH3n.cjs +2 -0
  58. package/dist/factory-CNj4DH3n.cjs.map +1 -0
  59. package/dist/fixed-window-CtaFHanJ.js +12 -0
  60. package/dist/fixed-window-CtaFHanJ.js.map +1 -0
  61. package/dist/fixed-window-CvESpFYV.cjs +2 -0
  62. package/dist/fixed-window-CvESpFYV.cjs.map +1 -0
  63. package/dist/identity-8vKkyAWm.js +103 -0
  64. package/dist/identity-8vKkyAWm.js.map +1 -0
  65. package/dist/identity-Da9TkuKd.cjs +2 -0
  66. package/dist/identity-Da9TkuKd.cjs.map +1 -0
  67. package/dist/index.cjs +1 -1
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.ts +66 -6
  70. package/dist/index.js +1253 -595
  71. package/dist/index.js.map +1 -1
  72. package/dist/indexeddb-storage-BTfIFRHF.cjs +2 -0
  73. package/dist/indexeddb-storage-BTfIFRHF.cjs.map +1 -0
  74. package/dist/{indexeddb-storage-T9YIYVYC.js → indexeddb-storage-CCA1LvtO.js} +45 -30
  75. package/dist/indexeddb-storage-CCA1LvtO.js.map +1 -0
  76. package/dist/{interactions-BLH_tX87.js → interactions-BUDLxbv1.js} +16 -12
  77. package/dist/interactions-BUDLxbv1.js.map +1 -0
  78. package/dist/interactions-NHbLKrqe.cjs +2 -0
  79. package/dist/interactions-NHbLKrqe.cjs.map +1 -0
  80. package/dist/{journey-yALMEWF7.js → journey-BUJ4WJxP.js} +37 -34
  81. package/dist/journey-BUJ4WJxP.js.map +1 -0
  82. package/dist/journey-B_tTnvac.cjs +2 -0
  83. package/dist/journey-B_tTnvac.cjs.map +1 -0
  84. package/dist/keys-BHhw_0Wh.cjs +2 -0
  85. package/dist/keys-BHhw_0Wh.cjs.map +1 -0
  86. package/dist/keys-D5r_GH9q.js +17 -0
  87. package/dist/keys-D5r_GH9q.js.map +1 -0
  88. package/dist/{library-request-CQD4HUiP.js → library-request-BKOcaKtQ.js} +3 -3
  89. package/dist/{library-request-CQD4HUiP.js.map → library-request-BKOcaKtQ.js.map} +1 -1
  90. package/dist/{library-request-BcAxuwsf.cjs → library-request-BaZOi4eg.cjs} +2 -2
  91. package/dist/{library-request-BcAxuwsf.cjs.map → library-request-BaZOi4eg.cjs.map} +1 -1
  92. package/dist/{long-frames-D4Bm3Zkz.cjs → long-frames-CF3qiSAX.cjs} +2 -2
  93. package/dist/long-frames-CF3qiSAX.cjs.map +1 -0
  94. package/dist/{long-frames-DD_Um9_4.js → long-frames-DI5ypfAF.js} +5 -5
  95. package/dist/long-frames-DI5ypfAF.js.map +1 -0
  96. package/dist/models/batch.d.ts +4 -0
  97. package/dist/models/bus.d.ts +32 -9
  98. package/dist/models/config.d.ts +401 -12
  99. package/dist/models/drop.d.ts +1 -1
  100. package/dist/models/health.d.ts +27 -0
  101. package/dist/models/log-record.d.ts +1 -1
  102. package/dist/models/plugin.d.ts +47 -0
  103. package/dist/models/stats.d.ts +11 -0
  104. package/dist/models/storage.d.ts +13 -0
  105. package/dist/network-CF8UO5PK.cjs +2 -0
  106. package/dist/network-CF8UO5PK.cjs.map +1 -0
  107. package/dist/{network--GoE7_Or.js → network-DdzXDI3J.js} +47 -31
  108. package/dist/network-DdzXDI3J.js.map +1 -0
  109. package/dist/openfin-BwEN0uj4.js.map +1 -1
  110. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  111. package/dist/{platform-GaM6h7XM.js → platform-Bw1btWCT.js} +21 -10
  112. package/dist/platform-Bw1btWCT.js.map +1 -0
  113. package/dist/platform-DBSKTvFn.cjs +2 -0
  114. package/dist/platform-DBSKTvFn.cjs.map +1 -0
  115. package/dist/remote-rules-DIcC5vVC.js +91 -0
  116. package/dist/remote-rules-DIcC5vVC.js.map +1 -0
  117. package/dist/remote-rules-DpFmOef2.cjs +2 -0
  118. package/dist/remote-rules-DpFmOef2.cjs.map +1 -0
  119. package/dist/sampling-BVjspJWu.cjs +2 -0
  120. package/dist/sampling-BVjspJWu.cjs.map +1 -0
  121. package/dist/sampling-Cm3WhI0a.js +76 -0
  122. package/dist/sampling-Cm3WhI0a.js.map +1 -0
  123. package/dist/{sanitize-DP0xDPrt.js → sanitize-C-ahCFsG.js} +2 -2
  124. package/dist/{sanitize-DP0xDPrt.js.map → sanitize-C-ahCFsG.js.map} +1 -1
  125. package/dist/{sanitize--_e4oOPX.cjs → sanitize-DHucKGdi.cjs} +2 -2
  126. package/dist/{sanitize--_e4oOPX.cjs.map → sanitize-DHucKGdi.cjs.map} +1 -1
  127. package/dist/sender-D3fRCR8d.cjs +3 -0
  128. package/dist/sender-D3fRCR8d.cjs.map +1 -0
  129. package/dist/sender-DUUmSglb.js +1163 -0
  130. package/dist/sender-DUUmSglb.js.map +1 -0
  131. package/dist/storage/context-storage.d.ts +89 -0
  132. package/dist/storage/emergency-queue.d.ts +9 -1
  133. package/dist/storage/factory.d.ts +7 -1
  134. package/dist/storage/idb-driver.d.ts +13 -0
  135. package/dist/storage/indexeddb-storage.d.ts +13 -0
  136. package/dist/storage/local-storage.d.ts +21 -1
  137. package/dist/storage/memory-storage.d.ts +13 -0
  138. package/dist/storage-BA9RqRO-.cjs +2 -0
  139. package/dist/storage-BA9RqRO-.cjs.map +1 -0
  140. package/dist/storage-w7Tslvlq.js +17 -0
  141. package/dist/storage-w7Tslvlq.js.map +1 -0
  142. package/dist/storm-CNZjsw4T.cjs +2 -0
  143. package/dist/storm-CNZjsw4T.cjs.map +1 -0
  144. package/dist/storm-Daq2jGHU.js +10 -0
  145. package/dist/storm-Daq2jGHU.js.map +1 -0
  146. package/dist/transport/exit-flush.d.ts +6 -0
  147. package/dist/transport/http-transport.d.ts +2 -1
  148. package/dist/transport/retry-engine.d.ts +7 -2
  149. package/dist/transport/serializers/otlp-traces.d.ts +3 -0
  150. package/dist/transport/serializers/select.d.ts +8 -5
  151. package/dist/transport/status-transport.d.ts +24 -0
  152. package/dist/types-BR9t_w28.js +8 -0
  153. package/dist/types-BR9t_w28.js.map +1 -0
  154. package/dist/types-C7WNpnG1.cjs +2 -0
  155. package/dist/types-C7WNpnG1.cjs.map +1 -0
  156. package/dist/utils/fixed-window.d.ts +9 -0
  157. package/dist/utils/identity.d.ts +20 -2
  158. package/dist/utils/lock.d.ts +8 -0
  159. package/dist/utils/openfin.d.ts +1 -1
  160. package/dist/utils/platform.d.ts +10 -0
  161. package/dist/utils/tracing.d.ts +82 -4
  162. package/dist/web-socket-BacvKOvD.cjs +2 -0
  163. package/dist/web-socket-BacvKOvD.cjs.map +1 -0
  164. package/dist/web-socket-CpsD8WAa.js +105 -0
  165. package/dist/web-socket-CpsD8WAa.js.map +1 -0
  166. package/package.json +1 -1
  167. package/dist/batch-D5qvsMQ_.cjs +0 -2
  168. package/dist/batch-D5qvsMQ_.cjs.map +0 -1
  169. package/dist/batch-DDgxg16_.js.map +0 -1
  170. package/dist/bus-C6RwKzPW.js +0 -478
  171. package/dist/bus-C6RwKzPW.js.map +0 -1
  172. package/dist/bus-WPVDFw2y.cjs +0 -2
  173. package/dist/bus-WPVDFw2y.cjs.map +0 -1
  174. package/dist/console-BSusX_M-.cjs.map +0 -1
  175. package/dist/console-Dv5GfaNn.js.map +0 -1
  176. package/dist/constants-Cb92egPS.cjs +0 -2
  177. package/dist/constants-Cb92egPS.cjs.map +0 -1
  178. package/dist/constants-DhH6VI5a.js +0 -144
  179. package/dist/constants-DhH6VI5a.js.map +0 -1
  180. package/dist/deadline-CUrH0Hd8.cjs +0 -2
  181. package/dist/deadline-CUrH0Hd8.cjs.map +0 -1
  182. package/dist/deadline-DeqXEliN.js +0 -31
  183. package/dist/deadline-DeqXEliN.js.map +0 -1
  184. package/dist/errors-DCZWcHkd.js.map +0 -1
  185. package/dist/errors-ERu-su8m.cjs +0 -3
  186. package/dist/errors-ERu-su8m.cjs.map +0 -1
  187. package/dist/fixed-window-BR0bu32Y.cjs +0 -2
  188. package/dist/fixed-window-BR0bu32Y.cjs.map +0 -1
  189. package/dist/fixed-window-Re7jIRJH.js +0 -9
  190. package/dist/fixed-window-Re7jIRJH.js.map +0 -1
  191. package/dist/identity-C1WLItSl.cjs +0 -2
  192. package/dist/identity-C1WLItSl.cjs.map +0 -1
  193. package/dist/identity-Di-QXGCC.js +0 -88
  194. package/dist/identity-Di-QXGCC.js.map +0 -1
  195. package/dist/indexeddb-storage-DX18p39D.cjs +0 -2
  196. package/dist/indexeddb-storage-DX18p39D.cjs.map +0 -1
  197. package/dist/indexeddb-storage-T9YIYVYC.js.map +0 -1
  198. package/dist/interactions-BLH_tX87.js.map +0 -1
  199. package/dist/interactions-_hfOerfC.cjs +0 -2
  200. package/dist/interactions-_hfOerfC.cjs.map +0 -1
  201. package/dist/journey-BRUj0hqD.cjs +0 -2
  202. package/dist/journey-BRUj0hqD.cjs.map +0 -1
  203. package/dist/journey-yALMEWF7.js.map +0 -1
  204. package/dist/long-frames-D4Bm3Zkz.cjs.map +0 -1
  205. package/dist/long-frames-DD_Um9_4.js.map +0 -1
  206. package/dist/network--GoE7_Or.js.map +0 -1
  207. package/dist/network-DcuS2H1P.cjs +0 -2
  208. package/dist/network-DcuS2H1P.cjs.map +0 -1
  209. package/dist/platform-GaM6h7XM.js.map +0 -1
  210. package/dist/platform-kIL5AZB7.cjs +0 -2
  211. package/dist/platform-kIL5AZB7.cjs.map +0 -1
  212. package/dist/remote-rules-6ePq8CrI.js +0 -84
  213. package/dist/remote-rules-6ePq8CrI.js.map +0 -1
  214. package/dist/remote-rules-CI3gbRCL.cjs +0 -2
  215. package/dist/remote-rules-CI3gbRCL.cjs.map +0 -1
  216. package/dist/sampling-C-M8p3FK.cjs +0 -2
  217. package/dist/sampling-C-M8p3FK.cjs.map +0 -1
  218. package/dist/sampling-Ud_WiuU9.js +0 -65
  219. package/dist/sampling-Ud_WiuU9.js.map +0 -1
  220. package/dist/sender-BESHz6my.cjs +0 -3
  221. package/dist/sender-BESHz6my.cjs.map +0 -1
  222. package/dist/sender-BUBWLn5i.js +0 -1244
  223. package/dist/sender-BUBWLn5i.js.map +0 -1
  224. package/dist/storm-DhHGHhOc.cjs +0 -2
  225. package/dist/storm-DhHGHhOc.cjs.map +0 -1
  226. package/dist/storm-OD5J6Ylm.js +0 -10
  227. package/dist/storm-OD5J6Ylm.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,55 +1,55 @@
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-DhH6VI5a.js";
2
- import { n as Te, r as Ee, t as De } from "./error-like-Ywo5uRHo.js";
3
- import { i as Oe, r as ke } from "./deadline-DeqXEliN.js";
4
- import { a as Ae, i as je, n as Me, o as Ne, r as Pe } from "./sampling-Ud_WiuU9.js";
5
- import { a as Fe, i as Ie, n as Le, o as A, r as j } from "./sanitize-DP0xDPrt.js";
6
- import { a as Re, i as ze, n as Be, o as Ve, r as He, s as Ue, t as We } from "./identity-Di-QXGCC.js";
7
- import { i as Ge, n as Ke, t as qe } from "./platform-GaM6h7XM.js";
8
- import { r as M, t as Je } from "./batch-DDgxg16_.js";
9
- import { r as Ye } from "./library-request-CQD4HUiP.js";
10
- import { n as Xe, t as Ze } from "./journey-yALMEWF7.js";
1
+ import { $t as e, Bt as t, C as n, Ct as r, En as i, Ft as a, Gt as o, Ht as s, Jt as c, Kt as l, L as u, M as d, N as f, Qt as p, R as m, St as h, Tn as g, Ut as _, V as v, Vt as y, Wt as ee, Xt as te, Yt as ne, Zt as re, _n as ie, a as ae, an as oe, bn as se, c as b, d as x, f as ce, gn as le, gt as ue, h as de, i as fe, j as pe, k as me, l as he, ln as ge, m as _e, mt as S, o as C, on as w, p as ve, pt as ye, qt as be, r as T, s as xe, tn as E, u as Se, vn as D, wn as Ce, wt as we, xn as Te, yn as Ee, z as De, zt as Oe } from "./constants-CN7GE1Lt.js";
2
+ import { n as ke, r as Ae, t as je } from "./error-like-Ywo5uRHo.js";
3
+ import { a as Me, c as Ne, i as Pe, l as Fe, n as Ie, o as Le, s as Re, u as O } from "./sampling-Cm3WhI0a.js";
4
+ import { r as ze } from "./deadline-5_PecIl5.js";
5
+ import { a as Be, i as Ve, n as He, o as k, r as A } from "./sanitize-C-ahCFsG.js";
6
+ import { a as Ue, i as j, n as We, o as Ge, r as Ke, s as qe, t as Je } from "./identity-8vKkyAWm.js";
7
+ import { r as Ye } from "./library-request-BKOcaKtQ.js";
8
+ import { i as Xe, n as Ze, t as Qe } from "./platform-Bw1btWCT.js";
9
+ import { r as $e, t as et } from "./batch-BUJh-1jZ.js";
10
+ import { n as tt, t as nt } from "./journey-BUJ4WJxP.js";
11
11
  //#region src/utils/timer.ts
12
- function N(e) {
13
- return Math.round((performance.now() - e) * Ce) / Ce;
12
+ function M(e) {
13
+ return Math.round((performance.now() - e) * v) / v;
14
14
  }
15
- function P(e, t, n, r, i) {
15
+ function N(e, t, n, r, i) {
16
16
  e.logMetric(`${t}.duration`, n, "ms", "histogram", {
17
17
  status: r,
18
18
  ...i
19
19
  });
20
20
  }
21
- function Qe(e, t, n, r, i) {
22
- let a = N(n);
21
+ function rt(e, t, n, r, i) {
22
+ let a = M(n);
23
23
  e.error(`${t} failed`, r, {
24
24
  "action.duration_ms": a,
25
25
  status: "FAILURE",
26
26
  ...i
27
- }), P(e, t, a, "FAILURE", i);
27
+ }), N(e, t, a, "FAILURE", i);
28
28
  }
29
- function $e(e, t, n, r) {
29
+ function it(e, t, n, r) {
30
30
  let i = performance.now();
31
31
  try {
32
32
  let a = n();
33
- return P(e, t, N(i), "SUCCESS", r), a;
33
+ return N(e, t, M(i), "SUCCESS", r), a;
34
34
  } catch (n) {
35
- throw Qe(e, t, i, n, r), n;
35
+ throw rt(e, t, i, n, r), n;
36
36
  }
37
37
  }
38
- async function et(e, t, n, r) {
38
+ async function at(e, t, n, r) {
39
39
  let i = performance.now();
40
40
  try {
41
41
  let a = await n();
42
- return P(e, t, N(i), "SUCCESS", r), a;
42
+ return N(e, t, M(i), "SUCCESS", r), a;
43
43
  } catch (n) {
44
- throw Qe(e, t, i, n, r), n;
44
+ throw rt(e, t, i, n, r), n;
45
45
  }
46
46
  }
47
47
  //#endregion
48
48
  //#region src/core/logger.ts
49
- var tt = [i, ye];
50
- function nt(e, t) {
49
+ var ot = [me, ge];
50
+ function st(e, t) {
51
51
  let n = t.guard("record.sanitize_failed", "The library could not read the error reason.", () => {
52
- if (!(e instanceof Error) && !Ee(e)) return;
52
+ if (!(e instanceof Error) && !Ae(e)) return;
53
53
  let t = Error(e.message);
54
54
  return t.name = e.name, t.stack = e.stack, t;
55
55
  });
@@ -57,38 +57,38 @@ function nt(e, t) {
57
57
  let r = t.guard("record.sanitize_failed", "The library could not convert the error reason to text.", () => String(e));
58
58
  return Error(r ?? typeof e);
59
59
  }
60
- function rt(e, t, n) {
60
+ function ct(e, t, n) {
61
61
  return n.guard("record.sanitize_failed", "The library could not read the error reason.", () => e instanceof Error ? e : t) ?? t;
62
62
  }
63
- function it(e, t) {
63
+ function lt(e, t) {
64
64
  if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" || typeof e == "symbol") return e;
65
65
  if (typeof e == "object" && e) return t.guard("record.sanitize_failed", "The library could not read the properties of the error reason.", () => {
66
- let t = e, n = Ee(e), r = {}, i = 0;
66
+ let t = e, n = Ae(e), r = {}, i = 0;
67
67
  for (let e of Object.keys(t)) {
68
68
  let a = t[e];
69
- (!n || !De.has(e)) && Te(a) && (r[e] = a, i++);
69
+ (!n || !je.has(e)) && ke(a) && (r[e] = a, i++);
70
70
  }
71
71
  return i === 0 ? void 0 : r;
72
72
  });
73
73
  }
74
- function at(e) {
75
- if (!Oe(e) || e instanceof Error) return !1;
74
+ function ut(e) {
75
+ if (!O(e) || e instanceof Error) return !1;
76
76
  let t = Object.getPrototypeOf(e);
77
77
  return t === null || Object.getPrototypeOf(t) === null;
78
78
  }
79
- function ot(e) {
80
- return tt.some((t) => e === t || e.startsWith(`${t}.`)) ? "system" : "log";
79
+ function dt(e) {
80
+ return ot.some((t) => e === t || e.startsWith(`${t}.`)) ? "system" : "log";
81
81
  }
82
- function F(e, t) {
82
+ function P(e, t) {
83
83
  return e === void 0 ? {} : t.guard("record.sanitize_failed", "The library could not read the payload.", () => ({ ...e })) ?? { "uiobs.sanitize_failed": !0 };
84
84
  }
85
- var I = class e {
85
+ var F = class e {
86
86
  bind;
87
87
  namespace;
88
88
  options;
89
89
  levelType;
90
90
  constructor(e, t, n = {}) {
91
- this.bind = e, this.namespace = t, this.options = n, this.levelType = ot(t);
91
+ this.bind = e, this.namespace = t, this.options = n, this.levelType = dt(t);
92
92
  }
93
93
  child(t, n = {}) {
94
94
  return new e(this.bind, `${this.namespace}.${t}`, { scopedContext: {
@@ -120,147 +120,316 @@ var I = class e {
120
120
  logEvent = (e, t) => {
121
121
  this.write("INFO", "event", e, t);
122
122
  };
123
- logMetric = (e, t, n = l, r = "gauge", i) => {
123
+ logMetric = (e, t, n = m, i = "gauge", a) => {
124
124
  if (!Number.isFinite(t)) {
125
125
  this.bind().diagnostics.report("record.dropped_malformed", "The metric value is not a finite number. The library dropped the metric.", { "metric.name": e });
126
126
  return;
127
127
  }
128
- let a = F(i, this.bind().diagnostics), o = {
129
- ...a,
128
+ let o = P(a, this.bind().diagnostics), s = {
129
+ ...o,
130
130
  "metric.name": e,
131
131
  "metric.value": t,
132
132
  "metric.unit": n,
133
- "metric.type": r,
134
- [k.attributeKeys]: Object.keys(a)
133
+ "metric.type": i,
134
+ [r.attributeKeys]: Object.keys(o)
135
135
  };
136
- this.write("INFO", "metric", e, o, !0);
136
+ this.write("INFO", "metric", e, s, !0);
137
137
  };
138
- timeSync = (e, t, n) => $e(this, e, t, n);
139
- timeAsync = (e, t, n) => et(this, e, t, n);
138
+ timeSync = (e, t, n) => it(this, e, t, n);
139
+ timeAsync = (e, t, n) => at(this, e, t, n);
140
140
  write(e, t, n, r, i = !1) {
141
141
  let a = this.bind();
142
142
  if (a.isDestroyed()) return;
143
- if (!a.builder.isEnabled(e, t)) {
143
+ if (a.isRotating()) {
144
+ a.diagnostics.count("record.dropped_during_rotation");
145
+ return;
146
+ }
147
+ if (!a.builder.isEnabled(e, this.namespace, t)) {
144
148
  this.mirrors(a, e) && this.print(a, e, n, r, void 0, null);
145
149
  return;
146
150
  }
147
- let { record: o, dropped: s } = a.builder.build({
151
+ let o = {
148
152
  level: e,
149
153
  type: t,
150
154
  body: n,
151
155
  namespace: this.namespace,
152
156
  scoped: this.options.scopedContext,
153
- payload: i ? r : F(r, a.diagnostics)
154
- }), c = o ? o.body : s === "sampling" ? n : void 0;
155
- t !== "metric" && c !== void 0 && a.breadcrumbs.push({
157
+ payload: i ? r : P(r, a.diagnostics)
158
+ }, { record: s, dropped: c } = a.builder.build(o), l = !!a.config.redact || a.config.processors.length > 0, u = t !== "metric" && a.config.capturePolicy.breadcrumbs > 0, d = c === "sampling" && l && u ? a.builder.build(o, !0) : void 0, f = s ?? d?.record ?? null, p = f ? f.body : c === "sampling" && !l ? n : void 0;
159
+ u && p !== void 0 && a.breadcrumbs.push({
156
160
  t: Date.now(),
157
161
  category: t === "action" ? "action" : t === "event" ? "event" : "log",
158
- message: c
159
- }), this.print(a, e, n, r, void 0, o, s), a.emit(o);
162
+ message: p
163
+ }), this.print(a, e, n, r, void 0, f, d?.dropped ?? c), a.emit(s);
160
164
  }
161
165
  writeError(e, t, n, r) {
162
166
  let i = this.bind();
163
167
  if (i.isDestroyed()) return;
164
- let a = i.builder.isEnabled(e);
168
+ if (i.isRotating()) {
169
+ i.diagnostics.count("record.dropped_during_rotation");
170
+ return;
171
+ }
172
+ let a = i.builder.isEnabled(e, this.namespace);
165
173
  if (!a && !this.mirrors(i, e)) return;
166
- let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () => at(n)) ?? !1), s = o ? n : r, c = o ? void 0 : n, l = c === void 0 ? void 0 : nt(c, i.diagnostics), u = l === void 0 ? void 0 : rt(c, l, i.diagnostics);
174
+ let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () => ut(n)) ?? !1), s = o ? n : r, c = o ? void 0 : n, l = c === void 0 ? void 0 : st(c, i.diagnostics), u = l === void 0 ? void 0 : ct(c, l, i.diagnostics);
167
175
  if (!a) {
168
176
  this.print(i, e, t, s, u, null);
169
177
  return;
170
178
  }
171
- let d = l ? it(c, i.diagnostics) : void 0, { record: f, dropped: p } = i.builder.build({
179
+ let d = l ? lt(c, i.diagnostics) : void 0, { record: f, dropped: p } = i.builder.build({
172
180
  level: e,
173
181
  type: this.levelType,
174
182
  body: t,
175
183
  namespace: this.namespace,
176
184
  scoped: this.options.scopedContext,
177
185
  payload: {
178
- ...F(s, i.diagnostics),
186
+ ...P(s, i.diagnostics),
179
187
  ...l ? {
180
188
  "error.type": l.name,
181
189
  "error.message": l.message,
182
190
  "error.stack_trace": l.stack
183
191
  } : {},
184
- ...d === void 0 ? {} : { [ge]: d },
185
- [v]: i.breadcrumbs.snapshot()
192
+ ...d === void 0 ? {} : { [xe]: d },
193
+ [C]: i.breadcrumbs.snapshot()
186
194
  }
187
195
  });
188
196
  this.print(i, e, t, s, u, f, p), i.emit(f);
189
197
  }
190
198
  print(e, t, n, r, i, a, o) {
191
- e.config.redact ? a ? e.console.write(this.namespace, t, a.body, a.attributes) : o !== "redact" && o !== "malformed" && e.console.write(this.namespace, t, n, void 0, i) : e.console.write(this.namespace, t, n, r, i);
199
+ if (!e.config.redact && e.config.processors.length === 0) {
200
+ e.console.write(this.namespace, t, n, r, i);
201
+ return;
202
+ }
203
+ if (a) {
204
+ e.console.write(this.namespace, t, a.body, a.attributes);
205
+ return;
206
+ }
207
+ if (o === "processor" || o === "redact" || o === "malformed" || !e.config.enabled || !e.console.accepts(t)) return;
208
+ let s = e.builder.build({
209
+ level: t,
210
+ type: this.levelType,
211
+ body: n,
212
+ namespace: this.namespace,
213
+ scoped: this.options.scopedContext,
214
+ payload: {
215
+ ...P(r, e.diagnostics),
216
+ ...i ? {
217
+ "error.type": i.name,
218
+ "error.message": i.message,
219
+ "error.stack_trace": i.stack
220
+ } : {}
221
+ }
222
+ }, !0).record;
223
+ s && e.console.write(this.namespace, t, s.body, s.attributes);
192
224
  }
193
225
  mirrors(e, t) {
194
226
  return e.config.enabled && e.console.accepts(t);
195
227
  }
196
- }, st = {
228
+ }, ft = "overflow", pt = /* @__PURE__ */ new Set([
229
+ ce,
230
+ x,
231
+ T,
232
+ _e,
233
+ b,
234
+ he,
235
+ Se
236
+ ]);
237
+ function mt(e = {}) {
238
+ let t = {};
239
+ for (let n of Object.keys(e).sort()) {
240
+ if (n.startsWith("metric.") || pt.has(n)) continue;
241
+ let r = e[n];
242
+ (typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) && (t[n] = r);
243
+ }
244
+ return t;
245
+ }
246
+ function ht(e, t) {
247
+ if (!Array.isArray(e)) return null;
248
+ let n = t === 0 ? e.length : Math.min(e.length, t + 1);
249
+ return Array.from({ length: n }, (t, n) => e[n]);
250
+ }
251
+ function gt(e, t) {
252
+ return Array.isArray(e) && (t === 0 || e.length <= t) && e.every((t, n) => typeof t == "number" && Number.isFinite(t) && (n === 0 || t > e[n - 1]));
253
+ }
254
+ function _t(e, t, n) {
255
+ let i = {
256
+ "metric.name": e.name,
257
+ "metric.unit": e.unit,
258
+ "metric.type": e.kind,
259
+ [r.start]: n,
260
+ [r.attributeKeys]: Object.keys(t.attributes)
261
+ };
262
+ return e.kind === "counter" ? (i["metric.value"] = t.sum, i) : {
263
+ ...i,
264
+ [r.count]: t.count,
265
+ [r.sum]: t.sum,
266
+ [r.min]: t.min,
267
+ [r.max]: t.max,
268
+ [r.bounds]: e.boundaries,
269
+ [r.buckets]: t.buckets
270
+ };
271
+ }
272
+ function vt(e, t, n) {
273
+ let r = {
274
+ name: e,
275
+ kind: "counter",
276
+ unit: t.unit ?? "count",
277
+ boundaries: []
278
+ };
279
+ return { add: (e, t) => {
280
+ n(r, e, t);
281
+ } };
282
+ }
283
+ function yt(e, t, n) {
284
+ let r = {
285
+ name: e,
286
+ kind: "histogram",
287
+ unit: t.unit ?? "count",
288
+ boundaries: t.boundaries ?? h
289
+ };
290
+ return { record: (e, t) => {
291
+ n(r, e, t);
292
+ } };
293
+ }
294
+ var bt = class {
295
+ intervalMs;
296
+ emit;
297
+ diagnostics;
298
+ policy;
299
+ instruments = /* @__PURE__ */ new Map();
300
+ timer = null;
301
+ startedAt = 0;
302
+ constructor(e, t, n, r = {
303
+ maxSeries: 100,
304
+ maxInstruments: 1e3,
305
+ maxHistogramBoundaries: 50
306
+ }) {
307
+ this.intervalMs = e, this.emit = t, this.diagnostics = n, this.policy = r;
308
+ }
309
+ record(e, t, n) {
310
+ !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}.`, () => {
311
+ let r = this.instrumentOf(e);
312
+ r && (this.add(r, t, mt(n)), this.arm());
313
+ });
314
+ }
315
+ collect() {
316
+ this.timer !== null && (clearTimeout(this.timer), this.timer = null);
317
+ let e = `${String(this.startedAt)}000000`, t = [...this.instruments.values()];
318
+ this.instruments.clear();
319
+ for (let { def: n, series: r } of t) for (let t of r.values()) this.emit(n.name, t.attributes, _t(n, t, e));
320
+ }
321
+ instrumentOf(e) {
322
+ let t = this.instruments.get(e.name);
323
+ 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);
324
+ if (this.policy.maxInstruments && this.instruments.size >= this.policy.maxInstruments) return this.diagnostics.count("record.dropped_by_ceiling"), null;
325
+ let n = ht(e.boundaries, this.policy.maxHistogramBoundaries), r = gt(n, this.policy.maxHistogramBoundaries);
326
+ e.kind === "histogram" && !r && this.diagnostics.report("config.invalid", `The boundaries of the metric ${e.name} must meet metrics.maxHistogramBoundaries and contain finite numbers in ascending order. The library uses the default boundaries.`);
327
+ let i = {
328
+ def: {
329
+ ...e,
330
+ boundaries: r ? n : [...h]
331
+ },
332
+ series: /* @__PURE__ */ new Map()
333
+ };
334
+ return this.instruments.set(e.name, i), i;
335
+ }
336
+ add(e, t, n) {
337
+ let r = JSON.stringify(n), i = e.series.get(r), a = n;
338
+ if (!i && this.policy.maxSeries > 0 && e.series.size >= this.policy.maxSeries && (r = ft, i = e.series.get(r), a = { [ve]: !0 }), !i) {
339
+ let n = e.def.kind === "histogram" ? e.def.boundaries.length + 1 : 0, o = Array(n).fill(0);
340
+ i = {
341
+ attributes: a,
342
+ count: 0,
343
+ sum: 0,
344
+ min: t,
345
+ max: t,
346
+ buckets: o
347
+ }, e.series.set(r, i);
348
+ }
349
+ 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) {
350
+ let n = e.def.boundaries.findIndex((e) => t <= e);
351
+ i.buckets[n === -1 ? i.buckets.length - 1 : n] += 1;
352
+ }
353
+ }
354
+ arm() {
355
+ this.timer === null && (this.startedAt = Date.now(), this.timer = setTimeout(() => {
356
+ this.collect();
357
+ }, this.intervalMs()), ze(this.timer));
358
+ }
359
+ }, xt = {
197
360
  TRACE: "debug",
198
361
  DEBUG: "debug",
199
362
  INFO: "info",
200
363
  WARN: "warn",
201
364
  ERROR: "error",
202
365
  FATAL: "error"
203
- }, ct = class {
366
+ }, St = class {
204
367
  settings;
205
368
  diagnostics;
206
369
  limits;
207
- constructor(e, n, r = t) {
208
- this.settings = e, this.diagnostics = n, this.limits = r;
370
+ constructor(e, t, n = a) {
371
+ this.settings = e, this.diagnostics = t, this.limits = n;
209
372
  }
210
373
  update(e) {
211
374
  this.settings = e;
212
375
  }
213
376
  accepts(e) {
214
- return this.settings.level === null || !Object.hasOwn(O, this.settings.level) ? !1 : O[e] >= O[this.settings.level];
377
+ return this.settings.level === null || !Object.hasOwn(S, this.settings.level) ? !1 : S[e] >= S[this.settings.level];
215
378
  }
216
379
  write(e, t, n, r, i) {
217
- if (!this.accepts(t) || typeof console > "u" || Fe()) return;
218
- let a = `%c[%s]%c[${t}]%c`, { styles: o } = this.settings, s = st[t];
380
+ if (!this.accepts(t) || typeof console > "u" || Be()) return;
381
+ let a = `%c[%s]%c[${t}]%c`, { styles: o } = this.settings, s = xt[t];
219
382
  this.diagnostics.guard("handler.threw", `The library could not print to console.${s}.`, () => {
220
383
  let c = [];
221
- i !== void 0 && c.push(i), r !== void 0 && c.push(Le(r, this.limits, this.diagnostics)), A(() => {
384
+ i !== void 0 && c.push(i), r !== void 0 && c.push(He(r, this.limits, this.diagnostics)), k(() => {
222
385
  console[s](a, o.namespace, e, o[t], "", n, ...c);
223
386
  });
224
387
  });
225
388
  }
226
- }, lt = class {
389
+ }, Ct = class {
227
390
  value = 0;
228
391
  next() {
229
392
  return ++this.value;
230
393
  }
231
- }, ut = /^[0-9a-f]{32}$/, dt = /^[0-9a-f]{16}$/, ft = /[1-9a-f]/;
232
- function pt(e) {
233
- return ut.test(e.traceId) && ft.test(e.traceId) && dt.test(e.spanId) && ft.test(e.spanId);
394
+ }, wt = /^[0-9a-f]{32}$/, Tt = /^[0-9a-f]{16}$/, Et = /[1-9a-f]/;
395
+ function Dt(e) {
396
+ return wt.test(e.traceId) && Et.test(e.traceId) && Tt.test(e.spanId) && Et.test(e.spanId);
234
397
  }
235
- function mt() {
236
- return Ve(16);
398
+ function Ot() {
399
+ return Ge(16);
237
400
  }
238
- function ht() {
239
- return Ve(8);
401
+ function kt() {
402
+ return Ge(8);
240
403
  }
241
- function gt() {
404
+ function At(e) {
242
405
  return {
243
- traceId: mt(),
244
- spanId: ht(),
406
+ traceId: Ot(),
407
+ spanId: kt(),
245
408
  traceFlags: 1,
246
- startedAt: Date.now()
409
+ startedAt: Date.now(),
410
+ reason: e,
411
+ ended: !1
247
412
  };
248
413
  }
249
- function _t(e) {
414
+ function jt(e, t, n) {
415
+ return `00-${e}-${t}-${(n & 255).toString(16).padStart(2, "0")}`;
416
+ }
417
+ function Mt(e) {
250
418
  return {
251
419
  traceId: e.traceId,
252
420
  spanId: e.spanId,
253
421
  traceFlags: e.traceFlags
254
422
  };
255
423
  }
256
- var vt = class {
424
+ var Nt = class {
257
425
  diagnostics;
258
426
  maxAgeMs;
259
427
  load;
260
- ambient = gt();
428
+ spans;
429
+ ambient = At("start");
261
430
  otel;
262
- constructor(e, t = be, n) {
263
- this.diagnostics = e, this.maxAgeMs = t, this.load = n;
431
+ constructor(e, t = se, n, r) {
432
+ this.diagnostics = e, this.maxAgeMs = t, this.load = n, this.spans = r;
264
433
  }
265
434
  async loadOtel() {
266
435
  if (this.load) try {
@@ -270,8 +439,10 @@ var vt = class {
270
439
  }
271
440
  }
272
441
  resolve() {
273
- let e = this.activeSpanContext();
274
- return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), _t(this.ambient)) : e;
442
+ return this.activeSpanContext() ?? this.ambientContext();
443
+ }
444
+ ambientContext() {
445
+ return Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), Mt(this.ambient);
275
446
  }
276
447
  activeSpanContext() {
277
448
  let e = this.otel;
@@ -279,7 +450,7 @@ var vt = class {
279
450
  let t = e.trace.getActiveSpan();
280
451
  if (t === void 0) return;
281
452
  let n = t.spanContext();
282
- if (pt(n)) return {
453
+ if (Dt(n)) return {
283
454
  traceId: n.traceId,
284
455
  spanId: n.spanId,
285
456
  traceFlags: n.traceFlags
@@ -287,71 +458,106 @@ var vt = class {
287
458
  });
288
459
  }
289
460
  rotate(e) {
290
- return this.ambient = gt(), _t(this.ambient);
461
+ let t = this.ambient;
462
+ this.ambient = At(e);
463
+ let n = Mt(this.ambient);
464
+ return this.finish(t), n;
465
+ }
466
+ end() {
467
+ this.finish(this.ambient);
468
+ }
469
+ finish(e) {
470
+ e.ended || (e.ended = !0, this.spans?.onEnd({
471
+ traceId: e.traceId,
472
+ spanId: e.spanId,
473
+ reason: e.reason,
474
+ startedAt: e.startedAt,
475
+ endedAt: Date.now()
476
+ }));
291
477
  }
292
478
  headers() {
293
- let e = {}, t = this.otel;
294
- if (t && this.diagnostics.guard("trace.otel_failed", "The library could not add the OpenTelemetry headers.", () => {
295
- t.propagation.inject(t.context.active(), e);
296
- }), !e.traceparent) {
297
- let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
298
- e[ie] = `00-${t.traceId}-${t.spanId}-${n}`;
299
- }
300
- return e;
479
+ return this.trace(!1).headers;
480
+ }
481
+ request() {
482
+ return this.trace(!0);
483
+ }
484
+ trace(e) {
485
+ let t = {}, n = this.otel;
486
+ if (n && this.diagnostics.guard("trace.otel_failed", "The library could not add the OpenTelemetry headers.", () => {
487
+ n.propagation.inject(n.context.active(), t);
488
+ }), t.traceparent) return { headers: t };
489
+ let r = this.activeSpanContext(), i = r ?? this.ambientContext(), a = r ? void 0 : this.spans;
490
+ if (!a?.enabled()) return t[Ee] = jt(i.traceId, i.spanId, i.traceFlags), { headers: t };
491
+ let o = a.keeps(i.traceId), s = o ? i.traceFlags : i.traceFlags & -2, c = e ? kt() : i.spanId;
492
+ return t[Ee] = jt(i.traceId, c, s), !e || !o ? { headers: t } : {
493
+ headers: t,
494
+ span: {
495
+ traceId: i.traceId,
496
+ spanId: c,
497
+ parentSpanId: i.spanId
498
+ }
499
+ };
301
500
  }
302
- }, yt = class {
501
+ }, Pt = class {
303
502
  buffer;
304
503
  pointer = 0;
305
504
  filled = !1;
306
505
  capacity;
307
506
  constructor(e) {
308
- this.capacity = Math.max(e, 1), this.buffer = Array(this.capacity);
507
+ this.capacity = e === 0 ? 0 : Math.max(e, 1), this.buffer = Array(this.capacity);
508
+ }
509
+ resize(e) {
510
+ let t = this.snapshot().slice(-e);
511
+ if (this.capacity = e, this.buffer = Array(e), this.pointer = 0, this.filled = !1, e) for (let e of t) this.push(e);
309
512
  }
310
513
  push(e) {
311
- this.buffer[this.pointer] = e, this.pointer = (this.pointer + 1) % this.capacity, this.pointer === 0 && (this.filled = !0);
514
+ this.capacity !== 0 && (this.buffer[this.pointer] = e, this.pointer = (this.pointer + 1) % this.capacity, this.pointer === 0 && (this.filled = !0));
515
+ }
516
+ clear() {
517
+ this.buffer.fill(void 0), this.pointer = 0, this.filled = !1;
312
518
  }
313
519
  snapshot() {
314
520
  return (this.filled ? [...this.buffer.slice(this.pointer), ...this.buffer.slice(0, this.pointer)] : this.buffer.slice(0, this.pointer)).filter((e) => e !== void 0);
315
521
  }
316
- }, bt = Object.keys(O), xt = ["gzip", "none"], St = [
522
+ }, Ft = Object.keys(S), It = ["gzip", "none"], Lt = [
317
523
  "omit",
318
524
  "same-origin",
319
525
  "include"
320
- ], Ct = [
526
+ ], Rt = [
321
527
  "auto",
322
528
  "indexeddb",
323
529
  "localstorage",
324
530
  "memory",
325
531
  "none"
326
- ], wt = ["storage", "memory"], Tt = [
532
+ ], zt = ["storage", "memory"], Bt = [
327
533
  "auto",
328
534
  "sender",
329
535
  "forwarder",
330
536
  "off"
331
- ], Et = [
537
+ ], Vt = [
332
538
  "auto",
333
539
  "provider",
334
540
  "client"
335
- ], Dt = [
541
+ ], Ht = [
336
542
  "auto",
337
543
  "context",
338
544
  "tab",
339
545
  "origin"
340
- ], Ot = [
546
+ ], Ut = [
341
547
  "error",
342
548
  "warn",
343
549
  "info",
344
550
  "log"
345
- ], kt = ["limited", "until-delivered"], At = {
551
+ ], Wt = ["limited", "until-delivered"], Gt = {
346
552
  logFlushIntervalMs: [100, 6e4],
347
553
  logBatchSize: [1, 1e3],
348
554
  metricFlushIntervalMs: [100, 6e4],
349
555
  metricBatchSize: [1, 1e3]
350
- }, jt = {
556
+ }, Kt = {
351
557
  maxBatches: [1, 5e3],
352
558
  maxAgeMs: [6e4, 6048e5],
353
559
  maxAttempts: [1, 20]
354
- }, Mt = {
560
+ }, qt = {
355
561
  maxBodyChars: [256, 65536],
356
562
  maxAttributeChars: [256, 65536],
357
563
  maxAttributeCount: [1, 1024],
@@ -359,139 +565,202 @@ var vt = class {
359
565
  maxDepth: [1, 16],
360
566
  maxArrayLength: [1, 1e4],
361
567
  maxNodes: [100, 1e5],
362
- maxRecordBytes: [1024, g]
363
- }, Nt = [6e4, 864e5], Pt = [
568
+ maxRecordBytes: [1024, n]
569
+ }, Jt = [6e4, 864e5], I = [0, 2147483647], L = [0, 2 ** 53 - 1], Yt = [1, 2 ** 53 - 1], Xt = {
570
+ capturePolicy: { ranges: {
571
+ breadcrumbs: [0, 1e6],
572
+ errorDedupeMs: I,
573
+ maxErrorSignatures: L,
574
+ errorsPerWindow: L,
575
+ consolePerWindow: L,
576
+ longFramesPerWindow: L,
577
+ webSocketPerWindow: L,
578
+ windowMs: I,
579
+ errorCeiling: L
580
+ } },
581
+ metadata: { ranges: {} },
582
+ persistence: { ranges: {} },
583
+ diagnostics: { ranges: { throttleMs: I } },
584
+ correlation: { ranges: {
585
+ sessionIdleMs: I,
586
+ sessionTouchMs: I,
587
+ traceMaxAgeMs: I
588
+ } },
589
+ metrics: { ranges: {
590
+ maxSeries: L,
591
+ maxInstruments: L,
592
+ maxHistogramBoundaries: L
593
+ } },
594
+ buffering: {
595
+ ranges: {
596
+ maxPendingRecords: L,
597
+ maxPendingBytes: L
598
+ },
599
+ choices: { overflow: [
600
+ "drop-oldest",
601
+ "drop-newest",
602
+ "persist"
603
+ ] }
604
+ },
605
+ delivery: { ranges: {
606
+ requestTimeoutMs: [1, I[1]],
607
+ maxConcurrentRequests: Yt,
608
+ retryBaseDelayMs: I,
609
+ retryMaxDelayMs: I,
610
+ retryIdleDelayMs: I,
611
+ batchesPerDrain: Yt
612
+ } }
613
+ }, Zt = [
364
614
  "errors",
365
615
  "rejections",
366
616
  "resourceErrors",
367
617
  "fetch",
368
618
  "xhr",
369
619
  "httpMetrics",
370
- "interactions",
371
620
  "navigation",
372
621
  "webVitals",
373
622
  "longFrames",
374
- "fullUrls"
375
- ], Ft = "null", L = `a level name: ${R(bt)}`, It = `true, false or a list of ${R(Ot)}`, Lt = "a list of strings and RegExp patterns", Rt = "a list of origin URLs such as \"https://api.example\" and RegExp patterns", zt = "a list of origin URLs such as \"https://app.example\". For a sandboxed frame, set bus.mode: \"sender\" in the frame", Bt = "a list of strings";
376
- function R(e) {
623
+ "fullUrls",
624
+ "webSocket"
625
+ ], Qt = "null", R = `a level name: ${z(Ft)}`, $t = `true, false or a list of ${z(Ut)}`, en = "a list of strings and RegExp patterns", tn = "a list of origin URLs such as \"https://api.example\" and RegExp patterns", nn = "a list of origin URLs such as \"https://app.example\". For a sandboxed frame, set bus.mode: \"sender\" in the frame", rn = "a list of strings";
626
+ function z(e) {
377
627
  let t = e.map((e) => `"${e}"`);
378
628
  return `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
379
629
  }
380
- function Vt(e) {
630
+ function an(e) {
381
631
  return typeof e == "string" ? `"${e}"` : typeof e == "function" ? "a function" : typeof e == "object" && e ? "an object" : String(e);
382
632
  }
383
- function z(e, t, n, r, i) {
384
- e.report("config.invalid", `${t} must be ${n}. The value is ${Vt(r)}. The library keeps ${i}.`);
385
- }
386
633
  function B(e, t, n, r, i) {
634
+ e.report("config.invalid", `${t} must be ${n}. The value is ${an(r)}. The library keeps ${i}.`);
635
+ }
636
+ function V(e, t, n, r, i) {
387
637
  if (t === void 0) return r;
388
638
  let a = n.find((e) => e === t);
389
- return a === void 0 ? (z(i, e, R(n), t, `"${r}"`), r) : a;
639
+ return a === void 0 ? (B(i, e, z(n), t, `"${r}"`), r) : a;
390
640
  }
391
- function V(e, t, n, r) {
392
- return t === void 0 ? n : typeof t == "boolean" ? t : (z(r, e, "true or false", t, String(n)), n);
641
+ function H(e, t, n, r) {
642
+ return t === void 0 ? n : typeof t == "boolean" ? t : (B(r, e, "true or false", t, String(n)), n);
393
643
  }
394
- function Ht(e, t, n, r) {
395
- 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);
644
+ function on(e, t, n, r) {
645
+ 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
646
  }
397
- function Ut(e, t, n, r, i) {
647
+ function U(e, t, n, r, i) {
398
648
  if (t === void 0) return r;
399
649
  let [a, o] = n;
400
- 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);
650
+ 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);
651
+ }
652
+ function sn(e, t, n) {
653
+ return e === void 0 ? t : e === null ? null : typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : (B(n, "loggerCache.maxEntries", "a nonnegative safe integer or null", e, String(t)), t);
401
654
  }
402
- function H(e, t, n, r, i) {
655
+ function cn(e, t, n, r, i) {
403
656
  let a = t ?? {}, o = Object.keys(r);
404
- return Object.fromEntries(o.map((t) => [t, Ut(`${e}.${t}`, a[t], r[t], n[t], i)]));
657
+ return Object.fromEntries(o.map((t) => [t, U(`${e}.${t}`, a[t], r[t], n[t], i)]));
405
658
  }
406
- function U(e) {
659
+ function W(e) {
407
660
  if (typeof e != "string") return;
408
661
  let t = e.toUpperCase();
409
- return bt.find((e) => e === t);
662
+ return Ft.find((e) => e === t);
410
663
  }
411
- function Wt(e, t, n, r) {
664
+ function ln(e, t, n, r) {
412
665
  if (t === void 0) return n;
413
- let i = U(t);
414
- return i === void 0 ? (z(r, e, L, t, `"${n}"`), n) : i;
666
+ let i = W(t);
667
+ return i === void 0 ? (B(r, e, R, t, `"${n}"`), n) : i;
415
668
  }
416
- function W(e, t, n, r, i, a) {
669
+ function un(e, t, n) {
670
+ if (e === void 0) return t;
671
+ if (!O(e)) return B(n, "minLevels", "an object of level names", e, "the value in force"), t;
672
+ let r = [];
673
+ for (let [t, i] of Object.entries(e)) {
674
+ let e = W(i);
675
+ t !== "" && e !== void 0 ? r.push([t, e]) : B(n, `minLevels["${t}"]`, R, i, "minLevel for it");
676
+ }
677
+ return Object.fromEntries(r);
678
+ }
679
+ function G(e, t, n, r, i, a) {
417
680
  if (t === void 0) return n;
418
- if (!Array.isArray(t)) return z(a, e, r, t, "the list in force"), n;
681
+ if (!Array.isArray(t)) return B(a, e, r, t, "the list in force"), n;
419
682
  let o = [], s = t;
420
683
  for (let t of s) {
421
684
  let n = i(t);
422
- n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${Vt(t)}. ${e} must be ${r}.`) : o.push(n);
685
+ n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${an(t)}. ${e} must be ${r}.`) : o.push(n);
423
686
  }
424
687
  return o;
425
688
  }
426
- function Gt(e) {
689
+ function dn(e) {
690
+ return typeof e == "function" ? e : void 0;
691
+ }
692
+ function fn(e) {
693
+ return O(e) && typeof e.name == "string" && e.name !== "" && typeof e.install == "function" && typeof e.uninstall == "function" ? e : void 0;
694
+ }
695
+ function pn(e) {
427
696
  return typeof e == "string" ? e : void 0;
428
697
  }
429
- function Kt(e) {
698
+ function mn(e) {
430
699
  return typeof e == "string" || e instanceof RegExp ? e : void 0;
431
700
  }
432
- function qt(e) {
433
- return Ot.find((t) => t === e);
701
+ function hn(e) {
702
+ return Ut.find((t) => t === e);
434
703
  }
435
- function Jt(e) {
704
+ function gn(e) {
436
705
  if (typeof e == "string") try {
437
706
  let { origin: t } = new URL(e);
438
- return t === Ft ? void 0 : t;
707
+ return t === Qt ? void 0 : t;
439
708
  } catch {
440
709
  return;
441
710
  }
442
711
  }
443
- function Yt(e) {
444
- return e instanceof RegExp ? e : Jt(e);
712
+ function _n(e) {
713
+ return e instanceof RegExp ? e : gn(e);
445
714
  }
446
- function Xt(e) {
447
- return Oe(e) ? Object.values(e).every((e) => typeof e == "string") : !1;
715
+ function vn(e) {
716
+ return O(e) ? Object.values(e).every((e) => typeof e == "string") : !1;
448
717
  }
449
- function Zt(e, t, n) {
450
- if (e !== void 0) return typeof e == "function" || Xt(e) ? e : (z(n, "headers", "an object of strings or a function", e, "the headers in force"), t);
718
+ function yn(e, t, n) {
719
+ if (e !== void 0) return typeof e == "function" || vn(e) ? e : (B(n, "headers", "an object of strings or a function", e, "the headers in force"), t);
451
720
  }
452
- function Qt(e) {
721
+ function bn(e) {
453
722
  return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
454
723
  }
455
- function $t(e, t, n) {
456
- return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || Qt(e) ? e : (n.report("config.invalid", `serializer must be "${x}", "ecs" or an implementation. The library uses "${x}".`), x);
724
+ function xn(e, t, n) {
725
+ return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || bn(e) ? e : (n.report("config.invalid", `serializer must be "${E}", "ecs" or an implementation. The library uses "${E}".`), E);
457
726
  }
458
- var en = new Set(Object.keys(de));
459
- function tn(e, t) {
727
+ var Sn = new Set(Object.keys(f));
728
+ function Cn(e, t) {
460
729
  let n = {}, r = Object.entries(e ?? {});
461
- for (let [e, i] of r) en.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.`);
730
+ for (let [e, i] of r) Sn.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.`);
462
731
  return n;
463
732
  }
464
- function nn(e, t, n) {
733
+ function wn(e, t, n) {
465
734
  if (e === void 0) return t ?? "DEBUG";
466
- let r = U(e);
467
- return r === void 0 ? (z(n, "console.level", L, e, "the console level in force"), t) : r;
735
+ let r = W(e);
736
+ return r === void 0 ? (B(n, "console.level", R, e, "the console level in force"), t) : r;
468
737
  }
469
- function rn(t, n, r) {
470
- if (t === void 0) return n;
471
- if (t === !1) return {
738
+ function Tn(e, t, n) {
739
+ if (e === void 0) return t;
740
+ if (e === !1) return {
472
741
  level: null,
473
- styles: n.styles
742
+ styles: t.styles
474
743
  };
475
- if (t === !0) return {
476
- level: e,
477
- styles: n.styles
744
+ if (e === !0) return {
745
+ level: d,
746
+ styles: t.styles
478
747
  };
479
- if (typeof t == "string") {
480
- let e = U(t);
481
- return e === void 0 ? (z(r, "console", L, t, "the console level in force"), n) : {
482
- level: e,
483
- styles: n.styles
748
+ if (typeof e == "string") {
749
+ let r = W(e);
750
+ return r === void 0 ? (B(n, "console", R, e, "the console level in force"), t) : {
751
+ level: r,
752
+ styles: t.styles
484
753
  };
485
754
  }
486
- 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) : {
487
- level: nn(t.level, n.level, r),
755
+ 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) : {
756
+ level: wn(e.level, t.level, n),
488
757
  styles: {
489
- ...n.styles,
490
- ...tn(t.styles, r)
758
+ ...t.styles,
759
+ ...Cn(e.styles, n)
491
760
  }
492
761
  };
493
762
  }
494
- function an(e, t, n) {
763
+ function En(e, t, n) {
495
764
  let r = e ?? {};
496
765
  return {
497
766
  ...t,
@@ -500,113 +769,168 @@ function an(e, t, n) {
500
769
  ...t.rates,
501
770
  ...r.rates
502
771
  },
503
- alwaysSampleTypes: W("sampling.alwaysSampleTypes", r.alwaysSampleTypes, t.alwaysSampleTypes, Bt, Gt, n),
504
- remote: V("sampling.remote", r.remote, t.remote, n)
772
+ alwaysSampleTypes: G("sampling.alwaysSampleTypes", r.alwaysSampleTypes, t.alwaysSampleTypes, rn, pn, n),
773
+ remote: H("sampling.remote", r.remote, t.remote, n)
505
774
  };
506
775
  }
507
- function on(e, t, n) {
776
+ function Dn(e, t, n) {
508
777
  let r = e ?? {};
509
778
  return {
510
- mode: B("bus.mode", r.mode, Tt, t.mode, n),
511
- trustedOrigins: W("bus.trustedOrigins", r.trustedOrigins, t.trustedOrigins, zt, Jt, n),
512
- openFinRole: B("bus.openFinRole", r.openFinRole, Et, t.openFinRole, n)
779
+ maxTrackedSources: U("bus.maxTrackedSources", r.maxTrackedSources, [0, 2 ** 53 - 1], t.maxTrackedSources, n),
780
+ sourcePolicy: V("bus.sourcePolicy", r.sourcePolicy, ["registered", "trusted-origin"], t.sourcePolicy, n),
781
+ validation: V("bus.validation", r.validation, ["strict", "envelope"], t.validation, n),
782
+ maxMessageBytes: U("bus.maxMessageBytes", r.maxMessageBytes, [0, 2 ** 53 - 1], t.maxMessageBytes, n),
783
+ maxRecordsPerMessage: U("bus.maxRecordsPerMessage", r.maxRecordsPerMessage, [0, 2 ** 53 - 1], t.maxRecordsPerMessage, n),
784
+ maxMessagesPerSecond: U("bus.maxMessagesPerSecond", r.maxMessagesPerSecond, [0, 2 ** 53 - 1], t.maxMessagesPerSecond, n),
785
+ mode: V("bus.mode", r.mode, Bt, t.mode, n),
786
+ trustedOrigins: G("bus.trustedOrigins", r.trustedOrigins, t.trustedOrigins, nn, gn, n),
787
+ openFinRole: V("bus.openFinRole", r.openFinRole, Vt, t.openFinRole, n)
513
788
  };
514
789
  }
515
- function sn(e, t, n) {
790
+ function On(e, t, n) {
516
791
  let r = e ?? {};
517
792
  return {
518
- scope: B("journey.scope", r.scope, Dt, t.scope, n),
519
- maxAgeMs: Ut("journey.maxAgeMs", r.maxAgeMs, Nt, t.maxAgeMs, n)
793
+ scope: V("journey.scope", r.scope, Ht, t.scope, n),
794
+ maxAgeMs: U("journey.maxAgeMs", r.maxAgeMs, Jt, t.maxAgeMs, n)
520
795
  };
521
796
  }
522
- function cn(e, t, n) {
797
+ function kn(e, t, n) {
523
798
  let r = e ?? {};
524
799
  return {
525
- mode: B("retention.mode", r.mode, kt, t.mode, n),
526
- ...H("retention", r, t, jt, n)
800
+ mode: V("retention.mode", r.mode, Wt, t.mode, n),
801
+ ...cn("retention", r, t, Kt, n)
527
802
  };
528
803
  }
529
- function ln(e, t, n) {
530
- return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ? W("capture.console", e, [], It, qt, n) : (z(n, "capture.console", It, e, "the value in force"), t);
804
+ function An(e, t, n) {
805
+ return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ? G("capture.console", e, [], $t, hn, n) : (B(n, "capture.console", $t, e, "the value in force"), t);
531
806
  }
532
- function un(e, t, n) {
807
+ function jn(e, t, n) {
533
808
  let r = e ?? {}, i = {
534
809
  ...t,
535
810
  ...r,
536
- console: ln(r.console, t.console, n),
537
- longFrameThresholdMs: Ht("capture.longFrameThresholdMs", r.longFrameThresholdMs, t.longFrameThresholdMs, n),
538
- ignoreUrls: W("capture.ignoreUrls", r.ignoreUrls, t.ignoreUrls, Lt, Kt, n),
539
- propagateTraceHeaderTo: W("capture.propagateTraceHeaderTo", r.propagateTraceHeaderTo, t.propagateTraceHeaderTo, Rt, Yt, n)
811
+ interactions: Mn(r.interactions, t.interactions, n),
812
+ console: An(r.console, t.console, n),
813
+ longFrameThresholdMs: on("capture.longFrameThresholdMs", r.longFrameThresholdMs, t.longFrameThresholdMs, n),
814
+ ignoreUrls: G("capture.ignoreUrls", r.ignoreUrls, t.ignoreUrls, en, mn, n),
815
+ propagateTraceHeaderTo: G("capture.propagateTraceHeaderTo", r.propagateTraceHeaderTo, t.propagateTraceHeaderTo, tn, _n, n),
816
+ plugins: G("capture.plugins", r.plugins, t.plugins, "a list of objects with a name, install() and uninstall()", fn, n)
540
817
  };
541
- for (let e of Pt) i[e] = V(`capture.${e}`, r[e], t[e], n);
818
+ for (let e of Zt) i[e] = H(`capture.${e}`, r[e], t[e], n);
542
819
  return i;
543
820
  }
544
- function dn(e, t, n, r) {
545
- let i = t;
546
- if (typeof e == "string" && e !== "") try {
547
- new URL(e), i = e;
548
- } catch (t) {
549
- r.report("config.invalid", `metricsEndpoint is not a valid absolute URL: ${e}. The library keeps the value in force.`, void 0, t);
821
+ function Mn(e, t, n) {
822
+ if (e === void 0) return t;
823
+ if (typeof e == "boolean") return e;
824
+ if (!O(e)) return n.report("config.invalid", "capture.interactions must be a boolean or an options object."), t;
825
+ let r = typeof t == "object" ? t : {}, i = e.ignoreSelector, a = i === void 0 ? r.ignoreSelector : i;
826
+ if (a != null) try {
827
+ if (typeof a != "string") throw Error("Invalid selector");
828
+ typeof document < "u" && document.createElement("div").matches(a);
829
+ } catch {
830
+ n.report("config.invalid", "capture.interactions.ignoreSelector must be a valid CSS selector or null."), a = r.ignoreSelector;
831
+ }
832
+ let o = r.actionAttribute ?? "data-observability-action";
833
+ return e.actionAttribute !== void 0 && (typeof e.actionAttribute == "string" && /^[a-z][\w-]*$/i.test(e.actionAttribute) ? o = e.actionAttribute : B(n, "capture.interactions.actionAttribute", "an attribute name of letters, digits, hyphens and underscores", e.actionAttribute, `"${o}"`)), {
834
+ actionAttribute: o,
835
+ text: H("capture.interactions.text", e.text, r.text ?? !1, n),
836
+ selector: H("capture.interactions.selector", e.selector, r.selector ?? !1, n),
837
+ ignoreSelector: typeof a == "string" || a === null ? a : void 0,
838
+ maxTextChars: U("capture.interactions.maxTextChars", e.maxTextChars, [0, 2 ** 53 - 1], r.maxTextChars ?? 50, n)
839
+ };
840
+ }
841
+ var Nn = {
842
+ metricsEndpoint: "The library sends metric records as log records.",
843
+ tracesEndpoint: "The library sends no span."
844
+ };
845
+ function Pn(e, t, n, r, i) {
846
+ let a = n;
847
+ if (typeof t == "string" && t !== "") try {
848
+ new URL(t), a = t;
849
+ } catch (n) {
850
+ i.report("config.invalid", `${e} is not a valid absolute URL: ${t}. The library keeps the value in force.`, void 0, n);
550
851
  }
551
- else e === "" ? i = "" : e !== void 0 && z(r, "metricsEndpoint", "a URL string", e, "the value in force");
552
- return i !== "" && n !== "otlp" ? (r.report("config.invalid", `metricsEndpoint needs serializer "${x}". The library sends metric records as log records.`), "") : i;
852
+ else t === "" ? a = "" : t !== void 0 && B(i, e, "a URL string", t, "the value in force");
853
+ return a !== "" && r !== "otlp" ? (i.report("config.invalid", `${e} needs serializer "${E}". ${Nn[e]}`), "") : a;
553
854
  }
554
- function fn(e, t, n) {
555
- let i = n ?? a, o = {
556
- ...i,
855
+ function Fn(e, t, n, r, i) {
856
+ let a = { ...n };
857
+ for (let o of Object.keys(n)) {
858
+ let s = t?.[o], c = n[o], l = r.ranges[o], u = r.choices?.[o], d = c;
859
+ typeof c == "number" && l ? d = U(`${e}.${o}`, s, l, c, i) : typeof c == "boolean" ? d = H(`${e}.${o}`, s, c, i) : u ? d = V(`${e}.${o}`, s, u, String(c), i) : s === void 0 || typeof s == "string" ? d = s ?? c : B(i, `${e}.${o}`, "a string", s, String(c)), Object.assign(a, { [o]: d });
860
+ }
861
+ return a;
862
+ }
863
+ function K(e, t, n) {
864
+ let r = n ?? u, a = Object.fromEntries(Object.keys(Xt).map((n) => [n, Fn(n, e[n], r[n], Xt[n], t)])), o = {
865
+ ...r,
557
866
  ...e,
558
- endpoint: e.endpoint === void 0 ? i.endpoint : e.endpoint,
559
- enabled: V("enabled", e.enabled, i.enabled, t),
560
- minLevel: Wt("minLevel", e.minLevel, i.minLevel, t),
561
- compression: B("compression", e.compression, xt, i.compression, t),
562
- credentials: B("credentials", e.credentials, St, i.credentials, t),
563
- headers: "headers" in e ? Zt(e.headers, i.headers, t) : i.headers,
564
- storage: B("storage", e.storage, Ct, i.storage, t),
565
- identity: B("identity", e.identity, wt, i.identity, t),
566
- serializer: $t(e.serializer, n?.serializer, t),
567
- console: rn(e.console, i.console, t),
568
- sampling: an(e.sampling, i.sampling, t),
569
- bus: on(e.bus, i.bus, t),
570
- batching: H("batching", e.batching, i.batching, At, t),
571
- retention: cn(e.retention, i.retention, t),
572
- limits: H("limits", e.limits, i.limits, Mt, t),
573
- journey: sn(e.journey, i.journey, t),
574
- capture: un(e.capture, i.capture, t)
867
+ ...a,
868
+ lockConfiguration: H("lockConfiguration", e.lockConfiguration, r.lockConfiguration, t),
869
+ loggerCache: { maxEntries: sn(e.loggerCache?.maxEntries, r.loggerCache.maxEntries, t) },
870
+ securityContext: {
871
+ id: typeof e.securityContext?.id == "string" && e.securityContext.id || r.securityContext.id,
872
+ isolation: H("securityContext.isolation", e.securityContext?.isolation, r.securityContext.isolation, t)
873
+ },
874
+ endpoint: e.endpoint === void 0 ? r.endpoint : e.endpoint,
875
+ enabled: H("enabled", e.enabled, r.enabled, t),
876
+ minLevel: ln("minLevel", e.minLevel, r.minLevel, t),
877
+ minLevels: un(e.minLevels, r.minLevels, t),
878
+ processors: G("processors", e.processors, r.processors, "a list of functions", dn, t),
879
+ compression: V("compression", e.compression, It, r.compression, t),
880
+ credentials: V("credentials", e.credentials, Lt, r.credentials, t),
881
+ headers: "headers" in e ? yn(e.headers, r.headers, t) : r.headers,
882
+ storage: V("storage", e.storage, Rt, r.storage, t),
883
+ identity: V("identity", e.identity, zt, r.identity, t),
884
+ serializer: xn(e.serializer, n?.serializer, t),
885
+ console: Tn(e.console, r.console, t),
886
+ sampling: En(e.sampling, r.sampling, t),
887
+ bus: Dn(e.bus, r.bus, t),
888
+ batching: cn("batching", e.batching, r.batching, Gt, t),
889
+ retention: kn(e.retention, r.retention, t),
890
+ limits: cn("limits", e.limits, r.limits, qt, t),
891
+ journey: On(e.journey, r.journey, t),
892
+ capture: jn(e.capture, r.capture, t)
575
893
  };
576
- if (o.metricsEndpoint = dn(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.");
894
+ for (let n of ["metricsEndpoint", "tracesEndpoint"]) o[n] = Pn(n, e[n], r[n], o.serializer, t);
895
+ if (o.transport !== void 0 && typeof o.transport != "function" && (t.report("config.invalid", "transport must be a function. The library ignores the value."), o.transport = r.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 = r.onDrop), o.contextProvider !== void 0 && typeof o.contextProvider != "function" && (t.report("config.invalid", "contextProvider must be a function. The library ignores the value."), o.contextProvider = r.contextProvider), o.transportOnExit !== void 0 && typeof o.transportOnExit != "function" && (t.report("config.invalid", "transportOnExit must be a function. The library ignores the value."), o.transportOnExit = r.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.");
577
896
  else if (o.endpoint !== null) try {
578
897
  new URL(o.endpoint);
579
898
  } catch (e) {
580
899
  t.report("config.invalid", `endpoint is not a valid absolute URL: ${o.endpoint}.`, void 0, e);
581
900
  }
582
- 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);
901
+ for (let e of ["metricsEndpoint", "tracesEndpoint"]) o[e] !== "" && o.endpoint === null && !o.transport && t.report("config.invalid", `${e} needs endpoint or transport. The library sends nothing to ${e}.`);
902
+ o.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${i}'.`), i);
583
903
  let s = o.sampling.defaultRate;
584
904
  (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);
585
905
  let c = o.sampling.remoteMaxRate;
586
906
  (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);
587
907
  let l = Object.entries(o.sampling.rates);
588
908
  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);
589
- o.capture.ignoreUrls = o.capture.ignoreUrls.filter((e) => e !== n?.endpoint && e !== n?.metricsEndpoint);
590
- for (let e of [o.endpoint, o.metricsEndpoint]) e && !o.capture.ignoreUrls.includes(e) && (o.capture.ignoreUrls = [...o.capture.ignoreUrls, e]);
591
- return pn(e, t), o;
909
+ o.capture.ignoreUrls = o.capture.ignoreUrls.filter((e) => e !== n?.endpoint && e !== n?.metricsEndpoint && e !== n?.tracesEndpoint);
910
+ for (let e of [
911
+ o.endpoint,
912
+ o.metricsEndpoint,
913
+ o.tracesEndpoint
914
+ ]) e && !o.capture.ignoreUrls.includes(e) && (o.capture.ignoreUrls = [...o.capture.ignoreUrls, e]);
915
+ return o.delivery.retryMaxDelayMs < o.delivery.retryBaseDelayMs && (t.report("config.invalid", "delivery.retryMaxDelayMs must be at least retryBaseDelayMs."), o.delivery.retryBaseDelayMs = r.delivery.retryBaseDelayMs, o.delivery.retryMaxDelayMs = r.delivery.retryMaxDelayMs), o.capture.urlTransform !== void 0 && typeof o.capture.urlTransform != "function" && (t.report("config.invalid", "capture.urlTransform must be a function."), o.capture.urlTransform = r.capture.urlTransform), In(e, t), o;
592
916
  }
593
- function pn(e, t) {
594
- let n = /* @__PURE__ */ new Set([...Object.keys(a), ...xe]);
917
+ function In(e, t) {
918
+ let n = /* @__PURE__ */ new Set([...Object.keys(u), ...Ce]);
595
919
  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.`);
596
- for (let n of C) {
920
+ for (let n of pe) {
597
921
  let r = e[n];
598
922
  if (typeof r != "object" || !r) continue;
599
- let i = /* @__PURE__ */ new Set([...Object.keys(a[n]), ..._[n]]);
923
+ let i = /* @__PURE__ */ new Set([...Object.keys(u[n]), ...g[n]]);
600
924
  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.`);
601
925
  }
602
926
  }
603
- function mn(e, t) {
604
- for (let n of Object.keys(t)) C.includes(n) || Object.assign(e, { [n]: t[n] });
605
- for (let n of C) Object.assign(e[n], t[n]);
927
+ function Ln(e, t) {
928
+ for (let n of Object.keys(t)) pe.includes(n) || Object.assign(e, { [n]: t[n] });
929
+ for (let n of pe) Object.assign(e[n], t[n]);
606
930
  }
607
931
  //#endregion
608
932
  //#region src/core/context.ts
609
- var hn = class {
933
+ var Rn = class {
610
934
  map = /* @__PURE__ */ new Map();
611
935
  set(e, t) {
612
936
  this.map.set(e, t);
@@ -617,16 +941,23 @@ var hn = class {
617
941
  remove(e) {
618
942
  this.map.delete(e);
619
943
  }
944
+ clear() {
945
+ this.map.clear();
946
+ }
620
947
  getAll() {
621
948
  return Object.fromEntries(this.map);
622
949
  }
623
- }, gn = class {
950
+ }, zn = class {
624
951
  handler;
625
952
  throttleMs;
953
+ consoleFallback;
626
954
  counters = /* @__PURE__ */ new Map();
627
955
  lastEmitted = /* @__PURE__ */ new Map();
628
- constructor(e, t = f) {
629
- this.handler = e, this.throttleMs = t;
956
+ constructor(e, t = De, n = !1) {
957
+ this.handler = e, this.throttleMs = t, this.consoleFallback = n;
958
+ }
959
+ setPolicy(e, t) {
960
+ this.throttleMs = e, this.consoleFallback = t;
630
961
  }
631
962
  setHandler(e) {
632
963
  this.handler = e;
@@ -648,12 +979,12 @@ var hn = class {
648
979
  count: i
649
980
  }, { handler: s } = this;
650
981
  if (s) try {
651
- A(() => {
982
+ k(() => {
652
983
  s(o);
653
984
  });
654
- } catch (e) {
655
- this.count("handler.threw"), typeof console < "u" && A(() => {
656
- console.warn(`${se} The onDiagnostic handler threw an error.`, e);
985
+ } catch {
986
+ this.count("handler.threw"), this.consoleFallback && typeof console < "u" && k(() => {
987
+ console.warn(`${ue} The onDiagnostic handler threw an error.`);
657
988
  });
658
989
  }
659
990
  }
@@ -679,10 +1010,10 @@ var hn = class {
679
1010
  };
680
1011
  //#endregion
681
1012
  //#region src/core/drops.ts
682
- function G(e, t) {
1013
+ function Bn(e, t) {
683
1014
  e.length < 20 && !e.includes(t) && e.push(t);
684
1015
  }
685
- var _n = class {
1016
+ var Vn = class {
686
1017
  config;
687
1018
  diagnostics;
688
1019
  pending = /* @__PURE__ */ new Map();
@@ -701,12 +1032,12 @@ var _n = class {
701
1032
  journeyIds: [],
702
1033
  actions: []
703
1034
  }, this.pending.set(e, r)), r.records += t.length;
704
- for (let e of n) G(r.batchIds, e);
1035
+ for (let e of n) Bn(r.batchIds, e);
705
1036
  for (let e of t) {
706
- let t = Je(e, E);
707
- typeof t == "string" && G(r.journeyIds, t);
708
- let n = M(e) ? e.body : void 0;
709
- typeof n == "string" && G(r.actions, n);
1037
+ let t = et(e, b);
1038
+ typeof t == "string" && Bn(r.journeyIds, t);
1039
+ let n = $e(e) ? e.body : void 0;
1040
+ typeof n == "string" && Bn(r.actions, n);
710
1041
  }
711
1042
  this.scheduled || (this.scheduled = !0, queueMicrotask(() => {
712
1043
  this.flush();
@@ -721,7 +1052,7 @@ var _n = class {
721
1052
  this.reporting = !0;
722
1053
  for (let n of e) this.diagnostics.guard("handler.threw", "The onDrop hook threw an error.", () => {
723
1054
  Ye(() => {
724
- A(() => {
1055
+ k(() => {
725
1056
  t(n);
726
1057
  });
727
1058
  });
@@ -729,7 +1060,7 @@ var _n = class {
729
1060
  this.reporting = !1;
730
1061
  }
731
1062
  }
732
- }, vn = class {
1063
+ }, Hn = class {
733
1064
  onDrop;
734
1065
  held = [];
735
1066
  actions = 0;
@@ -743,10 +1074,10 @@ var _n = class {
743
1074
  return this.held.length;
744
1075
  }
745
1076
  push(e) {
746
- let t = M(e);
1077
+ let t = $e(e);
747
1078
  if ((t ? this.actions : this.held.length - this.actions) < (t ? 2e3 : 500)) this.actions += +!!t;
748
1079
  else {
749
- let e = this.held.findIndex((e) => M(e) === t), [n] = this.held.splice(e, 1);
1080
+ let e = this.held.findIndex((e) => $e(e) === t), [n] = this.held.splice(e, 1);
750
1081
  this.onDrop(n);
751
1082
  }
752
1083
  this.held.push(e);
@@ -755,118 +1086,34 @@ var _n = class {
755
1086
  let e = this.held;
756
1087
  return this.held = [], this.actions = 0, e;
757
1088
  }
758
- }, yn = "overflow", bn = /* @__PURE__ */ new Set([
1089
+ }, Un = "error.", Wn = [
1090
+ _e,
759
1091
  b,
760
- D,
761
- w,
762
- T,
763
- E,
764
- y,
765
- fe
766
- ]);
767
- function xn(e = {}) {
768
- let t = {};
769
- for (let n of Object.keys(e).sort()) {
770
- if (n.startsWith("metric.") || bn.has(n)) continue;
771
- let r = e[n];
772
- (typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) && (t[n] = r);
773
- }
774
- return t;
775
- }
776
- function Sn(e) {
777
- if (!Array.isArray(e)) return null;
778
- let t = Math.min(e.length, 51);
779
- return Array.from({ length: t }, (t, n) => e[n]);
780
- }
781
- function Cn(e) {
782
- return Array.isArray(e) && e.length <= 50 && e.every((t, n) => typeof t == "number" && Number.isFinite(t) && (n === 0 || t > e[n - 1]));
783
- }
784
- function wn(e, t, n) {
785
- let r = {
786
- "metric.name": e.name,
787
- "metric.unit": e.unit,
788
- "metric.type": e.kind,
789
- [k.start]: n,
790
- [k.attributeKeys]: Object.keys(t.attributes)
791
- };
792
- return e.kind === "counter" ? (r["metric.value"] = t.sum, r) : {
793
- ...r,
794
- [k.count]: t.count,
795
- [k.sum]: t.sum,
796
- [k.min]: t.min,
797
- [k.max]: t.max,
798
- [k.bounds]: e.boundaries,
799
- [k.buckets]: t.buckets
800
- };
801
- }
802
- var Tn = class {
803
- intervalMs;
804
- emit;
805
- diagnostics;
806
- instruments = /* @__PURE__ */ new Map();
807
- timer = null;
808
- startedAt = 0;
809
- constructor(e, t, n) {
810
- this.intervalMs = e, this.emit = t, this.diagnostics = n;
811
- }
812
- record(e, t, n) {
813
- !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}.`, () => {
814
- let r = this.instrumentOf(e);
815
- r && (this.add(r, t, xn(n)), this.arm());
816
- });
817
- }
818
- collect() {
819
- this.timer !== null && (clearTimeout(this.timer), this.timer = null);
820
- let e = `${String(this.startedAt)}000000`, t = [...this.instruments.values()];
821
- this.instruments.clear();
822
- for (let { def: n, series: r } of t) for (let t of r.values()) this.emit(n.name, t.attributes, wn(n, t, e));
823
- }
824
- instrumentOf(e) {
825
- let t = this.instruments.get(e.name);
826
- 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);
827
- let n = Sn(e.boundaries), r = Cn(n);
828
- 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.`);
829
- let i = {
830
- def: {
831
- ...e,
832
- boundaries: r ? n : [...ae]
833
- },
834
- series: /* @__PURE__ */ new Map()
835
- };
836
- return this.instruments.set(e.name, i), i;
837
- }
838
- add(e, t, n) {
839
- let r = JSON.stringify(n), i = e.series.get(r), a = n;
840
- if (!i && e.series.size >= 100 && (r = yn, i = e.series.get(r), a = { [oe]: !0 }), !i) {
841
- let n = e.def.kind === "histogram" ? e.def.boundaries.length + 1 : 0, o = Array(n).fill(0);
842
- i = {
843
- attributes: a,
844
- count: 0,
845
- sum: 0,
846
- min: t,
847
- max: t,
848
- buckets: o
849
- }, e.series.set(r, i);
850
- }
851
- 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) {
852
- let n = e.def.boundaries.findIndex((e) => t <= e);
853
- i.buckets[n === -1 ? i.buckets.length - 1 : n] += 1;
854
- }
855
- }
856
- arm() {
857
- this.timer === null && (this.startedAt = Date.now(), this.timer = setTimeout(() => {
858
- this.collect();
859
- }, this.intervalMs()), ke(this.timer));
860
- }
861
- }, En = "error.", Dn = [
862
- T,
863
- E,
864
- y
1092
+ he
1093
+ ], Gn = {
1094
+ processor: {
1095
+ label: "A processor",
1096
+ code: "record.dropped_by_processor"
1097
+ },
1098
+ redact: {
1099
+ label: "The redact hook",
1100
+ code: "record.dropped_by_redact"
1101
+ }
1102
+ }, Kn = [
1103
+ "metric.name",
1104
+ "metric.unit",
1105
+ "metric.type",
1106
+ "metric.value",
1107
+ ...Object.values(r),
1108
+ ...Object.values(w)
865
1109
  ];
866
- function K(e) {
1110
+ function qn(e) {
1111
+ return Object.fromEntries(Kn.filter((t) => t in e).map((t) => [t, e[t]]));
1112
+ }
1113
+ function q(e) {
867
1114
  return e;
868
1115
  }
869
- var On = class {
1116
+ var Jn = class {
870
1117
  deps;
871
1118
  resourceCache = null;
872
1119
  constructor(e) {
@@ -875,156 +1122,225 @@ var On = class {
875
1122
  invalidateResource() {
876
1123
  this.resourceCache = null;
877
1124
  }
878
- isEnabled(e, t) {
879
- let { config: n } = this.deps;
880
- if (!n.enabled) return !1;
881
- if (t !== void 0 && pe.includes(t)) return !0;
882
- let r = this.deps.remote.sampling?.minLevel() ?? n.minLevel;
883
- return O[e] >= O[r];
1125
+ isEnabled(e, t, n) {
1126
+ let { config: r } = this.deps;
1127
+ if (!r.enabled) return !1;
1128
+ if (n !== void 0 && ye.includes(n)) return !0;
1129
+ let i = this.deps.remote.sampling?.minLevelFor(t) ?? Ie(t, r);
1130
+ return S[e] >= S[i];
884
1131
  }
885
- build(e) {
886
- let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o, remote: s } = this.deps;
887
- if (!this.isEnabled(e.level, e.type)) return n.count("record.dropped_by_level"), {
1132
+ build(e, t = !1) {
1133
+ let { config: n, diagnostics: r, tracing: i, journey: a, sequence: o, limits: s, remote: c } = this.deps;
1134
+ if (!t && !this.isEnabled(e.level, e.namespace, e.type)) return r.count("record.dropped_by_level"), {
888
1135
  record: null,
889
1136
  dropped: "level"
890
1137
  };
891
- let c = r.resolve(), l = i.current();
892
- if (!Pe({
1138
+ let l = e.trace ?? i.resolve(), u = a.current(), d = Le({
893
1139
  level: e.level,
894
1140
  type: e.type,
895
1141
  namespace: e.namespace,
896
- journeyId: l?.id ?? "",
897
- traceId: c.traceId,
1142
+ journeyId: u?.id ?? "",
1143
+ traceId: l.traceId,
898
1144
  aggregated: e.aggregated
899
- }, t, s.sampling?.current() ?? null)) return n.count("record.dropped_by_sampling"), {
1145
+ }, n, c.sampling?.current() ?? null);
1146
+ if (!t && !d) return r.count("record.dropped_by_sampling"), {
900
1147
  record: null,
901
1148
  dropped: "sampling"
902
1149
  };
903
- let u = a.next(), d = qe(n), f = t.capture.fullUrls ? d : Ge(d), p, m = 0;
1150
+ let f = o.next(), p = Qe(r), m = n.metadata.pageUrl ? Xe(p, n.capture.fullUrls, n.capture.urlTransform, r) : "", h, g = 0;
904
1151
  try {
905
- let t = j(this.deps.context.getAll(), o, n), r = j(e.scoped ?? {}, o, n), i = j(e.payload ?? {}, o, n);
906
- m = t.bytes + r.bytes + i.bytes, p = {
907
- ...K(t.value),
908
- ...K(r.value),
909
- ...K(i.value)
1152
+ let t = A(this.deps.context.getAll(), s, r), n = A(this.provided(), s, r), i = A(e.scoped ?? {}, s, r), a = A(e.payload ?? {}, s, r);
1153
+ g = t.bytes + n.bytes + i.bytes + a.bytes, h = {
1154
+ ...q(t.value),
1155
+ ...q(n.value),
1156
+ ...q(i.value),
1157
+ ...q(a.value)
910
1158
  };
911
1159
  } catch (e) {
912
- n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [me]: !0 };
1160
+ r.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), h = { [de]: !0 };
913
1161
  }
914
- 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));
915
- let h = Ie(e.body, o.maxBodyChars);
916
- h !== e.body && n.count("record.truncated");
917
- let g = {
918
- timeUnixNano: Ne(),
919
- traceId: c.traceId,
920
- spanId: c.spanId,
921
- traceFlags: c.traceFlags,
922
- severityNumber: ue[e.level],
1162
+ Object.assign(h, e.fixed), h[ce] = e.type, h[x] = f, h[T] = e.namespace, h[_e] = m, u && (h[b] = u.id, h[he] = u.name, u.parentId !== void 0 && (h[Se] = u.parentId));
1163
+ let _ = Ve(e.body, s.maxBodyChars);
1164
+ _ !== e.body && r.count("record.truncated");
1165
+ let v = {
1166
+ timeUnixNano: Fe(),
1167
+ traceId: l.traceId,
1168
+ spanId: l.spanId,
1169
+ traceFlags: l.traceFlags,
1170
+ severityNumber: oe[e.level],
923
1171
  severityText: e.level,
924
- body: h,
925
- attributes: p,
1172
+ body: _,
1173
+ attributes: h,
926
1174
  resource: this.resource()
927
- }, _ = t.redact;
928
- if (_) {
929
- let t;
930
- try {
931
- t = _(g);
932
- } catch (e) {
933
- return n.report("record.dropped_by_redact", "The redact hook threw an error. The library dropped the record.", void 0, e), {
934
- record: null,
935
- dropped: "redact"
936
- };
937
- }
938
- if (t === null) return n.count("record.dropped_by_redact"), {
1175
+ }, y = n.processors.map((e) => [e, "processor"]);
1176
+ if (n.redact && y.push([n.redact, "redact"]), y.length > 0) {
1177
+ let t = this.applyHooks(v, y, e.fixed);
1178
+ if (typeof t == "string") return {
939
1179
  record: null,
940
- dropped: "redact"
941
- };
942
- let r = t ?? g;
943
- if (!Ae(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."), {
944
- record: null,
945
- dropped: "malformed"
946
- }) : (n.report("record.dropped_by_redact", "The redact hook returned a value that is not a record. The library dropped the record."), {
947
- record: null,
948
- dropped: "redact"
949
- });
950
- if (je(r.severityText)) {
951
- if (r !== g) {
952
- let t = j(r.attributes, o, n);
953
- g = {
954
- ...r,
955
- attributes: K(t.value)
956
- }, m = t.bytes, Object.assign(g.attributes, e.fixed);
957
- }
958
- g.severityNumber = ue[g.severityText];
959
- } else return n.report("record.dropped_malformed", "The redact hook set a severityText that is not a log level. The library dropped the record."), {
960
- record: null,
961
- dropped: "malformed"
1180
+ dropped: t
962
1181
  };
1182
+ ({record: v, bytes: g} = t);
963
1183
  }
964
- if (m > o.maxRecordBytes) {
965
- n.report("record.truncated", "The attributes are larger than the size limit. The library dropped the caller attributes.", {
966
- bytes: m,
967
- body: g.body
1184
+ if (g > s.maxRecordBytes) {
1185
+ r.report("record.truncated", "The attributes are larger than the size limit. The library dropped the caller attributes.", {
1186
+ bytes: g,
1187
+ body: v.body
968
1188
  });
969
1189
  let t = {
970
- [b]: e.type,
971
- [D]: u,
972
- [w]: e.namespace,
973
- [le]: !0,
974
- [ve]: m
1190
+ [ce]: e.type,
1191
+ [x]: f,
1192
+ [T]: e.namespace,
1193
+ [ae]: !0,
1194
+ [fe]: g
975
1195
  };
976
- for (let e of Dn) e in g.attributes && (t[e] = g.attributes[e]);
977
- for (let [e, n] of Object.entries(g.attributes)) e.startsWith(En) && (t[e] = n);
978
- let r = j(t, o, n).bytes;
979
- r > o.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t, ge), r = j(t, o, n).bytes);
980
- let i = g.attributes[v];
1196
+ for (let e of Wn) e in v.attributes && (t[e] = v.attributes[e]);
1197
+ for (let [e, n] of Object.entries(v.attributes)) e.startsWith(Un) && (t[e] = n);
1198
+ let n = A(t, s, r).bytes;
1199
+ n > s.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t, xe), n = A(t, s, r).bytes);
1200
+ let i = v.attributes[C];
981
1201
  if (i !== void 0) {
982
- let e = j(i, o, n).bytes;
983
- r + e <= o.maxRecordBytes && (t[v] = i);
1202
+ let e = A(i, s, r).bytes;
1203
+ n + e <= s.maxRecordBytes && (t[C] = i);
984
1204
  }
985
- Object.assign(t, e.fixed), g.attributes = t;
1205
+ Object.assign(t, e.fixed), v.attributes = t;
1206
+ }
1207
+ return { record: v };
1208
+ }
1209
+ redactForwarded(e) {
1210
+ let { redact: t } = this.deps.config;
1211
+ if (!t) return e;
1212
+ let n = [[t, "redact"]], r = this.applyHooks(e, n, qn(e.attributes));
1213
+ return typeof r == "string" ? null : r.record;
1214
+ }
1215
+ applyHooks(e, t, n) {
1216
+ let r = e;
1217
+ for (let [e, n] of t) {
1218
+ let t = this.runHook(e, n, r);
1219
+ if (typeof t == "string") return t;
1220
+ r = t;
1221
+ }
1222
+ let { diagnostics: i, limits: a } = this.deps, o = A(r.attributes, a, i), s = q(o.value);
1223
+ return Object.assign(s, n), {
1224
+ record: {
1225
+ ...r,
1226
+ attributes: s
1227
+ },
1228
+ bytes: o.bytes
1229
+ };
1230
+ }
1231
+ runHook(e, t, n) {
1232
+ let { diagnostics: r } = this.deps, { label: i, code: a } = Gn[t], o;
1233
+ try {
1234
+ o = e(n);
1235
+ } catch (e) {
1236
+ return r.report(a, `${i} threw an error. The library dropped the record.`, void 0, e), t;
986
1237
  }
987
- return { record: g };
1238
+ if (o === null) return r.count(a), t;
1239
+ let s = o ?? n;
1240
+ return Ne(s) ? Re(s.severityText) ? {
1241
+ ...s,
1242
+ severityNumber: oe[s.severityText]
1243
+ } : (r.report("record.dropped_malformed", `${i} set a severityText that is not a log level. The library dropped the record.`), "malformed") : s === n ? (r.report("record.dropped_malformed", `${i} changed the record to a shape that is not a record. The library dropped it.`), "malformed") : (r.report(a, `${i} returned a value that is not a record. The library dropped the record.`), t);
1244
+ }
1245
+ provided() {
1246
+ let e = this.deps.config.contextProvider;
1247
+ if (!e) return {};
1248
+ let { diagnostics: t } = this.deps, n = t.guard("handler.threw", "The contextProvider threw an error. The record has no attributes from it.", () => {
1249
+ let t = e();
1250
+ return t === void 0 ? {} : O(t) && typeof t.then != "function" ? t : null;
1251
+ });
1252
+ return n === null && t.report("config.invalid", "contextProvider must return an object of attributes. The library ignores the value."), n ?? {};
988
1253
  }
989
1254
  resource() {
990
1255
  if (this.resourceCache) return this.resourceCache;
991
- let { config: e, identity: t, platform: r } = this.deps;
1256
+ let { config: e, identity: n, platform: r } = this.deps;
992
1257
  return this.resourceCache = {
993
- [te]: e.serviceName,
994
- [c]: e.serviceVersion,
995
- [p]: e.environment,
996
- [d]: ce,
997
- [_e]: S,
998
- [s]: he,
999
- [h]: r.platform,
1000
- [ee]: t.sessionId,
1001
- [ne]: t.tabId,
1002
- [u]: t.contextId,
1003
- [o]: r.userAgent,
1004
- ...r.openfinUuid === void 0 ? {} : { [n]: r.openfinUuid },
1005
- ...r.openfinName === void 0 ? {} : { [we]: r.openfinName }
1258
+ [o]: e.serviceName,
1259
+ [l]: e.serviceVersion,
1260
+ [y]: e.environment,
1261
+ [te]: ie,
1262
+ [re]: D,
1263
+ [ne]: le,
1264
+ [s]: r.platform,
1265
+ [be]: n.sessionId,
1266
+ [c]: n.tabId,
1267
+ [t]: n.contextId,
1268
+ ...e.metadata.userAgent ? { [Oe]: r.userAgent } : {},
1269
+ ...!e.metadata.openfin || r.openfinUuid === void 0 ? {} : { [ee]: r.openfinUuid },
1270
+ ...!e.metadata.openfin || r.openfinName === void 0 ? {} : { [_]: r.openfinName }
1006
1271
  }, this.resourceCache;
1007
1272
  }
1008
- }, kn = {
1009
- errors: async () => (await import("./errors-DCZWcHkd.js")).ErrorCapture,
1010
- network: async () => (await import("./network--GoE7_Or.js")).NetworkCapture,
1011
- interactions: async () => (await import("./interactions-BLH_tX87.js")).InteractionCapture,
1273
+ }, Yn = 1e3, Xn = {
1274
+ start: "ui.start",
1275
+ interaction: "ui.interaction",
1276
+ navigation: "ui.navigation",
1277
+ explicit: "ui.trace",
1278
+ maxAge: "ui.trace"
1279
+ };
1280
+ function Zn(e) {
1281
+ return `${String(Math.round(e * Yn))}000`;
1282
+ }
1283
+ function Qn(e) {
1284
+ return {
1285
+ name: Xn[e.reason],
1286
+ kind: "internal",
1287
+ traceId: e.traceId,
1288
+ spanId: e.spanId,
1289
+ parentSpanId: "",
1290
+ startMs: e.startedAt,
1291
+ endMs: e.endedAt,
1292
+ error: !1,
1293
+ attributes: {}
1294
+ };
1295
+ }
1296
+ function $n(e) {
1297
+ return {
1298
+ [w.kind]: e.kind,
1299
+ [w.parentId]: e.parentSpanId,
1300
+ [w.start]: Zn(e.startMs),
1301
+ [w.end]: Zn(e.endMs),
1302
+ [w.status]: e.error ? "error" : "unset"
1303
+ };
1304
+ }
1305
+ //#endregion
1306
+ //#region src/core/runtime.ts
1307
+ var er = {
1308
+ errors: async () => (await import("./errors-BhC7HTSt.js")).ErrorCapture,
1309
+ network: async () => (await import("./network-DdzXDI3J.js")).NetworkCapture,
1310
+ interactions: async () => (await import("./interactions-BUDLxbv1.js")).InteractionCapture,
1012
1311
  webVitals: async () => (await import("./web-vitals-Bflr5jSA.js")).WebVitalsCapture,
1013
- longFrames: async () => (await import("./long-frames-DD_Um9_4.js")).LongFrameCapture,
1014
- console: async () => (await import("./console-Dv5GfaNn.js")).ConsoleCapture
1015
- }, q = Symbol.for(re), J = Symbol.for(m), An = ["batching", "retention"];
1016
- function Y(e) {
1312
+ longFrames: async () => (await import("./long-frames-DI5ypfAF.js")).LongFrameCapture,
1313
+ console: async () => (await import("./console-DbAZYJuy.js")).ConsoleCapture
1314
+ }, tr = /* @__PURE__ */ new WeakMap(), nr = 0;
1315
+ function rr(e) {
1316
+ let t = tr.get(e);
1317
+ return t === void 0 && (t = ++nr, tr.set(e, t)), t;
1318
+ }
1319
+ var ir = Symbol.for(p), ar = Symbol.for(e), or = ["batching", "retention"], sr = {
1320
+ endpoint: null,
1321
+ metricsEndpoint: "",
1322
+ tracesEndpoint: "",
1323
+ headers: void 0,
1324
+ credentials: "omit",
1325
+ transport: void 0,
1326
+ transportOnExit: void 0
1327
+ }, cr = Object.keys(sr);
1328
+ function lr(e) {
1017
1329
  return JSON.stringify({
1018
1330
  ...e,
1331
+ urlTransform: e.urlTransform ? rr(e.urlTransform) : void 0,
1019
1332
  webVitalsLoader: e.webVitalsLoader !== void 0,
1020
1333
  ignoreUrls: e.ignoreUrls.map(String),
1021
- propagateTraceHeaderTo: e.propagateTraceHeaderTo.map(String)
1334
+ propagateTraceHeaderTo: e.propagateTraceHeaderTo.map(String),
1335
+ plugins: e.plugins.map(rr)
1022
1336
  });
1023
1337
  }
1024
- function jn(e) {
1338
+ function ur(e) {
1025
1339
  return {
1026
1340
  ...e,
1027
1341
  endpoint: null,
1342
+ metricsEndpoint: "",
1343
+ tracesEndpoint: "",
1028
1344
  transport: void 0,
1029
1345
  transportOnExit: void 0,
1030
1346
  bus: {
@@ -1033,13 +1349,29 @@ function jn(e) {
1033
1349
  }
1034
1350
  };
1035
1351
  }
1036
- function X(e) {
1037
- return e.sdkVersion === S;
1352
+ function dr(e) {
1353
+ return !!e.endpoint || !!e.metricsEndpoint || !!e.tracesEndpoint || e.transport !== void 0;
1038
1354
  }
1039
- var Z = class e {
1040
- degraded;
1355
+ function fr(e) {
1356
+ return e.sdkVersion === D;
1357
+ }
1358
+ var J = class e {
1359
+ rotating = !1;
1360
+ closingContext = !1;
1361
+ mismatchVersion = null;
1362
+ contextMismatch = !1;
1363
+ rotation;
1364
+ memoryStorage;
1365
+ explicitSecurityContext;
1366
+ ownerAdopted = !1;
1367
+ isRotating() {
1368
+ return this.rotating;
1369
+ }
1370
+ setConfigurationLocked(e) {
1371
+ typeof e == "boolean" && (this.config.lockConfiguration = e);
1372
+ }
1041
1373
  static local = null;
1042
- sdkVersion = S;
1374
+ sdkVersion = D;
1043
1375
  diagnostics;
1044
1376
  config;
1045
1377
  platform;
@@ -1047,10 +1379,10 @@ var Z = class e {
1047
1379
  stores;
1048
1380
  identityBuiltAs;
1049
1381
  sessionTouch;
1050
- context = new hn();
1382
+ context = new Rn();
1051
1383
  breadcrumbs;
1052
1384
  tracing;
1053
- sequence = new lt();
1385
+ sequence = new Ct();
1054
1386
  journey;
1055
1387
  builder;
1056
1388
  remote = { sampling: null };
@@ -1063,7 +1395,7 @@ var Z = class e {
1063
1395
  storageBuiltAs;
1064
1396
  sender;
1065
1397
  senderLoad;
1066
- pendingRecords = new vn((e) => {
1398
+ pendingRecords = new Hn((e) => {
1067
1399
  this.dropHeld(e);
1068
1400
  });
1069
1401
  captures = [];
@@ -1073,7 +1405,7 @@ var Z = class e {
1073
1405
  navigationTiming: !1,
1074
1406
  longFrames: !1
1075
1407
  };
1076
- bootBuffer = new vn((e) => {
1408
+ bootBuffer = new Hn((e) => {
1077
1409
  this.dropHeld(e);
1078
1410
  });
1079
1411
  forwardBuffer = [];
@@ -1086,13 +1418,26 @@ var Z = class e {
1086
1418
  limits;
1087
1419
  journeyOptions;
1088
1420
  tunablesLocked = !0;
1421
+ degraded;
1422
+ serverReported = !1;
1423
+ onPageHide = () => {
1424
+ this.role() === "forwarder" && (this.tracing.end(), this.sendForwarded());
1425
+ };
1089
1426
  constructor(e, t = !1) {
1090
- this.degraded = t, this.diagnostics = new gn(e.onDiagnostic), this.platform = Ke(this.diagnostics), this.config = fn(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? He() : We, this.identity = Ue(this.diagnostics, this.stores), this.sessionTouch = new Be(this.diagnostics, this.stores), this.breadcrumbs = new yt(50), this.tracing = new vt(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.limits = { ...this.config.limits }, this.console = new ct(this.config.console, this.diagnostics, this.limits), this.drops = new _n(this.config, this.diagnostics), this.journeyOptions = {
1091
- ...Ze,
1427
+ this.diagnostics = new zn(e.onDiagnostic), this.platform = Ze(this.diagnostics), this.degraded = t || this.onServer(), this.config = K(this.allowed(e), this.diagnostics), this.explicitSecurityContext = !!e.securityContext?.id, this.config.securityContext.id ||= j(this.diagnostics), this.diagnostics.setPolicy(this.config.diagnostics.throttleMs, this.config.diagnostics.consoleFallback), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" || this.onServer() ? Ke() : Je, this.identity = qe(this.diagnostics, this.stores, this.config.correlation.sessionIdleMs), this.sessionTouch = new We(this.diagnostics, this.stores, this.config.correlation.sessionTouchMs, this.config.correlation.sessionIdleMs), this.breadcrumbs = new Pt(this.config.capturePolicy.breadcrumbs);
1428
+ let n = (e) => Pe(e, this.config.sampling.defaultRate);
1429
+ this.tracing = new Nt(this.diagnostics, this.config.correlation.traceMaxAgeMs || Infinity, this.config.otelLoader, {
1430
+ enabled: () => this.config.tracesEndpoint !== "",
1431
+ keeps: n,
1432
+ onEnd: (e) => {
1433
+ n(e.traceId) && this.recordSpan(Qn(e));
1434
+ }
1435
+ }), this.tracing.loadOtel(), this.limits = { ...this.config.limits }, this.console = new St(this.config.console, this.diagnostics, this.limits), this.drops = new Vn(this.config, this.diagnostics), this.journeyOptions = {
1436
+ ...nt,
1092
1437
  maxAgeMs: this.config.journey.maxAgeMs
1093
- }, this.journey = new Xe(this.journeyOptions, this.diagnostics, this.identity.contextId, (e) => {
1438
+ }, this.journey = new tt(this.journeyOptions, this.diagnostics, this.identity.contextId, (e) => {
1094
1439
  this.bus?.broadcastJourney(e);
1095
- }, this.stores), this.builder = new On({
1440
+ }, this.stores), this.builder = new Jn({
1096
1441
  remote: this.remote,
1097
1442
  config: this.config,
1098
1443
  limits: this.limits,
@@ -1103,77 +1448,142 @@ var Z = class e {
1103
1448
  sequence: this.sequence,
1104
1449
  identity: this.identity,
1105
1450
  platform: this.platform
1106
- }), this.meter = new Tn(() => this.config.batching.metricFlushIntervalMs, (e, t, n) => {
1451
+ }), this.meter = new bt(() => this.config.batching.metricFlushIntervalMs, (e, t, n) => {
1107
1452
  this.emitPoint(e, t, n);
1108
- }, this.diagnostics);
1453
+ }, this.diagnostics, this.config.metrics);
1454
+ }
1455
+ addBreadcrumb(e, t) {
1456
+ this.rotating || this.destroyed || this.diagnostics.guard("record.sanitize_failed", "The library could not add the breadcrumb.", () => {
1457
+ let n = {
1458
+ t: Date.now(),
1459
+ category: "custom",
1460
+ message: Ve(String(e), this.limits.maxBodyChars)
1461
+ };
1462
+ if (t !== void 0) {
1463
+ let e = He(t, this.limits, this.diagnostics);
1464
+ n.data = O(e) ? e : { value: e };
1465
+ }
1466
+ this.breadcrumbs.push(n);
1467
+ });
1109
1468
  }
1110
1469
  recordMetric(e, t, n) {
1111
- this.destroyed || this.meter.record(e, t, n);
1470
+ !this.destroyed && !this.rotating && this.meter.record(e, t, n);
1471
+ }
1472
+ recordSpan(e) {
1473
+ if (this.config.tracesEndpoint === "") return;
1474
+ let { record: t } = this.builder.build({
1475
+ level: "INFO",
1476
+ type: "span",
1477
+ body: e.name,
1478
+ namespace: Te,
1479
+ payload: e.attributes,
1480
+ fixed: $n(e),
1481
+ trace: {
1482
+ traceId: e.traceId,
1483
+ spanId: e.spanId,
1484
+ traceFlags: 1
1485
+ }
1486
+ });
1487
+ this.emit(t);
1112
1488
  }
1113
1489
  emitPoint(e, t, n) {
1114
1490
  let { record: r } = this.builder.build({
1115
1491
  level: "INFO",
1116
1492
  type: "metric",
1117
1493
  body: e,
1118
- namespace: Se,
1494
+ namespace: we,
1119
1495
  payload: t,
1120
1496
  fixed: n,
1121
1497
  aggregated: !0
1122
1498
  });
1123
1499
  this.emit(r);
1124
1500
  }
1125
- busAccept = (e, t) => {
1126
- this.destroyed || this.ensureBus().then((n) => {
1127
- n && !this.destroyed && this.diagnostics.guard("bus.send_failed", "The bus could not accept a direct message from a child frame.", () => {
1128
- n.acceptDirect(e, t);
1501
+ busCanAccept = (e, t) => this.bus?.isRegistered(e, t) ?? !1;
1502
+ busAccept = (e, t, n) => {
1503
+ this.destroyed || this.ensureBus().then((r) => {
1504
+ r && !this.destroyed && this.diagnostics.guard("bus.send_failed", "The bus could not accept a direct message from a child frame.", () => {
1505
+ r.acceptDirect(e, t, n);
1129
1506
  });
1130
1507
  });
1131
1508
  };
1132
1509
  static pinned() {
1133
- return globalThis[q] ?? null;
1510
+ return globalThis[ir] ?? null;
1134
1511
  }
1135
1512
  static current() {
1136
1513
  let t = e.local;
1137
1514
  if (t) return t.destroyed ? null : t;
1138
1515
  let n = e.pinned();
1139
- return n && X(n) ? n : null;
1516
+ return n && fr(n) ? n : null;
1140
1517
  }
1141
1518
  static stopped() {
1142
1519
  let t = e.local;
1143
1520
  if (t?.destroyed) return t;
1144
- let n = globalThis[J];
1145
- return n && X(n) ? n : null;
1521
+ let n = globalThis[ar];
1522
+ return n && fr(n) ? n : null;
1146
1523
  }
1147
1524
  isDestroyed() {
1148
1525
  return this.destroyed;
1149
1526
  }
1150
1527
  static configure(t, n = !1) {
1151
1528
  let r = e.local;
1152
- if (r && !r.destroyed) return r.reconfigure(jn(t)), r;
1529
+ if (r && !r.destroyed) return r.reconfigure(t), r;
1153
1530
  e.local = null;
1154
1531
  let i = e.pinned();
1155
1532
  if (i) {
1156
- if (!X(i)) return e.startDegraded(t, i.sdkVersion);
1533
+ if (!fr(i)) return e.startDegraded(t, i.sdkVersion);
1157
1534
  if (!i.destroyed) return i.reconfigure(t), i;
1158
1535
  }
1159
1536
  let a = new e(t);
1160
- return a.tunablesLocked = !n, globalThis[q] = a, Reflect.deleteProperty(globalThis, J), a.init(), a;
1537
+ return a.tunablesLocked = !n, globalThis[ir] = a, Reflect.deleteProperty(globalThis, ar), a.init(), a;
1161
1538
  }
1162
1539
  static startDegraded(t, n) {
1163
- let r = new e(jn(t), !0);
1540
+ let r = new e(t, !0);
1164
1541
  e.local = r;
1165
1542
  let i = typeof n == "string" ? n : "before 0.9.0";
1166
- 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.`, {
1543
+ return r.mismatchVersion = i, r.diagnostics.report("runtime.version_mismatch", `Another copy of the library, version ${i}, owns the page runtime. This copy, version ${D}, runs in console-only mode and installs no capture. Load one version of the library on the page.`, {
1167
1544
  found: i,
1168
- own: S
1545
+ own: D
1169
1546
  }), r.init(), r;
1170
1547
  }
1171
1548
  reconfigure(e) {
1172
- let t = this.keepDestination(e), n = Y(this.config.capture), r = fn(t, this.diagnostics, this.config);
1173
- this.keepStartupTunables(r), mn(this.config, r), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), Y(this.config.capture) !== n && this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
1549
+ if (this.rotating) {
1550
+ this.diagnostics.report("config.locked", "Configuration cannot change during security-context rotation.");
1551
+ return;
1552
+ }
1553
+ if (this.config.lockConfiguration) {
1554
+ let t = K(e, this.diagnostics, this.config);
1555
+ Y(this.config, t) || this.diagnostics.report("config.locked", "Runtime configuration is locked. Use setConfigurationLocked(false) to unlock it explicitly.");
1556
+ return;
1557
+ }
1558
+ let t = this.keepDestination(this.keepRouting(this.allowed(e)));
1559
+ !this.tunablesLocked && t.securityContext?.id && (this.explicitSecurityContext = !0);
1560
+ for (let e of ["correlation", "persistence"]) (e !== "persistence" || this.tunablesLocked || this.senderLoad !== void 0) && t[e] && !Y({
1561
+ ...this.config[e],
1562
+ ...t[e]
1563
+ }, this.config[e]) && (this.diagnostics.report("config.invalid", `${e} cannot change after startup.`), Object.assign(t, { [e]: this.config[e] }));
1564
+ let n = lr(this.config.capture), r = K(t, this.diagnostics, this.config);
1565
+ this.keepStartupTunables(r), Ln(this.config, r), this.breadcrumbs.resize(this.config.capturePolicy.breadcrumbs), this.diagnostics.setHandler(this.config.onDiagnostic), this.diagnostics.setPolicy(this.config.diagnostics.throttleMs, this.config.diagnostics.consoleFallback), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), lr(this.config.capture) !== n && this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
1566
+ }
1567
+ onServer() {
1568
+ return this.platform.platform === "node";
1569
+ }
1570
+ allowed(e) {
1571
+ return this.degraded ? (this.onServer() && !this.serverReported && dr(e) && (this.serverReported = !0, this.diagnostics.report("config.invalid", "The library runs console-only on Node. It sends no record and installs no capture. It ignores endpoint, metricsEndpoint, tracesEndpoint and transport.")), ur(e)) : e;
1572
+ }
1573
+ keepRouting(e) {
1574
+ if (!this.tunablesLocked || this.degraded || !this.config.securityContext.isolation) return e;
1575
+ let t = K(e, new zn(), this.config), n = cr.filter((e) => !Y(t[e], this.config[e]));
1576
+ if (t.securityContext.id !== this.config.securityContext.id && n.push("securityContext.id"), n.length === 0) return e;
1577
+ let r = { ...e };
1578
+ for (let e of cr) n.includes(e) && Reflect.deleteProperty(r, e);
1579
+ if (n.includes("securityContext.id")) {
1580
+ let t = { ...e.securityContext };
1581
+ Reflect.deleteProperty(t, "id"), r.securityContext = t;
1582
+ }
1583
+ return this.diagnostics.report("config.invalid", `Isolation refuses changes to ${n.join(", ")}. Use rotateSecurityContext() for these changes. To permit them, set securityContext.isolation: false in a separate configure() call. The other settings apply.`), r;
1174
1584
  }
1175
1585
  keepStartupTunables(e) {
1176
- if (this.senderLoad !== void 0 && this.keepSections(e, An), !this.tunablesLocked) {
1586
+ if (this.senderLoad !== void 0 && this.keepSections(e, or), !this.tunablesLocked) {
1177
1587
  this.tunablesLocked = !0, Object.assign(this.limits, e.limits), this.journeyOptions.maxAgeMs = e.journey.maxAgeMs;
1178
1588
  return;
1179
1589
  }
@@ -1182,7 +1592,7 @@ var Z = class e {
1182
1592
  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);
1183
1593
  }
1184
1594
  keepSections(e, t) {
1185
- 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] }));
1595
+ for (let n of t) Y(e[n], 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] }));
1186
1596
  }
1187
1597
  keepBuiltStorage() {
1188
1598
  let e = this.storageBuiltAs;
@@ -1201,6 +1611,7 @@ var Z = class e {
1201
1611
  this.config.identity !== e && (this.diagnostics.report("config.invalid", `identity cannot change after startup. It stays ${e}.`, { requested: this.config.identity }), this.config.identity = e);
1202
1612
  }
1203
1613
  async init() {
1614
+ this.degraded || addEventListener("pagehide", this.onPageHide);
1204
1615
  let e = this.installCaptures();
1205
1616
  this.started = this.boot(), await this.started, await e;
1206
1617
  }
@@ -1231,9 +1642,27 @@ var Z = class e {
1231
1642
  }
1232
1643
  async buildBus() {
1233
1644
  try {
1234
- let { Bus: e } = await import("./bus-C6RwKzPW.js");
1645
+ let { Bus: e } = await import("./bus-DeOPHWaD.js");
1235
1646
  if (this.destroyed) return null;
1236
1647
  let t = new e(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
1648
+ onSecurityContext: (e) => {
1649
+ if (this.explicitSecurityContext && this.config.securityContext.id !== e) return this.contextMismatch = !0, this.diagnostics.report("security.context_mismatch", "The configured security context differs from the upstream owner."), !1;
1650
+ if (this.contextMismatch = !1, this.config.securityContext.id !== e) {
1651
+ if (this.ownerAdopted) {
1652
+ this.drops.add("security_context", [
1653
+ ...this.bootBuffer.take(),
1654
+ ...this.pendingRecords.take(),
1655
+ ...this.forwardBuffer
1656
+ ]), this.forwardBuffer = [], this.context.clear(), this.breadcrumbs.clear();
1657
+ let e = this.rotating;
1658
+ this.rotating = !0, this.meter.collect();
1659
+ let t = this.sessionTouch.stored();
1660
+ this.resetSession(t !== void 0 && t !== this.identity.sessionId ? t : j(this.diagnostics)), this.rotating = e;
1661
+ }
1662
+ this.config.securityContext.id = e;
1663
+ }
1664
+ return this.ownerAdopted = !0, !0;
1665
+ },
1237
1666
  onRecords: (e) => {
1238
1667
  this.ingestForwarded(e);
1239
1668
  },
@@ -1266,14 +1695,18 @@ var Z = class e {
1266
1695
  async buildSender() {
1267
1696
  this.storageBuiltAs = this.config.storage;
1268
1697
  try {
1269
- let { Sender: e } = await import("./sender-BUBWLn5i.js"), t = this.destroyed ? null : await e.create({
1698
+ let { Sender: e } = await import("./sender-DUUmSglb.js"), t = this.destroyed ? null : await e.create({
1699
+ storage: this.memoryStorage,
1700
+ onStorage: (e) => {
1701
+ e.name === "memory" && (this.memoryStorage = e);
1702
+ },
1270
1703
  config: this.config,
1271
1704
  diagnostics: this.diagnostics,
1272
1705
  onGap: this.reportGap,
1273
1706
  onLoss: this.reportLoss,
1274
1707
  remote: this.remote,
1275
1708
  beforeExit: () => {
1276
- this.meter.collect();
1709
+ this.meter.collect(), this.tracing.end();
1277
1710
  }
1278
1711
  });
1279
1712
  if (!t || this.destroyed) {
@@ -1290,21 +1723,27 @@ var Z = class e {
1290
1723
  if (this.degraded) return;
1291
1724
  let e = ++this.captureGeneration, t = this.config.capture, n = [];
1292
1725
  (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");
1293
- let r = await Promise.all(n.map((e) => this.loadCapture(e)));
1726
+ let [r, i] = await Promise.all([Promise.all(n.map((e) => this.loadCapture(e))), t.webSocket ? this.loadWebSocket() : void 0]);
1294
1727
  if (e !== this.captureGeneration || this.destroyed) return;
1295
1728
  this.uninstallCaptures();
1296
1729
  let a = {
1730
+ isActive: () => !this.destroyed && !this.rotating,
1297
1731
  config: this.config,
1298
1732
  diagnostics: this.diagnostics,
1299
1733
  breadcrumbs: this.breadcrumbs,
1300
1734
  tracing: this.tracing,
1301
- logger: new I(() => this, i),
1735
+ logger: new F(() => this, me),
1302
1736
  once: this.captureOnce,
1303
1737
  recordMetric: (e, t, n) => {
1304
1738
  this.recordMetric(e, t, n);
1739
+ },
1740
+ recordSpan: (e) => {
1741
+ this.recordSpan(e);
1305
1742
  }
1306
1743
  };
1307
1744
  for (let e of r) e && this.captures.push(new e(a));
1745
+ let o = i ? [...t.plugins, new i(this.diagnostics, this.config)] : t.plugins;
1746
+ for (let e of o) this.captures.push(this.pluginCapture(e));
1308
1747
  for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `The library could not install the ${e.name} capture.`, () => {
1309
1748
  e.install();
1310
1749
  });
@@ -1315,24 +1754,60 @@ var Z = class e {
1315
1754
  });
1316
1755
  this.captures.length = 0;
1317
1756
  }
1757
+ loadWebSocket() {
1758
+ return this.diagnostics.guardAsync("capture.install_failed", "The library could not load the webSocket capture.", async () => (await import("./web-socket-CpsD8WAa.js")).WebSocketCapture);
1759
+ }
1760
+ pluginCapture(e) {
1761
+ let { name: t } = e, n = (e, t, n) => {
1762
+ this.recordMetric(e, t, n);
1763
+ }, r = {
1764
+ logger: new F(() => this, `${me}.${t}`),
1765
+ counter: (e, t = {}) => vt(e, t, n),
1766
+ histogram: (e, t = {}) => yt(e, t, n),
1767
+ addBreadcrumb: (e, t) => {
1768
+ this.addBreadcrumb(e, t);
1769
+ },
1770
+ ownRequest: Ye
1771
+ };
1772
+ return {
1773
+ name: t,
1774
+ install: () => {
1775
+ e.install(r);
1776
+ },
1777
+ uninstall: () => {
1778
+ e.uninstall();
1779
+ }
1780
+ };
1781
+ }
1318
1782
  loadCapture(e) {
1319
- return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, kn[e]);
1783
+ return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, er[e]);
1320
1784
  }
1321
- registerWorker(e) {
1322
- this.destroyed || this.constructBus().then((t) => {
1323
- t && !this.destroyed && (this.diagnostics.guard("bus.send_failed", "The library could not register the worker.", () => {
1324
- t.attachWorker(e);
1785
+ registerWorker(e, t = {}) {
1786
+ let n = !1, r;
1787
+ return this.destroyed ? () => void 0 : (this.constructBus().then((i) => {
1788
+ !i || this.destroyed || n || (this.diagnostics.guard("bus.send_failed", "The library could not register the worker.", () => {
1789
+ r = i.attachWorker(e, t);
1325
1790
  }), this.ensureBus());
1791
+ }), () => {
1792
+ n = !0, r?.();
1326
1793
  });
1327
1794
  }
1795
+ registerFrame(e, t) {
1796
+ let n = !1, r;
1797
+ return this.constructBus().then((i) => {
1798
+ !i || this.destroyed || n || (r = this.diagnostics.guard("bus.send_failed", "The frame could not be registered.", () => i.registerFrame(e, t)), this.ensureBus());
1799
+ }), () => {
1800
+ n = !0, r?.();
1801
+ };
1802
+ }
1328
1803
  async destroy() {
1329
1804
  if (this.destroyed) return;
1330
- this.meter.collect(), this.destroyed = !0, this.uninstallCaptures();
1805
+ this.meter.collect(), this.tracing.end(), this.destroyed = !0, this.degraded || removeEventListener("pagehide", this.onPageHide), this.uninstallCaptures();
1331
1806
  let t = this.sender?.destroy();
1332
- 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);
1807
+ this.journey.destroy(), this.sendForwarded(), this.bus?.destroy(), this.drops.add("load_failed", this.pendingRecords.take()), await t, await this.senderLoad, await this.rotation?.catch(() => void 0), await this.memoryStorage?.close(), e.pinned() === this && (Reflect.deleteProperty(globalThis, ir), globalThis[ar] = this);
1333
1808
  }
1334
1809
  emit(e) {
1335
- e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.bootBuffer.push(e));
1810
+ !e || this.destroyed || this.rotating && !this.closingContext || (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.bootBuffer.push(e));
1336
1811
  }
1337
1812
  route(e) {
1338
1813
  this.role() === "forwarder" ? this.forward(e) : this.deliver(e);
@@ -1353,12 +1828,30 @@ var Z = class e {
1353
1828
  this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
1354
1829
  }
1355
1830
  ingestForwarded(e) {
1356
- if (!Array.isArray(e)) this.diagnostics.count("record.dropped_malformed");
1357
- else for (let t of e) Ae(t) ? Me(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
1831
+ if (this.destroyed) return;
1832
+ if (!Array.isArray(e)) {
1833
+ this.diagnostics.count("record.dropped_malformed");
1834
+ return;
1835
+ }
1836
+ let t = [];
1837
+ for (let n of e) {
1838
+ if (!Ne(n)) {
1839
+ this.diagnostics.count("record.dropped_malformed");
1840
+ continue;
1841
+ }
1842
+ if (!Me(n, this.config, this.remote.sampling?.current() ?? null)) {
1843
+ this.diagnostics.count("record.dropped_by_sampling");
1844
+ continue;
1845
+ }
1846
+ let e = this.builder.redactForwarded(n);
1847
+ e && t.push(e);
1848
+ }
1849
+ if (this.rotating) this.drops.add("security_context", t);
1850
+ else for (let e of t) this.deliver(e);
1358
1851
  }
1359
1852
  releaseBootBuffer() {
1360
- let e = this.bootBuffer.take(), t = this.journey.current();
1361
- 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);
1853
+ let e = this.bootBuffer.take(), { processors: t, redact: n } = this.config, r = t.length === 0 && n === void 0 ? this.journey.current() : null;
1854
+ for (let t of e) r && !t.attributes["journey.id"] && (t.attributes["journey.id"] = r.id, t.attributes["journey.name"] = r.name), this.route(t);
1362
1855
  }
1363
1856
  reportLoss = (e, t, n) => {
1364
1857
  this.drops.add(e, t, n);
@@ -1366,18 +1859,146 @@ var Z = class e {
1366
1859
  reportGap = (e, t) => {
1367
1860
  this.drops.add(e.reason, t.flatMap((e) => e.records), t.map((e) => e.id));
1368
1861
  let n = Date.now();
1369
- n - this.lastGapAt < 6e4 || (this.lastGapAt = n, new I(() => this, ye).warn("stored records were dropped before delivery", {
1862
+ n - this.lastGapAt < 6e4 || (this.lastGapAt = n, new F(() => this, ge).warn("stored records were dropped before delivery", {
1370
1863
  "gap.batches": e.batches,
1371
1864
  "gap.records": e.records,
1372
1865
  "gap.reason": e.reason
1373
1866
  }));
1374
1867
  };
1375
1868
  regenerateTabId() {
1376
- let e = ze(this.diagnostics);
1869
+ let e = j(this.diagnostics);
1377
1870
  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.", {
1378
1871
  was: this.identity.tabId,
1379
1872
  now: e
1380
- }), this.identity.tabId = e, Re(e, this.diagnostics, this.stores), this.builder.invalidateResource();
1873
+ }), this.identity.tabId = e, Ue(e, this.diagnostics, this.stores), this.builder.invalidateResource();
1874
+ }
1875
+ newSession() {
1876
+ this.destroyed || this.resetSession(j(this.diagnostics));
1877
+ }
1878
+ resetSession(e) {
1879
+ this.meter.collect(), this.tracing.rotate("explicit"), this.journey.end(), this.breadcrumbs.clear(), this.identity.sessionId = e, this.sessionTouch.restart(e), this.builder.invalidateResource();
1880
+ }
1881
+ rotateSecurityContext(e, t = {}) {
1882
+ if (this.rotation) return Promise.reject(/* @__PURE__ */ Error("A security-context rotation is already running."));
1883
+ let n = t.pending ?? "discard", r = t.timeoutMs ?? 5e3;
1884
+ return !O(e) || !O(e.delivery) || ![
1885
+ "discard",
1886
+ "flush",
1887
+ "retain",
1888
+ "carry"
1889
+ ].includes(n) || !Number.isFinite(r) || r < 0 || e.id !== void 0 && (typeof e.id != "string" || e.id.length === 0) ? Promise.reject(/* @__PURE__ */ Error("Invalid security-context rotation options.")) : this.destroyed ? Promise.reject(/* @__PURE__ */ Error("The runtime has stopped.")) : (this.rotating = !0, this.rotation = this.rotateContext(e, n, r).finally(() => {
1890
+ this.rotating = !1, this.rotation = void 0;
1891
+ }), this.rotation);
1892
+ }
1893
+ async rotateContext(e, t, n) {
1894
+ if (await this.started, this.role() === "forwarder") throw Error("Rotate the security context on the upstream owner, or use bus.mode: sender for an independent identity.");
1895
+ await this.senderLoad;
1896
+ let r = this.config.securityContext.id, i = e.id ?? j(this.diagnostics);
1897
+ if (i === r) throw Error("A rotation requires a different security-context id.");
1898
+ let a = {
1899
+ ...sr,
1900
+ ...e.delivery
1901
+ }, o = this.diagnostics.snapshot()["config.invalid"] ?? 0, s = K(this.allowed({
1902
+ ...a,
1903
+ securityContext: { id: i }
1904
+ }), this.diagnostics, {
1905
+ ...this.config,
1906
+ ...sr
1907
+ });
1908
+ if ((this.diagnostics.snapshot()["config.invalid"] ?? 0) !== o) throw Error("Invalid delivery settings for the next security context.");
1909
+ let c = e.context ? Object.fromEntries(Object.entries(e.context)) : void 0, l = /* @__PURE__ */ new Set([
1910
+ this.config.endpoint,
1911
+ this.config.metricsEndpoint,
1912
+ this.config.tracesEndpoint
1913
+ ]), u = /* @__PURE__ */ new Set([
1914
+ s.endpoint,
1915
+ s.metricsEndpoint,
1916
+ s.tracesEndpoint
1917
+ ]);
1918
+ s.capture.ignoreUrls = s.capture.ignoreUrls.filter((e) => !l.has(e) || u.has(e)), this.closingContext = !0;
1919
+ try {
1920
+ this.meter.collect(), this.tracing.end(), this.journey.end();
1921
+ } finally {
1922
+ this.closingContext = !1;
1923
+ }
1924
+ let d = [
1925
+ ...this.bootBuffer.take(),
1926
+ ...this.pendingRecords.take(),
1927
+ ...this.forwardBuffer
1928
+ ];
1929
+ this.forwardBuffer = [];
1930
+ let f = this.sender;
1931
+ this.sender = void 0, this.senderLoad = void 0;
1932
+ let p = await f?.retire(t, n, r) ?? {
1933
+ buffered: [],
1934
+ stored: []
1935
+ };
1936
+ if (this.destroyed) return;
1937
+ let m = [...d, ...p.buffered], h = p.stored.flatMap((e) => e.records);
1938
+ t !== "retain" && t !== "carry" && this.drops.add("security_context", [...m, ...h]), s.lockConfiguration = this.config.lockConfiguration, Ln(this.config, s), this.remote.sampling = null, this.context.clear(), c && this.context.setMany(c), this.breadcrumbs.clear(), this.newSession(), this.builder.invalidateResource(), await this.syncSender(), this.bus?.rotateContext(), t === "carry" && (this.rotating = !1, await this.carry(m, p.stored)), this.diagnostics.report("security.rotated", "The runtime rotated its security context.", { pending: t });
1939
+ }
1940
+ async carry(e, t) {
1941
+ for (let t of e) this.route(t);
1942
+ this.sender && await this.sender.adopt(t, this.config.securityContext.id);
1943
+ }
1944
+ async health() {
1945
+ let e = this.sender?.stats() ?? {
1946
+ pending: 0,
1947
+ inFlight: 0,
1948
+ lastSendAt: null
1949
+ }, t = [];
1950
+ this.mismatchVersion && t.push("runtime.version_mismatch"), this.contextMismatch && t.push("security.context_mismatch"), this.ready && this.hasDestination() && this.role() === "sender" && !this.sender && t.push("sender.unavailable");
1951
+ let { sourcePolicy: n, validation: r, maxMessageBytes: i, maxRecordsPerMessage: a, maxMessagesPerSecond: o, maxTrackedSources: s } = this.config.bus;
1952
+ return {
1953
+ ...e,
1954
+ pending: e.pending + this.bootBuffer.length + this.pendingRecords.length + this.forwardBuffer.length,
1955
+ stored: await this.sender?.queueDepth() ?? 0,
1956
+ sdkVersion: this.sdkVersion,
1957
+ owningSdkVersion: this.mismatchVersion,
1958
+ status: this.destroyed ? "stopped" : this.rotating ? "rotating" : t.length ? "degraded" : this.ready ? "ready" : "starting",
1959
+ mode: this.role() === "forwarder" ? "forwarder" : this.hasDestination() ? "sender" : "console-only",
1960
+ senderReady: this.sender !== void 0 && !this.destroyed && !this.rotating,
1961
+ configurationLocked: this.config.lockConfiguration,
1962
+ issues: t,
1963
+ securityContext: { ...this.config.securityContext },
1964
+ bus: {
1965
+ sourcePolicy: n,
1966
+ validation: r,
1967
+ maxMessageBytes: i,
1968
+ maxRecordsPerMessage: a,
1969
+ maxMessagesPerSecond: o,
1970
+ maxTrackedSources: s
1971
+ }
1972
+ };
1973
+ }
1974
+ async stats() {
1975
+ let e = await this.queueDepth(), t = this.sender?.stats() ?? {
1976
+ pending: 0,
1977
+ inFlight: 0,
1978
+ lastSendAt: null
1979
+ }, n = this.bootBuffer.length + this.pendingRecords.length + this.forwardBuffer.length;
1980
+ return {
1981
+ ...t,
1982
+ pending: t.pending + n,
1983
+ stored: e
1984
+ };
1985
+ }
1986
+ async clearPersisted(e) {
1987
+ if (await this.senderLoad, this.sender) {
1988
+ await this.sender.clearPersisted(e, this.config.securityContext.id);
1989
+ return;
1990
+ }
1991
+ let [{ createStorage: t, storageName: n }, { ContextStorage: r }, { storageLimits: i }, { clearEmergencyContext: a }] = await Promise.all([
1992
+ import("./factory-C5TujXlU.js"),
1993
+ import("./context-storage-DxZf4Gfh.js"),
1994
+ import("./storage-w7Tslvlq.js"),
1995
+ import("./emergency-queue-BYUyDHGD.js")
1996
+ ]), o = this.config.persistence.namespace, s = this.memoryStorage ?? await t(this.config.storage, n(o), i(this.config.retention), this.diagnostics, void 0, o), c = new r(s, this.config.securityContext, o);
1997
+ try {
1998
+ e === "namespace" ? await c.clearNamespace() : await c.clear(), a(this.config.securityContext.id, this.diagnostics, o, e === "namespace");
1999
+ } finally {
2000
+ s !== this.memoryStorage && await c.close();
2001
+ }
1381
2002
  }
1382
2003
  async queueDepth() {
1383
2004
  return await this.senderLoad, await this.sender?.queueDepth() ?? 0;
@@ -1386,9 +2007,18 @@ var Z = class e {
1386
2007
  this.meter.collect(), this.ready || await this.started, this.role() === "forwarder" ? this.sendForwarded() : (await this.senderLoad, await this.sender?.flush());
1387
2008
  }
1388
2009
  };
2010
+ function Y(e, t, n = /* @__PURE__ */ new WeakMap()) {
2011
+ if (Object.is(e, t)) return !0;
2012
+ if (e instanceof RegExp && t instanceof RegExp) return String(e) === String(t);
2013
+ if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
2014
+ if (n.has(e)) return n.get(e) === t;
2015
+ n.set(e, t);
2016
+ let r = Object.keys(e), i = Object.keys(t);
2017
+ return r.length === i.length && r.every((r) => Object.hasOwn(t, r) && Y(Reflect.get(e, r), Reflect.get(t, r), n));
2018
+ }
1389
2019
  //#endregion
1390
2020
  //#region src/transport/memory-transport.ts
1391
- function Mn() {
2021
+ function pr() {
1392
2022
  let e = [], t = [], n = { status: 200 };
1393
2023
  return {
1394
2024
  transport: (r) => (e.push(r), n.status >= 200 && n.status < 300 && t.push(r), Promise.resolve({ ...n })),
@@ -1407,122 +2037,150 @@ function Mn() {
1407
2037
  }
1408
2038
  //#endregion
1409
2039
  //#region src/index.ts
1410
- var Nn = /* @__PURE__ */ new Map();
1411
- function Q() {
1412
- return (Z.current() ?? Z.stopped()) || Z.configure({}, !0);
2040
+ var X = /* @__PURE__ */ new Map();
2041
+ function Z() {
2042
+ return (J.current() ?? J.stopped()) || J.configure({}, !0);
2043
+ }
2044
+ function mr(e = "context") {
2045
+ return ["context", "namespace"].includes(e) ? Z().clearPersisted(e) : Promise.reject(/* @__PURE__ */ Error("Invalid persistence scope."));
1413
2046
  }
1414
- function Pn(e) {
1415
- Z.configure(e);
2047
+ function hr(e) {
2048
+ J.configure(e), Q();
1416
2049
  }
1417
- function Fn(e, t) {
1418
- if (t) return new I(Q, e, t);
1419
- let n = Nn.get(e);
1420
- return n || (n = new I(Q, e), Nn.set(e, n)), n;
2050
+ function gr(e) {
2051
+ Z().setConfigurationLocked(e);
2052
+ }
2053
+ function _r(e, t) {
2054
+ return Z().rotateSecurityContext(e, t);
2055
+ }
2056
+ async function vr() {
2057
+ let e = Z();
2058
+ return Q(), {
2059
+ ...await e.health(),
2060
+ loggerCache: {
2061
+ ...e.config.loggerCache,
2062
+ size: X.size
2063
+ }
2064
+ };
2065
+ }
2066
+ function Q() {
2067
+ let e = (J.current() ?? J.stopped())?.config.loggerCache.maxEntries, t = e === void 0 ? 256 : e;
2068
+ if (t !== null) for (let e of X.keys()) {
2069
+ if (X.size <= t) break;
2070
+ X.delete(e);
2071
+ }
2072
+ return t;
2073
+ }
2074
+ function yr(e, t) {
2075
+ let n = Q();
2076
+ if (t || n === 0) return new F(Z, e, t);
2077
+ let r = X.get(e);
2078
+ return r ??= new F(Z, e), X.delete(e), X.set(e, r), Q(), r;
1421
2079
  }
1422
2080
  function $() {
1423
- return Fn("app");
2081
+ return yr("app");
1424
2082
  }
1425
- function In(e, t) {
2083
+ function br(e, t) {
1426
2084
  $().trace(e, t);
1427
2085
  }
1428
- function Ln(e, t) {
2086
+ function xr(e, t) {
1429
2087
  $().debug(e, t);
1430
2088
  }
1431
- function Rn(e, t) {
2089
+ function Sr(e, t) {
1432
2090
  $().info(e, t);
1433
2091
  }
1434
- function zn(e, t) {
2092
+ function Cr(e, t) {
1435
2093
  $().warn(e, t);
1436
2094
  }
1437
- function Bn(e, t, n) {
2095
+ function wr(e, t, n) {
1438
2096
  $().error(e, t, n);
1439
2097
  }
1440
- function Vn(e, t, n) {
2098
+ function Tr(e, t, n) {
1441
2099
  $().fatal(e, t, n);
1442
2100
  }
1443
- function Hn(e, t) {
2101
+ function Er(e, t) {
1444
2102
  $().logAction(e, t);
1445
2103
  }
1446
- function Un(e, t) {
2104
+ function Dr(e, t) {
1447
2105
  $().logEvent(e, t);
1448
2106
  }
1449
- function Wn(e, t, n, r, i) {
2107
+ function Or(e, t, n, r, i) {
1450
2108
  $().logMetric(e, t, n, r, i);
1451
2109
  }
1452
- function Gn(e, t = {}) {
1453
- let n = {
1454
- name: e,
1455
- kind: "counter",
1456
- unit: t.unit ?? "count",
1457
- boundaries: []
1458
- };
1459
- return { add: (e, t) => {
1460
- Q().recordMetric(n, e, t);
1461
- } };
2110
+ function kr(e, t = {}) {
2111
+ return vt(e, t, (e, t, n) => {
2112
+ Z().recordMetric(e, t, n);
2113
+ });
1462
2114
  }
1463
- function Kn(e, t = {}) {
1464
- let n = {
1465
- name: e,
1466
- kind: "histogram",
1467
- unit: t.unit ?? "count",
1468
- boundaries: t.boundaries ?? ae
1469
- };
1470
- return { record: (e, t) => {
1471
- Q().recordMetric(n, e, t);
1472
- } };
2115
+ function Ar(e, t = {}) {
2116
+ return yt(e, t, (e, t, n) => {
2117
+ Z().recordMetric(e, t, n);
2118
+ });
1473
2119
  }
1474
- function qn(e, t, n) {
2120
+ function jr(e, t, n) {
1475
2121
  return $().timeSync(e, t, n);
1476
2122
  }
1477
- function Jn(e, t, n) {
2123
+ function Mr(e, t, n) {
1478
2124
  return $().timeAsync(e, t, n);
1479
2125
  }
1480
- function Yn(e, t) {
1481
- Q().context.set(e, t);
2126
+ function Nr(e, t) {
2127
+ Z().addBreadcrumb(e, t);
1482
2128
  }
1483
- function Xn(e) {
1484
- Q().context.setMany(e);
2129
+ function Pr(e, t) {
2130
+ Z().context.set(e, t);
1485
2131
  }
1486
- function Zn(e) {
1487
- Q().context.remove(e);
2132
+ function Fr(e) {
2133
+ Z().context.setMany(e);
1488
2134
  }
1489
- function Qn(e, t) {
1490
- return Q().journey.start(e, t);
2135
+ function Ir(e) {
2136
+ Z().context.remove(e);
1491
2137
  }
1492
- function $n() {
1493
- Q().journey.end();
2138
+ function Lr(e, t) {
2139
+ return Z().journey.start(e, t);
1494
2140
  }
1495
- function er() {
1496
- return Q().journey.current();
2141
+ function Rr() {
2142
+ Z().journey.end();
1497
2143
  }
1498
- function tr() {
1499
- return Q().journey.getToken();
2144
+ function zr() {
2145
+ return Z().journey.current();
1500
2146
  }
1501
- function nr(e) {
1502
- return Q().journey.adopt(e, "manual", !0);
2147
+ function Br() {
2148
+ return Z().journey.getToken();
1503
2149
  }
1504
- function rr(e) {
1505
- Q().registerWorker(e);
2150
+ function Vr(e) {
2151
+ return Z().journey.adopt(e, "manual", !0);
2152
+ }
2153
+ function Hr(e, t) {
2154
+ return Z().registerWorker(e, t);
2155
+ }
2156
+ function Ur(e, t) {
2157
+ return Z().registerFrame(e, t);
2158
+ }
2159
+ function Wr() {
2160
+ Z().tracing.rotate("explicit");
2161
+ }
2162
+ function Gr() {
2163
+ return Z().tracing.headers();
1506
2164
  }
1507
- function ir() {
1508
- Q().tracing.rotate("explicit");
2165
+ function Kr() {
2166
+ return Z().flush();
1509
2167
  }
1510
- function ar() {
1511
- return Q().tracing.headers();
2168
+ function qr() {
2169
+ return Z().queueDepth();
1512
2170
  }
1513
- function or() {
1514
- return Q().flush();
2171
+ function Jr() {
2172
+ return Z().stats();
1515
2173
  }
1516
- function sr() {
1517
- return Q().queueDepth();
2174
+ function Yr() {
2175
+ Z().newSession();
1518
2176
  }
1519
- function cr() {
1520
- return Q().diagnostics.snapshot();
2177
+ function Xr() {
2178
+ return Z().diagnostics.snapshot();
1521
2179
  }
1522
- async function lr() {
1523
- await Z.current()?.destroy();
2180
+ async function Zr() {
2181
+ await J.current()?.destroy();
1524
2182
  }
1525
2183
  //#endregion
1526
- export { I as OneLogger, nr as adoptJourney, Pn as configure, Gn as counter, Mn as createMemoryTransport, er as currentJourney, Ln as debug, $n as endJourney, Bn as error, Vn as fatal, or as flush, cr as getDiagnosticCounters, tr as getJourneyToken, Fn as getLogger, sr as getQueueDepth, ar as getTraceHeaders, Kn as histogram, Rn as info, Hn as logAction, Un as logEvent, Wn as logMetric, rr as registerWorker, Zn as removeContext, Yn as setContext, Xn as setContextMap, lr as shutdown, Qn as startJourney, ir as startTrace, Jn as timeAsync, qn as timeSync, In as trace, zn as warn };
2184
+ export { F as OneLogger, Nr as addBreadcrumb, Vr as adoptJourney, mr as clearPersistedLogs, hr as configure, kr as counter, pr as createMemoryTransport, zr as currentJourney, xr as debug, Rr as endJourney, wr as error, Tr as fatal, Kr as flush, Xr as getDiagnosticCounters, vr as getHealth, Br as getJourneyToken, yr as getLogger, qr as getQueueDepth, Jr as getStats, Gr as getTraceHeaders, Ar as histogram, Sr as info, Er as logAction, Dr as logEvent, Or as logMetric, Yr as newSession, Ur as registerFrame, Hr as registerWorker, Ir as removeContext, _r as rotateSecurityContext, gr as setConfigurationLocked, Pr as setContext, Fr as setContextMap, Zr as shutdown, Lr as startJourney, Wr as startTrace, Mr as timeAsync, jr as timeSync, br as trace, Cr as warn };
1527
2185
 
1528
2186
  //# sourceMappingURL=index.js.map