@utk09/ui-observability 0.1.0 → 0.1.2
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/dist/{constants-DbvMIryP.js → constants-CYedFKrL.js} +5 -5
- package/dist/constants-CYedFKrL.js.map +1 -0
- package/dist/constants-CeqjB0Aa.cjs +2 -0
- package/dist/constants-CeqjB0Aa.cjs.map +1 -0
- package/dist/constants.d.ts +12 -1
- package/dist/core/journey.d.ts +3 -1
- package/dist/core/pipeline.d.ts +4 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +437 -423
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-DwpCDRnX.js → indexeddb-storage-3oT4si-p.js} +2 -2
- package/dist/{indexeddb-storage-DwpCDRnX.js.map → indexeddb-storage-3oT4si-p.js.map} +1 -1
- package/dist/{indexeddb-storage-DvsvCUlO.cjs → indexeddb-storage-K3DhJWgu.cjs} +2 -2
- package/dist/{indexeddb-storage-DvsvCUlO.cjs.map → indexeddb-storage-K3DhJWgu.cjs.map} +1 -1
- package/dist/models/batch.d.ts +9 -0
- package/dist/storage/emergency-queue.d.ts +1 -1
- package/dist/storage/local-storage.d.ts +1 -1
- package/package.json +1 -1
- package/dist/constants-D8-4Ged5.cjs +0 -2
- package/dist/constants-D8-4Ged5.cjs.map +0 -1
- package/dist/constants-DbvMIryP.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { $ as e, At as t, B as n,
|
|
2
|
-
import { context as
|
|
3
|
-
import { EMPTY as
|
|
1
|
+
import { $ as e, At as t, B as n, Bt as r, C as i, Ct as a, D as o, Dt as s, E as c, F as l, Ft as u, H as d, I as f, It as p, J as m, K as h, L as g, Lt as ee, Mt as te, N as _, Nt as ne, O as re, Ot as ie, P as ae, Pt as oe, Q as se, Rt as ce, S as le, T as ue, Tt as v, U as de, V as fe, Vt as pe, X as me, Y as he, Z as ge, _ as _e, _t as ve, a as ye, at as be, b as xe, bt as Se, c as Ce, ct as we, d as Te, dt as Ee, et as De, ft as Oe, g as ke, gt as Ae, h as je, ht as Me, i as Ne, it as Pe, j as Fe, jt as Ie, k as Le, l as y, lt as Re, m as ze, mt as Be, n as b, nt as Ve, o as He, ot as Ue, p as We, pt as Ge, q as x, r as Ke, rt as qe, s as Je, t as Ye, tt as Xe, u as Ze, ut as Qe, v as $e, vt as et, w as tt, x as nt, xt as rt, yt as it, z as at, zt as ot } from "./constants-CYedFKrL.js";
|
|
2
|
+
import { context as st, isSpanContextValid as ct, propagation as lt, trace as ut } from "@opentelemetry/api";
|
|
3
|
+
import { EMPTY as dt, Subject as ft, asapScheduler as pt, bufferTime as mt, catchError as ht, filter as S, from as gt, map as _t, merge as vt, mergeMap as yt, observeOn as bt, partition as xt, tap as St } from "rxjs";
|
|
4
4
|
//#region src/utils/timer.ts
|
|
5
|
-
function
|
|
6
|
-
return Math.round((performance.now() - e) *
|
|
5
|
+
function C(e) {
|
|
6
|
+
return Math.round((performance.now() - e) * Fe) / Fe;
|
|
7
7
|
}
|
|
8
8
|
function Ct(e, t, n, r, i) {
|
|
9
|
-
e.logMetric(`${t}.duration`,
|
|
9
|
+
e.logMetric(`${t}.duration`, C(n), "ms", "histogram", {
|
|
10
10
|
status: r,
|
|
11
11
|
...i
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
function wt(e, t, n, r, i) {
|
|
15
15
|
e.error(`${t} failed`, r, {
|
|
16
|
-
"action.duration_ms":
|
|
16
|
+
"action.duration_ms": C(n),
|
|
17
17
|
status: "FAILURE",
|
|
18
18
|
...i
|
|
19
19
|
});
|
|
@@ -41,7 +41,7 @@ async function Et(e, t, n, r) {
|
|
|
41
41
|
function Dt(e) {
|
|
42
42
|
return e instanceof Error ? e : Error(String(e));
|
|
43
43
|
}
|
|
44
|
-
var
|
|
44
|
+
var w = class e {
|
|
45
45
|
runtime;
|
|
46
46
|
namespace;
|
|
47
47
|
options;
|
|
@@ -128,18 +128,18 @@ var S = class e {
|
|
|
128
128
|
};
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/utils/unref.ts
|
|
131
|
-
function
|
|
131
|
+
function T(e) {
|
|
132
132
|
typeof e != "number" && e.unref?.();
|
|
133
133
|
}
|
|
134
134
|
//#endregion
|
|
135
135
|
//#region src/models/bus.ts
|
|
136
|
-
function
|
|
136
|
+
function E(e) {
|
|
137
137
|
return {
|
|
138
|
-
p:
|
|
138
|
+
p: xe,
|
|
139
139
|
m: e
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function D(e) {
|
|
143
143
|
if (typeof e != "object" || !e) return null;
|
|
144
144
|
let t = e;
|
|
145
145
|
if (t.p !== "ui-observability/1" || typeof t.m != "object" || t.m === null) return null;
|
|
@@ -174,7 +174,7 @@ function kt(e, t) {
|
|
|
174
174
|
function At(e, t) {
|
|
175
175
|
if (typeof window > "u" || window.parent === window) return null;
|
|
176
176
|
let n = (t) => {
|
|
177
|
-
let n =
|
|
177
|
+
let n = D(t.data);
|
|
178
178
|
n && t.source === window.parent && e(n, {
|
|
179
179
|
link: "parent",
|
|
180
180
|
origin: t.origin
|
|
@@ -184,7 +184,7 @@ function At(e, t) {
|
|
|
184
184
|
kind: "parent",
|
|
185
185
|
post(e) {
|
|
186
186
|
t.guard("bus.send_failed", "postMessage to parent", () => {
|
|
187
|
-
window.parent.postMessage(
|
|
187
|
+
window.parent.postMessage(E(e), "*");
|
|
188
188
|
});
|
|
189
189
|
},
|
|
190
190
|
close() {
|
|
@@ -195,7 +195,7 @@ function At(e, t) {
|
|
|
195
195
|
function jt(e, t, n) {
|
|
196
196
|
if (typeof window > "u") return null;
|
|
197
197
|
let r = /* @__PURE__ */ new Set([window.location.origin, ...t]), i = /* @__PURE__ */ new Set(), a = (t) => {
|
|
198
|
-
let a =
|
|
198
|
+
let a = D(t.data);
|
|
199
199
|
if (a) {
|
|
200
200
|
if (!r.has(t.origin)) {
|
|
201
201
|
n.report("bus.untrusted_origin", `ignored a bus message from ${t.origin}. Add it to bus.trustedOrigins if it is yours.`, {
|
|
@@ -220,7 +220,7 @@ function jt(e, t, n) {
|
|
|
220
220
|
continue;
|
|
221
221
|
}
|
|
222
222
|
n.guard("bus.send_failed", "postMessage to child", () => {
|
|
223
|
-
r.postMessage(
|
|
223
|
+
r.postMessage(E(e), "*");
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
},
|
|
@@ -234,7 +234,7 @@ function Mt(e, t, n) {
|
|
|
234
234
|
if (r === void 0) return null;
|
|
235
235
|
let i = n.guard("bus.send_failed", "opening BroadcastChannel", () => new r(e));
|
|
236
236
|
return i ? (i.onmessage = (e) => {
|
|
237
|
-
let n =
|
|
237
|
+
let n = D(e.data);
|
|
238
238
|
n && t(n, {
|
|
239
239
|
link: "broadcast",
|
|
240
240
|
origin: "same-origin"
|
|
@@ -243,7 +243,7 @@ function Mt(e, t, n) {
|
|
|
243
243
|
kind: "broadcast",
|
|
244
244
|
post(e) {
|
|
245
245
|
n.guard("bus.send_failed", "BroadcastChannel.postMessage", () => {
|
|
246
|
-
i.postMessage(
|
|
246
|
+
i.postMessage(E(e));
|
|
247
247
|
});
|
|
248
248
|
},
|
|
249
249
|
close() {
|
|
@@ -256,7 +256,7 @@ function Mt(e, t, n) {
|
|
|
256
256
|
function Nt(e, t, n) {
|
|
257
257
|
let r = globalThis.fin?.InterApplicationBus;
|
|
258
258
|
return r ? (n.guardAsync("bus.send_failed", "InterApplicationBus.subscribe", () => r.subscribe({ uuid: "*" }, e, (e) => {
|
|
259
|
-
let n =
|
|
259
|
+
let n = D(e);
|
|
260
260
|
n && t(n, {
|
|
261
261
|
link: "openfin",
|
|
262
262
|
origin: "openfin"
|
|
@@ -264,7 +264,7 @@ function Nt(e, t, n) {
|
|
|
264
264
|
})), {
|
|
265
265
|
kind: "openfin",
|
|
266
266
|
post(t) {
|
|
267
|
-
n.guardAsync("bus.send_failed", "InterApplicationBus.publish", () => r.publish(e,
|
|
267
|
+
n.guardAsync("bus.send_failed", "InterApplicationBus.publish", () => r.publish(e, E(t)));
|
|
268
268
|
},
|
|
269
269
|
close() {}
|
|
270
270
|
}) : null;
|
|
@@ -272,7 +272,7 @@ function Nt(e, t, n) {
|
|
|
272
272
|
function Pt(e, t) {
|
|
273
273
|
let n = globalThis, r = n.postMessage;
|
|
274
274
|
return n.WorkerGlobalScope === void 0 || !r ? null : (n.addEventListener?.("message", (t) => {
|
|
275
|
-
let n =
|
|
275
|
+
let n = D(t.data);
|
|
276
276
|
n && e(n, {
|
|
277
277
|
link: "owner",
|
|
278
278
|
origin: "same-origin"
|
|
@@ -281,7 +281,7 @@ function Pt(e, t) {
|
|
|
281
281
|
kind: "owner",
|
|
282
282
|
post(e) {
|
|
283
283
|
t.guard("bus.send_failed", "worker postMessage", () => {
|
|
284
|
-
r(
|
|
284
|
+
r(E(e));
|
|
285
285
|
});
|
|
286
286
|
},
|
|
287
287
|
close() {}
|
|
@@ -289,7 +289,7 @@ function Pt(e, t) {
|
|
|
289
289
|
}
|
|
290
290
|
function Ft(e, t, n) {
|
|
291
291
|
let r = (e) => {
|
|
292
|
-
let n =
|
|
292
|
+
let n = D(e.data);
|
|
293
293
|
n && t(n, {
|
|
294
294
|
link: "worker",
|
|
295
295
|
origin: "same-origin"
|
|
@@ -299,7 +299,7 @@ function Ft(e, t, n) {
|
|
|
299
299
|
kind: "worker",
|
|
300
300
|
post(t) {
|
|
301
301
|
n.guard("bus.send_failed", "postMessage to a worker", () => {
|
|
302
|
-
e.postMessage(
|
|
302
|
+
e.postMessage(E(t));
|
|
303
303
|
});
|
|
304
304
|
},
|
|
305
305
|
close() {
|
|
@@ -492,7 +492,7 @@ var It = [
|
|
|
492
492
|
let i = setTimeout(() => {
|
|
493
493
|
r(!1);
|
|
494
494
|
}, this.config.bus.handshakeTimeoutMs);
|
|
495
|
-
|
|
495
|
+
T(i), e.post({
|
|
496
496
|
t: "hello",
|
|
497
497
|
from: this.contextId,
|
|
498
498
|
tabId: this.tabId
|
|
@@ -554,7 +554,7 @@ var It = [
|
|
|
554
554
|
report(e, t, n) {
|
|
555
555
|
let r = Date.now();
|
|
556
556
|
if (r - this.windowStart > 1e4 && (this.windowStart = r, this.windowCount = 0), this.windowCount++, this.windowCount > 20) {
|
|
557
|
-
this.ctx.diagnostics.report("capture.rate_limited", `more than 20 errors in ${String(
|
|
557
|
+
this.ctx.diagnostics.report("capture.rate_limited", `more than 20 errors in ${String(l)}ms, suppressing the rest of this window`);
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
560
560
|
let i = t instanceof Error ? t : Error(String(t)), a = (i.stack ?? "").split("\n")[1] ?? "", o = `${i.name}|${i.message}|${a}`, s = this.seen.get(o);
|
|
@@ -562,7 +562,7 @@ var It = [
|
|
|
562
562
|
s.count++, s.at = r;
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
let
|
|
565
|
+
let c = s ? s.count - 1 : 0;
|
|
566
566
|
if (this.seen.delete(o), this.seen.set(o, {
|
|
567
567
|
at: r,
|
|
568
568
|
count: 1
|
|
@@ -573,7 +573,7 @@ var It = [
|
|
|
573
573
|
this.ctx.logger.error(i.message === "" ? e : i.message, i, {
|
|
574
574
|
...n,
|
|
575
575
|
"error.captured_by": e,
|
|
576
|
-
"error.suppressed_count":
|
|
576
|
+
"error.suppressed_count": c
|
|
577
577
|
});
|
|
578
578
|
}
|
|
579
579
|
};
|
|
@@ -589,7 +589,7 @@ function zt(e) {
|
|
|
589
589
|
let i = e.getAttribute("class")?.trim() ?? "";
|
|
590
590
|
return i === "" ? t : `${t}.${i.split(/\s+/).slice(0, 2).join(".")}`;
|
|
591
591
|
}
|
|
592
|
-
function
|
|
592
|
+
function O() {
|
|
593
593
|
return history;
|
|
594
594
|
}
|
|
595
595
|
var Bt = class {
|
|
@@ -606,7 +606,7 @@ var Bt = class {
|
|
|
606
606
|
this.installed || typeof document > "u" || (this.installed = !0, this.lastUrl = location.href, this.ctx.config.capture.interactions && addEventListener("click", this.onClick, !0), this.ctx.config.capture.navigation && (this.installHistory(), addEventListener("popstate", this.onNavigate), addEventListener("hashchange", this.onNavigate)));
|
|
607
607
|
}
|
|
608
608
|
uninstall() {
|
|
609
|
-
this.installed && (this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate), this.originalPushState && (
|
|
609
|
+
this.installed && (this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate), this.originalPushState && (O().pushState = this.originalPushState), this.originalReplaceState && (O().replaceState = this.originalReplaceState), this.originalPushState = null, this.originalReplaceState = null);
|
|
610
610
|
}
|
|
611
611
|
onClick = (e) => {
|
|
612
612
|
let t = e.target, n = zt(t instanceof Element ? t : null), r = t instanceof HTMLElement ? t.innerText.trim().slice(0, 50) : "";
|
|
@@ -627,7 +627,7 @@ var Bt = class {
|
|
|
627
627
|
};
|
|
628
628
|
installHistory() {
|
|
629
629
|
if (typeof history > "u" || this.originalPushState) return;
|
|
630
|
-
let e =
|
|
630
|
+
let e = O(), t = e.pushState, n = e.replaceState;
|
|
631
631
|
this.originalPushState = t, this.originalReplaceState = n;
|
|
632
632
|
let r = this.onNavigate;
|
|
633
633
|
e.pushState = function(...e) {
|
|
@@ -644,7 +644,7 @@ function Vt(e, t) {
|
|
|
644
644
|
}
|
|
645
645
|
//#endregion
|
|
646
646
|
//#region src/capture/network.ts
|
|
647
|
-
function
|
|
647
|
+
function k() {
|
|
648
648
|
return XMLHttpRequest.prototype;
|
|
649
649
|
}
|
|
650
650
|
var Ht = class {
|
|
@@ -660,7 +660,7 @@ var Ht = class {
|
|
|
660
660
|
this.ctx.config.capture.fetch && this.installFetch(), this.ctx.config.capture.xhr && this.installXhr();
|
|
661
661
|
}
|
|
662
662
|
uninstall() {
|
|
663
|
-
this.originalFetch &&= (globalThis.fetch = this.originalFetch, null), this.originalOpen &&= (
|
|
663
|
+
this.originalFetch &&= (globalThis.fetch = this.originalFetch, null), this.originalOpen &&= (k().open = this.originalOpen, null), this.originalSend &&= (k().send = this.originalSend, null);
|
|
664
664
|
}
|
|
665
665
|
ignored(e) {
|
|
666
666
|
return Vt(e, this.ctx.config.capture.ignoreUrls);
|
|
@@ -706,7 +706,7 @@ var Ht = class {
|
|
|
706
706
|
if (typeof XMLHttpRequest > "u" || this.originalOpen) return;
|
|
707
707
|
let e = (e) => this.ignored(e), t = (e, t, n, r) => {
|
|
708
708
|
this.record(e, t, n, r, void 0);
|
|
709
|
-
}, n =
|
|
709
|
+
}, n = k(), r = n.open, i = n.send;
|
|
710
710
|
this.originalOpen = r, this.originalSend = i, n.open = function(e, t, ...n) {
|
|
711
711
|
this.__uiobs = {
|
|
712
712
|
method: e.toUpperCase(),
|
|
@@ -805,23 +805,93 @@ var Wt = class {
|
|
|
805
805
|
};
|
|
806
806
|
//#endregion
|
|
807
807
|
//#region src/models/log-record.ts
|
|
808
|
-
function
|
|
808
|
+
function Gt() {
|
|
809
809
|
return `${String(Date.now())}000000`;
|
|
810
810
|
}
|
|
811
|
-
function
|
|
811
|
+
function A(e) {
|
|
812
812
|
if (typeof e != "object" || !e) return !1;
|
|
813
813
|
let t = e;
|
|
814
814
|
return typeof t.body == "string" && typeof t.severityText == "string" && typeof t.timeUnixNano == "string" && typeof t.attributes == "object" && t.attributes !== null && typeof t.resource == "object" && t.resource !== null;
|
|
815
815
|
}
|
|
816
816
|
//#endregion
|
|
817
|
+
//#region src/utils/identity.ts
|
|
818
|
+
function j(e) {
|
|
819
|
+
let t = new Uint8Array(e);
|
|
820
|
+
if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") crypto.getRandomValues(t);
|
|
821
|
+
else for (let n = 0; n < e; n++) t[n] = Math.floor(Math.random() * 256);
|
|
822
|
+
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
823
|
+
}
|
|
824
|
+
function M() {
|
|
825
|
+
try {
|
|
826
|
+
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
827
|
+
} catch {}
|
|
828
|
+
return j(16);
|
|
829
|
+
}
|
|
830
|
+
function Kt(e, t, n) {
|
|
831
|
+
return n.guard("storage.unavailable", `reading ${e}Storage`, () => (e === "local" ? localStorage : sessionStorage).getItem(t)) ?? null;
|
|
832
|
+
}
|
|
833
|
+
function N(e, t, n, r) {
|
|
834
|
+
r.guard("storage.unavailable", `writing ${e}Storage`, () => {
|
|
835
|
+
(e === "local" ? localStorage : sessionStorage).setItem(t, n);
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
function qt(e) {
|
|
839
|
+
let t = M(), n = Date.now(), r = M(), i = Kt("local", v, e);
|
|
840
|
+
if (i) try {
|
|
841
|
+
let e = JSON.parse(i);
|
|
842
|
+
e.id && n - (e.lastSeenAt ?? 0) < 18e5 && (r = e.id);
|
|
843
|
+
} catch {
|
|
844
|
+
e.report("storage.degraded", "session record was not JSON, starting a new session");
|
|
845
|
+
}
|
|
846
|
+
let a = JSON.stringify({
|
|
847
|
+
id: r,
|
|
848
|
+
lastSeenAt: n
|
|
849
|
+
});
|
|
850
|
+
N("local", v, a, e);
|
|
851
|
+
let o = Kt("session", "ui-observability.tab", e) ?? "";
|
|
852
|
+
return o || (o = M(), N("session", oe, o, e)), {
|
|
853
|
+
sessionId: r,
|
|
854
|
+
tabId: o,
|
|
855
|
+
contextId: t
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
var Jt = 0;
|
|
859
|
+
function Yt(e, t) {
|
|
860
|
+
let n = Date.now();
|
|
861
|
+
if (n - Jt < 6e4) return;
|
|
862
|
+
Jt = n;
|
|
863
|
+
let r = JSON.stringify({
|
|
864
|
+
id: e,
|
|
865
|
+
lastSeenAt: n
|
|
866
|
+
});
|
|
867
|
+
N("local", v, r, t);
|
|
868
|
+
}
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/models/batch.ts
|
|
871
|
+
function Xt(e) {
|
|
872
|
+
if (typeof e != "object" || !e) return !1;
|
|
873
|
+
let t = Reflect.get(e, "id"), n = Reflect.get(e, "createdAt"), r = Reflect.get(e, "attempts"), i = Reflect.get(e, "records");
|
|
874
|
+
return typeof t == "string" && typeof n == "number" && typeof r == "number" && Array.isArray(i);
|
|
875
|
+
}
|
|
876
|
+
function Zt(e) {
|
|
877
|
+
if (e.records.length < 2) return null;
|
|
878
|
+
let t = Math.floor(e.records.length / 2), n = (t) => ({
|
|
879
|
+
id: M(),
|
|
880
|
+
records: t,
|
|
881
|
+
createdAt: e.createdAt,
|
|
882
|
+
attempts: e.attempts
|
|
883
|
+
});
|
|
884
|
+
return [n(e.records.slice(0, t)), n(e.records.slice(t))];
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
817
887
|
//#region src/utils/lock.ts
|
|
818
|
-
function
|
|
888
|
+
function Qt(e, t, n, { skipIfBusy: r = !0 } = {}) {
|
|
819
889
|
let i = globalThis.navigator?.locks;
|
|
820
890
|
return i?.request ? t.guardAsync("storage.degraded", `acquiring lock ${e}`, () => i.request(e, { ifAvailable: r }, (e) => e ? n() : Promise.resolve(void 0))) : n();
|
|
821
891
|
}
|
|
822
892
|
//#endregion
|
|
823
893
|
//#region src/storage/keys.ts
|
|
824
|
-
function
|
|
894
|
+
function P(e, t) {
|
|
825
895
|
let n = [];
|
|
826
896
|
return t.guard("storage.unavailable", "enumerating localStorage", () => {
|
|
827
897
|
for (let t = 0; t < localStorage.length; t++) {
|
|
@@ -832,25 +902,23 @@ function j(e, t) {
|
|
|
832
902
|
}
|
|
833
903
|
//#endregion
|
|
834
904
|
//#region src/storage/emergency-queue.ts
|
|
835
|
-
function
|
|
905
|
+
function $t(e) {
|
|
836
906
|
let t = String(e.createdAt).padStart(14, "0");
|
|
837
|
-
return `${
|
|
907
|
+
return `${_}${t}.${e.id}`;
|
|
838
908
|
}
|
|
839
|
-
function
|
|
909
|
+
function en(e, t) {
|
|
840
910
|
let n = t.guard("storage.degraded", "an emergency entry was not JSON and was dropped", () => JSON.parse(e));
|
|
841
|
-
|
|
842
|
-
let r = Reflect.get(n, "createdAt"), i = Reflect.get(n, "records");
|
|
843
|
-
return typeof r != "number" || !Array.isArray(i) ? (t.report("storage.degraded", "an emergency entry was not a batch and was dropped"), null) : n;
|
|
911
|
+
return n === void 0 ? null : Xt(n) ? n : (t.report("storage.degraded", "an emergency entry was not a batch and was dropped"), null);
|
|
844
912
|
}
|
|
845
|
-
async function
|
|
913
|
+
async function tn(e, t) {
|
|
846
914
|
let n = 0;
|
|
847
|
-
for (let r of
|
|
915
|
+
for (let r of P(_, t)) {
|
|
848
916
|
let i = t.guard("storage.unavailable", "reading the emergency queue", () => {
|
|
849
917
|
let e = localStorage.getItem(r);
|
|
850
918
|
return localStorage.removeItem(r), e;
|
|
851
919
|
});
|
|
852
920
|
if (!i) continue;
|
|
853
|
-
let a =
|
|
921
|
+
let a = en(i, t);
|
|
854
922
|
if (a !== null) try {
|
|
855
923
|
await e.save(a), n++;
|
|
856
924
|
} catch (e) {
|
|
@@ -859,32 +927,33 @@ async function qt(e, t) {
|
|
|
859
927
|
}
|
|
860
928
|
return n;
|
|
861
929
|
}
|
|
862
|
-
function
|
|
863
|
-
|
|
864
|
-
|
|
930
|
+
function nn(e, t) {
|
|
931
|
+
let n = `writing the emergency queue, ${String(e.records.length)} records`;
|
|
932
|
+
t.guard("storage.quota_exceeded", n, () => {
|
|
933
|
+
let n = P(_, t);
|
|
865
934
|
for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) localStorage.removeItem(e);
|
|
866
|
-
localStorage.setItem(
|
|
935
|
+
localStorage.setItem($t(e), JSON.stringify(e));
|
|
867
936
|
});
|
|
868
937
|
}
|
|
869
|
-
async function
|
|
870
|
-
return await
|
|
938
|
+
async function rn(e, t) {
|
|
939
|
+
return await Qt("ui-observability.emergency", t, () => tn(e, t), { skipIfBusy: !1 }) ?? 0;
|
|
871
940
|
}
|
|
872
941
|
//#endregion
|
|
873
942
|
//#region src/storage/local-storage.ts
|
|
874
|
-
function
|
|
943
|
+
function an(e) {
|
|
875
944
|
let t = String(e.createdAt).padStart(14, "0");
|
|
876
|
-
return `${
|
|
945
|
+
return `${$e}${t}.${e.id}`;
|
|
877
946
|
}
|
|
878
|
-
var
|
|
947
|
+
var on = class {
|
|
879
948
|
limits;
|
|
880
949
|
diagnostics;
|
|
881
950
|
onGap;
|
|
882
|
-
name =
|
|
951
|
+
name = t;
|
|
883
952
|
constructor(e, t, n) {
|
|
884
953
|
this.limits = e, this.diagnostics = t, this.onGap = n;
|
|
885
954
|
}
|
|
886
955
|
async save(e) {
|
|
887
|
-
if (this.diagnostics.guard("storage.quota_exceeded", "localStorage refused a batch, evicting the oldest", () => (localStorage.setItem(
|
|
956
|
+
if (this.diagnostics.guard("storage.quota_exceeded", "localStorage refused a batch, evicting the oldest", () => (localStorage.setItem(an(e), JSON.stringify(e)), !0)) !== !0) {
|
|
888
957
|
let e = this.keys();
|
|
889
958
|
this.evict(e.slice(0, Math.ceil(e.length / 4)));
|
|
890
959
|
return;
|
|
@@ -958,9 +1027,7 @@ var Zt = class {
|
|
|
958
1027
|
let t = this.diagnostics.guard("storage.unavailable", "reading a stored batch", () => localStorage.getItem(e));
|
|
959
1028
|
if (!t) return null;
|
|
960
1029
|
let n = this.diagnostics.guard("storage.degraded", "a stored batch was corrupt and was removed", () => JSON.parse(t));
|
|
961
|
-
|
|
962
|
-
let r = Reflect.get(n, "createdAt"), i = Reflect.get(n, "records");
|
|
963
|
-
return typeof r != "number" || !Array.isArray(i) ? null : n;
|
|
1030
|
+
return n === void 0 ? null : Xt(n) ? n : (this.diagnostics.report("storage.degraded", "a stored entry was not a batch and was dropped"), null);
|
|
964
1031
|
}
|
|
965
1032
|
keyOf(e) {
|
|
966
1033
|
return this.keys().find((t) => t.endsWith(`.${e}`)) ?? null;
|
|
@@ -974,18 +1041,18 @@ var Zt = class {
|
|
|
974
1041
|
});
|
|
975
1042
|
}
|
|
976
1043
|
keys() {
|
|
977
|
-
return
|
|
1044
|
+
return P($e, this.diagnostics);
|
|
978
1045
|
}
|
|
979
1046
|
};
|
|
980
1047
|
//#endregion
|
|
981
1048
|
//#region src/storage/memory-storage.ts
|
|
982
|
-
function
|
|
1049
|
+
function sn(e) {
|
|
983
1050
|
return e.reduce((e, t) => e + t.records.length, 0);
|
|
984
1051
|
}
|
|
985
|
-
var
|
|
1052
|
+
var F = class {
|
|
986
1053
|
limits;
|
|
987
1054
|
onGap;
|
|
988
|
-
name =
|
|
1055
|
+
name = Ie;
|
|
989
1056
|
batches = [];
|
|
990
1057
|
constructor(e, t) {
|
|
991
1058
|
this.limits = e, this.onGap = t;
|
|
@@ -1009,12 +1076,12 @@ var M = class {
|
|
|
1009
1076
|
records: 0,
|
|
1010
1077
|
reason: "expired"
|
|
1011
1078
|
}, n = this.batches.filter((t) => t.createdAt < e);
|
|
1012
|
-
this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records +=
|
|
1079
|
+
this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records += sn(n);
|
|
1013
1080
|
let r = this.batches.length - this.limits.maxBatches;
|
|
1014
1081
|
if (r > 0) {
|
|
1015
1082
|
t.reason = "over_capacity";
|
|
1016
1083
|
let e = this.batches.slice(0, r);
|
|
1017
|
-
this.batches = this.batches.slice(r), t.batches += e.length, t.records +=
|
|
1084
|
+
this.batches = this.batches.slice(r), t.batches += e.length, t.records += sn(e);
|
|
1018
1085
|
}
|
|
1019
1086
|
return t.batches > 0 && this.onGap?.(t), Promise.resolve(t);
|
|
1020
1087
|
}
|
|
@@ -1027,8 +1094,8 @@ var M = class {
|
|
|
1027
1094
|
close() {
|
|
1028
1095
|
return this.batches = [], Promise.resolve();
|
|
1029
1096
|
}
|
|
1030
|
-
},
|
|
1031
|
-
name:
|
|
1097
|
+
}, cn = {
|
|
1098
|
+
name: te,
|
|
1032
1099
|
save: () => Promise.resolve(),
|
|
1033
1100
|
take: () => Promise.resolve([]),
|
|
1034
1101
|
remove: () => Promise.resolve(),
|
|
@@ -1042,112 +1109,112 @@ var M = class {
|
|
|
1042
1109
|
clear: () => Promise.resolve(),
|
|
1043
1110
|
close: () => Promise.resolve()
|
|
1044
1111
|
};
|
|
1045
|
-
function
|
|
1112
|
+
function ln(e) {
|
|
1046
1113
|
return e.guard("storage.unavailable", "reading indexedDB", () => globalThis.indexedDB != null) === !0;
|
|
1047
1114
|
}
|
|
1048
|
-
function
|
|
1049
|
-
return e.guard("storage.unavailable", "probing localStorage", () => (localStorage.setItem(
|
|
1115
|
+
function un(e) {
|
|
1116
|
+
return e.guard("storage.unavailable", "probing localStorage", () => (localStorage.setItem(ne, "1"), localStorage.removeItem(ne), !0)) === !0;
|
|
1050
1117
|
}
|
|
1051
|
-
async function
|
|
1052
|
-
if (e === "none") return
|
|
1053
|
-
if (e === "memory") return new
|
|
1118
|
+
async function dn(e, t, n, r, i) {
|
|
1119
|
+
if (e === "none") return cn;
|
|
1120
|
+
if (e === "memory") return new F(n, i);
|
|
1054
1121
|
if (e === "indexeddb" || e === "auto") {
|
|
1055
|
-
if (
|
|
1122
|
+
if (ln(r)) {
|
|
1056
1123
|
let e = await r.guardAsync("storage.unavailable", "opening IndexedDB", async () => {
|
|
1057
|
-
let { IndexedDbStorage: e } = await import("./indexeddb-storage-
|
|
1124
|
+
let { IndexedDbStorage: e } = await import("./indexeddb-storage-3oT4si-p.js");
|
|
1058
1125
|
return new e(t, n, r, i);
|
|
1059
1126
|
});
|
|
1060
1127
|
if (e) return e;
|
|
1061
1128
|
}
|
|
1062
|
-
if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new
|
|
1129
|
+
if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new F(n, i);
|
|
1063
1130
|
}
|
|
1064
|
-
return
|
|
1131
|
+
return un(r) ? new on(n, r, i) : (r.report("storage.degraded", "no persistent storage available, offline logs are memory only"), new F(n, i));
|
|
1065
1132
|
}
|
|
1066
1133
|
//#endregion
|
|
1067
1134
|
//#region src/utils/sanitize.ts
|
|
1068
|
-
function
|
|
1135
|
+
function I(e, t) {
|
|
1069
1136
|
if (e.length <= t) return e;
|
|
1070
|
-
let n =
|
|
1137
|
+
let n = fn(e.charCodeAt(t - 1)) ? t - 1 : t;
|
|
1071
1138
|
return `${e.slice(0, n)}… [truncated ${String(e.length - n)} chars]`;
|
|
1072
1139
|
}
|
|
1073
|
-
function
|
|
1140
|
+
function fn(e) {
|
|
1074
1141
|
return e >= 55296 && e <= 56319;
|
|
1075
1142
|
}
|
|
1076
|
-
function
|
|
1143
|
+
function pn(e) {
|
|
1077
1144
|
return `[Element ${(e.nodeName ?? "NODE").toLowerCase()}${e.id ? `#${e.id}` : ""}${typeof e.className == "string" && e.className ? `.${e.className.trim().split(/\s+/).slice(0, 3).join(".")}` : ""}]`;
|
|
1078
1145
|
}
|
|
1079
|
-
function
|
|
1146
|
+
function L(e, t) {
|
|
1080
1147
|
let n = { bytes: 0 };
|
|
1081
1148
|
return {
|
|
1082
|
-
value:
|
|
1149
|
+
value: z(e, t, /* @__PURE__ */ new WeakSet(), 0, n),
|
|
1083
1150
|
bytes: n.bytes
|
|
1084
1151
|
};
|
|
1085
1152
|
}
|
|
1086
|
-
function
|
|
1087
|
-
return t.bytes +=
|
|
1153
|
+
function R(e, t) {
|
|
1154
|
+
return t.bytes += B(e) + 2, e;
|
|
1088
1155
|
}
|
|
1089
|
-
function
|
|
1156
|
+
function z(e, t, n, r, i) {
|
|
1090
1157
|
if (e == null) return i.bytes += 4, e;
|
|
1091
|
-
if (typeof e == "string") return
|
|
1158
|
+
if (typeof e == "string") return R(I(e, t.maxAttributeChars), i);
|
|
1092
1159
|
if (typeof e == "number") return i.bytes += 8, Number.isFinite(e) ? e : String(e);
|
|
1093
1160
|
if (typeof e == "boolean") return i.bytes += 5, e;
|
|
1094
|
-
if (typeof e == "bigint") return
|
|
1095
|
-
if (typeof e == "symbol") return
|
|
1096
|
-
if (typeof e == "function") return
|
|
1097
|
-
if (r >= t.maxDepth) return
|
|
1098
|
-
if (n.has(e)) return
|
|
1161
|
+
if (typeof e == "bigint") return R(`${e.toString()}n`, i);
|
|
1162
|
+
if (typeof e == "symbol") return R(e.toString(), i);
|
|
1163
|
+
if (typeof e == "function") return R(`[Function ${e.name === "" ? "anonymous" : e.name}]`, i);
|
|
1164
|
+
if (r >= t.maxDepth) return R("[MaxDepth]", i);
|
|
1165
|
+
if (n.has(e)) return R("[Circular]", i);
|
|
1099
1166
|
n.add(e), i.bytes += 2;
|
|
1100
1167
|
try {
|
|
1101
1168
|
if (e instanceof Error) return {
|
|
1102
|
-
name:
|
|
1103
|
-
message:
|
|
1104
|
-
stack: e.stack ?
|
|
1105
|
-
cause: e.cause ?
|
|
1169
|
+
name: R(e.name, i),
|
|
1170
|
+
message: R(I(e.message, t.maxAttributeChars), i),
|
|
1171
|
+
stack: e.stack ? R(I(e.stack, t.maxStackChars), i) : void 0,
|
|
1172
|
+
cause: e.cause ? z(e.cause, t, n, r + 1, i) : void 0
|
|
1106
1173
|
};
|
|
1107
|
-
if (e instanceof Date) return
|
|
1108
|
-
if (e instanceof RegExp) return
|
|
1174
|
+
if (e instanceof Date) return R(e.toISOString(), i);
|
|
1175
|
+
if (e instanceof RegExp) return R(e.toString(), i);
|
|
1109
1176
|
if (e instanceof Map) {
|
|
1110
1177
|
let a = e, o = {}, s = 0;
|
|
1111
1178
|
for (let [e, c] of a) {
|
|
1112
1179
|
if (s >= t.maxArrayLength) {
|
|
1113
|
-
o["…"] =
|
|
1180
|
+
o["…"] = R(`[${String(a.size - t.maxArrayLength)} more entries]`, i);
|
|
1114
1181
|
break;
|
|
1115
1182
|
}
|
|
1116
1183
|
s++;
|
|
1117
1184
|
let l = String(e);
|
|
1118
|
-
i.bytes +=
|
|
1185
|
+
i.bytes += B(l) + 4, o[l] = z(c, t, n, r + 1, i);
|
|
1119
1186
|
}
|
|
1120
1187
|
return o;
|
|
1121
1188
|
}
|
|
1122
|
-
if (e instanceof Set) return
|
|
1189
|
+
if (e instanceof Set) return z([...e].slice(0, t.maxArrayLength), t, n, r, i);
|
|
1123
1190
|
if (ArrayBuffer.isView(e)) {
|
|
1124
1191
|
let t = e.length ?? 0;
|
|
1125
|
-
return
|
|
1192
|
+
return R(`[${e.constructor.name}(${String(t)})]`, i);
|
|
1126
1193
|
}
|
|
1127
|
-
if (e instanceof Promise) return
|
|
1128
|
-
if (typeof Node < "u" && e instanceof Node) return
|
|
1194
|
+
if (e instanceof Promise) return R("[Promise]", i);
|
|
1195
|
+
if (typeof Node < "u" && e instanceof Node) return R(pn(e), i);
|
|
1129
1196
|
if (Array.isArray(e)) {
|
|
1130
|
-
let a = e, o = a.slice(0, t.maxArrayLength).map((e) =>
|
|
1131
|
-
return a.length > t.maxArrayLength && o.push(
|
|
1197
|
+
let a = e, o = a.slice(0, t.maxArrayLength).map((e) => z(e, t, n, r + 1, i));
|
|
1198
|
+
return a.length > t.maxArrayLength && o.push(R(`[${String(a.length - t.maxArrayLength)} more items]`, i)), o;
|
|
1132
1199
|
}
|
|
1133
1200
|
let a = e.toJSON;
|
|
1134
|
-
if (typeof a == "function") return
|
|
1201
|
+
if (typeof a == "function") return z(a.call(e), t, n, r + 1, i);
|
|
1135
1202
|
let o = e, s = Object.keys(o), c = {}, l = 0;
|
|
1136
1203
|
for (let e of s) {
|
|
1137
1204
|
if (l >= t.maxAttributeCount) {
|
|
1138
|
-
c["…"] =
|
|
1205
|
+
c["…"] = R(`[${String(s.length - l)} more keys]`, i);
|
|
1139
1206
|
break;
|
|
1140
1207
|
}
|
|
1141
|
-
l++, i.bytes +=
|
|
1208
|
+
l++, i.bytes += B(e) + 4, c[e] = z(o[e], t, n, r + 1, i);
|
|
1142
1209
|
}
|
|
1143
1210
|
return c;
|
|
1144
1211
|
} catch (e) {
|
|
1145
|
-
return
|
|
1212
|
+
return R(`[Unserializable: ${e instanceof Error ? e.name : "error"}]`, i);
|
|
1146
1213
|
} finally {
|
|
1147
1214
|
n.delete(e);
|
|
1148
1215
|
}
|
|
1149
1216
|
}
|
|
1150
|
-
function
|
|
1217
|
+
function B(e) {
|
|
1151
1218
|
let t = 0;
|
|
1152
1219
|
for (let n = 0; n < e.length; n++) {
|
|
1153
1220
|
let r = e.charCodeAt(n);
|
|
@@ -1157,7 +1224,7 @@ function L(e) {
|
|
|
1157
1224
|
}
|
|
1158
1225
|
//#endregion
|
|
1159
1226
|
//#region src/transport/exit-flush.ts
|
|
1160
|
-
var
|
|
1227
|
+
var mn = class {
|
|
1161
1228
|
deps;
|
|
1162
1229
|
installed = !1;
|
|
1163
1230
|
onVisibility = () => {
|
|
@@ -1198,11 +1265,11 @@ var on = class {
|
|
|
1198
1265
|
if (!r || r.records.length === 0) return;
|
|
1199
1266
|
let i = t.guard("transport.serialize_failed", `the ${e} exit flush could not serialize its batch`, () => this.deps.config.serializer.serialize(r.records));
|
|
1200
1267
|
if (!i) return;
|
|
1201
|
-
if (
|
|
1202
|
-
|
|
1268
|
+
if (B(i.body) > 6e4) {
|
|
1269
|
+
nn(r, t);
|
|
1203
1270
|
return;
|
|
1204
1271
|
}
|
|
1205
|
-
n.searchParams.set(
|
|
1272
|
+
n.searchParams.set(be, r.id), n.searchParams.set(Ue, e);
|
|
1206
1273
|
let a = n.toString();
|
|
1207
1274
|
this.beacon(a, i.body) || this.keepaliveFetch(a, i.body, e);
|
|
1208
1275
|
}
|
|
@@ -1213,7 +1280,7 @@ var on = class {
|
|
|
1213
1280
|
beacon(e, t) {
|
|
1214
1281
|
return this.deps.diagnostics.guard("transport.http_error", "sendBeacon", () => {
|
|
1215
1282
|
let n = globalThis.navigator;
|
|
1216
|
-
return n?.sendBeacon ? n.sendBeacon(e, new Blob([t], { type:
|
|
1283
|
+
return n?.sendBeacon ? n.sendBeacon(e, new Blob([t], { type: c })) : !1;
|
|
1217
1284
|
}) === !0;
|
|
1218
1285
|
}
|
|
1219
1286
|
keepaliveFetch(e, t, n) {
|
|
@@ -1222,7 +1289,7 @@ var on = class {
|
|
|
1222
1289
|
fetch(e, {
|
|
1223
1290
|
method: "POST",
|
|
1224
1291
|
body: t,
|
|
1225
|
-
headers: { [
|
|
1292
|
+
headers: { [d]: c },
|
|
1226
1293
|
credentials: r.credentials,
|
|
1227
1294
|
keepalive: !0
|
|
1228
1295
|
}).catch((e) => {
|
|
@@ -1233,7 +1300,7 @@ var on = class {
|
|
|
1233
1300
|
};
|
|
1234
1301
|
//#endregion
|
|
1235
1302
|
//#region src/transport/compression.ts
|
|
1236
|
-
async function
|
|
1303
|
+
async function hn(e) {
|
|
1237
1304
|
let t = globalThis.CompressionStream;
|
|
1238
1305
|
if (t === void 0) return null;
|
|
1239
1306
|
let n = new Blob([e]).stream().pipeThrough(new t(ae)), r = await new Response(n).arrayBuffer();
|
|
@@ -1241,7 +1308,7 @@ async function sn(e) {
|
|
|
1241
1308
|
}
|
|
1242
1309
|
//#endregion
|
|
1243
1310
|
//#region src/transport/errors.ts
|
|
1244
|
-
var
|
|
1311
|
+
var V = class extends Error {
|
|
1245
1312
|
kind;
|
|
1246
1313
|
status;
|
|
1247
1314
|
retryAfterMs;
|
|
@@ -1250,7 +1317,7 @@ var R = class extends Error {
|
|
|
1250
1317
|
super(t), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
|
|
1251
1318
|
}
|
|
1252
1319
|
};
|
|
1253
|
-
function
|
|
1320
|
+
function gn(e) {
|
|
1254
1321
|
if (!e) return;
|
|
1255
1322
|
let t = Number(e);
|
|
1256
1323
|
if (Number.isFinite(t)) return Math.max(0, t * se);
|
|
@@ -1259,7 +1326,7 @@ function cn(e) {
|
|
|
1259
1326
|
}
|
|
1260
1327
|
//#endregion
|
|
1261
1328
|
//#region src/transport/http-transport.ts
|
|
1262
|
-
var
|
|
1329
|
+
var _n = class {
|
|
1263
1330
|
config;
|
|
1264
1331
|
diagnostics;
|
|
1265
1332
|
throttledUntil = 0;
|
|
@@ -1281,9 +1348,9 @@ var ln = class {
|
|
|
1281
1348
|
return;
|
|
1282
1349
|
}
|
|
1283
1350
|
let i = new Headers(await this.resolveHeaders());
|
|
1284
|
-
i.set(
|
|
1351
|
+
i.set(d, r.contentType), i.set(n, e.id), i.set(at, String(e.attempts));
|
|
1285
1352
|
let a = await this.encodeBody(r.body);
|
|
1286
|
-
typeof a != "string" && i.set(
|
|
1353
|
+
typeof a != "string" && i.set(fe, ae);
|
|
1287
1354
|
let o = await this.dispatch(i, a);
|
|
1288
1355
|
if (o.ok) {
|
|
1289
1356
|
this.throttledUntil = 0;
|
|
@@ -1293,12 +1360,13 @@ var ln = class {
|
|
|
1293
1360
|
}
|
|
1294
1361
|
async encodeBody(e) {
|
|
1295
1362
|
let { config: t } = this;
|
|
1296
|
-
return t.compression !== "gzip" ||
|
|
1363
|
+
return t.compression !== "gzip" || B(e) < t.compressionThresholdBytes ? e : await this.diagnostics.guardAsync("transport.http_error", "gzipping the payload", () => hn(e)) ?? e;
|
|
1297
1364
|
}
|
|
1298
1365
|
async dispatch(e, t) {
|
|
1299
1366
|
let { config: n } = this, r = new AbortController(), i = setTimeout(() => {
|
|
1300
1367
|
r.abort();
|
|
1301
1368
|
}, n.requestTimeoutMs);
|
|
1369
|
+
T(i);
|
|
1302
1370
|
try {
|
|
1303
1371
|
return await fetch(n.endpoint, {
|
|
1304
1372
|
method: "POST",
|
|
@@ -1309,28 +1377,28 @@ var ln = class {
|
|
|
1309
1377
|
cache: "no-store"
|
|
1310
1378
|
});
|
|
1311
1379
|
} catch {
|
|
1312
|
-
if (r.signal.aborted) throw new
|
|
1380
|
+
if (r.signal.aborted) throw new V("timeout", `request exceeded ${String(n.requestTimeoutMs)}ms`);
|
|
1313
1381
|
let e = globalThis.navigator?.onLine;
|
|
1314
|
-
throw new
|
|
1382
|
+
throw new V(e === !1 ? "offline" : "transient", "network error");
|
|
1315
1383
|
} finally {
|
|
1316
1384
|
clearTimeout(i);
|
|
1317
1385
|
}
|
|
1318
1386
|
}
|
|
1319
1387
|
async classify(e, t) {
|
|
1320
|
-
let n = e.status, r =
|
|
1388
|
+
let n = e.status, r = gn(e.headers.get(de));
|
|
1321
1389
|
if (n === 401 || n === 403) return this.diagnostics.report("transport.rejected_credentials", `server returned ${String(n)}. In a cross-origin iframe the session cookie is a third-party cookie and is very likely blocked. Forward to the platform document instead of promoting to sender, or issue the cookie with the Partitioned attribute.`, {
|
|
1322
1390
|
status: n,
|
|
1323
1391
|
endpoint: this.config.endpoint
|
|
1324
|
-
}), new
|
|
1325
|
-
if (n === 413) return new
|
|
1392
|
+
}), new V("permanent", `rejected with ${String(n)}`, n);
|
|
1393
|
+
if (n === 413) return new V("too_large", "payload too large", n, void 0, await this.readMaxBytes(e));
|
|
1326
1394
|
if (n === 429 || n === 503) {
|
|
1327
1395
|
let e = n === 429;
|
|
1328
|
-
return this.throttledUntil = Date.now() + (r ?? this.config.retry.baseDelayMs), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new
|
|
1396
|
+
return this.throttledUntil = Date.now() + (r ?? this.config.retry.baseDelayMs), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new V("throttled", e ? "throttled" : "service unavailable", n, r);
|
|
1329
1397
|
}
|
|
1330
|
-
return n === 408 || n >= 500 ? new
|
|
1398
|
+
return n === 408 || n >= 500 ? new V("transient", `server error ${String(n)}`, n) : (this.diagnostics.report("transport.dropped_permanent", `server rejected the batch with ${String(n)}, dropping it`, {
|
|
1331
1399
|
batchId: t,
|
|
1332
1400
|
status: n
|
|
1333
|
-
}), new
|
|
1401
|
+
}), new V("permanent", `rejected with ${String(n)}`, n));
|
|
1334
1402
|
}
|
|
1335
1403
|
async readMaxBytes(e) {
|
|
1336
1404
|
return this.diagnostics.guardAsync("transport.http_error", "reading the 413 body", async () => {
|
|
@@ -1342,75 +1410,7 @@ var ln = class {
|
|
|
1342
1410
|
let { headers: e } = this.config;
|
|
1343
1411
|
return e ? typeof e == "function" ? await this.diagnostics.guardAsync("transport.http_error", "headers() threw", () => Promise.resolve(e())) ?? {} : e : {};
|
|
1344
1412
|
}
|
|
1345
|
-
}
|
|
1346
|
-
//#endregion
|
|
1347
|
-
//#region src/utils/identity.ts
|
|
1348
|
-
function z(e) {
|
|
1349
|
-
let t = new Uint8Array(e);
|
|
1350
|
-
if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") crypto.getRandomValues(t);
|
|
1351
|
-
else for (let n = 0; n < e; n++) t[n] = Math.floor(Math.random() * 256);
|
|
1352
|
-
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1353
|
-
}
|
|
1354
|
-
function B() {
|
|
1355
|
-
try {
|
|
1356
|
-
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
1357
|
-
} catch {}
|
|
1358
|
-
return z(16);
|
|
1359
|
-
}
|
|
1360
|
-
function un(e, t, n) {
|
|
1361
|
-
return n.guard("storage.unavailable", `reading ${e}Storage`, () => (e === "local" ? localStorage : sessionStorage).getItem(t)) ?? null;
|
|
1362
|
-
}
|
|
1363
|
-
function V(e, t, n, r) {
|
|
1364
|
-
r.guard("storage.unavailable", `writing ${e}Storage`, () => {
|
|
1365
|
-
(e === "local" ? localStorage : sessionStorage).setItem(t, n);
|
|
1366
|
-
});
|
|
1367
|
-
}
|
|
1368
|
-
function dn(e) {
|
|
1369
|
-
let t = B(), n = Date.now(), r = B(), a = un("local", i, e);
|
|
1370
|
-
if (a) try {
|
|
1371
|
-
let e = JSON.parse(a);
|
|
1372
|
-
e.id && n - (e.lastSeenAt ?? 0) < 18e5 && (r = e.id);
|
|
1373
|
-
} catch {
|
|
1374
|
-
e.report("storage.degraded", "session record was not JSON, starting a new session");
|
|
1375
|
-
}
|
|
1376
|
-
let o = JSON.stringify({
|
|
1377
|
-
id: r,
|
|
1378
|
-
lastSeenAt: n
|
|
1379
|
-
});
|
|
1380
|
-
V("local", i, o, e);
|
|
1381
|
-
let s = un("session", "ui-observability.tab", e) ?? "";
|
|
1382
|
-
return s || (s = B(), V("session", te, s, e)), {
|
|
1383
|
-
sessionId: r,
|
|
1384
|
-
tabId: s,
|
|
1385
|
-
contextId: t
|
|
1386
|
-
};
|
|
1387
|
-
}
|
|
1388
|
-
var fn = 0;
|
|
1389
|
-
function pn(e, t) {
|
|
1390
|
-
let n = Date.now();
|
|
1391
|
-
if (n - fn < 6e4) return;
|
|
1392
|
-
fn = n;
|
|
1393
|
-
let r = JSON.stringify({
|
|
1394
|
-
id: e,
|
|
1395
|
-
lastSeenAt: n
|
|
1396
|
-
});
|
|
1397
|
-
V("local", i, r, t);
|
|
1398
|
-
}
|
|
1399
|
-
//#endregion
|
|
1400
|
-
//#region src/models/batch.ts
|
|
1401
|
-
function mn(e) {
|
|
1402
|
-
if (e.records.length < 2) return null;
|
|
1403
|
-
let t = Math.floor(e.records.length / 2), n = (t) => ({
|
|
1404
|
-
id: B(),
|
|
1405
|
-
records: t,
|
|
1406
|
-
createdAt: e.createdAt,
|
|
1407
|
-
attempts: e.attempts
|
|
1408
|
-
});
|
|
1409
|
-
return [n(e.records.slice(0, t)), n(e.records.slice(t))];
|
|
1410
|
-
}
|
|
1411
|
-
//#endregion
|
|
1412
|
-
//#region src/transport/retry-engine.ts
|
|
1413
|
-
var hn = class {
|
|
1413
|
+
}, vn = class {
|
|
1414
1414
|
storage;
|
|
1415
1415
|
transport;
|
|
1416
1416
|
diagnostics;
|
|
@@ -1441,7 +1441,7 @@ var hn = class {
|
|
|
1441
1441
|
let t = setTimeout(() => {
|
|
1442
1442
|
this.drain();
|
|
1443
1443
|
}, e);
|
|
1444
|
-
this.timer = t,
|
|
1444
|
+
this.timer = t, T(t);
|
|
1445
1445
|
}
|
|
1446
1446
|
clearTimer() {
|
|
1447
1447
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
@@ -1454,7 +1454,7 @@ var hn = class {
|
|
|
1454
1454
|
if (!this.draining) {
|
|
1455
1455
|
this.draining = !0;
|
|
1456
1456
|
try {
|
|
1457
|
-
await
|
|
1457
|
+
await Qt("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(this.config.retry.idleDelayMs);
|
|
1458
1458
|
} finally {
|
|
1459
1459
|
this.draining = !1;
|
|
1460
1460
|
}
|
|
@@ -1479,12 +1479,12 @@ var hn = class {
|
|
|
1479
1479
|
try {
|
|
1480
1480
|
return await this.transport.send(e), await this.storage.remove(e.id), this.attempt = 0, !0;
|
|
1481
1481
|
} catch (t) {
|
|
1482
|
-
let n = t instanceof
|
|
1482
|
+
let n = t instanceof V ? t : void 0;
|
|
1483
1483
|
return n?.kind === "permanent" ? (await this.storage.remove(e.id), !0) : n?.kind === "too_large" ? (await this.splitStored(e, n.maxBytes), !0) : n?.kind === "offline" ? (this.schedule(this.config.retry.idleDelayMs), !1) : (await this.storage.bumpAttempts(e.id, e.attempts + 1), this.attempt++, this.schedule(n?.retryAfterMs ?? this.backoffMs()), !1);
|
|
1484
1484
|
}
|
|
1485
1485
|
}
|
|
1486
1486
|
async splitStored(e, t) {
|
|
1487
|
-
let n =
|
|
1487
|
+
let n = Zt(e);
|
|
1488
1488
|
if (await this.storage.remove(e.id), !n) {
|
|
1489
1489
|
this.diagnostics.report("transport.dropped_permanent", "a single record exceeds the server limit and was dropped", {
|
|
1490
1490
|
batchId: e.id,
|
|
@@ -1499,14 +1499,14 @@ var hn = class {
|
|
|
1499
1499
|
});
|
|
1500
1500
|
for (let e of n) await this.storage.save(e);
|
|
1501
1501
|
}
|
|
1502
|
-
},
|
|
1502
|
+
}, yn = {
|
|
1503
1503
|
TRACE: "debug",
|
|
1504
1504
|
DEBUG: "debug",
|
|
1505
1505
|
INFO: "info",
|
|
1506
1506
|
WARN: "warn",
|
|
1507
1507
|
ERROR: "error",
|
|
1508
1508
|
FATAL: "error"
|
|
1509
|
-
},
|
|
1509
|
+
}, bn = class {
|
|
1510
1510
|
enabled;
|
|
1511
1511
|
minLevel;
|
|
1512
1512
|
constructor(e, t) {
|
|
@@ -1516,23 +1516,23 @@ var hn = class {
|
|
|
1516
1516
|
this.enabled = e, this.minLevel = t;
|
|
1517
1517
|
}
|
|
1518
1518
|
write(e, t, n) {
|
|
1519
|
-
if (!this.enabled ||
|
|
1520
|
-
let
|
|
1519
|
+
if (!this.enabled || m[e] < m[this.minLevel] || typeof console > "u") return;
|
|
1520
|
+
let r = `%c${he}%c ${e}`;
|
|
1521
1521
|
if (n === void 0) {
|
|
1522
|
-
console[
|
|
1522
|
+
console[yn[e]](r, i, "", t);
|
|
1523
1523
|
return;
|
|
1524
1524
|
}
|
|
1525
|
-
console[
|
|
1525
|
+
console[yn[e]](r, i, "", t, n);
|
|
1526
1526
|
}
|
|
1527
1527
|
}, H = null;
|
|
1528
1528
|
function U(e, t) {
|
|
1529
1529
|
let n = e[t];
|
|
1530
1530
|
return n !== void 0 && e instanceof n;
|
|
1531
1531
|
}
|
|
1532
|
-
function
|
|
1532
|
+
function xn(e) {
|
|
1533
1533
|
if (H) return H;
|
|
1534
1534
|
let t = globalThis, n = t.navigator?.userAgent ?? "", r = "browser", i, a, o = !1, s = t.fin?.me;
|
|
1535
|
-
return U(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", o = !0) : U(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", o = !0) : U(t, "WorkerGlobalScope") ? (r = "web_worker", o = !0) : s === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 ||
|
|
1535
|
+
return U(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", o = !0) : U(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", o = !0) : U(t, "WorkerGlobalScope") ? (r = "web_worker", o = !0) : s === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 || Sn(n) ? r = "mobile_webview" : typeof document > "u" && typeof process < "u" && (r = "node") : (r = Pe.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "reading fin.me.identity", () => {
|
|
1536
1536
|
let e = s.identity;
|
|
1537
1537
|
i = e?.uuid, a = e?.name;
|
|
1538
1538
|
})), H = {
|
|
@@ -1541,13 +1541,13 @@ function vn(e) {
|
|
|
1541
1541
|
openfinName: a,
|
|
1542
1542
|
userAgent: n,
|
|
1543
1543
|
isWorker: o,
|
|
1544
|
-
isTopLevelDocument:
|
|
1544
|
+
isTopLevelDocument: Cn()
|
|
1545
1545
|
}, H;
|
|
1546
1546
|
}
|
|
1547
|
-
function
|
|
1548
|
-
return
|
|
1547
|
+
function Sn(t) {
|
|
1548
|
+
return Ye.test(t) ? !0 : (h.test(t) || ge.test(t) && e.test(t)) && t.includes("AppleWebKit") && !t.includes("Safari/");
|
|
1549
1549
|
}
|
|
1550
|
-
function
|
|
1550
|
+
function Cn() {
|
|
1551
1551
|
if (typeof window > "u") return !1;
|
|
1552
1552
|
try {
|
|
1553
1553
|
return window.self === window.top;
|
|
@@ -1555,7 +1555,7 @@ function bn() {
|
|
|
1555
1555
|
return !1;
|
|
1556
1556
|
}
|
|
1557
1557
|
}
|
|
1558
|
-
function
|
|
1558
|
+
function wn() {
|
|
1559
1559
|
try {
|
|
1560
1560
|
return typeof location < "u" ? location.href : "";
|
|
1561
1561
|
} catch {
|
|
@@ -1564,7 +1564,7 @@ function xn() {
|
|
|
1564
1564
|
}
|
|
1565
1565
|
//#endregion
|
|
1566
1566
|
//#region src/utils/sequence.ts
|
|
1567
|
-
var
|
|
1567
|
+
var Tn = class {
|
|
1568
1568
|
value = 0;
|
|
1569
1569
|
next() {
|
|
1570
1570
|
return ++this.value;
|
|
@@ -1575,61 +1575,61 @@ var Sn = class {
|
|
|
1575
1575
|
};
|
|
1576
1576
|
//#endregion
|
|
1577
1577
|
//#region src/utils/tracing.ts
|
|
1578
|
-
function
|
|
1579
|
-
return
|
|
1578
|
+
function En() {
|
|
1579
|
+
return j(16);
|
|
1580
1580
|
}
|
|
1581
|
-
function
|
|
1582
|
-
return
|
|
1581
|
+
function Dn() {
|
|
1582
|
+
return j(8);
|
|
1583
1583
|
}
|
|
1584
|
-
function
|
|
1584
|
+
function On() {
|
|
1585
1585
|
return {
|
|
1586
|
-
traceId:
|
|
1587
|
-
spanId:
|
|
1586
|
+
traceId: En(),
|
|
1587
|
+
spanId: Dn(),
|
|
1588
1588
|
traceFlags: 1,
|
|
1589
1589
|
startedAt: Date.now()
|
|
1590
1590
|
};
|
|
1591
1591
|
}
|
|
1592
|
-
function
|
|
1592
|
+
function kn(e) {
|
|
1593
1593
|
return {
|
|
1594
1594
|
traceId: e.traceId,
|
|
1595
1595
|
spanId: e.spanId,
|
|
1596
1596
|
traceFlags: e.traceFlags
|
|
1597
1597
|
};
|
|
1598
1598
|
}
|
|
1599
|
-
var
|
|
1599
|
+
var An = class {
|
|
1600
1600
|
diagnostics;
|
|
1601
1601
|
maxAgeMs;
|
|
1602
|
-
ambient =
|
|
1603
|
-
constructor(e, t =
|
|
1602
|
+
ambient = On();
|
|
1603
|
+
constructor(e, t = ce) {
|
|
1604
1604
|
this.diagnostics = e, this.maxAgeMs = t;
|
|
1605
1605
|
}
|
|
1606
1606
|
resolve() {
|
|
1607
1607
|
let e = this.diagnostics.guard("trace.otel_failed", "reading the active OpenTelemetry span", () => {
|
|
1608
|
-
let e =
|
|
1608
|
+
let e = ut.getActiveSpan();
|
|
1609
1609
|
if (e === void 0) return;
|
|
1610
1610
|
let t = e.spanContext();
|
|
1611
|
-
if (
|
|
1611
|
+
if (ct(t)) return {
|
|
1612
1612
|
traceId: t.traceId,
|
|
1613
1613
|
spanId: t.spanId,
|
|
1614
1614
|
traceFlags: t.traceFlags
|
|
1615
1615
|
};
|
|
1616
1616
|
});
|
|
1617
|
-
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"),
|
|
1617
|
+
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), kn(this.ambient)) : e;
|
|
1618
1618
|
}
|
|
1619
1619
|
rotate(e) {
|
|
1620
|
-
return this.ambient =
|
|
1620
|
+
return this.ambient = On(), kn(this.ambient);
|
|
1621
1621
|
}
|
|
1622
1622
|
headers() {
|
|
1623
1623
|
let e = {};
|
|
1624
1624
|
if (this.diagnostics.guard("trace.otel_failed", "injecting OpenTelemetry headers", () => {
|
|
1625
|
-
|
|
1625
|
+
lt.inject(st.active(), e);
|
|
1626
1626
|
}), !e.traceparent) {
|
|
1627
1627
|
let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
|
|
1628
1628
|
e.traceparent = `00-${t.traceId}-${t.spanId}-${n}`;
|
|
1629
1629
|
}
|
|
1630
1630
|
return e;
|
|
1631
1631
|
}
|
|
1632
|
-
},
|
|
1632
|
+
}, jn = class {
|
|
1633
1633
|
buffer;
|
|
1634
1634
|
pointer = 0;
|
|
1635
1635
|
filled = !1;
|
|
@@ -1653,12 +1653,18 @@ var Dn = class {
|
|
|
1653
1653
|
clear() {
|
|
1654
1654
|
this.buffer = Array(this.capacity), this.pointer = 0, this.filled = !1;
|
|
1655
1655
|
}
|
|
1656
|
-
}
|
|
1656
|
+
};
|
|
1657
|
+
//#endregion
|
|
1658
|
+
//#region src/transport/serializers/ecs.ts
|
|
1659
|
+
function Mn(e) {
|
|
1660
|
+
return De.test(e) ? Number(BigInt(e) / Xe) : Date.now();
|
|
1661
|
+
}
|
|
1662
|
+
var Nn = {
|
|
1657
1663
|
name: "ecs",
|
|
1658
1664
|
serialize(e) {
|
|
1659
1665
|
return {
|
|
1660
1666
|
body: `${e.map((e) => {
|
|
1661
|
-
let t =
|
|
1667
|
+
let t = Mn(e.timeUnixNano);
|
|
1662
1668
|
return JSON.stringify({
|
|
1663
1669
|
"@timestamp": new Date(t).toISOString(),
|
|
1664
1670
|
message: e.body,
|
|
@@ -1666,11 +1672,11 @@ var Dn = class {
|
|
|
1666
1672
|
trace: { id: e.traceId },
|
|
1667
1673
|
span: { id: e.spanId },
|
|
1668
1674
|
service: {
|
|
1669
|
-
name: e.resource[
|
|
1670
|
-
version: e.resource[
|
|
1671
|
-
environment: e.resource[
|
|
1675
|
+
name: e.resource[Be],
|
|
1676
|
+
version: e.resource[Me],
|
|
1677
|
+
environment: e.resource[Qe]
|
|
1672
1678
|
},
|
|
1673
|
-
user_agent: { original: e.resource[
|
|
1679
|
+
user_agent: { original: e.resource[we] },
|
|
1674
1680
|
url: { full: e.attributes["url.full"] ?? e.attributes["page.url"] },
|
|
1675
1681
|
labels: {
|
|
1676
1682
|
...e.resource,
|
|
@@ -1684,13 +1690,13 @@ var Dn = class {
|
|
|
1684
1690
|
};
|
|
1685
1691
|
//#endregion
|
|
1686
1692
|
//#region src/transport/serializers/otlp.ts
|
|
1687
|
-
function
|
|
1688
|
-
return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(
|
|
1693
|
+
function Pn(e) {
|
|
1694
|
+
return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(Pn).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: W(e) } } : null;
|
|
1689
1695
|
}
|
|
1690
1696
|
function W(e) {
|
|
1691
1697
|
let t = [];
|
|
1692
1698
|
for (let [n, r] of Object.entries(e)) {
|
|
1693
|
-
let e =
|
|
1699
|
+
let e = Pn(r);
|
|
1694
1700
|
e && t.push({
|
|
1695
1701
|
key: n,
|
|
1696
1702
|
value: e
|
|
@@ -1698,19 +1704,19 @@ function W(e) {
|
|
|
1698
1704
|
}
|
|
1699
1705
|
return t;
|
|
1700
1706
|
}
|
|
1701
|
-
var
|
|
1702
|
-
function
|
|
1703
|
-
let t =
|
|
1707
|
+
var Fn = /* @__PURE__ */ new WeakMap();
|
|
1708
|
+
function In(e) {
|
|
1709
|
+
let t = Fn.get(e);
|
|
1704
1710
|
if (t !== void 0) return t;
|
|
1705
1711
|
let n = JSON.stringify(e);
|
|
1706
|
-
return
|
|
1712
|
+
return Fn.set(e, n), n;
|
|
1707
1713
|
}
|
|
1708
1714
|
var G = {
|
|
1709
|
-
name:
|
|
1715
|
+
name: a,
|
|
1710
1716
|
serialize(e) {
|
|
1711
1717
|
let t = /* @__PURE__ */ new Map();
|
|
1712
1718
|
for (let n of e) {
|
|
1713
|
-
let e =
|
|
1719
|
+
let e = In(n.resource), r = t.get(e);
|
|
1714
1720
|
if (r) {
|
|
1715
1721
|
r.records.push(n);
|
|
1716
1722
|
continue;
|
|
@@ -1724,8 +1730,8 @@ var G = {
|
|
|
1724
1730
|
resource: { attributes: W(e.resource) },
|
|
1725
1731
|
scopeLogs: [{
|
|
1726
1732
|
scope: {
|
|
1727
|
-
name:
|
|
1728
|
-
version:
|
|
1733
|
+
name: p,
|
|
1734
|
+
version: ee
|
|
1729
1735
|
},
|
|
1730
1736
|
logRecords: e.records.map((e) => ({
|
|
1731
1737
|
timeUnixNano: e.timeUnixNano,
|
|
@@ -1742,93 +1748,93 @@ var G = {
|
|
|
1742
1748
|
}));
|
|
1743
1749
|
return {
|
|
1744
1750
|
body: JSON.stringify({ resourceLogs: n }),
|
|
1745
|
-
contentType:
|
|
1751
|
+
contentType: tt
|
|
1746
1752
|
};
|
|
1747
1753
|
}
|
|
1748
1754
|
};
|
|
1749
1755
|
//#endregion
|
|
1750
1756
|
//#region src/core/config.ts
|
|
1751
|
-
function
|
|
1757
|
+
function Ln(e) {
|
|
1752
1758
|
return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
|
|
1753
1759
|
}
|
|
1754
|
-
function
|
|
1755
|
-
return e === void 0 ? t ?? G : e === "otlp" ? G : e === "ecs" ?
|
|
1760
|
+
function Rn(e, t, n) {
|
|
1761
|
+
return e === void 0 ? t ?? G : e === "otlp" ? G : e === "ecs" ? Nn : Ln(e) ? e : (n.report("config.invalid", `serializer must be "${a}", "ecs" or an implementation`), G);
|
|
1756
1762
|
}
|
|
1757
|
-
function
|
|
1758
|
-
let
|
|
1759
|
-
...
|
|
1763
|
+
function zn(e, t, n) {
|
|
1764
|
+
let i = n ?? o, a = {
|
|
1765
|
+
...i,
|
|
1760
1766
|
...e,
|
|
1761
|
-
serializer:
|
|
1767
|
+
serializer: Rn(e.serializer, n?.serializer, t),
|
|
1762
1768
|
streams: {
|
|
1763
1769
|
logs: {
|
|
1764
|
-
...
|
|
1770
|
+
...i.streams.logs,
|
|
1765
1771
|
...e.streams?.logs
|
|
1766
1772
|
},
|
|
1767
1773
|
metrics: {
|
|
1768
|
-
...
|
|
1774
|
+
...i.streams.metrics,
|
|
1769
1775
|
...e.streams?.metrics
|
|
1770
1776
|
}
|
|
1771
1777
|
},
|
|
1772
1778
|
storage: {
|
|
1773
|
-
...
|
|
1779
|
+
...i.storage,
|
|
1774
1780
|
...e.storage
|
|
1775
1781
|
},
|
|
1776
1782
|
retry: {
|
|
1777
|
-
...
|
|
1783
|
+
...i.retry,
|
|
1778
1784
|
...e.retry
|
|
1779
1785
|
},
|
|
1780
1786
|
sampling: {
|
|
1781
|
-
...
|
|
1787
|
+
...i.sampling,
|
|
1782
1788
|
...e.sampling,
|
|
1783
1789
|
rates: {
|
|
1784
|
-
...
|
|
1790
|
+
...i.sampling.rates,
|
|
1785
1791
|
...e.sampling?.rates
|
|
1786
1792
|
}
|
|
1787
1793
|
},
|
|
1788
1794
|
journey: {
|
|
1789
|
-
...
|
|
1795
|
+
...i.journey,
|
|
1790
1796
|
...e.journey
|
|
1791
1797
|
},
|
|
1792
1798
|
bus: {
|
|
1793
|
-
...
|
|
1799
|
+
...i.bus,
|
|
1794
1800
|
...e.bus
|
|
1795
1801
|
},
|
|
1796
1802
|
capture: {
|
|
1797
|
-
...
|
|
1803
|
+
...i.capture,
|
|
1798
1804
|
...e.capture
|
|
1799
1805
|
},
|
|
1800
1806
|
limits: {
|
|
1801
|
-
...
|
|
1807
|
+
...i.limits,
|
|
1802
1808
|
...e.limits
|
|
1803
1809
|
},
|
|
1804
1810
|
console: {
|
|
1805
|
-
...
|
|
1811
|
+
...i.console,
|
|
1806
1812
|
...e.console
|
|
1807
1813
|
}
|
|
1808
1814
|
};
|
|
1809
|
-
if (!
|
|
1815
|
+
if (!a.endpoint) t.report("config.invalid", "endpoint is missing. Records will be built and dropped, never sent.");
|
|
1810
1816
|
else try {
|
|
1811
|
-
new URL(
|
|
1817
|
+
new URL(a.endpoint);
|
|
1812
1818
|
} catch (e) {
|
|
1813
|
-
t.report("config.invalid", `endpoint is not a valid absolute URL: ${
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
let
|
|
1817
|
-
(typeof
|
|
1818
|
-
let
|
|
1819
|
-
for (let [e, n] of
|
|
1820
|
-
|
|
1821
|
-
let
|
|
1822
|
-
for (let n of Object.keys(e))
|
|
1823
|
-
return
|
|
1824
|
-
}
|
|
1825
|
-
function
|
|
1819
|
+
t.report("config.invalid", `endpoint is not a valid absolute URL: ${a.endpoint}`, void 0, e);
|
|
1820
|
+
}
|
|
1821
|
+
a.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record will report service.name as '${pe}'.`), pe);
|
|
1822
|
+
let s = a.sampling.defaultRate;
|
|
1823
|
+
(typeof s != "number" || s < 0 || s > 1) && (t.report("config.invalid", `sampling.defaultRate must be 0..1, got ${String(s)}`), a.sampling.defaultRate = 1);
|
|
1824
|
+
let c = Object.entries(a.sampling.rates);
|
|
1825
|
+
for (let [e, n] of c) (typeof n != "number" || n < 0 || n > 1) && (t.report("config.invalid", `sampling.rates["${e}"] must be 0..1, got ${String(n)}`), a.sampling.rates[e] = 1);
|
|
1826
|
+
a.capture.ignoreUrls = a.capture.ignoreUrls.filter((e) => e !== n?.endpoint), a.endpoint && !a.capture.ignoreUrls.includes(a.endpoint) && (a.capture.ignoreUrls = [...a.capture.ignoreUrls, a.endpoint]);
|
|
1827
|
+
let l = /* @__PURE__ */ new Set([...Object.keys(o), ...r]);
|
|
1828
|
+
for (let n of Object.keys(e)) l.has(n) || t.report("config.invalid", `unknown config key "${n}", ignored. Typo?`);
|
|
1829
|
+
return a;
|
|
1830
|
+
}
|
|
1831
|
+
function Bn(e, t) {
|
|
1826
1832
|
for (let n of Object.keys(t)) le.includes(n) || Object.assign(e, { [n]: t[n] });
|
|
1827
1833
|
for (let n of le) Object.assign(e[n], t[n]);
|
|
1828
1834
|
}
|
|
1829
1835
|
//#endregion
|
|
1830
1836
|
//#region src/core/context.ts
|
|
1831
|
-
var
|
|
1837
|
+
var Vn = class {
|
|
1832
1838
|
map = /* @__PURE__ */ new Map();
|
|
1833
1839
|
set(e, t) {
|
|
1834
1840
|
this.map.set(e, t);
|
|
@@ -1848,12 +1854,12 @@ var Ln = class {
|
|
|
1848
1854
|
getAll() {
|
|
1849
1855
|
return Object.fromEntries(this.map);
|
|
1850
1856
|
}
|
|
1851
|
-
},
|
|
1857
|
+
}, Hn = class {
|
|
1852
1858
|
handler;
|
|
1853
1859
|
throttleMs;
|
|
1854
1860
|
counters = /* @__PURE__ */ new Map();
|
|
1855
1861
|
lastEmitted = /* @__PURE__ */ new Map();
|
|
1856
|
-
constructor(e, t =
|
|
1862
|
+
constructor(e, t = Le) {
|
|
1857
1863
|
this.handler = e, this.throttleMs = t;
|
|
1858
1864
|
}
|
|
1859
1865
|
setHandler(e) {
|
|
@@ -1910,13 +1916,13 @@ function K(e, t) {
|
|
|
1910
1916
|
let n = Reflect.get(e, t);
|
|
1911
1917
|
return typeof n == "string" && n !== "" ? n : void 0;
|
|
1912
1918
|
}
|
|
1913
|
-
function
|
|
1919
|
+
function Un(e, t) {
|
|
1914
1920
|
let n = Reflect.get(e, t);
|
|
1915
1921
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
1916
1922
|
}
|
|
1917
|
-
function
|
|
1923
|
+
function Wn(e) {
|
|
1918
1924
|
if (typeof e != "object" || !e) return null;
|
|
1919
|
-
let t = K(e, "id"), n = K(e, "name"), r =
|
|
1925
|
+
let t = K(e, "id"), n = K(e, "name"), r = Un(e, "startedAt");
|
|
1920
1926
|
return t === void 0 || n === void 0 || r === void 0 ? null : {
|
|
1921
1927
|
id: t,
|
|
1922
1928
|
name: n,
|
|
@@ -1925,27 +1931,35 @@ function Bn(e) {
|
|
|
1925
1931
|
ownerContextId: K(e, "ownerContextId") ?? ""
|
|
1926
1932
|
};
|
|
1927
1933
|
}
|
|
1928
|
-
function
|
|
1934
|
+
function Gn(e) {
|
|
1929
1935
|
if (typeof e != "object" || !e) return null;
|
|
1930
1936
|
let t = K(e, "i"), n = K(e, "n");
|
|
1931
1937
|
return t === void 0 || n === void 0 ? null : {
|
|
1932
1938
|
id: t,
|
|
1933
1939
|
name: n,
|
|
1934
|
-
startedAt:
|
|
1940
|
+
startedAt: Un(e, "s") ?? Date.now(),
|
|
1935
1941
|
parentId: void 0,
|
|
1936
1942
|
ownerContextId: ""
|
|
1937
1943
|
};
|
|
1938
1944
|
}
|
|
1939
|
-
function
|
|
1945
|
+
function Kn(e) {
|
|
1940
1946
|
let t = JSON.stringify({
|
|
1941
1947
|
i: e.id,
|
|
1942
1948
|
n: e.name.slice(0, 64),
|
|
1943
1949
|
s: e.startedAt
|
|
1944
1950
|
}), n = new TextEncoder().encode(t), r = "";
|
|
1945
1951
|
for (let e of n) r += String.fromCharCode(e);
|
|
1946
|
-
return btoa(r).replace(
|
|
1952
|
+
return btoa(r).replace(ke, "-").replace(_e, "_").replace(je, "");
|
|
1947
1953
|
}
|
|
1948
|
-
|
|
1954
|
+
function qn(e, t) {
|
|
1955
|
+
let n = new Promise((e, n) => {
|
|
1956
|
+
T(setTimeout(() => {
|
|
1957
|
+
n(/* @__PURE__ */ Error(`timed out after ${String(t)}ms`));
|
|
1958
|
+
}, t));
|
|
1959
|
+
});
|
|
1960
|
+
return Promise.race([e, n]);
|
|
1961
|
+
}
|
|
1962
|
+
var Jn = class {
|
|
1949
1963
|
options;
|
|
1950
1964
|
diagnostics;
|
|
1951
1965
|
contextId;
|
|
@@ -1961,14 +1975,14 @@ var Un = class {
|
|
|
1961
1975
|
async bootstrap() {
|
|
1962
1976
|
let e = this.readUrlToken();
|
|
1963
1977
|
if (e && this.adopt(e, "url")) return;
|
|
1964
|
-
let t = this.diagnostics.guard("storage.unavailable", "reading the persisted journey", () => sessionStorage.getItem(
|
|
1978
|
+
let t = this.diagnostics.guard("storage.unavailable", "reading the persisted journey", () => sessionStorage.getItem(x));
|
|
1965
1979
|
if (t && this.restore(t)) return;
|
|
1966
1980
|
let n = await this.readOpenFinToken();
|
|
1967
1981
|
n !== null && this.adopt(n, "openfin.customData");
|
|
1968
1982
|
}
|
|
1969
1983
|
start(e, t = {}) {
|
|
1970
1984
|
let n = {
|
|
1971
|
-
id: t.id ??
|
|
1985
|
+
id: t.id ?? M(),
|
|
1972
1986
|
name: e,
|
|
1973
1987
|
startedAt: Date.now(),
|
|
1974
1988
|
parentId: t.parent ? this.journey?.id : void 0,
|
|
@@ -1986,7 +2000,7 @@ var Un = class {
|
|
|
1986
2000
|
getToken() {
|
|
1987
2001
|
let e = this.journey;
|
|
1988
2002
|
if (e === null) return;
|
|
1989
|
-
let t =
|
|
2003
|
+
let t = Kn(e);
|
|
1990
2004
|
if (t.length > 256) {
|
|
1991
2005
|
this.diagnostics.report("journey.token_too_large", "journey token exceeded the size cap and was not issued", { length: t.length });
|
|
1992
2006
|
return;
|
|
@@ -2010,7 +2024,7 @@ var Un = class {
|
|
|
2010
2024
|
this.clearTimer();
|
|
2011
2025
|
}
|
|
2012
2026
|
restore(e) {
|
|
2013
|
-
let t =
|
|
2027
|
+
let t = Wn(this.diagnostics.guard("storage.degraded", "parsing the persisted journey", () => JSON.parse(e)));
|
|
2014
2028
|
return t === null ? !1 : Date.now() - t.startedAt > this.options.maxAgeMs ? (this.diagnostics.report("journey.expired", "discarded a persisted journey older than maxAgeMs", { name: t.name }), this.clearStored(), !1) : (this.setJourney(t), this.diagnostics.report("journey.adopted", `resumed journey "${t.name}"`, {
|
|
2015
2029
|
source: "sessionStorage",
|
|
2016
2030
|
journeyId: t.id
|
|
@@ -2018,22 +2032,22 @@ var Un = class {
|
|
|
2018
2032
|
}
|
|
2019
2033
|
decodeToken(e) {
|
|
2020
2034
|
return this.diagnostics.guard("config.invalid", "decoding a seeded journey token", () => {
|
|
2021
|
-
let t = e.replace(
|
|
2022
|
-
return
|
|
2035
|
+
let t = e.replace(We, "+").replace(ze, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
|
|
2036
|
+
return Gn(JSON.parse(new TextDecoder().decode(i)));
|
|
2023
2037
|
}) ?? null;
|
|
2024
2038
|
}
|
|
2025
2039
|
setJourney(e) {
|
|
2026
2040
|
if (this.journey = e, this.clearTimer(), this.diagnostics.guard("storage.unavailable", "persisting the journey", () => {
|
|
2027
|
-
e === null ? sessionStorage.removeItem(
|
|
2041
|
+
e === null ? sessionStorage.removeItem(x) : sessionStorage.setItem(x, JSON.stringify(e));
|
|
2028
2042
|
}), e === null) return;
|
|
2029
2043
|
let t = Math.max(this.options.maxAgeMs - (Date.now() - e.startedAt), 0), n = setTimeout(() => {
|
|
2030
2044
|
this.diagnostics.report("journey.expired", `journey "${e.name}" hit maxAgeMs and was ended automatically`, { journeyId: e.id }), this.journey = null, this.expiryTimer = null, this.clearStored();
|
|
2031
2045
|
}, t);
|
|
2032
|
-
this.expiryTimer = n,
|
|
2046
|
+
this.expiryTimer = n, T(n);
|
|
2033
2047
|
}
|
|
2034
2048
|
clearStored() {
|
|
2035
2049
|
this.diagnostics.guard("storage.unavailable", "clearing the persisted journey", () => {
|
|
2036
|
-
sessionStorage.removeItem(
|
|
2050
|
+
sessionStorage.removeItem(x);
|
|
2037
2051
|
});
|
|
2038
2052
|
}
|
|
2039
2053
|
clearTimer() {
|
|
@@ -2045,37 +2059,37 @@ var Un = class {
|
|
|
2045
2059
|
async readOpenFinToken() {
|
|
2046
2060
|
let e = globalThis.fin?.me, t = e?.getOptions;
|
|
2047
2061
|
if (t === void 0) return null;
|
|
2048
|
-
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "reading fin.me.getOptions()", () => t.call(e)))?.customData?.[
|
|
2062
|
+
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "reading fin.me.getOptions()", () => qn(t.call(e), qe)))?.customData?.[Ve];
|
|
2049
2063
|
return typeof n == "string" ? n : null;
|
|
2050
2064
|
}
|
|
2051
2065
|
};
|
|
2052
2066
|
//#endregion
|
|
2053
2067
|
//#region src/core/sampling.ts
|
|
2054
|
-
function
|
|
2055
|
-
let t =
|
|
2056
|
-
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t,
|
|
2068
|
+
function Yn(e) {
|
|
2069
|
+
let t = f;
|
|
2070
|
+
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, g);
|
|
2057
2071
|
return t >>> 0;
|
|
2058
2072
|
}
|
|
2059
2073
|
function q(e, t) {
|
|
2060
2074
|
let n = e.attributes[t];
|
|
2061
2075
|
return typeof n == "string" ? n : "";
|
|
2062
2076
|
}
|
|
2063
|
-
function
|
|
2077
|
+
function Xn(e, t) {
|
|
2064
2078
|
let { rates: n, defaultRate: r } = t.sampling, i, a = -1;
|
|
2065
2079
|
for (let [t, r] of Object.entries(n)) (e === t || e.startsWith(`${t}.`)) && t.length > a && (i = r, a = t.length);
|
|
2066
2080
|
return i ?? r;
|
|
2067
2081
|
}
|
|
2068
|
-
function
|
|
2082
|
+
function Zn(e, t) {
|
|
2069
2083
|
if (e.severityText === "ERROR" || e.severityText === "FATAL" || t.sampling.alwaysSampleTypes.includes(q(e, "log.type"))) return !0;
|
|
2070
|
-
let n =
|
|
2071
|
-
return n >= 1 ? !0 : n <= 0 ? !1 :
|
|
2084
|
+
let n = Xn(q(e, b), t);
|
|
2085
|
+
return n >= 1 ? !0 : n <= 0 ? !1 : Yn(q(e, "journey.id") || e.traceId) / ot < n;
|
|
2072
2086
|
}
|
|
2073
2087
|
//#endregion
|
|
2074
2088
|
//#region src/core/pipeline.ts
|
|
2075
|
-
function
|
|
2076
|
-
return e.attributes[
|
|
2089
|
+
function Qn(e) {
|
|
2090
|
+
return e.attributes[y] === me;
|
|
2077
2091
|
}
|
|
2078
|
-
var
|
|
2092
|
+
var $n = class {
|
|
2079
2093
|
config;
|
|
2080
2094
|
name;
|
|
2081
2095
|
diagnostics;
|
|
@@ -2096,25 +2110,25 @@ var Jn = class {
|
|
|
2096
2110
|
let e = this.pending;
|
|
2097
2111
|
return this.pending = [], e;
|
|
2098
2112
|
}
|
|
2099
|
-
},
|
|
2113
|
+
}, er = class {
|
|
2100
2114
|
config;
|
|
2101
2115
|
transport;
|
|
2102
2116
|
storage;
|
|
2103
2117
|
retry;
|
|
2104
2118
|
diagnostics;
|
|
2105
|
-
records$ = new
|
|
2119
|
+
records$ = new ft();
|
|
2106
2120
|
streams;
|
|
2107
2121
|
subscription = null;
|
|
2108
2122
|
unconfirmed = /* @__PURE__ */ new Map();
|
|
2109
2123
|
stopped = !1;
|
|
2110
2124
|
constructor(e, t, n, r, i) {
|
|
2111
2125
|
this.config = e, this.transport = t, this.storage = n, this.retry = r, this.diagnostics = i, this.streams = {
|
|
2112
|
-
logs: new
|
|
2113
|
-
metrics: new
|
|
2126
|
+
logs: new $n(e, "logs", i),
|
|
2127
|
+
metrics: new $n(e, "metrics", i)
|
|
2114
2128
|
}, this.subscribe();
|
|
2115
2129
|
}
|
|
2116
2130
|
push(e) {
|
|
2117
|
-
this.stopped || (e.observedTimeUnixNano =
|
|
2131
|
+
this.stopped || (e.observedTimeUnixNano = Gt(), this.records$.next(e));
|
|
2118
2132
|
}
|
|
2119
2133
|
drainPending() {
|
|
2120
2134
|
let e = [
|
|
@@ -2123,7 +2137,7 @@ var Jn = class {
|
|
|
2123
2137
|
...this.streams.logs.take()
|
|
2124
2138
|
];
|
|
2125
2139
|
return this.unconfirmed.clear(), e.length === 0 ? null : {
|
|
2126
|
-
id:
|
|
2140
|
+
id: M(),
|
|
2127
2141
|
records: e,
|
|
2128
2142
|
createdAt: Date.now(),
|
|
2129
2143
|
attempts: 0
|
|
@@ -2137,19 +2151,19 @@ var Jn = class {
|
|
|
2137
2151
|
}
|
|
2138
2152
|
subscribe() {
|
|
2139
2153
|
if (this.stopped) return;
|
|
2140
|
-
let [e, t] =
|
|
2141
|
-
this.subscription =
|
|
2154
|
+
let [e, t] = xt(this.records$, Qn);
|
|
2155
|
+
this.subscription = vt(this.batches(e, this.streams.metrics), this.batches(t, this.streams.logs)).pipe(ht((e) => (this.diagnostics.report("pipeline.crashed", "the pipeline errored and was restarted", void 0, e), this.subscribe(), dt)), bt(pt), yt((e) => gt(this.dispatch(e)).pipe(ht((t) => (this.diagnostics.report("pipeline.crashed", "dispatch rejected, which it is written never to do", { batchId: e.id }, t), dt))), this.config.maxConcurrentRequests)).subscribe();
|
|
2142
2156
|
}
|
|
2143
2157
|
batches(e, t) {
|
|
2144
|
-
return e.pipe(
|
|
2158
|
+
return e.pipe(S((e) => Zn(e, this.config) ? !0 : (this.diagnostics.count("record.dropped_by_sampling"), !1)), St((e) => {
|
|
2145
2159
|
t.add(e);
|
|
2146
|
-
}),
|
|
2160
|
+
}), mt(t.options.flushIntervalMs, null, t.options.batchSize), _t(() => this.claim(t)), S((e) => e !== null));
|
|
2147
2161
|
}
|
|
2148
2162
|
claim(e) {
|
|
2149
2163
|
let t = e.take();
|
|
2150
2164
|
if (t.length === 0) return null;
|
|
2151
2165
|
let n = {
|
|
2152
|
-
id:
|
|
2166
|
+
id: M(),
|
|
2153
2167
|
records: t,
|
|
2154
2168
|
createdAt: Date.now(),
|
|
2155
2169
|
attempts: 0
|
|
@@ -2193,7 +2207,7 @@ var Jn = class {
|
|
|
2193
2207
|
function J(e) {
|
|
2194
2208
|
return e;
|
|
2195
2209
|
}
|
|
2196
|
-
var
|
|
2210
|
+
var tr = class {
|
|
2197
2211
|
deps;
|
|
2198
2212
|
resourceCache = null;
|
|
2199
2213
|
constructor(e) {
|
|
@@ -2204,83 +2218,83 @@ var Xn = class {
|
|
|
2204
2218
|
}
|
|
2205
2219
|
isEnabled(e) {
|
|
2206
2220
|
let { config: t } = this.deps;
|
|
2207
|
-
return t.enabled ?
|
|
2221
|
+
return t.enabled ? m[e] >= m[t.minLevel] : !1;
|
|
2208
2222
|
}
|
|
2209
2223
|
build(e) {
|
|
2210
2224
|
let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a } = this.deps;
|
|
2211
2225
|
if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"), null;
|
|
2212
|
-
let o = t.limits,
|
|
2226
|
+
let o = t.limits, c = r.resolve(), l = i.current(), u = a.next(), d = wn(), f, p = 0;
|
|
2213
2227
|
try {
|
|
2214
|
-
let t =
|
|
2215
|
-
|
|
2228
|
+
let t = L(this.deps.context.getAll(), o), n = L(e.scoped ?? {}, o), r = L(e.payload ?? {}, o);
|
|
2229
|
+
p = t.bytes + n.bytes + r.bytes, f = {
|
|
2216
2230
|
...J(t.value),
|
|
2217
2231
|
...J(n.value),
|
|
2218
2232
|
...J(r.value)
|
|
2219
2233
|
};
|
|
2220
2234
|
} catch (e) {
|
|
2221
|
-
n.report("record.sanitize_failed", "attributes could not be sanitized", void 0, e),
|
|
2235
|
+
n.report("record.sanitize_failed", "attributes could not be sanitized", void 0, e), f = { [Te]: !0 };
|
|
2222
2236
|
}
|
|
2223
|
-
|
|
2224
|
-
let
|
|
2225
|
-
|
|
2226
|
-
let
|
|
2227
|
-
timeUnixNano:
|
|
2228
|
-
traceId:
|
|
2229
|
-
spanId:
|
|
2230
|
-
traceFlags:
|
|
2231
|
-
severityNumber:
|
|
2237
|
+
f[y] = e.type, f[Ce] = u, f[b] = e.namespace, f[Ze] = d, l && (f[ye] = l.id, f[He] = l.name, l.parentId !== void 0 && (f[Je] = l.parentId));
|
|
2238
|
+
let m = I(e.body, o.maxBodyChars);
|
|
2239
|
+
m !== e.body && n.count("record.truncated");
|
|
2240
|
+
let h = {
|
|
2241
|
+
timeUnixNano: Gt(),
|
|
2242
|
+
traceId: c.traceId,
|
|
2243
|
+
spanId: c.spanId,
|
|
2244
|
+
traceFlags: c.traceFlags,
|
|
2245
|
+
severityNumber: s[e.level],
|
|
2232
2246
|
severityText: e.level,
|
|
2233
|
-
body:
|
|
2234
|
-
attributes:
|
|
2247
|
+
body: m,
|
|
2248
|
+
attributes: f,
|
|
2235
2249
|
resource: this.resource()
|
|
2236
|
-
},
|
|
2237
|
-
if (
|
|
2238
|
-
let e = n.guard("record.sanitize_failed", "redact hook threw", () => h
|
|
2250
|
+
}, g = t.redact;
|
|
2251
|
+
if (g) {
|
|
2252
|
+
let e = n.guard("record.sanitize_failed", "redact hook threw", () => g(h));
|
|
2239
2253
|
if (e === null) return n.count("record.dropped_by_redact"), null;
|
|
2240
|
-
if (e !== void 0 && e !==
|
|
2241
|
-
if (
|
|
2242
|
-
let t =
|
|
2243
|
-
|
|
2254
|
+
if (e !== void 0 && e !== h) {
|
|
2255
|
+
if (A(e)) {
|
|
2256
|
+
let t = L(e.attributes, o);
|
|
2257
|
+
h = {
|
|
2244
2258
|
...e,
|
|
2245
2259
|
attributes: J(t.value)
|
|
2246
|
-
},
|
|
2260
|
+
}, p = t.bytes;
|
|
2247
2261
|
} else n.report("record.sanitize_failed", "redact hook returned something that is not a record, keeping the original");
|
|
2248
2262
|
}
|
|
2249
2263
|
}
|
|
2250
|
-
if (
|
|
2264
|
+
if (p > o.maxRecordBytes) {
|
|
2251
2265
|
n.report("record.truncated", "attributes exceeded the size budget and were dropped", {
|
|
2252
|
-
bytes:
|
|
2253
|
-
body:
|
|
2266
|
+
bytes: p,
|
|
2267
|
+
body: h.body
|
|
2254
2268
|
});
|
|
2255
2269
|
let t = {
|
|
2256
|
-
[
|
|
2257
|
-
[
|
|
2258
|
-
[
|
|
2259
|
-
[
|
|
2260
|
-
[
|
|
2261
|
-
[
|
|
2270
|
+
[y]: e.type,
|
|
2271
|
+
[Ce]: u,
|
|
2272
|
+
[b]: e.namespace,
|
|
2273
|
+
[Ze]: d,
|
|
2274
|
+
[Ne]: !0,
|
|
2275
|
+
[Ke]: p
|
|
2262
2276
|
};
|
|
2263
|
-
|
|
2277
|
+
l && (t[ye] = l.id, t[He] = l.name), h.attributes = t;
|
|
2264
2278
|
}
|
|
2265
|
-
return
|
|
2279
|
+
return h;
|
|
2266
2280
|
}
|
|
2267
2281
|
resource() {
|
|
2268
2282
|
if (this.resourceCache) return this.resourceCache;
|
|
2269
2283
|
let { config: e, identity: t, platform: n } = this.deps;
|
|
2270
2284
|
return this.resourceCache = {
|
|
2271
|
-
[
|
|
2272
|
-
[
|
|
2273
|
-
[
|
|
2274
|
-
[
|
|
2275
|
-
[
|
|
2276
|
-
[
|
|
2277
|
-
[
|
|
2278
|
-
[
|
|
2279
|
-
[
|
|
2280
|
-
[
|
|
2281
|
-
[
|
|
2282
|
-
...n.openfinUuid === void 0 ? {} : { [
|
|
2283
|
-
...n.openfinName === void 0 ? {} : { [
|
|
2285
|
+
[Be]: e.serviceName,
|
|
2286
|
+
[Me]: e.serviceVersion,
|
|
2287
|
+
[Qe]: e.environment,
|
|
2288
|
+
[it]: p,
|
|
2289
|
+
[Se]: ee,
|
|
2290
|
+
[et]: u,
|
|
2291
|
+
[Ee]: n.platform,
|
|
2292
|
+
[Ae]: t.sessionId,
|
|
2293
|
+
[ve]: t.tabId,
|
|
2294
|
+
[Re]: t.contextId,
|
|
2295
|
+
[we]: n.userAgent,
|
|
2296
|
+
...n.openfinUuid === void 0 ? {} : { [Ge]: n.openfinUuid },
|
|
2297
|
+
...n.openfinName === void 0 ? {} : { [Oe]: n.openfinName }
|
|
2284
2298
|
}, this.resourceCache;
|
|
2285
2299
|
}
|
|
2286
2300
|
}, Y = Symbol.for(rt), X = class e {
|
|
@@ -2288,10 +2302,10 @@ var Xn = class {
|
|
|
2288
2302
|
config;
|
|
2289
2303
|
platform;
|
|
2290
2304
|
identity;
|
|
2291
|
-
context = new
|
|
2305
|
+
context = new Vn();
|
|
2292
2306
|
breadcrumbs;
|
|
2293
2307
|
tracing;
|
|
2294
|
-
sequence = new
|
|
2308
|
+
sequence = new Tn();
|
|
2295
2309
|
journey;
|
|
2296
2310
|
builder;
|
|
2297
2311
|
console;
|
|
@@ -2309,9 +2323,9 @@ var Xn = class {
|
|
|
2309
2323
|
destroyed = !1;
|
|
2310
2324
|
lastGapAt = 0;
|
|
2311
2325
|
constructor(e) {
|
|
2312
|
-
this.diagnostics = new
|
|
2326
|
+
this.diagnostics = new Hn(e.onDiagnostic), this.platform = xn(this.diagnostics), this.config = zn(e, this.diagnostics), this.identity = qt(this.diagnostics), this.breadcrumbs = new jn(this.config.capture.maxBreadcrumbs), this.tracing = new An(this.diagnostics), this.console = new bn(this.config.console.enabled, this.config.console.level), this.journey = new Jn(this.config.journey, this.diagnostics, this.identity.contextId, (e) => {
|
|
2313
2327
|
this.bus.broadcastJourney(e);
|
|
2314
|
-
}), this.builder = new
|
|
2328
|
+
}), this.builder = new tr({
|
|
2315
2329
|
config: this.config,
|
|
2316
2330
|
diagnostics: this.diagnostics,
|
|
2317
2331
|
context: this.context,
|
|
@@ -2348,7 +2362,7 @@ var Xn = class {
|
|
|
2348
2362
|
return globalThis[Y] = r, r.init(), r;
|
|
2349
2363
|
}
|
|
2350
2364
|
reconfigure(e) {
|
|
2351
|
-
|
|
2365
|
+
Bn(this.config, zn(e, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console.enabled, this.config.console.level), this.breadcrumbs.resize(this.config.capture.maxBreadcrumbs), this.pipeline?.refresh(), this.ready && this.reinstallCaptures(), this.diagnostics.report("config.reconfigured", "configure() was called again, the existing runtime was updated");
|
|
2352
2366
|
}
|
|
2353
2367
|
async init() {
|
|
2354
2368
|
try {
|
|
@@ -2361,11 +2375,11 @@ var Xn = class {
|
|
|
2361
2375
|
}
|
|
2362
2376
|
}
|
|
2363
2377
|
async becomeSender() {
|
|
2364
|
-
this.storage = await
|
|
2378
|
+
this.storage = await dn(this.config.storage.strategy, this.config.storage.dbName, this.config.storage, this.diagnostics, this.reportGap), this.transport = new _n(this.config, this.diagnostics), this.retry = new vn(this.storage, this.transport, this.diagnostics, this.config), this.pipeline = new er(this.config, this.transport, this.storage, this.retry, this.diagnostics), this.exitFlush = new mn({
|
|
2365
2379
|
config: this.config,
|
|
2366
2380
|
diagnostics: this.diagnostics,
|
|
2367
2381
|
drainPending: () => this.pipeline?.drainPending() ?? null
|
|
2368
|
-
}), await
|
|
2382
|
+
}), await rn(this.storage, this.diagnostics), this.retry.start(), this.exitFlush.install();
|
|
2369
2383
|
}
|
|
2370
2384
|
installCaptures() {
|
|
2371
2385
|
let e = {
|
|
@@ -2373,7 +2387,7 @@ var Xn = class {
|
|
|
2373
2387
|
diagnostics: this.diagnostics,
|
|
2374
2388
|
breadcrumbs: this.breadcrumbs,
|
|
2375
2389
|
tracing: this.tracing,
|
|
2376
|
-
logger: new
|
|
2390
|
+
logger: new w(this, nt)
|
|
2377
2391
|
}, t = this.config.capture;
|
|
2378
2392
|
(t.errors || t.rejections || t.resourceErrors) && this.captures.push(new Rt(e)), (t.fetch || t.xhr) && this.captures.push(new Ht(e)), (t.interactions || t.navigation) && this.captures.push(new Bt(e)), t.webVitals && this.captures.push(new Wt(e));
|
|
2379
2393
|
for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `installing ${e.name}`, () => {
|
|
@@ -2400,7 +2414,7 @@ var Xn = class {
|
|
|
2400
2414
|
}
|
|
2401
2415
|
emit(e) {
|
|
2402
2416
|
if (!(!e || this.destroyed)) {
|
|
2403
|
-
if (
|
|
2417
|
+
if (Yt(this.identity.sessionId, this.diagnostics), !this.ready) {
|
|
2404
2418
|
this.bootBuffer.length >= this.config.bus.maxBootBufferRecords && (this.bootBuffer.shift(), this.diagnostics.count("record.dropped_boot_buffer_full")), this.bootBuffer.push(e);
|
|
2405
2419
|
return;
|
|
2406
2420
|
}
|
|
@@ -2427,7 +2441,7 @@ var Xn = class {
|
|
|
2427
2441
|
return;
|
|
2428
2442
|
}
|
|
2429
2443
|
for (let t of e) {
|
|
2430
|
-
if (!
|
|
2444
|
+
if (!A(t)) {
|
|
2431
2445
|
this.diagnostics.count("record.dropped_malformed");
|
|
2432
2446
|
continue;
|
|
2433
2447
|
}
|
|
@@ -2442,19 +2456,19 @@ var Xn = class {
|
|
|
2442
2456
|
}
|
|
2443
2457
|
reportGap = (e) => {
|
|
2444
2458
|
let t = Date.now();
|
|
2445
|
-
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new
|
|
2459
|
+
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new w(this, ie).warn("stored records were dropped before delivery", {
|
|
2446
2460
|
"gap.batches": e.batches,
|
|
2447
2461
|
"gap.records": e.records,
|
|
2448
2462
|
"gap.reason": e.reason
|
|
2449
2463
|
}));
|
|
2450
2464
|
};
|
|
2451
2465
|
regenerateTabId() {
|
|
2452
|
-
let e =
|
|
2466
|
+
let e = M();
|
|
2453
2467
|
this.diagnostics.report("bus.role_resolved", "another context claimed this tab id, most likely a duplicated tab. Regenerating.", {
|
|
2454
2468
|
was: this.identity.tabId,
|
|
2455
2469
|
now: e
|
|
2456
2470
|
}), this.identity.tabId = e, this.diagnostics.guard("storage.unavailable", "persisting the new tab id", () => {
|
|
2457
|
-
sessionStorage.setItem(
|
|
2471
|
+
sessionStorage.setItem(oe, e);
|
|
2458
2472
|
}), this.builder.invalidateResource();
|
|
2459
2473
|
}
|
|
2460
2474
|
async queueDepth() {
|
|
@@ -2485,93 +2499,93 @@ var Xn = class {
|
|
|
2485
2499
|
function Q() {
|
|
2486
2500
|
return X.current() || X.configure({});
|
|
2487
2501
|
}
|
|
2488
|
-
function
|
|
2502
|
+
function nr(e) {
|
|
2489
2503
|
X.configure(e), Z.clear();
|
|
2490
2504
|
}
|
|
2491
|
-
function
|
|
2505
|
+
function rr(e, t) {
|
|
2492
2506
|
let n = t ? `${e}::${JSON.stringify(t)}` : e, r = Z.get(n);
|
|
2493
|
-
return r || (r = new
|
|
2507
|
+
return r || (r = new w(Q(), e, t), Z.set(n, r)), r;
|
|
2494
2508
|
}
|
|
2495
2509
|
function $() {
|
|
2496
|
-
return
|
|
2510
|
+
return rr("app");
|
|
2497
2511
|
}
|
|
2498
|
-
function
|
|
2512
|
+
function ir(e, t) {
|
|
2499
2513
|
$().trace(e, t);
|
|
2500
2514
|
}
|
|
2501
|
-
function
|
|
2515
|
+
function ar(e, t) {
|
|
2502
2516
|
$().debug(e, t);
|
|
2503
2517
|
}
|
|
2504
|
-
function
|
|
2518
|
+
function or(e, t) {
|
|
2505
2519
|
$().info(e, t);
|
|
2506
2520
|
}
|
|
2507
|
-
function
|
|
2521
|
+
function sr(e, t) {
|
|
2508
2522
|
$().warn(e, t);
|
|
2509
2523
|
}
|
|
2510
|
-
function
|
|
2524
|
+
function cr(e, t, n) {
|
|
2511
2525
|
$().error(e, t, n);
|
|
2512
2526
|
}
|
|
2513
|
-
function
|
|
2527
|
+
function lr(e, t) {
|
|
2514
2528
|
$().logAction(e, t);
|
|
2515
2529
|
}
|
|
2516
|
-
function
|
|
2530
|
+
function ur(e, t) {
|
|
2517
2531
|
$().logEvent(e, t);
|
|
2518
2532
|
}
|
|
2519
|
-
function
|
|
2533
|
+
function dr(e, t, n, r, i) {
|
|
2520
2534
|
$().logMetric(e, t, n, r, i);
|
|
2521
2535
|
}
|
|
2522
|
-
function
|
|
2536
|
+
function fr(e, t, n) {
|
|
2523
2537
|
return $().timeSync(e, t, n);
|
|
2524
2538
|
}
|
|
2525
|
-
function
|
|
2539
|
+
function pr(e, t, n) {
|
|
2526
2540
|
return $().timeAsync(e, t, n);
|
|
2527
2541
|
}
|
|
2528
|
-
function
|
|
2542
|
+
function mr(e, t) {
|
|
2529
2543
|
Q().context.set(e, t);
|
|
2530
2544
|
}
|
|
2531
|
-
function
|
|
2545
|
+
function hr(e) {
|
|
2532
2546
|
Q().context.setMany(e);
|
|
2533
2547
|
}
|
|
2534
|
-
function
|
|
2548
|
+
function gr(e) {
|
|
2535
2549
|
Q().context.remove(e);
|
|
2536
2550
|
}
|
|
2537
|
-
function
|
|
2551
|
+
function _r(e, t) {
|
|
2538
2552
|
return Q().journey.start(e, t);
|
|
2539
2553
|
}
|
|
2540
|
-
function
|
|
2554
|
+
function vr() {
|
|
2541
2555
|
Q().journey.end();
|
|
2542
2556
|
}
|
|
2543
|
-
function
|
|
2557
|
+
function yr() {
|
|
2544
2558
|
return Q().journey.current();
|
|
2545
2559
|
}
|
|
2546
|
-
function
|
|
2560
|
+
function br() {
|
|
2547
2561
|
return Q().journey.getToken();
|
|
2548
2562
|
}
|
|
2549
|
-
function
|
|
2563
|
+
function xr(e) {
|
|
2550
2564
|
return Q().journey.adopt(e, "manual", !0);
|
|
2551
2565
|
}
|
|
2552
|
-
function
|
|
2566
|
+
function Sr(e) {
|
|
2553
2567
|
Q().registerWorker(e);
|
|
2554
2568
|
}
|
|
2555
|
-
function
|
|
2569
|
+
function Cr() {
|
|
2556
2570
|
Q().tracing.rotate("explicit");
|
|
2557
2571
|
}
|
|
2558
|
-
function
|
|
2572
|
+
function wr() {
|
|
2559
2573
|
return Q().tracing.headers();
|
|
2560
2574
|
}
|
|
2561
|
-
function
|
|
2575
|
+
function Tr() {
|
|
2562
2576
|
return Q().flush();
|
|
2563
2577
|
}
|
|
2564
|
-
function
|
|
2578
|
+
function Er() {
|
|
2565
2579
|
return Q().queueDepth();
|
|
2566
2580
|
}
|
|
2567
|
-
function
|
|
2581
|
+
function Dr() {
|
|
2568
2582
|
return Q().diagnostics.snapshot();
|
|
2569
2583
|
}
|
|
2570
|
-
async function
|
|
2584
|
+
async function Or() {
|
|
2571
2585
|
let e = X.current();
|
|
2572
2586
|
Z.clear(), await e?.destroy();
|
|
2573
2587
|
}
|
|
2574
2588
|
//#endregion
|
|
2575
|
-
export {
|
|
2589
|
+
export { w as OneLogger, xr as adoptJourney, nr as configure, yr as currentJourney, ar as debug, vr as endJourney, cr as error, Tr as flush, Dr as getDiagnosticCounters, br as getJourneyToken, rr as getLogger, Er as getQueueDepth, wr as getTraceHeaders, or as info, lr as logAction, ur as logEvent, dr as logMetric, Sr as registerWorker, gr as removeContext, mr as setContext, hr as setContextMap, Or as shutdown, _r as startJourney, Cr as startTrace, pr as timeAsync, fr as timeSync, ir as trace, sr as warn };
|
|
2576
2590
|
|
|
2577
2591
|
//# sourceMappingURL=index.js.map
|