@utk09/ui-observability 0.5.0 → 0.7.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 (123) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +119 -60
  3. package/dist/bus/bus.d.ts +10 -10
  4. package/dist/bus/links.d.ts +1 -1
  5. package/dist/bus-DeZzr2bx.cjs +2 -0
  6. package/dist/bus-DeZzr2bx.cjs.map +1 -0
  7. package/dist/{bus-D3OO0OcL.js → bus-DfAbg_pg.js} +19 -19
  8. package/dist/bus-DfAbg_pg.js.map +1 -0
  9. package/dist/capture/network.d.ts +2 -2
  10. package/dist/capture/types.d.ts +10 -10
  11. package/dist/capture/web-vitals.d.ts +3 -3
  12. package/dist/constants-C8nZQBmQ.js +86 -0
  13. package/dist/constants-C8nZQBmQ.js.map +1 -0
  14. package/dist/constants-IBL_jd5R.cjs +2 -0
  15. package/dist/constants-IBL_jd5R.cjs.map +1 -0
  16. package/dist/constants.d.ts +56 -43
  17. package/dist/core/breadcrumbs.d.ts +14 -14
  18. package/dist/core/config.d.ts +5 -4
  19. package/dist/core/context.d.ts +2 -2
  20. package/dist/core/diagnostics.d.ts +10 -9
  21. package/dist/core/journey.d.ts +23 -20
  22. package/dist/core/logger.d.ts +7 -7
  23. package/dist/core/pipeline.d.ts +34 -29
  24. package/dist/core/record.d.ts +6 -6
  25. package/dist/core/runtime.d.ts +20 -18
  26. package/dist/core/sampling.d.ts +15 -16
  27. package/dist/core/sender.d.ts +1 -1
  28. package/dist/{errors-Dme9tz-6.js → errors-4MQyjZVj.js} +4 -4
  29. package/dist/errors-4MQyjZVj.js.map +1 -0
  30. package/dist/{errors-DPju_xSI.cjs → errors-CUdShXe7.cjs} +2 -2
  31. package/dist/errors-CUdShXe7.cjs.map +1 -0
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.ts +7 -5
  35. package/dist/index.js +136 -115
  36. package/dist/index.js.map +1 -1
  37. package/dist/{indexeddb-storage-nxs_rxGx.js → indexeddb-storage-0LtUALBg.js} +16 -16
  38. package/dist/indexeddb-storage-0LtUALBg.js.map +1 -0
  39. package/dist/indexeddb-storage-CcEJlq2l.cjs +2 -0
  40. package/dist/indexeddb-storage-CcEJlq2l.cjs.map +1 -0
  41. package/dist/{interactions-DP0-rIPJ.cjs → interactions-BMNPQ3WH.cjs} +2 -2
  42. package/dist/interactions-BMNPQ3WH.cjs.map +1 -0
  43. package/dist/{interactions-C1romMpE.js → interactions-BaCmoGLB.js} +2 -2
  44. package/dist/interactions-BaCmoGLB.js.map +1 -0
  45. package/dist/models/batch.d.ts +12 -9
  46. package/dist/models/bus.d.ts +12 -13
  47. package/dist/models/config.d.ts +85 -44
  48. package/dist/models/log-record.d.ts +12 -10
  49. package/dist/models/serializer.d.ts +3 -2
  50. package/dist/models/storage.d.ts +2 -2
  51. package/dist/network-DBNvxCE3.cjs +2 -0
  52. package/dist/network-DBNvxCE3.cjs.map +1 -0
  53. package/dist/{network-au-Tqt1n.js → network-jQ2t8rU4.js} +4 -4
  54. package/dist/network-jQ2t8rU4.js.map +1 -0
  55. package/dist/platform-ByQllE_W.cjs +2 -0
  56. package/dist/platform-ByQllE_W.cjs.map +1 -0
  57. package/dist/{platform-DMYo3AX3.js → platform-YuByH8A5.js} +8 -8
  58. package/dist/platform-YuByH8A5.js.map +1 -0
  59. package/dist/{sampling-ByI5H44E.js → sampling-CbYySsZ1.js} +21 -18
  60. package/dist/sampling-CbYySsZ1.js.map +1 -0
  61. package/dist/sampling-Cs50xsZl.cjs +2 -0
  62. package/dist/sampling-Cs50xsZl.cjs.map +1 -0
  63. package/dist/{sender-R7lOpyNc.js → sender-BIob8eZz.js} +60 -60
  64. package/dist/sender-BIob8eZz.js.map +1 -0
  65. package/dist/sender-iOjzcueM.cjs +3 -0
  66. package/dist/sender-iOjzcueM.cjs.map +1 -0
  67. package/dist/storage/emergency-queue.d.ts +2 -2
  68. package/dist/storage/factory.d.ts +2 -1
  69. package/dist/storage/idb-driver.d.ts +19 -19
  70. package/dist/storage/indexeddb-storage.d.ts +18 -17
  71. package/dist/storage/keys.d.ts +1 -1
  72. package/dist/storage/local-storage.d.ts +19 -18
  73. package/dist/storage/memory-storage.d.ts +12 -11
  74. package/dist/transport/compression.d.ts +2 -2
  75. package/dist/transport/errors.d.ts +8 -7
  76. package/dist/transport/exit-flush.d.ts +27 -24
  77. package/dist/transport/http-transport.d.ts +18 -11
  78. package/dist/transport/retry-engine.d.ts +33 -28
  79. package/dist/transport/serializers/ecs.d.ts +1 -1
  80. package/dist/transport/serializers/otlp.d.ts +1 -1
  81. package/dist/unref-16maCyKA.js.map +1 -1
  82. package/dist/unref-CU9Nyz_9.cjs.map +1 -1
  83. package/dist/utils/console.d.ts +7 -6
  84. package/dist/utils/identity.d.ts +6 -5
  85. package/dist/utils/lock.d.ts +4 -4
  86. package/dist/utils/platform.d.ts +5 -3
  87. package/dist/utils/sanitize.d.ts +5 -2
  88. package/dist/utils/sequence.d.ts +2 -2
  89. package/dist/utils/tracing.d.ts +8 -7
  90. package/dist/web-vitals-B2FYsEAU.cjs +2 -0
  91. package/dist/web-vitals-B2FYsEAU.cjs.map +1 -0
  92. package/dist/{web-vitals-DwWdLBq6.js → web-vitals-DHZ0yA_H.js} +4 -4
  93. package/dist/web-vitals-DHZ0yA_H.js.map +1 -0
  94. package/package.json +4 -2
  95. package/dist/bus-D3OO0OcL.js.map +0 -1
  96. package/dist/bus-OdRJVUzr.cjs +0 -2
  97. package/dist/bus-OdRJVUzr.cjs.map +0 -1
  98. package/dist/constants-B6kdsCzF.js +0 -75
  99. package/dist/constants-B6kdsCzF.js.map +0 -1
  100. package/dist/constants-DZH04585.cjs +0 -2
  101. package/dist/constants-DZH04585.cjs.map +0 -1
  102. package/dist/errors-DPju_xSI.cjs.map +0 -1
  103. package/dist/errors-Dme9tz-6.js.map +0 -1
  104. package/dist/indexeddb-storage-lGdoHGHy.cjs +0 -2
  105. package/dist/indexeddb-storage-lGdoHGHy.cjs.map +0 -1
  106. package/dist/indexeddb-storage-nxs_rxGx.js.map +0 -1
  107. package/dist/interactions-C1romMpE.js.map +0 -1
  108. package/dist/interactions-DP0-rIPJ.cjs.map +0 -1
  109. package/dist/network-DDVIJSHd.cjs +0 -2
  110. package/dist/network-DDVIJSHd.cjs.map +0 -1
  111. package/dist/network-au-Tqt1n.js.map +0 -1
  112. package/dist/platform-DMYo3AX3.js.map +0 -1
  113. package/dist/platform-g99Kn755.cjs +0 -2
  114. package/dist/platform-g99Kn755.cjs.map +0 -1
  115. package/dist/sampling-ByI5H44E.js.map +0 -1
  116. package/dist/sampling-Dui-Fp3u.cjs +0 -2
  117. package/dist/sampling-Dui-Fp3u.cjs.map +0 -1
  118. package/dist/sender-R7lOpyNc.js.map +0 -1
  119. package/dist/sender-vLcbQhiB.cjs +0 -3
  120. package/dist/sender-vLcbQhiB.cjs.map +0 -1
  121. package/dist/web-vitals-DM2nvcMJ.cjs +0 -2
  122. package/dist/web-vitals-DM2nvcMJ.cjs.map +0 -1
  123. package/dist/web-vitals-DwWdLBq6.js.map +0 -1
@@ -1,5 +1,5 @@
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-B6kdsCzF.js";
2
- import { _ as D, c as O, f as k, i as A, t as j } from "./sampling-ByI5H44E.js";
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
3
  import { t as M } from "./unref-16maCyKA.js";
4
4
  //#region src/models/batch.ts
5
5
  function N(e) {
@@ -7,27 +7,27 @@ function N(e) {
7
7
  let t = Reflect.get(e, "id"), n = Reflect.get(e, "createdAt"), r = Reflect.get(e, "attempts"), i = Reflect.get(e, "records");
8
8
  return typeof t == "string" && typeof n == "number" && typeof r == "number" && Array.isArray(i);
9
9
  }
10
- function P(e) {
10
+ function P(e, t) {
11
11
  if (e.records.length < 2) return null;
12
- let t = Math.floor(e.records.length / 2), n = (t) => ({
13
- id: O(),
14
- records: t,
12
+ let n = Math.floor(e.records.length / 2), r = (n) => ({
13
+ id: O(t),
14
+ records: n,
15
15
  createdAt: e.createdAt,
16
16
  attempts: e.attempts
17
17
  });
18
- return [n(e.records.slice(0, t)), n(e.records.slice(t))];
18
+ return [r(e.records.slice(0, n)), r(e.records.slice(n))];
19
19
  }
20
20
  //#endregion
21
21
  //#region src/utils/lock.ts
22
22
  function F(e, t, n, { skipIfBusy: r = !0 } = {}) {
23
23
  let i = globalThis.navigator?.locks;
24
- return i?.request ? t.guardAsync("storage.degraded", `acquiring lock ${e}`, () => i.request(e, { ifAvailable: r }, (e) => e ? n() : Promise.resolve(void 0))) : n();
24
+ 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
25
  }
26
26
  //#endregion
27
27
  //#region src/storage/keys.ts
28
28
  function I(e, t) {
29
29
  let n = [];
30
- return t.guard("storage.unavailable", "enumerating localStorage", () => {
30
+ return t.guard("storage.unavailable", "The library could not list the localStorage keys.", () => {
31
31
  for (let t = 0; t < localStorage.length; t++) {
32
32
  let r = String(localStorage.key(t));
33
33
  r.startsWith(e) && n.push(r);
@@ -41,13 +41,13 @@ function L(e) {
41
41
  return `${f}${t}.${e.id}`;
42
42
  }
43
43
  function R(e, t) {
44
- let n = t.guard("storage.degraded", "an emergency entry was not JSON and was dropped", () => JSON.parse(e));
45
- return n === void 0 ? null : N(n) ? n : (t.report("storage.degraded", "an emergency entry was not a batch and was dropped"), null);
44
+ 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);
46
46
  }
47
47
  async function z(e, t) {
48
48
  let n = 0;
49
49
  for (let r of I(f, t)) {
50
- let i = t.guard("storage.unavailable", "reading the emergency queue", () => {
50
+ let i = t.guard("storage.unavailable", "The library could not read the emergency queue.", () => {
51
51
  let e = localStorage.getItem(r);
52
52
  return localStorage.removeItem(r), e;
53
53
  });
@@ -56,7 +56,7 @@ async function z(e, t) {
56
56
  if (a !== null) try {
57
57
  await A(e.save(a), C), n++;
58
58
  } catch (e) {
59
- t.report("storage.degraded", "an emergency batch could not be recovered", { key: r }, e);
59
+ t.report("storage.degraded", "The library could not recover an emergency batch.", { key: r }, e);
60
60
  }
61
61
  }
62
62
  return n;
@@ -113,7 +113,7 @@ var pe = class {
113
113
  let n = this.keyOf(e);
114
114
  if (n === null) return Promise.resolve();
115
115
  let r = this.read(n);
116
- return r === null || (r.attempts = t, this.diagnostics.guard("storage.degraded", "updating attempts", () => {
116
+ return r === null || (r.attempts = t, this.diagnostics.guard("storage.degraded", "The library could not update the attempt count.", () => {
117
117
  localStorage.setItem(n, JSON.stringify(r));
118
118
  })), Promise.resolve();
119
119
  }
@@ -162,13 +162,13 @@ var pe = class {
162
162
  this.reportGap(t);
163
163
  }
164
164
  reportGap(e) {
165
- e.batches !== 0 && (this.diagnostics.report("storage.evicted", `dropped ${String(e.batches)} stored batches (${String(e.records)} records)`, { ...e }), this.onGap?.(e));
165
+ e.batches !== 0 && (this.diagnostics.report("storage.evicted", `The library dropped ${String(e.batches)} stored batches (${String(e.records)} records).`, { ...e }), this.onGap?.(e));
166
166
  }
167
167
  read(e) {
168
- let t = this.diagnostics.guard("storage.unavailable", "reading a stored batch", () => localStorage.getItem(e));
168
+ let t = this.diagnostics.guard("storage.unavailable", "The library could not read a stored batch.", () => localStorage.getItem(e));
169
169
  if (!t) return null;
170
- let n = this.diagnostics.guard("storage.degraded", "a stored batch was corrupt and was removed", () => JSON.parse(t));
171
- return n === void 0 ? null : N(n) ? n : (this.diagnostics.report("storage.degraded", "a stored entry was not a batch and was dropped"), null);
170
+ 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);
172
172
  }
173
173
  keyOf(e) {
174
174
  return this.keys().find((t) => t.endsWith(`.${e}`)) ?? null;
@@ -177,7 +177,7 @@ var pe = class {
177
177
  for (let t of e) this.removeKey(t);
178
178
  }
179
179
  removeKey(e) {
180
- this.diagnostics.guard("storage.degraded", "removing a stored batch", () => {
180
+ this.diagnostics.guard("storage.degraded", "The library could not remove a stored batch.", () => {
181
181
  localStorage.removeItem(e);
182
182
  });
183
183
  }
@@ -251,25 +251,25 @@ var W = class {
251
251
  close: () => Promise.resolve()
252
252
  };
253
253
  function he(e) {
254
- return e.guard("storage.unavailable", "reading indexedDB", () => globalThis.indexedDB != null) === !0;
254
+ return e.guard("storage.unavailable", "The library could not read indexedDB.", () => globalThis.indexedDB != null) === !0;
255
255
  }
256
256
  function ge(e) {
257
- return e.guard("storage.unavailable", "probing localStorage", () => (localStorage.setItem(h, "1"), localStorage.removeItem(h), !0)) === !0;
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;
258
258
  }
259
259
  async function _e(e, t, n, r, i) {
260
260
  if (e === "none") return me;
261
261
  if (e === "memory") return new W(n, i);
262
262
  if (e === "indexeddb" || e === "auto") {
263
263
  if (he(r)) {
264
- let e = await r.guardAsync("storage.unavailable", "opening IndexedDB", async () => {
265
- let { IndexedDbStorage: e } = await import("./indexeddb-storage-nxs_rxGx.js"), a = new e(t, n, r, i);
264
+ 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);
266
266
  return await a.open(), a;
267
267
  });
268
268
  if (e) return e;
269
269
  }
270
- if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new W(n, i);
270
+ if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new W(n, i);
271
271
  }
272
- return ge(r) ? new pe(n, r, i) : (r.report("storage.degraded", "no persistent storage available, offline logs are memory only"), new W(n, i));
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));
273
273
  }
274
274
  //#endregion
275
275
  //#region src/transport/serializers/ecs.ts
@@ -415,7 +415,7 @@ var we = class {
415
415
  if (this.installed || typeof addEventListener > "u") return;
416
416
  this.installed = !0, typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), document.addEventListener("freeze", this.onFreeze)), addEventListener("pagehide", this.onPageHide);
417
417
  let e = globalThis.fin?.me;
418
- this.deps.diagnostics.guard("openfin.unavailable", "subscribing to close-requested", () => {
418
+ this.deps.diagnostics.guard("openfin.unavailable", "The library could not subscribe to close-requested.", () => {
419
419
  e?.on?.("close-requested", this.onOpenFinClose);
420
420
  });
421
421
  }
@@ -423,7 +423,7 @@ var we = class {
423
423
  if (!this.installed) return;
424
424
  this.installed = !1, typeof document < "u" && (document.removeEventListener("visibilitychange", this.onVisibility), document.removeEventListener("freeze", this.onFreeze)), removeEventListener("pagehide", this.onPageHide);
425
425
  let e = globalThis.fin?.me;
426
- this.deps.diagnostics.guard("openfin.unavailable", "releasing close-requested", () => {
426
+ this.deps.diagnostics.guard("openfin.unavailable", "The library could not unsubscribe from close-requested.", () => {
427
427
  e?.removeListener?.("close-requested", this.onOpenFinClose);
428
428
  });
429
429
  }
@@ -432,7 +432,7 @@ var we = class {
432
432
  if (n === null) return;
433
433
  let r = this.drain(e);
434
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));
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
436
  if (!i) return;
437
437
  if (k(i.body) > 6e4) {
438
438
  B(r, t);
@@ -447,7 +447,7 @@ var we = class {
447
447
  }
448
448
  endpointUrl() {
449
449
  let { endpoint: e } = this.deps.config;
450
- return e ? this.deps.diagnostics.guard("config.invalid", `the exit flush cannot use endpoint ${e}`, () => new URL(e)) ?? null : null;
450
+ return e ? this.deps.diagnostics.guard("config.invalid", `The exit flush cannot use the endpoint ${e}.`, () => new URL(e)) ?? null : null;
451
451
  }
452
452
  beacon(e, t) {
453
453
  return this.deps.diagnostics.guard("transport.http_error", "sendBeacon", () => {
@@ -457,7 +457,7 @@ var we = class {
457
457
  }
458
458
  keepaliveFetch(e, n, r) {
459
459
  let { config: i, diagnostics: a } = this.deps;
460
- a.guard("transport.http_error", "the keepalive fetch fallback", () => {
460
+ a.guard("transport.http_error", "The keepalive fetch fallback failed.", () => {
461
461
  fetch(e, {
462
462
  method: "POST",
463
463
  body: n,
@@ -465,7 +465,7 @@ var we = class {
465
465
  credentials: i.credentials,
466
466
  keepalive: !0
467
467
  }).catch((e) => {
468
- a.report("transport.http_error", "the exit flush failed", { reason: r }, e);
468
+ a.report("transport.http_error", "The exit flush failed.", { reason: r }, e);
469
469
  });
470
470
  });
471
471
  }
@@ -517,7 +517,7 @@ var Q = class {
517
517
  try {
518
518
  i = X(n.serializer).serialize(e.records);
519
519
  } catch (t) {
520
- this.diagnostics.report("transport.serialize_failed", "serializer threw, dropping the batch", { batchId: e.id }, t);
520
+ this.diagnostics.report("transport.serialize_failed", "The serializer threw an error. The library dropped the batch.", { batchId: e.id }, t);
521
521
  return;
522
522
  }
523
523
  let a = new Headers(await this.resolveHeaders());
@@ -530,7 +530,7 @@ var Q = class {
530
530
  }
531
531
  async encodeBody(e) {
532
532
  let { config: t } = this;
533
- return t.compression !== "gzip" || k(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "gzipping the payload", () => Te(e)) ?? e;
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;
534
534
  }
535
535
  async dispatch(e, t, n) {
536
536
  let { config: r } = this, i = new AbortController(), a = setTimeout(() => {
@@ -547,38 +547,38 @@ var Q = class {
547
547
  cache: "no-store"
548
548
  });
549
549
  } catch {
550
- if (i.signal.aborted) throw new Z("timeout", `request exceeded ${String(T)}ms`);
550
+ if (i.signal.aborted) throw new Z("timeout", `The request took longer than ${String(T)} ms.`);
551
551
  let e = globalThis.navigator?.onLine;
552
- throw new Z(e === !1 ? "offline" : "transient", "network error");
552
+ throw new Z(e === !1 ? "offline" : "transient", "A network error occurred.");
553
553
  } finally {
554
554
  clearTimeout(a);
555
555
  }
556
556
  }
557
557
  async classify(e, t) {
558
558
  let n = e.status, r = Ee(e.headers.get(re));
559
- if (n === 401 || n === 403) return this.diagnostics.report("transport.rejected_credentials", `server returned ${String(n)}. In a cross-origin iframe the session cookie is a third-party cookie and is very likely blocked. Forward to the platform document instead of promoting to sender, or issue the cookie with the Partitioned attribute.`, {
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
560
  status: n,
561
561
  endpoint: this.config.endpoint
562
- }), new Z("permanent", `rejected with ${String(n)}`, n);
563
- if (n === 413) return new Z("too_large", "payload too large", n, void 0, await this.readMaxBytes(e));
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
564
  if (n === 429 || n === 503) {
565
565
  let e = n === 429;
566
- return this.throttledUntil = Date.now() + (r ?? 2e3), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new Z("throttled", e ? "throttled" : "service unavailable", n, r);
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
567
  }
568
- return n === 408 || n >= 500 ? new Z("transient", `server error ${String(n)}`, n) : (this.diagnostics.report("transport.dropped_permanent", `server rejected the batch with ${String(n)}, dropping it`, {
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
569
  batchId: t,
570
570
  status: n
571
- }), new Z("permanent", `rejected with ${String(n)}`, n));
571
+ }), new Z("permanent", `The server rejected the batch with ${String(n)}.`, n));
572
572
  }
573
573
  async readMaxBytes(e) {
574
- return this.diagnostics.guardAsync("transport.http_error", "reading the 413 body", async () => {
574
+ return this.diagnostics.guardAsync("transport.http_error", "The library could not read the body of the 413 response.", async () => {
575
575
  let t = JSON.parse(await e.text());
576
576
  return typeof t.maxBytes == "number" ? t.maxBytes : void 0;
577
577
  });
578
578
  }
579
579
  async resolveHeaders() {
580
580
  let { headers: e } = this.config;
581
- return e ? typeof e == "function" ? await this.diagnostics.guardAsync("transport.http_error", "headers() threw", () => Promise.resolve(e())) ?? {} : e : {};
581
+ return e ? typeof e == "function" ? await this.diagnostics.guardAsync("transport.http_error", "The headers() function threw an error.", () => Promise.resolve(e())) ?? {} : e : {};
582
582
  }
583
583
  }, De = class {
584
584
  storage;
@@ -646,11 +646,11 @@ var Q = class {
646
646
  for (let t of e) if (this.stopped || !await this.deliver(t)) return !0;
647
647
  return this.schedule(e.length === this.batchesPerDrain ? 0 : a), !0;
648
648
  } catch (e) {
649
- return this.diagnostics.report("storage.degraded", "the drain loop threw", void 0, e), this.attempt++, this.schedule(this.backoffMs()), !0;
649
+ return this.diagnostics.report("storage.degraded", "The drain loop threw an error.", void 0, e), this.attempt++, this.schedule(this.backoffMs()), !0;
650
650
  }
651
651
  }
652
652
  async deliver(e) {
653
- if (e.attempts >= s.maxAttempts) return this.diagnostics.report("storage.dead_lettered", `giving up on a batch after ${e.attempts.toString()} attempts`, {
653
+ if (e.attempts >= s.maxAttempts) return this.diagnostics.report("storage.dead_lettered", `The library dropped a batch after ${e.attempts.toString()} attempts.`, {
654
654
  batchId: e.id,
655
655
  records: e.records.length
656
656
  }), await this.bounded(this.storage.remove(e.id)), !0;
@@ -670,12 +670,12 @@ var Q = class {
670
670
  let n = t instanceof Z ? t : void 0;
671
671
  if (n?.kind === "permanent") return [];
672
672
  if (n?.kind !== "too_large") return [e];
673
- let r = P(e);
674
- return r ? (this.diagnostics.report("transport.batch_split", "the server refused the batch as too large", {
673
+ let r = P(e, this.diagnostics);
674
+ return r ? (this.diagnostics.report("transport.batch_split", "The server refused the batch because it is too large.", {
675
675
  from: e.records.length,
676
676
  to: r[0].records.length,
677
677
  serverMaxBytes: n.maxBytes
678
- }), r) : (this.diagnostics.report("transport.dropped_permanent", "a single record exceeds the server limit and was dropped", {
678
+ }), r) : (this.diagnostics.report("transport.dropped_permanent", "One record is larger than the server limit. The library dropped it.", {
679
679
  batchId: e.id,
680
680
  bodies: e.records.map((e) => e.body)
681
681
  }), []);
@@ -765,7 +765,7 @@ var ke = {
765
765
  }
766
766
  toBatch(e) {
767
767
  return e.length === 0 ? null : {
768
- id: O(),
768
+ id: O(this.diagnostics),
769
769
  records: e,
770
770
  createdAt: Date.now(),
771
771
  attempts: 0
@@ -780,12 +780,12 @@ var ke = {
780
780
  }
781
781
  t.add(e);
782
782
  } catch (e) {
783
- this.diagnostics.report("pipeline.crashed", "a record was dropped on its way into a stream", void 0, e);
783
+ this.diagnostics.report("pipeline.crashed", "The pipeline dropped a record before it reached a stream.", void 0, e);
784
784
  }
785
785
  }
786
786
  claim(e) {
787
787
  let t = e.take(), n = {
788
- id: O(),
788
+ id: O(this.diagnostics),
789
789
  records: t,
790
790
  createdAt: Date.now(),
791
791
  attempts: 0
@@ -808,7 +808,7 @@ var ke = {
808
808
  try {
809
809
  await this.dispatch(e);
810
810
  } catch (t) {
811
- this.diagnostics.report("pipeline.crashed", "dispatch rejected, which it is written never to do", { batchId: e.id }, t);
811
+ this.diagnostics.report("pipeline.crashed", "A dispatch rejected its promise. This must not occur.", { batchId: e.id }, t);
812
812
  } finally {
813
813
  this.inFlight--, this.pump();
814
814
  }
@@ -817,7 +817,7 @@ var ke = {
817
817
  try {
818
818
  let t = this.transport.throttledForMs();
819
819
  if (t > 0) {
820
- await this.store(e), this.diagnostics.report("transport.throttled", "stored the batch rather than sending it", {
820
+ await this.store(e), this.diagnostics.report("transport.throttled", "The server throttles requests. The pipeline stored the batch and did not send it.", {
821
821
  batchId: e.id,
822
822
  records: e.records.length,
823
823
  throttledMs: t
@@ -830,7 +830,7 @@ var ke = {
830
830
  await this.storeFailed({
831
831
  ...e,
832
832
  attempts: e.attempts + 1
833
- }, t), this.diagnostics.report("transport.http_error", "batch was stored for retry instead of being delivered", {
833
+ }, t), this.diagnostics.report("transport.http_error", "The send failed. The pipeline stored the batch for a retry.", {
834
834
  batchId: e.id,
835
835
  records: e.records.length
836
836
  }, t);
@@ -840,12 +840,12 @@ var ke = {
840
840
  }
841
841
  }
842
842
  async storeFailed(e, t) {
843
- await this.diagnostics.guardAsync("storage.degraded", "persisting an undelivered batch", async () => {
843
+ await this.diagnostics.guardAsync("storage.degraded", "The library could not store an undelivered batch.", async () => {
844
844
  await this.retry.storeFailed(e, t);
845
845
  });
846
846
  }
847
847
  async store(e) {
848
- await this.diagnostics.guardAsync("storage.degraded", "persisting an undelivered batch", async () => {
848
+ await this.diagnostics.guardAsync("storage.degraded", "The library could not store an undelivered batch.", async () => {
849
849
  await A(this.storage.save(e), C), this.retry.nudge();
850
850
  });
851
851
  }
@@ -883,19 +883,19 @@ var ke = {
883
883
  if (e) try {
884
884
  await this.transport.send(e);
885
885
  } catch (t) {
886
- await this.diagnostics.guardAsync("storage.degraded", "persisting the batch drained by flush()", async () => {
886
+ await this.diagnostics.guardAsync("storage.degraded", "The library could not store the batch that flush() drained.", async () => {
887
887
  await this.retry.storeFailed({
888
888
  ...e,
889
889
  attempts: e.attempts + 1
890
890
  }, t);
891
- }), this.diagnostics.report("transport.http_error", "the batch drained by flush() was stored for retry instead of being delivered", {
891
+ }), this.diagnostics.report("transport.http_error", "The send from flush() failed. The library stored the batch for a retry.", {
892
892
  batchId: e.id,
893
893
  records: e.records.length
894
894
  }, t);
895
895
  }
896
896
  }
897
897
  async queueDepth() {
898
- return await this.diagnostics.guardAsync("storage.degraded", "counting the batches waiting in storage", () => this.storage.count()) ?? 0;
898
+ return await this.diagnostics.guardAsync("storage.degraded", "The library could not count the batches in storage.", () => this.storage.count()) ?? 0;
899
899
  }
900
900
  async destroy() {
901
901
  this.exitFlush.flush("shutdown"), this.exitFlush.uninstall(), this.retry.stop(), this.pipeline.destroy(), await this.storage.close();
@@ -904,4 +904,4 @@ var ke = {
904
904
  //#endregion
905
905
  export { je as Sender };
906
906
 
907
- //# sourceMappingURL=sender-R7lOpyNc.js.map
907
+ //# sourceMappingURL=sender-BIob8eZz.js.map