@utk09/ui-observability 0.6.0 → 0.8.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 +34 -0
- package/README.md +189 -25
- package/dist/bus/bus.d.ts +30 -0
- package/dist/bus-CUXRY0JR.cjs +2 -0
- package/dist/bus-CUXRY0JR.cjs.map +1 -0
- package/dist/{bus-BTMuVkDk.js → bus-DPDrlUBY.js} +96 -50
- package/dist/bus-DPDrlUBY.js.map +1 -0
- package/dist/capture/console.d.ts +37 -0
- package/dist/capture/errors.d.ts +2 -4
- package/dist/capture/long-frames.d.ts +31 -0
- package/dist/capture/storm.d.ts +17 -0
- package/dist/capture/types.d.ts +2 -0
- package/dist/console-CNljJict.js +81 -0
- package/dist/console-CNljJict.js.map +1 -0
- package/dist/console-PKzc-FmR.cjs +2 -0
- package/dist/console-PKzc-FmR.cjs.map +1 -0
- package/dist/constants-B28fDv2F.cjs +2 -0
- package/dist/constants-B28fDv2F.cjs.map +1 -0
- package/dist/constants-Bu49bm39.js +93 -0
- package/dist/constants-Bu49bm39.js.map +1 -0
- package/dist/constants.d.ts +35 -5
- package/dist/core/breadcrumbs.d.ts +1 -1
- package/dist/core/pipeline.d.ts +2 -2
- package/dist/core/record.d.ts +3 -0
- package/dist/core/remote-rules.d.ts +17 -0
- package/dist/core/remote-sampling.d.ts +65 -0
- package/dist/core/runtime.d.ts +10 -4
- package/dist/core/sampling.d.ts +5 -2
- package/dist/core/sender.d.ts +3 -0
- package/dist/errors-C78ZTjet.cjs +3 -0
- package/dist/errors-C78ZTjet.cjs.map +1 -0
- package/dist/{errors-Dwm2SzBa.js → errors-Dnc-X4Ec.js} +19 -20
- package/dist/errors-Dnc-X4Ec.js.map +1 -0
- package/dist/global-scope-BN-Io_yv.cjs +2 -0
- package/dist/global-scope-BN-Io_yv.cjs.map +1 -0
- package/dist/global-scope-dp2jADRl.js +19 -0
- package/dist/global-scope-dp2jADRl.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +307 -241
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-D0p3iMD0.cjs +2 -0
- package/dist/{indexeddb-storage-B5dwq4hW.cjs.map → indexeddb-storage-D0p3iMD0.cjs.map} +1 -1
- package/dist/{indexeddb-storage-DjY4Ml6t.js → indexeddb-storage-uD4oaRMc.js} +10 -10
- package/dist/{indexeddb-storage-DjY4Ml6t.js.map → indexeddb-storage-uD4oaRMc.js.map} +1 -1
- package/dist/{interactions-DVom6eYn.cjs → interactions-CsE2y_fQ.cjs} +2 -2
- package/dist/{interactions-DVom6eYn.cjs.map → interactions-CsE2y_fQ.cjs.map} +1 -1
- package/dist/{interactions-DZmLu7l2.js → interactions-igKTAJvj.js} +2 -2
- package/dist/{interactions-DZmLu7l2.js.map → interactions-igKTAJvj.js.map} +1 -1
- package/dist/library-request-Br_T09Bn.cjs +2 -0
- package/dist/library-request-Br_T09Bn.cjs.map +1 -0
- package/dist/library-request-Dt0fXhcn.js +14 -0
- package/dist/library-request-Dt0fXhcn.js.map +1 -0
- package/dist/long-frames-6pnjWSSR.js +65 -0
- package/dist/long-frames-6pnjWSSR.js.map +1 -0
- package/dist/long-frames-DahhqM6u.cjs +2 -0
- package/dist/long-frames-DahhqM6u.cjs.map +1 -0
- package/dist/models/bus.d.ts +16 -0
- package/dist/models/config.d.ts +120 -6
- package/dist/network-CZ0aFUsy.cjs +2 -0
- package/dist/network-CZ0aFUsy.cjs.map +1 -0
- package/dist/{network-C4d2uw2Z.js → network-aSNbwpue.js} +16 -15
- package/dist/network-aSNbwpue.js.map +1 -0
- package/dist/{platform-CY8S3hUs.js → platform-BwbMRwHm.js} +7 -7
- package/dist/{platform-CY8S3hUs.js.map → platform-BwbMRwHm.js.map} +1 -1
- package/dist/{platform-CXio0W2n.cjs → platform-D_XkVIF6.cjs} +2 -2
- package/dist/{platform-CXio0W2n.cjs.map → platform-D_XkVIF6.cjs.map} +1 -1
- package/dist/remote-rules-5UA23alm.js +86 -0
- package/dist/remote-rules-5UA23alm.js.map +1 -0
- package/dist/remote-rules-rJJZKVG8.cjs +2 -0
- package/dist/remote-rules-rJJZKVG8.cjs.map +1 -0
- package/dist/sampling-E4x92Nn2.cjs +2 -0
- package/dist/sampling-E4x92Nn2.cjs.map +1 -0
- package/dist/sampling-J1eahbfT.js +160 -0
- package/dist/sampling-J1eahbfT.js.map +1 -0
- package/dist/sanitize-BMhh8ghJ.cjs +2 -0
- package/dist/sanitize-BMhh8ghJ.cjs.map +1 -0
- package/dist/sanitize-UJ-4Lb0n.js +114 -0
- package/dist/sanitize-UJ-4Lb0n.js.map +1 -0
- package/dist/sender-B6ufz26f.cjs +3 -0
- package/dist/sender-B6ufz26f.cjs.map +1 -0
- package/dist/{sender-dpvR_bHM.js → sender-G6v4Uqi4.js} +304 -219
- package/dist/sender-G6v4Uqi4.js.map +1 -0
- package/dist/storm-BtzgLOCX.cjs +2 -0
- package/dist/storm-BtzgLOCX.cjs.map +1 -0
- package/dist/storm-DJkEZP_8.js +10 -0
- package/dist/storm-DJkEZP_8.js.map +1 -0
- package/dist/transport/custom-transport.d.ts +20 -0
- package/dist/transport/errors.d.ts +2 -1
- package/dist/transport/exit-flush.d.ts +15 -0
- package/dist/transport/http-transport.d.ts +2 -24
- package/dist/transport/memory-transport.d.ts +30 -0
- package/dist/transport/retry-engine.d.ts +2 -2
- package/dist/transport/serializers/select.d.ts +12 -1
- package/dist/transport/status-transport.d.ts +72 -0
- package/dist/utils/console.d.ts +7 -6
- package/dist/utils/deadline.d.ts +7 -0
- package/dist/utils/global-scope.d.ts +20 -0
- package/dist/utils/library-console.d.ts +11 -0
- package/dist/utils/library-request.d.ts +12 -0
- package/package.json +4 -2
- package/dist/bus-BTMuVkDk.js.map +0 -1
- package/dist/bus-ChIXDAWD.cjs +0 -2
- package/dist/bus-ChIXDAWD.cjs.map +0 -1
- package/dist/constants-0-YchbAL.js +0 -75
- package/dist/constants-0-YchbAL.js.map +0 -1
- package/dist/constants-TUFcy95w.cjs +0 -2
- package/dist/constants-TUFcy95w.cjs.map +0 -1
- package/dist/errors-DRXBRqvm.cjs +0 -3
- package/dist/errors-DRXBRqvm.cjs.map +0 -1
- package/dist/errors-Dwm2SzBa.js.map +0 -1
- package/dist/indexeddb-storage-B5dwq4hW.cjs +0 -2
- package/dist/network-C4d2uw2Z.js.map +0 -1
- package/dist/network-CuqWadNn.cjs +0 -2
- package/dist/network-CuqWadNn.cjs.map +0 -1
- package/dist/sampling-CEthcmEX.cjs +0 -2
- package/dist/sampling-CEthcmEX.cjs.map +0 -1
- package/dist/sampling-CJsI_24L.js +0 -251
- package/dist/sampling-CJsI_24L.js.map +0 -1
- package/dist/sender-ByFAkXVd.cjs +0 -3
- package/dist/sender-ByFAkXVd.cjs.map +0 -1
- package/dist/sender-dpvR_bHM.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { At as e,
|
|
2
|
-
import {
|
|
3
|
-
import { n as Le,
|
|
4
|
-
import { t as Be } from "./
|
|
1
|
+
import { At as e, Bt as t, C as n, Ct as r, D as i, E as a, F as o, Ft as s, Gt as c, It as l, Lt as u, M as d, Mt as f, N as p, Nt as m, Ot as h, Pt as g, Rt as _, T as v, Wt as ee, Zt as te, _ as ne, _t as re, a as y, at as b, c as x, cn as ie, d as ae, dn as oe, fn as se, g as ce, gn as S, h as le, hn as ue, i as de, it as fe, j as C, jt as pe, kt as me, l as w, ln as he, m as ge, mn as _e, n as T, nt as ve, o as E, p as ye, qt as D, r as be, rt as O, s as xe, st as Se, tn as Ce, u as k, un as we, vt as Te, zt as Ee } from "./constants-Bu49bm39.js";
|
|
2
|
+
import { a as De, c as Oe, d as A, f as ke, l as j, m as Ae, n as je, o as M, p as N, r as Me, s as Ne, u as Pe } from "./sampling-J1eahbfT.js";
|
|
3
|
+
import { a as Fe, i as Ie, n as Le, o as P, r as F } from "./sanitize-UJ-4Lb0n.js";
|
|
4
|
+
import { n as Re, r as ze, t as Be } from "./platform-BwbMRwHm.js";
|
|
5
|
+
import { t as Ve } from "./unref-16maCyKA.js";
|
|
5
6
|
//#region src/utils/timer.ts
|
|
6
|
-
function
|
|
7
|
-
return Math.round((performance.now() - e) *
|
|
7
|
+
function I(e) {
|
|
8
|
+
return Math.round((performance.now() - e) * o) / o;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
e.logMetric(`${t}.duration`,
|
|
10
|
+
function L(e, t, n, r, i) {
|
|
11
|
+
e.logMetric(`${t}.duration`, I(n), "ms", "histogram", {
|
|
11
12
|
status: r,
|
|
12
13
|
...i
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function R(e, t, n, r, i) {
|
|
16
17
|
e.error(`${t} failed`, r, {
|
|
17
|
-
"action.duration_ms":
|
|
18
|
+
"action.duration_ms": I(n),
|
|
18
19
|
status: "FAILURE",
|
|
19
20
|
...i
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function He(e, t, n, r) {
|
|
23
24
|
let i = performance.now();
|
|
24
25
|
try {
|
|
25
26
|
let a = n();
|
|
26
|
-
return
|
|
27
|
+
return L(e, t, i, "SUCCESS", r), a;
|
|
27
28
|
} catch (n) {
|
|
28
|
-
throw
|
|
29
|
+
throw R(e, t, i, n, r), n;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
async function
|
|
32
|
+
async function Ue(e, t, n, r) {
|
|
32
33
|
let i = performance.now();
|
|
33
34
|
try {
|
|
34
35
|
let a = await n();
|
|
35
|
-
return
|
|
36
|
+
return L(e, t, i, "SUCCESS", r), a;
|
|
36
37
|
} catch (n) {
|
|
37
|
-
throw
|
|
38
|
+
throw R(e, t, i, n, r), n;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
//#endregion
|
|
41
42
|
//#region src/core/logger.ts
|
|
42
|
-
function
|
|
43
|
+
function We(e, t) {
|
|
43
44
|
if (e instanceof Error) return e;
|
|
44
45
|
let n = t.guard("record.sanitize_failed", "The library could not convert the error reason to text.", () => String(e));
|
|
45
46
|
return Error(n ?? typeof e);
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function Ge(e) {
|
|
48
49
|
if (typeof e != "object" || !e || Array.isArray(e) || e instanceof Error) return !1;
|
|
49
50
|
let t = Object.getPrototypeOf(e);
|
|
50
51
|
return t === null || Object.getPrototypeOf(t) === null;
|
|
51
52
|
}
|
|
52
|
-
var
|
|
53
|
+
var z = class e {
|
|
53
54
|
bind;
|
|
54
55
|
namespace;
|
|
55
56
|
options;
|
|
@@ -86,7 +87,7 @@ var R = class e {
|
|
|
86
87
|
logEvent = (e, t) => {
|
|
87
88
|
this.write("INFO", "event", e, t);
|
|
88
89
|
};
|
|
89
|
-
logMetric = (e, t, n =
|
|
90
|
+
logMetric = (e, t, n = d, r = "gauge", i) => {
|
|
90
91
|
this.write("INFO", "metric", e, {
|
|
91
92
|
"metric.name": e,
|
|
92
93
|
"metric.value": t,
|
|
@@ -95,8 +96,8 @@ var R = class e {
|
|
|
95
96
|
...i
|
|
96
97
|
});
|
|
97
98
|
};
|
|
98
|
-
timeSync = (e, t, n) =>
|
|
99
|
-
timeAsync = (e, t, n) =>
|
|
99
|
+
timeSync = (e, t, n) => He(this, e, t, n);
|
|
100
|
+
timeAsync = (e, t, n) => Ue(this, e, t, n);
|
|
100
101
|
write(e, t, n, r) {
|
|
101
102
|
let i = this.bind();
|
|
102
103
|
if (i.isDestroyed()) return;
|
|
@@ -123,7 +124,7 @@ var R = class e {
|
|
|
123
124
|
if (i.isDestroyed()) return;
|
|
124
125
|
let a = i.builder.isEnabled(e);
|
|
125
126
|
if (!a && !this.mirrors(i, e)) return;
|
|
126
|
-
let o = r === void 0 &&
|
|
127
|
+
let o = r === void 0 && Ge(n), s = o ? n : r, c = o || n === void 0 ? void 0 : We(n, i.diagnostics);
|
|
127
128
|
if (!a) {
|
|
128
129
|
this.print(i, e, t, s, c, null);
|
|
129
130
|
return;
|
|
@@ -152,34 +153,36 @@ var R = class e {
|
|
|
152
153
|
mirrors(e, t) {
|
|
153
154
|
return e.config.enabled && e.console.accepts(t);
|
|
154
155
|
}
|
|
155
|
-
},
|
|
156
|
+
}, Ke = {
|
|
156
157
|
TRACE: "debug",
|
|
157
158
|
DEBUG: "debug",
|
|
158
159
|
INFO: "info",
|
|
159
160
|
WARN: "warn",
|
|
160
161
|
ERROR: "error",
|
|
161
162
|
FATAL: "error"
|
|
162
|
-
},
|
|
163
|
-
|
|
163
|
+
}, qe = class {
|
|
164
|
+
settings;
|
|
164
165
|
diagnostics;
|
|
165
166
|
constructor(e, t) {
|
|
166
|
-
this.
|
|
167
|
+
this.settings = e, this.diagnostics = t;
|
|
167
168
|
}
|
|
168
169
|
update(e) {
|
|
169
|
-
this.
|
|
170
|
+
this.settings = e;
|
|
170
171
|
}
|
|
171
172
|
accepts(e) {
|
|
172
|
-
return this.
|
|
173
|
+
return this.settings.level !== null && b[e] >= b[this.settings.level];
|
|
173
174
|
}
|
|
174
175
|
write(e, t, n, i, a) {
|
|
175
|
-
if (!this.accepts(t) || typeof console > "u") return;
|
|
176
|
-
let o = `%c[%s]%c
|
|
177
|
-
this.diagnostics.guard("handler.threw", `The library could not print to console.${
|
|
178
|
-
let
|
|
179
|
-
a !== void 0 &&
|
|
176
|
+
if (!this.accepts(t) || typeof console > "u" || Fe()) return;
|
|
177
|
+
let o = `%c[%s]%c[${t}]%c`, { styles: s } = this.settings, c = Ke[t];
|
|
178
|
+
this.diagnostics.guard("handler.threw", `The library could not print to console.${c}.`, () => {
|
|
179
|
+
let l = [];
|
|
180
|
+
a !== void 0 && l.push(a), i !== void 0 && l.push(Le(i, r, this.diagnostics)), P(() => {
|
|
181
|
+
console[c](o, s.namespace, e, s[t], "", n, ...l);
|
|
182
|
+
});
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
|
-
},
|
|
185
|
+
}, Je = class {
|
|
183
186
|
value = 0;
|
|
184
187
|
next() {
|
|
185
188
|
return ++this.value;
|
|
@@ -187,38 +190,38 @@ var R = class e {
|
|
|
187
190
|
reset() {
|
|
188
191
|
this.value = 0;
|
|
189
192
|
}
|
|
190
|
-
},
|
|
191
|
-
function
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
function Ze() {
|
|
195
|
-
return P(16);
|
|
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);
|
|
196
196
|
}
|
|
197
197
|
function Qe() {
|
|
198
|
-
return
|
|
198
|
+
return A(16);
|
|
199
|
+
}
|
|
200
|
+
function $e() {
|
|
201
|
+
return A(8);
|
|
199
202
|
}
|
|
200
|
-
function
|
|
203
|
+
function V() {
|
|
201
204
|
return {
|
|
202
|
-
traceId:
|
|
203
|
-
spanId:
|
|
205
|
+
traceId: Qe(),
|
|
206
|
+
spanId: $e(),
|
|
204
207
|
traceFlags: 1,
|
|
205
208
|
startedAt: Date.now()
|
|
206
209
|
};
|
|
207
210
|
}
|
|
208
|
-
function
|
|
211
|
+
function H(e) {
|
|
209
212
|
return {
|
|
210
213
|
traceId: e.traceId,
|
|
211
214
|
spanId: e.spanId,
|
|
212
215
|
traceFlags: e.traceFlags
|
|
213
216
|
};
|
|
214
217
|
}
|
|
215
|
-
var
|
|
218
|
+
var et = class {
|
|
216
219
|
diagnostics;
|
|
217
220
|
maxAgeMs;
|
|
218
221
|
load;
|
|
219
|
-
ambient =
|
|
222
|
+
ambient = V();
|
|
220
223
|
otel;
|
|
221
|
-
constructor(e, t =
|
|
224
|
+
constructor(e, t = se, n) {
|
|
222
225
|
this.diagnostics = e, this.maxAgeMs = t, this.load = n;
|
|
223
226
|
}
|
|
224
227
|
async loadOtel() {
|
|
@@ -230,7 +233,7 @@ var $e = class {
|
|
|
230
233
|
}
|
|
231
234
|
resolve() {
|
|
232
235
|
let e = this.activeSpanContext();
|
|
233
|
-
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"),
|
|
236
|
+
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), H(this.ambient)) : e;
|
|
234
237
|
}
|
|
235
238
|
activeSpanContext() {
|
|
236
239
|
let e = this.otel;
|
|
@@ -238,7 +241,7 @@ var $e = class {
|
|
|
238
241
|
let t = e.trace.getActiveSpan();
|
|
239
242
|
if (t === void 0) return;
|
|
240
243
|
let n = t.spanContext();
|
|
241
|
-
if (
|
|
244
|
+
if (Ze(n)) return {
|
|
242
245
|
traceId: n.traceId,
|
|
243
246
|
spanId: n.spanId,
|
|
244
247
|
traceFlags: n.traceFlags
|
|
@@ -246,7 +249,7 @@ var $e = class {
|
|
|
246
249
|
});
|
|
247
250
|
}
|
|
248
251
|
rotate(e) {
|
|
249
|
-
return this.ambient =
|
|
252
|
+
return this.ambient = V(), H(this.ambient);
|
|
250
253
|
}
|
|
251
254
|
headers() {
|
|
252
255
|
let e = {}, t = this.otel;
|
|
@@ -254,11 +257,11 @@ var $e = class {
|
|
|
254
257
|
t.propagation.inject(t.context.active(), e);
|
|
255
258
|
}), !e.traceparent) {
|
|
256
259
|
let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
|
|
257
|
-
e[
|
|
260
|
+
e[oe] = `00-${t.traceId}-${t.spanId}-${n}`;
|
|
258
261
|
}
|
|
259
262
|
return e;
|
|
260
263
|
}
|
|
261
|
-
},
|
|
264
|
+
}, tt = class {
|
|
262
265
|
buffer;
|
|
263
266
|
pointer = 0;
|
|
264
267
|
filled = !1;
|
|
@@ -278,22 +281,43 @@ var $e = class {
|
|
|
278
281
|
};
|
|
279
282
|
//#endregion
|
|
280
283
|
//#region src/core/config.ts
|
|
281
|
-
function
|
|
284
|
+
function nt(e) {
|
|
282
285
|
return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
|
|
283
286
|
}
|
|
284
|
-
function
|
|
285
|
-
return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" ||
|
|
287
|
+
function rt(e, t, n) {
|
|
288
|
+
return e === void 0 ? t ?? "otlp" : e === "otlp" || e === "ecs" || nt(e) ? e : (n.report("config.invalid", `serializer must be "${D}", "ecs" or an implementation. The library uses "${D}".`), D);
|
|
286
289
|
}
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
var it = new Set(Object.keys(i));
|
|
291
|
+
function at(e, t) {
|
|
292
|
+
let n = {}, r = Object.entries(e ?? {});
|
|
293
|
+
for (let [e, i] of r) it.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
|
+
return n;
|
|
295
|
+
}
|
|
296
|
+
function ot(e, t, n) {
|
|
297
|
+
return e === void 0 ? t : e === !1 ? {
|
|
298
|
+
level: null,
|
|
299
|
+
styles: t.styles
|
|
300
|
+
} : e === !0 ? {
|
|
301
|
+
level: a,
|
|
302
|
+
styles: t.styles
|
|
303
|
+
} : typeof e == "string" ? {
|
|
304
|
+
level: e,
|
|
305
|
+
styles: t.styles
|
|
306
|
+
} : 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) : {
|
|
307
|
+
level: e.level ?? t.level ?? "DEBUG",
|
|
308
|
+
styles: {
|
|
309
|
+
...t.styles,
|
|
310
|
+
...at(e.styles, n)
|
|
311
|
+
}
|
|
312
|
+
};
|
|
289
313
|
}
|
|
290
|
-
function
|
|
314
|
+
function U(e, t, n) {
|
|
291
315
|
let r = n ?? C, i = {
|
|
292
316
|
...r,
|
|
293
317
|
...e,
|
|
294
318
|
endpoint: e.endpoint === void 0 ? r.endpoint : e.endpoint,
|
|
295
|
-
serializer:
|
|
296
|
-
console:
|
|
319
|
+
serializer: rt(e.serializer, n?.serializer, t),
|
|
320
|
+
console: ot(e.console, r.console, t),
|
|
297
321
|
sampling: {
|
|
298
322
|
...r.sampling,
|
|
299
323
|
...e.sampling,
|
|
@@ -311,36 +335,38 @@ function H(e, t, n) {
|
|
|
311
335
|
...e.capture
|
|
312
336
|
}
|
|
313
337
|
};
|
|
314
|
-
if (i.endpoint === "") t.report("config.invalid", "endpoint is missing. The library drops each record. Set endpoint: null for console-only mode.");
|
|
338
|
+
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.");
|
|
315
339
|
else if (i.endpoint !== null) try {
|
|
316
340
|
new URL(i.endpoint);
|
|
317
341
|
} catch (e) {
|
|
318
342
|
t.report("config.invalid", `endpoint is not a valid absolute URL: ${i.endpoint}.`, void 0, e);
|
|
319
343
|
}
|
|
320
|
-
i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${
|
|
344
|
+
i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record reports service.name as '${S}'.`), S);
|
|
321
345
|
let a = i.sampling.defaultRate;
|
|
322
346
|
(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);
|
|
323
|
-
let o =
|
|
324
|
-
|
|
325
|
-
|
|
347
|
+
let o = i.sampling.remoteMaxRate;
|
|
348
|
+
(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
|
+
let s = Object.entries(i.sampling.rates);
|
|
350
|
+
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]), st(e, t), i;
|
|
326
352
|
}
|
|
327
|
-
function
|
|
328
|
-
let n = /* @__PURE__ */ new Set([...Object.keys(C), ...
|
|
353
|
+
function st(e, t) {
|
|
354
|
+
let n = /* @__PURE__ */ new Set([...Object.keys(C), ..._e]);
|
|
329
355
|
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.`);
|
|
330
|
-
for (let n of
|
|
356
|
+
for (let n of v) {
|
|
331
357
|
let r = e[n];
|
|
332
358
|
if (typeof r != "object" || !r) continue;
|
|
333
|
-
let i = /* @__PURE__ */ new Set([...Object.keys(C[n]), ...
|
|
359
|
+
let i = /* @__PURE__ */ new Set([...Object.keys(C[n]), ...ue[n]]);
|
|
334
360
|
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.`);
|
|
335
361
|
}
|
|
336
362
|
}
|
|
337
|
-
function
|
|
338
|
-
for (let n of Object.keys(t))
|
|
339
|
-
for (let n of
|
|
363
|
+
function ct(e, t) {
|
|
364
|
+
for (let n of Object.keys(t)) v.includes(n) || Object.assign(e, { [n]: t[n] });
|
|
365
|
+
for (let n of v) Object.assign(e[n], t[n]);
|
|
340
366
|
}
|
|
341
367
|
//#endregion
|
|
342
368
|
//#region src/core/context.ts
|
|
343
|
-
var
|
|
369
|
+
var lt = class {
|
|
344
370
|
map = /* @__PURE__ */ new Map();
|
|
345
371
|
set(e, t) {
|
|
346
372
|
this.map.set(e, t);
|
|
@@ -360,12 +386,12 @@ var ot = class {
|
|
|
360
386
|
getAll() {
|
|
361
387
|
return Object.fromEntries(this.map);
|
|
362
388
|
}
|
|
363
|
-
},
|
|
389
|
+
}, ut = class {
|
|
364
390
|
handler;
|
|
365
391
|
throttleMs;
|
|
366
392
|
counters = /* @__PURE__ */ new Map();
|
|
367
393
|
lastEmitted = /* @__PURE__ */ new Map();
|
|
368
|
-
constructor(e, t =
|
|
394
|
+
constructor(e, t = p) {
|
|
369
395
|
this.handler = e, this.throttleMs = t;
|
|
370
396
|
}
|
|
371
397
|
setHandler(e) {
|
|
@@ -386,11 +412,15 @@ var ot = class {
|
|
|
386
412
|
cause: r,
|
|
387
413
|
at: a,
|
|
388
414
|
count: i
|
|
389
|
-
};
|
|
390
|
-
if (
|
|
391
|
-
|
|
415
|
+
}, { handler: s } = this;
|
|
416
|
+
if (s) try {
|
|
417
|
+
P(() => {
|
|
418
|
+
s(o);
|
|
419
|
+
});
|
|
392
420
|
} catch (e) {
|
|
393
|
-
this.count("handler.threw"), typeof console < "u" &&
|
|
421
|
+
this.count("handler.threw"), typeof console < "u" && P(() => {
|
|
422
|
+
console.warn(`${Se} The onDiagnostic handler threw an error.`, e);
|
|
423
|
+
});
|
|
394
424
|
}
|
|
395
425
|
}
|
|
396
426
|
guard(e, t, n) {
|
|
@@ -415,51 +445,51 @@ var ot = class {
|
|
|
415
445
|
reset() {
|
|
416
446
|
this.counters.clear(), this.lastEmitted.clear();
|
|
417
447
|
}
|
|
418
|
-
},
|
|
419
|
-
maxAgeMs:
|
|
448
|
+
}, dt = {
|
|
449
|
+
maxAgeMs: ve,
|
|
420
450
|
endOnOwnerClose: !1,
|
|
421
|
-
urlParam:
|
|
451
|
+
urlParam: fe
|
|
422
452
|
};
|
|
423
|
-
function
|
|
453
|
+
function W(e, t) {
|
|
424
454
|
let n = Reflect.get(e, t);
|
|
425
455
|
return typeof n == "string" && n !== "" ? n : void 0;
|
|
426
456
|
}
|
|
427
|
-
function
|
|
457
|
+
function G(e, t) {
|
|
428
458
|
let n = Reflect.get(e, t);
|
|
429
459
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
430
460
|
}
|
|
431
|
-
function
|
|
461
|
+
function ft(e) {
|
|
432
462
|
if (typeof e != "object" || !e) return null;
|
|
433
|
-
let t =
|
|
463
|
+
let t = W(e, "id"), n = W(e, "name"), r = G(e, "startedAt");
|
|
434
464
|
return t === void 0 || n === void 0 || r === void 0 ? null : {
|
|
435
465
|
id: t,
|
|
436
466
|
name: n,
|
|
437
467
|
startedAt: r,
|
|
438
|
-
parentId:
|
|
439
|
-
ownerContextId:
|
|
468
|
+
parentId: W(e, "parentId"),
|
|
469
|
+
ownerContextId: W(e, "ownerContextId") ?? ""
|
|
440
470
|
};
|
|
441
471
|
}
|
|
442
|
-
function
|
|
472
|
+
function pt(e) {
|
|
443
473
|
if (typeof e != "object" || !e) return null;
|
|
444
|
-
let t =
|
|
474
|
+
let t = W(e, "i"), n = W(e, "n");
|
|
445
475
|
return t === void 0 || n === void 0 ? null : {
|
|
446
476
|
id: t,
|
|
447
477
|
name: n,
|
|
448
|
-
startedAt:
|
|
478
|
+
startedAt: G(e, "s") ?? Date.now(),
|
|
449
479
|
parentId: void 0,
|
|
450
480
|
ownerContextId: ""
|
|
451
481
|
};
|
|
452
482
|
}
|
|
453
|
-
function
|
|
483
|
+
function mt(e) {
|
|
454
484
|
let t = JSON.stringify({
|
|
455
485
|
i: e.id,
|
|
456
486
|
n: e.name.slice(0, 64),
|
|
457
487
|
s: e.startedAt
|
|
458
488
|
}), n = new TextEncoder().encode(t), r = "";
|
|
459
489
|
for (let e of n) r += String.fromCharCode(e);
|
|
460
|
-
return btoa(r).replace(
|
|
490
|
+
return btoa(r).replace(ce, "-").replace(ne, "_").replace(le, "");
|
|
461
491
|
}
|
|
462
|
-
var
|
|
492
|
+
var ht = class {
|
|
463
493
|
options;
|
|
464
494
|
diagnostics;
|
|
465
495
|
contextId;
|
|
@@ -467,7 +497,7 @@ var ft = class {
|
|
|
467
497
|
stores;
|
|
468
498
|
journey = null;
|
|
469
499
|
expiryTimer = null;
|
|
470
|
-
constructor(e, t, n, r, i =
|
|
500
|
+
constructor(e, t, n, r, i = M) {
|
|
471
501
|
this.options = e, this.diagnostics = t, this.contextId = n, this.onLocalChange = r, this.stores = i;
|
|
472
502
|
}
|
|
473
503
|
current() {
|
|
@@ -476,7 +506,7 @@ var ft = class {
|
|
|
476
506
|
async bootstrap() {
|
|
477
507
|
let e = this.readUrlToken();
|
|
478
508
|
if (e && this.adopt(e, "url")) return;
|
|
479
|
-
let t = this.diagnostics.guard("storage.unavailable", "The library could not read the persisted journey.", () => this.stores.session().getItem(
|
|
509
|
+
let t = this.diagnostics.guard("storage.unavailable", "The library could not read the persisted journey.", () => this.stores.session().getItem(O));
|
|
480
510
|
if (t && this.restore(t)) return;
|
|
481
511
|
let n = await this.readOpenFinToken();
|
|
482
512
|
n !== null && this.adopt(n, "openfin.customData");
|
|
@@ -501,7 +531,7 @@ var ft = class {
|
|
|
501
531
|
getToken() {
|
|
502
532
|
let e = this.journey;
|
|
503
533
|
if (e === null) return;
|
|
504
|
-
let t =
|
|
534
|
+
let t = mt(e);
|
|
505
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 });
|
|
506
536
|
else return t;
|
|
507
537
|
}
|
|
@@ -522,7 +552,7 @@ var ft = class {
|
|
|
522
552
|
this.clearTimer();
|
|
523
553
|
}
|
|
524
554
|
restore(e) {
|
|
525
|
-
let t =
|
|
555
|
+
let t = ft(this.diagnostics.guard("storage.degraded", "The library could not parse the persisted journey.", () => JSON.parse(e)));
|
|
526
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}".`, {
|
|
527
557
|
source: "sessionStorage",
|
|
528
558
|
journeyId: t.id
|
|
@@ -530,22 +560,22 @@ var ft = class {
|
|
|
530
560
|
}
|
|
531
561
|
decodeToken(e) {
|
|
532
562
|
return this.diagnostics.guard("config.invalid", "The library could not decode a seeded journey token.", () => {
|
|
533
|
-
let t = e.replace(ye, "+").replace(
|
|
534
|
-
return
|
|
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)));
|
|
535
565
|
}) ?? null;
|
|
536
566
|
}
|
|
537
567
|
setJourney(e) {
|
|
538
568
|
if (this.journey = e, this.clearTimer(), this.diagnostics.guard("storage.unavailable", "The library could not save the journey.", () => {
|
|
539
|
-
e === null ? this.stores.session().removeItem(
|
|
569
|
+
e === null ? this.stores.session().removeItem(O) : this.stores.session().setItem(O, JSON.stringify(e));
|
|
540
570
|
}), e === null) return;
|
|
541
571
|
let t = Math.max(this.options.maxAgeMs - (Date.now() - e.startedAt), 0), n = setTimeout(() => {
|
|
542
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();
|
|
543
573
|
}, t);
|
|
544
|
-
this.expiryTimer = n,
|
|
574
|
+
this.expiryTimer = n, Ve(n);
|
|
545
575
|
}
|
|
546
576
|
clearStored() {
|
|
547
577
|
this.diagnostics.guard("storage.unavailable", "The library could not clear the persisted journey.", () => {
|
|
548
|
-
this.stores.session().removeItem(
|
|
578
|
+
this.stores.session().removeItem(O);
|
|
549
579
|
});
|
|
550
580
|
}
|
|
551
581
|
clearTimer() {
|
|
@@ -557,16 +587,16 @@ var ft = class {
|
|
|
557
587
|
async readOpenFinToken() {
|
|
558
588
|
let e = globalThis.fin?.me, t = e?.getOptions;
|
|
559
589
|
if (t === void 0) return null;
|
|
560
|
-
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "The library could not read fin.me.getOptions().", () =>
|
|
590
|
+
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "The library could not read fin.me.getOptions().", () => De(t.call(e), Te)))?.customData?.[re];
|
|
561
591
|
return typeof n == "string" ? n : null;
|
|
562
592
|
}
|
|
563
593
|
};
|
|
564
594
|
//#endregion
|
|
565
595
|
//#region src/core/record.ts
|
|
566
|
-
function
|
|
596
|
+
function K(e) {
|
|
567
597
|
return e;
|
|
568
598
|
}
|
|
569
|
-
var
|
|
599
|
+
var gt = class {
|
|
570
600
|
deps;
|
|
571
601
|
resourceCache = null;
|
|
572
602
|
constructor(e) {
|
|
@@ -577,45 +607,47 @@ var pt = class {
|
|
|
577
607
|
}
|
|
578
608
|
isEnabled(e) {
|
|
579
609
|
let { config: t } = this.deps;
|
|
580
|
-
|
|
610
|
+
if (!t.enabled) return !1;
|
|
611
|
+
let n = this.deps.remote.sampling?.minLevel() ?? t.minLevel;
|
|
612
|
+
return b[e] >= b[n];
|
|
581
613
|
}
|
|
582
614
|
build(e) {
|
|
583
|
-
let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o } = this.deps;
|
|
615
|
+
let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o, remote: s } = this.deps;
|
|
584
616
|
if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"), {
|
|
585
617
|
record: null,
|
|
586
618
|
dropped: "level"
|
|
587
619
|
};
|
|
588
|
-
let
|
|
589
|
-
if (!
|
|
620
|
+
let c = r.resolve(), l = i.current();
|
|
621
|
+
if (!Me({
|
|
590
622
|
level: e.level,
|
|
591
623
|
type: e.type,
|
|
592
624
|
namespace: e.namespace,
|
|
593
625
|
journeyId: l?.id ?? "",
|
|
594
|
-
traceId:
|
|
595
|
-
}, t)) return n.count("record.dropped_by_sampling"), {
|
|
626
|
+
traceId: c.traceId
|
|
627
|
+
}, t, s.sampling?.current() ?? null)) return n.count("record.dropped_by_sampling"), {
|
|
596
628
|
record: null,
|
|
597
629
|
dropped: "sampling"
|
|
598
630
|
};
|
|
599
|
-
let u = a.next(), d =
|
|
631
|
+
let u = a.next(), d = Be(n), f = t.capture.fullUrls ? d : ze(d), p, m = 0;
|
|
600
632
|
try {
|
|
601
|
-
let t =
|
|
633
|
+
let t = F(this.deps.context.getAll(), o, n), r = F(e.scoped ?? {}, o, n), i = F(e.payload ?? {}, o, n);
|
|
602
634
|
m = t.bytes + r.bytes + i.bytes, p = {
|
|
603
|
-
...
|
|
604
|
-
...
|
|
605
|
-
...
|
|
635
|
+
...K(t.value),
|
|
636
|
+
...K(r.value),
|
|
637
|
+
...K(i.value)
|
|
606
638
|
};
|
|
607
639
|
} catch (e) {
|
|
608
|
-
n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [
|
|
640
|
+
n.report("record.sanitize_failed", "The library could not sanitize the attributes.", void 0, e), p = { [ae]: !0 };
|
|
609
641
|
}
|
|
610
|
-
p[w] = e.type, p[x] = u, p[T] = e.namespace, p[
|
|
611
|
-
let h =
|
|
642
|
+
p[w] = e.type, p[x] = u, p[T] = e.namespace, p[k] = f, l && (p[y] = l.id, p[E] = l.name, l.parentId !== void 0 && (p[xe] = l.parentId));
|
|
643
|
+
let h = Ie(e.body, o.maxBodyChars);
|
|
612
644
|
h !== e.body && n.count("record.truncated");
|
|
613
645
|
let g = {
|
|
614
|
-
timeUnixNano:
|
|
615
|
-
traceId:
|
|
616
|
-
spanId:
|
|
617
|
-
traceFlags:
|
|
618
|
-
severityNumber:
|
|
646
|
+
timeUnixNano: Ae(),
|
|
647
|
+
traceId: c.traceId,
|
|
648
|
+
spanId: c.spanId,
|
|
649
|
+
traceFlags: c.traceFlags,
|
|
650
|
+
severityNumber: te[e.level],
|
|
619
651
|
severityText: e.level,
|
|
620
652
|
body: h,
|
|
621
653
|
attributes: p,
|
|
@@ -628,11 +660,11 @@ var pt = class {
|
|
|
628
660
|
dropped: "redact"
|
|
629
661
|
};
|
|
630
662
|
if (e !== void 0 && e !== g) {
|
|
631
|
-
if (
|
|
632
|
-
let t =
|
|
663
|
+
if (N(e)) {
|
|
664
|
+
let t = F(e.attributes, o, n);
|
|
633
665
|
g = {
|
|
634
666
|
...e,
|
|
635
|
-
attributes:
|
|
667
|
+
attributes: K(t.value)
|
|
636
668
|
}, m = t.bytes;
|
|
637
669
|
} else n.report("record.sanitize_failed", "The redact hook returned a value that is not a record. The library keeps the original record.");
|
|
638
670
|
}
|
|
@@ -646,39 +678,41 @@ var pt = class {
|
|
|
646
678
|
[w]: e.type,
|
|
647
679
|
[x]: u,
|
|
648
680
|
[T]: e.namespace,
|
|
649
|
-
[
|
|
650
|
-
[
|
|
681
|
+
[k]: f,
|
|
682
|
+
[de]: !0,
|
|
651
683
|
[be]: m
|
|
652
684
|
};
|
|
653
|
-
l && (t[y] = l.id, t[
|
|
685
|
+
l && (t[y] = l.id, t[E] = l.name), g.attributes = t;
|
|
654
686
|
}
|
|
655
687
|
return { record: g };
|
|
656
688
|
}
|
|
657
689
|
resource() {
|
|
658
690
|
if (this.resourceCache) return this.resourceCache;
|
|
659
|
-
let { config:
|
|
691
|
+
let { config: n, identity: r, platform: i } = this.deps;
|
|
660
692
|
return this.resourceCache = {
|
|
661
|
-
[
|
|
662
|
-
[
|
|
663
|
-
[
|
|
664
|
-
[
|
|
665
|
-
[
|
|
666
|
-
[
|
|
667
|
-
[
|
|
668
|
-
[
|
|
669
|
-
[
|
|
670
|
-
[
|
|
671
|
-
[
|
|
672
|
-
...
|
|
673
|
-
...
|
|
693
|
+
[g]: n.serviceName,
|
|
694
|
+
[s]: n.serviceVersion,
|
|
695
|
+
[e]: n.environment,
|
|
696
|
+
[Ee]: he,
|
|
697
|
+
[t]: we,
|
|
698
|
+
[_]: ie,
|
|
699
|
+
[pe]: i.platform,
|
|
700
|
+
[l]: r.sessionId,
|
|
701
|
+
[u]: r.tabId,
|
|
702
|
+
[me]: r.contextId,
|
|
703
|
+
[h]: i.userAgent,
|
|
704
|
+
...i.openfinUuid === void 0 ? {} : { [m]: i.openfinUuid },
|
|
705
|
+
...i.openfinName === void 0 ? {} : { [f]: i.openfinName }
|
|
674
706
|
}, this.resourceCache;
|
|
675
707
|
}
|
|
676
|
-
},
|
|
677
|
-
errors: async () => (await import("./errors-
|
|
678
|
-
network: async () => (await import("./network-
|
|
679
|
-
interactions: async () => (await import("./interactions-
|
|
680
|
-
webVitals: async () => (await import("./web-vitals-DHZ0yA_H.js")).WebVitalsCapture
|
|
681
|
-
|
|
708
|
+
}, _t = {
|
|
709
|
+
errors: async () => (await import("./errors-Dnc-X4Ec.js")).ErrorCapture,
|
|
710
|
+
network: async () => (await import("./network-aSNbwpue.js")).NetworkCapture,
|
|
711
|
+
interactions: async () => (await import("./interactions-igKTAJvj.js")).InteractionCapture,
|
|
712
|
+
webVitals: async () => (await import("./web-vitals-DHZ0yA_H.js")).WebVitalsCapture,
|
|
713
|
+
longFrames: async () => (await import("./long-frames-6pnjWSSR.js")).LongFrameCapture,
|
|
714
|
+
console: async () => (await import("./console-CNljJict.js")).ConsoleCapture
|
|
715
|
+
}, q = Symbol.for(ee), J = Symbol.for(c), Y = class e {
|
|
682
716
|
diagnostics;
|
|
683
717
|
config;
|
|
684
718
|
platform;
|
|
@@ -686,12 +720,13 @@ var pt = class {
|
|
|
686
720
|
stores;
|
|
687
721
|
identityBuiltAs;
|
|
688
722
|
sessionTouch;
|
|
689
|
-
context = new
|
|
723
|
+
context = new lt();
|
|
690
724
|
breadcrumbs;
|
|
691
725
|
tracing;
|
|
692
|
-
sequence = new
|
|
726
|
+
sequence = new Je();
|
|
693
727
|
journey;
|
|
694
728
|
builder;
|
|
729
|
+
remote = { sampling: null };
|
|
695
730
|
console;
|
|
696
731
|
bus = null;
|
|
697
732
|
busBuilt;
|
|
@@ -704,21 +739,24 @@ var pt = class {
|
|
|
704
739
|
captureGeneration = 0;
|
|
705
740
|
captureOnce = {
|
|
706
741
|
webVitals: !1,
|
|
707
|
-
navigationTiming: !1
|
|
742
|
+
navigationTiming: !1,
|
|
743
|
+
longFrames: !1
|
|
708
744
|
};
|
|
709
745
|
bootBuffer = [];
|
|
710
746
|
forwardBuffer = [];
|
|
711
747
|
forwardScheduled = !1;
|
|
712
748
|
roleResolved = !1;
|
|
749
|
+
started = Promise.resolve();
|
|
713
750
|
ready = !1;
|
|
714
751
|
destroyed = !1;
|
|
715
752
|
lastGapAt = 0;
|
|
716
753
|
constructor(e) {
|
|
717
|
-
this.diagnostics = new
|
|
754
|
+
this.diagnostics = new ut(e.onDiagnostic), this.platform = Re(this.diagnostics), this.config = U(e, this.diagnostics), this.identityBuiltAs = this.config.identity, this.stores = this.identityBuiltAs === "memory" ? Oe() : M, this.identity = ke(this.diagnostics, this.stores), this.sessionTouch = new Ne(this.diagnostics, this.stores), this.breadcrumbs = new tt(50), this.tracing = new et(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new qe(this.config.console, this.diagnostics), this.journey = new ht(dt, this.diagnostics, this.identity.contextId, (e) => {
|
|
718
755
|
this.bus?.broadcastJourney(e);
|
|
719
|
-
}, this.stores), this.builder = new
|
|
756
|
+
}, this.stores), this.builder = new gt({
|
|
757
|
+
remote: this.remote,
|
|
720
758
|
config: this.config,
|
|
721
|
-
limits:
|
|
759
|
+
limits: r,
|
|
722
760
|
diagnostics: this.diagnostics,
|
|
723
761
|
context: this.context,
|
|
724
762
|
journey: this.journey,
|
|
@@ -736,10 +774,10 @@ var pt = class {
|
|
|
736
774
|
});
|
|
737
775
|
};
|
|
738
776
|
static current() {
|
|
739
|
-
return globalThis[
|
|
777
|
+
return globalThis[q] ?? null;
|
|
740
778
|
}
|
|
741
779
|
static stopped() {
|
|
742
|
-
return globalThis[
|
|
780
|
+
return globalThis[J] ?? null;
|
|
743
781
|
}
|
|
744
782
|
isDestroyed() {
|
|
745
783
|
return this.destroyed;
|
|
@@ -748,21 +786,23 @@ var pt = class {
|
|
|
748
786
|
let n = e.current();
|
|
749
787
|
if (n && !n.destroyed) return n.reconfigure(t), n;
|
|
750
788
|
let r = new e(t);
|
|
751
|
-
return globalThis[
|
|
789
|
+
return globalThis[q] = r, Reflect.deleteProperty(globalThis, J), r.init(), r;
|
|
752
790
|
}
|
|
753
791
|
reconfigure(e) {
|
|
754
|
-
let t = this.
|
|
755
|
-
|
|
792
|
+
let t = this.keepDestination(e);
|
|
793
|
+
ct(this.config, U(t, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.keepBuiltIdentity(), this.installCaptures(), this.roleResolved && this.syncSender(), this.diagnostics.report("config.reconfigured", "A later configure() call updated the runtime.");
|
|
756
794
|
}
|
|
757
795
|
keepBuiltStorage() {
|
|
758
796
|
let e = this.storageBuiltAs;
|
|
759
797
|
e !== void 0 && this.config.storage !== e && (this.diagnostics.report("config.invalid", `storage cannot change after startup. It stays ${e}.`, { requested: this.config.storage }), this.config.storage = e);
|
|
760
798
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
799
|
+
keepDestination(e) {
|
|
800
|
+
if (this.senderLoad === void 0) return e;
|
|
801
|
+
let t = e;
|
|
802
|
+
return "transport" in e && e.transport === void 0 != (this.config.transport === void 0) && (this.diagnostics.report("config.invalid", "You cannot add or remove transport after the delivery stack loads. The transport in force stays."), t = { ...t }, delete t.transport), (t.endpoint === null || t.endpoint === "") && this.config.transport === void 0 && (this.diagnostics.report("config.invalid", "You cannot remove the endpoint after the delivery stack loads. The endpoint in force stays."), t = {
|
|
803
|
+
...t,
|
|
764
804
|
endpoint: void 0
|
|
765
|
-
});
|
|
805
|
+
}), t;
|
|
766
806
|
}
|
|
767
807
|
keepBuiltIdentity() {
|
|
768
808
|
let e = this.identityBuiltAs;
|
|
@@ -770,6 +810,9 @@ var pt = class {
|
|
|
770
810
|
}
|
|
771
811
|
async init() {
|
|
772
812
|
let e = this.installCaptures();
|
|
813
|
+
this.started = this.boot(), await this.started, await e;
|
|
814
|
+
}
|
|
815
|
+
async boot() {
|
|
773
816
|
try {
|
|
774
817
|
let e = this.journey.bootstrap();
|
|
775
818
|
this.config.bus.mode !== "off" && await this.ensureBus(), this.roleResolved = !0, await this.syncSender(), await e;
|
|
@@ -778,7 +821,6 @@ var pt = class {
|
|
|
778
821
|
} finally {
|
|
779
822
|
this.ready = !0, this.releaseBootBuffer();
|
|
780
823
|
}
|
|
781
|
-
await e;
|
|
782
824
|
}
|
|
783
825
|
ensureBus() {
|
|
784
826
|
return this.busLoad ??= this.startBus(), this.busLoad;
|
|
@@ -797,7 +839,7 @@ var pt = class {
|
|
|
797
839
|
}
|
|
798
840
|
async buildBus() {
|
|
799
841
|
try {
|
|
800
|
-
let { Bus: e } = await import("./bus-
|
|
842
|
+
let { Bus: e } = await import("./bus-DPDrlUBY.js");
|
|
801
843
|
if (this.destroyed) return null;
|
|
802
844
|
let t = new e(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
|
|
803
845
|
onRecords: (e) => {
|
|
@@ -809,7 +851,8 @@ var pt = class {
|
|
|
809
851
|
onJourneyRequest: () => this.journey.current(),
|
|
810
852
|
onTabConflict: () => {
|
|
811
853
|
this.regenerateTabId();
|
|
812
|
-
}
|
|
854
|
+
},
|
|
855
|
+
remote: this.remote
|
|
813
856
|
});
|
|
814
857
|
return this.bus = t, t;
|
|
815
858
|
} catch (e) {
|
|
@@ -820,7 +863,7 @@ var pt = class {
|
|
|
820
863
|
return this.bus?.getRole() ?? "sender";
|
|
821
864
|
}
|
|
822
865
|
syncSender() {
|
|
823
|
-
return !this.config.endpoint || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
|
|
866
|
+
return !(this.config.endpoint || this.config.transport !== void 0) || this.role() !== "sender" ? Promise.resolve() : this.loadSender();
|
|
824
867
|
}
|
|
825
868
|
loadSender() {
|
|
826
869
|
return this.senderLoad ??= this.buildSender(), this.senderLoad;
|
|
@@ -828,10 +871,11 @@ var pt = class {
|
|
|
828
871
|
async buildSender() {
|
|
829
872
|
this.storageBuiltAs = this.config.storage;
|
|
830
873
|
try {
|
|
831
|
-
let { Sender: e } = await import("./sender-
|
|
874
|
+
let { Sender: e } = await import("./sender-G6v4Uqi4.js"), t = this.destroyed ? null : await e.create({
|
|
832
875
|
config: this.config,
|
|
833
876
|
diagnostics: this.diagnostics,
|
|
834
|
-
onGap: this.reportGap
|
|
877
|
+
onGap: this.reportGap,
|
|
878
|
+
remote: this.remote
|
|
835
879
|
});
|
|
836
880
|
if (!t || this.destroyed) {
|
|
837
881
|
await t?.destroy();
|
|
@@ -846,8 +890,8 @@ var pt = class {
|
|
|
846
890
|
for (let t of e) this.sender?.push(t);
|
|
847
891
|
}
|
|
848
892
|
async installCaptures() {
|
|
849
|
-
let e = ++this.captureGeneration,
|
|
850
|
-
(
|
|
893
|
+
let e = ++this.captureGeneration, t = this.config.capture, r = [];
|
|
894
|
+
(t.errors || t.rejections || t.resourceErrors) && r.push("errors"), (t.fetch || t.xhr) && r.push("network"), (t.interactions || t.navigation) && r.push("interactions"), t.webVitals && r.push("webVitals"), t.longFrames && r.push("longFrames"), (Array.isArray(t.console) ? t.console.length > 0 : t.console) && r.push("console");
|
|
851
895
|
let i = await Promise.all(r.map((e) => this.loadCapture(e)));
|
|
852
896
|
if (e !== this.captureGeneration || this.destroyed) return;
|
|
853
897
|
this.uninstallCaptures();
|
|
@@ -856,7 +900,7 @@ var pt = class {
|
|
|
856
900
|
diagnostics: this.diagnostics,
|
|
857
901
|
breadcrumbs: this.breadcrumbs,
|
|
858
902
|
tracing: this.tracing,
|
|
859
|
-
logger: new
|
|
903
|
+
logger: new z(() => this, n),
|
|
860
904
|
once: this.captureOnce
|
|
861
905
|
};
|
|
862
906
|
for (let e of i) e && this.captures.push(new e(a));
|
|
@@ -871,7 +915,7 @@ var pt = class {
|
|
|
871
915
|
this.captures.length = 0;
|
|
872
916
|
}
|
|
873
917
|
loadCapture(e) {
|
|
874
|
-
return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`,
|
|
918
|
+
return this.diagnostics.guardAsync("capture.install_failed", `The library could not load the ${e} capture.`, _t[e]);
|
|
875
919
|
}
|
|
876
920
|
registerWorker(e) {
|
|
877
921
|
this.destroyed || this.constructBus().then((t) => {
|
|
@@ -884,7 +928,7 @@ var pt = class {
|
|
|
884
928
|
if (this.destroyed) return;
|
|
885
929
|
this.destroyed = !0, this.uninstallCaptures();
|
|
886
930
|
let t = this.sender?.destroy();
|
|
887
|
-
this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.current() === this && (Reflect.deleteProperty(globalThis,
|
|
931
|
+
this.journey.destroy(), this.bus?.destroy(), this.forwardBuffer = [], this.pendingRecords = [], await t, await this.senderLoad, e.current() === this && (Reflect.deleteProperty(globalThis, q), globalThis[J] = this);
|
|
888
932
|
}
|
|
889
933
|
emit(e) {
|
|
890
934
|
e && !this.destroyed && (this.sessionTouch.touch(this.identity.sessionId), this.ready ? this.route(e) : this.pushCapped(this.bootBuffer, e));
|
|
@@ -907,7 +951,7 @@ var pt = class {
|
|
|
907
951
|
}
|
|
908
952
|
ingestForwarded(e) {
|
|
909
953
|
if (!Array.isArray(e)) this.diagnostics.count("record.dropped_malformed");
|
|
910
|
-
else for (let t of e)
|
|
954
|
+
else for (let t of e) N(t) ? je(t, this.config, this.remote.sampling?.current() ?? null) ? this.deliver(t) : this.diagnostics.count("record.dropped_by_sampling") : this.diagnostics.count("record.dropped_malformed");
|
|
911
955
|
}
|
|
912
956
|
releaseBootBuffer() {
|
|
913
957
|
let e = this.bootBuffer;
|
|
@@ -917,7 +961,7 @@ var pt = class {
|
|
|
917
961
|
}
|
|
918
962
|
reportGap = (e) => {
|
|
919
963
|
let t = Date.now();
|
|
920
|
-
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new
|
|
964
|
+
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new z(() => this, Ce).warn("stored records were dropped before delivery", {
|
|
921
965
|
"gap.batches": e.batches,
|
|
922
966
|
"gap.records": e.records,
|
|
923
967
|
"gap.reason": e.reason
|
|
@@ -928,108 +972,130 @@ var pt = class {
|
|
|
928
972
|
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.", {
|
|
929
973
|
was: this.identity.tabId,
|
|
930
974
|
now: e
|
|
931
|
-
}), this.identity.tabId = e,
|
|
975
|
+
}), this.identity.tabId = e, Pe(e, this.diagnostics, this.stores), this.builder.invalidateResource();
|
|
932
976
|
}
|
|
933
977
|
async queueDepth() {
|
|
934
978
|
return await this.senderLoad, await this.sender?.queueDepth() ?? 0;
|
|
935
979
|
}
|
|
936
980
|
async flush() {
|
|
937
|
-
if (this.role() === "forwarder") {
|
|
981
|
+
if (this.ready || await this.started, this.role() === "forwarder") {
|
|
938
982
|
let e = this.forwardBuffer;
|
|
939
983
|
this.forwardBuffer = [], e.length > 0 && this.bus?.sendRecords(e);
|
|
940
984
|
} else await this.senderLoad, await this.sender?.flush();
|
|
941
985
|
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
|
|
986
|
+
};
|
|
987
|
+
//#endregion
|
|
988
|
+
//#region src/transport/memory-transport.ts
|
|
989
|
+
function vt() {
|
|
990
|
+
let e = [], t = [], n = { status: 200 };
|
|
991
|
+
return {
|
|
992
|
+
transport: (r) => (e.push(r), n.status >= 200 && n.status < 300 && t.push(r), Promise.resolve({ ...n })),
|
|
993
|
+
records: () => t.flatMap((e) => [...e.records]),
|
|
994
|
+
batches: () => [...e],
|
|
995
|
+
clear: () => {
|
|
996
|
+
e.length = 0, t.length = 0;
|
|
997
|
+
},
|
|
998
|
+
respondWith: (e, t) => {
|
|
999
|
+
n = t === void 0 ? { status: e } : {
|
|
1000
|
+
status: e,
|
|
1001
|
+
retryAfterMs: t
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
956
1005
|
}
|
|
957
|
-
|
|
958
|
-
|
|
1006
|
+
//#endregion
|
|
1007
|
+
//#region src/index.ts
|
|
1008
|
+
var X = /* @__PURE__ */ new Map();
|
|
1009
|
+
function Z() {
|
|
1010
|
+
return (Y.current() ?? Y.stopped()) || Y.configure({});
|
|
959
1011
|
}
|
|
960
|
-
function
|
|
961
|
-
|
|
1012
|
+
function yt(e) {
|
|
1013
|
+
Y.configure(e);
|
|
962
1014
|
}
|
|
963
|
-
function
|
|
964
|
-
|
|
1015
|
+
function Q(e, t) {
|
|
1016
|
+
if (t) return new z(Z, e, t);
|
|
1017
|
+
let n = X.get(e);
|
|
1018
|
+
return n || (n = new z(Z, e), X.set(e, n)), n;
|
|
965
1019
|
}
|
|
966
|
-
function
|
|
967
|
-
Q()
|
|
1020
|
+
function $() {
|
|
1021
|
+
return Q("app");
|
|
968
1022
|
}
|
|
969
|
-
function bt(e, t
|
|
970
|
-
|
|
1023
|
+
function bt(e, t) {
|
|
1024
|
+
$().trace(e, t);
|
|
971
1025
|
}
|
|
972
1026
|
function xt(e, t) {
|
|
973
|
-
|
|
1027
|
+
$().debug(e, t);
|
|
974
1028
|
}
|
|
975
1029
|
function St(e, t) {
|
|
976
|
-
|
|
1030
|
+
$().info(e, t);
|
|
977
1031
|
}
|
|
978
|
-
function Ct(e, t
|
|
979
|
-
|
|
1032
|
+
function Ct(e, t) {
|
|
1033
|
+
$().warn(e, t);
|
|
980
1034
|
}
|
|
981
1035
|
function wt(e, t, n) {
|
|
982
|
-
|
|
1036
|
+
$().error(e, t, n);
|
|
983
1037
|
}
|
|
984
|
-
function Tt(e, t
|
|
985
|
-
|
|
1038
|
+
function Tt(e, t) {
|
|
1039
|
+
$().logAction(e, t);
|
|
986
1040
|
}
|
|
987
1041
|
function Et(e, t) {
|
|
988
|
-
|
|
1042
|
+
$().logEvent(e, t);
|
|
989
1043
|
}
|
|
990
|
-
function
|
|
991
|
-
|
|
1044
|
+
function Dt(e, t, n, r, i) {
|
|
1045
|
+
$().logMetric(e, t, n, r, i);
|
|
992
1046
|
}
|
|
993
|
-
function
|
|
994
|
-
|
|
1047
|
+
function Ot(e, t, n) {
|
|
1048
|
+
return $().timeSync(e, t, n);
|
|
995
1049
|
}
|
|
996
|
-
function
|
|
997
|
-
return
|
|
1050
|
+
function kt(e, t, n) {
|
|
1051
|
+
return $().timeAsync(e, t, n);
|
|
998
1052
|
}
|
|
999
|
-
function
|
|
1000
|
-
|
|
1053
|
+
function At(e, t) {
|
|
1054
|
+
Z().context.set(e, t);
|
|
1001
1055
|
}
|
|
1002
|
-
function
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
function jt() {
|
|
1006
|
-
return X().journey.getToken();
|
|
1056
|
+
function jt(e) {
|
|
1057
|
+
Z().context.setMany(e);
|
|
1007
1058
|
}
|
|
1008
1059
|
function Mt(e) {
|
|
1009
|
-
|
|
1060
|
+
Z().context.remove(e);
|
|
1010
1061
|
}
|
|
1011
|
-
function Nt(e) {
|
|
1012
|
-
|
|
1062
|
+
function Nt(e, t) {
|
|
1063
|
+
return Z().journey.start(e, t);
|
|
1013
1064
|
}
|
|
1014
1065
|
function Pt() {
|
|
1015
|
-
|
|
1066
|
+
Z().journey.end();
|
|
1016
1067
|
}
|
|
1017
1068
|
function Ft() {
|
|
1018
|
-
return
|
|
1069
|
+
return Z().journey.current();
|
|
1019
1070
|
}
|
|
1020
1071
|
function It() {
|
|
1021
|
-
return
|
|
1072
|
+
return Z().journey.getToken();
|
|
1073
|
+
}
|
|
1074
|
+
function Lt(e) {
|
|
1075
|
+
return Z().journey.adopt(e, "manual", !0);
|
|
1076
|
+
}
|
|
1077
|
+
function Rt(e) {
|
|
1078
|
+
Z().registerWorker(e);
|
|
1079
|
+
}
|
|
1080
|
+
function zt() {
|
|
1081
|
+
Z().tracing.rotate("explicit");
|
|
1082
|
+
}
|
|
1083
|
+
function Bt() {
|
|
1084
|
+
return Z().tracing.headers();
|
|
1085
|
+
}
|
|
1086
|
+
function Vt() {
|
|
1087
|
+
return Z().flush();
|
|
1022
1088
|
}
|
|
1023
|
-
function
|
|
1024
|
-
return
|
|
1089
|
+
function Ht() {
|
|
1090
|
+
return Z().queueDepth();
|
|
1025
1091
|
}
|
|
1026
|
-
function
|
|
1027
|
-
return
|
|
1092
|
+
function Ut() {
|
|
1093
|
+
return Z().diagnostics.snapshot();
|
|
1028
1094
|
}
|
|
1029
|
-
async function
|
|
1030
|
-
await
|
|
1095
|
+
async function Wt() {
|
|
1096
|
+
await Y.current()?.destroy();
|
|
1031
1097
|
}
|
|
1032
1098
|
//#endregion
|
|
1033
|
-
export {
|
|
1099
|
+
export { z as OneLogger, Lt as adoptJourney, yt as configure, vt as createMemoryTransport, Ft as currentJourney, xt as debug, Pt as endJourney, wt as error, Vt as flush, Ut as getDiagnosticCounters, It as getJourneyToken, Q as getLogger, Ht as getQueueDepth, Bt as getTraceHeaders, St as info, Tt as logAction, Et as logEvent, Dt as logMetric, Rt as registerWorker, Mt as removeContext, At as setContext, jt as setContextMap, Wt as shutdown, Nt as startJourney, zt as startTrace, kt as timeAsync, Ot as timeSync, bt as trace, Ct as warn };
|
|
1034
1100
|
|
|
1035
1101
|
//# sourceMappingURL=index.js.map
|