@utk09/ui-observability 0.3.0 → 0.4.1
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 +66 -23
- package/README.md +86 -86
- package/dist/bus/bus.d.ts +9 -0
- package/dist/bus/links.d.ts +5 -4
- package/dist/capture/types.d.ts +14 -0
- package/dist/capture/web-vitals.d.ts +5 -2
- package/dist/constants-DVbpJ1tv.js +74 -0
- package/dist/constants-DVbpJ1tv.js.map +1 -0
- package/dist/constants-tQpoTzkY.cjs +2 -0
- package/dist/constants-tQpoTzkY.cjs.map +1 -0
- package/dist/constants.d.ts +18 -1
- package/dist/core/logger.d.ts +7 -5
- package/dist/core/pipeline.d.ts +10 -1
- package/dist/core/record.d.ts +11 -2
- package/dist/core/runtime.d.ts +12 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +675 -540
- package/dist/index.js.map +1 -1
- package/dist/{indexeddb-storage-bibcl7ZS.js → indexeddb-storage-B6uqejZb.js} +32 -11
- package/dist/indexeddb-storage-B6uqejZb.js.map +1 -0
- package/dist/indexeddb-storage-CgT1GLYj.cjs +2 -0
- package/dist/indexeddb-storage-CgT1GLYj.cjs.map +1 -0
- package/dist/storage/idb-driver.d.ts +9 -1
- package/dist/storage/indexeddb-storage.d.ts +5 -0
- package/dist/storage/local-storage.d.ts +14 -0
- package/dist/transport/exit-flush.d.ts +11 -1
- package/dist/transport/retry-engine.d.ts +28 -3
- package/dist/utils/console.d.ts +4 -1
- package/dist/utils/deadline.d.ts +7 -0
- package/dist/utils/identity.d.ts +17 -6
- package/dist/utils/sanitize.d.ts +2 -0
- package/package.json +5 -5
- package/dist/constants-BmO0GRWM.cjs +0 -2
- package/dist/constants-BmO0GRWM.cjs.map +0 -1
- package/dist/constants-CQr0wwbQ.js +0 -69
- package/dist/constants-CQr0wwbQ.js.map +0 -1
- package/dist/indexeddb-storage-DeEh8Ag-.cjs +0 -2
- package/dist/indexeddb-storage-DeEh8Ag-.cjs.map +0 -1
- package/dist/indexeddb-storage-bibcl7ZS.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
|
-
import { $ as e,
|
|
1
|
+
import { $t as e, A as t, At as n, Bt as r, C as i, Ct as a, D as o, Dt as s, E as c, Et as l, F as u, Ft as d, G as f, Gt as p, H as m, Ht as h, I as g, It as _, J as ee, Jt as te, K as ne, Kt as v, Lt as re, M as ie, Mt as ae, N as oe, Nt as se, O as ce, Ot as le, Pt as ue, Qt as de, R as y, Rt as fe, S as pe, St as me, T as b, Tt as he, U as ge, V as _e, Wt as ve, Xt as ye, Y as be, Zt as xe, _ as Se, _t as Ce, a as we, an as Te, at as Ee, b as De, bt as Oe, c as ke, cn as Ae, ct as je, d as Me, dt as Ne, en as Pe, et as Fe, ft as Ie, g as Le, gt as Re, h as ze, ht as Be, i as Ve, in as He, it as x, j as Ue, jt as We, k as Ge, kt as Ke, l as S, ln as qe, lt as Je, m as Ye, mt as Xe, n as C, nn as Ze, nt as w, o as Qe, on as $e, ot as et, p as tt, pt as nt, q as rt, qt as it, r as at, rn as ot, rt as st, s as ct, sn as lt, st as ut, t as dt, tn as ft, tt as pt, u as mt, ut as ht, v as T, vt as gt, wt as _t, x as vt, xt as yt, z as bt } from "./constants-DVbpJ1tv.js";
|
|
2
2
|
//#region src/utils/timer.ts
|
|
3
|
-
function
|
|
4
|
-
return Math.round((performance.now() - e) *
|
|
3
|
+
function xt(e) {
|
|
4
|
+
return Math.round((performance.now() - e) * u) / u;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
e.logMetric(`${t}.duration`,
|
|
6
|
+
function St(e, t, n, r, i) {
|
|
7
|
+
e.logMetric(`${t}.duration`, xt(n), "ms", "histogram", {
|
|
8
8
|
status: r,
|
|
9
9
|
...i
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function Ct(e, t, n, r, i) {
|
|
13
13
|
e.error(`${t} failed`, r, {
|
|
14
|
-
"action.duration_ms":
|
|
14
|
+
"action.duration_ms": xt(n),
|
|
15
15
|
status: "FAILURE",
|
|
16
16
|
...i
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function wt(e, t, n, r) {
|
|
20
20
|
let i = performance.now();
|
|
21
21
|
try {
|
|
22
22
|
let a = n();
|
|
23
|
-
return
|
|
23
|
+
return St(e, t, i, "SUCCESS", r), a;
|
|
24
24
|
} catch (n) {
|
|
25
|
-
throw
|
|
25
|
+
throw Ct(e, t, i, n, r), n;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function Tt(e, t, n, r) {
|
|
29
29
|
let i = performance.now();
|
|
30
30
|
try {
|
|
31
31
|
let a = await n();
|
|
32
|
-
return
|
|
32
|
+
return St(e, t, i, "SUCCESS", r), a;
|
|
33
33
|
} catch (n) {
|
|
34
|
-
throw
|
|
34
|
+
throw Ct(e, t, i, n, r), n;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/core/logger.ts
|
|
39
|
-
function
|
|
40
|
-
|
|
39
|
+
function Et(e, t) {
|
|
40
|
+
if (e instanceof Error) return e;
|
|
41
|
+
let n = t.guard("record.sanitize_failed", "describing an error reason", () => String(e));
|
|
42
|
+
return Error(n ?? typeof e);
|
|
43
|
+
}
|
|
44
|
+
function Dt(e) {
|
|
45
|
+
if (typeof e != "object" || !e || Array.isArray(e) || e instanceof Error) return !1;
|
|
46
|
+
let t = Object.getPrototypeOf(e);
|
|
47
|
+
return t === null || Object.getPrototypeOf(t) === null;
|
|
41
48
|
}
|
|
42
|
-
var
|
|
49
|
+
var E = class e {
|
|
43
50
|
runtime;
|
|
44
51
|
namespace;
|
|
45
52
|
options;
|
|
@@ -76,7 +83,7 @@ var w = class e {
|
|
|
76
83
|
logEvent = (e, t) => {
|
|
77
84
|
this.write("INFO", "event", e, t);
|
|
78
85
|
};
|
|
79
|
-
logMetric = (e, t, n =
|
|
86
|
+
logMetric = (e, t, n = ie, r = "gauge", i) => {
|
|
80
87
|
this.write("INFO", "metric", e, {
|
|
81
88
|
"metric.name": e,
|
|
82
89
|
"metric.value": t,
|
|
@@ -85,11 +92,11 @@ var w = class e {
|
|
|
85
92
|
...i
|
|
86
93
|
});
|
|
87
94
|
};
|
|
88
|
-
timeSync = (e, t, n) =>
|
|
89
|
-
timeAsync = (e, t, n) =>
|
|
95
|
+
timeSync = (e, t, n) => wt(this, e, t, n);
|
|
96
|
+
timeAsync = (e, t, n) => Tt(this, e, t, n);
|
|
90
97
|
write(e, t, n, r) {
|
|
91
98
|
if (!this.runtime.builder.isEnabled(e)) return;
|
|
92
|
-
let i = this.runtime.builder.build({
|
|
99
|
+
let { record: i, dropped: a } = this.runtime.builder.build({
|
|
93
100
|
level: e,
|
|
94
101
|
type: t,
|
|
95
102
|
body: n,
|
|
@@ -97,7 +104,7 @@ var w = class e {
|
|
|
97
104
|
scoped: this.options.scopedContext,
|
|
98
105
|
payload: r
|
|
99
106
|
});
|
|
100
|
-
|
|
107
|
+
t !== "metric" && a !== "redact" && this.runtime.breadcrumbs.push({
|
|
101
108
|
t: Date.now(),
|
|
102
109
|
category: t === "action" ? "action" : t === "event" ? "event" : "log",
|
|
103
110
|
message: n
|
|
@@ -105,39 +112,39 @@ var w = class e {
|
|
|
105
112
|
}
|
|
106
113
|
writeError(e, t, n, r) {
|
|
107
114
|
if (!this.runtime.builder.isEnabled(e)) return;
|
|
108
|
-
let i = n === void 0 ? void 0 :
|
|
115
|
+
let i = r === void 0 && Dt(n), a = i ? n : r, o = i || n === void 0 ? void 0 : Et(n, this.runtime.diagnostics), { record: s } = this.runtime.builder.build({
|
|
109
116
|
level: e,
|
|
110
117
|
type: "system",
|
|
111
118
|
body: t,
|
|
112
119
|
namespace: this.namespace,
|
|
113
120
|
scoped: this.options.scopedContext,
|
|
114
121
|
payload: {
|
|
115
|
-
...
|
|
116
|
-
...
|
|
117
|
-
"error.type":
|
|
118
|
-
"error.message":
|
|
119
|
-
"error.stack_trace":
|
|
122
|
+
...a,
|
|
123
|
+
...o ? {
|
|
124
|
+
"error.type": o.name,
|
|
125
|
+
"error.message": o.message,
|
|
126
|
+
"error.stack_trace": o.stack
|
|
120
127
|
} : {},
|
|
121
128
|
breadcrumbs: this.runtime.breadcrumbs.snapshot()
|
|
122
129
|
}
|
|
123
130
|
});
|
|
124
|
-
this.runtime.console.write(e, t,
|
|
131
|
+
this.runtime.console.write(e, t, o ?? s?.attributes), this.runtime.emit(s);
|
|
125
132
|
}
|
|
126
133
|
};
|
|
127
134
|
//#endregion
|
|
128
135
|
//#region src/utils/unref.ts
|
|
129
|
-
function
|
|
136
|
+
function D(e) {
|
|
130
137
|
typeof e != "number" && e.unref?.();
|
|
131
138
|
}
|
|
132
139
|
//#endregion
|
|
133
140
|
//#region src/models/bus.ts
|
|
134
|
-
function
|
|
141
|
+
function O(e) {
|
|
135
142
|
return {
|
|
136
|
-
p:
|
|
143
|
+
p: pe,
|
|
137
144
|
m: e
|
|
138
145
|
};
|
|
139
146
|
}
|
|
140
|
-
function
|
|
147
|
+
function k(e) {
|
|
141
148
|
if (typeof e != "object" || !e) return null;
|
|
142
149
|
let t = e;
|
|
143
150
|
if (t.p !== "ui-observability/1" || typeof t.m != "object" || t.m === null) return null;
|
|
@@ -146,12 +153,12 @@ function D(e) {
|
|
|
146
153
|
}
|
|
147
154
|
//#endregion
|
|
148
155
|
//#region src/bus/links.ts
|
|
149
|
-
var
|
|
150
|
-
function
|
|
156
|
+
var Ot = Symbol.for(fe);
|
|
157
|
+
function kt(e, t) {
|
|
151
158
|
if (typeof window > "u" || window.parent === window) return null;
|
|
152
159
|
let n;
|
|
153
160
|
try {
|
|
154
|
-
n = window.parent[
|
|
161
|
+
n = window.parent[Ot];
|
|
155
162
|
} catch {
|
|
156
163
|
return null;
|
|
157
164
|
}
|
|
@@ -169,10 +176,10 @@ function Dt(e, t) {
|
|
|
169
176
|
}
|
|
170
177
|
};
|
|
171
178
|
}
|
|
172
|
-
function
|
|
179
|
+
function At(e, t) {
|
|
173
180
|
if (typeof window > "u" || window.parent === window) return null;
|
|
174
181
|
let n = (t) => {
|
|
175
|
-
let n =
|
|
182
|
+
let n = k(t.data);
|
|
176
183
|
n && t.source === window.parent && e(n, {
|
|
177
184
|
link: "parent",
|
|
178
185
|
origin: t.origin
|
|
@@ -182,7 +189,7 @@ function Ot(e, t) {
|
|
|
182
189
|
kind: "parent",
|
|
183
190
|
post(e) {
|
|
184
191
|
t.guard("bus.send_failed", "postMessage to parent", () => {
|
|
185
|
-
window.parent.postMessage(
|
|
192
|
+
window.parent.postMessage(O(e), "*");
|
|
186
193
|
});
|
|
187
194
|
},
|
|
188
195
|
close() {
|
|
@@ -190,10 +197,10 @@ function Ot(e, t) {
|
|
|
190
197
|
}
|
|
191
198
|
};
|
|
192
199
|
}
|
|
193
|
-
function
|
|
200
|
+
function jt(e, t, n) {
|
|
194
201
|
if (typeof window > "u") return null;
|
|
195
202
|
let r = /* @__PURE__ */ new Set([window.location.origin, ...t]), i = /* @__PURE__ */ new Map(), a = (t) => {
|
|
196
|
-
let a =
|
|
203
|
+
let a = k(t.data);
|
|
197
204
|
if (a) {
|
|
198
205
|
if (!r.has(t.origin)) {
|
|
199
206
|
n.report("bus.untrusted_origin", `ignored a bus message from ${t.origin}. Add it to bus.trustedOrigins if it is yours.`, {
|
|
@@ -218,7 +225,7 @@ function kt(e, t, n) {
|
|
|
218
225
|
continue;
|
|
219
226
|
}
|
|
220
227
|
n.guard("bus.send_failed", "postMessage to child", () => {
|
|
221
|
-
a.postMessage(
|
|
228
|
+
a.postMessage(O(e), r);
|
|
222
229
|
});
|
|
223
230
|
}
|
|
224
231
|
},
|
|
@@ -227,12 +234,12 @@ function kt(e, t, n) {
|
|
|
227
234
|
}
|
|
228
235
|
};
|
|
229
236
|
}
|
|
230
|
-
function
|
|
237
|
+
function Mt(e, t, n) {
|
|
231
238
|
let r = globalThis.BroadcastChannel;
|
|
232
239
|
if (r === void 0) return null;
|
|
233
240
|
let i = n.guard("bus.send_failed", "opening BroadcastChannel", () => new r(e));
|
|
234
241
|
return i ? (i.onmessage = (e) => {
|
|
235
|
-
let n =
|
|
242
|
+
let n = k(e.data);
|
|
236
243
|
n && t(n, {
|
|
237
244
|
link: "broadcast",
|
|
238
245
|
origin: "same-origin"
|
|
@@ -241,7 +248,7 @@ function At(e, t, n) {
|
|
|
241
248
|
kind: "broadcast",
|
|
242
249
|
post(e) {
|
|
243
250
|
n.guard("bus.send_failed", "BroadcastChannel.postMessage", () => {
|
|
244
|
-
i.postMessage(
|
|
251
|
+
i.postMessage(O(e));
|
|
245
252
|
});
|
|
246
253
|
},
|
|
247
254
|
close() {
|
|
@@ -251,26 +258,29 @@ function At(e, t, n) {
|
|
|
251
258
|
}
|
|
252
259
|
}) : null;
|
|
253
260
|
}
|
|
254
|
-
function
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
261
|
+
function Nt(e, t, n, r) {
|
|
262
|
+
let i = globalThis.fin?.InterApplicationBus;
|
|
263
|
+
if (!i) return null;
|
|
264
|
+
if (!t) return r.report("openfin.unavailable", "no OpenFin application uuid, so the InterApplicationBus link stays closed"), null;
|
|
265
|
+
let a = `${e}.${t}`;
|
|
266
|
+
return r.guardAsync("bus.send_failed", "InterApplicationBus.subscribe", () => i.subscribe({ uuid: t }, a, (e) => {
|
|
267
|
+
let t = k(e);
|
|
268
|
+
t && n(t, {
|
|
259
269
|
link: "openfin",
|
|
260
270
|
origin: "openfin"
|
|
261
271
|
});
|
|
262
272
|
})), {
|
|
263
273
|
kind: "openfin",
|
|
264
|
-
post(
|
|
265
|
-
|
|
274
|
+
post(e) {
|
|
275
|
+
r.guardAsync("bus.send_failed", "InterApplicationBus.publish", () => i.publish(a, O(e)));
|
|
266
276
|
},
|
|
267
277
|
close() {}
|
|
268
|
-
}
|
|
278
|
+
};
|
|
269
279
|
}
|
|
270
|
-
function
|
|
280
|
+
function Pt(e, t) {
|
|
271
281
|
let n = globalThis, r = n.postMessage;
|
|
272
282
|
return n.WorkerGlobalScope === void 0 || !r ? null : (n.addEventListener?.("message", (t) => {
|
|
273
|
-
let n =
|
|
283
|
+
let n = k(t.data);
|
|
274
284
|
n && e(n, {
|
|
275
285
|
link: "owner",
|
|
276
286
|
origin: "same-origin"
|
|
@@ -279,15 +289,15 @@ function Mt(e, t) {
|
|
|
279
289
|
kind: "owner",
|
|
280
290
|
post(e) {
|
|
281
291
|
t.guard("bus.send_failed", "worker postMessage", () => {
|
|
282
|
-
r(
|
|
292
|
+
r(O(e));
|
|
283
293
|
});
|
|
284
294
|
},
|
|
285
295
|
close() {}
|
|
286
296
|
});
|
|
287
297
|
}
|
|
288
|
-
function
|
|
298
|
+
function Ft(e, t, n) {
|
|
289
299
|
let r = (e) => {
|
|
290
|
-
let n =
|
|
300
|
+
let n = k(e.data);
|
|
291
301
|
n && t(n, {
|
|
292
302
|
link: "worker",
|
|
293
303
|
origin: "same-origin"
|
|
@@ -297,7 +307,7 @@ function Nt(e, t, n) {
|
|
|
297
307
|
kind: "worker",
|
|
298
308
|
post(t) {
|
|
299
309
|
n.guard("bus.send_failed", "postMessage to a worker", () => {
|
|
300
|
-
e.postMessage(
|
|
310
|
+
e.postMessage(O(t));
|
|
301
311
|
});
|
|
302
312
|
},
|
|
303
313
|
close() {
|
|
@@ -307,14 +317,14 @@ function Nt(e, t, n) {
|
|
|
307
317
|
}
|
|
308
318
|
//#endregion
|
|
309
319
|
//#region src/bus/bus.ts
|
|
310
|
-
var
|
|
311
|
-
timeoutMs:
|
|
320
|
+
var It = {
|
|
321
|
+
timeoutMs: vt,
|
|
312
322
|
maxAttempts: 3
|
|
313
|
-
},
|
|
323
|
+
}, Lt = [
|
|
314
324
|
"children",
|
|
315
325
|
"direct",
|
|
316
326
|
"worker"
|
|
317
|
-
],
|
|
327
|
+
], Rt = class {
|
|
318
328
|
config;
|
|
319
329
|
diagnostics;
|
|
320
330
|
platform;
|
|
@@ -329,7 +339,7 @@ var Pt = {
|
|
|
329
339
|
isOpenFinProvider = !1;
|
|
330
340
|
resolved = !1;
|
|
331
341
|
awaitingWelcome = null;
|
|
332
|
-
constructor(e, t, n, r, i, a, o =
|
|
342
|
+
constructor(e, t, n, r, i, a, o = It) {
|
|
333
343
|
this.config = e, this.diagnostics = t, this.platform = n, this.contextId = r, this.tabId = i, this.handlers = a, this.handshakeOptions = o;
|
|
334
344
|
}
|
|
335
345
|
getRole() {
|
|
@@ -343,7 +353,7 @@ var Pt = {
|
|
|
343
353
|
if (e.mode === "off") return this.role = "sender", this.resolved = !0, this.role;
|
|
344
354
|
if (this.isOpenFinProvider = this.resolveOpenFinProvider(), e.mode === "sender" || e.mode === "forwarder") return this.role = e.mode, this.openControlLinks(), this.role === "forwarder" && (this.upstream = this.candidateUpstream(), this.upstream || this.diagnostics.report("bus.no_owner", "bus.mode is \"forwarder\" but there is no owner to forward to. Records will be dropped.")), this.resolved = !0, this.announce(), this.role;
|
|
345
355
|
this.openControlLinks();
|
|
346
|
-
let t =
|
|
356
|
+
let t = kt(this.receive, this.diagnostics);
|
|
347
357
|
if (t) return this.role = "forwarder", this.upstream = t, this.resolved = !0, this.diagnostics.report("bus.role_resolved", "attached directly to the same-origin parent runtime", {
|
|
348
358
|
role: "forwarder",
|
|
349
359
|
via: "direct"
|
|
@@ -394,7 +404,7 @@ var Pt = {
|
|
|
394
404
|
this.receive(e, n);
|
|
395
405
|
}
|
|
396
406
|
attachWorker(e) {
|
|
397
|
-
this.links.push(
|
|
407
|
+
this.links.push(Ft(e, this.receive, this.diagnostics));
|
|
398
408
|
}
|
|
399
409
|
broadcastJourney(e) {
|
|
400
410
|
this.post({
|
|
@@ -431,7 +441,7 @@ var Pt = {
|
|
|
431
441
|
this.awaitingWelcome?.link === t.link && this.awaitingWelcome.settle(!0);
|
|
432
442
|
break;
|
|
433
443
|
case "records":
|
|
434
|
-
this.role === "sender" ? this.handlers.onRecords(e.records) : this.upstream && t.link
|
|
444
|
+
this.role === "sender" ? this.handlers.onRecords(e.records) : this.upstream && this.canRelay(t.link) && this.upstream.post(e);
|
|
435
445
|
break;
|
|
436
446
|
case "journey":
|
|
437
447
|
this.handlers.onJourney(e.journey);
|
|
@@ -448,8 +458,11 @@ var Pt = {
|
|
|
448
458
|
case "tab": t.link === "broadcast" && e.tabId === this.tabId && this.contextId > e.from && this.handlers.onTabConflict();
|
|
449
459
|
}
|
|
450
460
|
};
|
|
461
|
+
canRelay(e) {
|
|
462
|
+
return e === "direct" || e !== this.upstream?.kind;
|
|
463
|
+
}
|
|
451
464
|
canOwn(e) {
|
|
452
|
-
return this.role === "sender" ? e === "openfin" ? this.isOpenFinProvider :
|
|
465
|
+
return this.role === "sender" ? e === "openfin" ? this.isOpenFinProvider : Lt.includes(e) : !1;
|
|
453
466
|
}
|
|
454
467
|
resolveOpenFinProvider() {
|
|
455
468
|
let e = this.config.bus.openFinRole;
|
|
@@ -464,22 +477,22 @@ var Pt = {
|
|
|
464
477
|
isCrossOriginFrame() {
|
|
465
478
|
if (typeof window > "u" || window.parent === window) return !1;
|
|
466
479
|
try {
|
|
467
|
-
return window.parent
|
|
480
|
+
return Reflect.get(window.parent, "location"), !1;
|
|
468
481
|
} catch {
|
|
469
482
|
return !0;
|
|
470
483
|
}
|
|
471
484
|
}
|
|
472
485
|
candidateUpstream() {
|
|
473
|
-
return this.platform.isWorker ?
|
|
486
|
+
return this.platform.isWorker ? Pt(this.receive, this.diagnostics) : this.platform.isTopLevelDocument ? this.platform.platform === "openfin" && !this.isOpenFinProvider ? this.ensureOpenFinLink() : null : At(this.receive, this.diagnostics);
|
|
474
487
|
}
|
|
475
488
|
openControlLinks() {
|
|
476
489
|
let e = (e) => {
|
|
477
490
|
e && this.links.push(e);
|
|
478
491
|
};
|
|
479
|
-
this.platform.isTopLevelDocument && (e(
|
|
492
|
+
this.platform.isTopLevelDocument && (e(jt(this.receive, this.config.bus.trustedOrigins, this.diagnostics)), e(Mt(De, this.receive, this.diagnostics))), (this.platform.platform === "openfin" || this.platform.platform === "openfin_web") && e(this.ensureOpenFinLink());
|
|
480
493
|
}
|
|
481
494
|
ensureOpenFinLink() {
|
|
482
|
-
return this.openFinLink ??=
|
|
495
|
+
return this.openFinLink ??= Nt(De, this.platform.openfinUuid, this.receive, this.diagnostics), this.openFinLink;
|
|
483
496
|
}
|
|
484
497
|
handshake(e) {
|
|
485
498
|
return new Promise((t) => {
|
|
@@ -493,7 +506,7 @@ var Pt = {
|
|
|
493
506
|
let i = setTimeout(() => {
|
|
494
507
|
r(!1);
|
|
495
508
|
}, this.handshakeOptions.timeoutMs);
|
|
496
|
-
|
|
509
|
+
D(i), e.post({
|
|
497
510
|
t: "hello",
|
|
498
511
|
from: this.contextId,
|
|
499
512
|
tabId: this.tabId
|
|
@@ -510,30 +523,30 @@ var Pt = {
|
|
|
510
523
|
from: this.contextId
|
|
511
524
|
});
|
|
512
525
|
}
|
|
513
|
-
},
|
|
514
|
-
function
|
|
526
|
+
}, A = null;
|
|
527
|
+
function j(e, t) {
|
|
515
528
|
let n = e[t];
|
|
516
529
|
return n !== void 0 && e instanceof n;
|
|
517
530
|
}
|
|
518
|
-
function
|
|
519
|
-
if (
|
|
531
|
+
function zt(e) {
|
|
532
|
+
if (A) return A;
|
|
520
533
|
let t = globalThis, n = t.navigator?.userAgent ?? "", r = "browser", i, a, o = !1, s = t.fin?.me;
|
|
521
|
-
return
|
|
534
|
+
return j(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", o = !0) : j(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", o = !0) : j(t, "WorkerGlobalScope") ? (r = "web_worker", o = !0) : s === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 || Bt(n) ? r = "mobile_webview" : typeof document > "u" && typeof process < "u" && (r = "node") : (r = Re.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "reading fin.me.identity", () => {
|
|
522
535
|
let e = s.identity;
|
|
523
536
|
i = e?.uuid, a = e?.name;
|
|
524
|
-
})),
|
|
537
|
+
})), A = {
|
|
525
538
|
platform: r,
|
|
526
539
|
openfinUuid: i,
|
|
527
540
|
openfinName: a,
|
|
528
541
|
userAgent: n,
|
|
529
542
|
isWorker: o,
|
|
530
|
-
isTopLevelDocument:
|
|
531
|
-
},
|
|
543
|
+
isTopLevelDocument: Vt()
|
|
544
|
+
}, A;
|
|
532
545
|
}
|
|
533
|
-
function
|
|
534
|
-
return
|
|
546
|
+
function Bt(e) {
|
|
547
|
+
return dt.test(e) ? !0 : (Fe.test(e) || je.test(e) && Ne.test(e)) && e.includes("AppleWebKit") && !e.includes("Safari/");
|
|
535
548
|
}
|
|
536
|
-
function
|
|
549
|
+
function Vt() {
|
|
537
550
|
if (typeof window > "u") return !1;
|
|
538
551
|
try {
|
|
539
552
|
return window.self === window.top;
|
|
@@ -541,20 +554,20 @@ function zt() {
|
|
|
541
554
|
return !1;
|
|
542
555
|
}
|
|
543
556
|
}
|
|
544
|
-
function
|
|
557
|
+
function Ht() {
|
|
545
558
|
try {
|
|
546
559
|
return typeof location < "u" ? location.href : "";
|
|
547
560
|
} catch {
|
|
548
561
|
return "";
|
|
549
562
|
}
|
|
550
563
|
}
|
|
551
|
-
function
|
|
564
|
+
function M(e) {
|
|
552
565
|
let t = e.search(/[?#]/);
|
|
553
566
|
return t === -1 ? e : e.slice(0, t);
|
|
554
567
|
}
|
|
555
568
|
//#endregion
|
|
556
569
|
//#region src/capture/errors.ts
|
|
557
|
-
var
|
|
570
|
+
var Ut = class {
|
|
558
571
|
ctx;
|
|
559
572
|
name = "errors";
|
|
560
573
|
installed = !1;
|
|
@@ -574,7 +587,7 @@ var Vt = class {
|
|
|
574
587
|
let t = e.target, n = t?.src ?? t?.href ?? "";
|
|
575
588
|
if (t !== null && t !== globalThis && n !== "") {
|
|
576
589
|
if (!this.ctx.config.capture.resourceErrors) return;
|
|
577
|
-
let e = this.ctx.config.capture.fullUrls ? n :
|
|
590
|
+
let e = this.ctx.config.capture.fullUrls ? n : M(n);
|
|
578
591
|
this.ctx.breadcrumbs.push({
|
|
579
592
|
t: Date.now(),
|
|
580
593
|
category: "http",
|
|
@@ -600,32 +613,32 @@ var Vt = class {
|
|
|
600
613
|
report(e, t, n) {
|
|
601
614
|
let r = Date.now();
|
|
602
615
|
if (r - this.windowStart > 1e4 && (this.windowStart = r, this.windowCount = 0), this.windowCount++, this.windowCount > 20) {
|
|
603
|
-
this.ctx.diagnostics.report("capture.rate_limited", `more than 20 errors in ${String(
|
|
616
|
+
this.ctx.diagnostics.report("capture.rate_limited", `more than 20 errors in ${String(_e)}ms, suppressing the rest of this window`);
|
|
604
617
|
return;
|
|
605
618
|
}
|
|
606
|
-
let
|
|
607
|
-
if (
|
|
608
|
-
|
|
619
|
+
let i = t instanceof Error ? t : Error(String(t)), a = (i.stack ?? "").split("\n")[1] ?? "", o = `${i.name}|${i.message}|${a}`, s = this.seen.get(o);
|
|
620
|
+
if (s && r - s.at < 5e3) {
|
|
621
|
+
s.count++, s.at = r;
|
|
609
622
|
return;
|
|
610
623
|
}
|
|
611
|
-
let
|
|
612
|
-
if (this.seen.delete(
|
|
624
|
+
let c = s ? s.count - 1 : 0;
|
|
625
|
+
if (this.seen.delete(o), this.seen.set(o, {
|
|
613
626
|
at: r,
|
|
614
627
|
count: 1
|
|
615
628
|
}), this.seen.size > 200) {
|
|
616
629
|
let [e] = this.seen.keys();
|
|
617
630
|
this.seen.delete(e);
|
|
618
631
|
}
|
|
619
|
-
this.ctx.logger.error(
|
|
632
|
+
this.ctx.logger.error(i.message === "" ? e : i.message, i, {
|
|
620
633
|
...n,
|
|
621
634
|
"error.captured_by": e,
|
|
622
|
-
"error.suppressed_count":
|
|
635
|
+
"error.suppressed_count": c
|
|
623
636
|
});
|
|
624
637
|
}
|
|
625
638
|
};
|
|
626
639
|
//#endregion
|
|
627
640
|
//#region src/capture/interactions.ts
|
|
628
|
-
function
|
|
641
|
+
function Wt(e) {
|
|
629
642
|
if (e === null) return "unknown";
|
|
630
643
|
let t = e.tagName.toLowerCase(), n = e.getAttribute("data-testid") ?? e.getAttribute("data-test-id");
|
|
631
644
|
if (n !== null) return `[data-testid="${n}"]`;
|
|
@@ -635,10 +648,10 @@ function Ht(e) {
|
|
|
635
648
|
let i = e.getAttribute("class")?.trim() ?? "";
|
|
636
649
|
return i === "" ? t : `${t}.${i.split(/\s+/).slice(0, 2).join(".")}`;
|
|
637
650
|
}
|
|
638
|
-
function
|
|
651
|
+
function N() {
|
|
639
652
|
return history;
|
|
640
653
|
}
|
|
641
|
-
var
|
|
654
|
+
var Gt = class {
|
|
642
655
|
ctx;
|
|
643
656
|
name = "interactions";
|
|
644
657
|
installed = !1;
|
|
@@ -652,10 +665,10 @@ var Ut = class {
|
|
|
652
665
|
this.installed || typeof document > "u" || (this.installed = !0, this.lastUrl = location.href, this.ctx.config.capture.interactions && addEventListener("click", this.onClick, !0), this.ctx.config.capture.navigation && (this.installHistory(), addEventListener("popstate", this.onNavigate), addEventListener("hashchange", this.onNavigate)));
|
|
653
666
|
}
|
|
654
667
|
uninstall() {
|
|
655
|
-
this.installed && (this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate), this.originalPushState && (
|
|
668
|
+
this.installed && (this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate), this.originalPushState && (N().pushState = this.originalPushState), this.originalReplaceState && (N().replaceState = this.originalReplaceState), this.originalPushState = null, this.originalReplaceState = null);
|
|
656
669
|
}
|
|
657
670
|
onClick = (e) => {
|
|
658
|
-
let t = e.target, n =
|
|
671
|
+
let t = e.target, n = Wt(t instanceof Element ? t : null), r = t instanceof HTMLElement ? t.textContent.trim().slice(0, 50) : "";
|
|
659
672
|
this.ctx.tracing.rotate("interaction"), this.ctx.breadcrumbs.push({
|
|
660
673
|
t: Date.now(),
|
|
661
674
|
category: "click",
|
|
@@ -667,7 +680,7 @@ var Ut = class {
|
|
|
667
680
|
let e = this.lastUrl, t = location.href;
|
|
668
681
|
if (e === t) return;
|
|
669
682
|
this.lastUrl = t;
|
|
670
|
-
let n = this.ctx.config.capture.fullUrls, r = n ? e :
|
|
683
|
+
let n = this.ctx.config.capture.fullUrls, r = n ? e : M(e), i = n ? t : M(t);
|
|
671
684
|
this.ctx.tracing.rotate("navigation"), this.ctx.breadcrumbs.push({
|
|
672
685
|
t: Date.now(),
|
|
673
686
|
category: "navigation",
|
|
@@ -676,7 +689,7 @@ var Ut = class {
|
|
|
676
689
|
};
|
|
677
690
|
installHistory() {
|
|
678
691
|
if (typeof history > "u" || this.originalPushState) return;
|
|
679
|
-
let e =
|
|
692
|
+
let e = N(), t = e.pushState, n = e.replaceState;
|
|
680
693
|
this.originalPushState = t, this.originalReplaceState = n;
|
|
681
694
|
let r = this.onNavigate;
|
|
682
695
|
e.pushState = function(...e) {
|
|
@@ -688,15 +701,15 @@ var Ut = class {
|
|
|
688
701
|
};
|
|
689
702
|
//#endregion
|
|
690
703
|
//#region src/capture/types.ts
|
|
691
|
-
function
|
|
704
|
+
function Kt(e, t) {
|
|
692
705
|
return t.some((t) => typeof t == "string" ? e.includes(t) : t.test(e));
|
|
693
706
|
}
|
|
694
707
|
//#endregion
|
|
695
708
|
//#region src/capture/network.ts
|
|
696
|
-
function
|
|
709
|
+
function P() {
|
|
697
710
|
return XMLHttpRequest.prototype;
|
|
698
711
|
}
|
|
699
|
-
var
|
|
712
|
+
var qt = class {
|
|
700
713
|
ctx;
|
|
701
714
|
name = "network";
|
|
702
715
|
originalFetch = null;
|
|
@@ -709,10 +722,10 @@ var Gt = class {
|
|
|
709
722
|
this.ctx.config.capture.fetch && this.installFetch(), this.ctx.config.capture.xhr && this.installXhr();
|
|
710
723
|
}
|
|
711
724
|
uninstall() {
|
|
712
|
-
this.originalFetch &&= (globalThis.fetch = this.originalFetch, null), this.originalOpen &&= (
|
|
725
|
+
this.originalFetch &&= (globalThis.fetch = this.originalFetch, null), this.originalOpen &&= (P().open = this.originalOpen, null), this.originalSend &&= (P().send = this.originalSend, null);
|
|
713
726
|
}
|
|
714
727
|
ignored(e) {
|
|
715
|
-
return
|
|
728
|
+
return Kt(e, this.ctx.config.capture.ignoreUrls);
|
|
716
729
|
}
|
|
717
730
|
installFetch() {
|
|
718
731
|
if (typeof globalThis.fetch != "function" || this.originalFetch) return;
|
|
@@ -725,7 +738,7 @@ var Gt = class {
|
|
|
725
738
|
let o = typeof i == "string" ? i : i instanceof URL ? i.href : i.url, s = (a?.method ?? (i instanceof Request ? i.method : "GET")).toUpperCase();
|
|
726
739
|
if (n(o)) return e(i, a);
|
|
727
740
|
let c = i, l = a;
|
|
728
|
-
if (
|
|
741
|
+
if (Kt(o, t.config.capture.propagateTraceHeaderTo)) try {
|
|
729
742
|
let e = Object.entries(t.tracing.headers());
|
|
730
743
|
if (i instanceof Request) {
|
|
731
744
|
let t = new Headers(i.headers);
|
|
@@ -755,7 +768,7 @@ var Gt = class {
|
|
|
755
768
|
if (typeof XMLHttpRequest > "u" || this.originalOpen) return;
|
|
756
769
|
let e = (e) => this.ignored(e), t = (e, t, n, r) => {
|
|
757
770
|
this.record(e, t, n, r, void 0);
|
|
758
|
-
}, n =
|
|
771
|
+
}, n = P(), r = n.open, i = n.send;
|
|
759
772
|
this.originalOpen = r, this.originalSend = i, n.open = function(e, t, ...n) {
|
|
760
773
|
this.__uiobs = {
|
|
761
774
|
method: e.toUpperCase(),
|
|
@@ -774,7 +787,7 @@ var Gt = class {
|
|
|
774
787
|
};
|
|
775
788
|
}
|
|
776
789
|
record(e, t, n, r, i) {
|
|
777
|
-
let a = this.ctx.config.capture.fullUrls ? t :
|
|
790
|
+
let a = this.ctx.config.capture.fullUrls ? t : M(t);
|
|
778
791
|
this.ctx.diagnostics.guard("capture.record_failed", `recording ${e} ${a}`, () => {
|
|
779
792
|
let t = Math.round(r);
|
|
780
793
|
this.ctx.breadcrumbs.push({
|
|
@@ -803,13 +816,13 @@ var Gt = class {
|
|
|
803
816
|
};
|
|
804
817
|
//#endregion
|
|
805
818
|
//#region src/capture/web-vitals.ts
|
|
806
|
-
function
|
|
819
|
+
function Jt() {
|
|
807
820
|
return import(
|
|
808
821
|
/* @vite-ignore */
|
|
809
822
|
"web-vitals"
|
|
810
823
|
);
|
|
811
824
|
}
|
|
812
|
-
var
|
|
825
|
+
var Yt = class {
|
|
813
826
|
ctx;
|
|
814
827
|
name = "web-vitals";
|
|
815
828
|
installed = !1;
|
|
@@ -817,13 +830,13 @@ var qt = class {
|
|
|
817
830
|
this.ctx = e;
|
|
818
831
|
}
|
|
819
832
|
install() {
|
|
820
|
-
this.installed || (this.installed = !0, this.reportNavigationTiming(), this.loadWebVitals());
|
|
833
|
+
this.installed || (this.installed = !0, this.reportNavigationTiming(), !this.ctx.once.webVitals && (this.ctx.once.webVitals = !0, this.loadWebVitals()));
|
|
821
834
|
}
|
|
822
835
|
uninstall() {
|
|
823
836
|
this.installed = !1;
|
|
824
837
|
}
|
|
825
838
|
async loadWebVitals() {
|
|
826
|
-
let e = this.ctx.config.capture.webVitalsLoader ??
|
|
839
|
+
let e = this.ctx.config.capture.webVitalsLoader ?? Jt, t = await this.ctx.diagnostics.guardAsync("capture.install_failed", "loading web-vitals", e);
|
|
827
840
|
if (!t) {
|
|
828
841
|
this.ctx.diagnostics.report("capture.install_failed", "web-vitals is not available, so LCP, CLS and INP are unavailable. Navigation timing still works.");
|
|
829
842
|
return;
|
|
@@ -837,7 +850,7 @@ var qt = class {
|
|
|
837
850
|
t.onLCP(n("lcp", "ms")), t.onCLS(n("cls", "1")), t.onINP(n("inp", "ms")), t.onFCP(n("fcp", "ms")), t.onTTFB(n("ttfb", "ms"));
|
|
838
851
|
}
|
|
839
852
|
reportNavigationTiming() {
|
|
840
|
-
this.ctx.diagnostics.guard("capture.install_failed", "reading navigation timing", () => {
|
|
853
|
+
this.ctx.once.navigationTiming || (this.ctx.once.navigationTiming = !0, this.ctx.diagnostics.guard("capture.install_failed", "reading navigation timing", () => {
|
|
841
854
|
let e = performance.getEntriesByType("navigation")[0];
|
|
842
855
|
if (!e) return;
|
|
843
856
|
let t = {
|
|
@@ -850,43 +863,43 @@ var qt = class {
|
|
|
850
863
|
"navigation.load_ms": e.loadEventEnd
|
|
851
864
|
};
|
|
852
865
|
for (let [n, r] of Object.entries(t)) Number.isFinite(r) && r >= 0 && this.ctx.logger.logMetric(n, Math.round(r), "ms", "gauge", { "navigation.type": e.type });
|
|
853
|
-
});
|
|
866
|
+
}));
|
|
854
867
|
}
|
|
855
868
|
};
|
|
856
869
|
//#endregion
|
|
857
870
|
//#region src/models/log-record.ts
|
|
858
|
-
function
|
|
871
|
+
function Xt() {
|
|
859
872
|
return `${String(Date.now())}000000`;
|
|
860
873
|
}
|
|
861
|
-
function
|
|
874
|
+
function Zt(e) {
|
|
862
875
|
if (typeof e != "object" || !e) return !1;
|
|
863
876
|
let t = e;
|
|
864
877
|
return typeof t.body == "string" && typeof t.severityText == "string" && typeof t.timeUnixNano == "string" && typeof t.attributes == "object" && t.attributes !== null && typeof t.resource == "object" && t.resource !== null;
|
|
865
878
|
}
|
|
866
879
|
//#endregion
|
|
867
880
|
//#region src/utils/identity.ts
|
|
868
|
-
function
|
|
881
|
+
function F(e) {
|
|
869
882
|
let t = new Uint8Array(e);
|
|
870
883
|
if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") crypto.getRandomValues(t);
|
|
871
884
|
else for (let n = 0; n < e; n++) t[n] = Math.floor(Math.random() * 256);
|
|
872
885
|
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
873
886
|
}
|
|
874
|
-
function
|
|
887
|
+
function I() {
|
|
875
888
|
try {
|
|
876
889
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
877
890
|
} catch {}
|
|
878
|
-
return
|
|
891
|
+
return F(16);
|
|
879
892
|
}
|
|
880
|
-
function
|
|
893
|
+
function Qt(e, t, n) {
|
|
881
894
|
return n.guard("storage.unavailable", `reading ${e}Storage`, () => (e === "local" ? localStorage : sessionStorage).getItem(t)) ?? null;
|
|
882
895
|
}
|
|
883
|
-
function
|
|
896
|
+
function L(e, t, n, r) {
|
|
884
897
|
r.guard("storage.unavailable", `writing ${e}Storage`, () => {
|
|
885
898
|
(e === "local" ? localStorage : sessionStorage).setItem(t, n);
|
|
886
899
|
});
|
|
887
900
|
}
|
|
888
|
-
function
|
|
889
|
-
let t =
|
|
901
|
+
function $t(e) {
|
|
902
|
+
let t = I(), n = Date.now(), r = I(), i = Qt("local", h, e);
|
|
890
903
|
if (i) try {
|
|
891
904
|
let e = JSON.parse(i);
|
|
892
905
|
e.id && n - (e.lastSeenAt ?? 0) < 18e5 && (r = e.id);
|
|
@@ -897,36 +910,42 @@ function Zt(e) {
|
|
|
897
910
|
id: r,
|
|
898
911
|
lastSeenAt: n
|
|
899
912
|
});
|
|
900
|
-
|
|
901
|
-
let o =
|
|
902
|
-
return o || (o =
|
|
913
|
+
L("local", h, a, e);
|
|
914
|
+
let o = Qt("session", "ui-observability.tab", e) ?? "";
|
|
915
|
+
return o || (o = I(), L("session", Pe, o, e)), {
|
|
903
916
|
sessionId: r,
|
|
904
917
|
tabId: o,
|
|
905
918
|
contextId: t
|
|
906
919
|
};
|
|
907
920
|
}
|
|
908
|
-
var
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
921
|
+
var en = class {
|
|
922
|
+
diagnostics;
|
|
923
|
+
lastTouchAt = 0;
|
|
924
|
+
constructor(e) {
|
|
925
|
+
this.diagnostics = e;
|
|
926
|
+
}
|
|
927
|
+
touch(e) {
|
|
928
|
+
let t = Date.now();
|
|
929
|
+
if (t - this.lastTouchAt < 6e4) return;
|
|
930
|
+
this.lastTouchAt = t;
|
|
931
|
+
let n = JSON.stringify({
|
|
932
|
+
id: e,
|
|
933
|
+
lastSeenAt: t
|
|
934
|
+
});
|
|
935
|
+
L("local", h, n, this.diagnostics);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
919
938
|
//#endregion
|
|
920
939
|
//#region src/models/batch.ts
|
|
921
|
-
function
|
|
940
|
+
function tn(e) {
|
|
922
941
|
if (typeof e != "object" || !e) return !1;
|
|
923
942
|
let t = Reflect.get(e, "id"), n = Reflect.get(e, "createdAt"), r = Reflect.get(e, "attempts"), i = Reflect.get(e, "records");
|
|
924
943
|
return typeof t == "string" && typeof n == "number" && typeof r == "number" && Array.isArray(i);
|
|
925
944
|
}
|
|
926
|
-
function
|
|
945
|
+
function nn(e) {
|
|
927
946
|
if (e.records.length < 2) return null;
|
|
928
947
|
let t = Math.floor(e.records.length / 2), n = (t) => ({
|
|
929
|
-
id:
|
|
948
|
+
id: I(),
|
|
930
949
|
records: t,
|
|
931
950
|
createdAt: e.createdAt,
|
|
932
951
|
attempts: e.attempts
|
|
@@ -934,14 +953,27 @@ function tn(e) {
|
|
|
934
953
|
return [n(e.records.slice(0, t)), n(e.records.slice(t))];
|
|
935
954
|
}
|
|
936
955
|
//#endregion
|
|
956
|
+
//#region src/utils/deadline.ts
|
|
957
|
+
function R(e, t) {
|
|
958
|
+
let n, r = new Promise((e, r) => {
|
|
959
|
+
let i = setTimeout(() => {
|
|
960
|
+
r(/* @__PURE__ */ Error(`timed out after ${String(t)}ms`));
|
|
961
|
+
}, t);
|
|
962
|
+
n = i, D(i);
|
|
963
|
+
});
|
|
964
|
+
return Promise.race([e, r]).finally(() => {
|
|
965
|
+
clearTimeout(n);
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
//#endregion
|
|
937
969
|
//#region src/utils/lock.ts
|
|
938
|
-
function
|
|
970
|
+
function rn(e, t, n, { skipIfBusy: r = !0 } = {}) {
|
|
939
971
|
let i = globalThis.navigator?.locks;
|
|
940
972
|
return i?.request ? t.guardAsync("storage.degraded", `acquiring lock ${e}`, () => i.request(e, { ifAvailable: r }, (e) => e ? n() : Promise.resolve(void 0))) : n();
|
|
941
973
|
}
|
|
942
974
|
//#endregion
|
|
943
975
|
//#region src/storage/keys.ts
|
|
944
|
-
function
|
|
976
|
+
function z(e, t) {
|
|
945
977
|
let n = [];
|
|
946
978
|
return t.guard("storage.unavailable", "enumerating localStorage", () => {
|
|
947
979
|
for (let t = 0; t < localStorage.length; t++) {
|
|
@@ -952,63 +984,70 @@ function I(e, t) {
|
|
|
952
984
|
}
|
|
953
985
|
//#endregion
|
|
954
986
|
//#region src/storage/emergency-queue.ts
|
|
955
|
-
function
|
|
987
|
+
function an(e) {
|
|
956
988
|
let t = String(e.createdAt).padStart(14, "0");
|
|
957
|
-
return `${
|
|
989
|
+
return `${y}${t}.${e.id}`;
|
|
958
990
|
}
|
|
959
|
-
function
|
|
991
|
+
function on(e, t) {
|
|
960
992
|
let n = t.guard("storage.degraded", "an emergency entry was not JSON and was dropped", () => JSON.parse(e));
|
|
961
|
-
return n === void 0 ? null :
|
|
993
|
+
return n === void 0 ? null : tn(n) ? n : (t.report("storage.degraded", "an emergency entry was not a batch and was dropped"), null);
|
|
962
994
|
}
|
|
963
|
-
async function
|
|
995
|
+
async function sn(e, t) {
|
|
964
996
|
let n = 0;
|
|
965
|
-
for (let r of
|
|
997
|
+
for (let r of z(y, t)) {
|
|
966
998
|
let i = t.guard("storage.unavailable", "reading the emergency queue", () => {
|
|
967
999
|
let e = localStorage.getItem(r);
|
|
968
1000
|
return localStorage.removeItem(r), e;
|
|
969
1001
|
});
|
|
970
1002
|
if (!i) continue;
|
|
971
|
-
let a =
|
|
1003
|
+
let a = on(i, t);
|
|
972
1004
|
if (a !== null) try {
|
|
973
|
-
await e.save(a), n++;
|
|
1005
|
+
await R(e.save(a), v), n++;
|
|
974
1006
|
} catch (e) {
|
|
975
1007
|
t.report("storage.degraded", "an emergency batch could not be recovered", { key: r }, e);
|
|
976
1008
|
}
|
|
977
1009
|
}
|
|
978
1010
|
return n;
|
|
979
1011
|
}
|
|
980
|
-
function
|
|
1012
|
+
function cn(e, t) {
|
|
981
1013
|
let n = `writing the emergency queue, ${String(e.records.length)} records`;
|
|
982
1014
|
t.guard("storage.quota_exceeded", n, () => {
|
|
983
|
-
let n =
|
|
1015
|
+
let n = z(y, t);
|
|
984
1016
|
for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) localStorage.removeItem(e);
|
|
985
|
-
localStorage.setItem(
|
|
1017
|
+
localStorage.setItem(an(e), JSON.stringify(e));
|
|
986
1018
|
});
|
|
987
1019
|
}
|
|
988
|
-
async function
|
|
989
|
-
return await
|
|
1020
|
+
async function ln(e, t) {
|
|
1021
|
+
return await rn("ui-observability.emergency", t, () => sn(e, t), { skipIfBusy: !1 }) ?? 0;
|
|
990
1022
|
}
|
|
991
1023
|
//#endregion
|
|
992
1024
|
//#region src/storage/local-storage.ts
|
|
993
|
-
function
|
|
1025
|
+
function un(e) {
|
|
994
1026
|
let t = String(e.createdAt).padStart(14, "0");
|
|
995
|
-
return `${
|
|
1027
|
+
return `${T}${t}.${e.id}`;
|
|
1028
|
+
}
|
|
1029
|
+
function dn(e) {
|
|
1030
|
+
let t = T.length, n = Number(e.slice(t, t + 14));
|
|
1031
|
+
return Number.isFinite(n) ? n : null;
|
|
996
1032
|
}
|
|
997
|
-
var
|
|
1033
|
+
var fn = class {
|
|
998
1034
|
limits;
|
|
999
1035
|
diagnostics;
|
|
1000
1036
|
onGap;
|
|
1001
|
-
name =
|
|
1037
|
+
name = ye;
|
|
1002
1038
|
constructor(e, t, n) {
|
|
1003
1039
|
this.limits = e, this.diagnostics = t, this.onGap = n;
|
|
1004
1040
|
}
|
|
1005
1041
|
async save(e) {
|
|
1006
|
-
if (this.
|
|
1007
|
-
|
|
1008
|
-
this.evict(e.slice(0, Math.ceil(e.length / 4)));
|
|
1042
|
+
if (this.write(e, "localStorage refused a batch, evicting the oldest")) {
|
|
1043
|
+
await this.prune();
|
|
1009
1044
|
return;
|
|
1010
1045
|
}
|
|
1011
|
-
|
|
1046
|
+
this.evictForQuota(), this.write(e, "localStorage refused a batch even after evicting") || this.reportGap({
|
|
1047
|
+
batches: 1,
|
|
1048
|
+
records: e.records.length,
|
|
1049
|
+
reason: "quota"
|
|
1050
|
+
});
|
|
1012
1051
|
}
|
|
1013
1052
|
take(e) {
|
|
1014
1053
|
let t = [];
|
|
@@ -1039,30 +1078,24 @@ var un = class {
|
|
|
1039
1078
|
batches: 0,
|
|
1040
1079
|
records: 0,
|
|
1041
1080
|
reason: "expired"
|
|
1042
|
-
}, n = (e
|
|
1043
|
-
this.
|
|
1081
|
+
}, n = (e) => {
|
|
1082
|
+
let n = this.read(e);
|
|
1083
|
+
this.removeKey(e), t.batches++, t.records += n?.records.length ?? 0;
|
|
1044
1084
|
}, r = [];
|
|
1045
1085
|
for (let t of this.keys()) {
|
|
1046
|
-
let i =
|
|
1047
|
-
if (i === null) {
|
|
1048
|
-
n(t
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
if (i.createdAt < e) {
|
|
1052
|
-
n(t, i.records.length);
|
|
1086
|
+
let i = dn(t);
|
|
1087
|
+
if (i === null || i < e) {
|
|
1088
|
+
n(t);
|
|
1053
1089
|
continue;
|
|
1054
1090
|
}
|
|
1055
|
-
r.push(
|
|
1056
|
-
key: t,
|
|
1057
|
-
records: i.records.length
|
|
1058
|
-
});
|
|
1091
|
+
r.push(t);
|
|
1059
1092
|
}
|
|
1060
1093
|
let i = r.length - this.limits.maxBatches;
|
|
1061
1094
|
if (i > 0) {
|
|
1062
1095
|
t.reason = "over_capacity";
|
|
1063
|
-
for (let e of r.slice(0, i)) n(e
|
|
1096
|
+
for (let e of r.slice(0, i)) n(e);
|
|
1064
1097
|
}
|
|
1065
|
-
return
|
|
1098
|
+
return this.reportGap(t), Promise.resolve(t);
|
|
1066
1099
|
}
|
|
1067
1100
|
count() {
|
|
1068
1101
|
return Promise.resolve(this.keys().length);
|
|
@@ -1073,11 +1106,29 @@ var un = class {
|
|
|
1073
1106
|
close() {
|
|
1074
1107
|
return Promise.resolve();
|
|
1075
1108
|
}
|
|
1109
|
+
write(e, t) {
|
|
1110
|
+
return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(un(e), JSON.stringify(e)), !0)) === !0;
|
|
1111
|
+
}
|
|
1112
|
+
evictForQuota() {
|
|
1113
|
+
let e = this.keys(), t = {
|
|
1114
|
+
batches: 0,
|
|
1115
|
+
records: 0,
|
|
1116
|
+
reason: "quota"
|
|
1117
|
+
};
|
|
1118
|
+
for (let n of e.slice(0, Math.ceil(e.length / 4))) {
|
|
1119
|
+
let e = this.read(n);
|
|
1120
|
+
this.removeKey(n), t.batches++, t.records += e?.records.length ?? 0;
|
|
1121
|
+
}
|
|
1122
|
+
this.reportGap(t);
|
|
1123
|
+
}
|
|
1124
|
+
reportGap(e) {
|
|
1125
|
+
e.batches !== 0 && (this.diagnostics.report("storage.evicted", `dropped ${String(e.batches)} stored batches (${String(e.records)} records)`, { ...e }), this.onGap?.(e));
|
|
1126
|
+
}
|
|
1076
1127
|
read(e) {
|
|
1077
1128
|
let t = this.diagnostics.guard("storage.unavailable", "reading a stored batch", () => localStorage.getItem(e));
|
|
1078
1129
|
if (!t) return null;
|
|
1079
1130
|
let n = this.diagnostics.guard("storage.degraded", "a stored batch was corrupt and was removed", () => JSON.parse(t));
|
|
1080
|
-
return n === void 0 ? null :
|
|
1131
|
+
return n === void 0 ? null : tn(n) ? n : (this.diagnostics.report("storage.degraded", "a stored entry was not a batch and was dropped"), null);
|
|
1081
1132
|
}
|
|
1082
1133
|
keyOf(e) {
|
|
1083
1134
|
return this.keys().find((t) => t.endsWith(`.${e}`)) ?? null;
|
|
@@ -1091,18 +1142,18 @@ var un = class {
|
|
|
1091
1142
|
});
|
|
1092
1143
|
}
|
|
1093
1144
|
keys() {
|
|
1094
|
-
return
|
|
1145
|
+
return z(T, this.diagnostics);
|
|
1095
1146
|
}
|
|
1096
1147
|
};
|
|
1097
1148
|
//#endregion
|
|
1098
1149
|
//#region src/storage/memory-storage.ts
|
|
1099
|
-
function
|
|
1150
|
+
function pn(e) {
|
|
1100
1151
|
return e.reduce((e, t) => e + t.records.length, 0);
|
|
1101
1152
|
}
|
|
1102
|
-
var
|
|
1153
|
+
var B = class {
|
|
1103
1154
|
limits;
|
|
1104
1155
|
onGap;
|
|
1105
|
-
name =
|
|
1156
|
+
name = xe;
|
|
1106
1157
|
batches = [];
|
|
1107
1158
|
constructor(e, t) {
|
|
1108
1159
|
this.limits = e, this.onGap = t;
|
|
@@ -1126,12 +1177,12 @@ var L = class {
|
|
|
1126
1177
|
records: 0,
|
|
1127
1178
|
reason: "expired"
|
|
1128
1179
|
}, n = this.batches.filter((t) => t.createdAt < e);
|
|
1129
|
-
this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records +=
|
|
1180
|
+
this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records += pn(n);
|
|
1130
1181
|
let r = this.batches.length - this.limits.maxBatches;
|
|
1131
1182
|
if (r > 0) {
|
|
1132
1183
|
t.reason = "over_capacity";
|
|
1133
1184
|
let e = this.batches.slice(0, r);
|
|
1134
|
-
this.batches = this.batches.slice(r), t.batches += e.length, t.records +=
|
|
1185
|
+
this.batches = this.batches.slice(r), t.batches += e.length, t.records += pn(e);
|
|
1135
1186
|
}
|
|
1136
1187
|
return t.batches > 0 && this.onGap?.(t), Promise.resolve(t);
|
|
1137
1188
|
}
|
|
@@ -1144,8 +1195,8 @@ var L = class {
|
|
|
1144
1195
|
close() {
|
|
1145
1196
|
return this.batches = [], Promise.resolve();
|
|
1146
1197
|
}
|
|
1147
|
-
},
|
|
1148
|
-
name:
|
|
1198
|
+
}, mn = {
|
|
1199
|
+
name: de,
|
|
1149
1200
|
save: () => Promise.resolve(),
|
|
1150
1201
|
take: () => Promise.resolve([]),
|
|
1151
1202
|
remove: () => Promise.resolve(),
|
|
@@ -1159,112 +1210,116 @@ var L = class {
|
|
|
1159
1210
|
clear: () => Promise.resolve(),
|
|
1160
1211
|
close: () => Promise.resolve()
|
|
1161
1212
|
};
|
|
1162
|
-
function
|
|
1213
|
+
function hn(e) {
|
|
1163
1214
|
return e.guard("storage.unavailable", "reading indexedDB", () => globalThis.indexedDB != null) === !0;
|
|
1164
1215
|
}
|
|
1165
|
-
function
|
|
1166
|
-
return
|
|
1216
|
+
function gn(t) {
|
|
1217
|
+
return t.guard("storage.unavailable", "probing localStorage", () => (localStorage.setItem(e, "1"), localStorage.removeItem(e), !0)) === !0;
|
|
1167
1218
|
}
|
|
1168
|
-
async function
|
|
1169
|
-
if (e === "none") return
|
|
1170
|
-
if (e === "memory") return new
|
|
1219
|
+
async function _n(e, t, n, r, i) {
|
|
1220
|
+
if (e === "none") return mn;
|
|
1221
|
+
if (e === "memory") return new B(n, i);
|
|
1171
1222
|
if (e === "indexeddb" || e === "auto") {
|
|
1172
|
-
if (
|
|
1223
|
+
if (hn(r)) {
|
|
1173
1224
|
let e = await r.guardAsync("storage.unavailable", "opening IndexedDB", async () => {
|
|
1174
|
-
let { IndexedDbStorage: e } = await import("./indexeddb-storage-
|
|
1175
|
-
return
|
|
1225
|
+
let { IndexedDbStorage: e } = await import("./indexeddb-storage-B6uqejZb.js"), a = new e(t, n, r, i);
|
|
1226
|
+
return await a.open(), a;
|
|
1176
1227
|
});
|
|
1177
1228
|
if (e) return e;
|
|
1178
1229
|
}
|
|
1179
|
-
if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new
|
|
1230
|
+
if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new B(n, i);
|
|
1180
1231
|
}
|
|
1181
|
-
return
|
|
1232
|
+
return gn(r) ? new fn(n, r, i) : (r.report("storage.degraded", "no persistent storage available, offline logs are memory only"), new B(n, i));
|
|
1182
1233
|
}
|
|
1183
1234
|
//#endregion
|
|
1184
1235
|
//#region src/utils/sanitize.ts
|
|
1185
|
-
function
|
|
1236
|
+
function V(e, t) {
|
|
1186
1237
|
if (e.length <= t) return e;
|
|
1187
|
-
let n =
|
|
1238
|
+
let n = vn(e.charCodeAt(t - 1)) ? t - 1 : t;
|
|
1188
1239
|
return `${e.slice(0, n)}… [truncated ${String(e.length - n)} chars]`;
|
|
1189
1240
|
}
|
|
1190
|
-
function
|
|
1241
|
+
function vn(e) {
|
|
1191
1242
|
return e >= 55296 && e <= 56319;
|
|
1192
1243
|
}
|
|
1193
|
-
function
|
|
1244
|
+
function yn(e) {
|
|
1194
1245
|
return `[Element ${(e.nodeName ?? "NODE").toLowerCase()}${e.id ? `#${e.id}` : ""}${typeof e.className == "string" && e.className ? `.${e.className.trim().split(/\s+/).slice(0, 3).join(".")}` : ""}]`;
|
|
1195
1246
|
}
|
|
1196
|
-
function
|
|
1197
|
-
let n = {
|
|
1247
|
+
function H(e, t) {
|
|
1248
|
+
let n = {
|
|
1249
|
+
bytes: 0,
|
|
1250
|
+
nodes: 0
|
|
1251
|
+
};
|
|
1198
1252
|
return {
|
|
1199
|
-
value:
|
|
1253
|
+
value: W(e, t, /* @__PURE__ */ new WeakSet(), 0, n),
|
|
1200
1254
|
bytes: n.bytes
|
|
1201
1255
|
};
|
|
1202
1256
|
}
|
|
1203
|
-
function
|
|
1204
|
-
return t.bytes +=
|
|
1257
|
+
function U(e, t) {
|
|
1258
|
+
return t.bytes += G(e) + 2, e;
|
|
1205
1259
|
}
|
|
1206
|
-
function
|
|
1260
|
+
function W(e, t, n, r, i) {
|
|
1261
|
+
if (i.nodes++, i.nodes > t.maxNodes) return U("[MaxNodes]", i);
|
|
1207
1262
|
if (e == null) return i.bytes += 4, e;
|
|
1208
|
-
if (typeof e == "string") return
|
|
1263
|
+
if (typeof e == "string") return U(V(e, t.maxAttributeChars), i);
|
|
1209
1264
|
if (typeof e == "number") return i.bytes += 8, Number.isFinite(e) ? e : String(e);
|
|
1210
1265
|
if (typeof e == "boolean") return i.bytes += 5, e;
|
|
1211
|
-
if (typeof e == "bigint") return
|
|
1212
|
-
if (typeof e == "symbol") return
|
|
1213
|
-
if (typeof e == "function") return
|
|
1214
|
-
if (r >= t.maxDepth) return
|
|
1215
|
-
if (n.has(e)) return
|
|
1266
|
+
if (typeof e == "bigint") return U(`${e.toString()}n`, i);
|
|
1267
|
+
if (typeof e == "symbol") return U(e.toString(), i);
|
|
1268
|
+
if (typeof e == "function") return U(`[Function ${e.name === "" ? "anonymous" : e.name}]`, i);
|
|
1269
|
+
if (r >= t.maxDepth) return U("[MaxDepth]", i);
|
|
1270
|
+
if (n.has(e)) return U("[Circular]", i);
|
|
1216
1271
|
n.add(e), i.bytes += 2;
|
|
1217
1272
|
try {
|
|
1218
1273
|
if (e instanceof Error) return {
|
|
1219
|
-
name:
|
|
1220
|
-
message:
|
|
1221
|
-
stack: e.stack ?
|
|
1222
|
-
cause: e.cause ?
|
|
1274
|
+
name: U(e.name, i),
|
|
1275
|
+
message: U(V(e.message, t.maxAttributeChars), i),
|
|
1276
|
+
stack: e.stack ? U(V(e.stack, t.maxStackChars), i) : void 0,
|
|
1277
|
+
cause: e.cause ? W(e.cause, t, n, r + 1, i) : void 0
|
|
1223
1278
|
};
|
|
1224
|
-
if (e instanceof Date) return
|
|
1225
|
-
if (e instanceof RegExp) return
|
|
1279
|
+
if (e instanceof Date) return U(e.toISOString(), i);
|
|
1280
|
+
if (e instanceof RegExp) return U(e.toString(), i);
|
|
1226
1281
|
if (e instanceof Map) {
|
|
1227
1282
|
let a = e, o = {}, s = 0;
|
|
1228
1283
|
for (let [e, c] of a) {
|
|
1229
1284
|
if (s >= t.maxArrayLength) {
|
|
1230
|
-
o["…"] =
|
|
1285
|
+
o["…"] = U(`[${String(a.size - t.maxArrayLength)} more entries]`, i);
|
|
1231
1286
|
break;
|
|
1232
1287
|
}
|
|
1233
1288
|
s++;
|
|
1234
1289
|
let l = String(e);
|
|
1235
|
-
i.bytes +=
|
|
1290
|
+
i.bytes += G(l) + 4, o[l] = W(c, t, n, r + 1, i);
|
|
1236
1291
|
}
|
|
1237
1292
|
return o;
|
|
1238
1293
|
}
|
|
1239
|
-
if (e instanceof Set) return
|
|
1294
|
+
if (e instanceof Set) return W([...e].slice(0, t.maxArrayLength), t, n, r, i);
|
|
1240
1295
|
if (ArrayBuffer.isView(e)) {
|
|
1241
1296
|
let t = e.length ?? 0;
|
|
1242
|
-
return
|
|
1297
|
+
return U(`[${e.constructor.name}(${String(t)})]`, i);
|
|
1243
1298
|
}
|
|
1244
|
-
if (e instanceof Promise) return
|
|
1245
|
-
if (typeof Node < "u" && e instanceof Node) return
|
|
1299
|
+
if (e instanceof Promise) return U("[Promise]", i);
|
|
1300
|
+
if (typeof Node < "u" && e instanceof Node) return U(yn(e), i);
|
|
1246
1301
|
if (Array.isArray(e)) {
|
|
1247
|
-
let a = e, o = a.slice(0, t.maxArrayLength).map((e) =>
|
|
1248
|
-
return a.length > t.maxArrayLength && o.push(
|
|
1302
|
+
let a = e, o = a.slice(0, t.maxArrayLength).map((e) => W(e, t, n, r + 1, i));
|
|
1303
|
+
return a.length > t.maxArrayLength && o.push(U(`[${String(a.length - t.maxArrayLength)} more items]`, i)), o;
|
|
1249
1304
|
}
|
|
1250
1305
|
let a = e.toJSON;
|
|
1251
|
-
if (typeof a == "function") return
|
|
1306
|
+
if (typeof a == "function") return W(a.call(e), t, n, r + 1, i);
|
|
1252
1307
|
let o = e, s = Object.keys(o), c = {}, l = 0;
|
|
1253
1308
|
for (let e of s) {
|
|
1254
1309
|
if (l >= t.maxAttributeCount) {
|
|
1255
|
-
c["…"] =
|
|
1310
|
+
c["…"] = U(`[${String(s.length - l)} more keys]`, i);
|
|
1256
1311
|
break;
|
|
1257
1312
|
}
|
|
1258
|
-
l++, i.bytes +=
|
|
1313
|
+
l++, i.bytes += G(e) + 4, c[e] = W(o[e], t, n, r + 1, i);
|
|
1259
1314
|
}
|
|
1260
1315
|
return c;
|
|
1261
1316
|
} catch (e) {
|
|
1262
|
-
return
|
|
1317
|
+
return U(`[Unserializable: ${e instanceof Error ? e.name : "error"}]`, i);
|
|
1263
1318
|
} finally {
|
|
1264
1319
|
n.delete(e);
|
|
1265
1320
|
}
|
|
1266
1321
|
}
|
|
1267
|
-
function
|
|
1322
|
+
function G(e) {
|
|
1268
1323
|
let t = 0;
|
|
1269
1324
|
for (let n = 0; n < e.length; n++) {
|
|
1270
1325
|
let r = e.charCodeAt(n);
|
|
@@ -1274,7 +1329,7 @@ function H(e) {
|
|
|
1274
1329
|
}
|
|
1275
1330
|
//#endregion
|
|
1276
1331
|
//#region src/transport/exit-flush.ts
|
|
1277
|
-
var
|
|
1332
|
+
var bn = class {
|
|
1278
1333
|
deps;
|
|
1279
1334
|
installed = !1;
|
|
1280
1335
|
onVisibility = () => {
|
|
@@ -1311,17 +1366,26 @@ var vn = class {
|
|
|
1311
1366
|
flush(e) {
|
|
1312
1367
|
let { diagnostics: t } = this.deps, n = this.endpointUrl();
|
|
1313
1368
|
if (n === null) return;
|
|
1314
|
-
let r = this.
|
|
1369
|
+
let r = this.drain(e);
|
|
1315
1370
|
if (!r || r.records.length === 0) return;
|
|
1316
1371
|
let i = t.guard("transport.serialize_failed", `the ${e} exit flush could not serialize its batch`, () => this.deps.config.serializer.serialize(r.records));
|
|
1317
1372
|
if (!i) return;
|
|
1318
|
-
if (
|
|
1319
|
-
|
|
1373
|
+
if (G(i.body) > 6e4) {
|
|
1374
|
+
cn(r, t);
|
|
1320
1375
|
return;
|
|
1321
1376
|
}
|
|
1322
|
-
n.searchParams.set(
|
|
1323
|
-
let a = n.toString();
|
|
1324
|
-
|
|
1377
|
+
n.searchParams.set(Ce, r.id), n.searchParams.set(gt, e);
|
|
1378
|
+
let a = n.toString(), o = this.beacon(a, i.body);
|
|
1379
|
+
if (o !== "sent") {
|
|
1380
|
+
if (o === "refused") {
|
|
1381
|
+
cn(r, t);
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
this.keepaliveFetch(a, i.body, e);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
drain(e) {
|
|
1388
|
+
return e === "hidden" ? this.deps.drainPending() : this.deps.drainForExit();
|
|
1325
1389
|
}
|
|
1326
1390
|
endpointUrl() {
|
|
1327
1391
|
let { endpoint: e } = this.deps.config;
|
|
@@ -1329,17 +1393,17 @@ var vn = class {
|
|
|
1329
1393
|
}
|
|
1330
1394
|
beacon(e, t) {
|
|
1331
1395
|
return this.deps.diagnostics.guard("transport.http_error", "sendBeacon", () => {
|
|
1332
|
-
let
|
|
1333
|
-
return
|
|
1334
|
-
})
|
|
1396
|
+
let n = globalThis.navigator;
|
|
1397
|
+
return n?.sendBeacon ? n.sendBeacon(e, new Blob([t], { type: "text/plain;charset=UTF-8" })) ? "sent" : "refused" : "unavailable";
|
|
1398
|
+
}) ?? "unavailable";
|
|
1335
1399
|
}
|
|
1336
|
-
keepaliveFetch(e,
|
|
1400
|
+
keepaliveFetch(e, n, r) {
|
|
1337
1401
|
let { config: i, diagnostics: a } = this.deps;
|
|
1338
1402
|
a.guard("transport.http_error", "the keepalive fetch fallback", () => {
|
|
1339
1403
|
fetch(e, {
|
|
1340
1404
|
method: "POST",
|
|
1341
|
-
body:
|
|
1342
|
-
headers: { [
|
|
1405
|
+
body: n,
|
|
1406
|
+
headers: { [ee]: t },
|
|
1343
1407
|
credentials: i.credentials,
|
|
1344
1408
|
keepalive: !0
|
|
1345
1409
|
}).catch((e) => {
|
|
@@ -1350,15 +1414,15 @@ var vn = class {
|
|
|
1350
1414
|
};
|
|
1351
1415
|
//#endregion
|
|
1352
1416
|
//#region src/transport/compression.ts
|
|
1353
|
-
async function
|
|
1417
|
+
async function xn(e) {
|
|
1354
1418
|
let t = globalThis.CompressionStream;
|
|
1355
1419
|
if (t === void 0) return null;
|
|
1356
|
-
let n = new Blob([e]).stream().pipeThrough(new t(
|
|
1420
|
+
let n = new Blob([e]).stream().pipeThrough(new t(bt)), r = await new Response(n).arrayBuffer();
|
|
1357
1421
|
return new Uint8Array(r);
|
|
1358
1422
|
}
|
|
1359
1423
|
//#endregion
|
|
1360
1424
|
//#region src/transport/errors.ts
|
|
1361
|
-
var
|
|
1425
|
+
var K = class extends Error {
|
|
1362
1426
|
kind;
|
|
1363
1427
|
status;
|
|
1364
1428
|
retryAfterMs;
|
|
@@ -1367,16 +1431,16 @@ var U = class extends Error {
|
|
|
1367
1431
|
super(t), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
|
|
1368
1432
|
}
|
|
1369
1433
|
};
|
|
1370
|
-
function
|
|
1434
|
+
function Sn(e) {
|
|
1371
1435
|
if (!e) return;
|
|
1372
1436
|
let t = Number(e);
|
|
1373
|
-
if (Number.isFinite(t)) return Math.max(0, t *
|
|
1437
|
+
if (Number.isFinite(t)) return Math.max(0, t * ht);
|
|
1374
1438
|
let n = Date.parse(e);
|
|
1375
1439
|
return Number.isNaN(n) ? void 0 : Math.max(0, n - Date.now());
|
|
1376
1440
|
}
|
|
1377
1441
|
//#endregion
|
|
1378
1442
|
//#region src/transport/http-transport.ts
|
|
1379
|
-
var
|
|
1443
|
+
var Cn = class {
|
|
1380
1444
|
config;
|
|
1381
1445
|
diagnostics;
|
|
1382
1446
|
throttledUntil = 0;
|
|
@@ -1398,9 +1462,9 @@ var xn = class {
|
|
|
1398
1462
|
return;
|
|
1399
1463
|
}
|
|
1400
1464
|
let r = new Headers(await this.resolveHeaders());
|
|
1401
|
-
r.set(
|
|
1465
|
+
r.set(ee, n.contentType), r.set(ne, e.id), r.set(f, String(e.attempts));
|
|
1402
1466
|
let i = await this.encodeBody(n.body);
|
|
1403
|
-
typeof i != "string" && r.set(
|
|
1467
|
+
typeof i != "string" && r.set(rt, bt);
|
|
1404
1468
|
let a = await this.dispatch(r, i);
|
|
1405
1469
|
if (a.ok) {
|
|
1406
1470
|
this.throttledUntil = 0;
|
|
@@ -1410,13 +1474,13 @@ var xn = class {
|
|
|
1410
1474
|
}
|
|
1411
1475
|
async encodeBody(e) {
|
|
1412
1476
|
let { config: t } = this;
|
|
1413
|
-
return t.compression !== "gzip" ||
|
|
1477
|
+
return t.compression !== "gzip" || G(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "gzipping the payload", () => xn(e)) ?? e;
|
|
1414
1478
|
}
|
|
1415
1479
|
async dispatch(e, t) {
|
|
1416
1480
|
let { config: n } = this, r = new AbortController(), i = setTimeout(() => {
|
|
1417
1481
|
r.abort();
|
|
1418
|
-
},
|
|
1419
|
-
|
|
1482
|
+
}, yt);
|
|
1483
|
+
D(i);
|
|
1420
1484
|
try {
|
|
1421
1485
|
return await fetch(n.endpoint, {
|
|
1422
1486
|
method: "POST",
|
|
@@ -1427,28 +1491,28 @@ var xn = class {
|
|
|
1427
1491
|
cache: "no-store"
|
|
1428
1492
|
});
|
|
1429
1493
|
} catch {
|
|
1430
|
-
if (r.signal.aborted) throw new
|
|
1494
|
+
if (r.signal.aborted) throw new K("timeout", `request exceeded ${String(yt)}ms`);
|
|
1431
1495
|
let e = globalThis.navigator?.onLine;
|
|
1432
|
-
throw new
|
|
1496
|
+
throw new K(e === !1 ? "offline" : "transient", "network error");
|
|
1433
1497
|
} finally {
|
|
1434
1498
|
clearTimeout(i);
|
|
1435
1499
|
}
|
|
1436
1500
|
}
|
|
1437
1501
|
async classify(e, t) {
|
|
1438
|
-
let n = e.status, r =
|
|
1502
|
+
let n = e.status, r = Sn(e.headers.get(be));
|
|
1439
1503
|
if (n === 401 || n === 403) return this.diagnostics.report("transport.rejected_credentials", `server returned ${String(n)}. In a cross-origin iframe the session cookie is a third-party cookie and is very likely blocked. Forward to the platform document instead of promoting to sender, or issue the cookie with the Partitioned attribute.`, {
|
|
1440
1504
|
status: n,
|
|
1441
1505
|
endpoint: this.config.endpoint
|
|
1442
|
-
}), new
|
|
1443
|
-
if (n === 413) return new
|
|
1506
|
+
}), new K("permanent", `rejected with ${String(n)}`, n);
|
|
1507
|
+
if (n === 413) return new K("too_large", "payload too large", n, void 0, await this.readMaxBytes(e));
|
|
1444
1508
|
if (n === 429 || n === 503) {
|
|
1445
1509
|
let e = n === 429;
|
|
1446
|
-
return this.throttledUntil = Date.now() + (r ?? 2e3), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new
|
|
1510
|
+
return this.throttledUntil = Date.now() + (r ?? 2e3), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new K("throttled", e ? "throttled" : "service unavailable", n, r);
|
|
1447
1511
|
}
|
|
1448
|
-
return n === 408 || n >= 500 ? new
|
|
1512
|
+
return n === 408 || n >= 500 ? new K("transient", `server error ${String(n)}`, n) : (this.diagnostics.report("transport.dropped_permanent", `server rejected the batch with ${String(n)}, dropping it`, {
|
|
1449
1513
|
batchId: t,
|
|
1450
1514
|
status: n
|
|
1451
|
-
}), new
|
|
1515
|
+
}), new K("permanent", `rejected with ${String(n)}`, n));
|
|
1452
1516
|
}
|
|
1453
1517
|
async readMaxBytes(e) {
|
|
1454
1518
|
return this.diagnostics.guardAsync("transport.http_error", "reading the 413 body", async () => {
|
|
@@ -1460,7 +1524,7 @@ var xn = class {
|
|
|
1460
1524
|
let { headers: e } = this.config;
|
|
1461
1525
|
return e ? typeof e == "function" ? await this.diagnostics.guardAsync("transport.http_error", "headers() threw", () => Promise.resolve(e())) ?? {} : e : {};
|
|
1462
1526
|
}
|
|
1463
|
-
},
|
|
1527
|
+
}, wn = class {
|
|
1464
1528
|
storage;
|
|
1465
1529
|
transport;
|
|
1466
1530
|
diagnostics;
|
|
@@ -1477,10 +1541,15 @@ var xn = class {
|
|
|
1477
1541
|
this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i;
|
|
1478
1542
|
}
|
|
1479
1543
|
start() {
|
|
1480
|
-
this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(
|
|
1544
|
+
this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(_);
|
|
1481
1545
|
}
|
|
1482
1546
|
nudge() {
|
|
1483
|
-
this.draining || this.schedule(
|
|
1547
|
+
this.draining || this.schedule(d);
|
|
1548
|
+
}
|
|
1549
|
+
async storeFailed(e, t) {
|
|
1550
|
+
let n = this.toStorable(e, t);
|
|
1551
|
+
for (let e of n) await this.bounded(this.storage.save(e));
|
|
1552
|
+
n.length > 0 && this.nudge();
|
|
1484
1553
|
}
|
|
1485
1554
|
stop() {
|
|
1486
1555
|
this.stopped = !0, typeof removeEventListener < "u" && removeEventListener("online", this.onOnline), this.clearTimer();
|
|
@@ -1491,20 +1560,23 @@ var xn = class {
|
|
|
1491
1560
|
let t = setTimeout(() => {
|
|
1492
1561
|
this.drain();
|
|
1493
1562
|
}, e);
|
|
1494
|
-
this.timer = t,
|
|
1563
|
+
this.timer = t, D(t);
|
|
1564
|
+
}
|
|
1565
|
+
bounded(e) {
|
|
1566
|
+
return R(e, v);
|
|
1495
1567
|
}
|
|
1496
1568
|
clearTimer() {
|
|
1497
1569
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
1498
1570
|
}
|
|
1499
1571
|
backoffMs() {
|
|
1500
|
-
let e = Math.min(
|
|
1572
|
+
let e = Math.min(d * 2 ** this.attempt, re);
|
|
1501
1573
|
return Math.random() * e;
|
|
1502
1574
|
}
|
|
1503
1575
|
async drain() {
|
|
1504
1576
|
if (!this.draining) {
|
|
1505
1577
|
this.draining = !0;
|
|
1506
1578
|
try {
|
|
1507
|
-
await
|
|
1579
|
+
await rn("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(_);
|
|
1508
1580
|
} finally {
|
|
1509
1581
|
this.draining = !1;
|
|
1510
1582
|
}
|
|
@@ -1512,68 +1584,74 @@ var xn = class {
|
|
|
1512
1584
|
}
|
|
1513
1585
|
async drainLocked() {
|
|
1514
1586
|
try {
|
|
1515
|
-
if (globalThis.navigator?.onLine === !1) return this.schedule(
|
|
1516
|
-
let e = await this.storage.take(this.batchesPerDrain);
|
|
1517
|
-
if (e.length === 0) return this.schedule(
|
|
1587
|
+
if (globalThis.navigator?.onLine === !1) return this.schedule(_), !0;
|
|
1588
|
+
let e = await this.bounded(this.storage.take(this.batchesPerDrain));
|
|
1589
|
+
if (e.length === 0) return this.schedule(_), !0;
|
|
1518
1590
|
for (let t of e) if (this.stopped || !await this.deliver(t)) return !0;
|
|
1519
|
-
return this.schedule(e.length === this.batchesPerDrain ? 0 :
|
|
1591
|
+
return this.schedule(e.length === this.batchesPerDrain ? 0 : _), !0;
|
|
1520
1592
|
} catch (e) {
|
|
1521
1593
|
return this.diagnostics.report("storage.degraded", "the drain loop threw", void 0, e), this.attempt++, this.schedule(this.backoffMs()), !0;
|
|
1522
1594
|
}
|
|
1523
1595
|
}
|
|
1524
1596
|
async deliver(e) {
|
|
1525
|
-
if (e.attempts >=
|
|
1597
|
+
if (e.attempts >= it.maxAttempts) return this.diagnostics.report("storage.dead_lettered", `giving up on a batch after ${e.attempts.toString()} attempts`, {
|
|
1526
1598
|
batchId: e.id,
|
|
1527
1599
|
records: e.records.length
|
|
1528
|
-
}), await this.storage.remove(e.id), !0;
|
|
1600
|
+
}), await this.bounded(this.storage.remove(e.id)), !0;
|
|
1529
1601
|
try {
|
|
1530
|
-
return await this.transport.send(e), await this.storage.remove(e.id), this.attempt = 0, !0;
|
|
1602
|
+
return await this.transport.send(e), await this.bounded(this.storage.remove(e.id)), this.attempt = 0, !0;
|
|
1531
1603
|
} catch (t) {
|
|
1532
|
-
let n = t instanceof
|
|
1533
|
-
return n?.kind === "permanent" ? (await this.
|
|
1604
|
+
let n = t instanceof K ? t : void 0;
|
|
1605
|
+
return n?.kind === "permanent" || n?.kind === "too_large" ? (await this.replaceStored(e, t), !0) : n?.kind === "offline" ? (this.schedule(_), !1) : n?.kind === "throttled" ? (this.attempt++, this.schedule(n.retryAfterMs ?? this.backoffMs()), !1) : (await this.bounded(this.storage.bumpAttempts(e.id, e.attempts + 1)), this.attempt++, this.schedule(n?.retryAfterMs ?? this.backoffMs()), !1);
|
|
1534
1606
|
}
|
|
1535
1607
|
}
|
|
1536
|
-
async
|
|
1537
|
-
let n =
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1608
|
+
async replaceStored(e, t) {
|
|
1609
|
+
let n = this.toStorable(e, t);
|
|
1610
|
+
await this.bounded(this.storage.remove(e.id));
|
|
1611
|
+
for (let e of n) await this.bounded(this.storage.save(e));
|
|
1612
|
+
}
|
|
1613
|
+
toStorable(e, t) {
|
|
1614
|
+
let n = t instanceof K ? t : void 0;
|
|
1615
|
+
if (n?.kind === "permanent") return [];
|
|
1616
|
+
if (n?.kind !== "too_large") return [e];
|
|
1617
|
+
let r = nn(e);
|
|
1618
|
+
return r ? (this.diagnostics.report("transport.batch_split", "the server refused the batch as too large", {
|
|
1546
1619
|
from: e.records.length,
|
|
1547
|
-
to:
|
|
1548
|
-
serverMaxBytes:
|
|
1549
|
-
})
|
|
1550
|
-
|
|
1620
|
+
to: r[0].records.length,
|
|
1621
|
+
serverMaxBytes: n.maxBytes
|
|
1622
|
+
}), r) : (this.diagnostics.report("transport.dropped_permanent", "a single record exceeds the server limit and was dropped", {
|
|
1623
|
+
batchId: e.id,
|
|
1624
|
+
bodies: e.records.map((e) => e.body)
|
|
1625
|
+
}), []);
|
|
1551
1626
|
}
|
|
1552
|
-
},
|
|
1627
|
+
}, Tn = {
|
|
1553
1628
|
TRACE: "debug",
|
|
1554
1629
|
DEBUG: "debug",
|
|
1555
1630
|
INFO: "info",
|
|
1556
1631
|
WARN: "warn",
|
|
1557
1632
|
ERROR: "error",
|
|
1558
1633
|
FATAL: "error"
|
|
1559
|
-
},
|
|
1634
|
+
}, En = class {
|
|
1560
1635
|
minLevel;
|
|
1561
|
-
|
|
1562
|
-
|
|
1636
|
+
diagnostics;
|
|
1637
|
+
constructor(e, t) {
|
|
1638
|
+
this.minLevel = e, this.diagnostics = t;
|
|
1563
1639
|
}
|
|
1564
1640
|
update(e) {
|
|
1565
1641
|
this.minLevel = e;
|
|
1566
1642
|
}
|
|
1567
1643
|
write(e, t, n) {
|
|
1568
|
-
if (this.minLevel === null ||
|
|
1569
|
-
let r = `%c${
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1644
|
+
if (this.minLevel === null || x[e] < x[this.minLevel] || typeof console > "u") return;
|
|
1645
|
+
let r = `%c${Ee}%c ${e}`, i = Tn[e];
|
|
1646
|
+
this.diagnostics.guard("handler.threw", `mirroring to console.${i}`, () => {
|
|
1647
|
+
if (n === void 0) {
|
|
1648
|
+
console[i](r, o, "", t);
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
console[i](r, o, "", t, n);
|
|
1652
|
+
});
|
|
1575
1653
|
}
|
|
1576
|
-
},
|
|
1654
|
+
}, Dn = class {
|
|
1577
1655
|
value = 0;
|
|
1578
1656
|
next() {
|
|
1579
1657
|
return ++this.value;
|
|
@@ -1581,44 +1659,44 @@ var xn = class {
|
|
|
1581
1659
|
reset() {
|
|
1582
1660
|
this.value = 0;
|
|
1583
1661
|
}
|
|
1584
|
-
},
|
|
1585
|
-
function
|
|
1662
|
+
}, On = /^[0-9a-f]{32}$/, kn = /^[0-9a-f]{16}$/, An = /[1-9a-f]/;
|
|
1663
|
+
function jn() {
|
|
1586
1664
|
return import(
|
|
1587
1665
|
/* @vite-ignore */
|
|
1588
1666
|
"@opentelemetry/api"
|
|
1589
1667
|
);
|
|
1590
1668
|
}
|
|
1591
|
-
function
|
|
1592
|
-
return
|
|
1669
|
+
function Mn(e) {
|
|
1670
|
+
return On.test(e.traceId) && An.test(e.traceId) && kn.test(e.spanId) && An.test(e.spanId);
|
|
1593
1671
|
}
|
|
1594
|
-
function
|
|
1595
|
-
return
|
|
1672
|
+
function Nn() {
|
|
1673
|
+
return F(16);
|
|
1596
1674
|
}
|
|
1597
|
-
function
|
|
1598
|
-
return
|
|
1675
|
+
function Pn() {
|
|
1676
|
+
return F(8);
|
|
1599
1677
|
}
|
|
1600
|
-
function
|
|
1678
|
+
function Fn() {
|
|
1601
1679
|
return {
|
|
1602
|
-
traceId:
|
|
1603
|
-
spanId:
|
|
1680
|
+
traceId: Nn(),
|
|
1681
|
+
spanId: Pn(),
|
|
1604
1682
|
traceFlags: 1,
|
|
1605
1683
|
startedAt: Date.now()
|
|
1606
1684
|
};
|
|
1607
1685
|
}
|
|
1608
|
-
function
|
|
1686
|
+
function In(e) {
|
|
1609
1687
|
return {
|
|
1610
1688
|
traceId: e.traceId,
|
|
1611
1689
|
spanId: e.spanId,
|
|
1612
1690
|
traceFlags: e.traceFlags
|
|
1613
1691
|
};
|
|
1614
1692
|
}
|
|
1615
|
-
var
|
|
1693
|
+
var Ln = class {
|
|
1616
1694
|
diagnostics;
|
|
1617
1695
|
maxAgeMs;
|
|
1618
1696
|
load;
|
|
1619
|
-
ambient =
|
|
1697
|
+
ambient = Fn();
|
|
1620
1698
|
otel;
|
|
1621
|
-
constructor(e, t =
|
|
1699
|
+
constructor(e, t = Te, n = jn) {
|
|
1622
1700
|
this.diagnostics = e, this.maxAgeMs = t, this.load = n;
|
|
1623
1701
|
}
|
|
1624
1702
|
async loadOtel() {
|
|
@@ -1630,7 +1708,7 @@ var Fn = class {
|
|
|
1630
1708
|
}
|
|
1631
1709
|
resolve() {
|
|
1632
1710
|
let e = this.activeSpanContext();
|
|
1633
|
-
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"),
|
|
1711
|
+
return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), In(this.ambient)) : e;
|
|
1634
1712
|
}
|
|
1635
1713
|
activeSpanContext() {
|
|
1636
1714
|
let e = this.otel;
|
|
@@ -1638,7 +1716,7 @@ var Fn = class {
|
|
|
1638
1716
|
let t = e.trace.getActiveSpan();
|
|
1639
1717
|
if (t === void 0) return;
|
|
1640
1718
|
let n = t.spanContext();
|
|
1641
|
-
if (
|
|
1719
|
+
if (Mn(n)) return {
|
|
1642
1720
|
traceId: n.traceId,
|
|
1643
1721
|
spanId: n.spanId,
|
|
1644
1722
|
traceFlags: n.traceFlags
|
|
@@ -1646,7 +1724,7 @@ var Fn = class {
|
|
|
1646
1724
|
});
|
|
1647
1725
|
}
|
|
1648
1726
|
rotate(e) {
|
|
1649
|
-
return this.ambient =
|
|
1727
|
+
return this.ambient = Fn(), In(this.ambient);
|
|
1650
1728
|
}
|
|
1651
1729
|
headers() {
|
|
1652
1730
|
let e = {}, t = this.otel;
|
|
@@ -1654,11 +1732,11 @@ var Fn = class {
|
|
|
1654
1732
|
t.propagation.inject(t.context.active(), e);
|
|
1655
1733
|
}), !e.traceparent) {
|
|
1656
1734
|
let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
|
|
1657
|
-
e[
|
|
1735
|
+
e[He] = `00-${t.traceId}-${t.spanId}-${n}`;
|
|
1658
1736
|
}
|
|
1659
1737
|
return e;
|
|
1660
1738
|
}
|
|
1661
|
-
},
|
|
1739
|
+
}, Rn = class {
|
|
1662
1740
|
buffer;
|
|
1663
1741
|
pointer = 0;
|
|
1664
1742
|
filled = !1;
|
|
@@ -1678,47 +1756,79 @@ var Fn = class {
|
|
|
1678
1756
|
};
|
|
1679
1757
|
//#endregion
|
|
1680
1758
|
//#region src/transport/serializers/ecs.ts
|
|
1681
|
-
function
|
|
1682
|
-
return
|
|
1759
|
+
function zn(e) {
|
|
1760
|
+
return Ie.test(e) ? Number(BigInt(e) / nt) : Date.now();
|
|
1761
|
+
}
|
|
1762
|
+
function Bn(e) {
|
|
1763
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : typeof e == "bigint" ? e.toString() : null;
|
|
1764
|
+
}
|
|
1765
|
+
function Vn(e, t, n) {
|
|
1766
|
+
let r = e[t];
|
|
1767
|
+
if (r === void 0) {
|
|
1768
|
+
e[t] = n;
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
if (Array.isArray(r)) {
|
|
1772
|
+
r.push(n);
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
e[t] = [r, n];
|
|
1776
|
+
}
|
|
1777
|
+
function Hn(e, t, n, r) {
|
|
1778
|
+
let i = Bn(n);
|
|
1779
|
+
if (i !== null) {
|
|
1780
|
+
Vn(e, t, i);
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
if (!(typeof n != "object" || !n || r.has(n))) {
|
|
1784
|
+
if (r.add(n), Array.isArray(n)) for (let i of n) Hn(e, t, i, r);
|
|
1785
|
+
else for (let [i, a] of Object.entries(n)) Hn(e, `${t}.${i}`, a, r);
|
|
1786
|
+
r.delete(n);
|
|
1787
|
+
}
|
|
1683
1788
|
}
|
|
1684
|
-
|
|
1789
|
+
function Un(e) {
|
|
1790
|
+
let t = Object.create(null), n = /* @__PURE__ */ new WeakSet();
|
|
1791
|
+
for (let [r, i] of Object.entries(e)) Hn(t, r, i, n);
|
|
1792
|
+
return t;
|
|
1793
|
+
}
|
|
1794
|
+
var Wn = {
|
|
1685
1795
|
name: "ecs",
|
|
1686
1796
|
serialize(e) {
|
|
1687
1797
|
return {
|
|
1688
1798
|
body: `${e.map((e) => {
|
|
1689
|
-
let t =
|
|
1799
|
+
let t = zn(e.timeUnixNano);
|
|
1690
1800
|
return JSON.stringify({
|
|
1691
1801
|
"@timestamp": new Date(t).toISOString(),
|
|
1692
1802
|
message: e.body,
|
|
1693
|
-
log: { level: e.severityText.toLowerCase() },
|
|
1803
|
+
log: { level: g[e.severityText] ?? e.severityText.toLowerCase() },
|
|
1694
1804
|
trace: { id: e.traceId },
|
|
1695
1805
|
span: { id: e.spanId },
|
|
1696
1806
|
service: {
|
|
1697
|
-
name: e.resource[
|
|
1698
|
-
version: e.resource[
|
|
1699
|
-
environment: e.resource[
|
|
1807
|
+
name: e.resource[le],
|
|
1808
|
+
version: e.resource[Ke],
|
|
1809
|
+
environment: e.resource[_t]
|
|
1700
1810
|
},
|
|
1701
|
-
user_agent: { original: e.resource[
|
|
1811
|
+
user_agent: { original: e.resource[me] },
|
|
1702
1812
|
url: { full: e.attributes["url.full"] ?? e.attributes["page.url"] },
|
|
1703
1813
|
labels: {
|
|
1704
|
-
...e.resource,
|
|
1705
|
-
...e.attributes
|
|
1814
|
+
...Un(e.resource),
|
|
1815
|
+
...Un(e.attributes)
|
|
1706
1816
|
}
|
|
1707
1817
|
});
|
|
1708
1818
|
}).join("\n")}\n`,
|
|
1709
|
-
contentType:
|
|
1819
|
+
contentType: Ge
|
|
1710
1820
|
};
|
|
1711
1821
|
}
|
|
1712
1822
|
};
|
|
1713
1823
|
//#endregion
|
|
1714
1824
|
//#region src/transport/serializers/otlp.ts
|
|
1715
|
-
function
|
|
1716
|
-
return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(
|
|
1825
|
+
function Gn(e) {
|
|
1826
|
+
return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(Gn).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: Kn(e) } } : null;
|
|
1717
1827
|
}
|
|
1718
|
-
function
|
|
1828
|
+
function Kn(e) {
|
|
1719
1829
|
let t = [];
|
|
1720
1830
|
for (let [n, r] of Object.entries(e)) {
|
|
1721
|
-
let e =
|
|
1831
|
+
let e = Gn(r);
|
|
1722
1832
|
e && t.push({
|
|
1723
1833
|
key: n,
|
|
1724
1834
|
value: e
|
|
@@ -1726,19 +1836,19 @@ function W(e) {
|
|
|
1726
1836
|
}
|
|
1727
1837
|
return t;
|
|
1728
1838
|
}
|
|
1729
|
-
var
|
|
1730
|
-
function
|
|
1731
|
-
let t =
|
|
1839
|
+
var qn = /* @__PURE__ */ new WeakMap();
|
|
1840
|
+
function Jn(e) {
|
|
1841
|
+
let t = qn.get(e);
|
|
1732
1842
|
if (t !== void 0) return t;
|
|
1733
1843
|
let n = JSON.stringify(e);
|
|
1734
|
-
return
|
|
1844
|
+
return qn.set(e, n), n;
|
|
1735
1845
|
}
|
|
1736
|
-
var
|
|
1737
|
-
name:
|
|
1846
|
+
var Yn = {
|
|
1847
|
+
name: r,
|
|
1738
1848
|
serialize(e) {
|
|
1739
1849
|
let t = /* @__PURE__ */ new Map();
|
|
1740
1850
|
for (let n of e) {
|
|
1741
|
-
let e =
|
|
1851
|
+
let e = Jn(n.resource), r = t.get(e);
|
|
1742
1852
|
if (r) {
|
|
1743
1853
|
r.records.push(n);
|
|
1744
1854
|
continue;
|
|
@@ -1749,11 +1859,11 @@ var G = {
|
|
|
1749
1859
|
});
|
|
1750
1860
|
}
|
|
1751
1861
|
let n = [...t.values()].map((e) => ({
|
|
1752
|
-
resource: { attributes:
|
|
1862
|
+
resource: { attributes: Kn(e.resource) },
|
|
1753
1863
|
scopeLogs: [{
|
|
1754
1864
|
scope: {
|
|
1755
|
-
name:
|
|
1756
|
-
version:
|
|
1865
|
+
name: Ze,
|
|
1866
|
+
version: ot
|
|
1757
1867
|
},
|
|
1758
1868
|
logRecords: e.records.map((e) => ({
|
|
1759
1869
|
timeUnixNano: e.timeUnixNano,
|
|
@@ -1764,33 +1874,33 @@ var G = {
|
|
|
1764
1874
|
traceId: e.traceId,
|
|
1765
1875
|
spanId: e.spanId,
|
|
1766
1876
|
flags: e.traceFlags,
|
|
1767
|
-
attributes:
|
|
1877
|
+
attributes: Kn(e.attributes)
|
|
1768
1878
|
}))
|
|
1769
1879
|
}]
|
|
1770
1880
|
}));
|
|
1771
1881
|
return {
|
|
1772
1882
|
body: JSON.stringify({ resourceLogs: n }),
|
|
1773
|
-
contentType:
|
|
1883
|
+
contentType: ce
|
|
1774
1884
|
};
|
|
1775
1885
|
}
|
|
1776
1886
|
};
|
|
1777
1887
|
//#endregion
|
|
1778
1888
|
//#region src/core/config.ts
|
|
1779
|
-
function
|
|
1889
|
+
function Xn(e) {
|
|
1780
1890
|
return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
|
|
1781
1891
|
}
|
|
1782
|
-
function
|
|
1783
|
-
return e === void 0 ? t ??
|
|
1892
|
+
function Zn(e, t, n) {
|
|
1893
|
+
return e === void 0 ? t ?? Yn : e === "otlp" ? Yn : e === "ecs" ? Wn : Xn(e) ? e : (n.report("config.invalid", `serializer must be "${r}", "ecs" or an implementation`), Yn);
|
|
1784
1894
|
}
|
|
1785
|
-
function
|
|
1786
|
-
return e === void 0 ? t : e === !1 ? null : e === !0 ?
|
|
1895
|
+
function Qn(e, t) {
|
|
1896
|
+
return e === void 0 ? t : e === !1 ? null : e === !0 ? c : e;
|
|
1787
1897
|
}
|
|
1788
|
-
function
|
|
1789
|
-
let r = n ??
|
|
1898
|
+
function $n(e, t, n) {
|
|
1899
|
+
let r = n ?? Ue, i = {
|
|
1790
1900
|
...r,
|
|
1791
1901
|
...e,
|
|
1792
|
-
serializer:
|
|
1793
|
-
console:
|
|
1902
|
+
serializer: Zn(e.serializer, n?.serializer, t),
|
|
1903
|
+
console: Qn(e.console, r.console),
|
|
1794
1904
|
sampling: {
|
|
1795
1905
|
...r.sampling,
|
|
1796
1906
|
...e.sampling,
|
|
@@ -1814,23 +1924,30 @@ function Gn(e, t, n) {
|
|
|
1814
1924
|
} catch (e) {
|
|
1815
1925
|
t.report("config.invalid", `endpoint is not a valid absolute URL: ${i.endpoint}`, void 0, e);
|
|
1816
1926
|
}
|
|
1817
|
-
i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record will report service.name as '${
|
|
1927
|
+
i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record will report service.name as '${qe}'.`), qe);
|
|
1818
1928
|
let a = i.sampling.defaultRate;
|
|
1819
1929
|
(typeof a != "number" || a < 0 || a > 1) && (t.report("config.invalid", `sampling.defaultRate must be 0..1, got ${String(a)}`), i.sampling.defaultRate = 1);
|
|
1820
1930
|
let o = Object.entries(i.sampling.rates);
|
|
1821
1931
|
for (let [e, n] of o) (typeof n != "number" || n < 0 || n > 1) && (t.report("config.invalid", `sampling.rates["${e}"] must be 0..1, got ${String(n)}`), i.sampling.rates[e] = 1);
|
|
1822
|
-
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]);
|
|
1823
|
-
let s = /* @__PURE__ */ new Set([...Object.keys(Ge), ...De]);
|
|
1824
|
-
for (let n of Object.keys(e)) s.has(n) || t.report("config.invalid", `unknown config key "${n}", ignored. Typo?`);
|
|
1825
|
-
return i;
|
|
1932
|
+
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]), er(e, t), i;
|
|
1826
1933
|
}
|
|
1827
|
-
function
|
|
1828
|
-
|
|
1829
|
-
for (let
|
|
1934
|
+
function er(e, t) {
|
|
1935
|
+
let n = /* @__PURE__ */ new Set([...Object.keys(Ue), ...lt]);
|
|
1936
|
+
for (let r of Object.keys(e)) n.has(r) || t.report("config.invalid", `unknown config key "${r}", ignored. Typo?`);
|
|
1937
|
+
for (let n of b) {
|
|
1938
|
+
let r = e[n];
|
|
1939
|
+
if (typeof r != "object" || !r) continue;
|
|
1940
|
+
let i = /* @__PURE__ */ new Set([...Object.keys(Ue[n]), ...Ae[n]]);
|
|
1941
|
+
for (let e of Object.keys(r)) i.has(e) || t.report("config.invalid", `unknown config key "${n}.${e}", ignored. Typo?`);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
function tr(e, t) {
|
|
1945
|
+
for (let n of Object.keys(t)) b.includes(n) || Object.assign(e, { [n]: t[n] });
|
|
1946
|
+
for (let n of b) Object.assign(e[n], t[n]);
|
|
1830
1947
|
}
|
|
1831
1948
|
//#endregion
|
|
1832
1949
|
//#region src/core/context.ts
|
|
1833
|
-
var
|
|
1950
|
+
var nr = class {
|
|
1834
1951
|
map = /* @__PURE__ */ new Map();
|
|
1835
1952
|
set(e, t) {
|
|
1836
1953
|
this.map.set(e, t);
|
|
@@ -1850,12 +1967,12 @@ var qn = class {
|
|
|
1850
1967
|
getAll() {
|
|
1851
1968
|
return Object.fromEntries(this.map);
|
|
1852
1969
|
}
|
|
1853
|
-
},
|
|
1970
|
+
}, rr = class {
|
|
1854
1971
|
handler;
|
|
1855
1972
|
throttleMs;
|
|
1856
1973
|
counters = /* @__PURE__ */ new Map();
|
|
1857
1974
|
lastEmitted = /* @__PURE__ */ new Map();
|
|
1858
|
-
constructor(e, t =
|
|
1975
|
+
constructor(e, t = oe) {
|
|
1859
1976
|
this.handler = e, this.throttleMs = t;
|
|
1860
1977
|
}
|
|
1861
1978
|
setHandler(e) {
|
|
@@ -1880,7 +1997,7 @@ var qn = class {
|
|
|
1880
1997
|
if (this.handler) try {
|
|
1881
1998
|
this.handler(o);
|
|
1882
1999
|
} catch (e) {
|
|
1883
|
-
this.count("handler.threw"), typeof console < "u" && console.warn(`${
|
|
2000
|
+
this.count("handler.threw"), typeof console < "u" && console.warn(`${Ee} onDiagnostic handler threw`, e);
|
|
1884
2001
|
}
|
|
1885
2002
|
}
|
|
1886
2003
|
guard(e, t, n) {
|
|
@@ -1905,59 +2022,51 @@ var qn = class {
|
|
|
1905
2022
|
reset() {
|
|
1906
2023
|
this.counters.clear(), this.lastEmitted.clear();
|
|
1907
2024
|
}
|
|
1908
|
-
},
|
|
1909
|
-
maxAgeMs:
|
|
2025
|
+
}, ir = {
|
|
2026
|
+
maxAgeMs: pt,
|
|
1910
2027
|
endOnOwnerClose: !1,
|
|
1911
|
-
urlParam:
|
|
2028
|
+
urlParam: st
|
|
1912
2029
|
};
|
|
1913
|
-
function
|
|
2030
|
+
function q(e, t) {
|
|
1914
2031
|
let n = Reflect.get(e, t);
|
|
1915
2032
|
return typeof n == "string" && n !== "" ? n : void 0;
|
|
1916
2033
|
}
|
|
1917
|
-
function
|
|
2034
|
+
function ar(e, t) {
|
|
1918
2035
|
let n = Reflect.get(e, t);
|
|
1919
2036
|
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
1920
2037
|
}
|
|
1921
|
-
function
|
|
2038
|
+
function or(e) {
|
|
1922
2039
|
if (typeof e != "object" || !e) return null;
|
|
1923
|
-
let t =
|
|
2040
|
+
let t = q(e, "id"), n = q(e, "name"), r = ar(e, "startedAt");
|
|
1924
2041
|
return t === void 0 || n === void 0 || r === void 0 ? null : {
|
|
1925
2042
|
id: t,
|
|
1926
2043
|
name: n,
|
|
1927
2044
|
startedAt: r,
|
|
1928
|
-
parentId:
|
|
1929
|
-
ownerContextId:
|
|
2045
|
+
parentId: q(e, "parentId"),
|
|
2046
|
+
ownerContextId: q(e, "ownerContextId") ?? ""
|
|
1930
2047
|
};
|
|
1931
2048
|
}
|
|
1932
|
-
function
|
|
2049
|
+
function sr(e) {
|
|
1933
2050
|
if (typeof e != "object" || !e) return null;
|
|
1934
|
-
let t =
|
|
2051
|
+
let t = q(e, "i"), n = q(e, "n");
|
|
1935
2052
|
return t === void 0 || n === void 0 ? null : {
|
|
1936
2053
|
id: t,
|
|
1937
2054
|
name: n,
|
|
1938
|
-
startedAt:
|
|
2055
|
+
startedAt: ar(e, "s") ?? Date.now(),
|
|
1939
2056
|
parentId: void 0,
|
|
1940
2057
|
ownerContextId: ""
|
|
1941
2058
|
};
|
|
1942
2059
|
}
|
|
1943
|
-
function
|
|
2060
|
+
function cr(e) {
|
|
1944
2061
|
let t = JSON.stringify({
|
|
1945
2062
|
i: e.id,
|
|
1946
2063
|
n: e.name.slice(0, 64),
|
|
1947
2064
|
s: e.startedAt
|
|
1948
2065
|
}), n = new TextEncoder().encode(t), r = "";
|
|
1949
2066
|
for (let e of n) r += String.fromCharCode(e);
|
|
1950
|
-
return btoa(r).replace(
|
|
1951
|
-
}
|
|
1952
|
-
function er(e, t) {
|
|
1953
|
-
let n = new Promise((e, n) => {
|
|
1954
|
-
T(setTimeout(() => {
|
|
1955
|
-
n(/* @__PURE__ */ Error(`timed out after ${String(t)}ms`));
|
|
1956
|
-
}, t));
|
|
1957
|
-
});
|
|
1958
|
-
return Promise.race([e, n]);
|
|
2067
|
+
return btoa(r).replace(Le, "-").replace(Se, "_").replace(ze, "");
|
|
1959
2068
|
}
|
|
1960
|
-
var
|
|
2069
|
+
var lr = class {
|
|
1961
2070
|
options;
|
|
1962
2071
|
diagnostics;
|
|
1963
2072
|
contextId;
|
|
@@ -1973,14 +2082,14 @@ var tr = class {
|
|
|
1973
2082
|
async bootstrap() {
|
|
1974
2083
|
let e = this.readUrlToken();
|
|
1975
2084
|
if (e && this.adopt(e, "url")) return;
|
|
1976
|
-
let t = this.diagnostics.guard("storage.unavailable", "reading the persisted journey", () => sessionStorage.getItem(
|
|
2085
|
+
let t = this.diagnostics.guard("storage.unavailable", "reading the persisted journey", () => sessionStorage.getItem(w));
|
|
1977
2086
|
if (t && this.restore(t)) return;
|
|
1978
2087
|
let n = await this.readOpenFinToken();
|
|
1979
2088
|
n !== null && this.adopt(n, "openfin.customData");
|
|
1980
2089
|
}
|
|
1981
2090
|
start(e, t = {}) {
|
|
1982
2091
|
let n = {
|
|
1983
|
-
id: t.id ??
|
|
2092
|
+
id: t.id ?? I(),
|
|
1984
2093
|
name: e,
|
|
1985
2094
|
startedAt: Date.now(),
|
|
1986
2095
|
parentId: t.parent ? this.journey?.id : void 0,
|
|
@@ -1998,7 +2107,7 @@ var tr = class {
|
|
|
1998
2107
|
getToken() {
|
|
1999
2108
|
let e = this.journey;
|
|
2000
2109
|
if (e === null) return;
|
|
2001
|
-
let t =
|
|
2110
|
+
let t = cr(e);
|
|
2002
2111
|
if (t.length > 256) {
|
|
2003
2112
|
this.diagnostics.report("journey.token_too_large", "journey token exceeded the size cap and was not issued", { length: t.length });
|
|
2004
2113
|
return;
|
|
@@ -2022,7 +2131,7 @@ var tr = class {
|
|
|
2022
2131
|
this.clearTimer();
|
|
2023
2132
|
}
|
|
2024
2133
|
restore(e) {
|
|
2025
|
-
let t =
|
|
2134
|
+
let t = or(this.diagnostics.guard("storage.degraded", "parsing the persisted journey", () => JSON.parse(e)));
|
|
2026
2135
|
return t === null ? !1 : Date.now() - t.startedAt > this.options.maxAgeMs ? (this.diagnostics.report("journey.expired", "discarded a persisted journey older than maxAgeMs", { name: t.name }), this.clearStored(), !1) : (this.setJourney(t), this.diagnostics.report("journey.adopted", `resumed journey "${t.name}"`, {
|
|
2027
2136
|
source: "sessionStorage",
|
|
2028
2137
|
journeyId: t.id
|
|
@@ -2030,22 +2139,22 @@ var tr = class {
|
|
|
2030
2139
|
}
|
|
2031
2140
|
decodeToken(e) {
|
|
2032
2141
|
return this.diagnostics.guard("config.invalid", "decoding a seeded journey token", () => {
|
|
2033
|
-
let t = e.replace(
|
|
2034
|
-
return
|
|
2142
|
+
let t = e.replace(tt, "+").replace(Ye, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
|
|
2143
|
+
return sr(JSON.parse(new TextDecoder().decode(i)));
|
|
2035
2144
|
}) ?? null;
|
|
2036
2145
|
}
|
|
2037
2146
|
setJourney(e) {
|
|
2038
2147
|
if (this.journey = e, this.clearTimer(), this.diagnostics.guard("storage.unavailable", "persisting the journey", () => {
|
|
2039
|
-
e === null ? sessionStorage.removeItem(
|
|
2148
|
+
e === null ? sessionStorage.removeItem(w) : sessionStorage.setItem(w, JSON.stringify(e));
|
|
2040
2149
|
}), e === null) return;
|
|
2041
2150
|
let t = Math.max(this.options.maxAgeMs - (Date.now() - e.startedAt), 0), n = setTimeout(() => {
|
|
2042
2151
|
this.diagnostics.report("journey.expired", `journey "${e.name}" hit maxAgeMs and was ended automatically`, { journeyId: e.id }), this.journey = null, this.expiryTimer = null, this.clearStored();
|
|
2043
2152
|
}, t);
|
|
2044
|
-
this.expiryTimer = n,
|
|
2153
|
+
this.expiryTimer = n, D(n);
|
|
2045
2154
|
}
|
|
2046
2155
|
clearStored() {
|
|
2047
2156
|
this.diagnostics.guard("storage.unavailable", "clearing the persisted journey", () => {
|
|
2048
|
-
sessionStorage.removeItem(
|
|
2157
|
+
sessionStorage.removeItem(w);
|
|
2049
2158
|
});
|
|
2050
2159
|
}
|
|
2051
2160
|
clearTimer() {
|
|
@@ -2057,41 +2166,41 @@ var tr = class {
|
|
|
2057
2166
|
async readOpenFinToken() {
|
|
2058
2167
|
let e = globalThis.fin?.me, t = e?.getOptions;
|
|
2059
2168
|
if (t === void 0) return null;
|
|
2060
|
-
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "reading fin.me.getOptions()", () =>
|
|
2169
|
+
let n = (await this.diagnostics.guardAsync("openfin.unavailable", "reading fin.me.getOptions()", () => R(t.call(e), Be)))?.customData?.[Xe];
|
|
2061
2170
|
return typeof n == "string" ? n : null;
|
|
2062
2171
|
}
|
|
2063
2172
|
};
|
|
2064
2173
|
//#endregion
|
|
2065
2174
|
//#region src/core/sampling.ts
|
|
2066
|
-
function
|
|
2067
|
-
let t =
|
|
2068
|
-
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t,
|
|
2175
|
+
function ur(e) {
|
|
2176
|
+
let t = m;
|
|
2177
|
+
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, ge);
|
|
2069
2178
|
return t >>> 0;
|
|
2070
2179
|
}
|
|
2071
|
-
function
|
|
2180
|
+
function J(e, t) {
|
|
2072
2181
|
let n = e.attributes[t];
|
|
2073
2182
|
return typeof n == "string" ? n : "";
|
|
2074
2183
|
}
|
|
2075
|
-
function
|
|
2184
|
+
function dr(e, t) {
|
|
2076
2185
|
let { rates: n, defaultRate: r } = t.sampling, i, a = -1;
|
|
2077
2186
|
for (let [t, r] of Object.entries(n)) (e === t || e.startsWith(`${t}.`)) && t.length > a && (i = r, a = t.length);
|
|
2078
2187
|
return i ?? r;
|
|
2079
2188
|
}
|
|
2080
|
-
function
|
|
2189
|
+
function fr(e, t) {
|
|
2081
2190
|
if (e.level === "ERROR" || e.level === "FATAL" || t.sampling.alwaysSampleTypes.includes(e.type)) return !0;
|
|
2082
|
-
let n =
|
|
2083
|
-
return n >= 1 ? !0 : n <= 0 ? !1 :
|
|
2191
|
+
let n = dr(e.namespace, t);
|
|
2192
|
+
return n >= 1 ? !0 : n <= 0 ? !1 : ur(e.journeyId || e.traceId) / $e < n;
|
|
2084
2193
|
}
|
|
2085
|
-
function
|
|
2086
|
-
return
|
|
2194
|
+
function pr(e, t) {
|
|
2195
|
+
return fr({
|
|
2087
2196
|
level: e.severityText,
|
|
2088
|
-
type:
|
|
2089
|
-
namespace:
|
|
2090
|
-
journeyId:
|
|
2197
|
+
type: J(e, S),
|
|
2198
|
+
namespace: J(e, C),
|
|
2199
|
+
journeyId: J(e, we),
|
|
2091
2200
|
traceId: e.traceId
|
|
2092
2201
|
}, t);
|
|
2093
2202
|
}
|
|
2094
|
-
var
|
|
2203
|
+
var mr = class {
|
|
2095
2204
|
windowStart = 0;
|
|
2096
2205
|
count = 0;
|
|
2097
2206
|
allow(e) {
|
|
@@ -2102,19 +2211,19 @@ var or = class {
|
|
|
2102
2211
|
};
|
|
2103
2212
|
//#endregion
|
|
2104
2213
|
//#region src/core/pipeline.ts
|
|
2105
|
-
function
|
|
2106
|
-
return e.attributes[
|
|
2214
|
+
function hr(e) {
|
|
2215
|
+
return e.attributes[S] === ut;
|
|
2107
2216
|
}
|
|
2108
|
-
var
|
|
2217
|
+
var gr = {
|
|
2109
2218
|
logs: {
|
|
2110
|
-
flushIntervalMs:
|
|
2219
|
+
flushIntervalMs: et,
|
|
2111
2220
|
batchSize: 100
|
|
2112
2221
|
},
|
|
2113
2222
|
metrics: {
|
|
2114
|
-
flushIntervalMs:
|
|
2223
|
+
flushIntervalMs: Je,
|
|
2115
2224
|
batchSize: 500
|
|
2116
2225
|
}
|
|
2117
|
-
},
|
|
2226
|
+
}, _r = class {
|
|
2118
2227
|
options;
|
|
2119
2228
|
onFlush;
|
|
2120
2229
|
pending = [];
|
|
@@ -2142,12 +2251,12 @@ var cr = {
|
|
|
2142
2251
|
let e = setTimeout(() => {
|
|
2143
2252
|
this.timer = null, this.onFlush(this);
|
|
2144
2253
|
}, this.options.flushIntervalMs);
|
|
2145
|
-
this.timer = e,
|
|
2254
|
+
this.timer = e, D(e);
|
|
2146
2255
|
}
|
|
2147
2256
|
clearTimer() {
|
|
2148
2257
|
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
2149
2258
|
}
|
|
2150
|
-
},
|
|
2259
|
+
}, vr = class {
|
|
2151
2260
|
transport;
|
|
2152
2261
|
storage;
|
|
2153
2262
|
retry;
|
|
@@ -2155,22 +2264,22 @@ var cr = {
|
|
|
2155
2264
|
streams;
|
|
2156
2265
|
unconfirmed = /* @__PURE__ */ new Map();
|
|
2157
2266
|
queue = [];
|
|
2158
|
-
ceiling = new
|
|
2267
|
+
ceiling = new mr();
|
|
2159
2268
|
inFlight = 0;
|
|
2160
2269
|
pumpScheduled = !1;
|
|
2161
2270
|
stopped = !1;
|
|
2162
|
-
constructor(e, t, n, r, i =
|
|
2271
|
+
constructor(e, t, n, r, i = gr) {
|
|
2163
2272
|
this.transport = e, this.storage = t, this.retry = n, this.diagnostics = r;
|
|
2164
2273
|
let a = (e) => {
|
|
2165
2274
|
this.claim(e);
|
|
2166
2275
|
};
|
|
2167
2276
|
this.streams = {
|
|
2168
|
-
logs: new
|
|
2169
|
-
metrics: new
|
|
2277
|
+
logs: new _r(i.logs, a),
|
|
2278
|
+
metrics: new _r(i.metrics, a)
|
|
2170
2279
|
};
|
|
2171
2280
|
}
|
|
2172
2281
|
push(e) {
|
|
2173
|
-
this.stopped || (e.observedTimeUnixNano =
|
|
2282
|
+
this.stopped || (e.observedTimeUnixNano = Xt(), this.route(e));
|
|
2174
2283
|
}
|
|
2175
2284
|
drainPending() {
|
|
2176
2285
|
return this.toBatch([...this.streams.metrics.take(), ...this.streams.logs.take()]);
|
|
@@ -2188,7 +2297,7 @@ var cr = {
|
|
|
2188
2297
|
}
|
|
2189
2298
|
toBatch(e) {
|
|
2190
2299
|
return e.length === 0 ? null : {
|
|
2191
|
-
id:
|
|
2300
|
+
id: I(),
|
|
2192
2301
|
records: e,
|
|
2193
2302
|
createdAt: Date.now(),
|
|
2194
2303
|
attempts: 0
|
|
@@ -2196,7 +2305,7 @@ var cr = {
|
|
|
2196
2305
|
}
|
|
2197
2306
|
route(e) {
|
|
2198
2307
|
try {
|
|
2199
|
-
let t =
|
|
2308
|
+
let t = hr(e) ? this.streams.metrics : this.streams.logs;
|
|
2200
2309
|
if (!this.ceiling.allow(e)) {
|
|
2201
2310
|
this.diagnostics.count("record.dropped_by_ceiling");
|
|
2202
2311
|
return;
|
|
@@ -2208,7 +2317,7 @@ var cr = {
|
|
|
2208
2317
|
}
|
|
2209
2318
|
claim(e) {
|
|
2210
2319
|
let t = e.take(), n = {
|
|
2211
|
-
id:
|
|
2320
|
+
id: I(),
|
|
2212
2321
|
records: t,
|
|
2213
2322
|
createdAt: Date.now(),
|
|
2214
2323
|
attempts: 0
|
|
@@ -2250,10 +2359,10 @@ var cr = {
|
|
|
2250
2359
|
try {
|
|
2251
2360
|
await this.transport.send(e);
|
|
2252
2361
|
} catch (t) {
|
|
2253
|
-
await this.
|
|
2362
|
+
await this.storeFailed({
|
|
2254
2363
|
...e,
|
|
2255
2364
|
attempts: e.attempts + 1
|
|
2256
|
-
}), this.diagnostics.report("transport.http_error", "batch was stored for retry instead of being delivered", {
|
|
2365
|
+
}, t), this.diagnostics.report("transport.http_error", "batch was stored for retry instead of being delivered", {
|
|
2257
2366
|
batchId: e.id,
|
|
2258
2367
|
records: e.records.length
|
|
2259
2368
|
}, t);
|
|
@@ -2262,18 +2371,23 @@ var cr = {
|
|
|
2262
2371
|
this.unconfirmed.delete(e.id);
|
|
2263
2372
|
}
|
|
2264
2373
|
}
|
|
2374
|
+
async storeFailed(e, t) {
|
|
2375
|
+
await this.diagnostics.guardAsync("storage.degraded", "persisting an undelivered batch", async () => {
|
|
2376
|
+
await this.retry.storeFailed(e, t);
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2265
2379
|
async store(e) {
|
|
2266
2380
|
await this.diagnostics.guardAsync("storage.degraded", "persisting an undelivered batch", async () => {
|
|
2267
|
-
await this.storage.save(e), this.retry.nudge();
|
|
2381
|
+
await R(this.storage.save(e), v), this.retry.nudge();
|
|
2268
2382
|
});
|
|
2269
2383
|
}
|
|
2270
2384
|
};
|
|
2271
2385
|
//#endregion
|
|
2272
2386
|
//#region src/core/record.ts
|
|
2273
|
-
function
|
|
2387
|
+
function Y(e) {
|
|
2274
2388
|
return e;
|
|
2275
2389
|
}
|
|
2276
|
-
var
|
|
2390
|
+
var yr = class {
|
|
2277
2391
|
deps;
|
|
2278
2392
|
resourceCache = null;
|
|
2279
2393
|
constructor(e) {
|
|
@@ -2284,35 +2398,41 @@ var dr = class {
|
|
|
2284
2398
|
}
|
|
2285
2399
|
isEnabled(e) {
|
|
2286
2400
|
let { config: t } = this.deps;
|
|
2287
|
-
return t.enabled ?
|
|
2401
|
+
return t.enabled ? x[e] >= x[t.minLevel] : !1;
|
|
2288
2402
|
}
|
|
2289
2403
|
build(e) {
|
|
2290
2404
|
let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o } = this.deps;
|
|
2291
|
-
if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"),
|
|
2405
|
+
if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"), {
|
|
2406
|
+
record: null,
|
|
2407
|
+
dropped: "level"
|
|
2408
|
+
};
|
|
2292
2409
|
let s = r.resolve(), c = i.current();
|
|
2293
|
-
if (!
|
|
2410
|
+
if (!fr({
|
|
2294
2411
|
level: e.level,
|
|
2295
2412
|
type: e.type,
|
|
2296
2413
|
namespace: e.namespace,
|
|
2297
2414
|
journeyId: c?.id ?? "",
|
|
2298
2415
|
traceId: s.traceId
|
|
2299
|
-
}, t)) return n.count("record.dropped_by_sampling"),
|
|
2300
|
-
|
|
2416
|
+
}, t)) return n.count("record.dropped_by_sampling"), {
|
|
2417
|
+
record: null,
|
|
2418
|
+
dropped: "sampling"
|
|
2419
|
+
};
|
|
2420
|
+
let l = a.next(), u = Ht(), d = t.capture.fullUrls ? u : M(u), f, p = 0;
|
|
2301
2421
|
try {
|
|
2302
|
-
let t =
|
|
2422
|
+
let t = H(this.deps.context.getAll(), o), n = H(e.scoped ?? {}, o), r = H(e.payload ?? {}, o);
|
|
2303
2423
|
p = t.bytes + n.bytes + r.bytes, f = {
|
|
2304
|
-
...
|
|
2305
|
-
...
|
|
2306
|
-
...
|
|
2424
|
+
...Y(t.value),
|
|
2425
|
+
...Y(n.value),
|
|
2426
|
+
...Y(r.value)
|
|
2307
2427
|
};
|
|
2308
2428
|
} catch (e) {
|
|
2309
|
-
n.report("record.sanitize_failed", "attributes could not be sanitized", void 0, e), f = { [
|
|
2429
|
+
n.report("record.sanitize_failed", "attributes could not be sanitized", void 0, e), f = { [Me]: !0 };
|
|
2310
2430
|
}
|
|
2311
|
-
f[
|
|
2312
|
-
let m =
|
|
2431
|
+
f[S] = e.type, f[ke] = l, f[C] = e.namespace, f[mt] = d, c && (f[we] = c.id, f[Qe] = c.name, c.parentId !== void 0 && (f[ct] = c.parentId));
|
|
2432
|
+
let m = V(e.body, o.maxBodyChars);
|
|
2313
2433
|
m !== e.body && n.count("record.truncated");
|
|
2314
2434
|
let h = {
|
|
2315
|
-
timeUnixNano:
|
|
2435
|
+
timeUnixNano: Xt(),
|
|
2316
2436
|
traceId: s.traceId,
|
|
2317
2437
|
spanId: s.spanId,
|
|
2318
2438
|
traceFlags: s.traceFlags,
|
|
@@ -2324,13 +2444,16 @@ var dr = class {
|
|
|
2324
2444
|
}, g = t.redact;
|
|
2325
2445
|
if (g) {
|
|
2326
2446
|
let e = n.guard("record.sanitize_failed", "redact hook threw", () => g(h));
|
|
2327
|
-
if (e === null) return n.count("record.dropped_by_redact"),
|
|
2447
|
+
if (e === null) return n.count("record.dropped_by_redact"), {
|
|
2448
|
+
record: null,
|
|
2449
|
+
dropped: "redact"
|
|
2450
|
+
};
|
|
2328
2451
|
if (e !== void 0 && e !== h) {
|
|
2329
|
-
if (
|
|
2330
|
-
let t =
|
|
2452
|
+
if (Zt(e)) {
|
|
2453
|
+
let t = H(e.attributes, o);
|
|
2331
2454
|
h = {
|
|
2332
2455
|
...e,
|
|
2333
|
-
attributes:
|
|
2456
|
+
attributes: Y(t.value)
|
|
2334
2457
|
}, p = t.bytes;
|
|
2335
2458
|
} else n.report("record.sanitize_failed", "redact hook returned something that is not a record, keeping the original");
|
|
2336
2459
|
}
|
|
@@ -2341,55 +2464,61 @@ var dr = class {
|
|
|
2341
2464
|
body: h.body
|
|
2342
2465
|
});
|
|
2343
2466
|
let t = {
|
|
2344
|
-
[
|
|
2345
|
-
[
|
|
2346
|
-
[
|
|
2347
|
-
[
|
|
2348
|
-
[
|
|
2349
|
-
[
|
|
2467
|
+
[S]: e.type,
|
|
2468
|
+
[ke]: l,
|
|
2469
|
+
[C]: e.namespace,
|
|
2470
|
+
[mt]: d,
|
|
2471
|
+
[Ve]: !0,
|
|
2472
|
+
[at]: p
|
|
2350
2473
|
};
|
|
2351
|
-
c && (t[
|
|
2474
|
+
c && (t[we] = c.id, t[Qe] = c.name), h.attributes = t;
|
|
2352
2475
|
}
|
|
2353
|
-
return h;
|
|
2476
|
+
return { record: h };
|
|
2354
2477
|
}
|
|
2355
2478
|
resource() {
|
|
2356
2479
|
if (this.resourceCache) return this.resourceCache;
|
|
2357
|
-
let { config: e, identity:
|
|
2480
|
+
let { config: e, identity: t, platform: r } = this.deps;
|
|
2358
2481
|
return this.resourceCache = {
|
|
2359
|
-
[
|
|
2360
|
-
[
|
|
2361
|
-
[
|
|
2362
|
-
[
|
|
2363
|
-
[
|
|
2364
|
-
[
|
|
2365
|
-
[
|
|
2366
|
-
[
|
|
2367
|
-
[
|
|
2368
|
-
[
|
|
2369
|
-
[
|
|
2370
|
-
...
|
|
2371
|
-
...
|
|
2482
|
+
[le]: e.serviceName,
|
|
2483
|
+
[Ke]: e.serviceVersion,
|
|
2484
|
+
[_t]: e.environment,
|
|
2485
|
+
[se]: Ze,
|
|
2486
|
+
[ue]: ot,
|
|
2487
|
+
[ae]: ft,
|
|
2488
|
+
[he]: r.platform,
|
|
2489
|
+
[n]: t.sessionId,
|
|
2490
|
+
[We]: t.tabId,
|
|
2491
|
+
[a]: t.contextId,
|
|
2492
|
+
[me]: r.userAgent,
|
|
2493
|
+
...r.openfinUuid === void 0 ? {} : { [s]: r.openfinUuid },
|
|
2494
|
+
...r.openfinName === void 0 ? {} : { [l]: r.openfinName }
|
|
2372
2495
|
}, this.resourceCache;
|
|
2373
2496
|
}
|
|
2374
|
-
},
|
|
2497
|
+
}, br = Symbol.for(fe), X = class e {
|
|
2375
2498
|
diagnostics;
|
|
2376
2499
|
config;
|
|
2377
2500
|
platform;
|
|
2378
2501
|
identity;
|
|
2379
|
-
|
|
2502
|
+
sessionTouch;
|
|
2503
|
+
context = new nr();
|
|
2380
2504
|
breadcrumbs;
|
|
2381
2505
|
tracing;
|
|
2382
|
-
sequence = new
|
|
2506
|
+
sequence = new Dn();
|
|
2383
2507
|
journey;
|
|
2384
2508
|
builder;
|
|
2385
2509
|
console;
|
|
2386
2510
|
bus;
|
|
2387
2511
|
storage;
|
|
2512
|
+
storageBuiltAs;
|
|
2388
2513
|
transport;
|
|
2389
2514
|
retry;
|
|
2390
2515
|
pipeline;
|
|
2391
2516
|
exitFlush;
|
|
2392
2517
|
captures = [];
|
|
2518
|
+
captureOnce = {
|
|
2519
|
+
webVitals: !1,
|
|
2520
|
+
navigationTiming: !1
|
|
2521
|
+
};
|
|
2393
2522
|
bootBuffer = [];
|
|
2394
2523
|
forwardBuffer = [];
|
|
2395
2524
|
forwardScheduled = !1;
|
|
@@ -2397,11 +2526,11 @@ var dr = class {
|
|
|
2397
2526
|
destroyed = !1;
|
|
2398
2527
|
lastGapAt = 0;
|
|
2399
2528
|
constructor(e) {
|
|
2400
|
-
this.diagnostics = new
|
|
2529
|
+
this.diagnostics = new rr(e.onDiagnostic), this.platform = zt(this.diagnostics), this.config = $n(e, this.diagnostics), this.identity = $t(this.diagnostics), this.sessionTouch = new en(this.diagnostics), this.breadcrumbs = new Rn(50), this.tracing = new Ln(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new En(this.config.console, this.diagnostics), this.journey = new lr(ir, this.diagnostics, this.identity.contextId, (e) => {
|
|
2401
2530
|
this.bus.broadcastJourney(e);
|
|
2402
|
-
}), this.builder = new
|
|
2531
|
+
}), this.builder = new yr({
|
|
2403
2532
|
config: this.config,
|
|
2404
|
-
limits:
|
|
2533
|
+
limits: Oe,
|
|
2405
2534
|
diagnostics: this.diagnostics,
|
|
2406
2535
|
context: this.context,
|
|
2407
2536
|
journey: this.journey,
|
|
@@ -2409,7 +2538,7 @@ var dr = class {
|
|
|
2409
2538
|
sequence: this.sequence,
|
|
2410
2539
|
identity: this.identity,
|
|
2411
2540
|
platform: this.platform
|
|
2412
|
-
}), this.bus = new
|
|
2541
|
+
}), this.bus = new Rt(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
|
|
2413
2542
|
onRecords: (e) => {
|
|
2414
2543
|
this.ingestForwarded(e);
|
|
2415
2544
|
},
|
|
@@ -2428,16 +2557,20 @@ var dr = class {
|
|
|
2428
2557
|
});
|
|
2429
2558
|
};
|
|
2430
2559
|
static current() {
|
|
2431
|
-
return globalThis[
|
|
2560
|
+
return globalThis[br] ?? null;
|
|
2432
2561
|
}
|
|
2433
2562
|
static configure(t) {
|
|
2434
2563
|
let n = e.current();
|
|
2435
2564
|
if (n && !n.destroyed) return n.reconfigure(t), n;
|
|
2436
2565
|
let r = new e(t);
|
|
2437
|
-
return globalThis[
|
|
2566
|
+
return globalThis[br] = r, r.init(), r;
|
|
2438
2567
|
}
|
|
2439
2568
|
reconfigure(e) {
|
|
2440
|
-
|
|
2569
|
+
tr(this.config, $n(e, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.keepBuiltStorage(), this.ready && this.reinstallCaptures(), this.diagnostics.report("config.reconfigured", "configure() was called again, the existing runtime was updated");
|
|
2570
|
+
}
|
|
2571
|
+
keepBuiltStorage() {
|
|
2572
|
+
let e = this.storageBuiltAs;
|
|
2573
|
+
e !== void 0 && this.config.storage !== e && (this.diagnostics.report("config.invalid", `storage cannot change after startup, still ${e}`, { requested: this.config.storage }), this.config.storage = e);
|
|
2441
2574
|
}
|
|
2442
2575
|
async init() {
|
|
2443
2576
|
try {
|
|
@@ -2450,11 +2583,12 @@ var dr = class {
|
|
|
2450
2583
|
}
|
|
2451
2584
|
}
|
|
2452
2585
|
async becomeSender() {
|
|
2453
|
-
this.storage = await
|
|
2586
|
+
this.storageBuiltAs = this.config.storage, this.storage = await _n(this.config.storage, p, it, this.diagnostics, this.reportGap), this.transport = new Cn(this.config, this.diagnostics), this.retry = new wn(this.storage, this.transport, this.diagnostics, this.config), this.pipeline = new vr(this.transport, this.storage, this.retry, this.diagnostics), this.exitFlush = new bn({
|
|
2454
2587
|
config: this.config,
|
|
2455
2588
|
diagnostics: this.diagnostics,
|
|
2456
|
-
drainForExit: () => this.pipeline?.drainForExit() ?? null
|
|
2457
|
-
|
|
2589
|
+
drainForExit: () => this.pipeline?.drainForExit() ?? null,
|
|
2590
|
+
drainPending: () => this.pipeline?.drainPending() ?? null
|
|
2591
|
+
}), await ln(this.storage, this.diagnostics), this.retry.start(), this.exitFlush.install();
|
|
2458
2592
|
}
|
|
2459
2593
|
installCaptures() {
|
|
2460
2594
|
let e = {
|
|
@@ -2462,9 +2596,10 @@ var dr = class {
|
|
|
2462
2596
|
diagnostics: this.diagnostics,
|
|
2463
2597
|
breadcrumbs: this.breadcrumbs,
|
|
2464
2598
|
tracing: this.tracing,
|
|
2465
|
-
logger: new
|
|
2599
|
+
logger: new E(this, i),
|
|
2600
|
+
once: this.captureOnce
|
|
2466
2601
|
}, t = this.config.capture;
|
|
2467
|
-
(t.errors || t.rejections || t.resourceErrors) && this.captures.push(new
|
|
2602
|
+
(t.errors || t.rejections || t.resourceErrors) && this.captures.push(new Ut(e)), (t.fetch || t.xhr) && this.captures.push(new qt(e)), (t.interactions || t.navigation) && this.captures.push(new Gt(e)), t.webVitals && this.captures.push(new Yt(e));
|
|
2468
2603
|
for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `installing ${e.name}`, () => {
|
|
2469
2604
|
e.install();
|
|
2470
2605
|
});
|
|
@@ -2484,12 +2619,12 @@ var dr = class {
|
|
|
2484
2619
|
if (!this.destroyed) {
|
|
2485
2620
|
this.destroyed = !0;
|
|
2486
2621
|
for (let e of this.captures) e.uninstall();
|
|
2487
|
-
this.captures.length = 0, this.exitFlush?.flush("shutdown"), this.exitFlush?.uninstall(), this.retry?.stop(), this.pipeline?.destroy(), this.journey.destroy(), this.bus.destroy(), this.forwardBuffer = [], await this.storage?.close(), e.current() === this && Reflect.deleteProperty(globalThis,
|
|
2622
|
+
this.captures.length = 0, this.exitFlush?.flush("shutdown"), this.exitFlush?.uninstall(), this.retry?.stop(), this.pipeline?.destroy(), this.journey.destroy(), this.bus.destroy(), this.forwardBuffer = [], await this.storage?.close(), e.current() === this && Reflect.deleteProperty(globalThis, br);
|
|
2488
2623
|
}
|
|
2489
2624
|
}
|
|
2490
2625
|
emit(e) {
|
|
2491
2626
|
if (!(!e || this.destroyed)) {
|
|
2492
|
-
if (
|
|
2627
|
+
if (this.sessionTouch.touch(this.identity.sessionId), !this.ready) {
|
|
2493
2628
|
this.bootBuffer.length >= 500 && (this.bootBuffer.shift(), this.diagnostics.count("record.dropped_boot_buffer_full")), this.bootBuffer.push(e);
|
|
2494
2629
|
return;
|
|
2495
2630
|
}
|
|
@@ -2516,11 +2651,11 @@ var dr = class {
|
|
|
2516
2651
|
return;
|
|
2517
2652
|
}
|
|
2518
2653
|
for (let t of e) {
|
|
2519
|
-
if (!
|
|
2654
|
+
if (!Zt(t)) {
|
|
2520
2655
|
this.diagnostics.count("record.dropped_malformed");
|
|
2521
2656
|
continue;
|
|
2522
2657
|
}
|
|
2523
|
-
if (!
|
|
2658
|
+
if (!pr(t, this.config)) {
|
|
2524
2659
|
this.diagnostics.count("record.dropped_by_sampling");
|
|
2525
2660
|
continue;
|
|
2526
2661
|
}
|
|
@@ -2535,19 +2670,19 @@ var dr = class {
|
|
|
2535
2670
|
}
|
|
2536
2671
|
reportGap = (e) => {
|
|
2537
2672
|
let t = Date.now();
|
|
2538
|
-
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new
|
|
2673
|
+
t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new E(this, te).warn("stored records were dropped before delivery", {
|
|
2539
2674
|
"gap.batches": e.batches,
|
|
2540
2675
|
"gap.records": e.records,
|
|
2541
2676
|
"gap.reason": e.reason
|
|
2542
2677
|
}));
|
|
2543
2678
|
};
|
|
2544
2679
|
regenerateTabId() {
|
|
2545
|
-
let e =
|
|
2680
|
+
let e = I();
|
|
2546
2681
|
this.diagnostics.report("bus.role_resolved", "another context claimed this tab id, most likely a duplicated tab. Regenerating.", {
|
|
2547
2682
|
was: this.identity.tabId,
|
|
2548
2683
|
now: e
|
|
2549
2684
|
}), this.identity.tabId = e, this.diagnostics.guard("storage.unavailable", "persisting the new tab id", () => {
|
|
2550
|
-
sessionStorage.setItem(
|
|
2685
|
+
sessionStorage.setItem(Pe, e);
|
|
2551
2686
|
}), this.builder.invalidateResource();
|
|
2552
2687
|
}
|
|
2553
2688
|
async queueDepth() {
|
|
@@ -2564,10 +2699,10 @@ var dr = class {
|
|
|
2564
2699
|
await this.transport.send(e);
|
|
2565
2700
|
} catch (t) {
|
|
2566
2701
|
await this.diagnostics.guardAsync("storage.degraded", "persisting the batch drained by flush()", async () => {
|
|
2567
|
-
await this.
|
|
2702
|
+
await this.retry?.storeFailed({
|
|
2568
2703
|
...e,
|
|
2569
|
-
attempts: 1
|
|
2570
|
-
}
|
|
2704
|
+
attempts: e.attempts + 1
|
|
2705
|
+
}, t);
|
|
2571
2706
|
}), this.diagnostics.report("transport.http_error", "the batch drained by flush() was stored for retry instead of being delivered", {
|
|
2572
2707
|
batchId: e.id,
|
|
2573
2708
|
records: e.records.length
|
|
@@ -2578,94 +2713,94 @@ var dr = class {
|
|
|
2578
2713
|
function Q() {
|
|
2579
2714
|
return X.current() || X.configure({});
|
|
2580
2715
|
}
|
|
2581
|
-
function
|
|
2716
|
+
function xr(e) {
|
|
2582
2717
|
X.configure(e), Z.clear();
|
|
2583
2718
|
}
|
|
2584
|
-
function
|
|
2585
|
-
if (t) return new
|
|
2719
|
+
function Sr(e, t) {
|
|
2720
|
+
if (t) return new E(Q(), e, t);
|
|
2586
2721
|
let n = Z.get(e);
|
|
2587
|
-
return n || (n = new
|
|
2722
|
+
return n || (n = new E(Q(), e), Z.set(e, n)), n;
|
|
2588
2723
|
}
|
|
2589
2724
|
function $() {
|
|
2590
|
-
return
|
|
2725
|
+
return Sr("app");
|
|
2591
2726
|
}
|
|
2592
|
-
function
|
|
2727
|
+
function Cr(e, t) {
|
|
2593
2728
|
$().trace(e, t);
|
|
2594
2729
|
}
|
|
2595
|
-
function
|
|
2730
|
+
function wr(e, t) {
|
|
2596
2731
|
$().debug(e, t);
|
|
2597
2732
|
}
|
|
2598
|
-
function
|
|
2733
|
+
function Tr(e, t) {
|
|
2599
2734
|
$().info(e, t);
|
|
2600
2735
|
}
|
|
2601
|
-
function
|
|
2736
|
+
function Er(e, t) {
|
|
2602
2737
|
$().warn(e, t);
|
|
2603
2738
|
}
|
|
2604
|
-
function
|
|
2739
|
+
function Dr(e, t, n) {
|
|
2605
2740
|
$().error(e, t, n);
|
|
2606
2741
|
}
|
|
2607
|
-
function
|
|
2742
|
+
function Or(e, t) {
|
|
2608
2743
|
$().logAction(e, t);
|
|
2609
2744
|
}
|
|
2610
|
-
function
|
|
2745
|
+
function kr(e, t) {
|
|
2611
2746
|
$().logEvent(e, t);
|
|
2612
2747
|
}
|
|
2613
|
-
function
|
|
2748
|
+
function Ar(e, t, n, r, i) {
|
|
2614
2749
|
$().logMetric(e, t, n, r, i);
|
|
2615
2750
|
}
|
|
2616
|
-
function
|
|
2751
|
+
function jr(e, t, n) {
|
|
2617
2752
|
return $().timeSync(e, t, n);
|
|
2618
2753
|
}
|
|
2619
|
-
function
|
|
2754
|
+
function Mr(e, t, n) {
|
|
2620
2755
|
return $().timeAsync(e, t, n);
|
|
2621
2756
|
}
|
|
2622
|
-
function
|
|
2757
|
+
function Nr(e, t) {
|
|
2623
2758
|
Q().context.set(e, t);
|
|
2624
2759
|
}
|
|
2625
|
-
function
|
|
2760
|
+
function Pr(e) {
|
|
2626
2761
|
Q().context.setMany(e);
|
|
2627
2762
|
}
|
|
2628
|
-
function
|
|
2763
|
+
function Fr(e) {
|
|
2629
2764
|
Q().context.remove(e);
|
|
2630
2765
|
}
|
|
2631
|
-
function
|
|
2766
|
+
function Ir(e, t) {
|
|
2632
2767
|
return Q().journey.start(e, t);
|
|
2633
2768
|
}
|
|
2634
|
-
function
|
|
2769
|
+
function Lr() {
|
|
2635
2770
|
Q().journey.end();
|
|
2636
2771
|
}
|
|
2637
|
-
function
|
|
2772
|
+
function Rr() {
|
|
2638
2773
|
return Q().journey.current();
|
|
2639
2774
|
}
|
|
2640
|
-
function
|
|
2775
|
+
function zr() {
|
|
2641
2776
|
return Q().journey.getToken();
|
|
2642
2777
|
}
|
|
2643
|
-
function
|
|
2778
|
+
function Br(e) {
|
|
2644
2779
|
return Q().journey.adopt(e, "manual", !0);
|
|
2645
2780
|
}
|
|
2646
|
-
function
|
|
2781
|
+
function Vr(e) {
|
|
2647
2782
|
Q().registerWorker(e);
|
|
2648
2783
|
}
|
|
2649
|
-
function
|
|
2784
|
+
function Hr() {
|
|
2650
2785
|
Q().tracing.rotate("explicit");
|
|
2651
2786
|
}
|
|
2652
|
-
function
|
|
2787
|
+
function Ur() {
|
|
2653
2788
|
return Q().tracing.headers();
|
|
2654
2789
|
}
|
|
2655
|
-
function
|
|
2790
|
+
function Wr() {
|
|
2656
2791
|
return Q().flush();
|
|
2657
2792
|
}
|
|
2658
|
-
function
|
|
2793
|
+
function Gr() {
|
|
2659
2794
|
return Q().queueDepth();
|
|
2660
2795
|
}
|
|
2661
|
-
function
|
|
2796
|
+
function Kr() {
|
|
2662
2797
|
return Q().diagnostics.snapshot();
|
|
2663
2798
|
}
|
|
2664
|
-
async function
|
|
2799
|
+
async function qr() {
|
|
2665
2800
|
let e = X.current();
|
|
2666
2801
|
Z.clear(), await e?.destroy();
|
|
2667
2802
|
}
|
|
2668
2803
|
//#endregion
|
|
2669
|
-
export {
|
|
2804
|
+
export { E as OneLogger, Br as adoptJourney, xr as configure, Rr as currentJourney, wr as debug, Lr as endJourney, Dr as error, Wr as flush, Kr as getDiagnosticCounters, zr as getJourneyToken, Sr as getLogger, Gr as getQueueDepth, Ur as getTraceHeaders, Tr as info, Or as logAction, kr as logEvent, Ar as logMetric, Vr as registerWorker, Fr as removeContext, Nr as setContext, Pr as setContextMap, qr as shutdown, Ir as startJourney, Hr as startTrace, Mr as timeAsync, jr as timeSync, Cr as trace, Er as warn };
|
|
2670
2805
|
|
|
2671
2806
|
//# sourceMappingURL=index.js.map
|