@utk09/ui-observability 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +52 -45
- package/dist/bus/bus.d.ts +46 -12
- package/dist/bus/links.d.ts +6 -3
- package/dist/bus-CtJWf9QN.cjs +2 -0
- package/dist/bus-CtJWf9QN.cjs.map +1 -0
- package/dist/{bus-DPDrlUBY.js → bus-D8kH58tb.js} +128 -71
- package/dist/bus-D8kH58tb.js.map +1 -0
- package/dist/capture/interactions.d.ts +7 -6
- package/dist/capture/network.d.ts +23 -9
- package/dist/capture/types.d.ts +3 -3
- package/dist/console-BpHfWstv.cjs +2 -0
- package/dist/console-BpHfWstv.cjs.map +1 -0
- package/dist/console-DjLbryED.js +82 -0
- package/dist/console-DjLbryED.js.map +1 -0
- package/dist/constants-Br3b89Wg.cjs +2 -0
- package/dist/constants-Br3b89Wg.cjs.map +1 -0
- package/dist/constants-DM94FjVX.js +96 -0
- package/dist/constants-DM94FjVX.js.map +1 -0
- package/dist/constants.d.ts +20 -9
- package/dist/core/diagnostics.d.ts +2 -2
- package/dist/core/journey.d.ts +16 -4
- package/dist/core/logger.d.ts +6 -2
- package/dist/core/pipeline.d.ts +18 -9
- package/dist/core/record.d.ts +11 -6
- package/dist/core/remote-sampling.d.ts +1 -1
- package/dist/core/runtime.d.ts +43 -15
- package/dist/core/sender.d.ts +15 -10
- package/dist/deadline-B5DINjD5.js +111 -0
- package/dist/deadline-B5DINjD5.js.map +1 -0
- package/dist/deadline-Cbg2cbUw.cjs +2 -0
- package/dist/deadline-Cbg2cbUw.cjs.map +1 -0
- package/dist/error-like-Ywo5uRHo.js +19 -0
- package/dist/error-like-Ywo5uRHo.js.map +1 -0
- package/dist/error-like-gGRx2s36.cjs +2 -0
- package/dist/error-like-gGRx2s36.cjs.map +1 -0
- package/dist/errors-CpGRhhIf.cjs +3 -0
- package/dist/errors-CpGRhhIf.cjs.map +1 -0
- package/dist/{errors-Dnc-X4Ec.js → errors-DH4QJS0u.js} +39 -20
- package/dist/errors-DH4QJS0u.js.map +1 -0
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
- package/dist/global-scope-dp2jADRl.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +561 -436
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-DNdf1fmL.cjs +2 -0
- package/dist/indexeddb-storage-DNdf1fmL.cjs.map +1 -0
- package/dist/{indexeddb-storage-uD4oaRMc.js → indexeddb-storage-n1qkFBGA.js} +17 -17
- package/dist/indexeddb-storage-n1qkFBGA.js.map +1 -0
- package/dist/interactions-31eHGwEQ.cjs +2 -0
- package/dist/interactions-31eHGwEQ.cjs.map +1 -0
- package/dist/{interactions-igKTAJvj.js → interactions-OU94MPXs.js} +22 -19
- package/dist/interactions-OU94MPXs.js.map +1 -0
- package/dist/journey-CE2EcwHW.cjs +2 -0
- package/dist/journey-CE2EcwHW.cjs.map +1 -0
- package/dist/journey-CeJ1QoT2.js +162 -0
- package/dist/journey-CeJ1QoT2.js.map +1 -0
- package/dist/{library-request-Br_T09Bn.cjs → library-request-C9uJFlbq.cjs} +2 -2
- package/dist/{library-request-Br_T09Bn.cjs.map → library-request-C9uJFlbq.cjs.map} +1 -1
- package/dist/{library-request-Dt0fXhcn.js → library-request-DvhuplAB.js} +2 -2
- package/dist/{library-request-Dt0fXhcn.js.map → library-request-DvhuplAB.js.map} +1 -1
- package/dist/{long-frames-DahhqM6u.cjs → long-frames-B8VdA_ny.cjs} +2 -2
- package/dist/{long-frames-DahhqM6u.cjs.map → long-frames-B8VdA_ny.cjs.map} +1 -1
- package/dist/{long-frames-6pnjWSSR.js → long-frames-C_7OutLs.js} +3 -3
- package/dist/{long-frames-6pnjWSSR.js.map → long-frames-C_7OutLs.js.map} +1 -1
- package/dist/models/batch.d.ts +1 -1
- package/dist/models/bus.d.ts +7 -4
- package/dist/models/config.d.ts +43 -12
- package/dist/models/log-record.d.ts +12 -6
- package/dist/network-BAV7ipyn.cjs +2 -0
- package/dist/network-BAV7ipyn.cjs.map +1 -0
- package/dist/network-D_lloS5t.js +174 -0
- package/dist/network-D_lloS5t.js.map +1 -0
- package/dist/patch-BX8KrPCT.cjs +2 -0
- package/dist/patch-BX8KrPCT.cjs.map +1 -0
- package/dist/patch-CCWfuEY7.js +9 -0
- package/dist/patch-CCWfuEY7.js.map +1 -0
- package/dist/{platform-D_XkVIF6.cjs → platform-D4wu1eIF.cjs} +2 -2
- package/dist/platform-D4wu1eIF.cjs.map +1 -0
- package/dist/platform-IHBZGqUe.js +48 -0
- package/dist/platform-IHBZGqUe.js.map +1 -0
- package/dist/{remote-rules-5UA23alm.js → remote-rules-Bt1XsdEQ.js} +14 -14
- package/dist/remote-rules-Bt1XsdEQ.js.map +1 -0
- package/dist/{remote-rules-rJJZKVG8.cjs → remote-rules-kuDf5gbe.cjs} +2 -2
- package/dist/remote-rules-kuDf5gbe.cjs.map +1 -0
- package/dist/sampling-BI15ds9D.cjs +2 -0
- package/dist/sampling-BI15ds9D.cjs.map +1 -0
- package/dist/sampling-o0VY1mqQ.js +63 -0
- package/dist/sampling-o0VY1mqQ.js.map +1 -0
- package/dist/sanitize-B9UheVKc.js +123 -0
- package/dist/sanitize-B9UheVKc.js.map +1 -0
- package/dist/sanitize-DSIP7amZ.cjs +2 -0
- package/dist/sanitize-DSIP7amZ.cjs.map +1 -0
- package/dist/{sender-G6v4Uqi4.js → sender-BnNj9bOX.js} +234 -176
- package/dist/sender-BnNj9bOX.js.map +1 -0
- package/dist/sender-D0OsyB1c.cjs +3 -0
- package/dist/sender-D0OsyB1c.cjs.map +1 -0
- package/dist/storage/emergency-queue.d.ts +1 -1
- package/dist/storage/factory.d.ts +1 -1
- package/dist/storage/idb-driver.d.ts +1 -1
- package/dist/storage/local-storage.d.ts +3 -3
- package/dist/storage/memory-storage.d.ts +3 -3
- package/dist/{storm-DJkEZP_8.js → storm-BTw0J6eE.js} +2 -2
- package/dist/{storm-DJkEZP_8.js.map → storm-BTw0J6eE.js.map} +1 -1
- package/dist/{storm-BtzgLOCX.cjs → storm-Y-yuBhvv.cjs} +2 -2
- package/dist/{storm-BtzgLOCX.cjs.map → storm-Y-yuBhvv.cjs.map} +1 -1
- package/dist/transport/compression.d.ts +1 -1
- package/dist/transport/exit-flush.d.ts +21 -17
- package/dist/transport/http-transport.d.ts +61 -7
- package/dist/transport/retry-engine.d.ts +5 -5
- package/dist/transport/status-transport.d.ts +4 -2
- package/dist/utils/console.d.ts +1 -1
- package/dist/utils/error-like.d.ts +25 -0
- package/dist/utils/global-scope.d.ts +1 -1
- package/dist/utils/identity.d.ts +1 -1
- package/dist/utils/library-console.d.ts +1 -1
- package/dist/utils/library-request.d.ts +1 -1
- package/dist/utils/patch.d.ts +9 -0
- package/dist/utils/platform.d.ts +3 -3
- package/dist/utils/sequence.d.ts +0 -5
- package/dist/utils/timer.d.ts +1 -1
- package/dist/utils/tracing.d.ts +3 -3
- package/dist/utils/unref.d.ts +2 -2
- package/dist/{web-vitals-DHZ0yA_H.js → web-vitals-Bflr5jSA.js} +4 -2
- package/dist/web-vitals-Bflr5jSA.js.map +1 -0
- package/dist/web-vitals-DFuoTQbZ.cjs +2 -0
- package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -0
- package/package.json +2 -2
- package/dist/bus-CUXRY0JR.cjs +0 -2
- package/dist/bus-CUXRY0JR.cjs.map +0 -1
- package/dist/bus-DPDrlUBY.js.map +0 -1
- package/dist/console-CNljJict.js +0 -81
- package/dist/console-CNljJict.js.map +0 -1
- package/dist/console-PKzc-FmR.cjs +0 -2
- package/dist/console-PKzc-FmR.cjs.map +0 -1
- package/dist/constants-B28fDv2F.cjs +0 -2
- package/dist/constants-B28fDv2F.cjs.map +0 -1
- package/dist/constants-Bu49bm39.js +0 -93
- package/dist/constants-Bu49bm39.js.map +0 -1
- package/dist/errors-C78ZTjet.cjs +0 -3
- package/dist/errors-C78ZTjet.cjs.map +0 -1
- package/dist/errors-Dnc-X4Ec.js.map +0 -1
- package/dist/indexeddb-storage-D0p3iMD0.cjs +0 -2
- package/dist/indexeddb-storage-D0p3iMD0.cjs.map +0 -1
- package/dist/indexeddb-storage-uD4oaRMc.js.map +0 -1
- package/dist/interactions-CsE2y_fQ.cjs +0 -2
- package/dist/interactions-CsE2y_fQ.cjs.map +0 -1
- package/dist/interactions-igKTAJvj.js.map +0 -1
- package/dist/network-CZ0aFUsy.cjs +0 -2
- package/dist/network-CZ0aFUsy.cjs.map +0 -1
- package/dist/network-aSNbwpue.js +0 -112
- package/dist/network-aSNbwpue.js.map +0 -1
- package/dist/platform-BwbMRwHm.js +0 -48
- package/dist/platform-BwbMRwHm.js.map +0 -1
- package/dist/platform-D_XkVIF6.cjs.map +0 -1
- package/dist/remote-rules-5UA23alm.js.map +0 -1
- package/dist/remote-rules-rJJZKVG8.cjs.map +0 -1
- package/dist/sampling-E4x92Nn2.cjs +0 -2
- package/dist/sampling-E4x92Nn2.cjs.map +0 -1
- package/dist/sampling-J1eahbfT.js +0 -160
- package/dist/sampling-J1eahbfT.js.map +0 -1
- package/dist/sanitize-BMhh8ghJ.cjs +0 -2
- package/dist/sanitize-BMhh8ghJ.cjs.map +0 -1
- package/dist/sanitize-UJ-4Lb0n.js +0 -114
- package/dist/sanitize-UJ-4Lb0n.js.map +0 -1
- package/dist/sender-B6ufz26f.cjs +0 -3
- package/dist/sender-B6ufz26f.cjs.map +0 -1
- package/dist/sender-G6v4Uqi4.js.map +0 -1
- package/dist/unref-16maCyKA.js +0 -8
- package/dist/unref-16maCyKA.js.map +0 -1
- package/dist/unref-CU9Nyz_9.cjs +0 -2
- package/dist/unref-CU9Nyz_9.cjs.map +0 -1
- package/dist/web-vitals-B2FYsEAU.cjs +0 -2
- package/dist/web-vitals-B2FYsEAU.cjs.map +0 -1
- package/dist/web-vitals-DHZ0yA_H.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,61 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
1
|
+
import { Bt as e, D as t, Et as n, F as r, Ft as i, Ht as a, It as o, Jt as s, L as c, Lt as l, Mt as u, N as d, Nt as f, O as p, P as m, Pt as h, Rt as g, T as _, Ut as ee, Vt as te, Xt as v, _n as ne, a as y, c as b, ct as x, d as S, dn as re, en as C, f as ie, fn as ae, hn as oe, i as se, in as ce, jt as le, k as ue, l as de, mn as fe, n as pe, o as me, p as he, pn as w, qt as ge, r as _e, s as ve, st as ye, u as T, ut as be, vn as xe, yn as E, zt as Se } from "./constants-DM94FjVX.js";
|
|
2
|
+
import { n as Ce, r as D, t as we } from "./error-like-Ywo5uRHo.js";
|
|
3
|
+
import { a as O, i as Te, n as Ee, o as De, r as Oe } from "./sampling-o0VY1mqQ.js";
|
|
4
|
+
import { a as ke, i as Ae, n as je, o as k, r as A } from "./sanitize-B9UheVKc.js";
|
|
5
|
+
import { a as Me, c as Ne, i as Pe, l as Fe, o as Ie, s as Le, u as Re } from "./deadline-B5DINjD5.js";
|
|
6
|
+
import { n as ze, r as Be, t as Ve } from "./platform-IHBZGqUe.js";
|
|
7
|
+
import { n as He, t as Ue } from "./journey-CeJ1QoT2.js";
|
|
6
8
|
//#region src/utils/timer.ts
|
|
7
|
-
function
|
|
8
|
-
return Math.round((performance.now() - e) *
|
|
9
|
+
function j(e) {
|
|
10
|
+
return Math.round((performance.now() - e) * c) / c;
|
|
9
11
|
}
|
|
10
|
-
function
|
|
11
|
-
e.logMetric(`${t}.duration`,
|
|
12
|
+
function M(e, t, n, r, i) {
|
|
13
|
+
e.logMetric(`${t}.duration`, n, "ms", "histogram", {
|
|
12
14
|
status: r,
|
|
13
15
|
...i
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
|
-
function
|
|
18
|
+
function N(e, t, n, r, i) {
|
|
19
|
+
let a = j(n);
|
|
17
20
|
e.error(`${t} failed`, r, {
|
|
18
|
-
"action.duration_ms":
|
|
21
|
+
"action.duration_ms": a,
|
|
19
22
|
status: "FAILURE",
|
|
20
23
|
...i
|
|
21
|
-
});
|
|
24
|
+
}), M(e, t, a, "FAILURE", i);
|
|
22
25
|
}
|
|
23
|
-
function
|
|
26
|
+
function We(e, t, n, r) {
|
|
24
27
|
let i = performance.now();
|
|
25
28
|
try {
|
|
26
29
|
let a = n();
|
|
27
|
-
return
|
|
30
|
+
return M(e, t, j(i), "SUCCESS", r), a;
|
|
28
31
|
} catch (n) {
|
|
29
|
-
throw
|
|
32
|
+
throw N(e, t, i, n, r), n;
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
|
-
async function
|
|
35
|
+
async function Ge(e, t, n, r) {
|
|
33
36
|
let i = performance.now();
|
|
34
37
|
try {
|
|
35
38
|
let a = await n();
|
|
36
|
-
return
|
|
39
|
+
return M(e, t, j(i), "SUCCESS", r), a;
|
|
37
40
|
} catch (n) {
|
|
38
|
-
throw
|
|
41
|
+
throw N(e, t, i, n, r), n;
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
//#endregion
|
|
42
45
|
//#region src/core/logger.ts
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let n = t.guard("record.sanitize_failed", "The library could not
|
|
46
|
-
|
|
46
|
+
var Ke = [_, ce];
|
|
47
|
+
function qe(e, t) {
|
|
48
|
+
let n = t.guard("record.sanitize_failed", "The library could not read the error reason.", () => {
|
|
49
|
+
if (!(e instanceof Error) && !D(e)) return;
|
|
50
|
+
let t = Error(e.message);
|
|
51
|
+
return t.name = e.name, t.stack = e.stack, t;
|
|
52
|
+
});
|
|
53
|
+
if (n) return n;
|
|
54
|
+
let r = t.guard("record.sanitize_failed", "The library could not convert the error reason to text.", () => String(e));
|
|
55
|
+
return Error(r ?? typeof e);
|
|
47
56
|
}
|
|
48
|
-
function
|
|
57
|
+
function Je(e, t, n) {
|
|
58
|
+
return n.guard("record.sanitize_failed", "The library could not read the error reason.", () => e instanceof Error ? e : t) ?? t;
|
|
59
|
+
}
|
|
60
|
+
function Ye(e, t) {
|
|
61
|
+
if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" || typeof e == "symbol") return e;
|
|
62
|
+
if (typeof e == "object" && e) return t.guard("record.sanitize_failed", "The library could not read the properties of the error reason.", () => {
|
|
63
|
+
let t = e, n = D(e), r = {}, i = 0;
|
|
64
|
+
for (let e of Object.keys(t)) {
|
|
65
|
+
let a = t[e];
|
|
66
|
+
(!n || !we.has(e)) && Ce(a) && (r[e] = a, i++);
|
|
67
|
+
}
|
|
68
|
+
return i === 0 ? void 0 : r;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function Xe(e) {
|
|
49
72
|
if (typeof e != "object" || !e || Array.isArray(e) || e instanceof Error) return !1;
|
|
50
73
|
let t = Object.getPrototypeOf(e);
|
|
51
74
|
return t === null || Object.getPrototypeOf(t) === null;
|
|
52
75
|
}
|
|
53
|
-
|
|
76
|
+
function Ze(e) {
|
|
77
|
+
return Ke.some((t) => e === t || e.startsWith(`${t}.`)) ? "system" : "log";
|
|
78
|
+
}
|
|
79
|
+
function P(e, t) {
|
|
80
|
+
return e === void 0 ? {} : t.guard("record.sanitize_failed", "The library could not read the payload.", () => ({ ...e })) ?? { "uiobs.sanitize_failed": !0 };
|
|
81
|
+
}
|
|
82
|
+
var F = class e {
|
|
54
83
|
bind;
|
|
55
84
|
namespace;
|
|
56
85
|
options;
|
|
86
|
+
levelType;
|
|
57
87
|
constructor(e, t, n = {}) {
|
|
58
|
-
this.bind = e, this.namespace = t, this.options = n;
|
|
88
|
+
this.bind = e, this.namespace = t, this.options = n, this.levelType = Ze(t);
|
|
59
89
|
}
|
|
60
90
|
child(t, n = {}) {
|
|
61
91
|
return new e(this.bind, `${this.namespace}.${t}`, { scopedContext: {
|
|
@@ -64,16 +94,16 @@ var z = class e {
|
|
|
64
94
|
} });
|
|
65
95
|
}
|
|
66
96
|
trace = (e, t) => {
|
|
67
|
-
this.write("TRACE",
|
|
97
|
+
this.write("TRACE", this.levelType, e, t);
|
|
68
98
|
};
|
|
69
99
|
debug = (e, t) => {
|
|
70
|
-
this.write("DEBUG",
|
|
100
|
+
this.write("DEBUG", this.levelType, e, t);
|
|
71
101
|
};
|
|
72
102
|
info = (e, t) => {
|
|
73
|
-
this.write("INFO",
|
|
103
|
+
this.write("INFO", this.levelType, e, t);
|
|
74
104
|
};
|
|
75
105
|
warn = (e, t) => {
|
|
76
|
-
this.write("WARN",
|
|
106
|
+
this.write("WARN", this.levelType, e, t);
|
|
77
107
|
};
|
|
78
108
|
error = (e, t, n) => {
|
|
79
109
|
this.writeError("ERROR", e, t, n);
|
|
@@ -87,80 +117,86 @@ var z = class e {
|
|
|
87
117
|
logEvent = (e, t) => {
|
|
88
118
|
this.write("INFO", "event", e, t);
|
|
89
119
|
};
|
|
90
|
-
logMetric = (e, t, n =
|
|
91
|
-
|
|
120
|
+
logMetric = (e, t, n = m, r = "gauge", i) => {
|
|
121
|
+
if (!Number.isFinite(t)) {
|
|
122
|
+
this.bind().diagnostics.report("record.dropped_malformed", "The metric value is not a finite number. The library dropped the metric.", { "metric.name": e });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
let a = {
|
|
126
|
+
...P(i, this.bind().diagnostics),
|
|
92
127
|
"metric.name": e,
|
|
93
128
|
"metric.value": t,
|
|
94
129
|
"metric.unit": n,
|
|
95
|
-
"metric.type": r
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
"metric.type": r
|
|
131
|
+
};
|
|
132
|
+
this.write("INFO", "metric", e, a, !0);
|
|
98
133
|
};
|
|
99
|
-
timeSync = (e, t, n) =>
|
|
100
|
-
timeAsync = (e, t, n) =>
|
|
101
|
-
write(e, t, n, r) {
|
|
102
|
-
let
|
|
103
|
-
if (
|
|
104
|
-
if (!
|
|
105
|
-
this.mirrors(
|
|
134
|
+
timeSync = (e, t, n) => We(this, e, t, n);
|
|
135
|
+
timeAsync = (e, t, n) => Ge(this, e, t, n);
|
|
136
|
+
write(e, t, n, r, i = !1) {
|
|
137
|
+
let a = this.bind();
|
|
138
|
+
if (a.isDestroyed()) return;
|
|
139
|
+
if (!a.builder.isEnabled(e, t)) {
|
|
140
|
+
this.mirrors(a, e) && this.print(a, e, n, r, void 0, null);
|
|
106
141
|
return;
|
|
107
142
|
}
|
|
108
|
-
let { record:
|
|
143
|
+
let { record: o, dropped: s } = a.builder.build({
|
|
109
144
|
level: e,
|
|
110
145
|
type: t,
|
|
111
146
|
body: n,
|
|
112
147
|
namespace: this.namespace,
|
|
113
148
|
scoped: this.options.scopedContext,
|
|
114
|
-
payload: r
|
|
115
|
-
});
|
|
116
|
-
t !== "metric" &&
|
|
149
|
+
payload: i ? r : P(r, a.diagnostics)
|
|
150
|
+
}), c = o ? o.body : s === "sampling" ? n : void 0;
|
|
151
|
+
t !== "metric" && c !== void 0 && a.breadcrumbs.push({
|
|
117
152
|
t: Date.now(),
|
|
118
153
|
category: t === "action" ? "action" : t === "event" ? "event" : "log",
|
|
119
|
-
message:
|
|
120
|
-
}), this.print(
|
|
154
|
+
message: c
|
|
155
|
+
}), this.print(a, e, n, r, void 0, o, s), a.emit(o);
|
|
121
156
|
}
|
|
122
157
|
writeError(e, t, n, r) {
|
|
123
158
|
let i = this.bind();
|
|
124
159
|
if (i.isDestroyed()) return;
|
|
125
160
|
let a = i.builder.isEnabled(e);
|
|
126
161
|
if (!a && !this.mirrors(i, e)) return;
|
|
127
|
-
let o = r === void 0 &&
|
|
162
|
+
let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () => Xe(n)) ?? !1), s = o ? n : r, c = o ? void 0 : n, l = c === void 0 ? void 0 : qe(c, i.diagnostics), u = l === void 0 ? void 0 : Je(c, l, i.diagnostics);
|
|
128
163
|
if (!a) {
|
|
129
|
-
this.print(i, e, t, s,
|
|
164
|
+
this.print(i, e, t, s, u, null);
|
|
130
165
|
return;
|
|
131
166
|
}
|
|
132
|
-
let { record:
|
|
167
|
+
let d = l ? Ye(c, i.diagnostics) : void 0, { record: f, dropped: p } = i.builder.build({
|
|
133
168
|
level: e,
|
|
134
|
-
type:
|
|
169
|
+
type: this.levelType,
|
|
135
170
|
body: t,
|
|
136
171
|
namespace: this.namespace,
|
|
137
172
|
scoped: this.options.scopedContext,
|
|
138
173
|
payload: {
|
|
139
|
-
...s,
|
|
140
|
-
...
|
|
141
|
-
"error.type":
|
|
142
|
-
"error.message":
|
|
143
|
-
"error.stack_trace":
|
|
174
|
+
...P(s, i.diagnostics),
|
|
175
|
+
...l ? {
|
|
176
|
+
"error.type": l.name,
|
|
177
|
+
"error.message": l.message,
|
|
178
|
+
"error.stack_trace": l.stack
|
|
144
179
|
} : {},
|
|
145
|
-
|
|
180
|
+
...d === void 0 ? {} : { [me]: d },
|
|
181
|
+
[y]: i.breadcrumbs.snapshot()
|
|
146
182
|
}
|
|
147
183
|
});
|
|
148
|
-
this.print(i, e, t, s,
|
|
184
|
+
this.print(i, e, t, s, u, f, p), i.emit(f);
|
|
149
185
|
}
|
|
150
|
-
print(e, t, n, r, i, a) {
|
|
151
|
-
e.config.redact ? a ? e.console.write(this.namespace, t, a.body, a.attributes) : e.console.write(this.namespace, t, n, void 0, i) : e.console.write(this.namespace, t, n, r, i);
|
|
186
|
+
print(e, t, n, r, i, a, o) {
|
|
187
|
+
e.config.redact ? a ? e.console.write(this.namespace, t, a.body, a.attributes) : o !== "redact" && o !== "malformed" && e.console.write(this.namespace, t, n, void 0, i) : e.console.write(this.namespace, t, n, r, i);
|
|
152
188
|
}
|
|
153
189
|
mirrors(e, t) {
|
|
154
190
|
return e.config.enabled && e.console.accepts(t);
|
|
155
191
|
}
|
|
156
|
-
},
|
|
192
|
+
}, Qe = {
|
|
157
193
|
TRACE: "debug",
|
|
158
194
|
DEBUG: "debug",
|
|
159
195
|
INFO: "info",
|
|
160
196
|
WARN: "warn",
|
|
161
197
|
ERROR: "error",
|
|
162
198
|
FATAL: "error"
|
|
163
|
-
},
|
|
199
|
+
}, $e = class {
|
|
164
200
|
settings;
|
|
165
201
|
diagnostics;
|
|
166
202
|
constructor(e, t) {
|
|
@@ -170,58 +206,55 @@ var z = class e {
|
|
|
170
206
|
this.settings = e;
|
|
171
207
|
}
|
|
172
208
|
accepts(e) {
|
|
173
|
-
return this.settings.level
|
|
209
|
+
return this.settings.level === null || !Object.hasOwn(x, this.settings.level) ? !1 : x[e] >= x[this.settings.level];
|
|
174
210
|
}
|
|
175
|
-
write(e, t,
|
|
176
|
-
if (!this.accepts(t) || typeof console > "u" ||
|
|
177
|
-
let o = `%c[%s]%c[${t}]%c`, { styles: s } = this.settings, c =
|
|
211
|
+
write(e, t, r, i, a) {
|
|
212
|
+
if (!this.accepts(t) || typeof console > "u" || ke()) return;
|
|
213
|
+
let o = `%c[%s]%c[${t}]%c`, { styles: s } = this.settings, c = Qe[t];
|
|
178
214
|
this.diagnostics.guard("handler.threw", `The library could not print to console.${c}.`, () => {
|
|
179
215
|
let l = [];
|
|
180
|
-
a !== void 0 && l.push(a), i !== void 0 && l.push(
|
|
181
|
-
console[c](o, s.namespace, e, s[t], "",
|
|
216
|
+
a !== void 0 && l.push(a), i !== void 0 && l.push(je(i, n, this.diagnostics)), k(() => {
|
|
217
|
+
console[c](o, s.namespace, e, s[t], "", r, ...l);
|
|
182
218
|
});
|
|
183
219
|
});
|
|
184
220
|
}
|
|
185
|
-
},
|
|
221
|
+
}, et = class {
|
|
186
222
|
value = 0;
|
|
187
223
|
next() {
|
|
188
224
|
return ++this.value;
|
|
189
225
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}, Ye = /^[0-9a-f]{32}$/, Xe = /^[0-9a-f]{16}$/, B = /[1-9a-f]/;
|
|
194
|
-
function Ze(e) {
|
|
195
|
-
return Ye.test(e.traceId) && B.test(e.traceId) && Xe.test(e.spanId) && B.test(e.spanId);
|
|
226
|
+
}, tt = /^[0-9a-f]{32}$/, nt = /^[0-9a-f]{16}$/, rt = /[1-9a-f]/;
|
|
227
|
+
function it(e) {
|
|
228
|
+
return tt.test(e.traceId) && rt.test(e.traceId) && nt.test(e.spanId) && rt.test(e.spanId);
|
|
196
229
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
230
|
+
function at() {
|
|
231
|
+
return Fe(16);
|
|
199
232
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
233
|
+
function ot() {
|
|
234
|
+
return Fe(8);
|
|
202
235
|
}
|
|
203
|
-
function
|
|
236
|
+
function st() {
|
|
204
237
|
return {
|
|
205
|
-
traceId:
|
|
206
|
-
spanId:
|
|
238
|
+
traceId: at(),
|
|
239
|
+
spanId: ot(),
|
|
207
240
|
traceFlags: 1,
|
|
208
241
|
startedAt: Date.now()
|
|
209
242
|
};
|
|
210
243
|
}
|
|
211
|
-
function
|
|
244
|
+
function ct(e) {
|
|
212
245
|
return {
|
|
213
246
|
traceId: e.traceId,
|
|
214
247
|
spanId: e.spanId,
|
|
215
248
|
traceFlags: e.traceFlags
|
|
216
249
|
};
|
|
217
250
|
}
|
|
218
|
-
var
|
|
251
|
+
var lt = class {
|
|
219
252
|
diagnostics;
|
|
220
253
|
maxAgeMs;
|
|
221
254
|
load;
|
|
222
|
-
ambient =
|
|
255
|
+
ambient = st();
|
|
223
256
|
otel;
|
|
224
|
-
constructor(e, t =
|
|
257
|
+
constructor(e, t = oe, n) {
|
|
225
258
|
this.diagnostics = e, this.maxAgeMs = t, this.load = n;
|
|
226
259
|
}
|
|
227
260
|
async loadOtel() {
|
|
@@ -233,7 +266,7 @@ var et = class {
|
|
|
233
266
|
}
|
|
234
267
|
resolve() {
|
|
235
268
|
let e = this.activeSpanContext();
|
|
236
|
-
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"),
|
|
269
|
+
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), ct(this.ambient)) : e;
|
|
237
270
|
}
|
|
238
271
|
activeSpanContext() {
|
|
239
272
|
let e = this.otel;
|
|
@@ -241,7 +274,7 @@ var et = class {
|
|
|
241
274
|
let t = e.trace.getActiveSpan();
|
|
242
275
|
if (t === void 0) return;
|
|
243
276
|
let n = t.spanContext();
|
|
244
|
-
if (
|
|
277
|
+
if (it(n)) return {
|
|
245
278
|
traceId: n.traceId,
|
|
246
279
|
spanId: n.spanId,
|
|
247
280
|
traceFlags: n.traceFlags
|
|
@@ -249,7 +282,7 @@ var et = class {
|
|
|
249
282
|
});
|
|
250
283
|
}
|
|
251
284
|
rotate(e) {
|
|
252
|
-
return this.ambient =
|
|
285
|
+
return this.ambient = st(), ct(this.ambient);
|
|
253
286
|
}
|
|
254
287
|
headers() {
|
|
255
288
|
let e = {}, t = this.otel;
|
|
@@ -257,11 +290,11 @@ var et = class {
|
|
|
257
290
|
t.propagation.inject(t.context.active(), e);
|
|
258
291
|
}), !e.traceparent) {
|
|
259
292
|
let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
|
|
260
|
-
e[
|
|
293
|
+
e[fe] = `00-${t.traceId}-${t.spanId}-${n}`;
|
|
261
294
|
}
|
|
262
295
|
return e;
|
|
263
296
|
}
|
|
264
|
-
},
|
|
297
|
+
}, ut = class {
|
|
265
298
|
buffer;
|
|
266
299
|
pointer = 0;
|
|
267
300
|
filled = !1;
|
|
@@ -278,62 +311,213 @@ var et = class {
|
|
|
278
311
|
clear() {
|
|
279
312
|
this.buffer = Array(this.capacity), this.pointer = 0, this.filled = !1;
|
|
280
313
|
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
314
|
+
}, I = Object.keys(x), dt = ["gzip", "none"], ft = [
|
|
315
|
+
"omit",
|
|
316
|
+
"same-origin",
|
|
317
|
+
"include"
|
|
318
|
+
], pt = [
|
|
319
|
+
"auto",
|
|
320
|
+
"indexeddb",
|
|
321
|
+
"localstorage",
|
|
322
|
+
"memory",
|
|
323
|
+
"none"
|
|
324
|
+
], mt = ["storage", "memory"], ht = [
|
|
325
|
+
"auto",
|
|
326
|
+
"sender",
|
|
327
|
+
"forwarder",
|
|
328
|
+
"off"
|
|
329
|
+
], gt = [
|
|
330
|
+
"auto",
|
|
331
|
+
"provider",
|
|
332
|
+
"client"
|
|
333
|
+
], _t = [
|
|
334
|
+
"auto",
|
|
335
|
+
"context",
|
|
336
|
+
"tab",
|
|
337
|
+
"origin"
|
|
338
|
+
], L = [
|
|
339
|
+
"error",
|
|
340
|
+
"warn",
|
|
341
|
+
"info",
|
|
342
|
+
"log"
|
|
343
|
+
], vt = [
|
|
344
|
+
"errors",
|
|
345
|
+
"rejections",
|
|
346
|
+
"resourceErrors",
|
|
347
|
+
"fetch",
|
|
348
|
+
"xhr",
|
|
349
|
+
"interactions",
|
|
350
|
+
"navigation",
|
|
351
|
+
"webVitals",
|
|
352
|
+
"longFrames",
|
|
353
|
+
"fullUrls"
|
|
354
|
+
], yt = "null", R = `a level name: ${B(I)}`, z = `true, false or a list of ${B(L)}`, bt = "a list of strings and RegExp patterns", xt = "a list of origin URLs such as \"https://api.example\" and RegExp patterns", St = "a list of origin URLs such as \"https://app.example\". For a sandboxed frame, set bus.mode: \"sender\" in the frame", Ct = "a list of strings";
|
|
355
|
+
function B(e) {
|
|
356
|
+
let t = e.map((e) => `"${e}"`);
|
|
357
|
+
return `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
|
|
358
|
+
}
|
|
359
|
+
function V(e) {
|
|
360
|
+
return typeof e == "string" ? `"${e}"` : typeof e == "function" ? "a function" : typeof e == "object" && e ? "an object" : String(e);
|
|
361
|
+
}
|
|
362
|
+
function H(e, t, n, r, i) {
|
|
363
|
+
e.report("config.invalid", `${t} must be ${n}. The value is ${V(r)}. The library keeps ${i}.`);
|
|
364
|
+
}
|
|
365
|
+
function U(e, t, n, r, i) {
|
|
366
|
+
if (t === void 0) return r;
|
|
367
|
+
let a = n.find((e) => e === t);
|
|
368
|
+
return a === void 0 ? (H(i, e, B(n), t, `"${r}"`), r) : a;
|
|
369
|
+
}
|
|
370
|
+
function W(e, t, n, r) {
|
|
371
|
+
return t === void 0 ? n : typeof t == "boolean" ? t : (H(r, e, "true or false", t, String(n)), n);
|
|
372
|
+
}
|
|
373
|
+
function wt(e, t, n, r) {
|
|
374
|
+
return t === void 0 ? n : typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : (H(r, e, "a finite number of 0 or more", t, String(n)), n);
|
|
375
|
+
}
|
|
376
|
+
function G(e) {
|
|
377
|
+
if (typeof e != "string") return;
|
|
378
|
+
let t = e.toUpperCase();
|
|
379
|
+
return I.find((e) => e === t);
|
|
380
|
+
}
|
|
381
|
+
function Tt(e, t, n, r) {
|
|
382
|
+
if (t === void 0) return n;
|
|
383
|
+
let i = G(t);
|
|
384
|
+
return i === void 0 ? (H(r, e, R, t, `"${n}"`), n) : i;
|
|
385
|
+
}
|
|
386
|
+
function K(e, t, n, r, i, a) {
|
|
387
|
+
if (t === void 0) return n;
|
|
388
|
+
if (!Array.isArray(t)) return H(a, e, r, t, "the list in force"), n;
|
|
389
|
+
let o = [], s = t;
|
|
390
|
+
for (let t of s) {
|
|
391
|
+
let n = i(t);
|
|
392
|
+
n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${V(t)}. ${e} must be ${r}.`) : o.push(n);
|
|
393
|
+
}
|
|
394
|
+
return o;
|
|
395
|
+
}
|
|
396
|
+
function Et(e) {
|
|
397
|
+
return typeof e == "string" ? e : void 0;
|
|
398
|
+
}
|
|
399
|
+
function Dt(e) {
|
|
400
|
+
return typeof e == "string" || e instanceof RegExp ? e : void 0;
|
|
401
|
+
}
|
|
402
|
+
function Ot(e) {
|
|
403
|
+
return L.find((t) => t === e);
|
|
404
|
+
}
|
|
405
|
+
function kt(e) {
|
|
406
|
+
if (typeof e == "string") try {
|
|
407
|
+
let { origin: t } = new URL(e);
|
|
408
|
+
return t === yt ? void 0 : t;
|
|
409
|
+
} catch {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function At(e) {
|
|
414
|
+
return e instanceof RegExp ? e : kt(e);
|
|
415
|
+
}
|
|
416
|
+
function jt(e) {
|
|
417
|
+
return typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.values(e).every((e) => typeof e == "string");
|
|
418
|
+
}
|
|
419
|
+
function Mt(e, t, n) {
|
|
420
|
+
if (e !== void 0) return typeof e == "function" || jt(e) ? e : (H(n, "headers", "an object of strings or a function", e, "the headers in force"), t);
|
|
421
|
+
}
|
|
422
|
+
function Nt(e) {
|
|
285
423
|
return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
|
|
286
424
|
}
|
|
287
|
-
function
|
|
288
|
-
return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" ||
|
|
425
|
+
function Pt(e, t, n) {
|
|
426
|
+
return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || Nt(e) ? e : (n.report("config.invalid", `serializer must be "${v}", "ecs" or an implementation. The library uses "${v}".`), v);
|
|
289
427
|
}
|
|
290
|
-
var
|
|
291
|
-
function
|
|
428
|
+
var Ft = new Set(Object.keys(ue));
|
|
429
|
+
function It(e, t) {
|
|
292
430
|
let n = {}, r = Object.entries(e ?? {});
|
|
293
|
-
for (let [e, i] of r)
|
|
431
|
+
for (let [e, i] of r) Ft.has(e) ? typeof i == "string" ? n[e] = i : t.report("config.invalid", `console.styles.${e} must be a string. The library keeps the style in force.`) : t.report("config.invalid", `The library ignores the unknown console.styles key "${e}". Check the spelling.`);
|
|
294
432
|
return n;
|
|
295
433
|
}
|
|
296
|
-
function
|
|
297
|
-
|
|
434
|
+
function Lt(e, t, n) {
|
|
435
|
+
if (e === void 0) return t ?? "DEBUG";
|
|
436
|
+
let r = G(e);
|
|
437
|
+
return r === void 0 ? (H(n, "console.level", R, e, "the console level in force"), t) : r;
|
|
438
|
+
}
|
|
439
|
+
function Rt(e, t, n) {
|
|
440
|
+
if (e === void 0) return t;
|
|
441
|
+
if (e === !1) return {
|
|
298
442
|
level: null,
|
|
299
443
|
styles: t.styles
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
} : typeof e == "string" ? {
|
|
304
|
-
level: e,
|
|
444
|
+
};
|
|
445
|
+
if (e === !0) return {
|
|
446
|
+
level: p,
|
|
305
447
|
styles: t.styles
|
|
306
|
-
}
|
|
307
|
-
|
|
448
|
+
};
|
|
449
|
+
if (typeof e == "string") {
|
|
450
|
+
let r = G(e);
|
|
451
|
+
return r === void 0 ? (H(n, "console", R, e, "the console level in force"), t) : {
|
|
452
|
+
level: r,
|
|
453
|
+
styles: t.styles
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
return typeof e != "object" || !e ? (n.report("config.invalid", "console must be a boolean, a level or an object. The console settings in force stay."), t) : {
|
|
457
|
+
level: Lt(e.level, t.level, n),
|
|
308
458
|
styles: {
|
|
309
459
|
...t.styles,
|
|
310
|
-
...
|
|
460
|
+
...It(e.styles, n)
|
|
311
461
|
}
|
|
312
462
|
};
|
|
313
463
|
}
|
|
314
|
-
function
|
|
315
|
-
let r =
|
|
464
|
+
function zt(e, t, n) {
|
|
465
|
+
let r = e ?? {};
|
|
466
|
+
return {
|
|
467
|
+
...t,
|
|
468
|
+
...r,
|
|
469
|
+
rates: {
|
|
470
|
+
...t.rates,
|
|
471
|
+
...r.rates
|
|
472
|
+
},
|
|
473
|
+
alwaysSampleTypes: K("sampling.alwaysSampleTypes", r.alwaysSampleTypes, t.alwaysSampleTypes, Ct, Et, n),
|
|
474
|
+
remote: W("sampling.remote", r.remote, t.remote, n)
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function Bt(e, t, n) {
|
|
478
|
+
let r = e ?? {};
|
|
479
|
+
return {
|
|
480
|
+
mode: U("bus.mode", r.mode, ht, t.mode, n),
|
|
481
|
+
trustedOrigins: K("bus.trustedOrigins", r.trustedOrigins, t.trustedOrigins, St, kt, n),
|
|
482
|
+
openFinRole: U("bus.openFinRole", r.openFinRole, gt, t.openFinRole, n)
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function Vt(e, t, n) {
|
|
486
|
+
return { scope: U("journey.scope", (e ?? {}).scope, _t, t.scope, n) };
|
|
487
|
+
}
|
|
488
|
+
function Ht(e, t, n) {
|
|
489
|
+
return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ? K("capture.console", e, [], z, Ot, n) : (H(n, "capture.console", z, e, "the value in force"), t);
|
|
490
|
+
}
|
|
491
|
+
function Ut(e, t, n) {
|
|
492
|
+
let r = e ?? {}, i = {
|
|
493
|
+
...t,
|
|
494
|
+
...r,
|
|
495
|
+
console: Ht(r.console, t.console, n),
|
|
496
|
+
longFrameThresholdMs: wt("capture.longFrameThresholdMs", r.longFrameThresholdMs, t.longFrameThresholdMs, n),
|
|
497
|
+
ignoreUrls: K("capture.ignoreUrls", r.ignoreUrls, t.ignoreUrls, bt, Dt, n),
|
|
498
|
+
propagateTraceHeaderTo: K("capture.propagateTraceHeaderTo", r.propagateTraceHeaderTo, t.propagateTraceHeaderTo, xt, At, n)
|
|
499
|
+
};
|
|
500
|
+
for (let e of vt) i[e] = W(`capture.${e}`, r[e], t[e], n);
|
|
501
|
+
return i;
|
|
502
|
+
}
|
|
503
|
+
function Wt(e, t, n) {
|
|
504
|
+
let r = n ?? d, i = {
|
|
316
505
|
...r,
|
|
317
506
|
...e,
|
|
318
507
|
endpoint: e.endpoint === void 0 ? r.endpoint : e.endpoint,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
bus:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
},
|
|
333
|
-
capture: {
|
|
334
|
-
...r.capture,
|
|
335
|
-
...e.capture
|
|
336
|
-
}
|
|
508
|
+
enabled: W("enabled", e.enabled, r.enabled, t),
|
|
509
|
+
minLevel: Tt("minLevel", e.minLevel, r.minLevel, t),
|
|
510
|
+
compression: U("compression", e.compression, dt, r.compression, t),
|
|
511
|
+
credentials: U("credentials", e.credentials, ft, r.credentials, t),
|
|
512
|
+
headers: "headers" in e ? Mt(e.headers, r.headers, t) : r.headers,
|
|
513
|
+
storage: U("storage", e.storage, pt, r.storage, t),
|
|
514
|
+
identity: U("identity", e.identity, mt, r.identity, t),
|
|
515
|
+
serializer: Pt(e.serializer, n?.serializer, t),
|
|
516
|
+
console: Rt(e.console, r.console, t),
|
|
517
|
+
sampling: zt(e.sampling, r.sampling, t),
|
|
518
|
+
bus: Bt(e.bus, r.bus, t),
|
|
519
|
+
journey: Vt(e.journey, r.journey, t),
|
|
520
|
+
capture: Ut(e.capture, r.capture, t)
|
|
337
521
|
};
|
|
338
522
|
if (i.transport !== void 0 && typeof i.transport != "function" && (t.report("config.invalid", "transport must be a function. The library ignores the value."), i.transport = r.transport), i.transportOnExit !== void 0 && typeof i.transportOnExit != "function" && (t.report("config.invalid", "transportOnExit must be a function. The library ignores the value."), i.transportOnExit = r.transportOnExit), i.endpoint === "") i.transport === void 0 && t.report("config.invalid", "endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.");
|
|
339
523
|
else if (i.endpoint !== null) try {
|
|
@@ -341,32 +525,32 @@ function U(e, t, n) {
|
|
|
341
525
|
} catch (e) {
|
|
342
526
|
t.report("config.invalid", `endpoint is not a valid absolute URL: ${i.endpoint}.`, void 0, e);
|
|
343
527
|
}
|
|
344
|
-
i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${
|
|
528
|
+
i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${E}'.`), E);
|
|
345
529
|
let a = i.sampling.defaultRate;
|
|
346
530
|
(typeof a != "number" || a < 0 || a > 1) && (t.report("config.invalid", `sampling.defaultRate must be 0..1. The value is ${String(a)}. The library uses 1.`), i.sampling.defaultRate = 1);
|
|
347
531
|
let o = i.sampling.remoteMaxRate;
|
|
348
532
|
(typeof o != "number" || !(o >= 0 && o <= 1)) && (t.report("config.invalid", `sampling.remoteMaxRate must be 0..1. The value is ${String(o)}. The library uses 1.`), i.sampling.remoteMaxRate = 1);
|
|
349
533
|
let s = Object.entries(i.sampling.rates);
|
|
350
534
|
for (let [e, n] of s) (typeof n != "number" || n < 0 || n > 1) && (t.report("config.invalid", `sampling.rates["${e}"] must be 0..1. The value is ${String(n)}. The library uses 1.`), i.sampling.rates[e] = 1);
|
|
351
|
-
return i.capture.ignoreUrls = i.capture.ignoreUrls.filter((e) => e !== n?.endpoint), i.endpoint && !i.capture.ignoreUrls.includes(i.endpoint) && (i.capture.ignoreUrls = [...i.capture.ignoreUrls, i.endpoint]),
|
|
535
|
+
return i.capture.ignoreUrls = i.capture.ignoreUrls.filter((e) => e !== n?.endpoint), i.endpoint && !i.capture.ignoreUrls.includes(i.endpoint) && (i.capture.ignoreUrls = [...i.capture.ignoreUrls, i.endpoint]), Gt(e, t), i;
|
|
352
536
|
}
|
|
353
|
-
function
|
|
354
|
-
let
|
|
355
|
-
for (let
|
|
356
|
-
for (let
|
|
357
|
-
let
|
|
358
|
-
if (typeof
|
|
359
|
-
let i = /* @__PURE__ */ new Set([...Object.keys(
|
|
360
|
-
for (let e of Object.keys(
|
|
537
|
+
function Gt(e, n) {
|
|
538
|
+
let r = /* @__PURE__ */ new Set([...Object.keys(d), ...ne]);
|
|
539
|
+
for (let t of Object.keys(e)) r.has(t) || n.report("config.invalid", `The library ignores the unknown config key "${t}". Check the spelling.`);
|
|
540
|
+
for (let r of t) {
|
|
541
|
+
let t = e[r];
|
|
542
|
+
if (typeof t != "object" || !t) continue;
|
|
543
|
+
let i = /* @__PURE__ */ new Set([...Object.keys(d[r]), ...xe[r]]);
|
|
544
|
+
for (let e of Object.keys(t)) i.has(e) || n.report("config.invalid", `The library ignores the unknown config key "${r}.${e}". Check the spelling.`);
|
|
361
545
|
}
|
|
362
546
|
}
|
|
363
|
-
function
|
|
364
|
-
for (let
|
|
365
|
-
for (let
|
|
547
|
+
function Kt(e, n) {
|
|
548
|
+
for (let r of Object.keys(n)) t.includes(r) || Object.assign(e, { [r]: n[r] });
|
|
549
|
+
for (let r of t) Object.assign(e[r], n[r]);
|
|
366
550
|
}
|
|
367
551
|
//#endregion
|
|
368
552
|
//#region src/core/context.ts
|
|
369
|
-
var
|
|
553
|
+
var qt = class {
|
|
370
554
|
map = /* @__PURE__ */ new Map();
|
|
371
555
|
set(e, t) {
|
|
372
556
|
this.map.set(e, t);
|
|
@@ -386,12 +570,12 @@ var lt = class {
|
|
|
386
570
|
getAll() {
|
|
387
571
|
return Object.fromEntries(this.map);
|
|
388
572
|
}
|
|
389
|
-
},
|
|
573
|
+
}, Jt = class {
|
|
390
574
|
handler;
|
|
391
575
|
throttleMs;
|
|
392
576
|
counters = /* @__PURE__ */ new Map();
|
|
393
577
|
lastEmitted = /* @__PURE__ */ new Map();
|
|
394
|
-
constructor(e, t =
|
|
578
|
+
constructor(e, t = r) {
|
|
395
579
|
this.handler = e, this.throttleMs = t;
|
|
396
580
|
}
|
|
397
581
|
setHandler(e) {
|
|
@@ -414,12 +598,12 @@ var lt = class {
|
|
|
414
598
|
count: i
|
|
415
599
|
}, { handler: s } = this;
|
|
416
600
|
if (s) try {
|
|
417
|
-
|
|
601
|
+
k(() => {
|
|
418
602
|
s(o);
|
|
419
603
|
});
|
|
420
604
|
} catch (e) {
|
|
421
|
-
this.count("handler.threw"), typeof console < "u" &&
|
|
422
|
-
console.warn(`${
|
|
605
|
+
this.count("handler.threw"), typeof console < "u" && k(() => {
|
|
606
|
+
console.warn(`${be} The onDiagnostic handler threw an error.`, e);
|
|
423
607
|
});
|
|
424
608
|
}
|
|
425
609
|
}
|
|
@@ -445,158 +629,15 @@ var lt = class {
|
|
|
445
629
|
reset() {
|
|
446
630
|
this.counters.clear(), this.lastEmitted.clear();
|
|
447
631
|
}
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
function
|
|
454
|
-
let n = Reflect.get(e, t);
|
|
455
|
-
return typeof n == "string" && n !== "" ? n : void 0;
|
|
456
|
-
}
|
|
457
|
-
function G(e, t) {
|
|
458
|
-
let n = Reflect.get(e, t);
|
|
459
|
-
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
460
|
-
}
|
|
461
|
-
function ft(e) {
|
|
462
|
-
if (typeof e != "object" || !e) return null;
|
|
463
|
-
let t = W(e, "id"), n = W(e, "name"), r = G(e, "startedAt");
|
|
464
|
-
return t === void 0 || n === void 0 || r === void 0 ? null : {
|
|
465
|
-
id: t,
|
|
466
|
-
name: n,
|
|
467
|
-
startedAt: r,
|
|
468
|
-
parentId: W(e, "parentId"),
|
|
469
|
-
ownerContextId: W(e, "ownerContextId") ?? ""
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
function pt(e) {
|
|
473
|
-
if (typeof e != "object" || !e) return null;
|
|
474
|
-
let t = W(e, "i"), n = W(e, "n");
|
|
475
|
-
return t === void 0 || n === void 0 ? null : {
|
|
476
|
-
id: t,
|
|
477
|
-
name: n,
|
|
478
|
-
startedAt: G(e, "s") ?? Date.now(),
|
|
479
|
-
parentId: void 0,
|
|
480
|
-
ownerContextId: ""
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
function mt(e) {
|
|
484
|
-
let t = JSON.stringify({
|
|
485
|
-
i: e.id,
|
|
486
|
-
n: e.name.slice(0, 64),
|
|
487
|
-
s: e.startedAt
|
|
488
|
-
}), n = new TextEncoder().encode(t), r = "";
|
|
489
|
-
for (let e of n) r += String.fromCharCode(e);
|
|
490
|
-
return btoa(r).replace(ce, "-").replace(ne, "_").replace(le, "");
|
|
491
|
-
}
|
|
492
|
-
var ht = class {
|
|
493
|
-
options;
|
|
494
|
-
diagnostics;
|
|
495
|
-
contextId;
|
|
496
|
-
onLocalChange;
|
|
497
|
-
stores;
|
|
498
|
-
journey = null;
|
|
499
|
-
expiryTimer = null;
|
|
500
|
-
constructor(e, t, n, r, i = M) {
|
|
501
|
-
this.options = e, this.diagnostics = t, this.contextId = n, this.onLocalChange = r, this.stores = i;
|
|
502
|
-
}
|
|
503
|
-
current() {
|
|
504
|
-
return this.journey;
|
|
505
|
-
}
|
|
506
|
-
async bootstrap() {
|
|
507
|
-
let e = this.readUrlToken();
|
|
508
|
-
if (e && this.adopt(e, "url")) return;
|
|
509
|
-
let t = this.diagnostics.guard("storage.unavailable", "The library could not read the persisted journey.", () => this.stores.session().getItem(O));
|
|
510
|
-
if (t && this.restore(t)) return;
|
|
511
|
-
let n = await this.readOpenFinToken();
|
|
512
|
-
n !== null && this.adopt(n, "openfin.customData");
|
|
513
|
-
}
|
|
514
|
-
start(e, t = {}) {
|
|
515
|
-
let n = {
|
|
516
|
-
id: t.id ?? j(this.diagnostics),
|
|
517
|
-
name: e,
|
|
518
|
-
startedAt: Date.now(),
|
|
519
|
-
parentId: t.parent ? this.journey?.id : void 0,
|
|
520
|
-
ownerContextId: this.contextId
|
|
521
|
-
};
|
|
522
|
-
return this.setJourney(n), this.onLocalChange(n), n;
|
|
523
|
-
}
|
|
524
|
-
end() {
|
|
525
|
-
this.journey !== null && (this.setJourney(null), this.onLocalChange(null));
|
|
526
|
-
}
|
|
527
|
-
applyRemote(e) {
|
|
528
|
-
let t = this.journey;
|
|
529
|
-
(e === null || t === null || e.id !== t.id) && this.setJourney(e);
|
|
530
|
-
}
|
|
531
|
-
getToken() {
|
|
532
|
-
let e = this.journey;
|
|
533
|
-
if (e === null) return;
|
|
534
|
-
let t = mt(e);
|
|
535
|
-
if (t.length > 256) this.diagnostics.report("journey.token_too_large", "The journey token is larger than the size limit. The library does not issue it.", { length: t.length });
|
|
536
|
-
else return t;
|
|
537
|
-
}
|
|
538
|
-
adopt(e, t, n = !1) {
|
|
539
|
-
let r = this.decodeToken(e);
|
|
540
|
-
return r === null ? !1 : Date.now() - r.startedAt > this.options.maxAgeMs ? (this.diagnostics.report("journey.expired", "The library discarded a seeded journey older than maxAgeMs.", {
|
|
541
|
-
source: t,
|
|
542
|
-
name: r.name
|
|
543
|
-
}), !1) : (this.setJourney(r), this.diagnostics.report("journey.adopted", `The library adopted the journey "${r.name}".`, {
|
|
544
|
-
source: t,
|
|
545
|
-
journeyId: r.id
|
|
546
|
-
}), n && this.onLocalChange(r), !0);
|
|
547
|
-
}
|
|
548
|
-
ownerClosed(e) {
|
|
549
|
-
this.options.endOnOwnerClose && this.journey?.ownerContextId === e && this.end();
|
|
550
|
-
}
|
|
551
|
-
destroy() {
|
|
552
|
-
this.clearTimer();
|
|
553
|
-
}
|
|
554
|
-
restore(e) {
|
|
555
|
-
let t = ft(this.diagnostics.guard("storage.degraded", "The library could not parse the persisted journey.", () => JSON.parse(e)));
|
|
556
|
-
return t === null ? !1 : Date.now() - t.startedAt > this.options.maxAgeMs ? (this.diagnostics.report("journey.expired", "The library discarded a persisted journey older than maxAgeMs.", { name: t.name }), this.clearStored(), !1) : (this.setJourney(t), this.diagnostics.report("journey.adopted", `The library resumed the journey "${t.name}".`, {
|
|
557
|
-
source: "sessionStorage",
|
|
558
|
-
journeyId: t.id
|
|
559
|
-
}), !0);
|
|
560
|
-
}
|
|
561
|
-
decodeToken(e) {
|
|
562
|
-
return this.diagnostics.guard("config.invalid", "The library could not decode a seeded journey token.", () => {
|
|
563
|
-
let t = e.replace(ye, "+").replace(ge, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
|
|
564
|
-
return pt(JSON.parse(new TextDecoder().decode(i)));
|
|
565
|
-
}) ?? null;
|
|
566
|
-
}
|
|
567
|
-
setJourney(e) {
|
|
568
|
-
if (this.journey = e, this.clearTimer(), this.diagnostics.guard("storage.unavailable", "The library could not save the journey.", () => {
|
|
569
|
-
e === null ? this.stores.session().removeItem(O) : this.stores.session().setItem(O, JSON.stringify(e));
|
|
570
|
-
}), e === null) return;
|
|
571
|
-
let t = Math.max(this.options.maxAgeMs - (Date.now() - e.startedAt), 0), n = setTimeout(() => {
|
|
572
|
-
this.diagnostics.report("journey.expired", `The journey "${e.name}" reached maxAgeMs. The library ended it.`, { journeyId: e.id }), this.journey = null, this.expiryTimer = null, this.clearStored();
|
|
573
|
-
}, t);
|
|
574
|
-
this.expiryTimer = n, Ve(n);
|
|
575
|
-
}
|
|
576
|
-
clearStored() {
|
|
577
|
-
this.diagnostics.guard("storage.unavailable", "The library could not clear the persisted journey.", () => {
|
|
578
|
-
this.stores.session().removeItem(O);
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
clearTimer() {
|
|
582
|
-
this.expiryTimer !== null && (clearTimeout(this.expiryTimer), this.expiryTimer = null);
|
|
583
|
-
}
|
|
584
|
-
readUrlToken() {
|
|
585
|
-
return this.diagnostics.guard("config.invalid", "The library could not read the journey token from the URL.", () => typeof location > "u" ? null : new URL(location.href).searchParams.get(this.options.urlParam)) ?? null;
|
|
586
|
-
}
|
|
587
|
-
async readOpenFinToken() {
|
|
588
|
-
let e = globalThis.fin?.me, t = e?.getOptions;
|
|
589
|
-
if (t === void 0) return null;
|
|
590
|
-
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "The library could not read fin.me.getOptions().", () => De(t.call(e), Te)))?.customData?.[re];
|
|
591
|
-
return typeof n == "string" ? n : null;
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
//#endregion
|
|
595
|
-
//#region src/core/record.ts
|
|
596
|
-
function K(e) {
|
|
632
|
+
}, Yt = "error.", Xt = [
|
|
633
|
+
ie,
|
|
634
|
+
ve,
|
|
635
|
+
b
|
|
636
|
+
];
|
|
637
|
+
function q(e) {
|
|
597
638
|
return e;
|
|
598
639
|
}
|
|
599
|
-
var
|
|
640
|
+
var Zt = class {
|
|
600
641
|
deps;
|
|
601
642
|
resourceCache = null;
|
|
602
643
|
constructor(e) {
|
|
@@ -605,20 +646,21 @@ var gt = class {
|
|
|
605
646
|
invalidateResource() {
|
|
606
647
|
this.resourceCache = null;
|
|
607
648
|
}
|
|
608
|
-
isEnabled(e) {
|
|
609
|
-
let { config:
|
|
610
|
-
if (!
|
|
611
|
-
|
|
612
|
-
|
|
649
|
+
isEnabled(e, t) {
|
|
650
|
+
let { config: n } = this.deps;
|
|
651
|
+
if (!n.enabled) return !1;
|
|
652
|
+
if (t !== void 0 && ye.includes(t)) return !0;
|
|
653
|
+
let r = this.deps.remote.sampling?.minLevel() ?? n.minLevel;
|
|
654
|
+
return x[e] >= x[r];
|
|
613
655
|
}
|
|
614
656
|
build(e) {
|
|
615
657
|
let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o, remote: s } = this.deps;
|
|
616
|
-
if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"), {
|
|
658
|
+
if (!this.isEnabled(e.level, e.type)) return n.count("record.dropped_by_level"), {
|
|
617
659
|
record: null,
|
|
618
660
|
dropped: "level"
|
|
619
661
|
};
|
|
620
662
|
let c = r.resolve(), l = i.current();
|
|
621
|
-
if (!
|
|
663
|
+
if (!Oe({
|
|
622
664
|
level: e.level,
|
|
623
665
|
type: e.type,
|
|
624
666
|
namespace: e.namespace,
|
|
@@ -628,91 +670,146 @@ var gt = class {
|
|
|
628
670
|
record: null,
|
|
629
671
|
dropped: "sampling"
|
|
630
672
|
};
|
|
631
|
-
let u = a.next(), d =
|
|
673
|
+
let u = a.next(), d = Ve(n), f = t.capture.fullUrls ? d : Be(d), p, m = 0;
|
|
632
674
|
try {
|
|
633
|
-
let t =
|
|
675
|
+
let t = A(this.deps.context.getAll(), o, n), r = A(e.scoped ?? {}, o, n), i = A(e.payload ?? {}, o, n);
|
|
634
676
|
m = t.bytes + r.bytes + i.bytes, p = {
|
|
635
|
-
...
|
|
636
|
-
...
|
|
637
|
-
...
|
|
677
|
+
...q(t.value),
|
|
678
|
+
...q(r.value),
|
|
679
|
+
...q(i.value)
|
|
638
680
|
};
|
|
639
681
|
} catch (e) {
|
|
640
|
-
n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [
|
|
682
|
+
n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [he]: !0 };
|
|
641
683
|
}
|
|
642
|
-
p[
|
|
643
|
-
let h =
|
|
684
|
+
p[S] = e.type, p[T] = u, p[pe] = e.namespace, p[ie] = f, l && (p[ve] = l.id, p[b] = l.name, l.parentId !== void 0 && (p[de] = l.parentId));
|
|
685
|
+
let h = Ae(e.body, o.maxBodyChars);
|
|
644
686
|
h !== e.body && n.count("record.truncated");
|
|
645
687
|
let g = {
|
|
646
|
-
timeUnixNano:
|
|
688
|
+
timeUnixNano: De(),
|
|
647
689
|
traceId: c.traceId,
|
|
648
690
|
spanId: c.spanId,
|
|
649
691
|
traceFlags: c.traceFlags,
|
|
650
|
-
severityNumber:
|
|
692
|
+
severityNumber: C[e.level],
|
|
651
693
|
severityText: e.level,
|
|
652
694
|
body: h,
|
|
653
695
|
attributes: p,
|
|
654
696
|
resource: this.resource()
|
|
655
697
|
}, _ = t.redact;
|
|
656
698
|
if (_) {
|
|
657
|
-
let e
|
|
699
|
+
let e;
|
|
700
|
+
try {
|
|
701
|
+
e = _(g);
|
|
702
|
+
} catch (e) {
|
|
703
|
+
return n.report("record.dropped_by_redact", "The redact hook threw an error. The library dropped the record.", void 0, e), {
|
|
704
|
+
record: null,
|
|
705
|
+
dropped: "redact"
|
|
706
|
+
};
|
|
707
|
+
}
|
|
658
708
|
if (e === null) return n.count("record.dropped_by_redact"), {
|
|
659
709
|
record: null,
|
|
660
710
|
dropped: "redact"
|
|
661
711
|
};
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
712
|
+
let t = e ?? g;
|
|
713
|
+
if (!O(t)) return t === g ? (n.report("record.dropped_malformed", "The redact hook changed the record to a shape that is not a record. The library dropped it."), {
|
|
714
|
+
record: null,
|
|
715
|
+
dropped: "malformed"
|
|
716
|
+
}) : (n.report("record.dropped_by_redact", "The redact hook returned a value that is not a record. The library dropped the record."), {
|
|
717
|
+
record: null,
|
|
718
|
+
dropped: "redact"
|
|
719
|
+
});
|
|
720
|
+
if (Te(t.severityText)) {
|
|
721
|
+
if (t !== g) {
|
|
722
|
+
let e = A(t.attributes, o, n);
|
|
665
723
|
g = {
|
|
666
|
-
...
|
|
667
|
-
attributes:
|
|
668
|
-
}, m =
|
|
669
|
-
}
|
|
670
|
-
|
|
724
|
+
...t,
|
|
725
|
+
attributes: q(e.value)
|
|
726
|
+
}, m = e.bytes;
|
|
727
|
+
}
|
|
728
|
+
g.severityNumber = C[g.severityText];
|
|
729
|
+
} else return n.report("record.dropped_malformed", "The redact hook set a severityText that is not a log level. The library dropped the record."), {
|
|
730
|
+
record: null,
|
|
731
|
+
dropped: "malformed"
|
|
732
|
+
};
|
|
671
733
|
}
|
|
672
734
|
if (m > o.maxRecordBytes) {
|
|
673
|
-
n.report("record.truncated", "The attributes are larger than the size limit. The library dropped
|
|
735
|
+
n.report("record.truncated", "The attributes are larger than the size limit. The library dropped the caller attributes.", {
|
|
674
736
|
bytes: m,
|
|
675
737
|
body: g.body
|
|
676
738
|
});
|
|
677
739
|
let t = {
|
|
678
|
-
[
|
|
679
|
-
[
|
|
680
|
-
[
|
|
681
|
-
[
|
|
682
|
-
[
|
|
683
|
-
[be]: m
|
|
740
|
+
[S]: e.type,
|
|
741
|
+
[T]: u,
|
|
742
|
+
[pe]: e.namespace,
|
|
743
|
+
[se]: !0,
|
|
744
|
+
[_e]: m
|
|
684
745
|
};
|
|
685
|
-
|
|
746
|
+
for (let e of Xt) e in g.attributes && (t[e] = g.attributes[e]);
|
|
747
|
+
for (let [e, n] of Object.entries(g.attributes)) e.startsWith(Yt) && (t[e] = n);
|
|
748
|
+
let r = A(t, o, n).bytes;
|
|
749
|
+
r > o.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t, me), r = A(t, o, n).bytes);
|
|
750
|
+
let i = g.attributes[y];
|
|
751
|
+
if (i !== void 0) {
|
|
752
|
+
let e = A(i, o, n).bytes;
|
|
753
|
+
r + e <= o.maxRecordBytes && (t[y] = i);
|
|
754
|
+
}
|
|
755
|
+
g.attributes = t;
|
|
686
756
|
}
|
|
687
757
|
return { record: g };
|
|
688
758
|
}
|
|
689
759
|
resource() {
|
|
690
760
|
if (this.resourceCache) return this.resourceCache;
|
|
691
|
-
let { config:
|
|
761
|
+
let { config: t, identity: n, platform: r } = this.deps;
|
|
692
762
|
return this.resourceCache = {
|
|
693
|
-
[
|
|
694
|
-
[
|
|
695
|
-
[
|
|
696
|
-
[
|
|
697
|
-
[
|
|
698
|
-
[
|
|
699
|
-
[
|
|
700
|
-
[
|
|
701
|
-
[
|
|
702
|
-
[
|
|
703
|
-
[
|
|
704
|
-
...
|
|
705
|
-
...
|
|
763
|
+
[l]: t.serviceName,
|
|
764
|
+
[g]: t.serviceVersion,
|
|
765
|
+
[f]: t.environment,
|
|
766
|
+
[a]: ae,
|
|
767
|
+
[ee]: w,
|
|
768
|
+
[te]: re,
|
|
769
|
+
[h]: r.platform,
|
|
770
|
+
[Se]: n.sessionId,
|
|
771
|
+
[e]: n.tabId,
|
|
772
|
+
[u]: n.contextId,
|
|
773
|
+
[le]: r.userAgent,
|
|
774
|
+
...r.openfinUuid === void 0 ? {} : { [o]: r.openfinUuid },
|
|
775
|
+
...r.openfinName === void 0 ? {} : { [i]: r.openfinName }
|
|
706
776
|
}, this.resourceCache;
|
|
707
777
|
}
|
|
708
|
-
},
|
|
709
|
-
errors: async () => (await import("./errors-
|
|
710
|
-
network: async () => (await import("./network-
|
|
711
|
-
interactions: async () => (await import("./interactions-
|
|
712
|
-
webVitals: async () => (await import("./web-vitals-
|
|
713
|
-
longFrames: async () => (await import("./long-frames-
|
|
714
|
-
console: async () => (await import("./console-
|
|
715
|
-
},
|
|
778
|
+
}, Qt = {
|
|
779
|
+
errors: async () => (await import("./errors-DH4QJS0u.js")).ErrorCapture,
|
|
780
|
+
network: async () => (await import("./network-D_lloS5t.js")).NetworkCapture,
|
|
781
|
+
interactions: async () => (await import("./interactions-OU94MPXs.js")).InteractionCapture,
|
|
782
|
+
webVitals: async () => (await import("./web-vitals-Bflr5jSA.js")).WebVitalsCapture,
|
|
783
|
+
longFrames: async () => (await import("./long-frames-C_7OutLs.js")).LongFrameCapture,
|
|
784
|
+
console: async () => (await import("./console-DjLbryED.js")).ConsoleCapture
|
|
785
|
+
}, J = Symbol.for(ge), Y = Symbol.for(s);
|
|
786
|
+
function $t(e) {
|
|
787
|
+
return JSON.stringify({
|
|
788
|
+
...e,
|
|
789
|
+
webVitalsLoader: e.webVitalsLoader !== void 0,
|
|
790
|
+
ignoreUrls: e.ignoreUrls.map(String),
|
|
791
|
+
propagateTraceHeaderTo: e.propagateTraceHeaderTo.map(String)
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
function en(e) {
|
|
795
|
+
return {
|
|
796
|
+
...e,
|
|
797
|
+
endpoint: null,
|
|
798
|
+
transport: void 0,
|
|
799
|
+
transportOnExit: void 0,
|
|
800
|
+
bus: {
|
|
801
|
+
...e.bus,
|
|
802
|
+
mode: "off"
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
function X(e) {
|
|
807
|
+
return e.sdkVersion === w;
|
|
808
|
+
}
|
|
809
|
+
var Z = class e {
|
|
810
|
+
degraded;
|
|
811
|
+
static local = null;
|
|
812
|
+
sdkVersion = w;
|
|
716
813
|
diagnostics;
|
|
717
814
|
config;
|
|
718
815
|
platform;
|
|
@@ -720,10 +817,10 @@ var gt = class {
|
|
|
720
817
|
stores;
|
|
721
818
|
identityBuiltAs;
|
|
722
819
|
sessionTouch;
|
|
723
|
-
context = new
|
|
820
|
+
context = new qt();
|
|
724
821
|
breadcrumbs;
|
|
725
822
|
tracing;
|
|
726
|
-
sequence = new
|
|
823
|
+
sequence = new et();
|
|
727
824
|
journey;
|
|
728
825
|
builder;
|
|
729
826
|
remote = { sampling: null };
|
|
@@ -750,13 +847,13 @@ var gt = class {
|
|
|
750
847
|
ready = !1;
|
|
751
848
|
destroyed = !1;
|
|
752
849
|
lastGapAt = 0;
|
|
753
|
-
constructor(e) {
|
|
754
|
-
this.diagnostics = new
|
|
850
|
+
constructor(e, t = !1) {
|
|
851
|
+
this.degraded = t, this.diagnostics = new Jt(e.onDiagnostic), this.platform = ze(this.diagnostics), this.config = Wt(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Ie() : Pe, this.identity = Re(this.diagnostics, this.stores), this.sessionTouch = new Me(this.diagnostics, this.stores), this.breadcrumbs = new ut(50), this.tracing = new lt(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new $e(this.config.console, this.diagnostics), this.journey = new He(Ue, this.diagnostics, this.identity.contextId, (e) => {
|
|
755
852
|
this.bus?.broadcastJourney(e);
|
|
756
|
-
}, this.stores), this.builder = new
|
|
853
|
+
}, this.stores), this.builder = new Zt({
|
|
757
854
|
remote: this.remote,
|
|
758
855
|
config: this.config,
|
|
759
|
-
limits:
|
|
856
|
+
limits: n,
|
|
760
857
|
diagnostics: this.diagnostics,
|
|
761
858
|
context: this.context,
|
|
762
859
|
journey: this.journey,
|
|
@@ -773,24 +870,48 @@ var gt = class {
|
|
|
773
870
|
});
|
|
774
871
|
});
|
|
775
872
|
};
|
|
873
|
+
static pinned() {
|
|
874
|
+
return globalThis[J] ?? null;
|
|
875
|
+
}
|
|
776
876
|
static current() {
|
|
777
|
-
|
|
877
|
+
let t = e.local;
|
|
878
|
+
if (t) return t.destroyed ? null : t;
|
|
879
|
+
let n = e.pinned();
|
|
880
|
+
return n && X(n) ? n : null;
|
|
778
881
|
}
|
|
779
882
|
static stopped() {
|
|
780
|
-
|
|
883
|
+
let t = e.local;
|
|
884
|
+
if (t?.destroyed) return t;
|
|
885
|
+
let n = globalThis[Y];
|
|
886
|
+
return n && X(n) ? n : null;
|
|
781
887
|
}
|
|
782
888
|
isDestroyed() {
|
|
783
889
|
return this.destroyed;
|
|
784
890
|
}
|
|
785
891
|
static configure(t) {
|
|
786
|
-
let n = e.
|
|
787
|
-
if (n && !n.destroyed) return n.reconfigure(t), n;
|
|
788
|
-
|
|
789
|
-
|
|
892
|
+
let n = e.local;
|
|
893
|
+
if (n && !n.destroyed) return n.reconfigure(en(t)), n;
|
|
894
|
+
e.local = null;
|
|
895
|
+
let r = e.pinned();
|
|
896
|
+
if (r) {
|
|
897
|
+
if (!X(r)) return e.startDegraded(t, r.sdkVersion);
|
|
898
|
+
if (!r.destroyed) return r.reconfigure(t), r;
|
|
899
|
+
}
|
|
900
|
+
let i = new e(t);
|
|
901
|
+
return globalThis[J] = i, Reflect.deleteProperty(globalThis, Y), i.init(), i;
|
|
902
|
+
}
|
|
903
|
+
static startDegraded(t, n) {
|
|
904
|
+
let r = new e(en(t), !0);
|
|
905
|
+
e.local = r;
|
|
906
|
+
let i = typeof n == "string" ? n : "before 0.9.0";
|
|
907
|
+
return r.diagnostics.report("runtime.version_mismatch", `Another copy of the library, version ${i}, owns the page runtime. This copy, version ${w}, runs in console-only mode and installs no capture. Load one version of the library on the page.`, {
|
|
908
|
+
found: i,
|
|
909
|
+
own: w
|
|
910
|
+
}), r.init(), r;
|
|
790
911
|
}
|
|
791
912
|
reconfigure(e) {
|
|
792
|
-
let t = this.keepDestination(e);
|
|
793
|
-
|
|
913
|
+
let t = this.keepDestination(e), n = $t(this.config.capture);
|
|
914
|
+
Kt(this.config, Wt(t, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), $t(this.config.capture) !== n && this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
|
|
794
915
|
}
|
|
795
916
|
keepBuiltStorage() {
|
|
796
917
|
let e = this.storageBuiltAs;
|
|
@@ -839,7 +960,7 @@ var gt = class {
|
|
|
839
960
|
}
|
|
840
961
|
async buildBus() {
|
|
841
962
|
try {
|
|
842
|
-
let { Bus: e } = await import("./bus-
|
|
963
|
+
let { Bus: e } = await import("./bus-D8kH58tb.js");
|
|
843
964
|
if (this.destroyed) return null;
|
|
844
965
|
let t = new e(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
|
|
845
966
|
onRecords: (e) => {
|
|
@@ -871,7 +992,7 @@ var gt = class {
|
|
|
871
992
|
async buildSender() {
|
|
872
993
|
this.storageBuiltAs = this.config.storage;
|
|
873
994
|
try {
|
|
874
|
-
let { Sender: e } = await import("./sender-
|
|
995
|
+
let { Sender: e } = await import("./sender-BnNj9bOX.js"), t = this.destroyed ? null : await e.create({
|
|
875
996
|
config: this.config,
|
|
876
997
|
diagnostics: this.diagnostics,
|
|
877
998
|
onGap: this.reportGap,
|
|
@@ -890,20 +1011,21 @@ var gt = class {
|
|
|
890
1011
|
for (let t of e) this.sender?.push(t);
|
|
891
1012
|
}
|
|
892
1013
|
async installCaptures() {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1014
|
+
if (this.degraded) return;
|
|
1015
|
+
let e = ++this.captureGeneration, t = this.config.capture, n = [];
|
|
1016
|
+
(t.errors || t.rejections || t.resourceErrors) && n.push("errors"), (t.fetch || t.xhr) && n.push("network"), (t.interactions || t.navigation) && n.push("interactions"), t.webVitals && n.push("webVitals"), t.longFrames && n.push("longFrames"), (Array.isArray(t.console) ? t.console.length > 0 : t.console) && n.push("console");
|
|
1017
|
+
let r = await Promise.all(n.map((e) => this.loadCapture(e)));
|
|
896
1018
|
if (e !== this.captureGeneration || this.destroyed) return;
|
|
897
1019
|
this.uninstallCaptures();
|
|
898
|
-
let
|
|
1020
|
+
let i = {
|
|
899
1021
|
config: this.config,
|
|
900
1022
|
diagnostics: this.diagnostics,
|
|
901
1023
|
breadcrumbs: this.breadcrumbs,
|
|
902
1024
|
tracing: this.tracing,
|
|
903
|
-
logger: new
|
|
1025
|
+
logger: new F(() => this, _),
|
|
904
1026
|
once: this.captureOnce
|
|
905
1027
|
};
|
|
906
|
-
for (let e of
|
|
1028
|
+
for (let e of r) e && this.captures.push(new e(i));
|
|
907
1029
|
for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `The library could not install the ${e.name} capture.`, () => {
|
|
908
1030
|
e.install();
|
|
909
1031
|
});
|
|
@@ -915,7 +1037,7 @@ var gt = class {
|
|
|
915
1037
|
this.captures.length = 0;
|
|
916
1038
|
}
|
|
917
1039
|
loadCapture(e) {
|
|
918
|
-
return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`,
|
|
1040
|
+
return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, Qt[e]);
|
|
919
1041
|
}
|
|
920
1042
|
registerWorker(e) {
|
|
921
1043
|
this.destroyed || this.constructBus().then((t) => {
|
|
@@ -928,7 +1050,7 @@ var gt = class {
|
|
|
928
1050
|
if (this.destroyed) return;
|
|
929
1051
|
this.destroyed = !0, this.uninstallCaptures();
|
|
930
1052
|
let t = this.sender?.destroy();
|
|
931
|
-
this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.
|
|
1053
|
+
this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.pinned() === this && (Reflect.deleteProperty(globalThis, J), globalThis[Y] = this);
|
|
932
1054
|
}
|
|
933
1055
|
emit(e) {
|
|
934
1056
|
e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.pushCapped(this.bootBuffer, e));
|
|
@@ -937,7 +1059,7 @@ var gt = class {
|
|
|
937
1059
|
this.role() === "forwarder" ? this.forward(e) : this.deliver(e);
|
|
938
1060
|
}
|
|
939
1061
|
deliver(e) {
|
|
940
|
-
this.sender ? this.sender.push(e) : this.senderLoad
|
|
1062
|
+
this.sender ? this.sender.push(e) : this.senderLoad ? this.pushCapped(this.pendingRecords, e) : this.diagnostics.count("record.dropped_no_destination");
|
|
941
1063
|
}
|
|
942
1064
|
pushCapped(e, t) {
|
|
943
1065
|
e.length >= 500 && (e.shift(), this.diagnostics.count("record.dropped_boot_buffer_full")), e.push(t);
|
|
@@ -951,7 +1073,7 @@ var gt = class {
|
|
|
951
1073
|
}
|
|
952
1074
|
ingestForwarded(e) {
|
|
953
1075
|
if (!Array.isArray(e)) this.diagnostics.count("record.dropped_malformed");
|
|
954
|
-
else for (let t of e)
|
|
1076
|
+
else for (let t of e) O(t) ? Ee(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
|
|
955
1077
|
}
|
|
956
1078
|
releaseBootBuffer() {
|
|
957
1079
|
let e = this.bootBuffer;
|
|
@@ -961,18 +1083,18 @@ var gt = class {
|
|
|
961
1083
|
}
|
|
962
1084
|
reportGap = (e) => {
|
|
963
1085
|
let t = Date.now();
|
|
964
|
-
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new
|
|
1086
|
+
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new F(() => this, ce).warn("stored records were dropped before delivery", {
|
|
965
1087
|
"gap.batches": e.batches,
|
|
966
1088
|
"gap.records": e.records,
|
|
967
1089
|
"gap.reason": e.reason
|
|
968
1090
|
}));
|
|
969
1091
|
};
|
|
970
1092
|
regenerateTabId() {
|
|
971
|
-
let e =
|
|
1093
|
+
let e = Le(this.diagnostics);
|
|
972
1094
|
this.diagnostics.report("bus.role_resolved", "Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.", {
|
|
973
1095
|
was: this.identity.tabId,
|
|
974
1096
|
now: e
|
|
975
|
-
}), this.identity.tabId = e,
|
|
1097
|
+
}), this.identity.tabId = e, Ne(e, this.diagnostics, this.stores), this.builder.invalidateResource();
|
|
976
1098
|
}
|
|
977
1099
|
async queueDepth() {
|
|
978
1100
|
return await this.senderLoad, await this.sender?.queueDepth() ?? 0;
|
|
@@ -986,7 +1108,7 @@ var gt = class {
|
|
|
986
1108
|
};
|
|
987
1109
|
//#endregion
|
|
988
1110
|
//#region src/transport/memory-transport.ts
|
|
989
|
-
function
|
|
1111
|
+
function tn() {
|
|
990
1112
|
let e = [], t = [], n = { status: 200 };
|
|
991
1113
|
return {
|
|
992
1114
|
transport: (r) => (e.push(r), n.status >= 200 && n.status < 300 && t.push(r), Promise.resolve({ ...n })),
|
|
@@ -1005,97 +1127,100 @@ function vt() {
|
|
|
1005
1127
|
}
|
|
1006
1128
|
//#endregion
|
|
1007
1129
|
//#region src/index.ts
|
|
1008
|
-
var
|
|
1009
|
-
function
|
|
1010
|
-
return (
|
|
1130
|
+
var nn = /* @__PURE__ */ new Map();
|
|
1131
|
+
function Q() {
|
|
1132
|
+
return (Z.current() ?? Z.stopped()) || Z.configure({});
|
|
1011
1133
|
}
|
|
1012
|
-
function
|
|
1013
|
-
|
|
1134
|
+
function rn(e) {
|
|
1135
|
+
Z.configure(e);
|
|
1014
1136
|
}
|
|
1015
|
-
function
|
|
1016
|
-
if (t) return new
|
|
1017
|
-
let n =
|
|
1018
|
-
return n || (n = new
|
|
1137
|
+
function an(e, t) {
|
|
1138
|
+
if (t) return new F(Q, e, t);
|
|
1139
|
+
let n = nn.get(e);
|
|
1140
|
+
return n || (n = new F(Q, e), nn.set(e, n)), n;
|
|
1019
1141
|
}
|
|
1020
1142
|
function $() {
|
|
1021
|
-
return
|
|
1143
|
+
return an("app");
|
|
1022
1144
|
}
|
|
1023
|
-
function
|
|
1145
|
+
function on(e, t) {
|
|
1024
1146
|
$().trace(e, t);
|
|
1025
1147
|
}
|
|
1026
|
-
function
|
|
1148
|
+
function sn(e, t) {
|
|
1027
1149
|
$().debug(e, t);
|
|
1028
1150
|
}
|
|
1029
|
-
function
|
|
1151
|
+
function cn(e, t) {
|
|
1030
1152
|
$().info(e, t);
|
|
1031
1153
|
}
|
|
1032
|
-
function
|
|
1154
|
+
function ln(e, t) {
|
|
1033
1155
|
$().warn(e, t);
|
|
1034
1156
|
}
|
|
1035
|
-
function
|
|
1157
|
+
function un(e, t, n) {
|
|
1036
1158
|
$().error(e, t, n);
|
|
1037
1159
|
}
|
|
1038
|
-
function
|
|
1160
|
+
function dn(e, t, n) {
|
|
1161
|
+
$().fatal(e, t, n);
|
|
1162
|
+
}
|
|
1163
|
+
function fn(e, t) {
|
|
1039
1164
|
$().logAction(e, t);
|
|
1040
1165
|
}
|
|
1041
|
-
function
|
|
1166
|
+
function pn(e, t) {
|
|
1042
1167
|
$().logEvent(e, t);
|
|
1043
1168
|
}
|
|
1044
|
-
function
|
|
1169
|
+
function mn(e, t, n, r, i) {
|
|
1045
1170
|
$().logMetric(e, t, n, r, i);
|
|
1046
1171
|
}
|
|
1047
|
-
function
|
|
1172
|
+
function hn(e, t, n) {
|
|
1048
1173
|
return $().timeSync(e, t, n);
|
|
1049
1174
|
}
|
|
1050
|
-
function
|
|
1175
|
+
function gn(e, t, n) {
|
|
1051
1176
|
return $().timeAsync(e, t, n);
|
|
1052
1177
|
}
|
|
1053
|
-
function
|
|
1054
|
-
|
|
1178
|
+
function _n(e, t) {
|
|
1179
|
+
Q().context.set(e, t);
|
|
1055
1180
|
}
|
|
1056
|
-
function
|
|
1057
|
-
|
|
1181
|
+
function vn(e) {
|
|
1182
|
+
Q().context.setMany(e);
|
|
1058
1183
|
}
|
|
1059
|
-
function
|
|
1060
|
-
|
|
1184
|
+
function yn(e) {
|
|
1185
|
+
Q().context.remove(e);
|
|
1061
1186
|
}
|
|
1062
|
-
function
|
|
1063
|
-
return
|
|
1187
|
+
function bn(e, t) {
|
|
1188
|
+
return Q().journey.start(e, t);
|
|
1064
1189
|
}
|
|
1065
|
-
function
|
|
1066
|
-
|
|
1190
|
+
function xn() {
|
|
1191
|
+
Q().journey.end();
|
|
1067
1192
|
}
|
|
1068
|
-
function
|
|
1069
|
-
return
|
|
1193
|
+
function Sn() {
|
|
1194
|
+
return Q().journey.current();
|
|
1070
1195
|
}
|
|
1071
|
-
function
|
|
1072
|
-
return
|
|
1196
|
+
function Cn() {
|
|
1197
|
+
return Q().journey.getToken();
|
|
1073
1198
|
}
|
|
1074
|
-
function
|
|
1075
|
-
return
|
|
1199
|
+
function wn(e) {
|
|
1200
|
+
return Q().journey.adopt(e, "manual", !0);
|
|
1076
1201
|
}
|
|
1077
|
-
function
|
|
1078
|
-
|
|
1202
|
+
function Tn(e) {
|
|
1203
|
+
Q().registerWorker(e);
|
|
1079
1204
|
}
|
|
1080
|
-
function
|
|
1081
|
-
|
|
1205
|
+
function En() {
|
|
1206
|
+
Q().tracing.rotate("explicit");
|
|
1082
1207
|
}
|
|
1083
|
-
function
|
|
1084
|
-
return
|
|
1208
|
+
function Dn() {
|
|
1209
|
+
return Q().tracing.headers();
|
|
1085
1210
|
}
|
|
1086
|
-
function
|
|
1087
|
-
return
|
|
1211
|
+
function On() {
|
|
1212
|
+
return Q().flush();
|
|
1088
1213
|
}
|
|
1089
|
-
function
|
|
1090
|
-
return
|
|
1214
|
+
function kn() {
|
|
1215
|
+
return Q().queueDepth();
|
|
1091
1216
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return
|
|
1217
|
+
function An() {
|
|
1218
|
+
return Q().diagnostics.snapshot();
|
|
1094
1219
|
}
|
|
1095
|
-
async function
|
|
1096
|
-
await
|
|
1220
|
+
async function jn() {
|
|
1221
|
+
await Z.current()?.destroy();
|
|
1097
1222
|
}
|
|
1098
1223
|
//#endregion
|
|
1099
|
-
export {
|
|
1224
|
+
export { F as OneLogger, wn as adoptJourney, rn as configure, tn as createMemoryTransport, Sn as currentJourney, sn as debug, xn as endJourney, un as error, dn as fatal, On as flush, An as getDiagnosticCounters, Cn as getJourneyToken, an as getLogger, kn as getQueueDepth, Dn as getTraceHeaders, cn as info, fn as logAction, pn as logEvent, mn as logMetric, Tn as registerWorker, yn as removeContext, _n as setContext, vn as setContextMap, jn as shutdown, bn as startJourney, En as startTrace, gn as timeAsync, hn as timeSync, on as trace, ln as warn };
|
|
1100
1225
|
|
|
1101
1226
|
//# sourceMappingURL=index.js.map
|