@utk09/ui-observability 0.5.0 → 0.6.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.
- package/CHANGELOG.md +16 -0
- package/README.md +77 -60
- package/dist/bus/bus.d.ts +10 -10
- package/dist/bus/links.d.ts +1 -1
- package/dist/{bus-D3OO0OcL.js → bus-BTMuVkDk.js} +19 -19
- package/dist/bus-BTMuVkDk.js.map +1 -0
- package/dist/bus-ChIXDAWD.cjs +2 -0
- package/dist/bus-ChIXDAWD.cjs.map +1 -0
- package/dist/capture/network.d.ts +2 -2
- package/dist/capture/types.d.ts +10 -10
- package/dist/capture/web-vitals.d.ts +3 -3
- package/dist/{constants-B6kdsCzF.js → constants-0-YchbAL.js} +2 -2
- package/dist/constants-0-YchbAL.js.map +1 -0
- package/dist/{constants-DZH04585.cjs → constants-TUFcy95w.cjs} +2 -2
- package/dist/constants-TUFcy95w.cjs.map +1 -0
- package/dist/constants.d.ts +53 -40
- package/dist/core/breadcrumbs.d.ts +14 -14
- package/dist/core/config.d.ts +5 -4
- package/dist/core/context.d.ts +2 -2
- package/dist/core/diagnostics.d.ts +10 -9
- package/dist/core/journey.d.ts +23 -20
- package/dist/core/logger.d.ts +7 -7
- package/dist/core/pipeline.d.ts +34 -29
- package/dist/core/record.d.ts +6 -6
- package/dist/core/runtime.d.ts +20 -18
- package/dist/core/sampling.d.ts +15 -16
- package/dist/core/sender.d.ts +1 -1
- package/dist/{errors-DPju_xSI.cjs → errors-DRXBRqvm.cjs} +2 -2
- package/dist/errors-DRXBRqvm.cjs.map +1 -0
- package/dist/{errors-Dme9tz-6.js → errors-Dwm2SzBa.js} +4 -4
- package/dist/errors-Dwm2SzBa.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +61 -61
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-B5dwq4hW.cjs +2 -0
- package/dist/indexeddb-storage-B5dwq4hW.cjs.map +1 -0
- package/dist/{indexeddb-storage-nxs_rxGx.js → indexeddb-storage-DjY4Ml6t.js} +16 -16
- package/dist/indexeddb-storage-DjY4Ml6t.js.map +1 -0
- package/dist/{interactions-DP0-rIPJ.cjs → interactions-DVom6eYn.cjs} +2 -2
- package/dist/interactions-DVom6eYn.cjs.map +1 -0
- package/dist/{interactions-C1romMpE.js → interactions-DZmLu7l2.js} +2 -2
- package/dist/interactions-DZmLu7l2.js.map +1 -0
- package/dist/models/batch.d.ts +12 -9
- package/dist/models/bus.d.ts +12 -13
- package/dist/models/config.d.ts +58 -41
- package/dist/models/log-record.d.ts +12 -10
- package/dist/models/serializer.d.ts +3 -2
- package/dist/models/storage.d.ts +2 -2
- package/dist/{network-au-Tqt1n.js → network-C4d2uw2Z.js} +4 -4
- package/dist/network-C4d2uw2Z.js.map +1 -0
- package/dist/network-CuqWadNn.cjs +2 -0
- package/dist/network-CuqWadNn.cjs.map +1 -0
- package/dist/platform-CXio0W2n.cjs +2 -0
- package/dist/platform-CXio0W2n.cjs.map +1 -0
- package/dist/{platform-DMYo3AX3.js → platform-CY8S3hUs.js} +8 -8
- package/dist/platform-CY8S3hUs.js.map +1 -0
- package/dist/sampling-CEthcmEX.cjs +2 -0
- package/dist/sampling-CEthcmEX.cjs.map +1 -0
- package/dist/{sampling-ByI5H44E.js → sampling-CJsI_24L.js} +21 -18
- package/dist/sampling-CJsI_24L.js.map +1 -0
- package/dist/sender-ByFAkXVd.cjs +3 -0
- package/dist/sender-ByFAkXVd.cjs.map +1 -0
- package/dist/{sender-R7lOpyNc.js → sender-dpvR_bHM.js} +60 -60
- package/dist/sender-dpvR_bHM.js.map +1 -0
- package/dist/storage/emergency-queue.d.ts +2 -2
- package/dist/storage/factory.d.ts +2 -1
- package/dist/storage/idb-driver.d.ts +19 -19
- package/dist/storage/indexeddb-storage.d.ts +18 -17
- package/dist/storage/keys.d.ts +1 -1
- package/dist/storage/local-storage.d.ts +19 -18
- package/dist/storage/memory-storage.d.ts +12 -11
- package/dist/transport/compression.d.ts +2 -2
- package/dist/transport/errors.d.ts +8 -7
- package/dist/transport/exit-flush.d.ts +27 -24
- package/dist/transport/http-transport.d.ts +18 -11
- package/dist/transport/retry-engine.d.ts +33 -28
- package/dist/transport/serializers/ecs.d.ts +1 -1
- package/dist/transport/serializers/otlp.d.ts +1 -1
- package/dist/unref-16maCyKA.js.map +1 -1
- package/dist/unref-CU9Nyz_9.cjs.map +1 -1
- package/dist/utils/identity.d.ts +6 -5
- package/dist/utils/lock.d.ts +4 -4
- package/dist/utils/platform.d.ts +5 -3
- package/dist/utils/sanitize.d.ts +5 -2
- package/dist/utils/sequence.d.ts +2 -2
- package/dist/utils/tracing.d.ts +8 -7
- package/dist/web-vitals-B2FYsEAU.cjs +2 -0
- package/dist/web-vitals-B2FYsEAU.cjs.map +1 -0
- package/dist/{web-vitals-DwWdLBq6.js → web-vitals-DHZ0yA_H.js} +4 -4
- package/dist/web-vitals-DHZ0yA_H.js.map +1 -0
- package/package.json +1 -1
- package/dist/bus-D3OO0OcL.js.map +0 -1
- package/dist/bus-OdRJVUzr.cjs +0 -2
- package/dist/bus-OdRJVUzr.cjs.map +0 -1
- package/dist/constants-B6kdsCzF.js.map +0 -1
- package/dist/constants-DZH04585.cjs.map +0 -1
- package/dist/errors-DPju_xSI.cjs.map +0 -1
- package/dist/errors-Dme9tz-6.js.map +0 -1
- package/dist/indexeddb-storage-lGdoHGHy.cjs +0 -2
- package/dist/indexeddb-storage-lGdoHGHy.cjs.map +0 -1
- package/dist/indexeddb-storage-nxs_rxGx.js.map +0 -1
- package/dist/interactions-C1romMpE.js.map +0 -1
- package/dist/interactions-DP0-rIPJ.cjs.map +0 -1
- package/dist/network-DDVIJSHd.cjs +0 -2
- package/dist/network-DDVIJSHd.cjs.map +0 -1
- package/dist/network-au-Tqt1n.js.map +0 -1
- package/dist/platform-DMYo3AX3.js.map +0 -1
- package/dist/platform-g99Kn755.cjs +0 -2
- package/dist/platform-g99Kn755.cjs.map +0 -1
- package/dist/sampling-ByI5H44E.js.map +0 -1
- package/dist/sampling-Dui-Fp3u.cjs +0 -2
- package/dist/sampling-Dui-Fp3u.cjs.map +0 -1
- package/dist/sender-R7lOpyNc.js.map +0 -1
- package/dist/sender-vLcbQhiB.cjs +0 -3
- package/dist/sender-vLcbQhiB.cjs.map +0 -1
- package/dist/web-vitals-DM2nvcMJ.cjs +0 -2
- package/dist/web-vitals-DM2nvcMJ.cjs.map +0 -1
- 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-
|
|
2
|
-
import { _ as D, c as O, f as k, i as A, t as j } from "./sampling-
|
|
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-0-YchbAL.js";
|
|
2
|
+
import { _ as D, c as O, f as k, i as A, t as j } from "./sampling-CJsI_24L.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
|
|
13
|
-
id: O(),
|
|
14
|
-
records:
|
|
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 [
|
|
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", `
|
|
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", "
|
|
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", "
|
|
45
|
-
return n === void 0 ? null : N(n) ? n : (t.report("storage.degraded", "
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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)
|
|
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", "
|
|
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", "
|
|
171
|
-
return n === void 0 ? null : N(n) ? n : (this.diagnostics.report("storage.degraded", "
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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", "
|
|
265
|
-
let { IndexedDbStorage: e } = await import("./indexeddb-storage-
|
|
264
|
+
let e = await r.guardAsync("storage.unavailable", "The library could not open IndexedDB.", async () => {
|
|
265
|
+
let { IndexedDbStorage: e } = await import("./indexeddb-storage-DjY4Ml6t.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
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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", `
|
|
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", `
|
|
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", "
|
|
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", "
|
|
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
|
|
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", "
|
|
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
|
|
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
|
|
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)}
|
|
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
|
|
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)}
|
|
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)}
|
|
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", "
|
|
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", "
|
|
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", `
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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
|
|
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
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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", "
|
|
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-
|
|
907
|
+
//# sourceMappingURL=sender-dpvR_bHM.js.map
|