@utk09/ui-observability 0.9.2 → 0.9.4
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 +51 -0
- package/README.md +108 -33
- package/dist/batch-C4oF6XZT.cjs +2 -0
- package/dist/batch-C4oF6XZT.cjs.map +1 -0
- package/dist/{batch-4xKzzSCj.js → batch-D-4xl7op.js} +8 -5
- package/dist/batch-D-4xl7op.js.map +1 -0
- package/dist/bus/bus.d.ts +0 -4
- package/dist/{bus-DrixwdiX.js → bus-Cyvq-Ngx.js} +59 -62
- package/dist/bus-Cyvq-Ngx.js.map +1 -0
- package/dist/bus-rOhVuRee.cjs +2 -0
- package/dist/bus-rOhVuRee.cjs.map +1 -0
- package/dist/capture/network.d.ts +1 -0
- package/dist/capture/storm.d.ts +2 -7
- package/dist/capture/types.d.ts +3 -0
- package/dist/capture/web-socket.d.ts +40 -0
- package/dist/{console-B3vGRW5p.js → console-BT7mcgU6.js} +3 -3
- package/dist/{console-B3vGRW5p.js.map → console-BT7mcgU6.js.map} +1 -1
- package/dist/{console-ChfuJlf9.cjs → console-Boqa7new.cjs} +2 -2
- package/dist/{console-ChfuJlf9.cjs.map → console-Boqa7new.cjs.map} +1 -1
- package/dist/constants-BgRS6MB0.cjs +2 -0
- package/dist/constants-BgRS6MB0.cjs.map +1 -0
- package/dist/constants-L_d5YvvQ.js +160 -0
- package/dist/constants-L_d5YvvQ.js.map +1 -0
- package/dist/constants.d.ts +36 -5
- package/dist/core/breadcrumbs.d.ts +4 -4
- package/dist/core/context.d.ts +0 -8
- package/dist/core/diagnostics.d.ts +1 -3
- package/dist/core/journey.d.ts +7 -0
- package/dist/core/meter.d.ts +19 -1
- package/dist/core/pipeline.d.ts +12 -4
- package/dist/core/record.d.ts +40 -8
- package/dist/core/remote-sampling.d.ts +7 -3
- package/dist/core/runtime.d.ts +62 -3
- package/dist/core/sampling.d.ts +33 -4
- package/dist/core/sender.d.ts +8 -0
- package/dist/core/spans.d.ts +34 -0
- package/dist/{errors-BGs5NOrw.js → errors-BDI96zKc.js} +6 -6
- package/dist/errors-BDI96zKc.js.map +1 -0
- package/dist/errors-_xEsCVXn.cjs +3 -0
- package/dist/errors-_xEsCVXn.cjs.map +1 -0
- package/dist/fixed-window-BR0bu32Y.cjs +2 -0
- package/dist/fixed-window-BR0bu32Y.cjs.map +1 -0
- package/dist/fixed-window-Re7jIRJH.js +9 -0
- package/dist/fixed-window-Re7jIRJH.js.map +1 -0
- package/dist/identity-Bwku7zzN.cjs +2 -0
- package/dist/identity-Bwku7zzN.cjs.map +1 -0
- package/dist/{identity-rpEyjvVg.js → identity-Dtv917nz.js} +33 -23
- package/dist/identity-Dtv917nz.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +804 -537
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-Cvavrf-y.cjs +2 -0
- package/dist/indexeddb-storage-Cvavrf-y.cjs.map +1 -0
- package/dist/{indexeddb-storage-Q9fDYlyn.js → indexeddb-storage-HgkQUTyS.js} +57 -68
- package/dist/indexeddb-storage-HgkQUTyS.js.map +1 -0
- package/dist/{interactions-BAGRmtrv.cjs → interactions-Bhe1ft8P.cjs} +2 -2
- package/dist/interactions-Bhe1ft8P.cjs.map +1 -0
- package/dist/{interactions-B8zjCjga.js → interactions-Ck01cEij.js} +3 -3
- package/dist/interactions-Ck01cEij.js.map +1 -0
- package/dist/journey-Co9OlzrW.cjs +2 -0
- package/dist/journey-Co9OlzrW.cjs.map +1 -0
- package/dist/{journey-_dQQ1eMP.js → journey-DRK0A8u_.js} +37 -33
- package/dist/journey-DRK0A8u_.js.map +1 -0
- package/dist/{library-request-DX6ev9oG.js → library-request-ChCar5F8.js} +3 -3
- package/dist/{library-request-DX6ev9oG.js.map → library-request-ChCar5F8.js.map} +1 -1
- package/dist/{library-request-BIG3Xpx3.cjs → library-request-gMFOCNcn.cjs} +2 -2
- package/dist/{library-request-BIG3Xpx3.cjs.map → library-request-gMFOCNcn.cjs.map} +1 -1
- package/dist/log-record-cwFiLyPY.js +17 -0
- package/dist/log-record-cwFiLyPY.js.map +1 -0
- package/dist/log-record-jX9eWUP8.cjs +2 -0
- package/dist/log-record-jX9eWUP8.cjs.map +1 -0
- package/dist/{long-frames-Cq2LgNnp.cjs → long-frames-Bky6nZDF.cjs} +2 -2
- package/dist/long-frames-Bky6nZDF.cjs.map +1 -0
- package/dist/{long-frames-B0tKuChx.js → long-frames-DDumopji.js} +4 -4
- package/dist/long-frames-DDumopji.js.map +1 -0
- package/dist/models/batch.d.ts +6 -0
- package/dist/models/config.d.ts +56 -5
- package/dist/models/log-record.d.ts +1 -1
- package/dist/models/plugin.d.ts +47 -0
- package/dist/models/stats.d.ts +11 -0
- package/dist/{network-CMnEvGJB.js → network-BsBZ6_-Q.js} +43 -29
- package/dist/network-BsBZ6_-Q.js.map +1 -0
- package/dist/network-_4csBGBM.cjs +2 -0
- package/dist/network-_4csBGBM.cjs.map +1 -0
- package/dist/openfin-BwEN0uj4.js +8 -0
- package/dist/openfin-BwEN0uj4.js.map +1 -0
- package/dist/openfin-DtH2f7zX.cjs +2 -0
- package/dist/openfin-DtH2f7zX.cjs.map +1 -0
- package/dist/platform-4yYjMD-B.js +57 -0
- package/dist/platform-4yYjMD-B.js.map +1 -0
- package/dist/platform-o7r1ocOu.cjs +2 -0
- package/dist/platform-o7r1ocOu.cjs.map +1 -0
- package/dist/remote-rules-1KqfVBIu.js +91 -0
- package/dist/remote-rules-1KqfVBIu.js.map +1 -0
- package/dist/remote-rules-BHgEGlYi.cjs +2 -0
- package/dist/remote-rules-BHgEGlYi.cjs.map +1 -0
- package/dist/sampling-C4my-ma0.cjs +2 -0
- package/dist/sampling-C4my-ma0.cjs.map +1 -0
- package/dist/sampling-nYIWP_vP.js +86 -0
- package/dist/sampling-nYIWP_vP.js.map +1 -0
- package/dist/{sanitize-BNwgPj_B.js → sanitize-BiUKCUG6.js} +2 -2
- package/dist/{sanitize-BNwgPj_B.js.map → sanitize-BiUKCUG6.js.map} +1 -1
- package/dist/{sanitize-BqzPc4Jg.cjs → sanitize-BxuPSXOk.cjs} +2 -2
- package/dist/{sanitize-BqzPc4Jg.cjs.map → sanitize-BxuPSXOk.cjs.map} +1 -1
- package/dist/sender-6vrT9fFL.cjs +3 -0
- package/dist/sender-6vrT9fFL.cjs.map +1 -0
- package/dist/{sender--0_VzPbN.js → sender-DFQMF39P.js} +380 -278
- package/dist/sender-DFQMF39P.js.map +1 -0
- package/dist/storage/gap.d.ts +20 -0
- package/dist/storage/indexeddb-storage.d.ts +1 -7
- package/dist/storage/keys.d.ts +9 -0
- package/dist/storage/local-storage.d.ts +0 -6
- package/dist/storage/memory-storage.d.ts +1 -1
- package/dist/storm-6YYbXzT_.cjs +2 -0
- package/dist/storm-6YYbXzT_.cjs.map +1 -0
- package/dist/storm-CfO0Sam2.js +10 -0
- package/dist/storm-CfO0Sam2.js.map +1 -0
- package/dist/transport/exit-flush.d.ts +6 -0
- package/dist/transport/http-transport.d.ts +2 -1
- package/dist/transport/serializers/otlp-traces.d.ts +3 -0
- package/dist/transport/serializers/select.d.ts +8 -5
- package/dist/transport/status-transport.d.ts +7 -0
- package/dist/types-BR9t_w28.js +8 -0
- package/dist/types-BR9t_w28.js.map +1 -0
- package/dist/types-C7WNpnG1.cjs +2 -0
- package/dist/types-C7WNpnG1.cjs.map +1 -0
- package/dist/utils/fixed-window.d.ts +15 -0
- package/dist/utils/guards.d.ts +6 -0
- package/dist/utils/identity.d.ts +11 -0
- package/dist/utils/openfin.d.ts +48 -0
- package/dist/utils/platform.d.ts +13 -0
- package/dist/utils/tracing.d.ts +82 -4
- package/dist/web-socket-Ar4cZxmd.js +102 -0
- package/dist/web-socket-Ar4cZxmd.js.map +1 -0
- package/dist/web-socket-BwJdwSHl.cjs +2 -0
- package/dist/web-socket-BwJdwSHl.cjs.map +1 -0
- package/package.json +2 -3
- package/dist/batch-4xKzzSCj.js.map +0 -1
- package/dist/batch-cys7e53Q.cjs +0 -2
- package/dist/batch-cys7e53Q.cjs.map +0 -1
- package/dist/bus-B6vzPmQM.cjs +0 -2
- package/dist/bus-B6vzPmQM.cjs.map +0 -1
- package/dist/bus-DrixwdiX.js.map +0 -1
- package/dist/constants-Be83LICb.cjs +0 -2
- package/dist/constants-Be83LICb.cjs.map +0 -1
- package/dist/constants-CQ_D7jIW.js +0 -144
- package/dist/constants-CQ_D7jIW.js.map +0 -1
- package/dist/deadline-5_PecIl5.js +0 -26
- package/dist/deadline-5_PecIl5.js.map +0 -1
- package/dist/deadline-XSnm95pg.cjs +0 -2
- package/dist/deadline-XSnm95pg.cjs.map +0 -1
- package/dist/errors-BGs5NOrw.js.map +0 -1
- package/dist/errors-BMJm7KZZ.cjs +0 -3
- package/dist/errors-BMJm7KZZ.cjs.map +0 -1
- package/dist/identity-DXyV86o-.cjs +0 -2
- package/dist/identity-DXyV86o-.cjs.map +0 -1
- package/dist/identity-rpEyjvVg.js.map +0 -1
- package/dist/indexeddb-storage-BXaPVPyG.cjs +0 -2
- package/dist/indexeddb-storage-BXaPVPyG.cjs.map +0 -1
- package/dist/indexeddb-storage-Q9fDYlyn.js.map +0 -1
- package/dist/interactions-B8zjCjga.js.map +0 -1
- package/dist/interactions-BAGRmtrv.cjs.map +0 -1
- package/dist/journey-BGSyy8Es.cjs +0 -2
- package/dist/journey-BGSyy8Es.cjs.map +0 -1
- package/dist/journey-_dQQ1eMP.js.map +0 -1
- package/dist/long-frames-B0tKuChx.js.map +0 -1
- package/dist/long-frames-Cq2LgNnp.cjs.map +0 -1
- package/dist/network-C6kJbW6K.cjs +0 -2
- package/dist/network-C6kJbW6K.cjs.map +0 -1
- package/dist/network-CMnEvGJB.js.map +0 -1
- package/dist/platform-DNOJjpOm.cjs +0 -2
- package/dist/platform-DNOJjpOm.cjs.map +0 -1
- package/dist/platform-j0uMPwHi.js +0 -48
- package/dist/platform-j0uMPwHi.js.map +0 -1
- package/dist/remote-rules-DgoBJxZL.cjs +0 -2
- package/dist/remote-rules-DgoBJxZL.cjs.map +0 -1
- package/dist/remote-rules-UggoZqfP.js +0 -86
- package/dist/remote-rules-UggoZqfP.js.map +0 -1
- package/dist/sampling-BLMD8EGM.js +0 -64
- package/dist/sampling-BLMD8EGM.js.map +0 -1
- package/dist/sampling-MthcVXXU.cjs +0 -2
- package/dist/sampling-MthcVXXU.cjs.map +0 -1
- package/dist/sender--0_VzPbN.js.map +0 -1
- package/dist/sender-SPGMqZjD.cjs +0 -3
- package/dist/sender-SPGMqZjD.cjs.map +0 -1
- package/dist/storm-CTy1dfvs.cjs +0 -2
- package/dist/storm-CTy1dfvs.cjs.map +0 -1
- package/dist/storm-knaj4GUH.js +0 -10
- package/dist/storm-knaj4GUH.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { $ as e,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
6
|
-
import { i as ye, r as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { $ as e, $t as t, B as n, Dt as r, Et as i, Gt as a, Kt as o, M as s, Mt as c, N as l, P as u, Q as d, Qt as f, Rt as p, St as m, U as h, V as ee, Vt as te, W as g, X as ne, Z as re, _n as _, bn as v, d as ie, dn as y, en as b, et as ae, gn as oe, hn as se, in as x, jt as ce, ln as S, mn as le, n as C, tt as ue, un as de, wt as fe, x as w, xn as T, zt as pe } from "./constants-L_d5YvvQ.js";
|
|
2
|
+
import { c as E, l as D, s as me, t as he } from "./sampling-nYIWP_vP.js";
|
|
3
|
+
import { r as ge } from "./log-record-cwFiLyPY.js";
|
|
4
|
+
import { o as _e, t as O } from "./sanitize-BiUKCUG6.js";
|
|
5
|
+
import { i as ve } from "./identity-Dtv917nz.js";
|
|
6
|
+
import { i as ye, r as k } from "./library-request-ChCar5F8.js";
|
|
7
|
+
import { t as A } from "./openfin-BwEN0uj4.js";
|
|
8
|
+
import { r as j } from "./platform-4yYjMD-B.js";
|
|
9
|
+
import { a as be, i as M, n as xe, r as Se, t as Ce } from "./batch-D-4xl7op.js";
|
|
10
|
+
import { n as we, t as Te } from "./remote-rules-1KqfVBIu.js";
|
|
9
11
|
//#region src/models/storage.ts
|
|
10
|
-
function
|
|
12
|
+
function Ee(e) {
|
|
11
13
|
let { maxBatches: t } = e;
|
|
12
14
|
return e.mode === "until-delivered" ? {
|
|
13
15
|
maxBatches: t,
|
|
@@ -21,12 +23,15 @@ function j(e) {
|
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
23
25
|
//#region src/utils/lock.ts
|
|
24
|
-
function
|
|
26
|
+
function De(e, t, n, { skipIfBusy: r = !0 } = {}) {
|
|
25
27
|
let i = globalThis.navigator?.locks;
|
|
26
28
|
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();
|
|
27
29
|
}
|
|
28
30
|
//#endregion
|
|
29
31
|
//#region src/storage/keys.ts
|
|
32
|
+
function Oe(e, t) {
|
|
33
|
+
return `${e}${String(t.createdAt).padStart(14, "0")}.${t.id}`;
|
|
34
|
+
}
|
|
30
35
|
function N(e, t) {
|
|
31
36
|
let n = [];
|
|
32
37
|
return t.guard("storage.unavailable", "The library could not list the localStorage keys.", () => {
|
|
@@ -38,57 +43,53 @@ function N(e, t) {
|
|
|
38
43
|
}
|
|
39
44
|
//#endregion
|
|
40
45
|
//#region src/storage/emergency-queue.ts
|
|
41
|
-
function
|
|
42
|
-
let t = String(e.createdAt).padStart(14, "0");
|
|
43
|
-
return `${a}${t}.${e.id}`;
|
|
44
|
-
}
|
|
45
|
-
function P(e, t) {
|
|
46
|
+
function ke(e, t) {
|
|
46
47
|
let n = t.guard("storage.degraded", "An emergency entry is not valid JSON. The library dropped it.", () => JSON.parse(e));
|
|
47
|
-
return n === void 0 ? null :
|
|
48
|
+
return n === void 0 ? null : M(n) ? n : (t.report("storage.degraded", "An emergency entry is not a batch. The library dropped it."), null);
|
|
48
49
|
}
|
|
49
|
-
async function
|
|
50
|
+
async function Ae(e, t) {
|
|
50
51
|
let n = 0;
|
|
51
|
-
for (let r of N(
|
|
52
|
+
for (let r of N(h, t)) {
|
|
52
53
|
let i = t.guard("storage.unavailable", "The library could not read the emergency queue.", () => {
|
|
53
54
|
let e = localStorage.getItem(r);
|
|
54
55
|
return localStorage.removeItem(r), e;
|
|
55
56
|
});
|
|
56
57
|
if (!i) continue;
|
|
57
|
-
let a =
|
|
58
|
+
let a = ke(i, t);
|
|
58
59
|
if (a !== null) try {
|
|
59
|
-
await
|
|
60
|
+
await E(e.save(a), y), n++;
|
|
60
61
|
} catch (e) {
|
|
61
62
|
t.report("storage.degraded", "The library could not recover an emergency batch.", { key: r }, e);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
return n;
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
-
let r = `writing the emergency queue, ${String(e.records.length)} records`, i = [],
|
|
68
|
-
let n = N(
|
|
67
|
+
function je(e, t, n) {
|
|
68
|
+
let r = `writing the emergency queue, ${String(e.records.length)} records`, i = [], a = t.guard("storage.quota_exceeded", r, () => {
|
|
69
|
+
let n = N(h, t);
|
|
69
70
|
for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) {
|
|
70
|
-
let n =
|
|
71
|
+
let n = ke(String(localStorage.getItem(e)), t);
|
|
71
72
|
n !== null && i.push(n), localStorage.removeItem(e);
|
|
72
73
|
}
|
|
73
|
-
return localStorage.setItem(
|
|
74
|
+
return localStorage.setItem(Oe(h, e), JSON.stringify(e)), !0;
|
|
74
75
|
});
|
|
75
76
|
t.guard("pipeline.crashed", "The loss report of the emergency queue failed.", () => {
|
|
76
77
|
if (i.length > 0) {
|
|
77
78
|
let e = i.flatMap((e) => e.records);
|
|
78
79
|
n?.("exit_queue_full", e, i.map((e) => e.id));
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
a !== !0 && n?.("quota", e.records, [e.id]);
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
async function
|
|
84
|
-
return await
|
|
84
|
+
async function Me(e, t) {
|
|
85
|
+
return await De("ui-observability.emergency", t, () => Ae(e, t), { skipIfBusy: !1 }) ?? 0;
|
|
85
86
|
}
|
|
86
87
|
//#endregion
|
|
87
88
|
//#region src/storage/eviction.ts
|
|
88
|
-
function
|
|
89
|
-
return Array.isArray(e.records) && e.records.some(
|
|
89
|
+
function P(e) {
|
|
90
|
+
return Array.isArray(e.records) && e.records.some(Se);
|
|
90
91
|
}
|
|
91
|
-
var
|
|
92
|
+
var Ne = class {
|
|
92
93
|
howMany;
|
|
93
94
|
isAudit;
|
|
94
95
|
plain = [];
|
|
@@ -103,35 +104,47 @@ var L = class {
|
|
|
103
104
|
return [...this.plain, ...this.audit].slice(0, this.howMany);
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
|
-
function
|
|
107
|
-
let r = new
|
|
107
|
+
function F(e, t, n) {
|
|
108
|
+
let r = new Ne(t, n);
|
|
108
109
|
for (let t of e) if (!r.add(t)) break;
|
|
109
110
|
return r.picked();
|
|
110
111
|
}
|
|
111
112
|
//#endregion
|
|
112
|
-
//#region src/storage/
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
//#region src/storage/gap.ts
|
|
114
|
+
function I(e, t, n, r) {
|
|
115
|
+
return e.batches += n, e.records += r, e.reason = t, {
|
|
116
|
+
batches: n,
|
|
117
|
+
records: r,
|
|
118
|
+
reason: t
|
|
119
|
+
};
|
|
116
120
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
121
|
+
function L(e, t, n, r) {
|
|
122
|
+
n.batches !== 0 && (e.report("storage.evicted", `The library dropped ${String(n.batches)} stored batches (${String(n.records)} records).`, { ...n }), t?.(n, r));
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/storage/local-storage.ts
|
|
126
|
+
function Pe(e) {
|
|
127
|
+
let t = w.length, n = Number(e.slice(t, t + 14));
|
|
119
128
|
return Number.isFinite(n) ? n : null;
|
|
120
129
|
}
|
|
121
|
-
var
|
|
130
|
+
var Fe = class {
|
|
122
131
|
limits;
|
|
123
132
|
diagnostics;
|
|
124
133
|
onGap;
|
|
125
|
-
name =
|
|
134
|
+
name = le;
|
|
126
135
|
constructor(e, t, n) {
|
|
127
136
|
this.limits = e, this.diagnostics = t, this.onGap = n;
|
|
128
137
|
}
|
|
129
138
|
async save(e) {
|
|
130
|
-
this.write(e, "localStorage refused a batch, evicting the oldest")
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
if (this.write(e, "localStorage refused a batch, evicting the oldest")) await this.prune();
|
|
140
|
+
else if (this.evictForQuota(), !this.write(e, "localStorage refused a batch even after evicting")) {
|
|
141
|
+
let t = {
|
|
142
|
+
batches: 1,
|
|
143
|
+
records: e.records.length,
|
|
144
|
+
reason: "quota"
|
|
145
|
+
};
|
|
146
|
+
L(this.diagnostics, this.onGap, t, [e]);
|
|
147
|
+
}
|
|
135
148
|
}
|
|
136
149
|
take(e) {
|
|
137
150
|
let t = [];
|
|
@@ -160,7 +173,7 @@ var Oe = class {
|
|
|
160
173
|
reason: "expired"
|
|
161
174
|
}, n = [], r = [];
|
|
162
175
|
for (let t of this.keys()) {
|
|
163
|
-
let i =
|
|
176
|
+
let i = Pe(t);
|
|
164
177
|
i === null || i < e ? n.push(t) : r.push(t);
|
|
165
178
|
}
|
|
166
179
|
this.drop(t, "expired", [...this.entries(n)]);
|
|
@@ -177,7 +190,7 @@ var Oe = class {
|
|
|
177
190
|
return Promise.resolve();
|
|
178
191
|
}
|
|
179
192
|
write(e, t) {
|
|
180
|
-
return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(
|
|
193
|
+
return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(Oe(w, e), JSON.stringify(e)), !0)) === !0;
|
|
181
194
|
}
|
|
182
195
|
evictForQuota() {
|
|
183
196
|
let e = this.keys(), t = {
|
|
@@ -188,7 +201,7 @@ var Oe = class {
|
|
|
188
201
|
this.drop(t, "quota", this.evictable(e, n));
|
|
189
202
|
}
|
|
190
203
|
evictable(e, t) {
|
|
191
|
-
return
|
|
204
|
+
return F(this.entries(e), t, (e) => e.batch !== null && P(e.batch));
|
|
192
205
|
}
|
|
193
206
|
*entries(e) {
|
|
194
207
|
for (let t of e) yield {
|
|
@@ -198,22 +211,16 @@ var Oe = class {
|
|
|
198
211
|
}
|
|
199
212
|
drop(e, t, n) {
|
|
200
213
|
if (n.length === 0) return;
|
|
201
|
-
let r = []
|
|
202
|
-
for (let { key: e, batch: t } of n) this.removeKey(e),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
records: i,
|
|
206
|
-
reason: t
|
|
207
|
-
}, r);
|
|
208
|
-
}
|
|
209
|
-
reportGap(e, t) {
|
|
210
|
-
this.diagnostics.report("storage.evicted", `The library dropped ${String(e.batches)} stored batches (${String(e.records)} records).`, { ...e }), this.onGap?.(e, t);
|
|
214
|
+
let r = [];
|
|
215
|
+
for (let { key: e, batch: t } of n) this.removeKey(e), t && r.push(t);
|
|
216
|
+
let i = I(e, t, n.length, xe(r));
|
|
217
|
+
L(this.diagnostics, this.onGap, i, r);
|
|
211
218
|
}
|
|
212
219
|
read(e) {
|
|
213
220
|
let t = this.diagnostics.guard("storage.unavailable", "The library could not read a stored batch.", () => localStorage.getItem(e));
|
|
214
221
|
if (!t) return null;
|
|
215
222
|
let n = this.diagnostics.guard("storage.degraded", "A stored batch is corrupt. The library removed it.", () => JSON.parse(t));
|
|
216
|
-
return n === void 0 ? null :
|
|
223
|
+
return n === void 0 ? null : M(n) ? n : (this.diagnostics.report("storage.degraded", "A stored entry is not a batch. The library dropped it."), null);
|
|
217
224
|
}
|
|
218
225
|
keyOf(e) {
|
|
219
226
|
return this.keys().find((t) => t.endsWith(`.${e}`)) ?? null;
|
|
@@ -227,18 +234,12 @@ var Oe = class {
|
|
|
227
234
|
});
|
|
228
235
|
}
|
|
229
236
|
keys() {
|
|
230
|
-
return N(
|
|
237
|
+
return N(w, this.diagnostics);
|
|
231
238
|
}
|
|
232
|
-
}
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region src/storage/memory-storage.ts
|
|
235
|
-
function ke(e) {
|
|
236
|
-
return e.reduce((e, t) => e + t.records.length, 0);
|
|
237
|
-
}
|
|
238
|
-
var z = class {
|
|
239
|
+
}, R = class {
|
|
239
240
|
limits;
|
|
240
241
|
onGap;
|
|
241
|
-
name =
|
|
242
|
+
name = se;
|
|
242
243
|
batches = [];
|
|
243
244
|
constructor(e, t) {
|
|
244
245
|
this.limits = e, this.onGap = t;
|
|
@@ -265,19 +266,15 @@ var z = class {
|
|
|
265
266
|
this.batches = this.batches.filter((t) => t.createdAt >= e), this.report(t, "expired", n);
|
|
266
267
|
let r = this.batches.length - this.limits.maxBatches;
|
|
267
268
|
if (r > 0) {
|
|
268
|
-
let e =
|
|
269
|
+
let e = F(this.batches, r, P);
|
|
269
270
|
this.batches = this.batches.filter((t) => !e.includes(t)), this.report(t, "over_capacity", e);
|
|
270
271
|
}
|
|
271
272
|
return Promise.resolve(t);
|
|
272
273
|
}
|
|
273
274
|
report(e, t, n) {
|
|
274
275
|
if (n.length === 0) return;
|
|
275
|
-
let r =
|
|
276
|
-
|
|
277
|
-
batches: n.length,
|
|
278
|
-
records: r,
|
|
279
|
-
reason: t
|
|
280
|
-
}, n);
|
|
276
|
+
let r = I(e, t, n.length, xe(n));
|
|
277
|
+
this.onGap?.(r, n);
|
|
281
278
|
}
|
|
282
279
|
count() {
|
|
283
280
|
return Promise.resolve(this.batches.length);
|
|
@@ -288,8 +285,8 @@ var z = class {
|
|
|
288
285
|
close() {
|
|
289
286
|
return this.batches = [], Promise.resolve();
|
|
290
287
|
}
|
|
291
|
-
},
|
|
292
|
-
name:
|
|
288
|
+
}, Ie = (e) => ({
|
|
289
|
+
name: oe,
|
|
293
290
|
save: (t) => (e?.({
|
|
294
291
|
batches: 1,
|
|
295
292
|
records: t.records.length,
|
|
@@ -307,30 +304,30 @@ var z = class {
|
|
|
307
304
|
clear: () => Promise.resolve(),
|
|
308
305
|
close: () => Promise.resolve()
|
|
309
306
|
});
|
|
310
|
-
function
|
|
307
|
+
function Le(e) {
|
|
311
308
|
return e.guard("storage.unavailable", "The library could not read indexedDB.", () => globalThis.indexedDB != null) === !0;
|
|
312
309
|
}
|
|
313
|
-
function
|
|
314
|
-
return e.guard("storage.unavailable", "The library could not write a test key to localStorage.", () => (localStorage.setItem(
|
|
310
|
+
function Re(e) {
|
|
311
|
+
return e.guard("storage.unavailable", "The library could not write a test key to localStorage.", () => (localStorage.setItem(_, "1"), localStorage.removeItem(_), !0)) === !0;
|
|
315
312
|
}
|
|
316
|
-
async function
|
|
317
|
-
if (e === "none") return
|
|
318
|
-
if (e === "memory") return new
|
|
313
|
+
async function ze(e, t, n, r, i) {
|
|
314
|
+
if (e === "none") return Ie(i);
|
|
315
|
+
if (e === "memory") return new R(n, i);
|
|
319
316
|
if (e === "indexeddb" || e === "auto") {
|
|
320
|
-
if (
|
|
317
|
+
if (Le(r)) {
|
|
321
318
|
let e = await r.guardAsync("storage.unavailable", "The library could not open IndexedDB.", async () => {
|
|
322
|
-
let { IndexedDbStorage: e } = await import("./indexeddb-storage-
|
|
319
|
+
let { IndexedDbStorage: e } = await import("./indexeddb-storage-HgkQUTyS.js"), a = new e(t, n, r, i);
|
|
323
320
|
return await a.open(), a;
|
|
324
321
|
});
|
|
325
322
|
if (e) return e;
|
|
326
323
|
}
|
|
327
|
-
if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new
|
|
324
|
+
if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new R(n, i);
|
|
328
325
|
}
|
|
329
|
-
return
|
|
326
|
+
return Re(r) ? new Fe(n, r, i) : (r.report("storage.degraded", "No persistent storage is available. The library keeps undelivered records in memory only."), new R(n, i));
|
|
330
327
|
}
|
|
331
328
|
//#endregion
|
|
332
329
|
//#region src/transport/errors.ts
|
|
333
|
-
var
|
|
330
|
+
var z = class extends Error {
|
|
334
331
|
kind;
|
|
335
332
|
status;
|
|
336
333
|
retryAfterMs;
|
|
@@ -339,28 +336,33 @@ var B = class extends Error {
|
|
|
339
336
|
super(t, a === void 0 ? void 0 : { cause: a }), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
|
|
340
337
|
}
|
|
341
338
|
};
|
|
342
|
-
function
|
|
339
|
+
function Be(e) {
|
|
343
340
|
if (!e) return;
|
|
344
341
|
let t = Number(e);
|
|
345
|
-
if (Number.isFinite(t)) return Math.max(0, t *
|
|
342
|
+
if (Number.isFinite(t)) return Math.max(0, t * fe);
|
|
346
343
|
let n = Date.parse(e);
|
|
347
344
|
return Number.isNaN(n) ? void 0 : Math.max(0, n - Date.now());
|
|
348
345
|
}
|
|
349
346
|
//#endregion
|
|
350
347
|
//#region src/transport/serializers/ecs.ts
|
|
351
|
-
|
|
352
|
-
|
|
348
|
+
var B = {
|
|
349
|
+
"error.type": "type",
|
|
350
|
+
"error.message": "message",
|
|
351
|
+
"error.stack_trace": "stack_trace"
|
|
352
|
+
}, Ve = /* @__PURE__ */ new Set([C, ...Object.keys(B)]);
|
|
353
|
+
function He(e) {
|
|
354
|
+
return i.test(e) ? Number(BigInt(e) / r) : Date.now();
|
|
353
355
|
}
|
|
354
|
-
function
|
|
356
|
+
function Ue(e) {
|
|
355
357
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : typeof e == "bigint" ? e.toString() : null;
|
|
356
358
|
}
|
|
357
|
-
function
|
|
359
|
+
function We(e, t, n) {
|
|
358
360
|
let r = e[t];
|
|
359
361
|
r === void 0 ? e[t] = n : Array.isArray(r) ? r.push(n) : e[t] = [r, n];
|
|
360
362
|
}
|
|
361
363
|
function V(e, t, n, r) {
|
|
362
|
-
let i =
|
|
363
|
-
if (i !== null)
|
|
364
|
+
let i = Ue(n);
|
|
365
|
+
if (i !== null) We(e, t, i);
|
|
364
366
|
else if (typeof n == "object" && n && !r.has(n)) {
|
|
365
367
|
if (r.add(n), Array.isArray(n)) for (let i of n) V(e, t, i, r);
|
|
366
368
|
else for (let [i, a] of Object.entries(n)) V(e, `${t}.${i}`, a, r);
|
|
@@ -372,32 +374,49 @@ function H(e) {
|
|
|
372
374
|
for (let [r, i] of Object.entries(e)) V(t, r, i, n);
|
|
373
375
|
return t;
|
|
374
376
|
}
|
|
375
|
-
|
|
377
|
+
function Ge(e) {
|
|
378
|
+
let t = [];
|
|
379
|
+
for (let [n, r] of Object.entries(B)) {
|
|
380
|
+
let i = e[n];
|
|
381
|
+
typeof i == "string" && t.push([r, i]);
|
|
382
|
+
}
|
|
383
|
+
return t.length > 0 ? Object.fromEntries(t) : void 0;
|
|
384
|
+
}
|
|
385
|
+
function Ke(e) {
|
|
386
|
+
return Object.fromEntries(Object.entries(e).filter(([e, t]) => !(Ve.has(e) && typeof t == "string")));
|
|
387
|
+
}
|
|
388
|
+
var qe = {
|
|
376
389
|
name: "ecs",
|
|
377
390
|
serialize(e) {
|
|
378
391
|
return {
|
|
379
392
|
body: `${e.map((e) => {
|
|
380
|
-
let
|
|
393
|
+
let t = He(e.timeUnixNano), { attributes: r } = e, i = r[C];
|
|
381
394
|
return JSON.stringify({
|
|
382
|
-
"@timestamp": new Date(
|
|
395
|
+
"@timestamp": new Date(t).toISOString(),
|
|
383
396
|
message: e.body,
|
|
384
|
-
|
|
397
|
+
ecs: { version: ee },
|
|
398
|
+
log: {
|
|
399
|
+
level: n[e.severityText] ?? e.severityText.toLowerCase(),
|
|
400
|
+
logger: typeof i == "string" ? i : void 0
|
|
401
|
+
},
|
|
402
|
+
event: { kind: r["log.type"] === "metric" ? "metric" : "event" },
|
|
403
|
+
error: Ge(r),
|
|
385
404
|
trace: { id: e.traceId },
|
|
386
405
|
span: { id: e.spanId },
|
|
387
406
|
service: {
|
|
388
|
-
name: e.resource[
|
|
407
|
+
name: e.resource[a],
|
|
389
408
|
version: e.resource[o],
|
|
390
|
-
environment: e.resource[
|
|
409
|
+
environment: e.resource[te]
|
|
391
410
|
},
|
|
392
|
-
user_agent: { original: e.resource[
|
|
393
|
-
url: { full:
|
|
411
|
+
user_agent: { original: e.resource[pe] },
|
|
412
|
+
url: { full: r["url.full"] ?? r["page.url"] },
|
|
394
413
|
labels: {
|
|
395
414
|
...H(e.resource),
|
|
396
|
-
...H(
|
|
415
|
+
...H(Ke(r))
|
|
397
416
|
}
|
|
398
417
|
});
|
|
399
418
|
}).join("\n")}\n`,
|
|
400
|
-
contentType:
|
|
419
|
+
contentType: l
|
|
401
420
|
};
|
|
402
421
|
}
|
|
403
422
|
};
|
|
@@ -418,7 +437,7 @@ function W(e) {
|
|
|
418
437
|
return t;
|
|
419
438
|
}
|
|
420
439
|
var G = /* @__PURE__ */ new WeakMap();
|
|
421
|
-
function
|
|
440
|
+
function Je(e) {
|
|
422
441
|
let t = G.get(e);
|
|
423
442
|
if (t !== void 0) return t;
|
|
424
443
|
let n = JSON.stringify(e);
|
|
@@ -427,7 +446,7 @@ function ze(e) {
|
|
|
427
446
|
function K(e) {
|
|
428
447
|
let t = /* @__PURE__ */ new Map();
|
|
429
448
|
for (let n of e) {
|
|
430
|
-
let e =
|
|
449
|
+
let e = Je(n.resource), r = t.get(e);
|
|
431
450
|
r ? r.records.push(n) : t.set(e, {
|
|
432
451
|
resource: n.resource,
|
|
433
452
|
records: [n]
|
|
@@ -435,15 +454,15 @@ function K(e) {
|
|
|
435
454
|
}
|
|
436
455
|
return [...t.values()];
|
|
437
456
|
}
|
|
438
|
-
var
|
|
439
|
-
name:
|
|
457
|
+
var Ye = {
|
|
458
|
+
name: x,
|
|
440
459
|
serialize(e) {
|
|
441
460
|
let t = K(e).map((e) => ({
|
|
442
461
|
resource: { attributes: W(e.resource) },
|
|
443
462
|
scopeLogs: [{
|
|
444
463
|
scope: {
|
|
445
|
-
name:
|
|
446
|
-
version:
|
|
464
|
+
name: v,
|
|
465
|
+
version: T
|
|
447
466
|
},
|
|
448
467
|
logRecords: e.records.map((e) => ({
|
|
449
468
|
timeUnixNano: e.timeUnixNano,
|
|
@@ -460,19 +479,19 @@ var Be = {
|
|
|
460
479
|
}));
|
|
461
480
|
return {
|
|
462
481
|
body: JSON.stringify({ resourceLogs: t }),
|
|
463
|
-
contentType:
|
|
482
|
+
contentType: s
|
|
464
483
|
};
|
|
465
484
|
}
|
|
466
|
-
},
|
|
485
|
+
}, Xe = 1;
|
|
467
486
|
function q(e, t) {
|
|
468
487
|
let n = e.attributes[t];
|
|
469
488
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
470
489
|
}
|
|
471
|
-
function
|
|
490
|
+
function Ze(e) {
|
|
472
491
|
return Array.isArray(e) && e.every((e) => typeof e == "number" && Number.isFinite(e));
|
|
473
492
|
}
|
|
474
|
-
function
|
|
475
|
-
let t = e.attributes[
|
|
493
|
+
function Qe(e) {
|
|
494
|
+
let t = e.attributes[m.attributeKeys], n = {};
|
|
476
495
|
if (!Array.isArray(t)) return n;
|
|
477
496
|
for (let r of t) {
|
|
478
497
|
let t = typeof r == "string" && !r.startsWith("metric.") ? e.attributes[r] : void 0;
|
|
@@ -480,8 +499,8 @@ function He(e) {
|
|
|
480
499
|
}
|
|
481
500
|
return n;
|
|
482
501
|
}
|
|
483
|
-
function
|
|
484
|
-
let t = q(e,
|
|
502
|
+
function $e(e) {
|
|
503
|
+
let t = q(e, m.count);
|
|
485
504
|
if (t === void 0) {
|
|
486
505
|
let t = q(e, "metric.value");
|
|
487
506
|
return t === void 0 ? null : {
|
|
@@ -493,39 +512,39 @@ function Ue(e) {
|
|
|
493
512
|
explicitBounds: []
|
|
494
513
|
};
|
|
495
514
|
}
|
|
496
|
-
let n = e.attributes[
|
|
497
|
-
if (!
|
|
498
|
-
let i = q(e,
|
|
515
|
+
let n = e.attributes[m.bounds], r = e.attributes[m.buckets];
|
|
516
|
+
if (!Ze(n) || !Ze(r) || r.length !== n.length + 1) return null;
|
|
517
|
+
let i = q(e, m.min);
|
|
499
518
|
return {
|
|
500
519
|
count: String(t),
|
|
501
|
-
sum: i !== void 0 && i < 0 ? void 0 : q(e,
|
|
520
|
+
sum: i !== void 0 && i < 0 ? void 0 : q(e, m.sum),
|
|
502
521
|
min: i,
|
|
503
|
-
max: q(e,
|
|
522
|
+
max: q(e, m.max),
|
|
504
523
|
bucketCounts: r.map(String),
|
|
505
524
|
explicitBounds: n
|
|
506
525
|
};
|
|
507
526
|
}
|
|
508
|
-
function
|
|
527
|
+
function et(e) {
|
|
509
528
|
let t = q(e, "metric.value");
|
|
510
529
|
return t === void 0 ? null : { asDouble: t };
|
|
511
530
|
}
|
|
512
|
-
function
|
|
513
|
-
let n = e.attributes[
|
|
531
|
+
function tt(e, t) {
|
|
532
|
+
let n = e.attributes[m.start], r = t === "histogram" ? $e(e) : et(e);
|
|
514
533
|
return r === null ? null : {
|
|
515
|
-
attributes: W(
|
|
534
|
+
attributes: W(Qe(e)),
|
|
516
535
|
startTimeUnixNano: typeof n == "string" ? n : e.timeUnixNano,
|
|
517
536
|
timeUnixNano: e.timeUnixNano,
|
|
518
537
|
...r
|
|
519
538
|
};
|
|
520
539
|
}
|
|
521
|
-
function
|
|
540
|
+
function nt({ name: e, unit: t, field: n, points: r }) {
|
|
522
541
|
if (n === "gauge") return {
|
|
523
542
|
name: e,
|
|
524
543
|
unit: t,
|
|
525
544
|
gauge: { dataPoints: r }
|
|
526
545
|
};
|
|
527
546
|
let i = {
|
|
528
|
-
aggregationTemporality:
|
|
547
|
+
aggregationTemporality: Xe,
|
|
529
548
|
dataPoints: r
|
|
530
549
|
};
|
|
531
550
|
return n === "sum" && (i.isMonotonic = r.every((e) => e.asDouble >= 0)), {
|
|
@@ -534,13 +553,13 @@ function Ke({ name: e, unit: t, field: n, points: r }) {
|
|
|
534
553
|
[n]: i
|
|
535
554
|
};
|
|
536
555
|
}
|
|
537
|
-
var
|
|
538
|
-
name:
|
|
556
|
+
var rt = {
|
|
557
|
+
name: x,
|
|
539
558
|
serialize(e) {
|
|
540
559
|
let t = K(e).map((e) => {
|
|
541
560
|
let t = /* @__PURE__ */ new Map();
|
|
542
561
|
for (let n of e.records) {
|
|
543
|
-
let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i =
|
|
562
|
+
let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i = tt(n, r);
|
|
544
563
|
if (i === null) continue;
|
|
545
564
|
let a = n.attributes["metric.name"], o = n.attributes["metric.unit"], s = {
|
|
546
565
|
name: typeof a == "string" ? a : n.body,
|
|
@@ -558,33 +577,78 @@ var qe = {
|
|
|
558
577
|
resource: { attributes: W(e.resource) },
|
|
559
578
|
scopeMetrics: [{
|
|
560
579
|
scope: {
|
|
561
|
-
name:
|
|
562
|
-
version:
|
|
580
|
+
name: v,
|
|
581
|
+
version: T
|
|
563
582
|
},
|
|
564
|
-
metrics: [...t.values()].map(
|
|
583
|
+
metrics: [...t.values()].map(nt)
|
|
565
584
|
}]
|
|
566
585
|
};
|
|
567
586
|
});
|
|
568
587
|
return {
|
|
569
588
|
body: JSON.stringify({ resourceMetrics: t }),
|
|
570
|
-
contentType:
|
|
589
|
+
contentType: s
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
}, it = {
|
|
593
|
+
internal: 1,
|
|
594
|
+
client: 3
|
|
595
|
+
}, at = 2, ot = 0, st = /* @__PURE__ */ new Set([ie, ...Object.values(S)]);
|
|
596
|
+
function J(e, t) {
|
|
597
|
+
let n = e.attributes[t];
|
|
598
|
+
return typeof n == "string" ? n : void 0;
|
|
599
|
+
}
|
|
600
|
+
function ct(e) {
|
|
601
|
+
let t = Object.fromEntries(Object.entries(e.attributes).filter(([e]) => !st.has(e))), n = J(e, S.parentId);
|
|
602
|
+
return {
|
|
603
|
+
traceId: e.traceId,
|
|
604
|
+
spanId: e.spanId,
|
|
605
|
+
...n ? { parentSpanId: n } : {},
|
|
606
|
+
name: e.body,
|
|
607
|
+
kind: J(e, S.kind) === "client" ? it.client : it.internal,
|
|
608
|
+
startTimeUnixNano: J(e, S.start) ?? e.timeUnixNano,
|
|
609
|
+
endTimeUnixNano: J(e, S.end) ?? e.timeUnixNano,
|
|
610
|
+
attributes: W(t),
|
|
611
|
+
status: { code: J(e, S.status) === "error" ? at : ot }
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
var lt = {
|
|
615
|
+
name: x,
|
|
616
|
+
serialize(e) {
|
|
617
|
+
let t = K(e).map((e) => ({
|
|
618
|
+
resource: { attributes: W(e.resource) },
|
|
619
|
+
scopeSpans: [{
|
|
620
|
+
scope: {
|
|
621
|
+
name: v,
|
|
622
|
+
version: T
|
|
623
|
+
},
|
|
624
|
+
spans: e.records.map(ct)
|
|
625
|
+
}]
|
|
626
|
+
}));
|
|
627
|
+
return {
|
|
628
|
+
body: JSON.stringify({ resourceSpans: t }),
|
|
629
|
+
contentType: s
|
|
571
630
|
};
|
|
572
631
|
}
|
|
573
632
|
};
|
|
574
633
|
//#endregion
|
|
575
634
|
//#region src/transport/serializers/select.ts
|
|
576
|
-
function
|
|
577
|
-
return e === "otlp" ?
|
|
635
|
+
function ut(e) {
|
|
636
|
+
return e === "otlp" ? Ye : e === "ecs" ? qe : e;
|
|
578
637
|
}
|
|
579
638
|
function Y(e, t) {
|
|
580
|
-
|
|
639
|
+
let n = (t) => e.records.length > 0 && e.records.every((e) => Ce(e, "log.type") === t);
|
|
640
|
+
return t.metricsEndpoint !== "" && n("metric") ? "metrics" : n("span") ? "traces" : "logs";
|
|
581
641
|
}
|
|
582
642
|
function X(e, t) {
|
|
583
|
-
return e === "metrics" ? t.metricsEndpoint : t.endpoint;
|
|
643
|
+
return e === "metrics" ? t.metricsEndpoint : e === "traces" ? t.tracesEndpoint : t.endpoint;
|
|
584
644
|
}
|
|
645
|
+
var dt = {
|
|
646
|
+
metrics: rt,
|
|
647
|
+
traces: lt
|
|
648
|
+
};
|
|
585
649
|
function Z(e, t, n, r) {
|
|
586
650
|
try {
|
|
587
|
-
return (Y(t, e)
|
|
651
|
+
return (dt[Y(t, e)] ?? ut(e.serializer)).serialize(t.records);
|
|
588
652
|
} catch (e) {
|
|
589
653
|
n.report("transport.serialize_failed", r, { batchId: t.id }, e);
|
|
590
654
|
return;
|
|
@@ -592,27 +656,32 @@ function Z(e, t, n, r) {
|
|
|
592
656
|
}
|
|
593
657
|
//#endregion
|
|
594
658
|
//#region src/transport/status-transport.ts
|
|
595
|
-
var
|
|
659
|
+
var ft = class {
|
|
596
660
|
config;
|
|
597
661
|
diagnostics;
|
|
598
662
|
onSampling;
|
|
599
663
|
onLoss;
|
|
600
664
|
throttledUntil = {
|
|
601
665
|
logs: 0,
|
|
602
|
-
metrics: 0
|
|
666
|
+
metrics: 0,
|
|
667
|
+
traces: 0
|
|
603
668
|
};
|
|
669
|
+
acceptedAt = null;
|
|
604
670
|
constructor(e, t, n = () => void 0, r = () => void 0) {
|
|
605
671
|
this.config = e, this.diagnostics = t, this.onSampling = n, this.onLoss = r;
|
|
606
672
|
}
|
|
607
673
|
throttledForMs(e) {
|
|
608
674
|
return Math.max(0, this.throttledUntil[Y(e, this.config)] - Date.now());
|
|
609
675
|
}
|
|
676
|
+
lastSendAt() {
|
|
677
|
+
return this.acceptedAt;
|
|
678
|
+
}
|
|
610
679
|
serialize(e) {
|
|
611
680
|
let t = Z(this.config, e, this.diagnostics, "The serializer threw an error. The library dropped the batch.");
|
|
612
681
|
return t || this.onLoss("unserializable", e.records, [e.id]), t;
|
|
613
682
|
}
|
|
614
683
|
accept(e, t) {
|
|
615
|
-
this.throttledUntil[e] = 0, this.config.sampling.remote && t != null && this.onSampling(t);
|
|
684
|
+
this.throttledUntil[e] = 0, this.acceptedAt = Date.now(), this.config.sampling.remote && t != null && this.onSampling(t);
|
|
616
685
|
}
|
|
617
686
|
reject(e, t, n, r) {
|
|
618
687
|
let i = String(e);
|
|
@@ -621,22 +690,22 @@ var Ye = class {
|
|
|
621
690
|
return this.diagnostics.report("transport.rejected_credentials", `The server returned ${i}.${t}`, {
|
|
622
691
|
status: e,
|
|
623
692
|
endpoint: X(n, this.config)
|
|
624
|
-
}), new
|
|
693
|
+
}), new z("permanent", `The server rejected the batch with ${i}.`, e);
|
|
625
694
|
}
|
|
626
|
-
if (e === 413) return new
|
|
695
|
+
if (e === 413) return new z("too_large", "The payload is too large.", e, void 0, r.maxBytes);
|
|
627
696
|
if (e === 429 || e === 503) {
|
|
628
|
-
let t = e === 429, i = r.retryAfterMs === void 0 ? void 0 : Math.min(r.retryAfterMs,
|
|
629
|
-
return this.throttledUntil[n] = Date.now() + (i ?? 2e3), t && this.diagnostics.report("transport.throttled", "The server throttles the requests.", { retryAfterMs: i }), new
|
|
697
|
+
let t = e === 429, i = r.retryAfterMs === void 0 ? void 0 : Math.min(r.retryAfterMs, b);
|
|
698
|
+
return this.throttledUntil[n] = Date.now() + (i ?? 2e3), t && this.diagnostics.report("transport.throttled", "The server throttles the requests.", { retryAfterMs: i }), new z("throttled", t ? "The server throttles the requests." : "The service is not available.", e, i);
|
|
630
699
|
}
|
|
631
|
-
return e === 408 || e >= 500 ? new
|
|
700
|
+
return e === 408 || e >= 500 ? new z("transient", `The server returned the error ${i}.`, e) : (this.diagnostics.report("transport.dropped_permanent", `The server rejected the batch with ${i}. The library dropped it.`, {
|
|
632
701
|
batchId: t,
|
|
633
702
|
status: e
|
|
634
|
-
}), new
|
|
703
|
+
}), new z("permanent", `The server rejected the batch with ${i}.`, e));
|
|
635
704
|
}
|
|
636
705
|
};
|
|
637
706
|
//#endregion
|
|
638
707
|
//#region src/transport/custom-transport.ts
|
|
639
|
-
function
|
|
708
|
+
function pt(e, t, n) {
|
|
640
709
|
return {
|
|
641
710
|
kind: n,
|
|
642
711
|
body: t.body,
|
|
@@ -646,36 +715,36 @@ function Xe(e, t, n) {
|
|
|
646
715
|
records: e.records
|
|
647
716
|
};
|
|
648
717
|
}
|
|
649
|
-
function
|
|
718
|
+
function mt(e) {
|
|
650
719
|
if (typeof e != "object" || !e) return !1;
|
|
651
720
|
let t = Reflect.get(e, "status");
|
|
652
721
|
return typeof t == "number" && Number.isInteger(t) && t >= 100 && t <= 599;
|
|
653
722
|
}
|
|
654
|
-
function
|
|
723
|
+
function ht(e) {
|
|
655
724
|
return typeof e == "number" && Number.isFinite(e) ? Math.max(0, e) : void 0;
|
|
656
725
|
}
|
|
657
|
-
var
|
|
726
|
+
var gt = class extends ft {
|
|
658
727
|
async send(e) {
|
|
659
728
|
let { transport: t } = this.config;
|
|
660
729
|
if (!t || e.records.length === 0) return;
|
|
661
730
|
let n = this.serialize(e);
|
|
662
731
|
if (!n) return;
|
|
663
|
-
let r = Y(e, this.config), i =
|
|
732
|
+
let r = Y(e, this.config), i = pt(e, n, r), a;
|
|
664
733
|
try {
|
|
665
|
-
a = await
|
|
734
|
+
a = await E(ye(() => k(() => _e(() => t(i)))), p);
|
|
666
735
|
} catch (e) {
|
|
667
|
-
let t = e instanceof
|
|
668
|
-
throw new
|
|
736
|
+
let t = e instanceof me ? e : void 0;
|
|
737
|
+
throw new z(t ? "timeout" : "transient", t?.message ?? "The custom transport failed.", void 0, void 0, void 0, e);
|
|
669
738
|
}
|
|
670
|
-
if (!
|
|
739
|
+
if (!mt(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 z("transient", "The custom transport returned no valid status.");
|
|
671
740
|
let { status: o } = a;
|
|
672
741
|
if (o >= 200 && o < 300) this.accept(r, a.sampling);
|
|
673
742
|
else throw this.reject(o, e.id, r, {
|
|
674
|
-
retryAfterMs:
|
|
675
|
-
maxBytes:
|
|
743
|
+
retryAfterMs: ht(a.retryAfterMs),
|
|
744
|
+
maxBytes: ht(a.maxBytes)
|
|
676
745
|
});
|
|
677
746
|
}
|
|
678
|
-
},
|
|
747
|
+
}, _t = class {
|
|
679
748
|
deps;
|
|
680
749
|
installed = !1;
|
|
681
750
|
keepaliveBytes = 0;
|
|
@@ -697,7 +766,7 @@ var $e = class extends Ye {
|
|
|
697
766
|
install() {
|
|
698
767
|
if (this.installed || typeof addEventListener > "u") return;
|
|
699
768
|
this.installed = !0, typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), document.addEventListener("freeze", this.onFreeze)), addEventListener("pagehide", this.onPageHide);
|
|
700
|
-
let e =
|
|
769
|
+
let e = A()?.me;
|
|
701
770
|
this.deps.diagnostics.guard("openfin.unavailable", "The library could not subscribe to close-requested.", () => {
|
|
702
771
|
e?.on?.("close-requested", this.onOpenFinClose);
|
|
703
772
|
});
|
|
@@ -705,7 +774,7 @@ var $e = class extends Ye {
|
|
|
705
774
|
uninstall() {
|
|
706
775
|
if (!this.installed) return;
|
|
707
776
|
this.installed = !1, typeof document < "u" && (document.removeEventListener("visibilitychange", this.onVisibility), document.removeEventListener("freeze", this.onFreeze)), removeEventListener("pagehide", this.onPageHide);
|
|
708
|
-
let e =
|
|
777
|
+
let e = A()?.me;
|
|
709
778
|
this.deps.diagnostics.guard("openfin.unavailable", "The library could not unsubscribe from close-requested.", () => {
|
|
710
779
|
e?.removeListener?.("close-requested", this.onOpenFinClose);
|
|
711
780
|
});
|
|
@@ -725,36 +794,36 @@ var $e = class extends Ye {
|
|
|
725
794
|
let r = this.endpointUrl();
|
|
726
795
|
if (r !== null) {
|
|
727
796
|
this.keepaliveBytes = 0;
|
|
728
|
-
for (let
|
|
729
|
-
let
|
|
730
|
-
this.flushBatch(
|
|
797
|
+
for (let i of this.deps.drainForExit()) {
|
|
798
|
+
let a = Y(i, t), o = a === "logs" ? r.href : X(a, t);
|
|
799
|
+
o ? this.flushBatch(i, e, new URL(o)) : n.count("record.dropped_no_destination");
|
|
731
800
|
}
|
|
732
801
|
}
|
|
733
802
|
}
|
|
734
|
-
flushBatch(
|
|
735
|
-
let { config: i
|
|
736
|
-
if (
|
|
737
|
-
let
|
|
738
|
-
if (!
|
|
739
|
-
if (
|
|
740
|
-
|
|
803
|
+
flushBatch(t, n, r) {
|
|
804
|
+
let { config: i } = this.deps;
|
|
805
|
+
if (t.records.length === 0) return;
|
|
806
|
+
let a = this.serialize(t, n);
|
|
807
|
+
if (!a) return;
|
|
808
|
+
if (O(a.body) > 6e4) {
|
|
809
|
+
this.park(t);
|
|
741
810
|
return;
|
|
742
811
|
}
|
|
743
|
-
|
|
744
|
-
let
|
|
745
|
-
if (
|
|
746
|
-
this.keepaliveFetch(
|
|
747
|
-
let
|
|
748
|
-
return
|
|
812
|
+
r.searchParams.set(ce, t.id), r.searchParams.set(c, n);
|
|
813
|
+
let o = r.toString(), s = this.deps.exitHeaders();
|
|
814
|
+
if (s) {
|
|
815
|
+
this.keepaliveFetch(o, t, a.body, n, () => {
|
|
816
|
+
let n = new Headers(s);
|
|
817
|
+
return n.set(e, a.contentType), n.set(re, t.id), n;
|
|
749
818
|
});
|
|
750
819
|
return;
|
|
751
820
|
}
|
|
752
821
|
if (i.headers) {
|
|
753
|
-
|
|
822
|
+
this.park(t);
|
|
754
823
|
return;
|
|
755
824
|
}
|
|
756
|
-
let l = this.beacon(
|
|
757
|
-
l !== "sent" && (l === "refused" ?
|
|
825
|
+
let l = this.beacon(o, a.body);
|
|
826
|
+
l !== "sent" && (l === "refused" ? this.park(t) : this.keepaliveFetch(o, t, a.body, n, () => new Headers({ [e]: u })));
|
|
758
827
|
}
|
|
759
828
|
flushAlive() {
|
|
760
829
|
let { diagnostics: e } = this.deps, t = "The flush of the hidden document failed.";
|
|
@@ -769,10 +838,14 @@ var $e = class extends Ye {
|
|
|
769
838
|
for (let i of this.deps.drainForExit()) {
|
|
770
839
|
let a = this.serialize(i, e);
|
|
771
840
|
if (!a) continue;
|
|
772
|
-
let o =
|
|
773
|
-
(t === void 0 || r.guard("transport.http_error", "The transportOnExit hook threw an error.", () =>
|
|
841
|
+
let o = pt(i, a, Y(i, n));
|
|
842
|
+
(t === void 0 || r.guard("transport.http_error", "The transportOnExit hook threw an error.", () => k(() => t(o))) !== !0) && this.park(i);
|
|
774
843
|
}
|
|
775
844
|
}
|
|
845
|
+
park(e) {
|
|
846
|
+
let { config: t, diagnostics: n, onLoss: r } = this.deps;
|
|
847
|
+
t.storage === "memory" || t.storage === "none" ? r?.("not_stored", e.records, [e.id]) : je(e, n, r);
|
|
848
|
+
}
|
|
776
849
|
serialize(e, t) {
|
|
777
850
|
let n = Z(this.deps.config, e, this.deps.diagnostics, `The ${t} exit flush could not serialize its batch.`);
|
|
778
851
|
return n || this.deps.onLoss?.("unserializable", e.records, [e.id]), n;
|
|
@@ -789,8 +862,8 @@ var $e = class extends Ye {
|
|
|
789
862
|
}
|
|
790
863
|
keepaliveFetch(e, t, n, r, i) {
|
|
791
864
|
let { config: a, diagnostics: o } = this.deps, s = () => {
|
|
792
|
-
|
|
793
|
-
}, c =
|
|
865
|
+
this.park(t);
|
|
866
|
+
}, c = O(n);
|
|
794
867
|
this.keepaliveBytes + c > 6e4 ? s() : (this.keepaliveBytes += c, o.guard("transport.http_error", "The keepalive fetch failed.", () => (fetch(e, {
|
|
795
868
|
method: "POST",
|
|
796
869
|
body: n,
|
|
@@ -804,75 +877,75 @@ var $e = class extends Ye {
|
|
|
804
877
|
};
|
|
805
878
|
//#endregion
|
|
806
879
|
//#region src/transport/compression.ts
|
|
807
|
-
async function
|
|
880
|
+
async function vt(e) {
|
|
808
881
|
let t = globalThis.CompressionStream;
|
|
809
882
|
if (t === void 0) return null;
|
|
810
|
-
let n = new Blob([e]).stream().pipeThrough(new t(
|
|
883
|
+
let n = new Blob([e]).stream().pipeThrough(new t(g)), r = await new Response(n).arrayBuffer();
|
|
811
884
|
return new Uint8Array(r);
|
|
812
885
|
}
|
|
813
886
|
//#endregion
|
|
814
887
|
//#region src/transport/http-transport.ts
|
|
815
|
-
var
|
|
888
|
+
var yt = "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.", bt = class extends ft {
|
|
816
889
|
cachedHeaders;
|
|
817
890
|
async send(e, t) {
|
|
818
891
|
let { config: n } = this, r = Y(e, n), i = X(r, n);
|
|
819
|
-
i
|
|
892
|
+
i ? e.records.length !== 0 && await this.post(e, r, i, t) : this.diagnostics.count("record.dropped_no_destination");
|
|
820
893
|
}
|
|
821
894
|
lastHeaders() {
|
|
822
895
|
let { headers: e } = this.config;
|
|
823
896
|
if (!e) return;
|
|
824
897
|
if (typeof e != "function") return e;
|
|
825
898
|
let t = this.cachedHeaders;
|
|
826
|
-
return t?.source === e && t.endpoint === this.config.endpoint && t.metricsEndpoint === this.config.metricsEndpoint ? t.headers : void 0;
|
|
827
|
-
}
|
|
828
|
-
async post(t, n, r
|
|
829
|
-
let
|
|
830
|
-
if (!
|
|
831
|
-
let
|
|
832
|
-
if (this.rejectsCredentials(
|
|
833
|
-
this.accept(
|
|
899
|
+
return t?.source === e && t.endpoint === this.config.endpoint && t.metricsEndpoint === this.config.metricsEndpoint && t.tracesEndpoint === this.config.tracesEndpoint ? t.headers : void 0;
|
|
900
|
+
}
|
|
901
|
+
async post(e, t, n, r) {
|
|
902
|
+
let i = this.serialize(e);
|
|
903
|
+
if (!i) return;
|
|
904
|
+
let a = await this.attempt(e, n, i, r);
|
|
905
|
+
if (this.rejectsCredentials(a.status) && typeof this.config.headers == "function" && (this.cachedHeaders = void 0, a = await this.attempt(e, n, i, r)), a.ok) {
|
|
906
|
+
this.accept(t, a.headers.get(ue));
|
|
834
907
|
return;
|
|
835
908
|
}
|
|
836
|
-
let
|
|
837
|
-
throw this.reject(
|
|
838
|
-
retryAfterMs:
|
|
839
|
-
maxBytes:
|
|
840
|
-
advice:
|
|
909
|
+
let o = a.status, s = Be(a.headers.get(ae)), c = o === 413 ? await this.readMaxBytes(a) : void 0;
|
|
910
|
+
throw this.reject(o, e.id, t, {
|
|
911
|
+
retryAfterMs: s,
|
|
912
|
+
maxBytes: c,
|
|
913
|
+
advice: yt
|
|
841
914
|
});
|
|
842
915
|
}
|
|
843
916
|
rejectsCredentials(e) {
|
|
844
917
|
return e === 401 || e === 403;
|
|
845
918
|
}
|
|
846
|
-
async attempt(
|
|
847
|
-
let
|
|
848
|
-
|
|
849
|
-
let
|
|
850
|
-
typeof
|
|
851
|
-
let
|
|
852
|
-
return
|
|
919
|
+
async attempt(t, n, r, i) {
|
|
920
|
+
let a = Date.now() + p, o = new Headers(await this.before(this.resolveHeaders(), a, n));
|
|
921
|
+
o.set(e, r.contentType), o.set(re, t.id), o.set(ne, String(t.attempts));
|
|
922
|
+
let s = await this.before(this.encodeBody(r.body), a, n);
|
|
923
|
+
typeof s != "string" && o.set(d, g);
|
|
924
|
+
let c = this.keepalive(s);
|
|
925
|
+
return c && i?.(), this.dispatch(n, o, s, a, c);
|
|
853
926
|
}
|
|
854
927
|
async before(e, t, n) {
|
|
855
928
|
try {
|
|
856
|
-
return await
|
|
929
|
+
return await E(e, Math.max(0, t - Date.now()));
|
|
857
930
|
} catch {
|
|
858
931
|
throw this.timeout(n);
|
|
859
932
|
}
|
|
860
933
|
}
|
|
861
934
|
timeout(e) {
|
|
862
935
|
let t = `The request took longer than ${String(p)} ms.`;
|
|
863
|
-
return this.diagnostics.report("transport.timeout", t, { endpoint: e }), new
|
|
936
|
+
return this.diagnostics.report("transport.timeout", t, { endpoint: e }), new z("timeout", t);
|
|
864
937
|
}
|
|
865
938
|
async encodeBody(e) {
|
|
866
939
|
let { config: t } = this;
|
|
867
|
-
return t.compression !== "gzip" ||
|
|
940
|
+
return t.compression !== "gzip" || O(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "The library could not compress the payload.", () => vt(e)) ?? e;
|
|
868
941
|
}
|
|
869
942
|
async dispatch(e, t, n, r, i) {
|
|
870
943
|
let { config: a } = this, o = new AbortController(), s = setTimeout(() => {
|
|
871
944
|
o.abort();
|
|
872
945
|
}, Math.max(0, r - Date.now()));
|
|
873
|
-
|
|
946
|
+
D(s);
|
|
874
947
|
try {
|
|
875
|
-
return await
|
|
948
|
+
return await k(() => fetch(e, {
|
|
876
949
|
method: "POST",
|
|
877
950
|
headers: t,
|
|
878
951
|
body: n,
|
|
@@ -882,15 +955,13 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
882
955
|
keepalive: i
|
|
883
956
|
}));
|
|
884
957
|
} catch {
|
|
885
|
-
|
|
886
|
-
let t = globalThis.navigator?.onLine;
|
|
887
|
-
throw new B(t === !1 ? "offline" : "transient", "A network error occurred.");
|
|
958
|
+
throw o.signal.aborted ? this.timeout(e) : new z(j() ? "transient" : "offline", "A network error occurred.");
|
|
888
959
|
} finally {
|
|
889
960
|
clearTimeout(s);
|
|
890
961
|
}
|
|
891
962
|
}
|
|
892
963
|
keepalive(e) {
|
|
893
|
-
let t = globalThis.document?.visibilityState === "hidden", n = typeof e == "string" ?
|
|
964
|
+
let t = globalThis.document?.visibilityState === "hidden", n = typeof e == "string" ? O(e) : e.byteLength;
|
|
894
965
|
return t && n <= 6e4;
|
|
895
966
|
}
|
|
896
967
|
async readMaxBytes(e) {
|
|
@@ -903,15 +974,16 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
903
974
|
let { headers: e } = this.config;
|
|
904
975
|
if (!e) return {};
|
|
905
976
|
if (typeof e != "function") return e;
|
|
906
|
-
let { endpoint: t, metricsEndpoint: n } = this.config,
|
|
907
|
-
return
|
|
977
|
+
let { endpoint: t, metricsEndpoint: n, tracesEndpoint: r } = this.config, i = await this.diagnostics.guardAsync("transport.http_error", "The headers() function threw an error.", () => Promise.resolve(e()));
|
|
978
|
+
return i && (this.cachedHeaders = {
|
|
908
979
|
source: e,
|
|
909
980
|
endpoint: t,
|
|
910
981
|
metricsEndpoint: n,
|
|
911
|
-
|
|
912
|
-
|
|
982
|
+
tracesEndpoint: r,
|
|
983
|
+
headers: i
|
|
984
|
+
}), i ?? {};
|
|
913
985
|
}
|
|
914
|
-
},
|
|
986
|
+
}, xt = class {
|
|
915
987
|
storage;
|
|
916
988
|
transport;
|
|
917
989
|
diagnostics;
|
|
@@ -927,13 +999,13 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
927
999
|
this.attempt = 0, this.schedule(0);
|
|
928
1000
|
};
|
|
929
1001
|
constructor(e, t, n, r, i = 20, a = () => void 0) {
|
|
930
|
-
this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i, this.onLoss = a, this.maxAttempts =
|
|
1002
|
+
this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i, this.onLoss = a, this.maxAttempts = Ee(r.retention).maxAttempts;
|
|
931
1003
|
}
|
|
932
1004
|
start() {
|
|
933
|
-
this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(
|
|
1005
|
+
this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(t);
|
|
934
1006
|
}
|
|
935
1007
|
nudge() {
|
|
936
|
-
this.draining || this.schedule(
|
|
1008
|
+
this.draining || this.schedule(f);
|
|
937
1009
|
}
|
|
938
1010
|
async storeFailed(e, t) {
|
|
939
1011
|
let n = this.toStorable(e, t);
|
|
@@ -949,23 +1021,23 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
949
1021
|
let t = setTimeout(() => {
|
|
950
1022
|
this.drain();
|
|
951
1023
|
}, e);
|
|
952
|
-
this.timer = t,
|
|
1024
|
+
this.timer = t, D(t);
|
|
953
1025
|
}
|
|
954
1026
|
bounded(e) {
|
|
955
|
-
return
|
|
1027
|
+
return E(e, y);
|
|
956
1028
|
}
|
|
957
1029
|
clearTimer() {
|
|
958
1030
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
959
1031
|
}
|
|
960
1032
|
backoffMs() {
|
|
961
|
-
let e = Math.min(
|
|
1033
|
+
let e = Math.min(f * 2 ** this.attempt, b);
|
|
962
1034
|
return Math.random() * e;
|
|
963
1035
|
}
|
|
964
1036
|
async drain() {
|
|
965
1037
|
if (!this.draining) {
|
|
966
1038
|
this.draining = !0;
|
|
967
1039
|
try {
|
|
968
|
-
await
|
|
1040
|
+
await De("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(t);
|
|
969
1041
|
} finally {
|
|
970
1042
|
this.draining = !1;
|
|
971
1043
|
}
|
|
@@ -973,19 +1045,19 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
973
1045
|
}
|
|
974
1046
|
async drainLocked() {
|
|
975
1047
|
try {
|
|
976
|
-
if (
|
|
1048
|
+
if (!j()) return this.schedule(t), !0;
|
|
977
1049
|
let e = await this.bounded(this.storage.take(this.batchesPerDrain));
|
|
978
|
-
if (e.length === 0) return this.schedule(
|
|
979
|
-
let
|
|
980
|
-
for (let
|
|
1050
|
+
if (e.length === 0) return this.schedule(t), !0;
|
|
1051
|
+
let n = /* @__PURE__ */ new Set(), r = 0;
|
|
1052
|
+
for (let t of e) {
|
|
981
1053
|
if (this.stopped) return !0;
|
|
982
|
-
let e = Y(
|
|
983
|
-
if (
|
|
984
|
-
let i = await this.deliver(
|
|
1054
|
+
let e = Y(t, this.config);
|
|
1055
|
+
if (n.has(e)) continue;
|
|
1056
|
+
let i = await this.deliver(t);
|
|
985
1057
|
if (i === "stop") return !0;
|
|
986
|
-
i !== "next" && (
|
|
1058
|
+
i !== "next" && (n.add(e), r = Math.max(r, i));
|
|
987
1059
|
}
|
|
988
|
-
return
|
|
1060
|
+
return n.size > 0 ? this.schedule(r) : this.schedule(e.length === this.batchesPerDrain ? 0 : t), !0;
|
|
989
1061
|
} catch (e) {
|
|
990
1062
|
return this.diagnostics.report("storage.degraded", "The drain loop threw an error.", void 0, e), this.attempt++, this.schedule(this.backoffMs()), !0;
|
|
991
1063
|
}
|
|
@@ -997,9 +1069,9 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
997
1069
|
}), this.onLoss("max_attempts", e.records, [e.id]), await this.bounded(this.storage.remove(e.id)), "next";
|
|
998
1070
|
try {
|
|
999
1071
|
return await this.transport.send(e), await this.bounded(this.storage.remove(e.id)), this.attempt = 0, "next";
|
|
1000
|
-
} catch (
|
|
1001
|
-
let
|
|
1002
|
-
return
|
|
1072
|
+
} catch (n) {
|
|
1073
|
+
let r = n instanceof z ? n : void 0;
|
|
1074
|
+
return r?.kind === "permanent" || r?.kind === "too_large" ? (await this.replaceStored(e, n), "next") : r?.kind === "offline" ? (this.schedule(t), "stop") : r?.kind === "throttled" ? (this.attempt++, r.retryAfterMs ?? this.backoffMs()) : (await this.bounded(this.storage.bumpAttempts(e.id, e.attempts + 1)), this.attempt++, r?.retryAfterMs ?? this.backoffMs());
|
|
1003
1075
|
}
|
|
1004
1076
|
}
|
|
1005
1077
|
async replaceStored(e, t) {
|
|
@@ -1008,10 +1080,10 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
1008
1080
|
for (let e of n) await this.bounded(this.storage.save(e));
|
|
1009
1081
|
}
|
|
1010
1082
|
toStorable(e, t) {
|
|
1011
|
-
let n = t instanceof
|
|
1083
|
+
let n = t instanceof z ? t : void 0;
|
|
1012
1084
|
if (n?.kind === "permanent") return this.onLoss("rejected", e.records, [e.id]), [];
|
|
1013
1085
|
if (n?.kind !== "too_large") return [e];
|
|
1014
|
-
let r =
|
|
1086
|
+
let r = be(e, this.diagnostics);
|
|
1015
1087
|
return r ? (this.diagnostics.report("transport.batch_split", "The server refused the batch because it is too large.", {
|
|
1016
1088
|
from: e.records.length,
|
|
1017
1089
|
to: r[0].records.length,
|
|
@@ -1021,11 +1093,14 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
1021
1093
|
bodies: e.records.map((e) => e.body)
|
|
1022
1094
|
}), this.onLoss("rejected", e.records, [e.id]), []);
|
|
1023
1095
|
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1096
|
+
}, Q = [
|
|
1097
|
+
"metrics",
|
|
1098
|
+
"logs",
|
|
1099
|
+
"traces"
|
|
1100
|
+
];
|
|
1101
|
+
function St(e) {
|
|
1102
|
+
let t = e.attributes[ie];
|
|
1103
|
+
return t === "metric" ? "metrics" : t === "span" ? "traces" : "logs";
|
|
1029
1104
|
}
|
|
1030
1105
|
var $ = class {
|
|
1031
1106
|
options;
|
|
@@ -1043,6 +1118,9 @@ var $ = class {
|
|
|
1043
1118
|
let e = this.pending;
|
|
1044
1119
|
return this.pending = [], e;
|
|
1045
1120
|
}
|
|
1121
|
+
get size() {
|
|
1122
|
+
return this.pending.length;
|
|
1123
|
+
}
|
|
1046
1124
|
stop() {
|
|
1047
1125
|
this.clearTimer();
|
|
1048
1126
|
}
|
|
@@ -1051,12 +1129,12 @@ var $ = class {
|
|
|
1051
1129
|
let e = setTimeout(() => {
|
|
1052
1130
|
this.timer = null, this.onFlush(this);
|
|
1053
1131
|
}, this.options.flushIntervalMs);
|
|
1054
|
-
this.timer = e,
|
|
1132
|
+
this.timer = e, D(e);
|
|
1055
1133
|
}
|
|
1056
1134
|
clearTimer() {
|
|
1057
1135
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
1058
1136
|
}
|
|
1059
|
-
},
|
|
1137
|
+
}, Ct = class {
|
|
1060
1138
|
transport;
|
|
1061
1139
|
storage;
|
|
1062
1140
|
retry;
|
|
@@ -1065,7 +1143,7 @@ var $ = class {
|
|
|
1065
1143
|
unconfirmed = /* @__PURE__ */ new Map();
|
|
1066
1144
|
queue = [];
|
|
1067
1145
|
open = /* @__PURE__ */ new Set();
|
|
1068
|
-
ceiling = new
|
|
1146
|
+
ceiling = new he();
|
|
1069
1147
|
inFlight = 0;
|
|
1070
1148
|
pumpScheduled = !1;
|
|
1071
1149
|
stopped = !1;
|
|
@@ -1076,29 +1154,42 @@ var $ = class {
|
|
|
1076
1154
|
};
|
|
1077
1155
|
this.streams = {
|
|
1078
1156
|
logs: new $(i.logs, a),
|
|
1079
|
-
metrics: new $(i.metrics, a)
|
|
1157
|
+
metrics: new $(i.metrics, a),
|
|
1158
|
+
traces: new $(i.traces, a)
|
|
1080
1159
|
};
|
|
1081
1160
|
}
|
|
1082
1161
|
push(e) {
|
|
1083
|
-
this.stopped || (e.observedTimeUnixNano =
|
|
1162
|
+
this.stopped || (e.observedTimeUnixNano = ge(), this.route(e));
|
|
1084
1163
|
}
|
|
1085
1164
|
drainForExit() {
|
|
1086
1165
|
let e = [...this.unconfirmed.values()].flatMap((e) => e.records);
|
|
1087
|
-
this.unconfirmed.clear();
|
|
1088
|
-
let t = [...e.filter(Q), ...this.streams.metrics.take()], n = [...e.filter((e) => !Q(e)), ...this.streams.logs.take()];
|
|
1089
|
-
return [this.toBatch(t), this.toBatch(n)].filter((e) => e !== null);
|
|
1166
|
+
return this.unconfirmed.clear(), Q.map((t) => this.toBatch([...e.filter((e) => St(e) === t), ...this.streams[t].take()])).filter((e) => e !== null);
|
|
1090
1167
|
}
|
|
1091
1168
|
async flushPending() {
|
|
1092
|
-
this.stopped
|
|
1169
|
+
if (!this.stopped) for (let e of Q) this.claim(this.streams[e]);
|
|
1170
|
+
await Promise.all([...this.open].map((e) => e.done));
|
|
1171
|
+
}
|
|
1172
|
+
counts() {
|
|
1173
|
+
let e = (e) => {
|
|
1174
|
+
let t = 0;
|
|
1175
|
+
for (let n of e) t += n.batch.records.length;
|
|
1176
|
+
return t;
|
|
1177
|
+
}, t = e(this.queue);
|
|
1178
|
+
return {
|
|
1179
|
+
pending: Q.reduce((e, t) => e + this.streams[t].size, 0) + t,
|
|
1180
|
+
inFlight: e(this.open) - t
|
|
1181
|
+
};
|
|
1093
1182
|
}
|
|
1094
1183
|
destroy() {
|
|
1095
|
-
this.stopped = !0
|
|
1184
|
+
this.stopped = !0;
|
|
1185
|
+
for (let e of Q) this.streams[e].stop();
|
|
1186
|
+
this.queue.length = 0;
|
|
1096
1187
|
for (let e of this.open) e.resolve();
|
|
1097
1188
|
this.open.clear();
|
|
1098
1189
|
}
|
|
1099
1190
|
toBatch(e) {
|
|
1100
1191
|
return e.length === 0 ? null : {
|
|
1101
|
-
id:
|
|
1192
|
+
id: ve(this.diagnostics),
|
|
1102
1193
|
records: e,
|
|
1103
1194
|
createdAt: Date.now(),
|
|
1104
1195
|
attempts: 0
|
|
@@ -1106,7 +1197,7 @@ var $ = class {
|
|
|
1106
1197
|
}
|
|
1107
1198
|
route(e) {
|
|
1108
1199
|
try {
|
|
1109
|
-
let t =
|
|
1200
|
+
let t = this.streams[St(e)];
|
|
1110
1201
|
if (!this.ceiling.allow(e)) {
|
|
1111
1202
|
this.diagnostics.count("record.dropped_by_ceiling");
|
|
1112
1203
|
return;
|
|
@@ -1184,23 +1275,24 @@ var $ = class {
|
|
|
1184
1275
|
}
|
|
1185
1276
|
async store(e) {
|
|
1186
1277
|
await this.diagnostics.guardAsync("storage.degraded", "The library could not store an undelivered batch.", async () => {
|
|
1187
|
-
await
|
|
1278
|
+
await E(this.storage.save(e), y), this.retry.nudge();
|
|
1188
1279
|
});
|
|
1189
1280
|
}
|
|
1190
|
-
},
|
|
1281
|
+
}, wt = class e {
|
|
1191
1282
|
storage;
|
|
1192
1283
|
retry;
|
|
1193
1284
|
pipeline;
|
|
1194
1285
|
exitFlush;
|
|
1195
1286
|
diagnostics;
|
|
1196
|
-
|
|
1197
|
-
|
|
1287
|
+
transport;
|
|
1288
|
+
constructor(e, t, n, r, i, a) {
|
|
1289
|
+
this.storage = e, this.retry = t, this.pipeline = n, this.exitFlush = r, this.diagnostics = i, this.transport = a;
|
|
1198
1290
|
}
|
|
1199
1291
|
static async create(t) {
|
|
1200
|
-
let { config: n, diagnostics: r } = t, i = await
|
|
1201
|
-
let i =
|
|
1202
|
-
i &&
|
|
1203
|
-
}, { onLoss: o } = t, s = n.transport ? void 0 : new
|
|
1292
|
+
let { config: n, diagnostics: r } = t, i = await ze(n.storage, de, Ee(n.retention), r, t.onGap), a = (e) => {
|
|
1293
|
+
let i = we(e, r);
|
|
1294
|
+
i && Te(t.remote, n, i);
|
|
1295
|
+
}, { onLoss: o } = t, s = n.transport ? void 0 : new bt(n, r, a, o), c = s ?? new gt(n, r, a, o), l = new xt(i, c, r, n, 20, o), { batching: u } = n, d = new Ct(c, i, l, r, {
|
|
1204
1296
|
logs: {
|
|
1205
1297
|
flushIntervalMs: u.logFlushIntervalMs,
|
|
1206
1298
|
batchSize: u.logBatchSize
|
|
@@ -1208,8 +1300,12 @@ var $ = class {
|
|
|
1208
1300
|
metrics: {
|
|
1209
1301
|
flushIntervalMs: u.metricFlushIntervalMs,
|
|
1210
1302
|
batchSize: u.metricBatchSize
|
|
1303
|
+
},
|
|
1304
|
+
traces: {
|
|
1305
|
+
flushIntervalMs: u.logFlushIntervalMs,
|
|
1306
|
+
batchSize: u.logBatchSize
|
|
1211
1307
|
}
|
|
1212
|
-
}), f = new
|
|
1308
|
+
}), f = new _t({
|
|
1213
1309
|
config: n,
|
|
1214
1310
|
diagnostics: r,
|
|
1215
1311
|
drainForExit: () => d.drainForExit(),
|
|
@@ -1223,7 +1319,7 @@ var $ = class {
|
|
|
1223
1319
|
} finally {
|
|
1224
1320
|
p || (f.uninstall(), l.stop());
|
|
1225
1321
|
}
|
|
1226
|
-
let m = new e(i, l, d, f, r);
|
|
1322
|
+
let m = new e(i, l, d, f, r, c);
|
|
1227
1323
|
return m.importEmergency(), m;
|
|
1228
1324
|
}
|
|
1229
1325
|
push(e) {
|
|
@@ -1235,15 +1331,21 @@ var $ = class {
|
|
|
1235
1331
|
async queueDepth() {
|
|
1236
1332
|
return await this.diagnostics.guardAsync("storage.degraded", "The library could not count the batches in storage.", () => this.storage.count()) ?? 0;
|
|
1237
1333
|
}
|
|
1334
|
+
stats() {
|
|
1335
|
+
return {
|
|
1336
|
+
...this.pipeline.counts(),
|
|
1337
|
+
lastSendAt: this.transport.lastSendAt()
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1238
1340
|
async destroy() {
|
|
1239
1341
|
await this.diagnostics.guardAsync("pipeline.crashed", "The flush before shutdown failed.", () => this.flush()), this.exitFlush.flush("shutdown"), this.exitFlush.uninstall(), this.retry.stop(), this.pipeline.destroy(), await this.storage.close();
|
|
1240
1342
|
}
|
|
1241
1343
|
async importEmergency() {
|
|
1242
|
-
let e = await this.diagnostics.guardAsync("storage.degraded", "The emergency import failed.", () =>
|
|
1344
|
+
let e = await this.diagnostics.guardAsync("storage.degraded", "The emergency import failed.", () => Me(this.storage, this.diagnostics));
|
|
1243
1345
|
e !== void 0 && e > 0 && this.retry.nudge();
|
|
1244
1346
|
}
|
|
1245
1347
|
};
|
|
1246
1348
|
//#endregion
|
|
1247
|
-
export {
|
|
1349
|
+
export { wt as Sender, P as i, L as n, Ne as r, I as t };
|
|
1248
1350
|
|
|
1249
|
-
//# sourceMappingURL=sender
|
|
1351
|
+
//# sourceMappingURL=sender-DFQMF39P.js.map
|