@utk09/ui-observability 0.9.1 → 0.9.3
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 +33 -0
- package/README.md +75 -64
- package/dist/batch-D5qvsMQ_.cjs +2 -0
- package/dist/batch-D5qvsMQ_.cjs.map +1 -0
- package/dist/{batch-DEK4bv9N.js → batch-DDgxg16_.js} +7 -4
- package/dist/batch-DDgxg16_.js.map +1 -0
- package/dist/bus/bus.d.ts +0 -4
- package/dist/{bus-HVQ8E72V.js → bus-C6RwKzPW.js} +63 -66
- package/dist/bus-C6RwKzPW.js.map +1 -0
- package/dist/bus-WPVDFw2y.cjs +2 -0
- package/dist/bus-WPVDFw2y.cjs.map +1 -0
- package/dist/capture/network.d.ts +2 -0
- package/dist/capture/storm.d.ts +2 -7
- package/dist/capture/types.d.ts +3 -0
- package/dist/{console-DssDxq1B.cjs → console-BSusX_M-.cjs} +2 -2
- package/dist/{console-DssDxq1B.cjs.map → console-BSusX_M-.cjs.map} +1 -1
- package/dist/{console-C9Y639mn.js → console-Dv5GfaNn.js} +3 -3
- package/dist/{console-C9Y639mn.js.map → console-Dv5GfaNn.js.map} +1 -1
- package/dist/constants-Cb92egPS.cjs +2 -0
- package/dist/constants-Cb92egPS.cjs.map +1 -0
- package/dist/{constants-N99w84xy.js → constants-DhH6VI5a.js} +39 -12
- package/dist/constants-DhH6VI5a.js.map +1 -0
- package/dist/constants.d.ts +28 -3
- package/dist/core/breadcrumbs.d.ts +1 -3
- package/dist/core/context.d.ts +0 -8
- package/dist/core/diagnostics.d.ts +1 -3
- package/dist/core/meter.d.ts +45 -0
- package/dist/core/pipeline.d.ts +5 -12
- package/dist/core/record.d.ts +7 -0
- package/dist/core/runtime.d.ts +17 -0
- package/dist/core/sampling.d.ts +3 -3
- package/dist/core/sender.d.ts +2 -0
- package/dist/deadline-CUrH0Hd8.cjs +2 -0
- package/dist/deadline-CUrH0Hd8.cjs.map +1 -0
- package/dist/deadline-DeqXEliN.js +31 -0
- package/dist/deadline-DeqXEliN.js.map +1 -0
- package/dist/{errors-CQusIGWJ.js → errors-DCZWcHkd.js} +4 -4
- package/dist/{errors-CQusIGWJ.js.map → errors-DCZWcHkd.js.map} +1 -1
- package/dist/{errors-BTWuVnHZ.cjs → errors-ERu-su8m.cjs} +3 -3
- package/dist/{errors-BTWuVnHZ.cjs.map → errors-ERu-su8m.cjs.map} +1 -1
- 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-B1GDS1Tb.cjs → identity-C1WLItSl.cjs} +2 -2
- package/dist/{identity-B1GDS1Tb.cjs.map → identity-C1WLItSl.cjs.map} +1 -1
- package/dist/{identity-D4DPjTM9.js → identity-Di-QXGCC.js} +2 -2
- package/dist/{identity-D4DPjTM9.js.map → identity-Di-QXGCC.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +522 -369
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-DX18p39D.cjs +2 -0
- package/dist/indexeddb-storage-DX18p39D.cjs.map +1 -0
- package/dist/{indexeddb-storage-B8SGUzSV.js → indexeddb-storage-T9YIYVYC.js} +48 -59
- package/dist/indexeddb-storage-T9YIYVYC.js.map +1 -0
- package/dist/{interactions-CnjfQgw3.js → interactions-BLH_tX87.js} +2 -2
- package/dist/{interactions-CnjfQgw3.js.map → interactions-BLH_tX87.js.map} +1 -1
- package/dist/{interactions-CcxrVzpg.cjs → interactions-_hfOerfC.cjs} +2 -2
- package/dist/{interactions-CcxrVzpg.cjs.map → interactions-_hfOerfC.cjs.map} +1 -1
- package/dist/journey-BRUj0hqD.cjs +2 -0
- package/dist/journey-BRUj0hqD.cjs.map +1 -0
- package/dist/{journey-DjvDzHyp.js → journey-yALMEWF7.js} +39 -38
- package/dist/journey-yALMEWF7.js.map +1 -0
- package/dist/library-request-BcAxuwsf.cjs +2 -0
- package/dist/library-request-BcAxuwsf.cjs.map +1 -0
- package/dist/library-request-CQD4HUiP.js +25 -0
- package/dist/library-request-CQD4HUiP.js.map +1 -0
- package/dist/{long-frames-BGik_Yhy.cjs → long-frames-D4Bm3Zkz.cjs} +2 -2
- package/dist/{long-frames-BGik_Yhy.cjs.map → long-frames-D4Bm3Zkz.cjs.map} +1 -1
- package/dist/{long-frames-CZk3XOkH.js → long-frames-DD_Um9_4.js} +3 -3
- package/dist/{long-frames-CZk3XOkH.js.map → long-frames-DD_Um9_4.js.map} +1 -1
- package/dist/models/batch.d.ts +6 -0
- package/dist/models/config.d.ts +23 -0
- package/dist/models/metric.d.ts +50 -0
- package/dist/network--GoE7_Or.js +211 -0
- package/dist/network--GoE7_Or.js.map +1 -0
- package/dist/network-DcuS2H1P.cjs +2 -0
- package/dist/network-DcuS2H1P.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-GaM6h7XM.js +52 -0
- package/dist/platform-GaM6h7XM.js.map +1 -0
- package/dist/platform-kIL5AZB7.cjs +2 -0
- package/dist/platform-kIL5AZB7.cjs.map +1 -0
- package/dist/{remote-rules-M-XZ1xbe.js → remote-rules-6ePq8CrI.js} +23 -25
- package/dist/remote-rules-6ePq8CrI.js.map +1 -0
- package/dist/remote-rules-CI3gbRCL.cjs +2 -0
- package/dist/remote-rules-CI3gbRCL.cjs.map +1 -0
- package/dist/sampling-C-M8p3FK.cjs +2 -0
- package/dist/sampling-C-M8p3FK.cjs.map +1 -0
- package/dist/sampling-Ud_WiuU9.js +65 -0
- package/dist/sampling-Ud_WiuU9.js.map +1 -0
- package/dist/{sanitize-DKp5MRsa.cjs → sanitize--_e4oOPX.cjs} +2 -2
- package/dist/{sanitize-DKp5MRsa.cjs.map → sanitize--_e4oOPX.cjs.map} +1 -1
- package/dist/{sanitize-Dwj9JCkI.js → sanitize-DP0xDPrt.js} +2 -2
- package/dist/{sanitize-Dwj9JCkI.js.map → sanitize-DP0xDPrt.js.map} +1 -1
- package/dist/sender-BESHz6my.cjs +3 -0
- package/dist/sender-BESHz6my.cjs.map +1 -0
- package/dist/{sender-BBY0IcUo.js → sender-BUBWLn5i.js} +425 -290
- package/dist/sender-BUBWLn5i.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-DhHGHhOc.cjs +2 -0
- package/dist/storm-DhHGHhOc.cjs.map +1 -0
- package/dist/storm-OD5J6Ylm.js +10 -0
- package/dist/storm-OD5J6Ylm.js.map +1 -0
- package/dist/transport/custom-transport.d.ts +3 -2
- package/dist/transport/exit-flush.d.ts +13 -2
- package/dist/transport/http-transport.d.ts +6 -4
- package/dist/transport/retry-engine.d.ts +3 -1
- package/dist/transport/serializers/otlp-metrics.d.ts +3 -0
- package/dist/transport/serializers/otlp.d.ts +30 -0
- package/dist/transport/serializers/select.d.ts +20 -4
- package/dist/transport/status-transport.d.ts +19 -11
- package/dist/utils/fixed-window.d.ts +15 -0
- package/dist/utils/guards.d.ts +6 -0
- package/dist/utils/library-request.d.ts +12 -0
- package/dist/utils/openfin.d.ts +48 -0
- package/dist/utils/platform.d.ts +5 -0
- package/package.json +2 -3
- package/dist/batch-DEK4bv9N.js.map +0 -1
- package/dist/batch-DEVFs28i.cjs +0 -2
- package/dist/batch-DEVFs28i.cjs.map +0 -1
- package/dist/bus-DNFvTkif.cjs +0 -2
- package/dist/bus-DNFvTkif.cjs.map +0 -1
- package/dist/bus-HVQ8E72V.js.map +0 -1
- package/dist/constants-N99w84xy.js.map +0 -1
- package/dist/constants-X86IDwkC.cjs +0 -2
- package/dist/constants-X86IDwkC.cjs.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/indexeddb-storage-B8SGUzSV.js.map +0 -1
- package/dist/indexeddb-storage-ukzC82dm.cjs +0 -2
- package/dist/indexeddb-storage-ukzC82dm.cjs.map +0 -1
- package/dist/journey-DjvDzHyp.js.map +0 -1
- package/dist/journey-DxlfdFJV.cjs +0 -2
- package/dist/journey-DxlfdFJV.cjs.map +0 -1
- package/dist/library-request-BZ1ekVtl.cjs +0 -2
- package/dist/library-request-BZ1ekVtl.cjs.map +0 -1
- package/dist/library-request-C8kc5YWv.js +0 -14
- package/dist/library-request-C8kc5YWv.js.map +0 -1
- package/dist/network-51iicpLl.js +0 -174
- package/dist/network-51iicpLl.js.map +0 -1
- package/dist/network-jBbjyAJP.cjs +0 -2
- package/dist/network-jBbjyAJP.cjs.map +0 -1
- package/dist/platform-Cjts-8k8.js +0 -48
- package/dist/platform-Cjts-8k8.js.map +0 -1
- package/dist/platform-DW3GFIUE.cjs +0 -2
- package/dist/platform-DW3GFIUE.cjs.map +0 -1
- package/dist/remote-rules-ByS34k4e.cjs +0 -2
- package/dist/remote-rules-ByS34k4e.cjs.map +0 -1
- package/dist/remote-rules-M-XZ1xbe.js.map +0 -1
- package/dist/sampling-BN3Oi6SV.js +0 -63
- package/dist/sampling-BN3Oi6SV.js.map +0 -1
- package/dist/sampling-b2ck5X98.cjs +0 -2
- package/dist/sampling-b2ck5X98.cjs.map +0 -1
- package/dist/sender-BBY0IcUo.js.map +0 -1
- package/dist/sender-BXoAZKum.cjs +0 -3
- package/dist/sender-BXoAZKum.cjs.map +0 -1
- package/dist/storm-CKuaBp7i.cjs +0 -2
- package/dist/storm-CKuaBp7i.cjs.map +0 -1
- package/dist/storm-DhtL2eVr.js +0 -10
- package/dist/storm-DhtL2eVr.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { $ as e,
|
|
2
|
-
import {
|
|
3
|
-
import { o as
|
|
4
|
-
import {
|
|
5
|
-
import { i as ge
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as j, t as
|
|
1
|
+
import { $ as e, B as t, Ct as n, Dt as r, Ft as i, H as a, Ht as o, Jt as s, Lt as c, M as l, N as u, Ot as d, P as f, Pt as p, Q as m, St as ee, U as h, Vt as te, X as g, Xt as _, Y as ne, Yt as v, Z as re, an as ie, bt as ae, d as oe, dn as se, en as y, et as ce, fn as b, gn as x, hn as S, ht as le, ln as ue, on as C, un as de, vt as w, x as T } from "./constants-DhH6VI5a.js";
|
|
2
|
+
import { n as E, r as D, t as fe } from "./deadline-DeqXEliN.js";
|
|
3
|
+
import { o as pe, t as me } from "./sampling-Ud_WiuU9.js";
|
|
4
|
+
import { o as he, t as O } from "./sanitize-DP0xDPrt.js";
|
|
5
|
+
import { i as ge } from "./identity-Di-QXGCC.js";
|
|
6
|
+
import { t as k } from "./openfin-BwEN0uj4.js";
|
|
7
|
+
import { r as _e } from "./platform-GaM6h7XM.js";
|
|
8
|
+
import { a as ve, i as A, n as j, r as ye, t as be } from "./batch-DDgxg16_.js";
|
|
9
|
+
import { i as xe, r as M } from "./library-request-CQD4HUiP.js";
|
|
10
|
+
import { n as Se, t as Ce } from "./remote-rules-6ePq8CrI.js";
|
|
9
11
|
//#region src/models/storage.ts
|
|
10
12
|
function N(e) {
|
|
11
13
|
let { maxBatches: t } = e;
|
|
@@ -28,6 +30,9 @@ function P(e, t, n, { skipIfBusy: r = !0 } = {}) {
|
|
|
28
30
|
//#endregion
|
|
29
31
|
//#region src/storage/keys.ts
|
|
30
32
|
function F(e, t) {
|
|
33
|
+
return `${e}${String(t.createdAt).padStart(14, "0")}.${t.id}`;
|
|
34
|
+
}
|
|
35
|
+
function I(e, t) {
|
|
31
36
|
let n = [];
|
|
32
37
|
return t.guard("storage.unavailable", "The library could not list the localStorage keys.", () => {
|
|
33
38
|
for (let t = 0; t < localStorage.length; t++) {
|
|
@@ -38,17 +43,13 @@ function F(e, t) {
|
|
|
38
43
|
}
|
|
39
44
|
//#endregion
|
|
40
45
|
//#region src/storage/emergency-queue.ts
|
|
41
|
-
function I(e) {
|
|
42
|
-
let t = String(e.createdAt).padStart(14, "0");
|
|
43
|
-
return `${p}${t}.${e.id}`;
|
|
44
|
-
}
|
|
45
46
|
function L(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 : A(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 we(e, t) {
|
|
50
51
|
let n = 0;
|
|
51
|
-
for (let r of
|
|
52
|
+
for (let r of I(a, 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;
|
|
@@ -56,7 +57,7 @@ async function ve(e, t) {
|
|
|
56
57
|
if (!i) continue;
|
|
57
58
|
let a = L(i, t);
|
|
58
59
|
if (a !== null) try {
|
|
59
|
-
await
|
|
60
|
+
await E(e.save(a), C), n++;
|
|
60
61
|
} catch (e) {
|
|
61
62
|
t.report("storage.degraded", "The library could not recover an emergency batch.", { key: r }, e);
|
|
62
63
|
}
|
|
@@ -64,29 +65,29 @@ async function ve(e, t) {
|
|
|
64
65
|
return n;
|
|
65
66
|
}
|
|
66
67
|
function R(e, t, n) {
|
|
67
|
-
let r = `writing the emergency queue, ${String(e.records.length)} records`, i = [],
|
|
68
|
-
let n =
|
|
68
|
+
let r = `writing the emergency queue, ${String(e.records.length)} records`, i = [], o = t.guard("storage.quota_exceeded", r, () => {
|
|
69
|
+
let n = I(a, t);
|
|
69
70
|
for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) {
|
|
70
71
|
let n = L(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(F(a, 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
|
+
o !== !0 && n?.("quota", e.records, [e.id]);
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
async function
|
|
84
|
-
return await P("ui-observability.emergency", t, () =>
|
|
84
|
+
async function Te(e, t) {
|
|
85
|
+
return await P("ui-observability.emergency", t, () => we(e, t), { skipIfBusy: !1 }) ?? 0;
|
|
85
86
|
}
|
|
86
87
|
//#endregion
|
|
87
88
|
//#region src/storage/eviction.ts
|
|
88
89
|
function z(e) {
|
|
89
|
-
return Array.isArray(e.records) && e.records.some(
|
|
90
|
+
return Array.isArray(e.records) && e.records.some(ye);
|
|
90
91
|
}
|
|
91
92
|
var B = class {
|
|
92
93
|
howMany;
|
|
@@ -109,29 +110,41 @@ function V(e, t, n) {
|
|
|
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 H(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
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function U(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));
|
|
116
123
|
}
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/storage/local-storage.ts
|
|
126
|
+
function Ee(e) {
|
|
127
|
+
let t = T.length, n = Number(e.slice(t, t + 14));
|
|
119
128
|
return Number.isFinite(n) ? n : null;
|
|
120
129
|
}
|
|
121
|
-
var
|
|
130
|
+
var De = class {
|
|
122
131
|
limits;
|
|
123
132
|
diagnostics;
|
|
124
133
|
onGap;
|
|
125
|
-
name =
|
|
134
|
+
name = ue;
|
|
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
|
+
U(this.diagnostics, this.onGap, t, [e]);
|
|
147
|
+
}
|
|
135
148
|
}
|
|
136
149
|
take(e) {
|
|
137
150
|
let t = [];
|
|
@@ -160,7 +173,7 @@ var Se = class {
|
|
|
160
173
|
reason: "expired"
|
|
161
174
|
}, n = [], r = [];
|
|
162
175
|
for (let t of this.keys()) {
|
|
163
|
-
let i =
|
|
176
|
+
let i = Ee(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 Se = 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(F(T, e), JSON.stringify(e)), !0)) === !0;
|
|
181
194
|
}
|
|
182
195
|
evictForQuota() {
|
|
183
196
|
let e = this.keys(), t = {
|
|
@@ -198,22 +211,16 @@ var Se = 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 = H(e, t, n.length, j(r));
|
|
217
|
+
U(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 : A(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 Se = class {
|
|
|
227
234
|
});
|
|
228
235
|
}
|
|
229
236
|
keys() {
|
|
230
|
-
return
|
|
237
|
+
return I(T, this.diagnostics);
|
|
231
238
|
}
|
|
232
|
-
}
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region src/storage/memory-storage.ts
|
|
235
|
-
function Ce(e) {
|
|
236
|
-
return e.reduce((e, t) => e + t.records.length, 0);
|
|
237
|
-
}
|
|
238
|
-
var H = class {
|
|
239
|
+
}, W = class {
|
|
239
240
|
limits;
|
|
240
241
|
onGap;
|
|
241
|
-
name =
|
|
242
|
+
name = de;
|
|
242
243
|
batches = [];
|
|
243
244
|
constructor(e, t) {
|
|
244
245
|
this.limits = e, this.onGap = t;
|
|
@@ -272,12 +273,8 @@ var H = class {
|
|
|
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 = H(e, t, n.length, j(n));
|
|
277
|
+
this.onGap?.(r, n);
|
|
281
278
|
}
|
|
282
279
|
count() {
|
|
283
280
|
return Promise.resolve(this.batches.length);
|
|
@@ -288,8 +285,8 @@ var H = class {
|
|
|
288
285
|
close() {
|
|
289
286
|
return this.batches = [], Promise.resolve();
|
|
290
287
|
}
|
|
291
|
-
},
|
|
292
|
-
name:
|
|
288
|
+
}, Oe = (e) => ({
|
|
289
|
+
name: se,
|
|
293
290
|
save: (t) => (e?.({
|
|
294
291
|
batches: 1,
|
|
295
292
|
records: t.records.length,
|
|
@@ -307,30 +304,30 @@ var H = class {
|
|
|
307
304
|
clear: () => Promise.resolve(),
|
|
308
305
|
close: () => Promise.resolve()
|
|
309
306
|
});
|
|
310
|
-
function
|
|
307
|
+
function ke(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 Ae(e) {
|
|
311
|
+
return e.guard("storage.unavailable", "The library could not write a test key to localStorage.", () => (localStorage.setItem(b, "1"), localStorage.removeItem(b), !0)) === !0;
|
|
315
312
|
}
|
|
316
|
-
async function
|
|
317
|
-
if (e === "none") return
|
|
318
|
-
if (e === "memory") return new
|
|
313
|
+
async function je(e, t, n, r, i) {
|
|
314
|
+
if (e === "none") return Oe(i);
|
|
315
|
+
if (e === "memory") return new W(n, i);
|
|
319
316
|
if (e === "indexeddb" || e === "auto") {
|
|
320
|
-
if (
|
|
317
|
+
if (ke(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-T9YIYVYC.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 W(n, i);
|
|
328
325
|
}
|
|
329
|
-
return
|
|
326
|
+
return Ae(r) ? new De(n, r, i) : (r.report("storage.degraded", "No persistent storage is available. The library keeps undelivered records in memory only."), new W(n, i));
|
|
330
327
|
}
|
|
331
328
|
//#endregion
|
|
332
329
|
//#region src/transport/errors.ts
|
|
333
|
-
var
|
|
330
|
+
var G = class extends Error {
|
|
334
331
|
kind;
|
|
335
332
|
status;
|
|
336
333
|
retryAfterMs;
|
|
@@ -339,77 +336,77 @@ var U = 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 Me(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 * ae);
|
|
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
|
-
function
|
|
352
|
-
return
|
|
348
|
+
function Ne(e) {
|
|
349
|
+
return ee.test(e) ? Number(BigInt(e) / n) : Date.now();
|
|
353
350
|
}
|
|
354
|
-
function
|
|
351
|
+
function Pe(e) {
|
|
355
352
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : typeof e == "bigint" ? e.toString() : null;
|
|
356
353
|
}
|
|
357
|
-
function
|
|
354
|
+
function Fe(e, t, n) {
|
|
358
355
|
let r = e[t];
|
|
359
356
|
r === void 0 ? e[t] = n : Array.isArray(r) ? r.push(n) : e[t] = [r, n];
|
|
360
357
|
}
|
|
361
|
-
function
|
|
362
|
-
let i =
|
|
363
|
-
if (i !== null)
|
|
358
|
+
function K(e, t, n, r) {
|
|
359
|
+
let i = Pe(n);
|
|
360
|
+
if (i !== null) Fe(e, t, i);
|
|
364
361
|
else if (typeof n == "object" && n && !r.has(n)) {
|
|
365
|
-
if (r.add(n), Array.isArray(n)) for (let i of n)
|
|
366
|
-
else for (let [i, a] of Object.entries(n))
|
|
362
|
+
if (r.add(n), Array.isArray(n)) for (let i of n) K(e, t, i, r);
|
|
363
|
+
else for (let [i, a] of Object.entries(n)) K(e, `${t}.${i}`, a, r);
|
|
367
364
|
r.delete(n);
|
|
368
365
|
}
|
|
369
366
|
}
|
|
370
|
-
function
|
|
367
|
+
function q(e) {
|
|
371
368
|
let t = Object.create(null), n = /* @__PURE__ */ new WeakSet();
|
|
372
|
-
for (let [r, i] of Object.entries(e))
|
|
369
|
+
for (let [r, i] of Object.entries(e)) K(t, r, i, n);
|
|
373
370
|
return t;
|
|
374
371
|
}
|
|
375
|
-
var
|
|
372
|
+
var Ie = {
|
|
376
373
|
name: "ecs",
|
|
377
374
|
serialize(e) {
|
|
378
375
|
return {
|
|
379
376
|
body: `${e.map((e) => {
|
|
380
|
-
let
|
|
377
|
+
let n = Ne(e.timeUnixNano);
|
|
381
378
|
return JSON.stringify({
|
|
382
|
-
"@timestamp": new Date(
|
|
379
|
+
"@timestamp": new Date(n).toISOString(),
|
|
383
380
|
message: e.body,
|
|
384
|
-
log: { level:
|
|
381
|
+
log: { level: t[e.severityText] ?? e.severityText.toLowerCase() },
|
|
385
382
|
trace: { id: e.traceId },
|
|
386
383
|
span: { id: e.spanId },
|
|
387
384
|
service: {
|
|
388
|
-
name: e.resource[
|
|
389
|
-
version: e.resource[
|
|
390
|
-
environment: e.resource[
|
|
385
|
+
name: e.resource[te],
|
|
386
|
+
version: e.resource[o],
|
|
387
|
+
environment: e.resource[c]
|
|
391
388
|
},
|
|
392
|
-
user_agent: { original: e.resource[
|
|
389
|
+
user_agent: { original: e.resource[i] },
|
|
393
390
|
url: { full: e.attributes["url.full"] ?? e.attributes["page.url"] },
|
|
394
391
|
labels: {
|
|
395
|
-
...
|
|
396
|
-
...
|
|
392
|
+
...q(e.resource),
|
|
393
|
+
...q(e.attributes)
|
|
397
394
|
}
|
|
398
395
|
});
|
|
399
396
|
}).join("\n")}\n`,
|
|
400
|
-
contentType:
|
|
397
|
+
contentType: u
|
|
401
398
|
};
|
|
402
399
|
}
|
|
403
400
|
};
|
|
404
401
|
//#endregion
|
|
405
402
|
//#region src/transport/serializers/otlp.ts
|
|
406
|
-
function
|
|
407
|
-
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(
|
|
403
|
+
function J(e) {
|
|
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(J).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: Y(e) } } : null;
|
|
408
405
|
}
|
|
409
|
-
function
|
|
406
|
+
function Y(e) {
|
|
410
407
|
let t = [];
|
|
411
408
|
for (let [n, r] of Object.entries(e)) {
|
|
412
|
-
let e =
|
|
409
|
+
let e = J(r);
|
|
413
410
|
e && t.push({
|
|
414
411
|
key: n,
|
|
415
412
|
value: e
|
|
@@ -417,30 +414,33 @@ function q(e) {
|
|
|
417
414
|
}
|
|
418
415
|
return t;
|
|
419
416
|
}
|
|
420
|
-
var
|
|
421
|
-
function
|
|
422
|
-
let t =
|
|
417
|
+
var Le = /* @__PURE__ */ new WeakMap();
|
|
418
|
+
function Re(e) {
|
|
419
|
+
let t = Le.get(e);
|
|
423
420
|
if (t !== void 0) return t;
|
|
424
421
|
let n = JSON.stringify(e);
|
|
425
|
-
return
|
|
422
|
+
return Le.set(e, n), n;
|
|
426
423
|
}
|
|
427
|
-
|
|
428
|
-
|
|
424
|
+
function ze(e) {
|
|
425
|
+
let t = /* @__PURE__ */ new Map();
|
|
426
|
+
for (let n of e) {
|
|
427
|
+
let e = Re(n.resource), r = t.get(e);
|
|
428
|
+
r ? r.records.push(n) : t.set(e, {
|
|
429
|
+
resource: n.resource,
|
|
430
|
+
records: [n]
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return [...t.values()];
|
|
434
|
+
}
|
|
435
|
+
var Be = {
|
|
436
|
+
name: y,
|
|
429
437
|
serialize(e) {
|
|
430
|
-
let t =
|
|
431
|
-
|
|
432
|
-
let e = Ne(n.resource), r = t.get(e);
|
|
433
|
-
r ? r.records.push(n) : t.set(e, {
|
|
434
|
-
resource: n.resource,
|
|
435
|
-
records: [n]
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
let n = [...t.values()].map((e) => ({
|
|
439
|
-
resource: { attributes: q(e.resource) },
|
|
438
|
+
let t = ze(e).map((e) => ({
|
|
439
|
+
resource: { attributes: Y(e.resource) },
|
|
440
440
|
scopeLogs: [{
|
|
441
441
|
scope: {
|
|
442
|
-
name:
|
|
443
|
-
version:
|
|
442
|
+
name: S,
|
|
443
|
+
version: x
|
|
444
444
|
},
|
|
445
445
|
logRecords: e.records.map((e) => ({
|
|
446
446
|
timeUnixNano: e.timeUnixNano,
|
|
@@ -451,24 +451,137 @@ var Pe = {
|
|
|
451
451
|
traceId: e.traceId,
|
|
452
452
|
spanId: e.spanId,
|
|
453
453
|
flags: e.traceFlags,
|
|
454
|
-
attributes:
|
|
454
|
+
attributes: Y(e.attributes)
|
|
455
455
|
}))
|
|
456
456
|
}]
|
|
457
457
|
}));
|
|
458
458
|
return {
|
|
459
|
-
body: JSON.stringify({ resourceLogs:
|
|
460
|
-
contentType:
|
|
459
|
+
body: JSON.stringify({ resourceLogs: t }),
|
|
460
|
+
contentType: l
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}, Ve = 1;
|
|
464
|
+
function X(e, t) {
|
|
465
|
+
let n = e.attributes[t];
|
|
466
|
+
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
467
|
+
}
|
|
468
|
+
function He(e) {
|
|
469
|
+
return Array.isArray(e) && e.every((e) => typeof e == "number" && Number.isFinite(e));
|
|
470
|
+
}
|
|
471
|
+
function Ue(e) {
|
|
472
|
+
let t = e.attributes[w.attributeKeys], n = {};
|
|
473
|
+
if (!Array.isArray(t)) return n;
|
|
474
|
+
for (let r of t) {
|
|
475
|
+
let t = typeof r == "string" && !r.startsWith("metric.") ? e.attributes[r] : void 0;
|
|
476
|
+
(typeof t == "string" || typeof t == "number" || typeof t == "boolean") && (n[r] = t);
|
|
477
|
+
}
|
|
478
|
+
return n;
|
|
479
|
+
}
|
|
480
|
+
function We(e) {
|
|
481
|
+
let t = X(e, w.count);
|
|
482
|
+
if (t === void 0) {
|
|
483
|
+
let t = X(e, "metric.value");
|
|
484
|
+
return t === void 0 ? null : {
|
|
485
|
+
count: "1",
|
|
486
|
+
sum: t < 0 ? void 0 : t,
|
|
487
|
+
min: t,
|
|
488
|
+
max: t,
|
|
489
|
+
bucketCounts: ["1"],
|
|
490
|
+
explicitBounds: []
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
let n = e.attributes[w.bounds], r = e.attributes[w.buckets];
|
|
494
|
+
if (!He(n) || !He(r) || r.length !== n.length + 1) return null;
|
|
495
|
+
let i = X(e, w.min);
|
|
496
|
+
return {
|
|
497
|
+
count: String(t),
|
|
498
|
+
sum: i !== void 0 && i < 0 ? void 0 : X(e, w.sum),
|
|
499
|
+
min: i,
|
|
500
|
+
max: X(e, w.max),
|
|
501
|
+
bucketCounts: r.map(String),
|
|
502
|
+
explicitBounds: n
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function Ge(e) {
|
|
506
|
+
let t = X(e, "metric.value");
|
|
507
|
+
return t === void 0 ? null : { asDouble: t };
|
|
508
|
+
}
|
|
509
|
+
function Ke(e, t) {
|
|
510
|
+
let n = e.attributes[w.start], r = t === "histogram" ? We(e) : Ge(e);
|
|
511
|
+
return r === null ? null : {
|
|
512
|
+
attributes: Y(Ue(e)),
|
|
513
|
+
startTimeUnixNano: typeof n == "string" ? n : e.timeUnixNano,
|
|
514
|
+
timeUnixNano: e.timeUnixNano,
|
|
515
|
+
...r
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function qe({ name: e, unit: t, field: n, points: r }) {
|
|
519
|
+
if (n === "gauge") return {
|
|
520
|
+
name: e,
|
|
521
|
+
unit: t,
|
|
522
|
+
gauge: { dataPoints: r }
|
|
523
|
+
};
|
|
524
|
+
let i = {
|
|
525
|
+
aggregationTemporality: Ve,
|
|
526
|
+
dataPoints: r
|
|
527
|
+
};
|
|
528
|
+
return n === "sum" && (i.isMonotonic = r.every((e) => e.asDouble >= 0)), {
|
|
529
|
+
name: e,
|
|
530
|
+
unit: t,
|
|
531
|
+
[n]: i
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
var Je = {
|
|
535
|
+
name: y,
|
|
536
|
+
serialize(e) {
|
|
537
|
+
let t = ze(e).map((e) => {
|
|
538
|
+
let t = /* @__PURE__ */ new Map();
|
|
539
|
+
for (let n of e.records) {
|
|
540
|
+
let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i = Ke(n, r);
|
|
541
|
+
if (i === null) continue;
|
|
542
|
+
let a = n.attributes["metric.name"], o = n.attributes["metric.unit"], s = {
|
|
543
|
+
name: typeof a == "string" ? a : n.body,
|
|
544
|
+
unit: typeof o == "string" ? o : "",
|
|
545
|
+
field: r,
|
|
546
|
+
points: []
|
|
547
|
+
}, c = JSON.stringify([
|
|
548
|
+
s.field,
|
|
549
|
+
s.name,
|
|
550
|
+
s.unit
|
|
551
|
+
]), l = t.get(c) ?? s;
|
|
552
|
+
l.points.push(i), t.set(c, l);
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
resource: { attributes: Y(e.resource) },
|
|
556
|
+
scopeMetrics: [{
|
|
557
|
+
scope: {
|
|
558
|
+
name: S,
|
|
559
|
+
version: x
|
|
560
|
+
},
|
|
561
|
+
metrics: [...t.values()].map(qe)
|
|
562
|
+
}]
|
|
563
|
+
};
|
|
564
|
+
});
|
|
565
|
+
return {
|
|
566
|
+
body: JSON.stringify({ resourceMetrics: t }),
|
|
567
|
+
contentType: l
|
|
461
568
|
};
|
|
462
569
|
}
|
|
463
570
|
};
|
|
464
571
|
//#endregion
|
|
465
572
|
//#region src/transport/serializers/select.ts
|
|
466
|
-
function
|
|
467
|
-
return e === "otlp" ?
|
|
573
|
+
function Ye(e) {
|
|
574
|
+
return e === "otlp" ? Be : e === "ecs" ? Ie : e;
|
|
468
575
|
}
|
|
469
|
-
function
|
|
576
|
+
function Z(e, t) {
|
|
577
|
+
return t.metricsEndpoint !== "" && e.records.length > 0 && e.records.every((e) => be(e, "log.type") === "metric") ? "metrics" : "logs";
|
|
578
|
+
}
|
|
579
|
+
function Xe(e, t) {
|
|
580
|
+
return e === "metrics" ? t.metricsEndpoint : t.endpoint;
|
|
581
|
+
}
|
|
582
|
+
function Ze(e, t, n, r) {
|
|
470
583
|
try {
|
|
471
|
-
return
|
|
584
|
+
return (Z(t, e) === "metrics" ? Je : Ye(e.serializer)).serialize(t.records);
|
|
472
585
|
} catch (e) {
|
|
473
586
|
n.report("transport.serialize_failed", r, { batchId: t.id }, e);
|
|
474
587
|
return;
|
|
@@ -476,49 +589,53 @@ function Y(e, t, n, r) {
|
|
|
476
589
|
}
|
|
477
590
|
//#endregion
|
|
478
591
|
//#region src/transport/status-transport.ts
|
|
479
|
-
var
|
|
592
|
+
var Qe = class {
|
|
480
593
|
config;
|
|
481
594
|
diagnostics;
|
|
482
595
|
onSampling;
|
|
483
596
|
onLoss;
|
|
484
|
-
throttledUntil =
|
|
597
|
+
throttledUntil = {
|
|
598
|
+
logs: 0,
|
|
599
|
+
metrics: 0
|
|
600
|
+
};
|
|
485
601
|
constructor(e, t, n = () => void 0, r = () => void 0) {
|
|
486
602
|
this.config = e, this.diagnostics = t, this.onSampling = n, this.onLoss = r;
|
|
487
603
|
}
|
|
488
|
-
throttledForMs() {
|
|
489
|
-
return Math.max(0, this.throttledUntil - Date.now());
|
|
604
|
+
throttledForMs(e) {
|
|
605
|
+
return Math.max(0, this.throttledUntil[Z(e, this.config)] - Date.now());
|
|
490
606
|
}
|
|
491
607
|
serialize(e) {
|
|
492
|
-
let t =
|
|
608
|
+
let t = Ze(this.config, e, this.diagnostics, "The serializer threw an error. The library dropped the batch.");
|
|
493
609
|
return t || this.onLoss("unserializable", e.records, [e.id]), t;
|
|
494
610
|
}
|
|
495
|
-
accept(e) {
|
|
496
|
-
this.throttledUntil = 0, this.config.sampling.remote &&
|
|
611
|
+
accept(e, t) {
|
|
612
|
+
this.throttledUntil[e] = 0, this.config.sampling.remote && t != null && this.onSampling(t);
|
|
497
613
|
}
|
|
498
|
-
reject(e, t, n) {
|
|
499
|
-
let
|
|
614
|
+
reject(e, t, n, r) {
|
|
615
|
+
let i = String(e);
|
|
500
616
|
if (e === 401 || e === 403) {
|
|
501
|
-
let t =
|
|
502
|
-
return this.diagnostics.report("transport.rejected_credentials", `The server returned ${
|
|
617
|
+
let t = r.advice === void 0 ? "" : ` ${r.advice}`;
|
|
618
|
+
return this.diagnostics.report("transport.rejected_credentials", `The server returned ${i}.${t}`, {
|
|
503
619
|
status: e,
|
|
504
|
-
endpoint: this.config
|
|
505
|
-
}), new
|
|
620
|
+
endpoint: Xe(n, this.config)
|
|
621
|
+
}), new G("permanent", `The server rejected the batch with ${i}.`, e);
|
|
506
622
|
}
|
|
507
|
-
if (e === 413) return new
|
|
623
|
+
if (e === 413) return new G("too_large", "The payload is too large.", e, void 0, r.maxBytes);
|
|
508
624
|
if (e === 429 || e === 503) {
|
|
509
|
-
let t = e === 429,
|
|
510
|
-
return this.throttledUntil = Date.now() + (
|
|
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 G("throttled", t ? "The server throttles the requests." : "The service is not available.", e, i);
|
|
511
627
|
}
|
|
512
|
-
return e === 408 || e >= 500 ? new
|
|
628
|
+
return e === 408 || e >= 500 ? new G("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.`, {
|
|
513
629
|
batchId: t,
|
|
514
630
|
status: e
|
|
515
|
-
}), new
|
|
631
|
+
}), new G("permanent", `The server rejected the batch with ${i}.`, e));
|
|
516
632
|
}
|
|
517
633
|
};
|
|
518
634
|
//#endregion
|
|
519
635
|
//#region src/transport/custom-transport.ts
|
|
520
|
-
function
|
|
636
|
+
function $e(e, t, n) {
|
|
521
637
|
return {
|
|
638
|
+
kind: n,
|
|
522
639
|
body: t.body,
|
|
523
640
|
contentType: t.contentType,
|
|
524
641
|
batchId: e.id,
|
|
@@ -526,38 +643,39 @@ function Z(e, t) {
|
|
|
526
643
|
records: e.records
|
|
527
644
|
};
|
|
528
645
|
}
|
|
529
|
-
function
|
|
646
|
+
function et(e) {
|
|
530
647
|
if (typeof e != "object" || !e) return !1;
|
|
531
648
|
let t = Reflect.get(e, "status");
|
|
532
649
|
return typeof t == "number" && Number.isInteger(t) && t >= 100 && t <= 599;
|
|
533
650
|
}
|
|
534
|
-
function
|
|
651
|
+
function tt(e) {
|
|
535
652
|
return typeof e == "number" && Number.isFinite(e) ? Math.max(0, e) : void 0;
|
|
536
653
|
}
|
|
537
|
-
var
|
|
654
|
+
var nt = class extends Qe {
|
|
538
655
|
async send(e) {
|
|
539
|
-
let { transport:
|
|
540
|
-
if (!
|
|
541
|
-
let
|
|
542
|
-
if (!
|
|
543
|
-
let
|
|
656
|
+
let { transport: t } = this.config;
|
|
657
|
+
if (!t || e.records.length === 0) return;
|
|
658
|
+
let n = this.serialize(e);
|
|
659
|
+
if (!n) return;
|
|
660
|
+
let r = Z(e, this.config), i = $e(e, n, r), a;
|
|
544
661
|
try {
|
|
545
|
-
a = await
|
|
662
|
+
a = await E(xe(() => M(() => he(() => t(i)))), p);
|
|
546
663
|
} catch (e) {
|
|
547
|
-
let t = e instanceof
|
|
548
|
-
throw new
|
|
664
|
+
let t = e instanceof fe ? e : void 0;
|
|
665
|
+
throw new G(t ? "timeout" : "transient", t?.message ?? "The custom transport failed.", void 0, void 0, void 0, e);
|
|
549
666
|
}
|
|
550
|
-
if (!
|
|
667
|
+
if (!et(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 G("transient", "The custom transport returned no valid status.");
|
|
551
668
|
let { status: o } = a;
|
|
552
|
-
if (o >= 200 && o < 300) this.accept(a.sampling);
|
|
553
|
-
else throw this.reject(o, e.id, {
|
|
554
|
-
retryAfterMs:
|
|
555
|
-
maxBytes:
|
|
669
|
+
if (o >= 200 && o < 300) this.accept(r, a.sampling);
|
|
670
|
+
else throw this.reject(o, e.id, r, {
|
|
671
|
+
retryAfterMs: tt(a.retryAfterMs),
|
|
672
|
+
maxBytes: tt(a.maxBytes)
|
|
556
673
|
});
|
|
557
674
|
}
|
|
558
|
-
},
|
|
675
|
+
}, rt = class {
|
|
559
676
|
deps;
|
|
560
677
|
installed = !1;
|
|
678
|
+
keepaliveBytes = 0;
|
|
561
679
|
onVisibility = () => {
|
|
562
680
|
document.visibilityState === "hidden" && this.flush("hidden");
|
|
563
681
|
};
|
|
@@ -576,7 +694,7 @@ var Le = class extends X {
|
|
|
576
694
|
install() {
|
|
577
695
|
if (this.installed || typeof addEventListener > "u") return;
|
|
578
696
|
this.installed = !0, typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), document.addEventListener("freeze", this.onFreeze)), addEventListener("pagehide", this.onPageHide);
|
|
579
|
-
let e =
|
|
697
|
+
let e = k()?.me;
|
|
580
698
|
this.deps.diagnostics.guard("openfin.unavailable", "The library could not subscribe to close-requested.", () => {
|
|
581
699
|
e?.on?.("close-requested", this.onOpenFinClose);
|
|
582
700
|
});
|
|
@@ -584,14 +702,16 @@ var Le = class extends X {
|
|
|
584
702
|
uninstall() {
|
|
585
703
|
if (!this.installed) return;
|
|
586
704
|
this.installed = !1, typeof document < "u" && (document.removeEventListener("visibilitychange", this.onVisibility), document.removeEventListener("freeze", this.onFreeze)), removeEventListener("pagehide", this.onPageHide);
|
|
587
|
-
let e =
|
|
705
|
+
let e = k()?.me;
|
|
588
706
|
this.deps.diagnostics.guard("openfin.unavailable", "The library could not unsubscribe from close-requested.", () => {
|
|
589
707
|
e?.removeListener?.("close-requested", this.onOpenFinClose);
|
|
590
708
|
});
|
|
591
709
|
}
|
|
592
710
|
flush(e) {
|
|
593
|
-
let { config: t, diagnostics:
|
|
594
|
-
if (
|
|
711
|
+
let { config: t, diagnostics: n } = this.deps;
|
|
712
|
+
if (n.guard("pipeline.crashed", "The metric points before the exit flush failed.", () => {
|
|
713
|
+
this.deps.beforeExit?.();
|
|
714
|
+
}), e === "hidden") {
|
|
595
715
|
this.flushAlive();
|
|
596
716
|
return;
|
|
597
717
|
}
|
|
@@ -599,31 +719,39 @@ var Le = class extends X {
|
|
|
599
719
|
this.flushCustom(e, t.transportOnExit);
|
|
600
720
|
return;
|
|
601
721
|
}
|
|
602
|
-
let
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
722
|
+
let r = this.endpointUrl();
|
|
723
|
+
if (r !== null) {
|
|
724
|
+
this.keepaliveBytes = 0;
|
|
725
|
+
for (let n of this.deps.drainForExit()) {
|
|
726
|
+
let i = Z(n, t) === "metrics" ? t.metricsEndpoint : r.href;
|
|
727
|
+
this.flushBatch(n, e, new URL(i));
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
flushBatch(e, t, n) {
|
|
732
|
+
let { config: i, diagnostics: a } = this.deps;
|
|
733
|
+
if (e.records.length === 0) return;
|
|
734
|
+
let o = this.serialize(e, t);
|
|
607
735
|
if (!o) return;
|
|
608
|
-
if (
|
|
609
|
-
R(
|
|
736
|
+
if (O(o.body) > 6e4) {
|
|
737
|
+
R(e, a, this.deps.onLoss);
|
|
610
738
|
return;
|
|
611
739
|
}
|
|
612
|
-
|
|
613
|
-
let s =
|
|
740
|
+
n.searchParams.set(r, e.id), n.searchParams.set(d, t);
|
|
741
|
+
let s = n.toString(), c = this.deps.exitHeaders();
|
|
614
742
|
if (c) {
|
|
615
|
-
this.keepaliveFetch(s,
|
|
616
|
-
let
|
|
617
|
-
return
|
|
743
|
+
this.keepaliveFetch(s, e, o.body, t, () => {
|
|
744
|
+
let t = new Headers(c);
|
|
745
|
+
return t.set(m, o.contentType), t.set(g, e.id), t;
|
|
618
746
|
});
|
|
619
747
|
return;
|
|
620
748
|
}
|
|
621
|
-
if (
|
|
622
|
-
R(
|
|
749
|
+
if (i.headers) {
|
|
750
|
+
R(e, a, this.deps.onLoss);
|
|
623
751
|
return;
|
|
624
752
|
}
|
|
625
|
-
let
|
|
626
|
-
|
|
753
|
+
let l = this.beacon(s, o.body);
|
|
754
|
+
l !== "sent" && (l === "refused" ? R(e, a, this.deps.onLoss) : this.keepaliveFetch(s, e, o.body, t, () => new Headers({ [m]: f })));
|
|
627
755
|
}
|
|
628
756
|
flushAlive() {
|
|
629
757
|
let { diagnostics: e } = this.deps, t = "The flush of the hidden document failed.";
|
|
@@ -634,13 +762,16 @@ var Le = class extends X {
|
|
|
634
762
|
});
|
|
635
763
|
}
|
|
636
764
|
flushCustom(e, t) {
|
|
637
|
-
let {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
765
|
+
let { config: n, diagnostics: r } = this.deps;
|
|
766
|
+
for (let i of this.deps.drainForExit()) {
|
|
767
|
+
let a = this.serialize(i, e);
|
|
768
|
+
if (!a) continue;
|
|
769
|
+
let o = $e(i, a, Z(i, n));
|
|
770
|
+
(t === void 0 || r.guard("transport.http_error", "The transportOnExit hook threw an error.", () => M(() => t(o))) !== !0) && R(i, r, this.deps.onLoss);
|
|
771
|
+
}
|
|
641
772
|
}
|
|
642
773
|
serialize(e, t) {
|
|
643
|
-
let n =
|
|
774
|
+
let n = Ze(this.deps.config, e, this.deps.diagnostics, `The ${t} exit flush could not serialize its batch.`);
|
|
644
775
|
return n || this.deps.onLoss?.("unserializable", e.records, [e.id]), n;
|
|
645
776
|
}
|
|
646
777
|
endpointUrl() {
|
|
@@ -656,8 +787,8 @@ var Le = class extends X {
|
|
|
656
787
|
keepaliveFetch(e, t, n, r, i) {
|
|
657
788
|
let { config: a, diagnostics: o } = this.deps, s = () => {
|
|
658
789
|
R(t, o, this.deps.onLoss);
|
|
659
|
-
};
|
|
660
|
-
o.guard("transport.http_error", "The keepalive fetch failed.", () => (fetch(e, {
|
|
790
|
+
}, c = O(n);
|
|
791
|
+
this.keepaliveBytes + c > 6e4 ? s() : (this.keepaliveBytes += c, o.guard("transport.http_error", "The keepalive fetch failed.", () => (fetch(e, {
|
|
661
792
|
method: "POST",
|
|
662
793
|
body: n,
|
|
663
794
|
headers: i(),
|
|
@@ -665,80 +796,80 @@ var Le = class extends X {
|
|
|
665
796
|
keepalive: !0
|
|
666
797
|
}).catch((e) => {
|
|
667
798
|
o.report("transport.http_error", "The exit flush failed.", { reason: r }, e), s();
|
|
668
|
-
}), !0)) !== !0 && s();
|
|
799
|
+
}), !0)) !== !0 && s());
|
|
669
800
|
}
|
|
670
801
|
};
|
|
671
802
|
//#endregion
|
|
672
803
|
//#region src/transport/compression.ts
|
|
673
|
-
async function
|
|
804
|
+
async function it(e) {
|
|
674
805
|
let t = globalThis.CompressionStream;
|
|
675
806
|
if (t === void 0) return null;
|
|
676
|
-
let n = new Blob([e]).stream().pipeThrough(new t(
|
|
807
|
+
let n = new Blob([e]).stream().pipeThrough(new t(h)), r = await new Response(n).arrayBuffer();
|
|
677
808
|
return new Uint8Array(r);
|
|
678
809
|
}
|
|
679
810
|
//#endregion
|
|
680
811
|
//#region src/transport/http-transport.ts
|
|
681
|
-
var
|
|
812
|
+
var at = "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.", ot = class extends Qe {
|
|
682
813
|
cachedHeaders;
|
|
683
814
|
async send(e, t) {
|
|
684
|
-
let {
|
|
685
|
-
|
|
815
|
+
let { config: n } = this, r = Z(e, n), i = Xe(r, n);
|
|
816
|
+
i && e.records.length !== 0 && await this.post(e, r, i, t);
|
|
686
817
|
}
|
|
687
818
|
lastHeaders() {
|
|
688
819
|
let { headers: e } = this.config;
|
|
689
820
|
if (!e) return;
|
|
690
821
|
if (typeof e != "function") return e;
|
|
691
822
|
let t = this.cachedHeaders;
|
|
692
|
-
return t?.source === e && t.endpoint === this.config.endpoint ? t.headers : void 0;
|
|
693
|
-
}
|
|
694
|
-
async post(t, n, r) {
|
|
695
|
-
let
|
|
696
|
-
if (!
|
|
697
|
-
let
|
|
698
|
-
if (this.rejectsCredentials(
|
|
699
|
-
this.accept(
|
|
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, i) {
|
|
826
|
+
let a = this.serialize(t);
|
|
827
|
+
if (!a) return;
|
|
828
|
+
let o = await this.attempt(t, r, a, i);
|
|
829
|
+
if (this.rejectsCredentials(o.status) && typeof this.config.headers == "function" && (this.cachedHeaders = void 0, o = await this.attempt(t, r, a, i)), o.ok) {
|
|
830
|
+
this.accept(n, o.headers.get(ce));
|
|
700
831
|
return;
|
|
701
832
|
}
|
|
702
|
-
let
|
|
703
|
-
throw this.reject(
|
|
704
|
-
retryAfterMs:
|
|
705
|
-
maxBytes:
|
|
706
|
-
advice:
|
|
833
|
+
let s = o.status, c = Me(o.headers.get(e)), l = s === 413 ? await this.readMaxBytes(o) : void 0;
|
|
834
|
+
throw this.reject(s, t.id, n, {
|
|
835
|
+
retryAfterMs: c,
|
|
836
|
+
maxBytes: l,
|
|
837
|
+
advice: at
|
|
707
838
|
});
|
|
708
839
|
}
|
|
709
840
|
rejectsCredentials(e) {
|
|
710
841
|
return e === 401 || e === 403;
|
|
711
842
|
}
|
|
712
|
-
async attempt(e, n, r
|
|
713
|
-
let
|
|
714
|
-
|
|
715
|
-
let
|
|
716
|
-
typeof
|
|
717
|
-
let
|
|
718
|
-
return
|
|
843
|
+
async attempt(e, t, n, r) {
|
|
844
|
+
let i = Date.now() + p, a = new Headers(await this.before(this.resolveHeaders(), i, t));
|
|
845
|
+
a.set(m, n.contentType), a.set(g, e.id), a.set(ne, String(e.attempts));
|
|
846
|
+
let o = await this.before(this.encodeBody(n.body), i, t);
|
|
847
|
+
typeof o != "string" && a.set(re, h);
|
|
848
|
+
let s = this.keepalive(o);
|
|
849
|
+
return s && r?.(), this.dispatch(t, a, o, i, s);
|
|
719
850
|
}
|
|
720
|
-
async before(e, t) {
|
|
851
|
+
async before(e, t, n) {
|
|
721
852
|
try {
|
|
722
|
-
return await
|
|
853
|
+
return await E(e, Math.max(0, t - Date.now()));
|
|
723
854
|
} catch {
|
|
724
|
-
throw this.timeout();
|
|
855
|
+
throw this.timeout(n);
|
|
725
856
|
}
|
|
726
857
|
}
|
|
727
|
-
timeout() {
|
|
728
|
-
let
|
|
729
|
-
return this.diagnostics.report("transport.timeout",
|
|
858
|
+
timeout(e) {
|
|
859
|
+
let t = `The request took longer than ${String(p)} ms.`;
|
|
860
|
+
return this.diagnostics.report("transport.timeout", t, { endpoint: e }), new G("timeout", t);
|
|
730
861
|
}
|
|
731
862
|
async encodeBody(e) {
|
|
732
863
|
let { config: t } = this;
|
|
733
|
-
return t.compression !== "gzip" ||
|
|
864
|
+
return t.compression !== "gzip" || O(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "The library could not compress the payload.", () => it(e)) ?? e;
|
|
734
865
|
}
|
|
735
866
|
async dispatch(e, t, n, r, i) {
|
|
736
867
|
let { config: a } = this, o = new AbortController(), s = setTimeout(() => {
|
|
737
868
|
o.abort();
|
|
738
869
|
}, Math.max(0, r - Date.now()));
|
|
739
|
-
|
|
870
|
+
D(s);
|
|
740
871
|
try {
|
|
741
|
-
return await
|
|
872
|
+
return await M(() => fetch(e, {
|
|
742
873
|
method: "POST",
|
|
743
874
|
headers: t,
|
|
744
875
|
body: n,
|
|
@@ -748,15 +879,13 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
748
879
|
keepalive: i
|
|
749
880
|
}));
|
|
750
881
|
} catch {
|
|
751
|
-
|
|
752
|
-
let e = globalThis.navigator?.onLine;
|
|
753
|
-
throw new U(e === !1 ? "offline" : "transient", "A network error occurred.");
|
|
882
|
+
throw o.signal.aborted ? this.timeout(e) : new G(_e() ? "transient" : "offline", "A network error occurred.");
|
|
754
883
|
} finally {
|
|
755
884
|
clearTimeout(s);
|
|
756
885
|
}
|
|
757
886
|
}
|
|
758
887
|
keepalive(e) {
|
|
759
|
-
let t = globalThis.document?.visibilityState === "hidden", n = typeof e == "string" ?
|
|
888
|
+
let t = globalThis.document?.visibilityState === "hidden", n = typeof e == "string" ? O(e) : e.byteLength;
|
|
760
889
|
return t && n <= 6e4;
|
|
761
890
|
}
|
|
762
891
|
async readMaxBytes(e) {
|
|
@@ -765,21 +894,23 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
765
894
|
return typeof t.maxBytes == "number" ? t.maxBytes : void 0;
|
|
766
895
|
});
|
|
767
896
|
}
|
|
768
|
-
async resolveHeaders(
|
|
769
|
-
let { headers:
|
|
770
|
-
if (!
|
|
771
|
-
if (typeof
|
|
772
|
-
let n = await this.diagnostics.guardAsync("transport.http_error", "The headers() function threw an error.", () => Promise.resolve(
|
|
773
|
-
return
|
|
774
|
-
source:
|
|
775
|
-
endpoint:
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}
|
|
897
|
+
async resolveHeaders() {
|
|
898
|
+
let { headers: e } = this.config;
|
|
899
|
+
if (!e) return {};
|
|
900
|
+
if (typeof e != "function") return e;
|
|
901
|
+
let { endpoint: t, metricsEndpoint: n } = this.config, r = await this.diagnostics.guardAsync("transport.http_error", "The headers() function threw an error.", () => Promise.resolve(e()));
|
|
902
|
+
return r && (this.cachedHeaders = {
|
|
903
|
+
source: e,
|
|
904
|
+
endpoint: t,
|
|
905
|
+
metricsEndpoint: n,
|
|
906
|
+
headers: r
|
|
907
|
+
}), r ?? {};
|
|
908
|
+
}
|
|
909
|
+
}, st = class {
|
|
780
910
|
storage;
|
|
781
911
|
transport;
|
|
782
912
|
diagnostics;
|
|
913
|
+
config;
|
|
783
914
|
batchesPerDrain;
|
|
784
915
|
onLoss;
|
|
785
916
|
timer = null;
|
|
@@ -791,13 +922,13 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
791
922
|
this.attempt = 0, this.schedule(0);
|
|
792
923
|
};
|
|
793
924
|
constructor(e, t, n, r, i = 20, a = () => void 0) {
|
|
794
|
-
this.storage = e, this.transport = t, this.diagnostics = n, this.batchesPerDrain = i, this.onLoss = a, this.maxAttempts = N(r.retention).maxAttempts;
|
|
925
|
+
this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i, this.onLoss = a, this.maxAttempts = N(r.retention).maxAttempts;
|
|
795
926
|
}
|
|
796
927
|
start() {
|
|
797
|
-
this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(
|
|
928
|
+
this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(v);
|
|
798
929
|
}
|
|
799
930
|
nudge() {
|
|
800
|
-
this.draining || this.schedule(
|
|
931
|
+
this.draining || this.schedule(s);
|
|
801
932
|
}
|
|
802
933
|
async storeFailed(e, t) {
|
|
803
934
|
let n = this.toStorable(e, t);
|
|
@@ -813,23 +944,23 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
813
944
|
let t = setTimeout(() => {
|
|
814
945
|
this.drain();
|
|
815
946
|
}, e);
|
|
816
|
-
this.timer = t,
|
|
947
|
+
this.timer = t, D(t);
|
|
817
948
|
}
|
|
818
949
|
bounded(e) {
|
|
819
|
-
return
|
|
950
|
+
return E(e, C);
|
|
820
951
|
}
|
|
821
952
|
clearTimer() {
|
|
822
953
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
823
954
|
}
|
|
824
955
|
backoffMs() {
|
|
825
|
-
let e = Math.min(
|
|
956
|
+
let e = Math.min(s * 2 ** this.attempt, _);
|
|
826
957
|
return Math.random() * e;
|
|
827
958
|
}
|
|
828
959
|
async drain() {
|
|
829
960
|
if (!this.draining) {
|
|
830
961
|
this.draining = !0;
|
|
831
962
|
try {
|
|
832
|
-
await P("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(
|
|
963
|
+
await P("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(v);
|
|
833
964
|
} finally {
|
|
834
965
|
this.draining = !1;
|
|
835
966
|
}
|
|
@@ -837,11 +968,19 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
837
968
|
}
|
|
838
969
|
async drainLocked() {
|
|
839
970
|
try {
|
|
840
|
-
if (
|
|
971
|
+
if (!_e()) return this.schedule(v), !0;
|
|
841
972
|
let e = await this.bounded(this.storage.take(this.batchesPerDrain));
|
|
842
|
-
if (e.length === 0) return this.schedule(
|
|
843
|
-
|
|
844
|
-
|
|
973
|
+
if (e.length === 0) return this.schedule(v), !0;
|
|
974
|
+
let t = /* @__PURE__ */ new Set(), n = 0;
|
|
975
|
+
for (let r of e) {
|
|
976
|
+
if (this.stopped) return !0;
|
|
977
|
+
let e = Z(r, this.config);
|
|
978
|
+
if (t.has(e)) continue;
|
|
979
|
+
let i = await this.deliver(r);
|
|
980
|
+
if (i === "stop") return !0;
|
|
981
|
+
i !== "next" && (t.add(e), n = Math.max(n, i));
|
|
982
|
+
}
|
|
983
|
+
return t.size > 0 ? this.schedule(n) : this.schedule(e.length === this.batchesPerDrain ? 0 : v), !0;
|
|
845
984
|
} catch (e) {
|
|
846
985
|
return this.diagnostics.report("storage.degraded", "The drain loop threw an error.", void 0, e), this.attempt++, this.schedule(this.backoffMs()), !0;
|
|
847
986
|
}
|
|
@@ -850,12 +989,12 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
850
989
|
if (e.attempts >= this.maxAttempts) return this.diagnostics.report("storage.dead_lettered", `The library dropped a batch after ${e.attempts.toString()} attempts.`, {
|
|
851
990
|
batchId: e.id,
|
|
852
991
|
records: e.records.length
|
|
853
|
-
}), this.onLoss("max_attempts", e.records, [e.id]), await this.bounded(this.storage.remove(e.id)),
|
|
992
|
+
}), this.onLoss("max_attempts", e.records, [e.id]), await this.bounded(this.storage.remove(e.id)), "next";
|
|
854
993
|
try {
|
|
855
|
-
return await this.transport.send(e), await this.bounded(this.storage.remove(e.id)), this.attempt = 0,
|
|
994
|
+
return await this.transport.send(e), await this.bounded(this.storage.remove(e.id)), this.attempt = 0, "next";
|
|
856
995
|
} catch (t) {
|
|
857
|
-
let n = t instanceof
|
|
858
|
-
return n?.kind === "permanent" || n?.kind === "too_large" ? (await this.replaceStored(e, t),
|
|
996
|
+
let n = t instanceof G ? t : void 0;
|
|
997
|
+
return n?.kind === "permanent" || n?.kind === "too_large" ? (await this.replaceStored(e, t), "next") : n?.kind === "offline" ? (this.schedule(v), "stop") : n?.kind === "throttled" ? (this.attempt++, n.retryAfterMs ?? this.backoffMs()) : (await this.bounded(this.storage.bumpAttempts(e.id, e.attempts + 1)), this.attempt++, n?.retryAfterMs ?? this.backoffMs());
|
|
859
998
|
}
|
|
860
999
|
}
|
|
861
1000
|
async replaceStored(e, t) {
|
|
@@ -864,10 +1003,10 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
864
1003
|
for (let e of n) await this.bounded(this.storage.save(e));
|
|
865
1004
|
}
|
|
866
1005
|
toStorable(e, t) {
|
|
867
|
-
let n = t instanceof
|
|
1006
|
+
let n = t instanceof G ? t : void 0;
|
|
868
1007
|
if (n?.kind === "permanent") return this.onLoss("rejected", e.records, [e.id]), [];
|
|
869
1008
|
if (n?.kind !== "too_large") return [e];
|
|
870
|
-
let r =
|
|
1009
|
+
let r = ve(e, this.diagnostics);
|
|
871
1010
|
return r ? (this.diagnostics.report("transport.batch_split", "The server refused the batch because it is too large.", {
|
|
872
1011
|
from: e.records.length,
|
|
873
1012
|
to: r[0].records.length,
|
|
@@ -880,8 +1019,8 @@ var Be = "In a cross-origin iframe, the session cookie is a third-party cookie.
|
|
|
880
1019
|
};
|
|
881
1020
|
//#endregion
|
|
882
1021
|
//#region src/core/pipeline.ts
|
|
883
|
-
function
|
|
884
|
-
return e.attributes[
|
|
1022
|
+
function Q(e) {
|
|
1023
|
+
return e.attributes[oe] === le;
|
|
885
1024
|
}
|
|
886
1025
|
var $ = class {
|
|
887
1026
|
options;
|
|
@@ -907,12 +1046,12 @@ var $ = class {
|
|
|
907
1046
|
let e = setTimeout(() => {
|
|
908
1047
|
this.timer = null, this.onFlush(this);
|
|
909
1048
|
}, this.options.flushIntervalMs);
|
|
910
|
-
this.timer = e,
|
|
1049
|
+
this.timer = e, D(e);
|
|
911
1050
|
}
|
|
912
1051
|
clearTimer() {
|
|
913
1052
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
914
1053
|
}
|
|
915
|
-
},
|
|
1054
|
+
}, ct = class {
|
|
916
1055
|
transport;
|
|
917
1056
|
storage;
|
|
918
1057
|
retry;
|
|
@@ -921,7 +1060,7 @@ var $ = class {
|
|
|
921
1060
|
unconfirmed = /* @__PURE__ */ new Map();
|
|
922
1061
|
queue = [];
|
|
923
1062
|
open = /* @__PURE__ */ new Set();
|
|
924
|
-
ceiling = new
|
|
1063
|
+
ceiling = new me();
|
|
925
1064
|
inFlight = 0;
|
|
926
1065
|
pumpScheduled = !1;
|
|
927
1066
|
stopped = !1;
|
|
@@ -936,21 +1075,16 @@ var $ = class {
|
|
|
936
1075
|
};
|
|
937
1076
|
}
|
|
938
1077
|
push(e) {
|
|
939
|
-
this.stopped || (e.observedTimeUnixNano =
|
|
940
|
-
}
|
|
941
|
-
drainPending() {
|
|
942
|
-
return this.toBatch([...this.streams.metrics.take(), ...this.streams.logs.take()]);
|
|
1078
|
+
this.stopped || (e.observedTimeUnixNano = pe(), this.route(e));
|
|
943
1079
|
}
|
|
944
1080
|
drainForExit() {
|
|
945
1081
|
let e = [...this.unconfirmed.values()].flatMap((e) => e.records);
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
...this.streams.logs.take()
|
|
950
|
-
]);
|
|
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);
|
|
951
1085
|
}
|
|
952
1086
|
async flushPending() {
|
|
953
|
-
this.
|
|
1087
|
+
this.stopped || (this.claim(this.streams.metrics), this.claim(this.streams.logs)), await Promise.all([...this.open].map((e) => e.done));
|
|
954
1088
|
}
|
|
955
1089
|
destroy() {
|
|
956
1090
|
this.stopped = !0, this.streams.logs.stop(), this.streams.metrics.stop(), this.queue.length = 0;
|
|
@@ -959,7 +1093,7 @@ var $ = class {
|
|
|
959
1093
|
}
|
|
960
1094
|
toBatch(e) {
|
|
961
1095
|
return e.length === 0 ? null : {
|
|
962
|
-
id:
|
|
1096
|
+
id: ge(this.diagnostics),
|
|
963
1097
|
records: e,
|
|
964
1098
|
createdAt: Date.now(),
|
|
965
1099
|
attempts: 0
|
|
@@ -967,7 +1101,7 @@ var $ = class {
|
|
|
967
1101
|
}
|
|
968
1102
|
route(e) {
|
|
969
1103
|
try {
|
|
970
|
-
let t =
|
|
1104
|
+
let t = Q(e) ? this.streams.metrics : this.streams.logs;
|
|
971
1105
|
if (!this.ceiling.allow(e)) {
|
|
972
1106
|
this.diagnostics.count("record.dropped_by_ceiling");
|
|
973
1107
|
return;
|
|
@@ -1012,7 +1146,7 @@ var $ = class {
|
|
|
1012
1146
|
}
|
|
1013
1147
|
async dispatch(e) {
|
|
1014
1148
|
try {
|
|
1015
|
-
let t = this.transport.throttledForMs();
|
|
1149
|
+
let t = this.transport.throttledForMs(e);
|
|
1016
1150
|
if (t > 0) {
|
|
1017
1151
|
await this.store(e), this.diagnostics.report("transport.throttled", "The server throttles requests. The pipeline stored the batch and did not send it.", {
|
|
1018
1152
|
batchId: e.id,
|
|
@@ -1045,10 +1179,10 @@ var $ = class {
|
|
|
1045
1179
|
}
|
|
1046
1180
|
async store(e) {
|
|
1047
1181
|
await this.diagnostics.guardAsync("storage.degraded", "The library could not store an undelivered batch.", async () => {
|
|
1048
|
-
await
|
|
1182
|
+
await E(this.storage.save(e), C), this.retry.nudge();
|
|
1049
1183
|
});
|
|
1050
1184
|
}
|
|
1051
|
-
},
|
|
1185
|
+
}, lt = class e {
|
|
1052
1186
|
storage;
|
|
1053
1187
|
retry;
|
|
1054
1188
|
pipeline;
|
|
@@ -1058,10 +1192,10 @@ var $ = class {
|
|
|
1058
1192
|
this.storage = e, this.retry = t, this.pipeline = n, this.exitFlush = r, this.diagnostics = i;
|
|
1059
1193
|
}
|
|
1060
1194
|
static async create(t) {
|
|
1061
|
-
let { config: n, diagnostics: r } = t, i = await
|
|
1062
|
-
let i =
|
|
1063
|
-
i &&
|
|
1064
|
-
}, { onLoss: o } = t, s = n.transport ? void 0 : new
|
|
1195
|
+
let { config: n, diagnostics: r } = t, i = await je(n.storage, ie, N(n.retention), r, t.onGap), a = (e) => {
|
|
1196
|
+
let i = Se(e, r);
|
|
1197
|
+
i && Ce(t.remote, n, i);
|
|
1198
|
+
}, { onLoss: o } = t, s = n.transport ? void 0 : new ot(n, r, a, o), c = s ?? new nt(n, r, a, o), l = new st(i, c, r, n, 20, o), { batching: u } = n, d = new ct(c, i, l, r, {
|
|
1065
1199
|
logs: {
|
|
1066
1200
|
flushIntervalMs: u.logFlushIntervalMs,
|
|
1067
1201
|
batchSize: u.logBatchSize
|
|
@@ -1070,13 +1204,14 @@ var $ = class {
|
|
|
1070
1204
|
flushIntervalMs: u.metricFlushIntervalMs,
|
|
1071
1205
|
batchSize: u.metricBatchSize
|
|
1072
1206
|
}
|
|
1073
|
-
}), f = new
|
|
1207
|
+
}), f = new rt({
|
|
1074
1208
|
config: n,
|
|
1075
1209
|
diagnostics: r,
|
|
1076
1210
|
drainForExit: () => d.drainForExit(),
|
|
1077
1211
|
flushAlive: () => d.flushPending(),
|
|
1078
1212
|
exitHeaders: () => s?.lastHeaders(),
|
|
1079
|
-
onLoss: o
|
|
1213
|
+
onLoss: o,
|
|
1214
|
+
beforeExit: t.beforeExit
|
|
1080
1215
|
}), p = !1;
|
|
1081
1216
|
try {
|
|
1082
1217
|
f.install(), l.start(), p = !0;
|
|
@@ -1099,11 +1234,11 @@ var $ = class {
|
|
|
1099
1234
|
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();
|
|
1100
1235
|
}
|
|
1101
1236
|
async importEmergency() {
|
|
1102
|
-
let e = await this.diagnostics.guardAsync("storage.degraded", "The emergency import failed.", () =>
|
|
1237
|
+
let e = await this.diagnostics.guardAsync("storage.degraded", "The emergency import failed.", () => Te(this.storage, this.diagnostics));
|
|
1103
1238
|
e !== void 0 && e > 0 && this.retry.nudge();
|
|
1104
1239
|
}
|
|
1105
1240
|
};
|
|
1106
1241
|
//#endregion
|
|
1107
|
-
export {
|
|
1242
|
+
export { lt as Sender, z as i, U as n, B as r, H as t };
|
|
1108
1243
|
|
|
1109
|
-
//# sourceMappingURL=sender-
|
|
1244
|
+
//# sourceMappingURL=sender-BUBWLn5i.js.map
|