@utk09/ui-observability 0.9.0 → 0.9.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/CHANGELOG.md +63 -0
- package/README.md +83 -52
- package/dist/batch-4xKzzSCj.js +31 -0
- package/dist/batch-4xKzzSCj.js.map +1 -0
- package/dist/batch-cys7e53Q.cjs +2 -0
- package/dist/batch-cys7e53Q.cjs.map +1 -0
- package/dist/{bus-CtJWf9QN.cjs → bus-B6vzPmQM.cjs} +2 -2
- package/dist/{bus-CtJWf9QN.cjs.map → bus-B6vzPmQM.cjs.map} +1 -1
- package/dist/{bus-D8kH58tb.js → bus-DrixwdiX.js} +10 -10
- package/dist/{bus-D8kH58tb.js.map → bus-DrixwdiX.js.map} +1 -1
- package/dist/capture/network.d.ts +2 -0
- package/dist/capture/types.d.ts +3 -0
- package/dist/{console-DjLbryED.js → console-B3vGRW5p.js} +3 -3
- package/dist/{console-DjLbryED.js.map → console-B3vGRW5p.js.map} +1 -1
- package/dist/{console-BpHfWstv.cjs → console-ChfuJlf9.cjs} +2 -2
- package/dist/{console-BpHfWstv.cjs.map → console-ChfuJlf9.cjs.map} +1 -1
- package/dist/constants-Be83LICb.cjs +2 -0
- package/dist/constants-Be83LICb.cjs.map +1 -0
- package/dist/constants-CQ_D7jIW.js +144 -0
- package/dist/constants-CQ_D7jIW.js.map +1 -0
- package/dist/constants.d.ts +44 -11
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/drops.d.ts +29 -0
- package/dist/core/hold-buffer.d.ts +27 -0
- package/dist/core/meter.d.ts +45 -0
- package/dist/core/pipeline.d.ts +7 -19
- package/dist/core/record.d.ts +7 -0
- package/dist/core/runtime.d.ts +61 -8
- package/dist/core/sampling.d.ts +2 -0
- package/dist/core/sender.d.ts +6 -1
- package/dist/deadline-5_PecIl5.js +26 -0
- package/dist/deadline-5_PecIl5.js.map +1 -0
- package/dist/deadline-XSnm95pg.cjs +2 -0
- package/dist/deadline-XSnm95pg.cjs.map +1 -0
- package/dist/{errors-DH4QJS0u.js → errors-BGs5NOrw.js} +4 -4
- package/dist/{errors-DH4QJS0u.js.map → errors-BGs5NOrw.js.map} +1 -1
- package/dist/{errors-CpGRhhIf.cjs → errors-BMJm7KZZ.cjs} +2 -2
- package/dist/{errors-CpGRhhIf.cjs.map → errors-BMJm7KZZ.cjs.map} +1 -1
- package/dist/identity-DXyV86o-.cjs +2 -0
- package/dist/identity-DXyV86o-.cjs.map +1 -0
- package/dist/{deadline-B5DINjD5.js → identity-rpEyjvVg.js} +3 -26
- package/dist/identity-rpEyjvVg.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.js +683 -369
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-BXaPVPyG.cjs +2 -0
- package/dist/indexeddb-storage-BXaPVPyG.cjs.map +1 -0
- package/dist/{indexeddb-storage-n1qkFBGA.js → indexeddb-storage-Q9fDYlyn.js} +76 -47
- package/dist/indexeddb-storage-Q9fDYlyn.js.map +1 -0
- package/dist/{interactions-OU94MPXs.js → interactions-B8zjCjga.js} +2 -2
- package/dist/{interactions-OU94MPXs.js.map → interactions-B8zjCjga.js.map} +1 -1
- package/dist/{interactions-31eHGwEQ.cjs → interactions-BAGRmtrv.cjs} +2 -2
- package/dist/{interactions-31eHGwEQ.cjs.map → interactions-BAGRmtrv.cjs.map} +1 -1
- package/dist/journey-BGSyy8Es.cjs +2 -0
- package/dist/journey-BGSyy8Es.cjs.map +1 -0
- package/dist/{journey-CeJ1QoT2.js → journey-_dQQ1eMP.js} +27 -26
- package/dist/{journey-CeJ1QoT2.js.map → journey-_dQQ1eMP.js.map} +1 -1
- package/dist/library-request-BIG3Xpx3.cjs +2 -0
- package/dist/library-request-BIG3Xpx3.cjs.map +1 -0
- package/dist/library-request-DX6ev9oG.js +25 -0
- package/dist/library-request-DX6ev9oG.js.map +1 -0
- package/dist/{long-frames-C_7OutLs.js → long-frames-B0tKuChx.js} +3 -3
- package/dist/{long-frames-C_7OutLs.js.map → long-frames-B0tKuChx.js.map} +1 -1
- package/dist/{long-frames-B8VdA_ny.cjs → long-frames-Cq2LgNnp.cjs} +2 -2
- package/dist/{long-frames-B8VdA_ny.cjs.map → long-frames-Cq2LgNnp.cjs.map} +1 -1
- package/dist/models/batch.d.ts +14 -0
- package/dist/models/config.d.ts +169 -0
- package/dist/models/drop.d.ts +39 -0
- package/dist/models/metric.d.ts +50 -0
- package/dist/models/storage.d.ts +15 -3
- package/dist/network-C6kJbW6K.cjs +2 -0
- package/dist/network-C6kJbW6K.cjs.map +1 -0
- package/dist/network-CMnEvGJB.js +211 -0
- package/dist/network-CMnEvGJB.js.map +1 -0
- package/dist/{platform-D4wu1eIF.cjs → platform-DNOJjpOm.cjs} +2 -2
- package/dist/{platform-D4wu1eIF.cjs.map → platform-DNOJjpOm.cjs.map} +1 -1
- package/dist/{platform-IHBZGqUe.js → platform-j0uMPwHi.js} +3 -3
- package/dist/{platform-IHBZGqUe.js.map → platform-j0uMPwHi.js.map} +1 -1
- package/dist/{remote-rules-kuDf5gbe.cjs → remote-rules-DgoBJxZL.cjs} +2 -2
- package/dist/{remote-rules-kuDf5gbe.cjs.map → remote-rules-DgoBJxZL.cjs.map} +1 -1
- package/dist/{remote-rules-Bt1XsdEQ.js → remote-rules-UggoZqfP.js} +11 -11
- package/dist/{remote-rules-Bt1XsdEQ.js.map → remote-rules-UggoZqfP.js.map} +1 -1
- package/dist/{sampling-o0VY1mqQ.js → sampling-BLMD8EGM.js} +28 -27
- package/dist/sampling-BLMD8EGM.js.map +1 -0
- package/dist/sampling-MthcVXXU.cjs +2 -0
- package/dist/sampling-MthcVXXU.cjs.map +1 -0
- package/dist/{sanitize-B9UheVKc.js → sanitize-BNwgPj_B.js} +2 -2
- package/dist/{sanitize-B9UheVKc.js.map → sanitize-BNwgPj_B.js.map} +1 -1
- package/dist/{sanitize-DSIP7amZ.cjs → sanitize-BqzPc4Jg.cjs} +2 -2
- package/dist/{sanitize-DSIP7amZ.cjs.map → sanitize-BqzPc4Jg.cjs.map} +1 -1
- package/dist/sender--0_VzPbN.js +1249 -0
- package/dist/sender--0_VzPbN.js.map +1 -0
- package/dist/sender-SPGMqZjD.cjs +3 -0
- package/dist/sender-SPGMqZjD.cjs.map +1 -0
- package/dist/storage/emergency-queue.d.ts +4 -1
- package/dist/storage/eviction.d.ts +40 -0
- package/dist/storage/idb-driver.d.ts +6 -0
- package/dist/storage/indexeddb-storage.d.ts +13 -5
- package/dist/storage/local-storage.d.ts +24 -1
- package/dist/storage/memory-storage.d.ts +7 -0
- package/dist/{storm-Y-yuBhvv.cjs → storm-CTy1dfvs.cjs} +2 -2
- package/dist/{storm-Y-yuBhvv.cjs.map → storm-CTy1dfvs.cjs.map} +1 -1
- package/dist/{storm-BTw0J6eE.js → storm-knaj4GUH.js} +2 -2
- package/dist/{storm-BTw0J6eE.js.map → storm-knaj4GUH.js.map} +1 -1
- package/dist/transport/custom-transport.d.ts +3 -2
- package/dist/transport/exit-flush.d.ts +19 -2
- package/dist/transport/http-transport.d.ts +6 -4
- package/dist/transport/retry-engine.d.ts +9 -3
- package/dist/transport/serializers/otlp-metrics.d.ts +3 -0
- package/dist/transport/serializers/otlp.d.ts +30 -0
- package/dist/transport/serializers/select.d.ts +20 -4
- package/dist/transport/status-transport.d.ts +23 -12
- package/dist/utils/console.d.ts +4 -1
- package/dist/utils/library-request.d.ts +12 -0
- package/package.json +1 -1
- package/dist/constants-Br3b89Wg.cjs +0 -2
- package/dist/constants-Br3b89Wg.cjs.map +0 -1
- package/dist/constants-DM94FjVX.js +0 -96
- package/dist/constants-DM94FjVX.js.map +0 -1
- package/dist/deadline-B5DINjD5.js.map +0 -1
- package/dist/deadline-Cbg2cbUw.cjs +0 -2
- package/dist/deadline-Cbg2cbUw.cjs.map +0 -1
- package/dist/indexeddb-storage-DNdf1fmL.cjs +0 -2
- package/dist/indexeddb-storage-DNdf1fmL.cjs.map +0 -1
- package/dist/indexeddb-storage-n1qkFBGA.js.map +0 -1
- package/dist/journey-CE2EcwHW.cjs +0 -2
- package/dist/journey-CE2EcwHW.cjs.map +0 -1
- package/dist/library-request-C9uJFlbq.cjs +0 -2
- package/dist/library-request-C9uJFlbq.cjs.map +0 -1
- package/dist/library-request-DvhuplAB.js +0 -14
- package/dist/library-request-DvhuplAB.js.map +0 -1
- package/dist/network-BAV7ipyn.cjs +0 -2
- package/dist/network-BAV7ipyn.cjs.map +0 -1
- package/dist/network-D_lloS5t.js +0 -174
- package/dist/network-D_lloS5t.js.map +0 -1
- package/dist/sampling-BI15ds9D.cjs +0 -2
- package/dist/sampling-BI15ds9D.cjs.map +0 -1
- package/dist/sampling-o0VY1mqQ.js.map +0 -1
- package/dist/sender-BnNj9bOX.js +0 -1050
- package/dist/sender-BnNj9bOX.js.map +0 -1
- package/dist/sender-D0OsyB1c.cjs +0 -3
- package/dist/sender-D0OsyB1c.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,52 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { a as
|
|
4
|
-
import { a as
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as
|
|
7
|
-
import { n as
|
|
1
|
+
import { A as e, At as t, Bt as n, Cn as r, D as i, F as a, Ft as o, Gt as s, Ht as c, I as l, It as u, Kt as d, L as f, Lt as p, Qt as m, Rt as h, S as g, Sn as _, Ut as ee, Vt as te, Wt as ne, Zt as re, _n as ie, _t as ae, a as v, c as y, d as b, en as x, f as oe, ft as se, gn as S, hn as ce, i as le, in as ue, j as de, k as C, l as fe, lt as pe, m as me, mn as he, n as w, o as ge, p as T, qt as _e, r as ve, s as E, sn as ye, u as D, ut as O, vn as be, vt as k, xn as xe, yt as Se, z as Ce, zt as we } from "./constants-CQ_D7jIW.js";
|
|
2
|
+
import { n as Te, r as Ee, t as De } from "./error-like-Ywo5uRHo.js";
|
|
3
|
+
import { a as Oe, i as ke, n as Ae, o as je, r as Me } from "./sampling-BLMD8EGM.js";
|
|
4
|
+
import { a as Ne, i as Pe, n as Fe, o as A, r as j } from "./sanitize-BNwgPj_B.js";
|
|
5
|
+
import { a as Ie, i as Le, n as Re, o as ze, r as Be, s as Ve, t as He } from "./identity-rpEyjvVg.js";
|
|
6
|
+
import { n as Ue, r as We, t as Ge } from "./platform-j0uMPwHi.js";
|
|
7
|
+
import { n as M, t as Ke } from "./batch-4xKzzSCj.js";
|
|
8
|
+
import { r as qe } from "./library-request-DX6ev9oG.js";
|
|
9
|
+
import { r as Je } from "./deadline-5_PecIl5.js";
|
|
10
|
+
import { n as Ye, t as Xe } from "./journey-_dQQ1eMP.js";
|
|
8
11
|
//#region src/utils/timer.ts
|
|
9
|
-
function
|
|
10
|
-
return Math.round((performance.now() - e) *
|
|
12
|
+
function N(e) {
|
|
13
|
+
return Math.round((performance.now() - e) * Ce) / Ce;
|
|
11
14
|
}
|
|
12
|
-
function
|
|
15
|
+
function P(e, t, n, r, i) {
|
|
13
16
|
e.logMetric(`${t}.duration`, n, "ms", "histogram", {
|
|
14
17
|
status: r,
|
|
15
18
|
...i
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
let a =
|
|
21
|
+
function Ze(e, t, n, r, i) {
|
|
22
|
+
let a = N(n);
|
|
20
23
|
e.error(`${t} failed`, r, {
|
|
21
24
|
"action.duration_ms": a,
|
|
22
25
|
status: "FAILURE",
|
|
23
26
|
...i
|
|
24
|
-
}),
|
|
27
|
+
}), P(e, t, a, "FAILURE", i);
|
|
25
28
|
}
|
|
26
|
-
function
|
|
29
|
+
function Qe(e, t, n, r) {
|
|
27
30
|
let i = performance.now();
|
|
28
31
|
try {
|
|
29
32
|
let a = n();
|
|
30
|
-
return
|
|
33
|
+
return P(e, t, N(i), "SUCCESS", r), a;
|
|
31
34
|
} catch (n) {
|
|
32
|
-
throw
|
|
35
|
+
throw Ze(e, t, i, n, r), n;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
async function
|
|
38
|
+
async function $e(e, t, n, r) {
|
|
36
39
|
let i = performance.now();
|
|
37
40
|
try {
|
|
38
41
|
let a = await n();
|
|
39
|
-
return
|
|
42
|
+
return P(e, t, N(i), "SUCCESS", r), a;
|
|
40
43
|
} catch (n) {
|
|
41
|
-
throw
|
|
44
|
+
throw Ze(e, t, i, n, r), n;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
//#endregion
|
|
45
48
|
//#region src/core/logger.ts
|
|
46
|
-
var
|
|
47
|
-
function
|
|
49
|
+
var et = [i, ye];
|
|
50
|
+
function tt(e, t) {
|
|
48
51
|
let n = t.guard("record.sanitize_failed", "The library could not read the error reason.", () => {
|
|
49
|
-
if (!(e instanceof Error) && !
|
|
52
|
+
if (!(e instanceof Error) && !Ee(e)) return;
|
|
50
53
|
let t = Error(e.message);
|
|
51
54
|
return t.name = e.name, t.stack = e.stack, t;
|
|
52
55
|
});
|
|
@@ -54,38 +57,38 @@ function qe(e, t) {
|
|
|
54
57
|
let r = t.guard("record.sanitize_failed", "The library could not convert the error reason to text.", () => String(e));
|
|
55
58
|
return Error(r ?? typeof e);
|
|
56
59
|
}
|
|
57
|
-
function
|
|
60
|
+
function nt(e, t, n) {
|
|
58
61
|
return n.guard("record.sanitize_failed", "The library could not read the error reason.", () => e instanceof Error ? e : t) ?? t;
|
|
59
62
|
}
|
|
60
|
-
function
|
|
63
|
+
function rt(e, t) {
|
|
61
64
|
if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" || typeof e == "symbol") return e;
|
|
62
65
|
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 =
|
|
66
|
+
let t = e, n = Ee(e), r = {}, i = 0;
|
|
64
67
|
for (let e of Object.keys(t)) {
|
|
65
68
|
let a = t[e];
|
|
66
|
-
(!n || !
|
|
69
|
+
(!n || !De.has(e)) && Te(a) && (r[e] = a, i++);
|
|
67
70
|
}
|
|
68
71
|
return i === 0 ? void 0 : r;
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
|
-
function
|
|
74
|
+
function it(e) {
|
|
72
75
|
if (typeof e != "object" || !e || Array.isArray(e) || e instanceof Error) return !1;
|
|
73
76
|
let t = Object.getPrototypeOf(e);
|
|
74
77
|
return t === null || Object.getPrototypeOf(t) === null;
|
|
75
78
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
79
|
+
function at(e) {
|
|
80
|
+
return et.some((t) => e === t || e.startsWith(`${t}.`)) ? "system" : "log";
|
|
78
81
|
}
|
|
79
|
-
function
|
|
82
|
+
function F(e, t) {
|
|
80
83
|
return e === void 0 ? {} : t.guard("record.sanitize_failed", "The library could not read the payload.", () => ({ ...e })) ?? { "uiobs.sanitize_failed": !0 };
|
|
81
84
|
}
|
|
82
|
-
var
|
|
85
|
+
var I = class e {
|
|
83
86
|
bind;
|
|
84
87
|
namespace;
|
|
85
88
|
options;
|
|
86
89
|
levelType;
|
|
87
90
|
constructor(e, t, n = {}) {
|
|
88
|
-
this.bind = e, this.namespace = t, this.options = n, this.levelType =
|
|
91
|
+
this.bind = e, this.namespace = t, this.options = n, this.levelType = at(t);
|
|
89
92
|
}
|
|
90
93
|
child(t, n = {}) {
|
|
91
94
|
return new e(this.bind, `${this.namespace}.${t}`, { scopedContext: {
|
|
@@ -117,22 +120,23 @@ var F = class e {
|
|
|
117
120
|
logEvent = (e, t) => {
|
|
118
121
|
this.write("INFO", "event", e, t);
|
|
119
122
|
};
|
|
120
|
-
logMetric = (e, t, n =
|
|
123
|
+
logMetric = (e, t, n = l, r = "gauge", i) => {
|
|
121
124
|
if (!Number.isFinite(t)) {
|
|
122
125
|
this.bind().diagnostics.report("record.dropped_malformed", "The metric value is not a finite number. The library dropped the metric.", { "metric.name": e });
|
|
123
126
|
return;
|
|
124
127
|
}
|
|
125
|
-
let a = {
|
|
126
|
-
...
|
|
128
|
+
let a = F(i, this.bind().diagnostics), o = {
|
|
129
|
+
...a,
|
|
127
130
|
"metric.name": e,
|
|
128
131
|
"metric.value": t,
|
|
129
132
|
"metric.unit": n,
|
|
130
|
-
"metric.type": r
|
|
133
|
+
"metric.type": r,
|
|
134
|
+
[k.attributeKeys]: Object.keys(a)
|
|
131
135
|
};
|
|
132
|
-
this.write("INFO", "metric", e,
|
|
136
|
+
this.write("INFO", "metric", e, o, !0);
|
|
133
137
|
};
|
|
134
|
-
timeSync = (e, t, n) =>
|
|
135
|
-
timeAsync = (e, t, n) =>
|
|
138
|
+
timeSync = (e, t, n) => Qe(this, e, t, n);
|
|
139
|
+
timeAsync = (e, t, n) => $e(this, e, t, n);
|
|
136
140
|
write(e, t, n, r, i = !1) {
|
|
137
141
|
let a = this.bind();
|
|
138
142
|
if (a.isDestroyed()) return;
|
|
@@ -146,7 +150,7 @@ var F = class e {
|
|
|
146
150
|
body: n,
|
|
147
151
|
namespace: this.namespace,
|
|
148
152
|
scoped: this.options.scopedContext,
|
|
149
|
-
payload: i ? r :
|
|
153
|
+
payload: i ? r : F(r, a.diagnostics)
|
|
150
154
|
}), c = o ? o.body : s === "sampling" ? n : void 0;
|
|
151
155
|
t !== "metric" && c !== void 0 && a.breadcrumbs.push({
|
|
152
156
|
t: Date.now(),
|
|
@@ -159,26 +163,26 @@ var F = class e {
|
|
|
159
163
|
if (i.isDestroyed()) return;
|
|
160
164
|
let a = i.builder.isEnabled(e);
|
|
161
165
|
if (!a && !this.mirrors(i, e)) return;
|
|
162
|
-
let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () =>
|
|
166
|
+
let o = r === void 0 && (i.diagnostics.guard("record.sanitize_failed", "The library could not read the error slot.", () => it(n)) ?? !1), s = o ? n : r, c = o ? void 0 : n, l = c === void 0 ? void 0 : tt(c, i.diagnostics), u = l === void 0 ? void 0 : nt(c, l, i.diagnostics);
|
|
163
167
|
if (!a) {
|
|
164
168
|
this.print(i, e, t, s, u, null);
|
|
165
169
|
return;
|
|
166
170
|
}
|
|
167
|
-
let d = l ?
|
|
171
|
+
let d = l ? rt(c, i.diagnostics) : void 0, { record: f, dropped: p } = i.builder.build({
|
|
168
172
|
level: e,
|
|
169
173
|
type: this.levelType,
|
|
170
174
|
body: t,
|
|
171
175
|
namespace: this.namespace,
|
|
172
176
|
scoped: this.options.scopedContext,
|
|
173
177
|
payload: {
|
|
174
|
-
...
|
|
178
|
+
...F(s, i.diagnostics),
|
|
175
179
|
...l ? {
|
|
176
180
|
"error.type": l.name,
|
|
177
181
|
"error.message": l.message,
|
|
178
182
|
"error.stack_trace": l.stack
|
|
179
183
|
} : {},
|
|
180
|
-
...d === void 0 ? {} : { [
|
|
181
|
-
[
|
|
184
|
+
...d === void 0 ? {} : { [ge]: d },
|
|
185
|
+
[v]: i.breadcrumbs.snapshot()
|
|
182
186
|
}
|
|
183
187
|
});
|
|
184
188
|
this.print(i, e, t, s, u, f, p), i.emit(f);
|
|
@@ -189,72 +193,73 @@ var F = class e {
|
|
|
189
193
|
mirrors(e, t) {
|
|
190
194
|
return e.config.enabled && e.console.accepts(t);
|
|
191
195
|
}
|
|
192
|
-
},
|
|
196
|
+
}, ot = {
|
|
193
197
|
TRACE: "debug",
|
|
194
198
|
DEBUG: "debug",
|
|
195
199
|
INFO: "info",
|
|
196
200
|
WARN: "warn",
|
|
197
201
|
ERROR: "error",
|
|
198
202
|
FATAL: "error"
|
|
199
|
-
},
|
|
203
|
+
}, st = class {
|
|
200
204
|
settings;
|
|
201
205
|
diagnostics;
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
limits;
|
|
207
|
+
constructor(e, n, r = t) {
|
|
208
|
+
this.settings = e, this.diagnostics = n, this.limits = r;
|
|
204
209
|
}
|
|
205
210
|
update(e) {
|
|
206
211
|
this.settings = e;
|
|
207
212
|
}
|
|
208
213
|
accepts(e) {
|
|
209
|
-
return this.settings.level === null || !Object.hasOwn(
|
|
210
|
-
}
|
|
211
|
-
write(e, t, r, i
|
|
212
|
-
if (!this.accepts(t) || typeof console > "u" ||
|
|
213
|
-
let
|
|
214
|
-
this.diagnostics.guard("handler.threw", `The library could not print to console.${
|
|
215
|
-
let
|
|
216
|
-
|
|
217
|
-
console[
|
|
214
|
+
return this.settings.level === null || !Object.hasOwn(O, this.settings.level) ? !1 : O[e] >= O[this.settings.level];
|
|
215
|
+
}
|
|
216
|
+
write(e, t, n, r, i) {
|
|
217
|
+
if (!this.accepts(t) || typeof console > "u" || Ne()) return;
|
|
218
|
+
let a = `%c[%s]%c[${t}]%c`, { styles: o } = this.settings, s = ot[t];
|
|
219
|
+
this.diagnostics.guard("handler.threw", `The library could not print to console.${s}.`, () => {
|
|
220
|
+
let c = [];
|
|
221
|
+
i !== void 0 && c.push(i), r !== void 0 && c.push(Fe(r, this.limits, this.diagnostics)), A(() => {
|
|
222
|
+
console[s](a, o.namespace, e, o[t], "", n, ...c);
|
|
218
223
|
});
|
|
219
224
|
});
|
|
220
225
|
}
|
|
221
|
-
},
|
|
226
|
+
}, ct = class {
|
|
222
227
|
value = 0;
|
|
223
228
|
next() {
|
|
224
229
|
return ++this.value;
|
|
225
230
|
}
|
|
226
|
-
},
|
|
227
|
-
function
|
|
228
|
-
return
|
|
231
|
+
}, lt = /^[0-9a-f]{32}$/, ut = /^[0-9a-f]{16}$/, dt = /[1-9a-f]/;
|
|
232
|
+
function ft(e) {
|
|
233
|
+
return lt.test(e.traceId) && dt.test(e.traceId) && ut.test(e.spanId) && dt.test(e.spanId);
|
|
229
234
|
}
|
|
230
|
-
function
|
|
231
|
-
return
|
|
235
|
+
function pt() {
|
|
236
|
+
return ze(16);
|
|
232
237
|
}
|
|
233
|
-
function
|
|
234
|
-
return
|
|
238
|
+
function mt() {
|
|
239
|
+
return ze(8);
|
|
235
240
|
}
|
|
236
|
-
function
|
|
241
|
+
function ht() {
|
|
237
242
|
return {
|
|
238
|
-
traceId:
|
|
239
|
-
spanId:
|
|
243
|
+
traceId: pt(),
|
|
244
|
+
spanId: mt(),
|
|
240
245
|
traceFlags: 1,
|
|
241
246
|
startedAt: Date.now()
|
|
242
247
|
};
|
|
243
248
|
}
|
|
244
|
-
function
|
|
249
|
+
function gt(e) {
|
|
245
250
|
return {
|
|
246
251
|
traceId: e.traceId,
|
|
247
252
|
spanId: e.spanId,
|
|
248
253
|
traceFlags: e.traceFlags
|
|
249
254
|
};
|
|
250
255
|
}
|
|
251
|
-
var
|
|
256
|
+
var _t = class {
|
|
252
257
|
diagnostics;
|
|
253
258
|
maxAgeMs;
|
|
254
259
|
load;
|
|
255
|
-
ambient =
|
|
260
|
+
ambient = ht();
|
|
256
261
|
otel;
|
|
257
|
-
constructor(e, t =
|
|
262
|
+
constructor(e, t = be, n) {
|
|
258
263
|
this.diagnostics = e, this.maxAgeMs = t, this.load = n;
|
|
259
264
|
}
|
|
260
265
|
async loadOtel() {
|
|
@@ -266,7 +271,7 @@ var lt = class {
|
|
|
266
271
|
}
|
|
267
272
|
resolve() {
|
|
268
273
|
let e = this.activeSpanContext();
|
|
269
|
-
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"),
|
|
274
|
+
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), gt(this.ambient)) : e;
|
|
270
275
|
}
|
|
271
276
|
activeSpanContext() {
|
|
272
277
|
let e = this.otel;
|
|
@@ -274,7 +279,7 @@ var lt = class {
|
|
|
274
279
|
let t = e.trace.getActiveSpan();
|
|
275
280
|
if (t === void 0) return;
|
|
276
281
|
let n = t.spanContext();
|
|
277
|
-
if (
|
|
282
|
+
if (ft(n)) return {
|
|
278
283
|
traceId: n.traceId,
|
|
279
284
|
spanId: n.spanId,
|
|
280
285
|
traceFlags: n.traceFlags
|
|
@@ -282,7 +287,7 @@ var lt = class {
|
|
|
282
287
|
});
|
|
283
288
|
}
|
|
284
289
|
rotate(e) {
|
|
285
|
-
return this.ambient =
|
|
290
|
+
return this.ambient = ht(), gt(this.ambient);
|
|
286
291
|
}
|
|
287
292
|
headers() {
|
|
288
293
|
let e = {}, t = this.otel;
|
|
@@ -290,11 +295,11 @@ var lt = class {
|
|
|
290
295
|
t.propagation.inject(t.context.active(), e);
|
|
291
296
|
}), !e.traceparent) {
|
|
292
297
|
let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
|
|
293
|
-
e[
|
|
298
|
+
e[ie] = `00-${t.traceId}-${t.spanId}-${n}`;
|
|
294
299
|
}
|
|
295
300
|
return e;
|
|
296
301
|
}
|
|
297
|
-
},
|
|
302
|
+
}, vt = class {
|
|
298
303
|
buffer;
|
|
299
304
|
pointer = 0;
|
|
300
305
|
filled = !1;
|
|
@@ -311,157 +316,185 @@ var lt = class {
|
|
|
311
316
|
clear() {
|
|
312
317
|
this.buffer = Array(this.capacity), this.pointer = 0, this.filled = !1;
|
|
313
318
|
}
|
|
314
|
-
},
|
|
319
|
+
}, yt = Object.keys(O), bt = ["gzip", "none"], xt = [
|
|
315
320
|
"omit",
|
|
316
321
|
"same-origin",
|
|
317
322
|
"include"
|
|
318
|
-
],
|
|
323
|
+
], St = [
|
|
319
324
|
"auto",
|
|
320
325
|
"indexeddb",
|
|
321
326
|
"localstorage",
|
|
322
327
|
"memory",
|
|
323
328
|
"none"
|
|
324
|
-
],
|
|
329
|
+
], Ct = ["storage", "memory"], wt = [
|
|
325
330
|
"auto",
|
|
326
331
|
"sender",
|
|
327
332
|
"forwarder",
|
|
328
333
|
"off"
|
|
329
|
-
],
|
|
334
|
+
], Tt = [
|
|
330
335
|
"auto",
|
|
331
336
|
"provider",
|
|
332
337
|
"client"
|
|
333
|
-
],
|
|
338
|
+
], Et = [
|
|
334
339
|
"auto",
|
|
335
340
|
"context",
|
|
336
341
|
"tab",
|
|
337
342
|
"origin"
|
|
338
|
-
],
|
|
343
|
+
], Dt = [
|
|
339
344
|
"error",
|
|
340
345
|
"warn",
|
|
341
346
|
"info",
|
|
342
347
|
"log"
|
|
343
|
-
],
|
|
348
|
+
], Ot = ["limited", "until-delivered"], kt = {
|
|
349
|
+
logFlushIntervalMs: [100, 6e4],
|
|
350
|
+
logBatchSize: [1, 1e3],
|
|
351
|
+
metricFlushIntervalMs: [100, 6e4],
|
|
352
|
+
metricBatchSize: [1, 1e3]
|
|
353
|
+
}, At = {
|
|
354
|
+
maxBatches: [1, 5e3],
|
|
355
|
+
maxAgeMs: [6e4, 6048e5],
|
|
356
|
+
maxAttempts: [1, 20]
|
|
357
|
+
}, jt = {
|
|
358
|
+
maxBodyChars: [256, 65536],
|
|
359
|
+
maxAttributeChars: [256, 65536],
|
|
360
|
+
maxAttributeCount: [1, 1024],
|
|
361
|
+
maxStackChars: [256, 65536],
|
|
362
|
+
maxDepth: [1, 16],
|
|
363
|
+
maxArrayLength: [1, 1e4],
|
|
364
|
+
maxNodes: [100, 1e5],
|
|
365
|
+
maxRecordBytes: [1024, g]
|
|
366
|
+
}, Mt = [6e4, 864e5], Nt = [
|
|
344
367
|
"errors",
|
|
345
368
|
"rejections",
|
|
346
369
|
"resourceErrors",
|
|
347
370
|
"fetch",
|
|
348
371
|
"xhr",
|
|
372
|
+
"httpMetrics",
|
|
349
373
|
"interactions",
|
|
350
374
|
"navigation",
|
|
351
375
|
"webVitals",
|
|
352
376
|
"longFrames",
|
|
353
377
|
"fullUrls"
|
|
354
|
-
],
|
|
355
|
-
function
|
|
378
|
+
], Pt = "null", L = `a level name: ${R(yt)}`, Ft = `true, false or a list of ${R(Dt)}`, It = "a list of strings and RegExp patterns", Lt = "a list of origin URLs such as \"https://api.example\" and RegExp patterns", Rt = "a list of origin URLs such as \"https://app.example\". For a sandboxed frame, set bus.mode: \"sender\" in the frame", zt = "a list of strings";
|
|
379
|
+
function R(e) {
|
|
356
380
|
let t = e.map((e) => `"${e}"`);
|
|
357
381
|
return `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
|
|
358
382
|
}
|
|
359
|
-
function
|
|
383
|
+
function Bt(e) {
|
|
360
384
|
return typeof e == "string" ? `"${e}"` : typeof e == "function" ? "a function" : typeof e == "object" && e ? "an object" : String(e);
|
|
361
385
|
}
|
|
362
|
-
function
|
|
363
|
-
e.report("config.invalid", `${t} must be ${n}. The value is ${
|
|
386
|
+
function z(e, t, n, r, i) {
|
|
387
|
+
e.report("config.invalid", `${t} must be ${n}. The value is ${Bt(r)}. The library keeps ${i}.`);
|
|
364
388
|
}
|
|
365
|
-
function
|
|
389
|
+
function B(e, t, n, r, i) {
|
|
366
390
|
if (t === void 0) return r;
|
|
367
391
|
let a = n.find((e) => e === t);
|
|
368
|
-
return a === void 0 ? (
|
|
392
|
+
return a === void 0 ? (z(i, e, R(n), t, `"${r}"`), r) : a;
|
|
369
393
|
}
|
|
370
|
-
function
|
|
371
|
-
return t === void 0 ? n : typeof t == "boolean" ? t : (
|
|
394
|
+
function V(e, t, n, r) {
|
|
395
|
+
return t === void 0 ? n : typeof t == "boolean" ? t : (z(r, e, "true or false", t, String(n)), n);
|
|
372
396
|
}
|
|
373
|
-
function
|
|
374
|
-
return t === void 0 ? n : typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : (
|
|
397
|
+
function Vt(e, t, n, r) {
|
|
398
|
+
return t === void 0 ? n : typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : (z(r, e, "a finite number of 0 or more", t, String(n)), n);
|
|
375
399
|
}
|
|
376
|
-
function
|
|
400
|
+
function Ht(e, t, n, r, i) {
|
|
401
|
+
if (t === void 0) return r;
|
|
402
|
+
let [a, o] = n;
|
|
403
|
+
return typeof t == "number" && Number.isInteger(t) && t >= a && t <= o ? t : (z(i, e, `an integer from ${String(a)} to ${String(o)}`, t, String(r)), r);
|
|
404
|
+
}
|
|
405
|
+
function H(e, t, n, r, i) {
|
|
406
|
+
let a = t ?? {}, o = Object.keys(r);
|
|
407
|
+
return Object.fromEntries(o.map((t) => [t, Ht(`${e}.${t}`, a[t], r[t], n[t], i)]));
|
|
408
|
+
}
|
|
409
|
+
function U(e) {
|
|
377
410
|
if (typeof e != "string") return;
|
|
378
411
|
let t = e.toUpperCase();
|
|
379
|
-
return
|
|
412
|
+
return yt.find((e) => e === t);
|
|
380
413
|
}
|
|
381
|
-
function
|
|
414
|
+
function Ut(e, t, n, r) {
|
|
382
415
|
if (t === void 0) return n;
|
|
383
|
-
let i =
|
|
384
|
-
return i === void 0 ? (
|
|
416
|
+
let i = U(t);
|
|
417
|
+
return i === void 0 ? (z(r, e, L, t, `"${n}"`), n) : i;
|
|
385
418
|
}
|
|
386
|
-
function
|
|
419
|
+
function W(e, t, n, r, i, a) {
|
|
387
420
|
if (t === void 0) return n;
|
|
388
|
-
if (!Array.isArray(t)) return
|
|
421
|
+
if (!Array.isArray(t)) return z(a, e, r, t, "the list in force"), n;
|
|
389
422
|
let o = [], s = t;
|
|
390
423
|
for (let t of s) {
|
|
391
424
|
let n = i(t);
|
|
392
|
-
n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${
|
|
425
|
+
n === void 0 ? a.report("config.invalid", `The library ignores the ${e} entry ${Bt(t)}. ${e} must be ${r}.`) : o.push(n);
|
|
393
426
|
}
|
|
394
427
|
return o;
|
|
395
428
|
}
|
|
396
|
-
function
|
|
429
|
+
function Wt(e) {
|
|
397
430
|
return typeof e == "string" ? e : void 0;
|
|
398
431
|
}
|
|
399
|
-
function
|
|
432
|
+
function Gt(e) {
|
|
400
433
|
return typeof e == "string" || e instanceof RegExp ? e : void 0;
|
|
401
434
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
435
|
+
function Kt(e) {
|
|
436
|
+
return Dt.find((t) => t === e);
|
|
404
437
|
}
|
|
405
|
-
function
|
|
438
|
+
function qt(e) {
|
|
406
439
|
if (typeof e == "string") try {
|
|
407
440
|
let { origin: t } = new URL(e);
|
|
408
|
-
return t ===
|
|
441
|
+
return t === Pt ? void 0 : t;
|
|
409
442
|
} catch {
|
|
410
443
|
return;
|
|
411
444
|
}
|
|
412
445
|
}
|
|
413
|
-
function
|
|
414
|
-
return e instanceof RegExp ? e :
|
|
446
|
+
function Jt(e) {
|
|
447
|
+
return e instanceof RegExp ? e : qt(e);
|
|
415
448
|
}
|
|
416
|
-
function
|
|
449
|
+
function Yt(e) {
|
|
417
450
|
return typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.values(e).every((e) => typeof e == "string");
|
|
418
451
|
}
|
|
419
|
-
function
|
|
420
|
-
if (e !== void 0) return typeof e == "function" ||
|
|
452
|
+
function Xt(e, t, n) {
|
|
453
|
+
if (e !== void 0) return typeof e == "function" || Yt(e) ? e : (z(n, "headers", "an object of strings or a function", e, "the headers in force"), t);
|
|
421
454
|
}
|
|
422
|
-
function
|
|
455
|
+
function Zt(e) {
|
|
423
456
|
return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
|
|
424
457
|
}
|
|
425
|
-
function
|
|
426
|
-
return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" ||
|
|
458
|
+
function Qt(e, t, n) {
|
|
459
|
+
return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || Zt(e) ? e : (n.report("config.invalid", `serializer must be "${x}", "ecs" or an implementation. The library uses "${x}".`), x);
|
|
427
460
|
}
|
|
428
|
-
var
|
|
429
|
-
function
|
|
461
|
+
var $t = new Set(Object.keys(de));
|
|
462
|
+
function en(e, t) {
|
|
430
463
|
let n = {}, r = Object.entries(e ?? {});
|
|
431
|
-
for (let [e, i] of r)
|
|
464
|
+
for (let [e, i] of r) $t.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.`);
|
|
432
465
|
return n;
|
|
433
466
|
}
|
|
434
|
-
function
|
|
467
|
+
function tn(e, t, n) {
|
|
435
468
|
if (e === void 0) return t ?? "DEBUG";
|
|
436
|
-
let r =
|
|
437
|
-
return r === void 0 ? (
|
|
469
|
+
let r = U(e);
|
|
470
|
+
return r === void 0 ? (z(n, "console.level", L, e, "the console level in force"), t) : r;
|
|
438
471
|
}
|
|
439
|
-
function
|
|
440
|
-
if (
|
|
441
|
-
if (
|
|
472
|
+
function nn(t, n, r) {
|
|
473
|
+
if (t === void 0) return n;
|
|
474
|
+
if (t === !1) return {
|
|
442
475
|
level: null,
|
|
443
|
-
styles:
|
|
476
|
+
styles: n.styles
|
|
444
477
|
};
|
|
445
|
-
if (
|
|
446
|
-
level:
|
|
447
|
-
styles:
|
|
478
|
+
if (t === !0) return {
|
|
479
|
+
level: e,
|
|
480
|
+
styles: n.styles
|
|
448
481
|
};
|
|
449
|
-
if (typeof
|
|
450
|
-
let
|
|
451
|
-
return
|
|
452
|
-
level:
|
|
453
|
-
styles:
|
|
482
|
+
if (typeof t == "string") {
|
|
483
|
+
let e = U(t);
|
|
484
|
+
return e === void 0 ? (z(r, "console", L, t, "the console level in force"), n) : {
|
|
485
|
+
level: e,
|
|
486
|
+
styles: n.styles
|
|
454
487
|
};
|
|
455
488
|
}
|
|
456
|
-
return typeof
|
|
457
|
-
level:
|
|
489
|
+
return typeof t != "object" || !t ? (r.report("config.invalid", "console must be a boolean, a level or an object. The console settings in force stay."), n) : {
|
|
490
|
+
level: tn(t.level, n.level, r),
|
|
458
491
|
styles: {
|
|
459
|
-
...
|
|
460
|
-
...
|
|
492
|
+
...n.styles,
|
|
493
|
+
...en(t.styles, r)
|
|
461
494
|
}
|
|
462
495
|
};
|
|
463
496
|
}
|
|
464
|
-
function
|
|
497
|
+
function rn(e, t, n) {
|
|
465
498
|
let r = e ?? {};
|
|
466
499
|
return {
|
|
467
500
|
...t,
|
|
@@ -470,87 +503,113 @@ function zt(e, t, n) {
|
|
|
470
503
|
...t.rates,
|
|
471
504
|
...r.rates
|
|
472
505
|
},
|
|
473
|
-
alwaysSampleTypes:
|
|
474
|
-
remote:
|
|
506
|
+
alwaysSampleTypes: W("sampling.alwaysSampleTypes", r.alwaysSampleTypes, t.alwaysSampleTypes, zt, Wt, n),
|
|
507
|
+
remote: V("sampling.remote", r.remote, t.remote, n)
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function an(e, t, n) {
|
|
511
|
+
let r = e ?? {};
|
|
512
|
+
return {
|
|
513
|
+
mode: B("bus.mode", r.mode, wt, t.mode, n),
|
|
514
|
+
trustedOrigins: W("bus.trustedOrigins", r.trustedOrigins, t.trustedOrigins, Rt, qt, n),
|
|
515
|
+
openFinRole: B("bus.openFinRole", r.openFinRole, Tt, t.openFinRole, n)
|
|
475
516
|
};
|
|
476
517
|
}
|
|
477
|
-
function
|
|
518
|
+
function on(e, t, n) {
|
|
478
519
|
let r = e ?? {};
|
|
479
520
|
return {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
openFinRole: U("bus.openFinRole", r.openFinRole, gt, t.openFinRole, n)
|
|
521
|
+
scope: B("journey.scope", r.scope, Et, t.scope, n),
|
|
522
|
+
maxAgeMs: Ht("journey.maxAgeMs", r.maxAgeMs, Mt, t.maxAgeMs, n)
|
|
483
523
|
};
|
|
484
524
|
}
|
|
485
|
-
function
|
|
486
|
-
|
|
525
|
+
function sn(e, t, n) {
|
|
526
|
+
let r = e ?? {};
|
|
527
|
+
return {
|
|
528
|
+
mode: B("retention.mode", r.mode, Ot, t.mode, n),
|
|
529
|
+
...H("retention", r, t, At, n)
|
|
530
|
+
};
|
|
487
531
|
}
|
|
488
|
-
function
|
|
489
|
-
return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ?
|
|
532
|
+
function cn(e, t, n) {
|
|
533
|
+
return e === void 0 ? t : typeof e == "boolean" ? e : Array.isArray(e) ? W("capture.console", e, [], Ft, Kt, n) : (z(n, "capture.console", Ft, e, "the value in force"), t);
|
|
490
534
|
}
|
|
491
|
-
function
|
|
535
|
+
function ln(e, t, n) {
|
|
492
536
|
let r = e ?? {}, i = {
|
|
493
537
|
...t,
|
|
494
538
|
...r,
|
|
495
|
-
console:
|
|
496
|
-
longFrameThresholdMs:
|
|
497
|
-
ignoreUrls:
|
|
498
|
-
propagateTraceHeaderTo:
|
|
539
|
+
console: cn(r.console, t.console, n),
|
|
540
|
+
longFrameThresholdMs: Vt("capture.longFrameThresholdMs", r.longFrameThresholdMs, t.longFrameThresholdMs, n),
|
|
541
|
+
ignoreUrls: W("capture.ignoreUrls", r.ignoreUrls, t.ignoreUrls, It, Gt, n),
|
|
542
|
+
propagateTraceHeaderTo: W("capture.propagateTraceHeaderTo", r.propagateTraceHeaderTo, t.propagateTraceHeaderTo, Lt, Jt, n)
|
|
499
543
|
};
|
|
500
|
-
for (let e of
|
|
544
|
+
for (let e of Nt) i[e] = V(`capture.${e}`, r[e], t[e], n);
|
|
501
545
|
return i;
|
|
502
546
|
}
|
|
503
|
-
function
|
|
504
|
-
let
|
|
505
|
-
|
|
547
|
+
function un(e, t, n, r) {
|
|
548
|
+
let i = t;
|
|
549
|
+
if (typeof e == "string" && e !== "") try {
|
|
550
|
+
new URL(e), i = e;
|
|
551
|
+
} catch (t) {
|
|
552
|
+
r.report("config.invalid", `metricsEndpoint is not a valid absolute URL: ${e}. The library keeps the value in force.`, void 0, t);
|
|
553
|
+
}
|
|
554
|
+
else e === "" ? i = "" : e !== void 0 && z(r, "metricsEndpoint", "a URL string", e, "the value in force");
|
|
555
|
+
return i !== "" && n !== "otlp" ? (r.report("config.invalid", `metricsEndpoint needs serializer "${x}". The library sends metric records as log records.`), "") : i;
|
|
556
|
+
}
|
|
557
|
+
function dn(e, t, n) {
|
|
558
|
+
let i = n ?? a, o = {
|
|
559
|
+
...i,
|
|
506
560
|
...e,
|
|
507
|
-
endpoint: e.endpoint === void 0 ?
|
|
508
|
-
enabled:
|
|
509
|
-
minLevel:
|
|
510
|
-
compression:
|
|
511
|
-
credentials:
|
|
512
|
-
headers: "headers" in e ?
|
|
513
|
-
storage:
|
|
514
|
-
identity:
|
|
515
|
-
serializer:
|
|
516
|
-
console:
|
|
517
|
-
sampling:
|
|
518
|
-
bus:
|
|
519
|
-
|
|
520
|
-
|
|
561
|
+
endpoint: e.endpoint === void 0 ? i.endpoint : e.endpoint,
|
|
562
|
+
enabled: V("enabled", e.enabled, i.enabled, t),
|
|
563
|
+
minLevel: Ut("minLevel", e.minLevel, i.minLevel, t),
|
|
564
|
+
compression: B("compression", e.compression, bt, i.compression, t),
|
|
565
|
+
credentials: B("credentials", e.credentials, xt, i.credentials, t),
|
|
566
|
+
headers: "headers" in e ? Xt(e.headers, i.headers, t) : i.headers,
|
|
567
|
+
storage: B("storage", e.storage, St, i.storage, t),
|
|
568
|
+
identity: B("identity", e.identity, Ct, i.identity, t),
|
|
569
|
+
serializer: Qt(e.serializer, n?.serializer, t),
|
|
570
|
+
console: nn(e.console, i.console, t),
|
|
571
|
+
sampling: rn(e.sampling, i.sampling, t),
|
|
572
|
+
bus: an(e.bus, i.bus, t),
|
|
573
|
+
batching: H("batching", e.batching, i.batching, kt, t),
|
|
574
|
+
retention: sn(e.retention, i.retention, t),
|
|
575
|
+
limits: H("limits", e.limits, i.limits, jt, t),
|
|
576
|
+
journey: on(e.journey, i.journey, t),
|
|
577
|
+
capture: ln(e.capture, i.capture, t)
|
|
521
578
|
};
|
|
522
|
-
if (i.transport !== void 0 && typeof
|
|
523
|
-
else if (
|
|
524
|
-
new URL(
|
|
579
|
+
if (o.metricsEndpoint = un(e.metricsEndpoint, i.metricsEndpoint, o.serializer, t), o.transport !== void 0 && typeof o.transport != "function" && (t.report("config.invalid", "transport must be a function. The library ignores the value."), o.transport = i.transport), o.onDrop !== void 0 && typeof o.onDrop != "function" && (t.report("config.invalid", "onDrop must be a function. The library ignores the value."), o.onDrop = i.onDrop), o.transportOnExit !== void 0 && typeof o.transportOnExit != "function" && (t.report("config.invalid", "transportOnExit must be a function. The library ignores the value."), o.transportOnExit = i.transportOnExit), o.endpoint === "") o.transport === void 0 && t.report("config.invalid", "endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.");
|
|
580
|
+
else if (o.endpoint !== null) try {
|
|
581
|
+
new URL(o.endpoint);
|
|
525
582
|
} catch (e) {
|
|
526
|
-
t.report("config.invalid", `endpoint is not a valid absolute URL: ${
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
let
|
|
530
|
-
(typeof
|
|
531
|
-
let
|
|
532
|
-
(typeof
|
|
533
|
-
let
|
|
534
|
-
for (let [e, n] of
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
let
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
583
|
+
t.report("config.invalid", `endpoint is not a valid absolute URL: ${o.endpoint}.`, void 0, e);
|
|
584
|
+
}
|
|
585
|
+
o.metricsEndpoint !== "" && o.endpoint === null && !o.transport && t.report("config.invalid", "metricsEndpoint needs endpoint or transport. The library sends nothing to metricsEndpoint."), o.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${r}'.`), r);
|
|
586
|
+
let s = o.sampling.defaultRate;
|
|
587
|
+
(typeof s != "number" || s < 0 || s > 1) && (t.report("config.invalid", `sampling.defaultRate must be 0..1. The value is ${String(s)}. The library uses 1.`), o.sampling.defaultRate = 1);
|
|
588
|
+
let c = o.sampling.remoteMaxRate;
|
|
589
|
+
(typeof c != "number" || !(c >= 0 && c <= 1)) && (t.report("config.invalid", `sampling.remoteMaxRate must be 0..1. The value is ${String(c)}. The library uses 1.`), o.sampling.remoteMaxRate = 1);
|
|
590
|
+
let l = Object.entries(o.sampling.rates);
|
|
591
|
+
for (let [e, n] of l) (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.`), o.sampling.rates[e] = 1);
|
|
592
|
+
o.capture.ignoreUrls = o.capture.ignoreUrls.filter((e) => e !== n?.endpoint && e !== n?.metricsEndpoint);
|
|
593
|
+
for (let e of [o.endpoint, o.metricsEndpoint]) e && !o.capture.ignoreUrls.includes(e) && (o.capture.ignoreUrls = [...o.capture.ignoreUrls, e]);
|
|
594
|
+
return fn(e, t), o;
|
|
595
|
+
}
|
|
596
|
+
function fn(e, t) {
|
|
597
|
+
let n = /* @__PURE__ */ new Set([...Object.keys(a), ...xe]);
|
|
598
|
+
for (let r of Object.keys(e)) n.has(r) || t.report("config.invalid", `The library ignores the unknown config key "${r}". Check the spelling.`);
|
|
599
|
+
for (let n of C) {
|
|
600
|
+
let r = e[n];
|
|
601
|
+
if (typeof r != "object" || !r) continue;
|
|
602
|
+
let i = /* @__PURE__ */ new Set([...Object.keys(a[n]), ..._[n]]);
|
|
603
|
+
for (let e of Object.keys(r)) i.has(e) || t.report("config.invalid", `The library ignores the unknown config key "${n}.${e}". Check the spelling.`);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
function pn(e, t) {
|
|
607
|
+
for (let n of Object.keys(t)) C.includes(n) || Object.assign(e, { [n]: t[n] });
|
|
608
|
+
for (let n of C) Object.assign(e[n], t[n]);
|
|
550
609
|
}
|
|
551
610
|
//#endregion
|
|
552
611
|
//#region src/core/context.ts
|
|
553
|
-
var
|
|
612
|
+
var mn = class {
|
|
554
613
|
map = /* @__PURE__ */ new Map();
|
|
555
614
|
set(e, t) {
|
|
556
615
|
this.map.set(e, t);
|
|
@@ -570,12 +629,12 @@ var qt = class {
|
|
|
570
629
|
getAll() {
|
|
571
630
|
return Object.fromEntries(this.map);
|
|
572
631
|
}
|
|
573
|
-
},
|
|
632
|
+
}, hn = class {
|
|
574
633
|
handler;
|
|
575
634
|
throttleMs;
|
|
576
635
|
counters = /* @__PURE__ */ new Map();
|
|
577
636
|
lastEmitted = /* @__PURE__ */ new Map();
|
|
578
|
-
constructor(e, t =
|
|
637
|
+
constructor(e, t = f) {
|
|
579
638
|
this.handler = e, this.throttleMs = t;
|
|
580
639
|
}
|
|
581
640
|
setHandler(e) {
|
|
@@ -598,12 +657,12 @@ var qt = class {
|
|
|
598
657
|
count: i
|
|
599
658
|
}, { handler: s } = this;
|
|
600
659
|
if (s) try {
|
|
601
|
-
|
|
660
|
+
A(() => {
|
|
602
661
|
s(o);
|
|
603
662
|
});
|
|
604
663
|
} catch (e) {
|
|
605
|
-
this.count("handler.threw"), typeof console < "u" &&
|
|
606
|
-
console.warn(`${
|
|
664
|
+
this.count("handler.threw"), typeof console < "u" && A(() => {
|
|
665
|
+
console.warn(`${se} The onDiagnostic handler threw an error.`, e);
|
|
607
666
|
});
|
|
608
667
|
}
|
|
609
668
|
}
|
|
@@ -629,15 +688,197 @@ var qt = class {
|
|
|
629
688
|
reset() {
|
|
630
689
|
this.counters.clear(), this.lastEmitted.clear();
|
|
631
690
|
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
691
|
+
};
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region src/core/drops.ts
|
|
694
|
+
function G(e, t) {
|
|
695
|
+
e.length < 20 && !e.includes(t) && e.push(t);
|
|
696
|
+
}
|
|
697
|
+
var gn = class {
|
|
698
|
+
config;
|
|
699
|
+
diagnostics;
|
|
700
|
+
pending = /* @__PURE__ */ new Map();
|
|
701
|
+
scheduled = !1;
|
|
702
|
+
reporting = !1;
|
|
703
|
+
constructor(e, t) {
|
|
704
|
+
this.config = e, this.diagnostics = t;
|
|
705
|
+
}
|
|
706
|
+
add(e, t, n = []) {
|
|
707
|
+
if (!this.config.onDrop || this.reporting || t.length === 0 && n.length === 0) return;
|
|
708
|
+
let r = this.pending.get(e);
|
|
709
|
+
r || (r = {
|
|
710
|
+
reason: e,
|
|
711
|
+
records: 0,
|
|
712
|
+
batchIds: [],
|
|
713
|
+
journeyIds: [],
|
|
714
|
+
actions: []
|
|
715
|
+
}, this.pending.set(e, r)), r.records += t.length;
|
|
716
|
+
for (let e of n) G(r.batchIds, e);
|
|
717
|
+
for (let e of t) {
|
|
718
|
+
let t = Ke(e, E);
|
|
719
|
+
typeof t == "string" && G(r.journeyIds, t);
|
|
720
|
+
let n = M(e) ? e.body : void 0;
|
|
721
|
+
typeof n == "string" && G(r.actions, n);
|
|
722
|
+
}
|
|
723
|
+
this.scheduled || (this.scheduled = !0, queueMicrotask(() => {
|
|
724
|
+
this.flush();
|
|
725
|
+
}));
|
|
726
|
+
}
|
|
727
|
+
flush() {
|
|
728
|
+
this.scheduled = !1;
|
|
729
|
+
let e = [...this.pending.values()];
|
|
730
|
+
this.pending.clear();
|
|
731
|
+
let t = this.config.onDrop;
|
|
732
|
+
if (t) {
|
|
733
|
+
this.reporting = !0;
|
|
734
|
+
for (let n of e) this.diagnostics.guard("handler.threw", "The onDrop hook threw an error.", () => {
|
|
735
|
+
qe(() => {
|
|
736
|
+
A(() => {
|
|
737
|
+
t(n);
|
|
738
|
+
});
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
this.reporting = !1;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}, _n = class {
|
|
745
|
+
onDrop;
|
|
746
|
+
held = [];
|
|
747
|
+
actions = 0;
|
|
748
|
+
constructor(e) {
|
|
749
|
+
this.onDrop = e;
|
|
750
|
+
}
|
|
751
|
+
get records() {
|
|
752
|
+
return this.held;
|
|
753
|
+
}
|
|
754
|
+
get length() {
|
|
755
|
+
return this.held.length;
|
|
756
|
+
}
|
|
757
|
+
push(e) {
|
|
758
|
+
let t = M(e);
|
|
759
|
+
if ((t ? this.actions : this.held.length - this.actions) < (t ? 2e3 : 500)) this.actions += +!!t;
|
|
760
|
+
else {
|
|
761
|
+
let e = this.held.findIndex((e) => M(e) === t), [n] = this.held.splice(e, 1);
|
|
762
|
+
this.onDrop(n);
|
|
763
|
+
}
|
|
764
|
+
this.held.push(e);
|
|
765
|
+
}
|
|
766
|
+
take() {
|
|
767
|
+
let e = this.held;
|
|
768
|
+
return this.held = [], this.actions = 0, e;
|
|
769
|
+
}
|
|
770
|
+
}, vn = "overflow", yn = /* @__PURE__ */ new Set([
|
|
771
|
+
b,
|
|
772
|
+
D,
|
|
773
|
+
w,
|
|
774
|
+
T,
|
|
775
|
+
E,
|
|
776
|
+
y,
|
|
777
|
+
fe
|
|
778
|
+
]);
|
|
779
|
+
function bn(e = {}) {
|
|
780
|
+
let t = {};
|
|
781
|
+
for (let n of Object.keys(e).sort()) {
|
|
782
|
+
if (n.startsWith("metric.") || yn.has(n)) continue;
|
|
783
|
+
let r = e[n];
|
|
784
|
+
(typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) && (t[n] = r);
|
|
785
|
+
}
|
|
786
|
+
return t;
|
|
787
|
+
}
|
|
788
|
+
function xn(e) {
|
|
789
|
+
if (!Array.isArray(e)) return null;
|
|
790
|
+
let t = Math.min(e.length, 51);
|
|
791
|
+
return Array.from({ length: t }, (t, n) => e[n]);
|
|
792
|
+
}
|
|
793
|
+
function Sn(e) {
|
|
794
|
+
return Array.isArray(e) && e.length <= 50 && e.every((t, n) => typeof t == "number" && Number.isFinite(t) && (n === 0 || t > e[n - 1]));
|
|
795
|
+
}
|
|
796
|
+
function Cn(e, t, n) {
|
|
797
|
+
let r = {
|
|
798
|
+
"metric.name": e.name,
|
|
799
|
+
"metric.unit": e.unit,
|
|
800
|
+
"metric.type": e.kind,
|
|
801
|
+
[k.start]: n,
|
|
802
|
+
[k.attributeKeys]: Object.keys(t.attributes)
|
|
803
|
+
};
|
|
804
|
+
return e.kind === "counter" ? (r["metric.value"] = t.sum, r) : {
|
|
805
|
+
...r,
|
|
806
|
+
[k.count]: t.count,
|
|
807
|
+
[k.sum]: t.sum,
|
|
808
|
+
[k.min]: t.min,
|
|
809
|
+
[k.max]: t.max,
|
|
810
|
+
[k.bounds]: e.boundaries,
|
|
811
|
+
[k.buckets]: t.buckets
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
var wn = class {
|
|
815
|
+
intervalMs;
|
|
816
|
+
emit;
|
|
817
|
+
diagnostics;
|
|
818
|
+
instruments = /* @__PURE__ */ new Map();
|
|
819
|
+
timer = null;
|
|
820
|
+
startedAt = 0;
|
|
821
|
+
constructor(e, t, n) {
|
|
822
|
+
this.intervalMs = e, this.emit = t, this.diagnostics = n;
|
|
823
|
+
}
|
|
824
|
+
record(e, t, n) {
|
|
825
|
+
!Number.isFinite(t) || e.kind === "counter" && t < 0 ? this.diagnostics.report("record.dropped_malformed", `The value of the metric ${e.name} is not valid. The library dropped it.`, { "metric.name": e.name }) : this.diagnostics.guard("record.sanitize_failed", `The library could not read the attributes of the metric ${e.name}.`, () => {
|
|
826
|
+
let r = this.instrumentOf(e);
|
|
827
|
+
r && (this.add(r, t, bn(n)), this.arm());
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
collect() {
|
|
831
|
+
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
832
|
+
let e = `${String(this.startedAt)}000000`, t = [...this.instruments.values()];
|
|
833
|
+
this.instruments.clear();
|
|
834
|
+
for (let { def: n, series: r } of t) for (let t of r.values()) this.emit(n.name, t.attributes, Cn(n, t, e));
|
|
835
|
+
}
|
|
836
|
+
instrumentOf(e) {
|
|
837
|
+
let t = this.instruments.get(e.name);
|
|
838
|
+
if (t) return t.def.kind === e.kind ? t : (this.diagnostics.report("record.dropped_malformed", `The metric ${e.name} is a counter and a histogram. The library dropped the value.`, { "metric.name": e.name }), null);
|
|
839
|
+
let n = xn(e.boundaries), r = Sn(n);
|
|
840
|
+
e.kind === "histogram" && !r && this.diagnostics.report("config.invalid", `The boundaries of the metric ${e.name} must be at most 50 finite numbers in ascending order. The library uses the default boundaries.`);
|
|
841
|
+
let i = {
|
|
842
|
+
def: {
|
|
843
|
+
...e,
|
|
844
|
+
boundaries: r ? n : [...ae]
|
|
845
|
+
},
|
|
846
|
+
series: /* @__PURE__ */ new Map()
|
|
847
|
+
};
|
|
848
|
+
return this.instruments.set(e.name, i), i;
|
|
849
|
+
}
|
|
850
|
+
add(e, t, n) {
|
|
851
|
+
let r = JSON.stringify(n), i = e.series.get(r), a = n;
|
|
852
|
+
if (!i && e.series.size >= 100 && (r = vn, i = e.series.get(r), a = { [oe]: !0 }), !i) {
|
|
853
|
+
let n = e.def.kind === "histogram" ? e.def.boundaries.length + 1 : 0, o = Array(n).fill(0);
|
|
854
|
+
i = {
|
|
855
|
+
attributes: a,
|
|
856
|
+
count: 0,
|
|
857
|
+
sum: 0,
|
|
858
|
+
min: t,
|
|
859
|
+
max: t,
|
|
860
|
+
buckets: o
|
|
861
|
+
}, e.series.set(r, i);
|
|
862
|
+
}
|
|
863
|
+
if (i.count += 1, i.sum += t, i.min = Math.min(i.min, t), i.max = Math.max(i.max, t), i.buckets.length > 0) {
|
|
864
|
+
let n = e.def.boundaries.findIndex((e) => t <= e);
|
|
865
|
+
i.buckets[n === -1 ? i.buckets.length - 1 : n] += 1;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
arm() {
|
|
869
|
+
this.timer === null && (this.startedAt = Date.now(), this.timer = setTimeout(() => {
|
|
870
|
+
this.collect();
|
|
871
|
+
}, this.intervalMs()), Je(this.timer));
|
|
872
|
+
}
|
|
873
|
+
}, Tn = "error.", En = [
|
|
874
|
+
T,
|
|
875
|
+
E,
|
|
876
|
+
y
|
|
636
877
|
];
|
|
637
|
-
function
|
|
878
|
+
function K(e) {
|
|
638
879
|
return e;
|
|
639
880
|
}
|
|
640
|
-
var
|
|
881
|
+
var Dn = class {
|
|
641
882
|
deps;
|
|
642
883
|
resourceCache = null;
|
|
643
884
|
constructor(e) {
|
|
@@ -649,9 +890,9 @@ var Zt = class {
|
|
|
649
890
|
isEnabled(e, t) {
|
|
650
891
|
let { config: n } = this.deps;
|
|
651
892
|
if (!n.enabled) return !1;
|
|
652
|
-
if (t !== void 0 &&
|
|
893
|
+
if (t !== void 0 && pe.includes(t)) return !0;
|
|
653
894
|
let r = this.deps.remote.sampling?.minLevel() ?? n.minLevel;
|
|
654
|
-
return
|
|
895
|
+
return O[e] >= O[r];
|
|
655
896
|
}
|
|
656
897
|
build(e) {
|
|
657
898
|
let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o, remote: s } = this.deps;
|
|
@@ -660,72 +901,73 @@ var Zt = class {
|
|
|
660
901
|
dropped: "level"
|
|
661
902
|
};
|
|
662
903
|
let c = r.resolve(), l = i.current();
|
|
663
|
-
if (!
|
|
904
|
+
if (!Me({
|
|
664
905
|
level: e.level,
|
|
665
906
|
type: e.type,
|
|
666
907
|
namespace: e.namespace,
|
|
667
908
|
journeyId: l?.id ?? "",
|
|
668
|
-
traceId: c.traceId
|
|
909
|
+
traceId: c.traceId,
|
|
910
|
+
aggregated: e.aggregated
|
|
669
911
|
}, t, s.sampling?.current() ?? null)) return n.count("record.dropped_by_sampling"), {
|
|
670
912
|
record: null,
|
|
671
913
|
dropped: "sampling"
|
|
672
914
|
};
|
|
673
|
-
let u = a.next(), d =
|
|
915
|
+
let u = a.next(), d = Ge(n), f = t.capture.fullUrls ? d : We(d), p, m = 0;
|
|
674
916
|
try {
|
|
675
|
-
let t =
|
|
917
|
+
let t = j(this.deps.context.getAll(), o, n), r = j(e.scoped ?? {}, o, n), i = j(e.payload ?? {}, o, n);
|
|
676
918
|
m = t.bytes + r.bytes + i.bytes, p = {
|
|
677
|
-
...
|
|
678
|
-
...
|
|
679
|
-
...
|
|
919
|
+
...K(t.value),
|
|
920
|
+
...K(r.value),
|
|
921
|
+
...K(i.value)
|
|
680
922
|
};
|
|
681
923
|
} catch (e) {
|
|
682
|
-
n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [
|
|
924
|
+
n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [me]: !0 };
|
|
683
925
|
}
|
|
684
|
-
p[
|
|
685
|
-
let h =
|
|
926
|
+
Object.assign(p, e.fixed), p[b] = e.type, p[D] = u, p[w] = e.namespace, p[T] = f, l && (p[E] = l.id, p[y] = l.name, l.parentId !== void 0 && (p[fe] = l.parentId));
|
|
927
|
+
let h = Pe(e.body, o.maxBodyChars);
|
|
686
928
|
h !== e.body && n.count("record.truncated");
|
|
687
929
|
let g = {
|
|
688
|
-
timeUnixNano:
|
|
930
|
+
timeUnixNano: je(),
|
|
689
931
|
traceId: c.traceId,
|
|
690
932
|
spanId: c.spanId,
|
|
691
933
|
traceFlags: c.traceFlags,
|
|
692
|
-
severityNumber:
|
|
934
|
+
severityNumber: ue[e.level],
|
|
693
935
|
severityText: e.level,
|
|
694
936
|
body: h,
|
|
695
937
|
attributes: p,
|
|
696
938
|
resource: this.resource()
|
|
697
939
|
}, _ = t.redact;
|
|
698
940
|
if (_) {
|
|
699
|
-
let
|
|
941
|
+
let t;
|
|
700
942
|
try {
|
|
701
|
-
|
|
943
|
+
t = _(g);
|
|
702
944
|
} catch (e) {
|
|
703
945
|
return n.report("record.dropped_by_redact", "The redact hook threw an error. The library dropped the record.", void 0, e), {
|
|
704
946
|
record: null,
|
|
705
947
|
dropped: "redact"
|
|
706
948
|
};
|
|
707
949
|
}
|
|
708
|
-
if (
|
|
950
|
+
if (t === null) return n.count("record.dropped_by_redact"), {
|
|
709
951
|
record: null,
|
|
710
952
|
dropped: "redact"
|
|
711
953
|
};
|
|
712
|
-
let
|
|
713
|
-
if (!
|
|
954
|
+
let r = t ?? g;
|
|
955
|
+
if (!Oe(r)) return r === 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
956
|
record: null,
|
|
715
957
|
dropped: "malformed"
|
|
716
958
|
}) : (n.report("record.dropped_by_redact", "The redact hook returned a value that is not a record. The library dropped the record."), {
|
|
717
959
|
record: null,
|
|
718
960
|
dropped: "redact"
|
|
719
961
|
});
|
|
720
|
-
if (
|
|
721
|
-
if (
|
|
722
|
-
let
|
|
962
|
+
if (ke(r.severityText)) {
|
|
963
|
+
if (r !== g) {
|
|
964
|
+
let t = j(r.attributes, o, n);
|
|
723
965
|
g = {
|
|
724
|
-
...
|
|
725
|
-
attributes:
|
|
726
|
-
}, m = e.
|
|
966
|
+
...r,
|
|
967
|
+
attributes: K(t.value)
|
|
968
|
+
}, m = t.bytes, Object.assign(g.attributes, e.fixed);
|
|
727
969
|
}
|
|
728
|
-
g.severityNumber =
|
|
970
|
+
g.severityNumber = ue[g.severityText];
|
|
729
971
|
} 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
972
|
record: null,
|
|
731
973
|
dropped: "malformed"
|
|
@@ -737,53 +979,53 @@ var Zt = class {
|
|
|
737
979
|
body: g.body
|
|
738
980
|
});
|
|
739
981
|
let t = {
|
|
740
|
-
[
|
|
741
|
-
[
|
|
742
|
-
[
|
|
743
|
-
[
|
|
744
|
-
[
|
|
982
|
+
[b]: e.type,
|
|
983
|
+
[D]: u,
|
|
984
|
+
[w]: e.namespace,
|
|
985
|
+
[le]: !0,
|
|
986
|
+
[ve]: m
|
|
745
987
|
};
|
|
746
|
-
for (let e of
|
|
747
|
-
for (let [e, n] of Object.entries(g.attributes)) e.startsWith(
|
|
748
|
-
let r =
|
|
749
|
-
r > o.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t,
|
|
750
|
-
let i = g.attributes[
|
|
988
|
+
for (let e of En) e in g.attributes && (t[e] = g.attributes[e]);
|
|
989
|
+
for (let [e, n] of Object.entries(g.attributes)) e.startsWith(Tn) && (t[e] = n);
|
|
990
|
+
let r = j(t, o, n).bytes;
|
|
991
|
+
r > o.maxRecordBytes && "error.data" in t && (Reflect.deleteProperty(t, ge), r = j(t, o, n).bytes);
|
|
992
|
+
let i = g.attributes[v];
|
|
751
993
|
if (i !== void 0) {
|
|
752
|
-
let e =
|
|
753
|
-
r + e <= o.maxRecordBytes && (t[
|
|
994
|
+
let e = j(i, o, n).bytes;
|
|
995
|
+
r + e <= o.maxRecordBytes && (t[v] = i);
|
|
754
996
|
}
|
|
755
|
-
g.attributes = t;
|
|
997
|
+
Object.assign(t, e.fixed), g.attributes = t;
|
|
756
998
|
}
|
|
757
999
|
return { record: g };
|
|
758
1000
|
}
|
|
759
1001
|
resource() {
|
|
760
1002
|
if (this.resourceCache) return this.resourceCache;
|
|
761
|
-
let { config:
|
|
1003
|
+
let { config: e, identity: t, platform: r } = this.deps;
|
|
762
1004
|
return this.resourceCache = {
|
|
763
|
-
[
|
|
764
|
-
[
|
|
765
|
-
[
|
|
766
|
-
[
|
|
767
|
-
[
|
|
768
|
-
[
|
|
1005
|
+
[te]: e.serviceName,
|
|
1006
|
+
[c]: e.serviceVersion,
|
|
1007
|
+
[p]: e.environment,
|
|
1008
|
+
[d]: ce,
|
|
1009
|
+
[_e]: S,
|
|
1010
|
+
[s]: he,
|
|
769
1011
|
[h]: r.platform,
|
|
770
|
-
[
|
|
771
|
-
[
|
|
772
|
-
[u]:
|
|
773
|
-
[
|
|
774
|
-
...r.openfinUuid === void 0 ? {} : { [
|
|
775
|
-
...r.openfinName === void 0 ? {} : { [
|
|
1012
|
+
[ee]: t.sessionId,
|
|
1013
|
+
[ne]: t.tabId,
|
|
1014
|
+
[u]: t.contextId,
|
|
1015
|
+
[o]: r.userAgent,
|
|
1016
|
+
...r.openfinUuid === void 0 ? {} : { [n]: r.openfinUuid },
|
|
1017
|
+
...r.openfinName === void 0 ? {} : { [we]: r.openfinName }
|
|
776
1018
|
}, this.resourceCache;
|
|
777
1019
|
}
|
|
778
|
-
},
|
|
779
|
-
errors: async () => (await import("./errors-
|
|
780
|
-
network: async () => (await import("./network-
|
|
781
|
-
interactions: async () => (await import("./interactions-
|
|
1020
|
+
}, On = {
|
|
1021
|
+
errors: async () => (await import("./errors-BGs5NOrw.js")).ErrorCapture,
|
|
1022
|
+
network: async () => (await import("./network-CMnEvGJB.js")).NetworkCapture,
|
|
1023
|
+
interactions: async () => (await import("./interactions-B8zjCjga.js")).InteractionCapture,
|
|
782
1024
|
webVitals: async () => (await import("./web-vitals-Bflr5jSA.js")).WebVitalsCapture,
|
|
783
|
-
longFrames: async () => (await import("./long-frames-
|
|
784
|
-
console: async () => (await import("./console-
|
|
785
|
-
},
|
|
786
|
-
function
|
|
1025
|
+
longFrames: async () => (await import("./long-frames-B0tKuChx.js")).LongFrameCapture,
|
|
1026
|
+
console: async () => (await import("./console-B3vGRW5p.js")).ConsoleCapture
|
|
1027
|
+
}, q = Symbol.for(re), J = Symbol.for(m), kn = ["batching", "retention"];
|
|
1028
|
+
function An(e) {
|
|
787
1029
|
return JSON.stringify({
|
|
788
1030
|
...e,
|
|
789
1031
|
webVitalsLoader: e.webVitalsLoader !== void 0,
|
|
@@ -791,7 +1033,7 @@ function $t(e) {
|
|
|
791
1033
|
propagateTraceHeaderTo: e.propagateTraceHeaderTo.map(String)
|
|
792
1034
|
});
|
|
793
1035
|
}
|
|
794
|
-
function
|
|
1036
|
+
function Y(e) {
|
|
795
1037
|
return {
|
|
796
1038
|
...e,
|
|
797
1039
|
endpoint: null,
|
|
@@ -804,12 +1046,12 @@ function en(e) {
|
|
|
804
1046
|
};
|
|
805
1047
|
}
|
|
806
1048
|
function X(e) {
|
|
807
|
-
return e.sdkVersion ===
|
|
1049
|
+
return e.sdkVersion === S;
|
|
808
1050
|
}
|
|
809
1051
|
var Z = class e {
|
|
810
1052
|
degraded;
|
|
811
1053
|
static local = null;
|
|
812
|
-
sdkVersion =
|
|
1054
|
+
sdkVersion = S;
|
|
813
1055
|
diagnostics;
|
|
814
1056
|
config;
|
|
815
1057
|
platform;
|
|
@@ -817,21 +1059,25 @@ var Z = class e {
|
|
|
817
1059
|
stores;
|
|
818
1060
|
identityBuiltAs;
|
|
819
1061
|
sessionTouch;
|
|
820
|
-
context = new
|
|
1062
|
+
context = new mn();
|
|
821
1063
|
breadcrumbs;
|
|
822
1064
|
tracing;
|
|
823
|
-
sequence = new
|
|
1065
|
+
sequence = new ct();
|
|
824
1066
|
journey;
|
|
825
1067
|
builder;
|
|
826
1068
|
remote = { sampling: null };
|
|
827
1069
|
console;
|
|
1070
|
+
drops;
|
|
1071
|
+
meter;
|
|
828
1072
|
bus = null;
|
|
829
1073
|
busBuilt;
|
|
830
1074
|
busLoad;
|
|
831
1075
|
storageBuiltAs;
|
|
832
1076
|
sender;
|
|
833
1077
|
senderLoad;
|
|
834
|
-
pendingRecords =
|
|
1078
|
+
pendingRecords = new _n((e) => {
|
|
1079
|
+
this.dropHeld(e);
|
|
1080
|
+
});
|
|
835
1081
|
captures = [];
|
|
836
1082
|
captureGeneration = 0;
|
|
837
1083
|
captureOnce = {
|
|
@@ -839,7 +1085,9 @@ var Z = class e {
|
|
|
839
1085
|
navigationTiming: !1,
|
|
840
1086
|
longFrames: !1
|
|
841
1087
|
};
|
|
842
|
-
bootBuffer =
|
|
1088
|
+
bootBuffer = new _n((e) => {
|
|
1089
|
+
this.dropHeld(e);
|
|
1090
|
+
});
|
|
843
1091
|
forwardBuffer = [];
|
|
844
1092
|
forwardScheduled = !1;
|
|
845
1093
|
roleResolved = !1;
|
|
@@ -847,13 +1095,19 @@ var Z = class e {
|
|
|
847
1095
|
ready = !1;
|
|
848
1096
|
destroyed = !1;
|
|
849
1097
|
lastGapAt = 0;
|
|
1098
|
+
limits;
|
|
1099
|
+
journeyOptions;
|
|
1100
|
+
tunablesLocked = !0;
|
|
850
1101
|
constructor(e, t = !1) {
|
|
851
|
-
this.degraded = t, this.diagnostics = new
|
|
1102
|
+
this.degraded = t, this.diagnostics = new hn(e.onDiagnostic), this.platform = Ue(this.diagnostics), this.config = dn(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Be() : He, this.identity = Ve(this.diagnostics, this.stores), this.sessionTouch = new Re(this.diagnostics, this.stores), this.breadcrumbs = new vt(50), this.tracing = new _t(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.limits = { ...this.config.limits }, this.console = new st(this.config.console, this.diagnostics, this.limits), this.drops = new gn(this.config, this.diagnostics), this.journeyOptions = {
|
|
1103
|
+
...Xe,
|
|
1104
|
+
maxAgeMs: this.config.journey.maxAgeMs
|
|
1105
|
+
}, this.journey = new Ye(this.journeyOptions, this.diagnostics, this.identity.contextId, (e) => {
|
|
852
1106
|
this.bus?.broadcastJourney(e);
|
|
853
|
-
}, this.stores), this.builder = new
|
|
1107
|
+
}, this.stores), this.builder = new Dn({
|
|
854
1108
|
remote: this.remote,
|
|
855
1109
|
config: this.config,
|
|
856
|
-
limits:
|
|
1110
|
+
limits: this.limits,
|
|
857
1111
|
diagnostics: this.diagnostics,
|
|
858
1112
|
context: this.context,
|
|
859
1113
|
journey: this.journey,
|
|
@@ -861,7 +1115,24 @@ var Z = class e {
|
|
|
861
1115
|
sequence: this.sequence,
|
|
862
1116
|
identity: this.identity,
|
|
863
1117
|
platform: this.platform
|
|
1118
|
+
}), this.meter = new wn(() => this.config.batching.metricFlushIntervalMs, (e, t, n) => {
|
|
1119
|
+
this.emitPoint(e, t, n);
|
|
1120
|
+
}, this.diagnostics);
|
|
1121
|
+
}
|
|
1122
|
+
recordMetric(e, t, n) {
|
|
1123
|
+
this.destroyed || this.meter.record(e, t, n);
|
|
1124
|
+
}
|
|
1125
|
+
emitPoint(e, t, n) {
|
|
1126
|
+
let { record: r } = this.builder.build({
|
|
1127
|
+
level: "INFO",
|
|
1128
|
+
type: "metric",
|
|
1129
|
+
body: e,
|
|
1130
|
+
namespace: Se,
|
|
1131
|
+
payload: t,
|
|
1132
|
+
fixed: n,
|
|
1133
|
+
aggregated: !0
|
|
864
1134
|
});
|
|
1135
|
+
this.emit(r);
|
|
865
1136
|
}
|
|
866
1137
|
busAccept = (e, t) => {
|
|
867
1138
|
this.destroyed || this.ensureBus().then((n) => {
|
|
@@ -871,7 +1142,7 @@ var Z = class e {
|
|
|
871
1142
|
});
|
|
872
1143
|
};
|
|
873
1144
|
static pinned() {
|
|
874
|
-
return globalThis[
|
|
1145
|
+
return globalThis[q] ?? null;
|
|
875
1146
|
}
|
|
876
1147
|
static current() {
|
|
877
1148
|
let t = e.local;
|
|
@@ -882,36 +1153,48 @@ var Z = class e {
|
|
|
882
1153
|
static stopped() {
|
|
883
1154
|
let t = e.local;
|
|
884
1155
|
if (t?.destroyed) return t;
|
|
885
|
-
let n = globalThis[
|
|
1156
|
+
let n = globalThis[J];
|
|
886
1157
|
return n && X(n) ? n : null;
|
|
887
1158
|
}
|
|
888
1159
|
isDestroyed() {
|
|
889
1160
|
return this.destroyed;
|
|
890
1161
|
}
|
|
891
|
-
static configure(t) {
|
|
892
|
-
let
|
|
893
|
-
if (
|
|
1162
|
+
static configure(t, n = !1) {
|
|
1163
|
+
let r = e.local;
|
|
1164
|
+
if (r && !r.destroyed) return r.reconfigure(Y(t)), r;
|
|
894
1165
|
e.local = null;
|
|
895
|
-
let
|
|
896
|
-
if (
|
|
897
|
-
if (!X(
|
|
898
|
-
if (!
|
|
1166
|
+
let i = e.pinned();
|
|
1167
|
+
if (i) {
|
|
1168
|
+
if (!X(i)) return e.startDegraded(t, i.sdkVersion);
|
|
1169
|
+
if (!i.destroyed) return i.reconfigure(t), i;
|
|
899
1170
|
}
|
|
900
|
-
let
|
|
901
|
-
return globalThis[
|
|
1171
|
+
let a = new e(t);
|
|
1172
|
+
return a.tunablesLocked = !n, globalThis[q] = a, Reflect.deleteProperty(globalThis, J), a.init(), a;
|
|
902
1173
|
}
|
|
903
1174
|
static startDegraded(t, n) {
|
|
904
|
-
let r = new e(
|
|
1175
|
+
let r = new e(Y(t), !0);
|
|
905
1176
|
e.local = r;
|
|
906
1177
|
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 ${
|
|
1178
|
+
return r.diagnostics.report("runtime.version_mismatch", `Another copy of the library, version ${i}, owns the page runtime. This copy, version ${S}, runs in console-only mode and installs no capture. Load one version of the library on the page.`, {
|
|
908
1179
|
found: i,
|
|
909
|
-
own:
|
|
1180
|
+
own: S
|
|
910
1181
|
}), r.init(), r;
|
|
911
1182
|
}
|
|
912
1183
|
reconfigure(e) {
|
|
913
|
-
let t = this.keepDestination(e), n =
|
|
914
|
-
|
|
1184
|
+
let t = this.keepDestination(e), n = An(this.config.capture), r = dn(t, this.diagnostics, this.config);
|
|
1185
|
+
this.keepStartupTunables(r), pn(this.config, r), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), An(this.config.capture) !== n && this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
|
|
1186
|
+
}
|
|
1187
|
+
keepStartupTunables(e) {
|
|
1188
|
+
if (this.senderLoad !== void 0 && this.keepSections(e, kn), !this.tunablesLocked) {
|
|
1189
|
+
this.tunablesLocked = !0, Object.assign(this.limits, e.limits), this.journeyOptions.maxAgeMs = e.journey.maxAgeMs;
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
this.keepSections(e, ["limits"]);
|
|
1193
|
+
let { maxAgeMs: t } = this.config.journey;
|
|
1194
|
+
e.journey.maxAgeMs !== t && (this.diagnostics.report("config.invalid", `journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`, { requested: e.journey.maxAgeMs }), e.journey.maxAgeMs = t);
|
|
1195
|
+
}
|
|
1196
|
+
keepSections(e, t) {
|
|
1197
|
+
for (let n of t) JSON.stringify(e[n]) !== JSON.stringify(this.config[n]) && (this.diagnostics.report("config.invalid", `${n} cannot change after startup. The values in force stay.`, { requested: e[n] }), Object.assign(e, { [n]: this.config[n] }));
|
|
915
1198
|
}
|
|
916
1199
|
keepBuiltStorage() {
|
|
917
1200
|
let e = this.storageBuiltAs;
|
|
@@ -960,7 +1243,7 @@ var Z = class e {
|
|
|
960
1243
|
}
|
|
961
1244
|
async buildBus() {
|
|
962
1245
|
try {
|
|
963
|
-
let { Bus: e } = await import("./bus-
|
|
1246
|
+
let { Bus: e } = await import("./bus-DrixwdiX.js");
|
|
964
1247
|
if (this.destroyed) return null;
|
|
965
1248
|
let t = new e(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
|
|
966
1249
|
onRecords: (e) => {
|
|
@@ -984,7 +1267,10 @@ var Z = class e {
|
|
|
984
1267
|
return this.bus?.getRole() ?? "sender";
|
|
985
1268
|
}
|
|
986
1269
|
syncSender() {
|
|
987
|
-
return !
|
|
1270
|
+
return !this.hasDestination() || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
|
|
1271
|
+
}
|
|
1272
|
+
hasDestination() {
|
|
1273
|
+
return !!this.config.endpoint || this.config.transport !== void 0;
|
|
988
1274
|
}
|
|
989
1275
|
loadSender() {
|
|
990
1276
|
return this.senderLoad ??= this.buildSender(), this.senderLoad;
|
|
@@ -992,11 +1278,15 @@ var Z = class e {
|
|
|
992
1278
|
async buildSender() {
|
|
993
1279
|
this.storageBuiltAs = this.config.storage;
|
|
994
1280
|
try {
|
|
995
|
-
let { Sender: e } = await import("./sender
|
|
1281
|
+
let { Sender: e } = await import("./sender--0_VzPbN.js"), t = this.destroyed ? null : await e.create({
|
|
996
1282
|
config: this.config,
|
|
997
1283
|
diagnostics: this.diagnostics,
|
|
998
1284
|
onGap: this.reportGap,
|
|
999
|
-
|
|
1285
|
+
onLoss: this.reportLoss,
|
|
1286
|
+
remote: this.remote,
|
|
1287
|
+
beforeExit: () => {
|
|
1288
|
+
this.meter.collect();
|
|
1289
|
+
}
|
|
1000
1290
|
});
|
|
1001
1291
|
if (!t || this.destroyed) {
|
|
1002
1292
|
await t?.destroy();
|
|
@@ -1004,11 +1294,9 @@ var Z = class e {
|
|
|
1004
1294
|
}
|
|
1005
1295
|
this.sender = t;
|
|
1006
1296
|
} catch (e) {
|
|
1007
|
-
this.senderLoad = void 0, this.diagnostics.report("pipeline.crashed", "The delivery stack did not load. The library does not send records.", { held: this.pendingRecords.length }, e);
|
|
1297
|
+
this.senderLoad = void 0, this.diagnostics.report("pipeline.crashed", "The delivery stack did not load. The library does not send records.", { held: this.pendingRecords.length }, e), this.drops.add("load_failed", this.pendingRecords.records);
|
|
1008
1298
|
}
|
|
1009
|
-
let e
|
|
1010
|
-
this.pendingRecords = [];
|
|
1011
|
-
for (let t of e) this.sender?.push(t);
|
|
1299
|
+
for (let e of this.pendingRecords.take()) this.sender?.push(e);
|
|
1012
1300
|
}
|
|
1013
1301
|
async installCaptures() {
|
|
1014
1302
|
if (this.degraded) return;
|
|
@@ -1017,15 +1305,18 @@ var Z = class e {
|
|
|
1017
1305
|
let r = await Promise.all(n.map((e) => this.loadCapture(e)));
|
|
1018
1306
|
if (e !== this.captureGeneration || this.destroyed) return;
|
|
1019
1307
|
this.uninstallCaptures();
|
|
1020
|
-
let
|
|
1308
|
+
let a = {
|
|
1021
1309
|
config: this.config,
|
|
1022
1310
|
diagnostics: this.diagnostics,
|
|
1023
1311
|
breadcrumbs: this.breadcrumbs,
|
|
1024
1312
|
tracing: this.tracing,
|
|
1025
|
-
logger: new
|
|
1026
|
-
once: this.captureOnce
|
|
1313
|
+
logger: new I(() => this, i),
|
|
1314
|
+
once: this.captureOnce,
|
|
1315
|
+
recordMetric: (e, t, n) => {
|
|
1316
|
+
this.recordMetric(e, t, n);
|
|
1317
|
+
}
|
|
1027
1318
|
};
|
|
1028
|
-
for (let e of r) e && this.captures.push(new e(
|
|
1319
|
+
for (let e of r) e && this.captures.push(new e(a));
|
|
1029
1320
|
for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `The library could not install the ${e.name} capture.`, () => {
|
|
1030
1321
|
e.install();
|
|
1031
1322
|
});
|
|
@@ -1037,7 +1328,7 @@ var Z = class e {
|
|
|
1037
1328
|
this.captures.length = 0;
|
|
1038
1329
|
}
|
|
1039
1330
|
loadCapture(e) {
|
|
1040
|
-
return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`,
|
|
1331
|
+
return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, On[e]);
|
|
1041
1332
|
}
|
|
1042
1333
|
registerWorker(e) {
|
|
1043
1334
|
this.destroyed || this.constructBus().then((t) => {
|
|
@@ -1048,42 +1339,46 @@ var Z = class e {
|
|
|
1048
1339
|
}
|
|
1049
1340
|
async destroy() {
|
|
1050
1341
|
if (this.destroyed) return;
|
|
1051
|
-
this.destroyed = !0, this.uninstallCaptures();
|
|
1342
|
+
this.meter.collect(), this.destroyed = !0, this.uninstallCaptures();
|
|
1052
1343
|
let t = this.sender?.destroy();
|
|
1053
|
-
this.journey.destroy(), this.bus?.destroy(), this.
|
|
1344
|
+
this.journey.destroy(), this.sendForwarded(), this.bus?.destroy(), this.drops.add("load_failed", this.pendingRecords.take()), await t, await this.senderLoad, e.pinned() === this && (Reflect.deleteProperty(globalThis, q), globalThis[J] = this);
|
|
1054
1345
|
}
|
|
1055
1346
|
emit(e) {
|
|
1056
|
-
e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.
|
|
1347
|
+
e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.bootBuffer.push(e));
|
|
1057
1348
|
}
|
|
1058
1349
|
route(e) {
|
|
1059
1350
|
this.role() === "forwarder" ? this.forward(e) : this.deliver(e);
|
|
1060
1351
|
}
|
|
1061
1352
|
deliver(e) {
|
|
1062
|
-
this.sender ? this.sender.push(e) : this.senderLoad ? this.
|
|
1353
|
+
this.sender ? this.sender.push(e) : this.senderLoad ? this.pendingRecords.push(e) : (this.diagnostics.count("record.dropped_no_destination"), this.hasDestination() && this.drops.add("load_failed", [e]));
|
|
1063
1354
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1355
|
+
dropHeld(e) {
|
|
1356
|
+
this.diagnostics.count("record.dropped_boot_buffer_full"), this.drops.add("buffer_full", [e]);
|
|
1066
1357
|
}
|
|
1067
1358
|
forward(e) {
|
|
1068
1359
|
this.forwardBuffer.push(e), !this.forwardScheduled && (this.forwardScheduled = !0, queueMicrotask(() => {
|
|
1069
|
-
this.forwardScheduled = !1;
|
|
1070
|
-
let e = this.forwardBuffer;
|
|
1071
|
-
this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
|
|
1360
|
+
this.forwardScheduled = !1, this.sendForwarded();
|
|
1072
1361
|
}));
|
|
1073
1362
|
}
|
|
1363
|
+
sendForwarded() {
|
|
1364
|
+
let e = this.forwardBuffer;
|
|
1365
|
+
this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
|
|
1366
|
+
}
|
|
1074
1367
|
ingestForwarded(e) {
|
|
1075
1368
|
if (!Array.isArray(e)) this.diagnostics.count("record.dropped_malformed");
|
|
1076
|
-
else for (let t of e)
|
|
1369
|
+
else for (let t of e) Oe(t) ? Ae(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
|
|
1077
1370
|
}
|
|
1078
1371
|
releaseBootBuffer() {
|
|
1079
|
-
let e = this.bootBuffer;
|
|
1080
|
-
this.bootBuffer = [];
|
|
1081
|
-
let t = this.journey.current();
|
|
1372
|
+
let e = this.bootBuffer.take(), t = this.journey.current();
|
|
1082
1373
|
for (let n of e) t && !n.attributes["journey.id"] && (n.attributes["journey.id"] = t.id, n.attributes["journey.name"] = t.name), this.route(n);
|
|
1083
1374
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1375
|
+
reportLoss = (e, t, n) => {
|
|
1376
|
+
this.drops.add(e, t, n);
|
|
1377
|
+
};
|
|
1378
|
+
reportGap = (e, t) => {
|
|
1379
|
+
this.drops.add(e.reason, t.flatMap((e) => e.records), t.map((e) => e.id));
|
|
1380
|
+
let n = Date.now();
|
|
1381
|
+
n - this.lastGapAt < 6e4 || (this.lastGapAt = n, new I(() => this, ye).warn("stored records were dropped before delivery", {
|
|
1087
1382
|
"gap.batches": e.batches,
|
|
1088
1383
|
"gap.records": e.records,
|
|
1089
1384
|
"gap.reason": e.reason
|
|
@@ -1094,21 +1389,18 @@ var Z = class e {
|
|
|
1094
1389
|
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.", {
|
|
1095
1390
|
was: this.identity.tabId,
|
|
1096
1391
|
now: e
|
|
1097
|
-
}), this.identity.tabId = e,
|
|
1392
|
+
}), this.identity.tabId = e, Ie(e, this.diagnostics, this.stores), this.builder.invalidateResource();
|
|
1098
1393
|
}
|
|
1099
1394
|
async queueDepth() {
|
|
1100
1395
|
return await this.senderLoad, await this.sender?.queueDepth() ?? 0;
|
|
1101
1396
|
}
|
|
1102
1397
|
async flush() {
|
|
1103
|
-
|
|
1104
|
-
let e = this.forwardBuffer;
|
|
1105
|
-
this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
|
|
1106
|
-
} else await this.senderLoad, await this.sender?.flush();
|
|
1398
|
+
this.meter.collect(), this.ready || await this.started, this.role() === "forwarder" ? this.sendForwarded() : (await this.senderLoad, await this.sender?.flush());
|
|
1107
1399
|
}
|
|
1108
1400
|
};
|
|
1109
1401
|
//#endregion
|
|
1110
1402
|
//#region src/transport/memory-transport.ts
|
|
1111
|
-
function
|
|
1403
|
+
function jn() {
|
|
1112
1404
|
let e = [], t = [], n = { status: 200 };
|
|
1113
1405
|
return {
|
|
1114
1406
|
transport: (r) => (e.push(r), n.status >= 200 && n.status < 300 && t.push(r), Promise.resolve({ ...n })),
|
|
@@ -1127,100 +1419,122 @@ function tn() {
|
|
|
1127
1419
|
}
|
|
1128
1420
|
//#endregion
|
|
1129
1421
|
//#region src/index.ts
|
|
1130
|
-
var
|
|
1422
|
+
var Mn = /* @__PURE__ */ new Map();
|
|
1131
1423
|
function Q() {
|
|
1132
|
-
return (Z.current() ?? Z.stopped()) || Z.configure({});
|
|
1424
|
+
return (Z.current() ?? Z.stopped()) || Z.configure({}, !0);
|
|
1133
1425
|
}
|
|
1134
|
-
function
|
|
1426
|
+
function Nn(e) {
|
|
1135
1427
|
Z.configure(e);
|
|
1136
1428
|
}
|
|
1137
|
-
function
|
|
1138
|
-
if (t) return new
|
|
1139
|
-
let n =
|
|
1140
|
-
return n || (n = new
|
|
1429
|
+
function Pn(e, t) {
|
|
1430
|
+
if (t) return new I(Q, e, t);
|
|
1431
|
+
let n = Mn.get(e);
|
|
1432
|
+
return n || (n = new I(Q, e), Mn.set(e, n)), n;
|
|
1141
1433
|
}
|
|
1142
1434
|
function $() {
|
|
1143
|
-
return
|
|
1435
|
+
return Pn("app");
|
|
1144
1436
|
}
|
|
1145
|
-
function
|
|
1437
|
+
function Fn(e, t) {
|
|
1146
1438
|
$().trace(e, t);
|
|
1147
1439
|
}
|
|
1148
|
-
function
|
|
1440
|
+
function In(e, t) {
|
|
1149
1441
|
$().debug(e, t);
|
|
1150
1442
|
}
|
|
1151
|
-
function
|
|
1443
|
+
function Ln(e, t) {
|
|
1152
1444
|
$().info(e, t);
|
|
1153
1445
|
}
|
|
1154
|
-
function
|
|
1446
|
+
function Rn(e, t) {
|
|
1155
1447
|
$().warn(e, t);
|
|
1156
1448
|
}
|
|
1157
|
-
function
|
|
1449
|
+
function zn(e, t, n) {
|
|
1158
1450
|
$().error(e, t, n);
|
|
1159
1451
|
}
|
|
1160
|
-
function
|
|
1452
|
+
function Bn(e, t, n) {
|
|
1161
1453
|
$().fatal(e, t, n);
|
|
1162
1454
|
}
|
|
1163
|
-
function
|
|
1455
|
+
function Vn(e, t) {
|
|
1164
1456
|
$().logAction(e, t);
|
|
1165
1457
|
}
|
|
1166
|
-
function
|
|
1458
|
+
function Hn(e, t) {
|
|
1167
1459
|
$().logEvent(e, t);
|
|
1168
1460
|
}
|
|
1169
|
-
function
|
|
1461
|
+
function Un(e, t, n, r, i) {
|
|
1170
1462
|
$().logMetric(e, t, n, r, i);
|
|
1171
1463
|
}
|
|
1172
|
-
function
|
|
1464
|
+
function Wn(e, t = {}) {
|
|
1465
|
+
let n = {
|
|
1466
|
+
name: e,
|
|
1467
|
+
kind: "counter",
|
|
1468
|
+
unit: t.unit ?? "count",
|
|
1469
|
+
boundaries: []
|
|
1470
|
+
};
|
|
1471
|
+
return { add: (e, t) => {
|
|
1472
|
+
Q().recordMetric(n, e, t);
|
|
1473
|
+
} };
|
|
1474
|
+
}
|
|
1475
|
+
function Gn(e, t = {}) {
|
|
1476
|
+
let n = {
|
|
1477
|
+
name: e,
|
|
1478
|
+
kind: "histogram",
|
|
1479
|
+
unit: t.unit ?? "count",
|
|
1480
|
+
boundaries: t.boundaries ?? ae
|
|
1481
|
+
};
|
|
1482
|
+
return { record: (e, t) => {
|
|
1483
|
+
Q().recordMetric(n, e, t);
|
|
1484
|
+
} };
|
|
1485
|
+
}
|
|
1486
|
+
function Kn(e, t, n) {
|
|
1173
1487
|
return $().timeSync(e, t, n);
|
|
1174
1488
|
}
|
|
1175
|
-
function
|
|
1489
|
+
function qn(e, t, n) {
|
|
1176
1490
|
return $().timeAsync(e, t, n);
|
|
1177
1491
|
}
|
|
1178
|
-
function
|
|
1492
|
+
function Jn(e, t) {
|
|
1179
1493
|
Q().context.set(e, t);
|
|
1180
1494
|
}
|
|
1181
|
-
function
|
|
1495
|
+
function Yn(e) {
|
|
1182
1496
|
Q().context.setMany(e);
|
|
1183
1497
|
}
|
|
1184
|
-
function
|
|
1498
|
+
function Xn(e) {
|
|
1185
1499
|
Q().context.remove(e);
|
|
1186
1500
|
}
|
|
1187
|
-
function
|
|
1501
|
+
function Zn(e, t) {
|
|
1188
1502
|
return Q().journey.start(e, t);
|
|
1189
1503
|
}
|
|
1190
|
-
function
|
|
1504
|
+
function Qn() {
|
|
1191
1505
|
Q().journey.end();
|
|
1192
1506
|
}
|
|
1193
|
-
function
|
|
1507
|
+
function $n() {
|
|
1194
1508
|
return Q().journey.current();
|
|
1195
1509
|
}
|
|
1196
|
-
function
|
|
1510
|
+
function er() {
|
|
1197
1511
|
return Q().journey.getToken();
|
|
1198
1512
|
}
|
|
1199
|
-
function
|
|
1513
|
+
function tr(e) {
|
|
1200
1514
|
return Q().journey.adopt(e, "manual", !0);
|
|
1201
1515
|
}
|
|
1202
|
-
function
|
|
1516
|
+
function nr(e) {
|
|
1203
1517
|
Q().registerWorker(e);
|
|
1204
1518
|
}
|
|
1205
|
-
function
|
|
1519
|
+
function rr() {
|
|
1206
1520
|
Q().tracing.rotate("explicit");
|
|
1207
1521
|
}
|
|
1208
|
-
function
|
|
1522
|
+
function ir() {
|
|
1209
1523
|
return Q().tracing.headers();
|
|
1210
1524
|
}
|
|
1211
|
-
function
|
|
1525
|
+
function ar() {
|
|
1212
1526
|
return Q().flush();
|
|
1213
1527
|
}
|
|
1214
|
-
function
|
|
1528
|
+
function or() {
|
|
1215
1529
|
return Q().queueDepth();
|
|
1216
1530
|
}
|
|
1217
|
-
function
|
|
1531
|
+
function sr() {
|
|
1218
1532
|
return Q().diagnostics.snapshot();
|
|
1219
1533
|
}
|
|
1220
|
-
async function
|
|
1534
|
+
async function cr() {
|
|
1221
1535
|
await Z.current()?.destroy();
|
|
1222
1536
|
}
|
|
1223
1537
|
//#endregion
|
|
1224
|
-
export {
|
|
1538
|
+
export { I as OneLogger, tr as adoptJourney, Nn as configure, Wn as counter, jn as createMemoryTransport, $n as currentJourney, In as debug, Qn as endJourney, zn as error, Bn as fatal, ar as flush, sr as getDiagnosticCounters, er as getJourneyToken, Pn as getLogger, or as getQueueDepth, ir as getTraceHeaders, Gn as histogram, Ln as info, Vn as logAction, Hn as logEvent, Un as logMetric, nr as registerWorker, Xn as removeContext, Jn as setContext, Yn as setContextMap, cr as shutdown, Zn as startJourney, rr as startTrace, qn as timeAsync, Kn as timeSync, Fn as trace, Rn as warn };
|
|
1225
1539
|
|
|
1226
1540
|
//# sourceMappingURL=index.js.map
|