@utk09/ui-observability 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +122 -0
  3. package/dist/bus/bus.d.ts +30 -0
  4. package/dist/bus-CUXRY0JR.cjs +2 -0
  5. package/dist/bus-CUXRY0JR.cjs.map +1 -0
  6. package/dist/{bus-DfAbg_pg.js → bus-DPDrlUBY.js} +96 -50
  7. package/dist/bus-DPDrlUBY.js.map +1 -0
  8. package/dist/capture/console.d.ts +37 -0
  9. package/dist/capture/errors.d.ts +2 -4
  10. package/dist/capture/long-frames.d.ts +31 -0
  11. package/dist/capture/storm.d.ts +17 -0
  12. package/dist/capture/types.d.ts +2 -0
  13. package/dist/console-CNljJict.js +81 -0
  14. package/dist/console-CNljJict.js.map +1 -0
  15. package/dist/console-PKzc-FmR.cjs +2 -0
  16. package/dist/console-PKzc-FmR.cjs.map +1 -0
  17. package/dist/constants-B28fDv2F.cjs +2 -0
  18. package/dist/constants-B28fDv2F.cjs.map +1 -0
  19. package/dist/constants-Bu49bm39.js +93 -0
  20. package/dist/constants-Bu49bm39.js.map +1 -0
  21. package/dist/constants.d.ts +32 -2
  22. package/dist/core/breadcrumbs.d.ts +1 -1
  23. package/dist/core/pipeline.d.ts +2 -2
  24. package/dist/core/record.d.ts +3 -0
  25. package/dist/core/remote-rules.d.ts +17 -0
  26. package/dist/core/remote-sampling.d.ts +65 -0
  27. package/dist/core/runtime.d.ts +10 -4
  28. package/dist/core/sampling.d.ts +5 -2
  29. package/dist/core/sender.d.ts +3 -0
  30. package/dist/errors-C78ZTjet.cjs +3 -0
  31. package/dist/errors-C78ZTjet.cjs.map +1 -0
  32. package/dist/{errors-4MQyjZVj.js → errors-Dnc-X4Ec.js} +19 -20
  33. package/dist/errors-Dnc-X4Ec.js.map +1 -0
  34. package/dist/global-scope-BN-Io_yv.cjs +2 -0
  35. package/dist/global-scope-BN-Io_yv.cjs.map +1 -0
  36. package/dist/global-scope-dp2jADRl.js +19 -0
  37. package/dist/global-scope-dp2jADRl.js.map +1 -0
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.ts +2 -1
  41. package/dist/index.js +287 -242
  42. package/dist/index.js.map +1 -1
  43. package/dist/indexeddb-storage-D0p3iMD0.cjs +2 -0
  44. package/dist/{indexeddb-storage-CcEJlq2l.cjs.map → indexeddb-storage-D0p3iMD0.cjs.map} +1 -1
  45. package/dist/{indexeddb-storage-0LtUALBg.js → indexeddb-storage-uD4oaRMc.js} +10 -10
  46. package/dist/{indexeddb-storage-0LtUALBg.js.map → indexeddb-storage-uD4oaRMc.js.map} +1 -1
  47. package/dist/{interactions-BMNPQ3WH.cjs → interactions-CsE2y_fQ.cjs} +2 -2
  48. package/dist/{interactions-BMNPQ3WH.cjs.map → interactions-CsE2y_fQ.cjs.map} +1 -1
  49. package/dist/{interactions-BaCmoGLB.js → interactions-igKTAJvj.js} +2 -2
  50. package/dist/{interactions-BaCmoGLB.js.map → interactions-igKTAJvj.js.map} +1 -1
  51. package/dist/library-request-Br_T09Bn.cjs +2 -0
  52. package/dist/library-request-Br_T09Bn.cjs.map +1 -0
  53. package/dist/library-request-Dt0fXhcn.js +14 -0
  54. package/dist/library-request-Dt0fXhcn.js.map +1 -0
  55. package/dist/long-frames-6pnjWSSR.js +65 -0
  56. package/dist/long-frames-6pnjWSSR.js.map +1 -0
  57. package/dist/long-frames-DahhqM6u.cjs +2 -0
  58. package/dist/long-frames-DahhqM6u.cjs.map +1 -0
  59. package/dist/models/bus.d.ts +16 -0
  60. package/dist/models/config.d.ts +90 -0
  61. package/dist/network-CZ0aFUsy.cjs +2 -0
  62. package/dist/network-CZ0aFUsy.cjs.map +1 -0
  63. package/dist/{network-jQ2t8rU4.js → network-aSNbwpue.js} +16 -15
  64. package/dist/network-aSNbwpue.js.map +1 -0
  65. package/dist/{platform-YuByH8A5.js → platform-BwbMRwHm.js} +7 -7
  66. package/dist/{platform-YuByH8A5.js.map → platform-BwbMRwHm.js.map} +1 -1
  67. package/dist/{platform-ByQllE_W.cjs → platform-D_XkVIF6.cjs} +2 -2
  68. package/dist/{platform-ByQllE_W.cjs.map → platform-D_XkVIF6.cjs.map} +1 -1
  69. package/dist/remote-rules-5UA23alm.js +86 -0
  70. package/dist/remote-rules-5UA23alm.js.map +1 -0
  71. package/dist/remote-rules-rJJZKVG8.cjs +2 -0
  72. package/dist/remote-rules-rJJZKVG8.cjs.map +1 -0
  73. package/dist/sampling-E4x92Nn2.cjs +2 -0
  74. package/dist/sampling-E4x92Nn2.cjs.map +1 -0
  75. package/dist/sampling-J1eahbfT.js +160 -0
  76. package/dist/sampling-J1eahbfT.js.map +1 -0
  77. package/dist/sanitize-BMhh8ghJ.cjs +2 -0
  78. package/dist/sanitize-BMhh8ghJ.cjs.map +1 -0
  79. package/dist/sanitize-UJ-4Lb0n.js +114 -0
  80. package/dist/sanitize-UJ-4Lb0n.js.map +1 -0
  81. package/dist/sender-B6ufz26f.cjs +3 -0
  82. package/dist/sender-B6ufz26f.cjs.map +1 -0
  83. package/dist/{sender-BIob8eZz.js → sender-G6v4Uqi4.js} +304 -219
  84. package/dist/sender-G6v4Uqi4.js.map +1 -0
  85. package/dist/storm-BtzgLOCX.cjs +2 -0
  86. package/dist/storm-BtzgLOCX.cjs.map +1 -0
  87. package/dist/storm-DJkEZP_8.js +10 -0
  88. package/dist/storm-DJkEZP_8.js.map +1 -0
  89. package/dist/transport/custom-transport.d.ts +20 -0
  90. package/dist/transport/errors.d.ts +2 -1
  91. package/dist/transport/exit-flush.d.ts +15 -0
  92. package/dist/transport/http-transport.d.ts +2 -24
  93. package/dist/transport/memory-transport.d.ts +30 -0
  94. package/dist/transport/retry-engine.d.ts +2 -2
  95. package/dist/transport/serializers/select.d.ts +12 -1
  96. package/dist/transport/status-transport.d.ts +72 -0
  97. package/dist/utils/deadline.d.ts +7 -0
  98. package/dist/utils/global-scope.d.ts +20 -0
  99. package/dist/utils/library-console.d.ts +11 -0
  100. package/dist/utils/library-request.d.ts +12 -0
  101. package/package.json +1 -1
  102. package/dist/bus-DeZzr2bx.cjs +0 -2
  103. package/dist/bus-DeZzr2bx.cjs.map +0 -1
  104. package/dist/bus-DfAbg_pg.js.map +0 -1
  105. package/dist/constants-C8nZQBmQ.js +0 -86
  106. package/dist/constants-C8nZQBmQ.js.map +0 -1
  107. package/dist/constants-IBL_jd5R.cjs +0 -2
  108. package/dist/constants-IBL_jd5R.cjs.map +0 -1
  109. package/dist/errors-4MQyjZVj.js.map +0 -1
  110. package/dist/errors-CUdShXe7.cjs +0 -3
  111. package/dist/errors-CUdShXe7.cjs.map +0 -1
  112. package/dist/indexeddb-storage-CcEJlq2l.cjs +0 -2
  113. package/dist/network-DBNvxCE3.cjs +0 -2
  114. package/dist/network-DBNvxCE3.cjs.map +0 -1
  115. package/dist/network-jQ2t8rU4.js.map +0 -1
  116. package/dist/sampling-CbYySsZ1.js +0 -251
  117. package/dist/sampling-CbYySsZ1.js.map +0 -1
  118. package/dist/sampling-Cs50xsZl.cjs +0 -2
  119. package/dist/sampling-Cs50xsZl.cjs.map +0 -1
  120. package/dist/sender-BIob8eZz.js.map +0 -1
  121. package/dist/sender-iOjzcueM.cjs +0 -3
  122. package/dist/sender-iOjzcueM.cjs.map +0 -1
@@ -1,16 +1,19 @@
1
- import { $t as e, A as t, Ft as n, G as r, I as i, It as a, J as o, Jt as s, K as c, Kt as l, Lt as u, O as d, Ot as ee, Qt as te, R as f, St as p, Vt as ne, Y as re, Zt as ie, _t as m, en as h, ft as g, in as _, k as v, kt as y, l as b, lt as x, ot as S, pt as ae, q as oe, qt as C, rn as se, st as ce, ut as le, v as w, vt as ue, wt as de, xt as T, z as E } from "./constants-C8nZQBmQ.js";
2
- import { _ as D, c as O, f as k, i as A, t as j } from "./sampling-CbYySsZ1.js";
3
- import { t as M } from "./unref-16maCyKA.js";
1
+ import { $t as e, A as t, At as n, Dt as r, Ft as i, G as a, Ht as o, I as s, J as c, K as l, O as u, Ot as d, Pt as f, Qt as ee, R as p, Ut as te, Vt as m, X as ne, Y as re, an as h, bt as g, en as _, ft as v, gt as y, ht as b, in as x, k as ie, l as ae, ln as oe, lt as se, on as S, pt as ce, q as le, qt as ue, rn as de, un as fe, ut as pe, v as C, xt as me, z as w } from "./constants-Bu49bm39.js";
2
+ import { a as T, i as he, l as E, m as D, t as O } from "./sampling-J1eahbfT.js";
3
+ import { o as k, t as A } from "./sanitize-UJ-4Lb0n.js";
4
+ import { t as j } from "./unref-16maCyKA.js";
5
+ import { n as M, t as N } from "./remote-rules-5UA23alm.js";
6
+ import { n as P } from "./library-request-Dt0fXhcn.js";
4
7
  //#region src/models/batch.ts
5
- function N(e) {
8
+ function F(e) {
6
9
  if (typeof e != "object" || !e) return !1;
7
10
  let t = Reflect.get(e, "id"), n = Reflect.get(e, "createdAt"), r = Reflect.get(e, "attempts"), i = Reflect.get(e, "records");
8
11
  return typeof t == "string" && typeof n == "number" && typeof r == "number" && Array.isArray(i);
9
12
  }
10
- function P(e, t) {
13
+ function I(e, t) {
11
14
  if (e.records.length < 2) return null;
12
15
  let n = Math.floor(e.records.length / 2), r = (n) => ({
13
- id: O(t),
16
+ id: E(t),
14
17
  records: n,
15
18
  createdAt: e.createdAt,
16
19
  attempts: e.attempts
@@ -19,13 +22,13 @@ function P(e, t) {
19
22
  }
20
23
  //#endregion
21
24
  //#region src/utils/lock.ts
22
- function F(e, t, n, { skipIfBusy: r = !0 } = {}) {
25
+ function L(e, t, n, { skipIfBusy: r = !0 } = {}) {
23
26
  let i = globalThis.navigator?.locks;
24
27
  return i?.request ? t.guardAsync("storage.degraded", `The library could not get the lock ${e}.`, () => i.request(e, { ifAvailable: r }, (e) => e ? n() : Promise.resolve(void 0))) : n();
25
28
  }
26
29
  //#endregion
27
30
  //#region src/storage/keys.ts
28
- function I(e, t) {
31
+ function R(e, t) {
29
32
  let n = [];
30
33
  return t.guard("storage.unavailable", "The library could not list the localStorage keys.", () => {
31
34
  for (let t = 0; t < localStorage.length; t++) {
@@ -36,57 +39,57 @@ function I(e, t) {
36
39
  }
37
40
  //#endregion
38
41
  //#region src/storage/emergency-queue.ts
39
- function L(e) {
42
+ function ge(e) {
40
43
  let t = String(e.createdAt).padStart(14, "0");
41
- return `${f}${t}.${e.id}`;
44
+ return `${p}${t}.${e.id}`;
42
45
  }
43
- function R(e, t) {
46
+ function _e(e, t) {
44
47
  let n = t.guard("storage.degraded", "An emergency entry is not valid JSON. The library dropped it.", () => JSON.parse(e));
45
- return n === void 0 ? null : N(n) ? n : (t.report("storage.degraded", "An emergency entry is not a batch. The library dropped it."), null);
48
+ return n === void 0 ? null : F(n) ? n : (t.report("storage.degraded", "An emergency entry is not a batch. The library dropped it."), null);
46
49
  }
47
- async function z(e, t) {
48
- let n = 0;
49
- for (let r of I(f, t)) {
50
- let i = t.guard("storage.unavailable", "The library could not read the emergency queue.", () => {
51
- let e = localStorage.getItem(r);
52
- return localStorage.removeItem(r), e;
50
+ async function ve(t, n) {
51
+ let r = 0;
52
+ for (let i of R(p, n)) {
53
+ let a = n.guard("storage.unavailable", "The library could not read the emergency queue.", () => {
54
+ let e = localStorage.getItem(i);
55
+ return localStorage.removeItem(i), e;
53
56
  });
54
- if (!i) continue;
55
- let a = R(i, t);
56
- if (a !== null) try {
57
- await A(e.save(a), C), n++;
57
+ if (!a) continue;
58
+ let o = _e(a, n);
59
+ if (o !== null) try {
60
+ await T(t.save(o), e), r++;
58
61
  } catch (e) {
59
- t.report("storage.degraded", "The library could not recover an emergency batch.", { key: r }, e);
62
+ n.report("storage.degraded", "The library could not recover an emergency batch.", { key: i }, e);
60
63
  }
61
64
  }
62
- return n;
65
+ return r;
63
66
  }
64
- function B(e, t) {
67
+ function z(e, t) {
65
68
  let n = `writing the emergency queue, ${String(e.records.length)} records`;
66
69
  t.guard("storage.quota_exceeded", n, () => {
67
- let n = I(f, t);
70
+ let n = R(p, t);
68
71
  for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) localStorage.removeItem(e);
69
- localStorage.setItem(L(e), JSON.stringify(e));
72
+ localStorage.setItem(ge(e), JSON.stringify(e));
70
73
  });
71
74
  }
72
- async function V(e, t) {
73
- return await F("ui-observability.emergency", t, () => z(e, t), { skipIfBusy: !1 }) ?? 0;
75
+ async function ye(e, t) {
76
+ return await L("ui-observability.emergency", t, () => ve(e, t), { skipIfBusy: !1 }) ?? 0;
74
77
  }
75
78
  //#endregion
76
79
  //#region src/storage/local-storage.ts
77
- function H(e) {
80
+ function be(e) {
78
81
  let t = String(e.createdAt).padStart(14, "0");
79
- return `${w}${t}.${e.id}`;
82
+ return `${C}${t}.${e.id}`;
80
83
  }
81
- function fe(e) {
82
- let t = w.length, n = Number(e.slice(t, t + 14));
84
+ function xe(e) {
85
+ let t = C.length, n = Number(e.slice(t, t + 14));
83
86
  return Number.isFinite(n) ? n : null;
84
87
  }
85
- var pe = class {
88
+ var Se = class {
86
89
  limits;
87
90
  diagnostics;
88
91
  onGap;
89
- name = ie;
92
+ name = de;
90
93
  constructor(e, t, n) {
91
94
  this.limits = e, this.diagnostics = t, this.onGap = n;
92
95
  }
@@ -127,7 +130,7 @@ var pe = class {
127
130
  this.removeKey(e), t.batches++, t.records += n?.records.length ?? 0;
128
131
  }, r = [];
129
132
  for (let t of this.keys()) {
130
- let i = fe(t);
133
+ let i = xe(t);
131
134
  i === null || i < e ? n(t) : r.push(t);
132
135
  }
133
136
  let i = r.length - this.limits.maxBatches;
@@ -147,7 +150,7 @@ var pe = class {
147
150
  return Promise.resolve();
148
151
  }
149
152
  write(e, t) {
150
- return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(H(e), JSON.stringify(e)), !0)) === !0;
153
+ return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(be(e), JSON.stringify(e)), !0)) === !0;
151
154
  }
152
155
  evictForQuota() {
153
156
  let e = this.keys(), t = {
@@ -168,7 +171,7 @@ var pe = class {
168
171
  let t = this.diagnostics.guard("storage.unavailable", "The library could not read a stored batch.", () => localStorage.getItem(e));
169
172
  if (!t) return null;
170
173
  let n = this.diagnostics.guard("storage.degraded", "A stored batch is corrupt. The library removed it.", () => JSON.parse(t));
171
- return n === void 0 ? null : N(n) ? n : (this.diagnostics.report("storage.degraded", "A stored entry is not a batch. The library dropped it."), null);
174
+ return n === void 0 ? null : F(n) ? n : (this.diagnostics.report("storage.degraded", "A stored entry is not a batch. The library dropped it."), null);
172
175
  }
173
176
  keyOf(e) {
174
177
  return this.keys().find((t) => t.endsWith(`.${e}`)) ?? null;
@@ -182,18 +185,18 @@ var pe = class {
182
185
  });
183
186
  }
184
187
  keys() {
185
- return I(w, this.diagnostics);
188
+ return R(C, this.diagnostics);
186
189
  }
187
190
  };
188
191
  //#endregion
189
192
  //#region src/storage/memory-storage.ts
190
- function U(e) {
193
+ function B(e) {
191
194
  return e.reduce((e, t) => e + t.records.length, 0);
192
195
  }
193
- var W = class {
196
+ var V = class {
194
197
  limits;
195
198
  onGap;
196
- name = te;
199
+ name = x;
197
200
  batches = [];
198
201
  constructor(e, t) {
199
202
  this.limits = e, this.onGap = t;
@@ -217,12 +220,12 @@ var W = class {
217
220
  records: 0,
218
221
  reason: "expired"
219
222
  }, n = this.batches.filter((t) => t.createdAt < e);
220
- this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records += U(n);
223
+ this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records += B(n);
221
224
  let r = this.batches.length - this.limits.maxBatches;
222
225
  if (r > 0) {
223
226
  t.reason = "over_capacity";
224
227
  let e = this.batches.slice(0, r);
225
- this.batches = this.batches.slice(r), t.batches += e.length, t.records += U(e);
228
+ this.batches = this.batches.slice(r), t.batches += e.length, t.records += B(e);
226
229
  }
227
230
  return t.batches > 0 && this.onGap?.(t), Promise.resolve(t);
228
231
  }
@@ -235,8 +238,8 @@ var W = class {
235
238
  close() {
236
239
  return this.batches = [], Promise.resolve();
237
240
  }
238
- }, me = {
239
- name: e,
241
+ }, Ce = {
242
+ name: h,
240
243
  save: () => Promise.resolve(),
241
244
  take: () => Promise.resolve([]),
242
245
  remove: () => Promise.resolve(),
@@ -250,91 +253,109 @@ var W = class {
250
253
  clear: () => Promise.resolve(),
251
254
  close: () => Promise.resolve()
252
255
  };
253
- function he(e) {
256
+ function we(e) {
254
257
  return e.guard("storage.unavailable", "The library could not read indexedDB.", () => globalThis.indexedDB != null) === !0;
255
258
  }
256
- function ge(e) {
257
- return e.guard("storage.unavailable", "The library could not write a test key to localStorage.", () => (localStorage.setItem(h, "1"), localStorage.removeItem(h), !0)) === !0;
259
+ function Te(e) {
260
+ return e.guard("storage.unavailable", "The library could not write a test key to localStorage.", () => (localStorage.setItem(S, "1"), localStorage.removeItem(S), !0)) === !0;
258
261
  }
259
- async function _e(e, t, n, r, i) {
260
- if (e === "none") return me;
261
- if (e === "memory") return new W(n, i);
262
+ async function Ee(e, t, n, r, i) {
263
+ if (e === "none") return Ce;
264
+ if (e === "memory") return new V(n, i);
262
265
  if (e === "indexeddb" || e === "auto") {
263
- if (he(r)) {
266
+ if (we(r)) {
264
267
  let e = await r.guardAsync("storage.unavailable", "The library could not open IndexedDB.", async () => {
265
- let { IndexedDbStorage: e } = await import("./indexeddb-storage-0LtUALBg.js"), a = new e(t, n, r, i);
268
+ let { IndexedDbStorage: e } = await import("./indexeddb-storage-uD4oaRMc.js"), a = new e(t, n, r, i);
266
269
  return await a.open(), a;
267
270
  });
268
271
  if (e) return e;
269
272
  }
270
- if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new W(n, i);
273
+ if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new V(n, i);
274
+ }
275
+ return Te(r) ? new Se(n, r, i) : (r.report("storage.degraded", "No persistent storage is available. The library keeps undelivered records in memory only."), new V(n, i));
276
+ }
277
+ //#endregion
278
+ //#region src/transport/errors.ts
279
+ var H = class extends Error {
280
+ kind;
281
+ status;
282
+ retryAfterMs;
283
+ maxBytes;
284
+ constructor(e, t, n, r, i, a) {
285
+ super(t, a === void 0 ? void 0 : { cause: a }), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
271
286
  }
272
- return ge(r) ? new pe(n, r, i) : (r.report("storage.degraded", "No persistent storage is available. The library keeps undelivered records in memory only."), new W(n, i));
287
+ };
288
+ function De(e) {
289
+ if (!e) return;
290
+ let t = Number(e);
291
+ if (Number.isFinite(t)) return Math.max(0, t * ce);
292
+ let n = Date.parse(e);
293
+ return Number.isNaN(n) ? void 0 : Math.max(0, n - Date.now());
273
294
  }
274
295
  //#endregion
275
296
  //#region src/transport/serializers/ecs.ts
276
- function ve(e) {
277
- return g.test(e) ? Number(BigInt(e) / ae) : Date.now();
297
+ function Oe(e) {
298
+ return b.test(e) ? Number(BigInt(e) / y) : Date.now();
278
299
  }
279
- function ye(e) {
300
+ function ke(e) {
280
301
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : typeof e == "bigint" ? e.toString() : null;
281
302
  }
282
- function be(e, t, n) {
303
+ function Ae(e, t, n) {
283
304
  let r = e[t];
284
305
  r === void 0 ? e[t] = n : Array.isArray(r) ? r.push(n) : e[t] = [r, n];
285
306
  }
286
- function G(e, t, n, r) {
287
- let i = ye(n);
288
- if (i !== null) be(e, t, i);
307
+ function U(e, t, n, r) {
308
+ let i = ke(n);
309
+ if (i !== null) Ae(e, t, i);
289
310
  else if (typeof n == "object" && n && !r.has(n)) {
290
- if (r.add(n), Array.isArray(n)) for (let i of n) G(e, t, i, r);
291
- else for (let [i, a] of Object.entries(n)) G(e, `${t}.${i}`, a, r);
311
+ if (r.add(n), Array.isArray(n)) for (let i of n) U(e, t, i, r);
312
+ else for (let [i, a] of Object.entries(n)) U(e, `${t}.${i}`, a, r);
292
313
  r.delete(n);
293
314
  }
294
315
  }
295
- function K(e) {
316
+ function W(e) {
296
317
  let t = Object.create(null), n = /* @__PURE__ */ new WeakSet();
297
- for (let [r, i] of Object.entries(e)) G(t, r, i, n);
318
+ for (let [r, i] of Object.entries(e)) U(t, r, i, n);
298
319
  return t;
299
320
  }
300
- var xe = {
321
+ var je = {
301
322
  name: "ecs",
302
323
  serialize(e) {
303
324
  return {
304
325
  body: `${e.map((e) => {
305
- let t = ve(e.timeUnixNano);
326
+ let t = Oe(e.timeUnixNano);
306
327
  return JSON.stringify({
307
328
  "@timestamp": new Date(t).toISOString(),
308
329
  message: e.body,
309
- log: { level: i[e.severityText] ?? e.severityText.toLowerCase() },
330
+ log: { level: s[e.severityText] ?? e.severityText.toLowerCase() },
310
331
  trace: { id: e.traceId },
311
332
  span: { id: e.spanId },
312
333
  service: {
313
- name: e.resource[ee],
314
- version: e.resource[y],
315
- environment: e.resource[de]
334
+ name: e.resource[f],
335
+ version: e.resource[i],
336
+ environment: e.resource[n]
316
337
  },
317
- user_agent: { original: e.resource[p] },
338
+ user_agent: { original: e.resource[d] },
318
339
  url: { full: e.attributes["url.full"] ?? e.attributes["page.url"] },
319
340
  labels: {
320
- ...K(e.resource),
321
- ...K(e.attributes)
341
+ ...W(e.resource),
342
+ ...W(e.attributes)
322
343
  }
323
344
  });
324
345
  }).join("\n")}\n`,
325
- contentType: v
346
+ contentType: ie
326
347
  };
327
348
  }
328
349
  };
329
350
  //#endregion
330
351
  //#region src/transport/serializers/otlp.ts
331
- function q(e) {
332
- return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(q).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: J(e) } } : null;
352
+ function G(e) {
353
+ return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(G).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: K(e) } } : null;
333
354
  }
334
- function J(e) {
355
+ function K(e) {
335
356
  let t = [];
336
357
  for (let [n, r] of Object.entries(e)) {
337
- let e = q(r);
358
+ let e = G(r);
338
359
  e && t.push({
339
360
  key: n,
340
361
  value: e
@@ -342,30 +363,30 @@ function J(e) {
342
363
  }
343
364
  return t;
344
365
  }
345
- var Y = /* @__PURE__ */ new WeakMap();
346
- function Se(e) {
347
- let t = Y.get(e);
366
+ var q = /* @__PURE__ */ new WeakMap();
367
+ function Me(e) {
368
+ let t = q.get(e);
348
369
  if (t !== void 0) return t;
349
370
  let n = JSON.stringify(e);
350
- return Y.set(e, n), n;
371
+ return q.set(e, n), n;
351
372
  }
352
- var Ce = {
353
- name: ne,
373
+ var Ne = {
374
+ name: ue,
354
375
  serialize(e) {
355
376
  let t = /* @__PURE__ */ new Map();
356
377
  for (let n of e) {
357
- let e = Se(n.resource), r = t.get(e);
378
+ let e = Me(n.resource), r = t.get(e);
358
379
  r ? r.records.push(n) : t.set(e, {
359
380
  resource: n.resource,
360
381
  records: [n]
361
382
  });
362
383
  }
363
384
  let n = [...t.values()].map((e) => ({
364
- resource: { attributes: J(e.resource) },
385
+ resource: { attributes: K(e.resource) },
365
386
  scopeLogs: [{
366
387
  scope: {
367
- name: se,
368
- version: _
388
+ name: oe,
389
+ version: fe
369
390
  },
370
391
  logRecords: e.records.map((e) => ({
371
392
  timeUnixNano: e.timeUnixNano,
@@ -376,24 +397,109 @@ var Ce = {
376
397
  traceId: e.traceId,
377
398
  spanId: e.spanId,
378
399
  flags: e.traceFlags,
379
- attributes: J(e.attributes)
400
+ attributes: K(e.attributes)
380
401
  }))
381
402
  }]
382
403
  }));
383
404
  return {
384
405
  body: JSON.stringify({ resourceLogs: n }),
385
- contentType: d
406
+ contentType: u
386
407
  };
387
408
  }
388
409
  };
389
410
  //#endregion
390
411
  //#region src/transport/serializers/select.ts
391
- function X(e) {
392
- return e === "otlp" ? Ce : e === "ecs" ? xe : e;
412
+ function Pe(e) {
413
+ return e === "otlp" ? Ne : e === "ecs" ? je : e;
414
+ }
415
+ function J(e, t, n, r) {
416
+ try {
417
+ return Pe(e).serialize(t.records);
418
+ } catch (e) {
419
+ n.report("transport.serialize_failed", r, { batchId: t.id }, e);
420
+ return;
421
+ }
393
422
  }
394
423
  //#endregion
395
- //#region src/transport/exit-flush.ts
396
- var we = class {
424
+ //#region src/transport/status-transport.ts
425
+ var Y = class {
426
+ config;
427
+ diagnostics;
428
+ onSampling;
429
+ throttledUntil = 0;
430
+ constructor(e, t, n = () => void 0) {
431
+ this.config = e, this.diagnostics = t, this.onSampling = n;
432
+ }
433
+ throttledForMs() {
434
+ return Math.max(0, this.throttledUntil - Date.now());
435
+ }
436
+ serialize(e) {
437
+ return J(this.config.serializer, e, this.diagnostics, "The serializer threw an error. The library dropped the batch.");
438
+ }
439
+ accept(e) {
440
+ this.throttledUntil = 0, this.config.sampling.remote && e != null && this.onSampling(e);
441
+ }
442
+ reject(e, t, n) {
443
+ let r = String(e);
444
+ if (e === 401 || e === 403) {
445
+ let t = n.advice === void 0 ? "" : ` ${n.advice}`;
446
+ return this.diagnostics.report("transport.rejected_credentials", `The server returned ${r}.${t}`, {
447
+ status: e,
448
+ endpoint: this.config.endpoint
449
+ }), new H("permanent", `The server rejected the batch with ${r}.`, e);
450
+ }
451
+ if (e === 413) return new H("too_large", "The payload is too large.", e, void 0, n.maxBytes);
452
+ if (e === 429 || e === 503) {
453
+ let t = e === 429;
454
+ return this.throttledUntil = Date.now() + (n.retryAfterMs ?? 2e3), t && this.diagnostics.report("transport.throttled", "The server throttles the requests.", { retryAfterMs: n.retryAfterMs }), new H("throttled", t ? "The server throttles the requests." : "The service is not available.", e, n.retryAfterMs);
455
+ }
456
+ return e === 408 || e >= 500 ? new H("transient", `The server returned the error ${r}.`, e) : (this.diagnostics.report("transport.dropped_permanent", `The server rejected the batch with ${r}. The library dropped it.`, {
457
+ batchId: t,
458
+ status: e
459
+ }), new H("permanent", `The server rejected the batch with ${r}.`, e));
460
+ }
461
+ };
462
+ //#endregion
463
+ //#region src/transport/custom-transport.ts
464
+ function X(e, t) {
465
+ return {
466
+ body: t.body,
467
+ contentType: t.contentType,
468
+ batchId: e.id,
469
+ attempt: e.attempts,
470
+ records: e.records
471
+ };
472
+ }
473
+ function Fe(e) {
474
+ if (typeof e != "object" || !e) return !1;
475
+ let t = Reflect.get(e, "status");
476
+ return typeof t == "number" && Number.isInteger(t) && t >= 100 && t <= 599;
477
+ }
478
+ function Z(e) {
479
+ return typeof e == "number" && Number.isFinite(e) ? Math.max(0, e) : void 0;
480
+ }
481
+ var Ie = class extends Y {
482
+ async send(e) {
483
+ let { transport: t } = this.config;
484
+ if (!t || e.records.length === 0) return;
485
+ let n = this.serialize(e);
486
+ if (!n) return;
487
+ let i = X(e, n), a;
488
+ try {
489
+ a = await T(P(() => k(() => t(i))), r);
490
+ } catch (e) {
491
+ let t = e instanceof he ? e : void 0;
492
+ throw new H(t ? "timeout" : "transient", t?.message ?? "The custom transport failed.", void 0, void 0, void 0, e);
493
+ }
494
+ if (!Fe(a)) throw this.diagnostics.report("transport.http_error", "The custom transport returned no valid status. The library sends the batch again later.", { batchId: e.id }), new H("transient", "The custom transport returned no valid status.");
495
+ let { status: o } = a;
496
+ if (o >= 200 && o < 300) this.accept(a.sampling);
497
+ else throw this.reject(o, e.id, {
498
+ retryAfterMs: Z(a.retryAfterMs),
499
+ maxBytes: Z(a.maxBytes)
500
+ });
501
+ }
502
+ }, Le = class {
397
503
  deps;
398
504
  installed = !1;
399
505
  onVisibility = () => {
@@ -428,19 +534,35 @@ var we = class {
428
534
  });
429
535
  }
430
536
  flush(e) {
431
- let { diagnostics: t } = this.deps, n = this.endpointUrl();
432
- if (n === null) return;
433
- let r = this.drain(e);
434
- if (!r || r.records.length === 0) return;
435
- let i = t.guard("transport.serialize_failed", `The ${e} exit flush could not serialize its batch.`, () => X(this.deps.config.serializer).serialize(r.records));
436
- if (!i) return;
437
- if (k(i.body) > 6e4) {
438
- B(r, t);
537
+ let { config: t, diagnostics: n } = this.deps;
538
+ if (t.transport) {
539
+ this.flushCustom(e, t.transportOnExit);
439
540
  return;
440
541
  }
441
- n.searchParams.set(m, r.id), n.searchParams.set(ue, e);
442
- let a = n.toString(), o = this.beacon(a, i.body);
443
- o !== "sent" && (o === "refused" ? B(r, t) : this.keepaliveFetch(a, i.body, e));
542
+ let r = this.endpointUrl();
543
+ if (r === null) return;
544
+ let i = this.drain(e);
545
+ if (!i || i.records.length === 0) return;
546
+ let a = this.serialize(i, e);
547
+ if (!a) return;
548
+ if (A(a.body) > 6e4) {
549
+ z(i, n);
550
+ return;
551
+ }
552
+ r.searchParams.set(g, i.id), r.searchParams.set(me, e);
553
+ let o = r.toString(), s = this.beacon(o, a.body);
554
+ s !== "sent" && (s === "refused" ? z(i, n) : this.keepaliveFetch(o, a.body, e));
555
+ }
556
+ flushCustom(e, t) {
557
+ let { diagnostics: n } = this.deps;
558
+ if (e === "hidden" && !t) return;
559
+ let r = this.drain(e);
560
+ if (!r || r.records.length === 0) return;
561
+ let i = this.serialize(r, e);
562
+ i && (t === void 0 || n.guard("transport.http_error", "The transportOnExit hook threw an error.", () => P(() => t(X(r, i)))) !== !0) && z(r, n);
563
+ }
564
+ serialize(e, t) {
565
+ return J(this.deps.config.serializer, e, this.deps.diagnostics, `The ${t} exit flush could not serialize its batch.`);
444
566
  }
445
567
  drain(e) {
446
568
  return e === "hidden" ? this.deps.drainPending() : this.deps.drainForExit();
@@ -450,7 +572,7 @@ var we = class {
450
572
  return e ? this.deps.diagnostics.guard("config.invalid", `The exit flush cannot use the endpoint ${e}.`, () => new URL(e)) ?? null : null;
451
573
  }
452
574
  beacon(e, t) {
453
- return this.deps.diagnostics.guard("transport.http_error", "sendBeacon", () => {
575
+ return this.deps.diagnostics.guard("transport.http_error", "The sendBeacon call failed.", () => {
454
576
  let n = globalThis.navigator;
455
577
  return n?.sendBeacon ? n.sendBeacon(e, new Blob([t], { type: "text/plain;charset=UTF-8" })) ? "sent" : "refused" : "unavailable";
456
578
  }) ?? "unavailable";
@@ -461,7 +583,7 @@ var we = class {
461
583
  fetch(e, {
462
584
  method: "POST",
463
585
  body: n,
464
- headers: { [o]: t },
586
+ headers: { [c]: t },
465
587
  credentials: i.credentials,
466
588
  keepalive: !0
467
589
  }).catch((e) => {
@@ -472,104 +594,64 @@ var we = class {
472
594
  };
473
595
  //#endregion
474
596
  //#region src/transport/compression.ts
475
- async function Te(e) {
597
+ async function Re(e) {
476
598
  let t = globalThis.CompressionStream;
477
599
  if (t === void 0) return null;
478
- let n = new Blob([e]).stream().pipeThrough(new t(E)), r = await new Response(n).arrayBuffer();
600
+ let n = new Blob([e]).stream().pipeThrough(new t(w)), r = await new Response(n).arrayBuffer();
479
601
  return new Uint8Array(r);
480
602
  }
481
603
  //#endregion
482
- //#region src/transport/errors.ts
483
- var Z = class extends Error {
484
- kind;
485
- status;
486
- retryAfterMs;
487
- maxBytes;
488
- constructor(e, t, n, r, i) {
489
- super(t), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
490
- }
491
- };
492
- function Ee(e) {
493
- if (!e) return;
494
- let t = Number(e);
495
- if (Number.isFinite(t)) return Math.max(0, t * le);
496
- let n = Date.parse(e);
497
- return Number.isNaN(n) ? void 0 : Math.max(0, n - Date.now());
498
- }
499
- //#endregion
500
604
  //#region src/transport/http-transport.ts
501
- var Q = class {
502
- config;
503
- diagnostics;
504
- throttledUntil = 0;
505
- constructor(e, t) {
506
- this.config = e, this.diagnostics = t;
507
- }
605
+ var Q = "In a cross-origin iframe, the session cookie is a third-party cookie. The browser often blocks it. Forward the records to the platform document. As an alternative, issue the cookie with the Partitioned attribute.", ze = class extends Y {
508
606
  async send(e) {
509
607
  let { endpoint: t } = this.config;
510
608
  t && e.records.length !== 0 && await this.post(e, t);
511
609
  }
512
- throttledForMs() {
513
- return Math.max(0, this.throttledUntil - Date.now());
514
- }
515
610
  async post(e, t) {
516
- let { config: n } = this, i;
517
- try {
518
- i = X(n.serializer).serialize(e.records);
519
- } catch (t) {
520
- this.diagnostics.report("transport.serialize_failed", "The serializer threw an error. The library dropped the batch.", { batchId: e.id }, t);
611
+ let n = this.serialize(e);
612
+ if (!n) return;
613
+ let r = new Headers(await this.resolveHeaders());
614
+ r.set(c, n.contentType), r.set(l, e.id), r.set(a, String(e.attempts));
615
+ let i = await this.encodeBody(n.body);
616
+ typeof i != "string" && r.set(le, w);
617
+ let o = await this.dispatch(t, r, i);
618
+ if (o.ok) {
619
+ this.accept(o.headers.get(ne));
521
620
  return;
522
621
  }
523
- let a = new Headers(await this.resolveHeaders());
524
- a.set(o, i.contentType), a.set(c, e.id), a.set(r, String(e.attempts));
525
- let s = await this.encodeBody(i.body);
526
- typeof s != "string" && a.set(oe, E);
527
- let l = await this.dispatch(t, a, s);
528
- if (l.ok) this.throttledUntil = 0;
529
- else throw await this.classify(l, e.id);
622
+ let s = o.status, u = De(o.headers.get(re)), d = s === 413 ? await this.readMaxBytes(o) : void 0;
623
+ throw this.reject(s, e.id, {
624
+ retryAfterMs: u,
625
+ maxBytes: d,
626
+ advice: Q
627
+ });
530
628
  }
531
629
  async encodeBody(e) {
532
630
  let { config: t } = this;
533
- return t.compression !== "gzip" || k(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "The library could not compress the payload.", () => Te(e)) ?? e;
631
+ return t.compression !== "gzip" || A(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "The library could not compress the payload.", () => Re(e)) ?? e;
534
632
  }
535
633
  async dispatch(e, t, n) {
536
- let { config: r } = this, i = new AbortController(), a = setTimeout(() => {
537
- i.abort();
538
- }, T);
539
- M(a);
634
+ let { config: i } = this, a = new AbortController(), o = setTimeout(() => {
635
+ a.abort();
636
+ }, r);
637
+ j(o);
540
638
  try {
541
- return await fetch(e, {
639
+ return await P(() => fetch(e, {
542
640
  method: "POST",
543
641
  headers: t,
544
642
  body: n,
545
- credentials: r.credentials,
546
- signal: i.signal,
643
+ credentials: i.credentials,
644
+ signal: a.signal,
547
645
  cache: "no-store"
548
- });
646
+ }));
549
647
  } catch {
550
- if (i.signal.aborted) throw new Z("timeout", `The request took longer than ${String(T)} ms.`);
648
+ if (a.signal.aborted) throw new H("timeout", `The request took longer than ${String(r)} ms.`);
551
649
  let e = globalThis.navigator?.onLine;
552
- throw new Z(e === !1 ? "offline" : "transient", "A network error occurred.");
650
+ throw new H(e === !1 ? "offline" : "transient", "A network error occurred.");
553
651
  } finally {
554
- clearTimeout(a);
652
+ clearTimeout(o);
555
653
  }
556
654
  }
557
- async classify(e, t) {
558
- let n = e.status, r = Ee(e.headers.get(re));
559
- if (n === 401 || n === 403) return this.diagnostics.report("transport.rejected_credentials", `The server returned ${String(n)}. In a cross-origin iframe, the session cookie is a third-party cookie. The browser often blocks it. Forward the records to the platform document. As an alternative, issue the cookie with the Partitioned attribute.`, {
560
- status: n,
561
- endpoint: this.config.endpoint
562
- }), new Z("permanent", `The server rejected the batch with ${String(n)}.`, n);
563
- if (n === 413) return new Z("too_large", "The payload is too large.", n, void 0, await this.readMaxBytes(e));
564
- if (n === 429 || n === 503) {
565
- let e = n === 429;
566
- return this.throttledUntil = Date.now() + (r ?? 2e3), e && this.diagnostics.report("transport.throttled", "The server throttles the requests.", { retryAfterMs: r }), new Z("throttled", e ? "The server throttles the requests." : "The service is not available.", n, r);
567
- }
568
- return n === 408 || n >= 500 ? new Z("transient", `The server returned the error ${String(n)}.`, n) : (this.diagnostics.report("transport.dropped_permanent", `The server rejected the batch with ${String(n)}. The library dropped it.`, {
569
- batchId: t,
570
- status: n
571
- }), new Z("permanent", `The server rejected the batch with ${String(n)}.`, n));
572
- }
573
655
  async readMaxBytes(e) {
574
656
  return this.diagnostics.guardAsync("transport.http_error", "The library could not read the body of the 413 response.", async () => {
575
657
  let t = JSON.parse(await e.text());
@@ -580,7 +662,7 @@ var Q = class {
580
662
  let { headers: e } = this.config;
581
663
  return e ? typeof e == "function" ? await this.diagnostics.guardAsync("transport.http_error", "The headers() function threw an error.", () => Promise.resolve(e())) ?? {} : e : {};
582
664
  }
583
- }, De = class {
665
+ }, Be = class {
584
666
  storage;
585
667
  transport;
586
668
  diagnostics;
@@ -597,10 +679,10 @@ var Q = class {
597
679
  this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i;
598
680
  }
599
681
  start() {
600
- this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(a);
682
+ this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(o);
601
683
  }
602
684
  nudge() {
603
- this.draining || this.schedule(n);
685
+ this.draining || this.schedule(m);
604
686
  }
605
687
  async storeFailed(e, t) {
606
688
  let n = this.toStorable(e, t);
@@ -616,23 +698,23 @@ var Q = class {
616
698
  let t = setTimeout(() => {
617
699
  this.drain();
618
700
  }, e);
619
- this.timer = t, M(t);
701
+ this.timer = t, j(t);
620
702
  }
621
- bounded(e) {
622
- return A(e, C);
703
+ bounded(t) {
704
+ return T(t, e);
623
705
  }
624
706
  clearTimer() {
625
707
  this.timer !== null && (clearTimeout(this.timer), this.timer = null);
626
708
  }
627
709
  backoffMs() {
628
- let e = Math.min(n * 2 ** this.attempt, u);
710
+ let e = Math.min(m * 2 ** this.attempt, te);
629
711
  return Math.random() * e;
630
712
  }
631
713
  async drain() {
632
714
  if (!this.draining) {
633
715
  this.draining = !0;
634
716
  try {
635
- await F("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(a);
717
+ await L("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(o);
636
718
  } finally {
637
719
  this.draining = !1;
638
720
  }
@@ -640,25 +722,25 @@ var Q = class {
640
722
  }
641
723
  async drainLocked() {
642
724
  try {
643
- if (globalThis.navigator?.onLine === !1) return this.schedule(a), !0;
725
+ if (globalThis.navigator?.onLine === !1) return this.schedule(o), !0;
644
726
  let e = await this.bounded(this.storage.take(this.batchesPerDrain));
645
- if (e.length === 0) return this.schedule(a), !0;
727
+ if (e.length === 0) return this.schedule(o), !0;
646
728
  for (let t of e) if (this.stopped || !await this.deliver(t)) return !0;
647
- return this.schedule(e.length === this.batchesPerDrain ? 0 : a), !0;
729
+ return this.schedule(e.length === this.batchesPerDrain ? 0 : o), !0;
648
730
  } catch (e) {
649
731
  return this.diagnostics.report("storage.degraded", "The drain loop threw an error.", void 0, e), this.attempt++, this.schedule(this.backoffMs()), !0;
650
732
  }
651
733
  }
652
734
  async deliver(e) {
653
- if (e.attempts >= s.maxAttempts) return this.diagnostics.report("storage.dead_lettered", `The library dropped a batch after ${e.attempts.toString()} attempts.`, {
735
+ if (e.attempts >= _.maxAttempts) return this.diagnostics.report("storage.dead_lettered", `The library dropped a batch after ${e.attempts.toString()} attempts.`, {
654
736
  batchId: e.id,
655
737
  records: e.records.length
656
738
  }), await this.bounded(this.storage.remove(e.id)), !0;
657
739
  try {
658
740
  return await this.transport.send(e), await this.bounded(this.storage.remove(e.id)), this.attempt = 0, !0;
659
741
  } catch (t) {
660
- let n = t instanceof Z ? t : void 0;
661
- return n?.kind === "permanent" || n?.kind === "too_large" ? (await this.replaceStored(e, t), !0) : n?.kind === "offline" ? (this.schedule(a), !1) : n?.kind === "throttled" ? (this.attempt++, this.schedule(n.retryAfterMs ?? this.backoffMs()), !1) : (await this.bounded(this.storage.bumpAttempts(e.id, e.attempts + 1)), this.attempt++, this.schedule(n?.retryAfterMs ?? this.backoffMs()), !1);
742
+ let n = t instanceof H ? t : void 0;
743
+ return n?.kind === "permanent" || n?.kind === "too_large" ? (await this.replaceStored(e, t), !0) : n?.kind === "offline" ? (this.schedule(o), !1) : n?.kind === "throttled" ? (this.attempt++, this.schedule(n.retryAfterMs ?? this.backoffMs()), !1) : (await this.bounded(this.storage.bumpAttempts(e.id, e.attempts + 1)), this.attempt++, this.schedule(n?.retryAfterMs ?? this.backoffMs()), !1);
662
744
  }
663
745
  }
664
746
  async replaceStored(e, t) {
@@ -667,10 +749,10 @@ var Q = class {
667
749
  for (let e of n) await this.bounded(this.storage.save(e));
668
750
  }
669
751
  toStorable(e, t) {
670
- let n = t instanceof Z ? t : void 0;
752
+ let n = t instanceof H ? t : void 0;
671
753
  if (n?.kind === "permanent") return [];
672
754
  if (n?.kind !== "too_large") return [e];
673
- let r = P(e, this.diagnostics);
755
+ let r = I(e, this.diagnostics);
674
756
  return r ? (this.diagnostics.report("transport.batch_split", "The server refused the batch because it is too large.", {
675
757
  from: e.records.length,
676
758
  to: r[0].records.length,
@@ -683,16 +765,16 @@ var Q = class {
683
765
  };
684
766
  //#endregion
685
767
  //#region src/core/pipeline.ts
686
- function Oe(e) {
687
- return e.attributes[b] === ce;
768
+ function Ve(e) {
769
+ return e.attributes[ae] === pe;
688
770
  }
689
- var ke = {
771
+ var He = {
690
772
  logs: {
691
- flushIntervalMs: S,
773
+ flushIntervalMs: se,
692
774
  batchSize: 100
693
775
  },
694
776
  metrics: {
695
- flushIntervalMs: x,
777
+ flushIntervalMs: v,
696
778
  batchSize: 500
697
779
  }
698
780
  }, $ = class {
@@ -719,12 +801,12 @@ var ke = {
719
801
  let e = setTimeout(() => {
720
802
  this.timer = null, this.onFlush(this);
721
803
  }, this.options.flushIntervalMs);
722
- this.timer = e, M(e);
804
+ this.timer = e, j(e);
723
805
  }
724
806
  clearTimer() {
725
807
  this.timer !== null && (clearTimeout(this.timer), this.timer = null);
726
808
  }
727
- }, Ae = class {
809
+ }, Ue = class {
728
810
  transport;
729
811
  storage;
730
812
  retry;
@@ -732,11 +814,11 @@ var ke = {
732
814
  streams;
733
815
  unconfirmed = /* @__PURE__ */ new Map();
734
816
  queue = [];
735
- ceiling = new j();
817
+ ceiling = new O();
736
818
  inFlight = 0;
737
819
  pumpScheduled = !1;
738
820
  stopped = !1;
739
- constructor(e, t, n, r, i = ke) {
821
+ constructor(e, t, n, r, i = He) {
740
822
  this.transport = e, this.storage = t, this.retry = n, this.diagnostics = r;
741
823
  let a = (e) => {
742
824
  this.claim(e);
@@ -765,7 +847,7 @@ var ke = {
765
847
  }
766
848
  toBatch(e) {
767
849
  return e.length === 0 ? null : {
768
- id: O(this.diagnostics),
850
+ id: E(this.diagnostics),
769
851
  records: e,
770
852
  createdAt: Date.now(),
771
853
  attempts: 0
@@ -773,7 +855,7 @@ var ke = {
773
855
  }
774
856
  route(e) {
775
857
  try {
776
- let t = Oe(e) ? this.streams.metrics : this.streams.logs;
858
+ let t = Ve(e) ? this.streams.metrics : this.streams.logs;
777
859
  if (!this.ceiling.allow(e)) {
778
860
  this.diagnostics.count("record.dropped_by_ceiling");
779
861
  return;
@@ -785,7 +867,7 @@ var ke = {
785
867
  }
786
868
  claim(e) {
787
869
  let t = e.take(), n = {
788
- id: O(this.diagnostics),
870
+ id: E(this.diagnostics),
789
871
  records: t,
790
872
  createdAt: Date.now(),
791
873
  attempts: 0
@@ -844,12 +926,12 @@ var ke = {
844
926
  await this.retry.storeFailed(e, t);
845
927
  });
846
928
  }
847
- async store(e) {
929
+ async store(t) {
848
930
  await this.diagnostics.guardAsync("storage.degraded", "The library could not store an undelivered batch.", async () => {
849
- await A(this.storage.save(e), C), this.retry.nudge();
931
+ await T(this.storage.save(t), e), this.retry.nudge();
850
932
  });
851
933
  }
852
- }, je = class e {
934
+ }, We = class e {
853
935
  storage;
854
936
  transport;
855
937
  retry;
@@ -860,20 +942,23 @@ var ke = {
860
942
  this.storage = e, this.transport = t, this.retry = n, this.pipeline = r, this.exitFlush = i, this.diagnostics = a;
861
943
  }
862
944
  static async create(t) {
863
- let { config: n, diagnostics: r } = t, i = await _e(n.storage, l, s, r, t.onGap), a = new Q(n, r), o = new De(i, a, r, n), c = new Ae(a, i, o, r), u = new we({
945
+ let { config: n, diagnostics: r } = t, i = await Ee(n.storage, ee, _, r, t.onGap), a = (e) => {
946
+ let i = M(e, r);
947
+ i && N(t.remote, n, i);
948
+ }, o = n.transport ? new Ie(n, r, a) : new ze(n, r, a), s = new Be(i, o, r, n), c = new Ue(o, i, s, r), l = new Le({
864
949
  config: n,
865
950
  diagnostics: r,
866
951
  drainForExit: () => c.drainForExit(),
867
952
  drainPending: () => c.drainPending()
868
953
  });
869
- await V(i, r);
870
- let d = !1;
954
+ await ye(i, r);
955
+ let u = !1;
871
956
  try {
872
- u.install(), o.start(), d = !0;
957
+ l.install(), s.start(), u = !0;
873
958
  } finally {
874
- d || (u.uninstall(), o.stop());
959
+ u || (l.uninstall(), s.stop());
875
960
  }
876
- return new e(i, a, o, c, u, r);
961
+ return new e(i, o, s, c, l, r);
877
962
  }
878
963
  push(e) {
879
964
  this.pipeline.push(e);
@@ -902,6 +987,6 @@ var ke = {
902
987
  }
903
988
  };
904
989
  //#endregion
905
- export { je as Sender };
990
+ export { We as Sender };
906
991
 
907
- //# sourceMappingURL=sender-BIob8eZz.js.map
992
+ //# sourceMappingURL=sender-G6v4Uqi4.js.map