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