@utk09/ui-observability 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,46 +1,45 @@
1
- import { $ as e, $t as t, A as n, At as r, B as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, It as ee, J as te, Jt as ne, K as re, Kt as ie, L as g, Lt as ae, M as oe, Mt as se, N as ce, Nt as le, O as ue, Ot as de, Pt as fe, Qt as pe, R as me, S as he, St as ge, T as _e, Tt as ve, Ut as ye, V as be, Vt as _, W as xe, Wt as Se, Xt as Ce, Yt as we, Zt as Te, _ as Ee, _t as De, a as Oe, an as ke, at as Ae, b as je, bt as Me, c as Ne, ct as Pe, d as Fe, dt as Ie, en as Le, et as Re, ft as ze, g as Be, gt as Ve, h as He, ht as Ue, i as We, in as Ge, it as Ke, j as qe, jt as Je, k as Ye, kt as Xe, l as v, lt as Ze, m as Qe, mt as $e, n as y, nn as et, nt as tt, o as nt, on as rt, ot as it, p as at, pt as ot, q as st, r as ct, rn as lt, rt as b, s as ut, st as dt, t as ft, tn as pt, tt as x, u as mt, ut as ht, v as gt, wt as _t, x as vt, xt as yt, yt as bt, zt as xt } from "./constants-NJNXpfPi.js";
2
- import { context as St, isSpanContextValid as Ct, propagation as wt, trace as Tt } from "@opentelemetry/api";
1
+ import { $ as e, $t as t, A as n, At as r, B as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, It as g, J as ee, Jt as te, K as ne, Kt as re, L as _, Lt as ie, M as ae, Mt as oe, N as se, Nt as ce, O as le, Ot as ue, Pt as de, Qt as fe, R as pe, S as me, St as he, T as ge, Tt as _e, Ut as ve, V as ye, Vt as v, W as be, Wt as xe, Xt as Se, Yt as Ce, Zt as we, _ as Te, _t as Ee, a as y, an as De, at as Oe, b as ke, bt as Ae, c as je, ct as Me, d as Ne, dt as Pe, en as Fe, et as Ie, ft as Le, g as Re, gt as ze, h as Be, ht as Ve, i as He, in as Ue, it as We, j as Ge, jt as Ke, k as qe, kt as Je, l as b, lt as Ye, m as Xe, mt as Ze, n as x, nn as Qe, nt as $e, o as et, on as tt, ot as nt, p as rt, pt as it, q as at, r as ot, rn as st, rt as S, s as ct, st as lt, t as ut, tn as dt, tt as C, u as ft, ut as pt, v as mt, wt as ht, x as gt, xt as _t, yt as vt, zt as yt } from "./constants-CQr0wwbQ.js";
3
2
  //#region src/utils/timer.ts
4
- function Et(e) {
3
+ function bt(e) {
5
4
  return Math.round((performance.now() - e) * d) / d;
6
5
  }
7
- function Dt(e, t, n, r, i) {
8
- e.logMetric(`${t}.duration`, Et(n), "ms", "histogram", {
6
+ function xt(e, t, n, r, i) {
7
+ e.logMetric(`${t}.duration`, bt(n), "ms", "histogram", {
9
8
  status: r,
10
9
  ...i
11
10
  });
12
11
  }
13
- function Ot(e, t, n, r, i) {
12
+ function St(e, t, n, r, i) {
14
13
  e.error(`${t} failed`, r, {
15
- "action.duration_ms": Et(n),
14
+ "action.duration_ms": bt(n),
16
15
  status: "FAILURE",
17
16
  ...i
18
17
  });
19
18
  }
20
- function kt(e, t, n, r) {
19
+ function Ct(e, t, n, r) {
21
20
  let i = performance.now();
22
21
  try {
23
22
  let a = n();
24
- return Dt(e, t, i, "SUCCESS", r), a;
23
+ return xt(e, t, i, "SUCCESS", r), a;
25
24
  } catch (n) {
26
- throw Ot(e, t, i, n, r), n;
25
+ throw St(e, t, i, n, r), n;
27
26
  }
28
27
  }
29
- async function At(e, t, n, r) {
28
+ async function wt(e, t, n, r) {
30
29
  let i = performance.now();
31
30
  try {
32
31
  let a = await n();
33
- return Dt(e, t, i, "SUCCESS", r), a;
32
+ return xt(e, t, i, "SUCCESS", r), a;
34
33
  } catch (n) {
35
- throw Ot(e, t, i, n, r), n;
34
+ throw St(e, t, i, n, r), n;
36
35
  }
37
36
  }
38
37
  //#endregion
39
38
  //#region src/core/logger.ts
40
- function jt(e) {
39
+ function Tt(e) {
41
40
  return e instanceof Error ? e : Error(String(e));
42
41
  }
43
- var S = class e {
42
+ var w = class e {
44
43
  runtime;
45
44
  namespace;
46
45
  options;
@@ -77,7 +76,7 @@ var S = class e {
77
76
  logEvent = (e, t) => {
78
77
  this.write("INFO", "event", e, t);
79
78
  };
80
- logMetric = (e, t, n = oe, r = "gauge", i) => {
79
+ logMetric = (e, t, n = ae, r = "gauge", i) => {
81
80
  this.write("INFO", "metric", e, {
82
81
  "metric.name": e,
83
82
  "metric.value": t,
@@ -86,8 +85,8 @@ var S = class e {
86
85
  ...i
87
86
  });
88
87
  };
89
- timeSync = (e, t, n) => kt(this, e, t, n);
90
- timeAsync = (e, t, n) => At(this, e, t, n);
88
+ timeSync = (e, t, n) => Ct(this, e, t, n);
89
+ timeAsync = (e, t, n) => wt(this, e, t, n);
91
90
  write(e, t, n, r) {
92
91
  if (!this.runtime.builder.isEnabled(e)) return;
93
92
  let i = this.runtime.builder.build({
@@ -106,7 +105,7 @@ var S = class e {
106
105
  }
107
106
  writeError(e, t, n, r) {
108
107
  if (!this.runtime.builder.isEnabled(e)) return;
109
- let i = n === void 0 ? void 0 : jt(n), a = this.runtime.builder.build({
108
+ let i = n === void 0 ? void 0 : Tt(n), a = this.runtime.builder.build({
110
109
  level: e,
111
110
  type: "system",
112
111
  body: t,
@@ -127,18 +126,18 @@ var S = class e {
127
126
  };
128
127
  //#endregion
129
128
  //#region src/utils/unref.ts
130
- function C(e) {
129
+ function T(e) {
131
130
  typeof e != "number" && e.unref?.();
132
131
  }
133
132
  //#endregion
134
133
  //#region src/models/bus.ts
135
- function w(e) {
134
+ function E(e) {
136
135
  return {
137
- p: he,
136
+ p: me,
138
137
  m: e
139
138
  };
140
139
  }
141
- function T(e) {
140
+ function D(e) {
142
141
  if (typeof e != "object" || !e) return null;
143
142
  let t = e;
144
143
  if (t.p !== "ui-observability/1" || typeof t.m != "object" || t.m === null) return null;
@@ -147,12 +146,12 @@ function T(e) {
147
146
  }
148
147
  //#endregion
149
148
  //#region src/bus/links.ts
150
- var Mt = Symbol.for(ae);
151
- function Nt(e, t) {
149
+ var Et = Symbol.for(ie);
150
+ function Dt(e, t) {
152
151
  if (typeof window > "u" || window.parent === window) return null;
153
152
  let n;
154
153
  try {
155
- n = window.parent[Mt];
154
+ n = window.parent[Et];
156
155
  } catch {
157
156
  return null;
158
157
  }
@@ -170,10 +169,10 @@ function Nt(e, t) {
170
169
  }
171
170
  };
172
171
  }
173
- function Pt(e, t) {
172
+ function Ot(e, t) {
174
173
  if (typeof window > "u" || window.parent === window) return null;
175
174
  let n = (t) => {
176
- let n = T(t.data);
175
+ let n = D(t.data);
177
176
  n && t.source === window.parent && e(n, {
178
177
  link: "parent",
179
178
  origin: t.origin
@@ -183,7 +182,7 @@ function Pt(e, t) {
183
182
  kind: "parent",
184
183
  post(e) {
185
184
  t.guard("bus.send_failed", "postMessage to parent", () => {
186
- window.parent.postMessage(w(e), "*");
185
+ window.parent.postMessage(E(e), "*");
187
186
  });
188
187
  },
189
188
  close() {
@@ -191,10 +190,10 @@ function Pt(e, t) {
191
190
  }
192
191
  };
193
192
  }
194
- function Ft(e, t, n) {
193
+ function kt(e, t, n) {
195
194
  if (typeof window > "u") return null;
196
- let r = /* @__PURE__ */ new Set([window.location.origin, ...t]), i = /* @__PURE__ */ new Set(), a = (t) => {
197
- let a = T(t.data);
195
+ let r = /* @__PURE__ */ new Set([window.location.origin, ...t]), i = /* @__PURE__ */ new Map(), a = (t) => {
196
+ let a = D(t.data);
198
197
  if (a) {
199
198
  if (!r.has(t.origin)) {
200
199
  n.report("bus.untrusted_origin", `ignored a bus message from ${t.origin}. Add it to bus.trustedOrigins if it is yours.`, {
@@ -203,7 +202,7 @@ function Ft(e, t, n) {
203
202
  });
204
203
  return;
205
204
  }
206
- t.source && i.add(t.source), e(a, {
205
+ t.source && i.set(t.source, t.origin), e(a, {
207
206
  link: "children",
208
207
  origin: t.origin
209
208
  });
@@ -212,14 +211,14 @@ function Ft(e, t, n) {
212
211
  return addEventListener("message", a), {
213
212
  kind: "children",
214
213
  post(e) {
215
- for (let t of i) {
216
- let r = t;
217
- if (r.closed) {
214
+ for (let [t, r] of i) {
215
+ let a = t;
216
+ if (a.closed) {
218
217
  i.delete(t);
219
218
  continue;
220
219
  }
221
220
  n.guard("bus.send_failed", "postMessage to child", () => {
222
- r.postMessage(w(e), "*");
221
+ a.postMessage(E(e), r);
223
222
  });
224
223
  }
225
224
  },
@@ -228,12 +227,12 @@ function Ft(e, t, n) {
228
227
  }
229
228
  };
230
229
  }
231
- function It(e, t, n) {
230
+ function At(e, t, n) {
232
231
  let r = globalThis.BroadcastChannel;
233
232
  if (r === void 0) return null;
234
233
  let i = n.guard("bus.send_failed", "opening BroadcastChannel", () => new r(e));
235
234
  return i ? (i.onmessage = (e) => {
236
- let n = T(e.data);
235
+ let n = D(e.data);
237
236
  n && t(n, {
238
237
  link: "broadcast",
239
238
  origin: "same-origin"
@@ -242,7 +241,7 @@ function It(e, t, n) {
242
241
  kind: "broadcast",
243
242
  post(e) {
244
243
  n.guard("bus.send_failed", "BroadcastChannel.postMessage", () => {
245
- i.postMessage(w(e));
244
+ i.postMessage(E(e));
246
245
  });
247
246
  },
248
247
  close() {
@@ -252,10 +251,10 @@ function It(e, t, n) {
252
251
  }
253
252
  }) : null;
254
253
  }
255
- function Lt(e, t, n) {
254
+ function jt(e, t, n) {
256
255
  let r = globalThis.fin?.InterApplicationBus;
257
256
  return r ? (n.guardAsync("bus.send_failed", "InterApplicationBus.subscribe", () => r.subscribe({ uuid: "*" }, e, (e) => {
258
- let n = T(e);
257
+ let n = D(e);
259
258
  n && t(n, {
260
259
  link: "openfin",
261
260
  origin: "openfin"
@@ -263,15 +262,15 @@ function Lt(e, t, n) {
263
262
  })), {
264
263
  kind: "openfin",
265
264
  post(t) {
266
- n.guardAsync("bus.send_failed", "InterApplicationBus.publish", () => r.publish(e, w(t)));
265
+ n.guardAsync("bus.send_failed", "InterApplicationBus.publish", () => r.publish(e, E(t)));
267
266
  },
268
267
  close() {}
269
268
  }) : null;
270
269
  }
271
- function Rt(e, t) {
270
+ function Mt(e, t) {
272
271
  let n = globalThis, r = n.postMessage;
273
272
  return n.WorkerGlobalScope === void 0 || !r ? null : (n.addEventListener?.("message", (t) => {
274
- let n = T(t.data);
273
+ let n = D(t.data);
275
274
  n && e(n, {
276
275
  link: "owner",
277
276
  origin: "same-origin"
@@ -280,15 +279,15 @@ function Rt(e, t) {
280
279
  kind: "owner",
281
280
  post(e) {
282
281
  t.guard("bus.send_failed", "worker postMessage", () => {
283
- r(w(e));
282
+ r(E(e));
284
283
  });
285
284
  },
286
285
  close() {}
287
286
  });
288
287
  }
289
- function zt(e, t, n) {
288
+ function Nt(e, t, n) {
290
289
  let r = (e) => {
291
- let n = T(e.data);
290
+ let n = D(e.data);
292
291
  n && t(n, {
293
292
  link: "worker",
294
293
  origin: "same-origin"
@@ -298,7 +297,7 @@ function zt(e, t, n) {
298
297
  kind: "worker",
299
298
  post(t) {
300
299
  n.guard("bus.send_failed", "postMessage to a worker", () => {
301
- e.postMessage(w(t));
300
+ e.postMessage(E(t));
302
301
  });
303
302
  },
304
303
  close() {
@@ -308,14 +307,14 @@ function zt(e, t, n) {
308
307
  }
309
308
  //#endregion
310
309
  //#region src/bus/bus.ts
311
- var Bt = {
312
- timeoutMs: vt,
310
+ var Pt = {
311
+ timeoutMs: gt,
313
312
  maxAttempts: 3
314
- }, Vt = [
313
+ }, Ft = [
315
314
  "children",
316
315
  "direct",
317
316
  "worker"
318
- ], Ht = class {
317
+ ], It = class {
319
318
  config;
320
319
  diagnostics;
321
320
  platform;
@@ -330,7 +329,7 @@ var Bt = {
330
329
  isOpenFinProvider = !1;
331
330
  resolved = !1;
332
331
  awaitingWelcome = null;
333
- constructor(e, t, n, r, i, a, o = Bt) {
332
+ constructor(e, t, n, r, i, a, o = Pt) {
334
333
  this.config = e, this.diagnostics = t, this.platform = n, this.contextId = r, this.tabId = i, this.handlers = a, this.handshakeOptions = o;
335
334
  }
336
335
  getRole() {
@@ -344,7 +343,7 @@ var Bt = {
344
343
  if (e.mode === "off") return this.role = "sender", this.resolved = !0, this.role;
345
344
  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;
346
345
  this.openControlLinks();
347
- let t = Nt(this.receive, this.diagnostics);
346
+ let t = Dt(this.receive, this.diagnostics);
348
347
  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", {
349
348
  role: "forwarder",
350
349
  via: "direct"
@@ -395,7 +394,7 @@ var Bt = {
395
394
  this.receive(e, n);
396
395
  }
397
396
  attachWorker(e) {
398
- this.links.push(zt(e, this.receive, this.diagnostics));
397
+ this.links.push(Nt(e, this.receive, this.diagnostics));
399
398
  }
400
399
  broadcastJourney(e) {
401
400
  this.post({
@@ -450,7 +449,7 @@ var Bt = {
450
449
  }
451
450
  };
452
451
  canOwn(e) {
453
- return this.role === "sender" ? e === "openfin" ? this.isOpenFinProvider : Vt.includes(e) : !1;
452
+ return this.role === "sender" ? e === "openfin" ? this.isOpenFinProvider : Ft.includes(e) : !1;
454
453
  }
455
454
  resolveOpenFinProvider() {
456
455
  let e = this.config.bus.openFinRole;
@@ -471,16 +470,16 @@ var Bt = {
471
470
  }
472
471
  }
473
472
  candidateUpstream() {
474
- return this.platform.isWorker ? Rt(this.receive, this.diagnostics) : this.platform.isTopLevelDocument ? this.platform.platform === "openfin" && !this.isOpenFinProvider ? this.ensureOpenFinLink() : null : Pt(this.receive, this.diagnostics);
473
+ return this.platform.isWorker ? Mt(this.receive, this.diagnostics) : this.platform.isTopLevelDocument ? this.platform.platform === "openfin" && !this.isOpenFinProvider ? this.ensureOpenFinLink() : null : Ot(this.receive, this.diagnostics);
475
474
  }
476
475
  openControlLinks() {
477
476
  let e = (e) => {
478
477
  e && this.links.push(e);
479
478
  };
480
- this.platform.isTopLevelDocument && (e(Ft(this.receive, this.config.bus.trustedOrigins, this.diagnostics)), e(It(je, this.receive, this.diagnostics))), (this.platform.platform === "openfin" || this.platform.platform === "openfin_web") && e(this.ensureOpenFinLink());
479
+ this.platform.isTopLevelDocument && (e(kt(this.receive, this.config.bus.trustedOrigins, this.diagnostics)), e(At(ke, this.receive, this.diagnostics))), (this.platform.platform === "openfin" || this.platform.platform === "openfin_web") && e(this.ensureOpenFinLink());
481
480
  }
482
481
  ensureOpenFinLink() {
483
- return this.openFinLink ??= Lt(je, this.receive, this.diagnostics), this.openFinLink;
482
+ return this.openFinLink ??= jt(ke, this.receive, this.diagnostics), this.openFinLink;
484
483
  }
485
484
  handshake(e) {
486
485
  return new Promise((t) => {
@@ -494,7 +493,7 @@ var Bt = {
494
493
  let i = setTimeout(() => {
495
494
  r(!1);
496
495
  }, this.handshakeOptions.timeoutMs);
497
- C(i), e.post({
496
+ T(i), e.post({
498
497
  t: "hello",
499
498
  from: this.contextId,
500
499
  tabId: this.tabId
@@ -511,7 +510,51 @@ var Bt = {
511
510
  from: this.contextId
512
511
  });
513
512
  }
514
- }, Ut = class {
513
+ }, O = null;
514
+ function k(e, t) {
515
+ let n = e[t];
516
+ return n !== void 0 && e instanceof n;
517
+ }
518
+ function Lt(e) {
519
+ if (O) return O;
520
+ let t = globalThis, n = t.navigator?.userAgent ?? "", r = "browser", i, a, o = !1, s = t.fin?.me;
521
+ return k(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", o = !0) : k(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", o = !0) : k(t, "WorkerGlobalScope") ? (r = "web_worker", o = !0) : s === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 || Rt(n) ? r = "mobile_webview" : typeof document > "u" && typeof process < "u" && (r = "node") : (r = Ve.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "reading fin.me.identity", () => {
522
+ let e = s.identity;
523
+ i = e?.uuid, a = e?.name;
524
+ })), O = {
525
+ platform: r,
526
+ openfinUuid: i,
527
+ openfinName: a,
528
+ userAgent: n,
529
+ isWorker: o,
530
+ isTopLevelDocument: zt()
531
+ }, O;
532
+ }
533
+ function Rt(t) {
534
+ return ut.test(t) ? !0 : (e.test(t) || lt.test(t) && pt.test(t)) && t.includes("AppleWebKit") && !t.includes("Safari/");
535
+ }
536
+ function zt() {
537
+ if (typeof window > "u") return !1;
538
+ try {
539
+ return window.self === window.top;
540
+ } catch {
541
+ return !1;
542
+ }
543
+ }
544
+ function Bt() {
545
+ try {
546
+ return typeof location < "u" ? location.href : "";
547
+ } catch {
548
+ return "";
549
+ }
550
+ }
551
+ function A(e) {
552
+ let t = e.search(/[?#]/);
553
+ return t === -1 ? e : e.slice(0, t);
554
+ }
555
+ //#endregion
556
+ //#region src/capture/errors.ts
557
+ var Vt = class {
515
558
  ctx;
516
559
  name = "errors";
517
560
  installed = !1;
@@ -531,13 +574,14 @@ var Bt = {
531
574
  let t = e.target, n = t?.src ?? t?.href ?? "";
532
575
  if (t !== null && t !== globalThis && n !== "") {
533
576
  if (!this.ctx.config.capture.resourceErrors) return;
577
+ let e = this.ctx.config.capture.fullUrls ? n : A(n);
534
578
  this.ctx.breadcrumbs.push({
535
579
  t: Date.now(),
536
580
  category: "http",
537
- message: `resource failed: ${n}`
581
+ message: `resource failed: ${e}`
538
582
  }), this.ctx.logger.warn("resource failed to load", {
539
583
  "error.type": "resource",
540
- "resource.url": n,
584
+ "resource.url": e,
541
585
  "resource.tag": t.tagName.toLowerCase()
542
586
  });
543
587
  return;
@@ -581,7 +625,7 @@ var Bt = {
581
625
  };
582
626
  //#endregion
583
627
  //#region src/capture/interactions.ts
584
- function Wt(e) {
628
+ function Ht(e) {
585
629
  if (e === null) return "unknown";
586
630
  let t = e.tagName.toLowerCase(), n = e.getAttribute("data-testid") ?? e.getAttribute("data-test-id");
587
631
  if (n !== null) return `[data-testid="${n}"]`;
@@ -591,10 +635,10 @@ function Wt(e) {
591
635
  let i = e.getAttribute("class")?.trim() ?? "";
592
636
  return i === "" ? t : `${t}.${i.split(/\s+/).slice(0, 2).join(".")}`;
593
637
  }
594
- function E() {
638
+ function j() {
595
639
  return history;
596
640
  }
597
- var Gt = class {
641
+ var Ut = class {
598
642
  ctx;
599
643
  name = "interactions";
600
644
  installed = !1;
@@ -608,10 +652,10 @@ var Gt = class {
608
652
  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)));
609
653
  }
610
654
  uninstall() {
611
- this.installed && (this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate), this.originalPushState && (E().pushState = this.originalPushState), this.originalReplaceState && (E().replaceState = this.originalReplaceState), this.originalPushState = null, this.originalReplaceState = null);
655
+ this.installed && (this.installed = !1, removeEventListener("click", this.onClick, !0), removeEventListener("popstate", this.onNavigate), removeEventListener("hashchange", this.onNavigate), this.originalPushState && (j().pushState = this.originalPushState), this.originalReplaceState && (j().replaceState = this.originalReplaceState), this.originalPushState = null, this.originalReplaceState = null);
612
656
  }
613
657
  onClick = (e) => {
614
- let t = e.target, n = Wt(t instanceof Element ? t : null), r = t instanceof HTMLElement ? t.innerText.trim().slice(0, 50) : "";
658
+ let t = e.target, n = Ht(t instanceof Element ? t : null), r = t instanceof HTMLElement ? t.innerText.trim().slice(0, 50) : "";
615
659
  this.ctx.tracing.rotate("interaction"), this.ctx.breadcrumbs.push({
616
660
  t: Date.now(),
617
661
  category: "click",
@@ -621,15 +665,18 @@ var Gt = class {
621
665
  };
622
666
  onNavigate = () => {
623
667
  let e = this.lastUrl, t = location.href;
624
- e !== t && (this.lastUrl = t, this.ctx.tracing.rotate("navigation"), this.ctx.breadcrumbs.push({
668
+ if (e === t) return;
669
+ this.lastUrl = t;
670
+ let n = this.ctx.config.capture.fullUrls, r = n ? e : A(e), i = n ? t : A(t);
671
+ this.ctx.tracing.rotate("navigation"), this.ctx.breadcrumbs.push({
625
672
  t: Date.now(),
626
673
  category: "navigation",
627
- message: `${e} -> ${t}`
628
- }), this.ctx.logger.logEvent("NAVIGATION", { "page.url.previous": e }));
674
+ message: `${r} -> ${i}`
675
+ }), this.ctx.logger.logEvent("NAVIGATION", { "page.url.previous": r });
629
676
  };
630
677
  installHistory() {
631
678
  if (typeof history > "u" || this.originalPushState) return;
632
- let e = E(), t = e.pushState, n = e.replaceState;
679
+ let e = j(), t = e.pushState, n = e.replaceState;
633
680
  this.originalPushState = t, this.originalReplaceState = n;
634
681
  let r = this.onNavigate;
635
682
  e.pushState = function(...e) {
@@ -641,15 +688,15 @@ var Gt = class {
641
688
  };
642
689
  //#endregion
643
690
  //#region src/capture/types.ts
644
- function Kt(e, t) {
691
+ function Wt(e, t) {
645
692
  return t.some((t) => typeof t == "string" ? e.includes(t) : t.test(e));
646
693
  }
647
694
  //#endregion
648
695
  //#region src/capture/network.ts
649
- function D() {
696
+ function M() {
650
697
  return XMLHttpRequest.prototype;
651
698
  }
652
- var qt = class {
699
+ var Gt = class {
653
700
  ctx;
654
701
  name = "network";
655
702
  originalFetch = null;
@@ -662,10 +709,10 @@ var qt = class {
662
709
  this.ctx.config.capture.fetch && this.installFetch(), this.ctx.config.capture.xhr && this.installXhr();
663
710
  }
664
711
  uninstall() {
665
- this.originalFetch &&= (globalThis.fetch = this.originalFetch, null), this.originalOpen &&= (D().open = this.originalOpen, null), this.originalSend &&= (D().send = this.originalSend, null);
712
+ this.originalFetch &&= (globalThis.fetch = this.originalFetch, null), this.originalOpen &&= (M().open = this.originalOpen, null), this.originalSend &&= (M().send = this.originalSend, null);
666
713
  }
667
714
  ignored(e) {
668
- return Kt(e, this.ctx.config.capture.ignoreUrls);
715
+ return Wt(e, this.ctx.config.capture.ignoreUrls);
669
716
  }
670
717
  installFetch() {
671
718
  if (typeof globalThis.fetch != "function" || this.originalFetch) return;
@@ -678,7 +725,7 @@ var qt = class {
678
725
  let o = typeof i == "string" ? i : i instanceof URL ? i.href : i.url, s = (a?.method ?? (i instanceof Request ? i.method : "GET")).toUpperCase();
679
726
  if (n(o)) return e(i, a);
680
727
  let c = i, l = a;
681
- if (Kt(o, t.config.capture.propagateTraceHeaderTo)) try {
728
+ if (Wt(o, t.config.capture.propagateTraceHeaderTo)) try {
682
729
  let e = Object.entries(t.tracing.headers());
683
730
  if (i instanceof Request) {
684
731
  let t = new Headers(i.headers);
@@ -708,7 +755,7 @@ var qt = class {
708
755
  if (typeof XMLHttpRequest > "u" || this.originalOpen) return;
709
756
  let e = (e) => this.ignored(e), t = (e, t, n, r) => {
710
757
  this.record(e, t, n, r, void 0);
711
- }, n = D(), r = n.open, i = n.send;
758
+ }, n = M(), r = n.open, i = n.send;
712
759
  this.originalOpen = r, this.originalSend = i, n.open = function(e, t, ...n) {
713
760
  this.__uiobs = {
714
761
  method: e.toUpperCase(),
@@ -727,41 +774,42 @@ var qt = class {
727
774
  };
728
775
  }
729
776
  record(e, t, n, r, i) {
730
- this.ctx.diagnostics.guard("capture.record_failed", `recording ${e} ${t}`, () => {
731
- let a = Math.round(r);
777
+ let a = this.ctx.config.capture.fullUrls ? t : A(t);
778
+ this.ctx.diagnostics.guard("capture.record_failed", `recording ${e} ${a}`, () => {
779
+ let t = Math.round(r);
732
780
  this.ctx.breadcrumbs.push({
733
781
  t: Date.now(),
734
782
  category: "http",
735
- message: `${e} ${t} ${n === 0 ? "failed" : String(n)}`,
736
- data: { durationMs: a }
783
+ message: `${e} ${a} ${n === 0 ? "failed" : String(n)}`,
784
+ data: { durationMs: t }
737
785
  });
738
786
  let o = {
739
787
  "http.request.method": e,
740
- "url.full": t,
788
+ "url.full": a,
741
789
  "http.response.status_code": n,
742
- "http.duration_ms": a
790
+ "http.duration_ms": t
743
791
  };
744
792
  if (n === 0) {
745
- this.ctx.logger.error(`${e} ${t} failed`, i, o);
793
+ this.ctx.logger.error(`${e} ${a} failed`, i, o);
746
794
  return;
747
795
  }
748
796
  if (n >= 400) {
749
- this.ctx.logger.warn(`${e} ${t} returned ${String(n)}`, o);
797
+ this.ctx.logger.warn(`${e} ${a} returned ${String(n)}`, o);
750
798
  return;
751
799
  }
752
- this.ctx.logger.debug(`${e} ${t}`, o);
800
+ this.ctx.logger.debug(`${e} ${a}`, o);
753
801
  });
754
802
  }
755
803
  };
756
804
  //#endregion
757
805
  //#region src/capture/web-vitals.ts
758
- function Jt() {
806
+ function Kt() {
759
807
  return import(
760
808
  /* @vite-ignore */
761
809
  "web-vitals"
762
810
  );
763
811
  }
764
- var Yt = class {
812
+ var qt = class {
765
813
  ctx;
766
814
  name = "web-vitals";
767
815
  installed = !1;
@@ -775,7 +823,7 @@ var Yt = class {
775
823
  this.installed = !1;
776
824
  }
777
825
  async loadWebVitals() {
778
- let e = this.ctx.config.capture.webVitalsLoader ?? Jt, t = await this.ctx.diagnostics.guardAsync("capture.install_failed", "loading web-vitals", e);
826
+ let e = this.ctx.config.capture.webVitalsLoader ?? Kt, t = await this.ctx.diagnostics.guardAsync("capture.install_failed", "loading web-vitals", e);
779
827
  if (!t) {
780
828
  this.ctx.diagnostics.report("capture.install_failed", "web-vitals is not available, so LCP, CLS and INP are unavailable. Navigation timing still works.");
781
829
  return;
@@ -807,38 +855,38 @@ var Yt = class {
807
855
  };
808
856
  //#endregion
809
857
  //#region src/models/log-record.ts
810
- function O() {
858
+ function Jt() {
811
859
  return `${String(Date.now())}000000`;
812
860
  }
813
- function k(e) {
861
+ function Yt(e) {
814
862
  if (typeof e != "object" || !e) return !1;
815
863
  let t = e;
816
864
  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;
817
865
  }
818
866
  //#endregion
819
867
  //#region src/utils/identity.ts
820
- function A(e) {
868
+ function N(e) {
821
869
  let t = new Uint8Array(e);
822
870
  if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") crypto.getRandomValues(t);
823
871
  else for (let n = 0; n < e; n++) t[n] = Math.floor(Math.random() * 256);
824
872
  return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
825
873
  }
826
- function j() {
874
+ function P() {
827
875
  try {
828
876
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
829
877
  } catch {}
830
- return A(16);
878
+ return N(16);
831
879
  }
832
880
  function Xt(e, t, n) {
833
881
  return n.guard("storage.unavailable", `reading ${e}Storage`, () => (e === "local" ? localStorage : sessionStorage).getItem(t)) ?? null;
834
882
  }
835
- function M(e, t, n, r) {
883
+ function F(e, t, n, r) {
836
884
  r.guard("storage.unavailable", `writing ${e}Storage`, () => {
837
885
  (e === "local" ? localStorage : sessionStorage).setItem(t, n);
838
886
  });
839
887
  }
840
888
  function Zt(e) {
841
- let t = j(), n = Date.now(), r = j(), i = Xt("local", _, e);
889
+ let t = P(), n = Date.now(), r = P(), i = Xt("local", v, e);
842
890
  if (i) try {
843
891
  let e = JSON.parse(i);
844
892
  e.id && n - (e.lastSeenAt ?? 0) < 18e5 && (r = e.id);
@@ -849,9 +897,9 @@ function Zt(e) {
849
897
  id: r,
850
898
  lastSeenAt: n
851
899
  });
852
- M("local", _, a, e);
900
+ F("local", v, a, e);
853
901
  let o = Xt("session", "ui-observability.tab", e) ?? "";
854
- return o || (o = j(), M("session", pe, o, e)), {
902
+ return o || (o = P(), F("session", fe, o, e)), {
855
903
  sessionId: r,
856
904
  tabId: o,
857
905
  contextId: t
@@ -866,7 +914,7 @@ function $t(e, t) {
866
914
  id: e,
867
915
  lastSeenAt: n
868
916
  });
869
- M("local", _, r, t);
917
+ F("local", v, r, t);
870
918
  }
871
919
  //#endregion
872
920
  //#region src/models/batch.ts
@@ -878,7 +926,7 @@ function en(e) {
878
926
  function tn(e) {
879
927
  if (e.records.length < 2) return null;
880
928
  let t = Math.floor(e.records.length / 2), n = (t) => ({
881
- id: j(),
929
+ id: P(),
882
930
  records: t,
883
931
  createdAt: e.createdAt,
884
932
  attempts: e.attempts
@@ -893,7 +941,7 @@ function nn(e, t, n, { skipIfBusy: r = !0 } = {}) {
893
941
  }
894
942
  //#endregion
895
943
  //#region src/storage/keys.ts
896
- function N(e, t) {
944
+ function I(e, t) {
897
945
  let n = [];
898
946
  return t.guard("storage.unavailable", "enumerating localStorage", () => {
899
947
  for (let t = 0; t < localStorage.length; t++) {
@@ -906,7 +954,7 @@ function N(e, t) {
906
954
  //#region src/storage/emergency-queue.ts
907
955
  function rn(e) {
908
956
  let t = String(e.createdAt).padStart(14, "0");
909
- return `${g}${t}.${e.id}`;
957
+ return `${_}${t}.${e.id}`;
910
958
  }
911
959
  function an(e, t) {
912
960
  let n = t.guard("storage.degraded", "an emergency entry was not JSON and was dropped", () => JSON.parse(e));
@@ -914,7 +962,7 @@ function an(e, t) {
914
962
  }
915
963
  async function on(e, t) {
916
964
  let n = 0;
917
- for (let r of N(g, t)) {
965
+ for (let r of I(_, t)) {
918
966
  let i = t.guard("storage.unavailable", "reading the emergency queue", () => {
919
967
  let e = localStorage.getItem(r);
920
968
  return localStorage.removeItem(r), e;
@@ -932,7 +980,7 @@ async function on(e, t) {
932
980
  function sn(e, t) {
933
981
  let n = `writing the emergency queue, ${String(e.records.length)} records`;
934
982
  t.guard("storage.quota_exceeded", n, () => {
935
- let n = N(g, t);
983
+ let n = I(_, t);
936
984
  for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) localStorage.removeItem(e);
937
985
  localStorage.setItem(rn(e), JSON.stringify(e));
938
986
  });
@@ -944,13 +992,13 @@ async function cn(e, t) {
944
992
  //#region src/storage/local-storage.ts
945
993
  function ln(e) {
946
994
  let t = String(e.createdAt).padStart(14, "0");
947
- return `${gt}${t}.${e.id}`;
995
+ return `${mt}${t}.${e.id}`;
948
996
  }
949
997
  var un = class {
950
998
  limits;
951
999
  diagnostics;
952
1000
  onGap;
953
- name = ne;
1001
+ name = te;
954
1002
  constructor(e, t, n) {
955
1003
  this.limits = e, this.diagnostics = t, this.onGap = n;
956
1004
  }
@@ -1043,18 +1091,18 @@ var un = class {
1043
1091
  });
1044
1092
  }
1045
1093
  keys() {
1046
- return N(gt, this.diagnostics);
1094
+ return I(mt, this.diagnostics);
1047
1095
  }
1048
1096
  };
1049
1097
  //#endregion
1050
1098
  //#region src/storage/memory-storage.ts
1051
- function P(e) {
1099
+ function dn(e) {
1052
1100
  return e.reduce((e, t) => e + t.records.length, 0);
1053
1101
  }
1054
- var F = class {
1102
+ var L = class {
1055
1103
  limits;
1056
1104
  onGap;
1057
- name = we;
1105
+ name = Ce;
1058
1106
  batches = [];
1059
1107
  constructor(e, t) {
1060
1108
  this.limits = e, this.onGap = t;
@@ -1078,12 +1126,12 @@ var F = class {
1078
1126
  records: 0,
1079
1127
  reason: "expired"
1080
1128
  }, n = this.batches.filter((t) => t.createdAt < e);
1081
- this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records += P(n);
1129
+ this.batches = this.batches.filter((t) => t.createdAt >= e), t.batches += n.length, t.records += dn(n);
1082
1130
  let r = this.batches.length - this.limits.maxBatches;
1083
1131
  if (r > 0) {
1084
1132
  t.reason = "over_capacity";
1085
1133
  let e = this.batches.slice(0, r);
1086
- this.batches = this.batches.slice(r), t.batches += e.length, t.records += P(e);
1134
+ this.batches = this.batches.slice(r), t.batches += e.length, t.records += dn(e);
1087
1135
  }
1088
1136
  return t.batches > 0 && this.onGap?.(t), Promise.resolve(t);
1089
1137
  }
@@ -1096,8 +1144,8 @@ var F = class {
1096
1144
  close() {
1097
1145
  return this.batches = [], Promise.resolve();
1098
1146
  }
1099
- }, dn = {
1100
- name: Ce,
1147
+ }, fn = {
1148
+ name: Se,
1101
1149
  save: () => Promise.resolve(),
1102
1150
  take: () => Promise.resolve([]),
1103
1151
  remove: () => Promise.resolve(),
@@ -1111,112 +1159,112 @@ var F = class {
1111
1159
  clear: () => Promise.resolve(),
1112
1160
  close: () => Promise.resolve()
1113
1161
  };
1114
- function fn(e) {
1162
+ function pn(e) {
1115
1163
  return e.guard("storage.unavailable", "reading indexedDB", () => globalThis.indexedDB != null) === !0;
1116
1164
  }
1117
- function pn(e) {
1118
- return e.guard("storage.unavailable", "probing localStorage", () => (localStorage.setItem(Te, "1"), localStorage.removeItem(Te), !0)) === !0;
1165
+ function mn(e) {
1166
+ return e.guard("storage.unavailable", "probing localStorage", () => (localStorage.setItem(we, "1"), localStorage.removeItem(we), !0)) === !0;
1119
1167
  }
1120
- async function mn(e, t, n, r, i) {
1121
- if (e === "none") return dn;
1122
- if (e === "memory") return new F(n, i);
1168
+ async function hn(e, t, n, r, i) {
1169
+ if (e === "none") return fn;
1170
+ if (e === "memory") return new L(n, i);
1123
1171
  if (e === "indexeddb" || e === "auto") {
1124
- if (fn(r)) {
1172
+ if (pn(r)) {
1125
1173
  let e = await r.guardAsync("storage.unavailable", "opening IndexedDB", async () => {
1126
- let { IndexedDbStorage: e } = await import("./indexeddb-storage-DAoHV_oL.js");
1174
+ let { IndexedDbStorage: e } = await import("./indexeddb-storage-bibcl7ZS.js");
1127
1175
  return new e(t, n, r, i);
1128
1176
  });
1129
1177
  if (e) return e;
1130
1178
  }
1131
- if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new F(n, i);
1179
+ if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB was asked for by name and is unavailable, using memory"), new L(n, i);
1132
1180
  }
1133
- return pn(r) ? new un(n, r, i) : (r.report("storage.degraded", "no persistent storage available, offline logs are memory only"), new F(n, i));
1181
+ return mn(r) ? new un(n, r, i) : (r.report("storage.degraded", "no persistent storage available, offline logs are memory only"), new L(n, i));
1134
1182
  }
1135
1183
  //#endregion
1136
1184
  //#region src/utils/sanitize.ts
1137
- function I(e, t) {
1185
+ function R(e, t) {
1138
1186
  if (e.length <= t) return e;
1139
- let n = hn(e.charCodeAt(t - 1)) ? t - 1 : t;
1187
+ let n = gn(e.charCodeAt(t - 1)) ? t - 1 : t;
1140
1188
  return `${e.slice(0, n)}… [truncated ${String(e.length - n)} chars]`;
1141
1189
  }
1142
- function hn(e) {
1190
+ function gn(e) {
1143
1191
  return e >= 55296 && e <= 56319;
1144
1192
  }
1145
- function gn(e) {
1193
+ function _n(e) {
1146
1194
  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(".")}` : ""}]`;
1147
1195
  }
1148
- function L(e, t) {
1196
+ function z(e, t) {
1149
1197
  let n = { bytes: 0 };
1150
1198
  return {
1151
- value: z(e, t, /* @__PURE__ */ new WeakSet(), 0, n),
1199
+ value: V(e, t, /* @__PURE__ */ new WeakSet(), 0, n),
1152
1200
  bytes: n.bytes
1153
1201
  };
1154
1202
  }
1155
- function R(e, t) {
1156
- return t.bytes += B(e) + 2, e;
1203
+ function B(e, t) {
1204
+ return t.bytes += H(e) + 2, e;
1157
1205
  }
1158
- function z(e, t, n, r, i) {
1206
+ function V(e, t, n, r, i) {
1159
1207
  if (e == null) return i.bytes += 4, e;
1160
- if (typeof e == "string") return R(I(e, t.maxAttributeChars), i);
1208
+ if (typeof e == "string") return B(R(e, t.maxAttributeChars), i);
1161
1209
  if (typeof e == "number") return i.bytes += 8, Number.isFinite(e) ? e : String(e);
1162
1210
  if (typeof e == "boolean") return i.bytes += 5, e;
1163
- if (typeof e == "bigint") return R(`${e.toString()}n`, i);
1164
- if (typeof e == "symbol") return R(e.toString(), i);
1165
- if (typeof e == "function") return R(`[Function ${e.name === "" ? "anonymous" : e.name}]`, i);
1166
- if (r >= t.maxDepth) return R("[MaxDepth]", i);
1167
- if (n.has(e)) return R("[Circular]", i);
1211
+ if (typeof e == "bigint") return B(`${e.toString()}n`, i);
1212
+ if (typeof e == "symbol") return B(e.toString(), i);
1213
+ if (typeof e == "function") return B(`[Function ${e.name === "" ? "anonymous" : e.name}]`, i);
1214
+ if (r >= t.maxDepth) return B("[MaxDepth]", i);
1215
+ if (n.has(e)) return B("[Circular]", i);
1168
1216
  n.add(e), i.bytes += 2;
1169
1217
  try {
1170
1218
  if (e instanceof Error) return {
1171
- name: R(e.name, i),
1172
- message: R(I(e.message, t.maxAttributeChars), i),
1173
- stack: e.stack ? R(I(e.stack, t.maxStackChars), i) : void 0,
1174
- cause: e.cause ? z(e.cause, t, n, r + 1, i) : void 0
1219
+ name: B(e.name, i),
1220
+ message: B(R(e.message, t.maxAttributeChars), i),
1221
+ stack: e.stack ? B(R(e.stack, t.maxStackChars), i) : void 0,
1222
+ cause: e.cause ? V(e.cause, t, n, r + 1, i) : void 0
1175
1223
  };
1176
- if (e instanceof Date) return R(e.toISOString(), i);
1177
- if (e instanceof RegExp) return R(e.toString(), i);
1224
+ if (e instanceof Date) return B(e.toISOString(), i);
1225
+ if (e instanceof RegExp) return B(e.toString(), i);
1178
1226
  if (e instanceof Map) {
1179
1227
  let a = e, o = {}, s = 0;
1180
1228
  for (let [e, c] of a) {
1181
1229
  if (s >= t.maxArrayLength) {
1182
- o["…"] = R(`[${String(a.size - t.maxArrayLength)} more entries]`, i);
1230
+ o["…"] = B(`[${String(a.size - t.maxArrayLength)} more entries]`, i);
1183
1231
  break;
1184
1232
  }
1185
1233
  s++;
1186
1234
  let l = String(e);
1187
- i.bytes += B(l) + 4, o[l] = z(c, t, n, r + 1, i);
1235
+ i.bytes += H(l) + 4, o[l] = V(c, t, n, r + 1, i);
1188
1236
  }
1189
1237
  return o;
1190
1238
  }
1191
- if (e instanceof Set) return z([...e].slice(0, t.maxArrayLength), t, n, r, i);
1239
+ if (e instanceof Set) return V([...e].slice(0, t.maxArrayLength), t, n, r, i);
1192
1240
  if (ArrayBuffer.isView(e)) {
1193
1241
  let t = e.length ?? 0;
1194
- return R(`[${e.constructor.name}(${String(t)})]`, i);
1242
+ return B(`[${e.constructor.name}(${String(t)})]`, i);
1195
1243
  }
1196
- if (e instanceof Promise) return R("[Promise]", i);
1197
- if (typeof Node < "u" && e instanceof Node) return R(gn(e), i);
1244
+ if (e instanceof Promise) return B("[Promise]", i);
1245
+ if (typeof Node < "u" && e instanceof Node) return B(_n(e), i);
1198
1246
  if (Array.isArray(e)) {
1199
- let a = e, o = a.slice(0, t.maxArrayLength).map((e) => z(e, t, n, r + 1, i));
1200
- return a.length > t.maxArrayLength && o.push(R(`[${String(a.length - t.maxArrayLength)} more items]`, i)), o;
1247
+ let a = e, o = a.slice(0, t.maxArrayLength).map((e) => V(e, t, n, r + 1, i));
1248
+ return a.length > t.maxArrayLength && o.push(B(`[${String(a.length - t.maxArrayLength)} more items]`, i)), o;
1201
1249
  }
1202
1250
  let a = e.toJSON;
1203
- if (typeof a == "function") return z(a.call(e), t, n, r + 1, i);
1251
+ if (typeof a == "function") return V(a.call(e), t, n, r + 1, i);
1204
1252
  let o = e, s = Object.keys(o), c = {}, l = 0;
1205
1253
  for (let e of s) {
1206
1254
  if (l >= t.maxAttributeCount) {
1207
- c["…"] = R(`[${String(s.length - l)} more keys]`, i);
1255
+ c["…"] = B(`[${String(s.length - l)} more keys]`, i);
1208
1256
  break;
1209
1257
  }
1210
- l++, i.bytes += B(e) + 4, c[e] = z(o[e], t, n, r + 1, i);
1258
+ l++, i.bytes += H(e) + 4, c[e] = V(o[e], t, n, r + 1, i);
1211
1259
  }
1212
1260
  return c;
1213
1261
  } catch (e) {
1214
- return R(`[Unserializable: ${e instanceof Error ? e.name : "error"}]`, i);
1262
+ return B(`[Unserializable: ${e instanceof Error ? e.name : "error"}]`, i);
1215
1263
  } finally {
1216
1264
  n.delete(e);
1217
1265
  }
1218
1266
  }
1219
- function B(e) {
1267
+ function H(e) {
1220
1268
  let t = 0;
1221
1269
  for (let n = 0; n < e.length; n++) {
1222
1270
  let r = e.charCodeAt(n);
@@ -1226,7 +1274,7 @@ function B(e) {
1226
1274
  }
1227
1275
  //#endregion
1228
1276
  //#region src/transport/exit-flush.ts
1229
- var _n = class {
1277
+ var vn = class {
1230
1278
  deps;
1231
1279
  installed = !1;
1232
1280
  onVisibility = () => {
@@ -1263,15 +1311,15 @@ var _n = class {
1263
1311
  flush(e) {
1264
1312
  let { diagnostics: t } = this.deps, n = this.endpointUrl();
1265
1313
  if (n === null) return;
1266
- let r = this.deps.drainPending();
1314
+ let r = this.deps.drainForExit();
1267
1315
  if (!r || r.records.length === 0) return;
1268
1316
  let i = t.guard("transport.serialize_failed", `the ${e} exit flush could not serialize its batch`, () => this.deps.config.serializer.serialize(r.records));
1269
1317
  if (!i) return;
1270
- if (B(i.body) > 6e4) {
1318
+ if (H(i.body) > 6e4) {
1271
1319
  sn(r, t);
1272
1320
  return;
1273
1321
  }
1274
- n.searchParams.set(Ve, r.id), n.searchParams.set(De, e);
1322
+ n.searchParams.set(ze, r.id), n.searchParams.set(Ee, e);
1275
1323
  let a = n.toString();
1276
1324
  this.beacon(a, i.body) || this.keepaliveFetch(a, i.body, e);
1277
1325
  }
@@ -1291,7 +1339,7 @@ var _n = class {
1291
1339
  fetch(e, {
1292
1340
  method: "POST",
1293
1341
  body: t,
1294
- headers: { [st]: n },
1342
+ headers: { [at]: n },
1295
1343
  credentials: i.credentials,
1296
1344
  keepalive: !0
1297
1345
  }).catch((e) => {
@@ -1302,15 +1350,15 @@ var _n = class {
1302
1350
  };
1303
1351
  //#endregion
1304
1352
  //#region src/transport/compression.ts
1305
- async function vn(e) {
1353
+ async function yn(e) {
1306
1354
  let t = globalThis.CompressionStream;
1307
1355
  if (t === void 0) return null;
1308
- let n = new Blob([e]).stream().pipeThrough(new t(me)), r = await new Response(n).arrayBuffer();
1356
+ let n = new Blob([e]).stream().pipeThrough(new t(pe)), r = await new Response(n).arrayBuffer();
1309
1357
  return new Uint8Array(r);
1310
1358
  }
1311
1359
  //#endregion
1312
1360
  //#region src/transport/errors.ts
1313
- var V = class extends Error {
1361
+ var U = class extends Error {
1314
1362
  kind;
1315
1363
  status;
1316
1364
  retryAfterMs;
@@ -1319,16 +1367,16 @@ var V = class extends Error {
1319
1367
  super(t), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
1320
1368
  }
1321
1369
  };
1322
- function yn(e) {
1370
+ function bn(e) {
1323
1371
  if (!e) return;
1324
1372
  let t = Number(e);
1325
- if (Number.isFinite(t)) return Math.max(0, t * Ze);
1373
+ if (Number.isFinite(t)) return Math.max(0, t * Ye);
1326
1374
  let n = Date.parse(e);
1327
1375
  return Number.isNaN(n) ? void 0 : Math.max(0, n - Date.now());
1328
1376
  }
1329
1377
  //#endregion
1330
1378
  //#region src/transport/http-transport.ts
1331
- var bn = class {
1379
+ var xn = class {
1332
1380
  config;
1333
1381
  diagnostics;
1334
1382
  throttledUntil = 0;
@@ -1350,9 +1398,9 @@ var bn = class {
1350
1398
  return;
1351
1399
  }
1352
1400
  let r = new Headers(await this.resolveHeaders());
1353
- r.set(st, n.contentType), r.set(p, e.id), r.set(xe, String(e.attempts));
1401
+ r.set(at, n.contentType), r.set(p, e.id), r.set(be, String(e.attempts));
1354
1402
  let i = await this.encodeBody(n.body);
1355
- typeof i != "string" && r.set(re, me);
1403
+ typeof i != "string" && r.set(ne, pe);
1356
1404
  let a = await this.dispatch(r, i);
1357
1405
  if (a.ok) {
1358
1406
  this.throttledUntil = 0;
@@ -1362,13 +1410,13 @@ var bn = class {
1362
1410
  }
1363
1411
  async encodeBody(e) {
1364
1412
  let { config: t } = this;
1365
- return t.compression !== "gzip" || B(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "gzipping the payload", () => vn(e)) ?? e;
1413
+ return t.compression !== "gzip" || H(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "gzipping the payload", () => yn(e)) ?? e;
1366
1414
  }
1367
1415
  async dispatch(e, t) {
1368
1416
  let { config: n } = this, r = new AbortController(), i = setTimeout(() => {
1369
1417
  r.abort();
1370
- }, Me);
1371
- C(i);
1418
+ }, Ae);
1419
+ T(i);
1372
1420
  try {
1373
1421
  return await fetch(n.endpoint, {
1374
1422
  method: "POST",
@@ -1379,28 +1427,28 @@ var bn = class {
1379
1427
  cache: "no-store"
1380
1428
  });
1381
1429
  } catch {
1382
- if (r.signal.aborted) throw new V("timeout", `request exceeded ${String(Me)}ms`);
1430
+ if (r.signal.aborted) throw new U("timeout", `request exceeded ${String(Ae)}ms`);
1383
1431
  let e = globalThis.navigator?.onLine;
1384
- throw new V(e === !1 ? "offline" : "transient", "network error");
1432
+ throw new U(e === !1 ? "offline" : "transient", "network error");
1385
1433
  } finally {
1386
1434
  clearTimeout(i);
1387
1435
  }
1388
1436
  }
1389
1437
  async classify(e, t) {
1390
- let n = e.status, r = yn(e.headers.get(te));
1438
+ let n = e.status, r = bn(e.headers.get(ee));
1391
1439
  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.`, {
1392
1440
  status: n,
1393
1441
  endpoint: this.config.endpoint
1394
- }), new V("permanent", `rejected with ${String(n)}`, n);
1395
- if (n === 413) return new V("too_large", "payload too large", n, void 0, await this.readMaxBytes(e));
1442
+ }), new U("permanent", `rejected with ${String(n)}`, n);
1443
+ if (n === 413) return new U("too_large", "payload too large", n, void 0, await this.readMaxBytes(e));
1396
1444
  if (n === 429 || n === 503) {
1397
1445
  let e = n === 429;
1398
- return this.throttledUntil = Date.now() + (r ?? 2e3), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new V("throttled", e ? "throttled" : "service unavailable", n, r);
1446
+ return this.throttledUntil = Date.now() + (r ?? 2e3), e && this.diagnostics.report("transport.throttled", "server throttled us", { retryAfterMs: r }), new U("throttled", e ? "throttled" : "service unavailable", n, r);
1399
1447
  }
1400
- return n === 408 || n >= 500 ? new V("transient", `server error ${String(n)}`, n) : (this.diagnostics.report("transport.dropped_permanent", `server rejected the batch with ${String(n)}, dropping it`, {
1448
+ return n === 408 || n >= 500 ? new U("transient", `server error ${String(n)}`, n) : (this.diagnostics.report("transport.dropped_permanent", `server rejected the batch with ${String(n)}, dropping it`, {
1401
1449
  batchId: t,
1402
1450
  status: n
1403
- }), new V("permanent", `rejected with ${String(n)}`, n));
1451
+ }), new U("permanent", `rejected with ${String(n)}`, n));
1404
1452
  }
1405
1453
  async readMaxBytes(e) {
1406
1454
  return this.diagnostics.guardAsync("transport.http_error", "reading the 413 body", async () => {
@@ -1412,7 +1460,7 @@ var bn = class {
1412
1460
  let { headers: e } = this.config;
1413
1461
  return e ? typeof e == "function" ? await this.diagnostics.guardAsync("transport.http_error", "headers() threw", () => Promise.resolve(e())) ?? {} : e : {};
1414
1462
  }
1415
- }, xn = class {
1463
+ }, Sn = class {
1416
1464
  storage;
1417
1465
  transport;
1418
1466
  diagnostics;
@@ -1432,7 +1480,7 @@ var bn = class {
1432
1480
  this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(f);
1433
1481
  }
1434
1482
  nudge() {
1435
- this.draining || this.schedule(fe);
1483
+ this.draining || this.schedule(de);
1436
1484
  }
1437
1485
  stop() {
1438
1486
  this.stopped = !0, typeof removeEventListener < "u" && removeEventListener("online", this.onOnline), this.clearTimer();
@@ -1443,13 +1491,13 @@ var bn = class {
1443
1491
  let t = setTimeout(() => {
1444
1492
  this.drain();
1445
1493
  }, e);
1446
- this.timer = t, C(t);
1494
+ this.timer = t, T(t);
1447
1495
  }
1448
1496
  clearTimer() {
1449
1497
  this.timer !== null && (clearTimeout(this.timer), this.timer = null);
1450
1498
  }
1451
1499
  backoffMs() {
1452
- let e = Math.min(fe * 2 ** this.attempt, ee);
1500
+ let e = Math.min(de * 2 ** this.attempt, g);
1453
1501
  return Math.random() * e;
1454
1502
  }
1455
1503
  async drain() {
@@ -1481,7 +1529,7 @@ var bn = class {
1481
1529
  try {
1482
1530
  return await this.transport.send(e), await this.storage.remove(e.id), this.attempt = 0, !0;
1483
1531
  } catch (t) {
1484
- let n = t instanceof V ? t : void 0;
1532
+ let n = t instanceof U ? t : void 0;
1485
1533
  return n?.kind === "permanent" ? (await this.storage.remove(e.id), !0) : n?.kind === "too_large" ? (await this.splitStored(e, n.maxBytes), !0) : n?.kind === "offline" ? (this.schedule(f), !1) : (await this.storage.bumpAttempts(e.id, e.attempts + 1), this.attempt++, this.schedule(n?.retryAfterMs ?? this.backoffMs()), !1);
1486
1534
  }
1487
1535
  }
@@ -1501,14 +1549,14 @@ var bn = class {
1501
1549
  });
1502
1550
  for (let e of n) await this.storage.save(e);
1503
1551
  }
1504
- }, Sn = {
1552
+ }, Cn = {
1505
1553
  TRACE: "debug",
1506
1554
  DEBUG: "debug",
1507
1555
  INFO: "info",
1508
1556
  WARN: "warn",
1509
1557
  ERROR: "error",
1510
1558
  FATAL: "error"
1511
- }, Cn = class {
1559
+ }, wn = class {
1512
1560
  minLevel;
1513
1561
  constructor(e) {
1514
1562
  this.minLevel = e;
@@ -1517,55 +1565,15 @@ var bn = class {
1517
1565
  this.minLevel = e;
1518
1566
  }
1519
1567
  write(e, t, n) {
1520
- if (this.minLevel === null || b[e] < b[this.minLevel] || typeof console > "u") return;
1521
- let r = `%c${Ke}%c ${e}`;
1568
+ if (this.minLevel === null || S[e] < S[this.minLevel] || typeof console > "u") return;
1569
+ let r = `%c${We}%c ${e}`;
1522
1570
  if (n === void 0) {
1523
- console[Sn[e]](r, s, "", t);
1571
+ console[Cn[e]](r, s, "", t);
1524
1572
  return;
1525
1573
  }
1526
- console[Sn[e]](r, s, "", t, n);
1527
- }
1528
- }, H = null;
1529
- function U(e, t) {
1530
- let n = e[t];
1531
- return n !== void 0 && e instanceof n;
1532
- }
1533
- function wn(e) {
1534
- if (H) return H;
1535
- let t = globalThis, n = t.navigator?.userAgent ?? "", r = "browser", i, a, o = !1, s = t.fin?.me;
1536
- return U(t, "ServiceWorkerGlobalScope") ? (r = "service_worker", o = !0) : U(t, "SharedWorkerGlobalScope") ? (r = "shared_worker", o = !0) : U(t, "WorkerGlobalScope") ? (r = "web_worker", o = !0) : s === void 0 ? t.Capacitor !== void 0 || t.Ionic !== void 0 ? r = "ionic" : t.cordova !== void 0 || Tn(n) ? r = "mobile_webview" : typeof document > "u" && typeof process < "u" && (r = "node") : (r = Ue.test(n) ? "openfin" : "openfin_web", e.guard("openfin.unavailable", "reading fin.me.identity", () => {
1537
- let e = s.identity;
1538
- i = e?.uuid, a = e?.name;
1539
- })), H = {
1540
- platform: r,
1541
- openfinUuid: i,
1542
- openfinName: a,
1543
- userAgent: n,
1544
- isWorker: o,
1545
- isTopLevelDocument: En()
1546
- }, H;
1547
- }
1548
- function Tn(t) {
1549
- return ft.test(t) ? !0 : (e.test(t) || dt.test(t) && ht.test(t)) && t.includes("AppleWebKit") && !t.includes("Safari/");
1550
- }
1551
- function En() {
1552
- if (typeof window > "u") return !1;
1553
- try {
1554
- return window.self === window.top;
1555
- } catch {
1556
- return !1;
1574
+ console[Cn[e]](r, s, "", t, n);
1557
1575
  }
1558
- }
1559
- function Dn() {
1560
- try {
1561
- return typeof location < "u" ? location.href : "";
1562
- } catch {
1563
- return "";
1564
- }
1565
- }
1566
- //#endregion
1567
- //#region src/utils/sequence.ts
1568
- var On = class {
1576
+ }, Tn = class {
1569
1577
  value = 0;
1570
1578
  next() {
1571
1579
  return ++this.value;
@@ -1573,64 +1581,84 @@ var On = class {
1573
1581
  reset() {
1574
1582
  this.value = 0;
1575
1583
  }
1576
- };
1577
- //#endregion
1578
- //#region src/utils/tracing.ts
1584
+ }, En = /^[0-9a-f]{32}$/, Dn = /^[0-9a-f]{16}$/, On = /[1-9a-f]/;
1579
1585
  function kn() {
1580
- return A(16);
1586
+ return import(
1587
+ /* @vite-ignore */
1588
+ "@opentelemetry/api"
1589
+ );
1581
1590
  }
1582
- function An() {
1583
- return A(8);
1591
+ function An(e) {
1592
+ return En.test(e.traceId) && On.test(e.traceId) && Dn.test(e.spanId) && On.test(e.spanId);
1584
1593
  }
1585
1594
  function jn() {
1595
+ return N(16);
1596
+ }
1597
+ function Mn() {
1598
+ return N(8);
1599
+ }
1600
+ function Nn() {
1586
1601
  return {
1587
- traceId: kn(),
1588
- spanId: An(),
1602
+ traceId: jn(),
1603
+ spanId: Mn(),
1589
1604
  traceFlags: 1,
1590
1605
  startedAt: Date.now()
1591
1606
  };
1592
1607
  }
1593
- function Mn(e) {
1608
+ function Pn(e) {
1594
1609
  return {
1595
1610
  traceId: e.traceId,
1596
1611
  spanId: e.spanId,
1597
1612
  traceFlags: e.traceFlags
1598
1613
  };
1599
1614
  }
1600
- var Nn = class {
1615
+ var Fn = class {
1601
1616
  diagnostics;
1602
1617
  maxAgeMs;
1603
- ambient = jn();
1604
- constructor(e, t = lt) {
1605
- this.diagnostics = e, this.maxAgeMs = t;
1618
+ load;
1619
+ ambient = Nn();
1620
+ otel;
1621
+ constructor(e, t = st, n = kn) {
1622
+ this.diagnostics = e, this.maxAgeMs = t, this.load = n;
1623
+ }
1624
+ async loadOtel() {
1625
+ try {
1626
+ this.otel = await this.load();
1627
+ } catch (e) {
1628
+ this.diagnostics.report("trace.otel_failed", "@opentelemetry/api is not available, so records carry this library's own trace ids", void 0, e);
1629
+ }
1606
1630
  }
1607
1631
  resolve() {
1608
- let e = this.diagnostics.guard("trace.otel_failed", "reading the active OpenTelemetry span", () => {
1609
- let e = Tt.getActiveSpan();
1610
- if (e === void 0) return;
1611
- let t = e.spanContext();
1612
- if (Ct(t)) return {
1613
- traceId: t.traceId,
1614
- spanId: t.spanId,
1615
- traceFlags: t.traceFlags
1632
+ let e = this.activeSpanContext();
1633
+ return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), Pn(this.ambient)) : e;
1634
+ }
1635
+ activeSpanContext() {
1636
+ let e = this.otel;
1637
+ if (e) return this.diagnostics.guard("trace.otel_failed", "reading the active OpenTelemetry span", () => {
1638
+ let t = e.trace.getActiveSpan();
1639
+ if (t === void 0) return;
1640
+ let n = t.spanContext();
1641
+ if (An(n)) return {
1642
+ traceId: n.traceId,
1643
+ spanId: n.spanId,
1644
+ traceFlags: n.traceFlags
1616
1645
  };
1617
1646
  });
1618
- return e === void 0 ? (Date.now() - this.ambient.startedAt > this.maxAgeMs && this.rotate("maxAge"), Mn(this.ambient)) : e;
1619
1647
  }
1620
1648
  rotate(e) {
1621
- return this.ambient = jn(), Mn(this.ambient);
1649
+ return this.ambient = Nn(), Pn(this.ambient);
1622
1650
  }
1623
1651
  headers() {
1624
- let e = {};
1625
- if (this.diagnostics.guard("trace.otel_failed", "injecting OpenTelemetry headers", () => {
1626
- wt.inject(St.active(), e);
1652
+ let e = {}, t = this.otel;
1653
+ if (t && this.diagnostics.guard("trace.otel_failed", "injecting OpenTelemetry headers", () => {
1654
+ t.propagation.inject(t.context.active(), e);
1627
1655
  }), !e.traceparent) {
1628
1656
  let t = this.resolve(), n = (t.traceFlags & 255).toString(16).padStart(2, "0");
1629
- e[et] = `00-${t.traceId}-${t.spanId}-${n}`;
1657
+ e[Qe] = `00-${t.traceId}-${t.spanId}-${n}`;
1630
1658
  }
1631
1659
  return e;
1632
1660
  }
1633
- }, Pn = class {
1661
+ }, In = class {
1634
1662
  buffer;
1635
1663
  pointer = 0;
1636
1664
  filled = !1;
@@ -1650,15 +1678,15 @@ var Nn = class {
1650
1678
  };
1651
1679
  //#endregion
1652
1680
  //#region src/transport/serializers/ecs.ts
1653
- function Fn(e) {
1654
- return Ie.test(e) ? Number(BigInt(e) / ze) : Date.now();
1681
+ function Ln(e) {
1682
+ return Pe.test(e) ? Number(BigInt(e) / Le) : Date.now();
1655
1683
  }
1656
- var In = {
1684
+ var Rn = {
1657
1685
  name: "ecs",
1658
1686
  serialize(e) {
1659
1687
  return {
1660
1688
  body: `${e.map((e) => {
1661
- let t = Fn(e.timeUnixNano);
1689
+ let t = Ln(e.timeUnixNano);
1662
1690
  return JSON.stringify({
1663
1691
  "@timestamp": new Date(t).toISOString(),
1664
1692
  message: e.body,
@@ -1667,10 +1695,10 @@ var In = {
1667
1695
  span: { id: e.spanId },
1668
1696
  service: {
1669
1697
  name: e.resource[c],
1670
- version: e.resource[de],
1698
+ version: e.resource[ue],
1671
1699
  environment: e.resource[o]
1672
1700
  },
1673
- user_agent: { original: e.resource[yt] },
1701
+ user_agent: { original: e.resource[_t] },
1674
1702
  url: { full: e.attributes["url.full"] ?? e.attributes["page.url"] },
1675
1703
  labels: {
1676
1704
  ...e.resource,
@@ -1678,19 +1706,19 @@ var In = {
1678
1706
  }
1679
1707
  });
1680
1708
  }).join("\n")}\n`,
1681
- contentType: Ye
1709
+ contentType: qe
1682
1710
  };
1683
1711
  }
1684
1712
  };
1685
1713
  //#endregion
1686
1714
  //#region src/transport/serializers/otlp.ts
1687
- function Ln(e) {
1688
- return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(Ln).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: W(e) } } : null;
1715
+ function zn(e) {
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(zn).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: W(e) } } : null;
1689
1717
  }
1690
1718
  function W(e) {
1691
1719
  let t = [];
1692
1720
  for (let [n, r] of Object.entries(e)) {
1693
- let e = Ln(r);
1721
+ let e = zn(r);
1694
1722
  e && t.push({
1695
1723
  key: n,
1696
1724
  value: e
@@ -1698,19 +1726,19 @@ function W(e) {
1698
1726
  }
1699
1727
  return t;
1700
1728
  }
1701
- var Rn = /* @__PURE__ */ new WeakMap();
1702
- function zn(e) {
1703
- let t = Rn.get(e);
1729
+ var Bn = /* @__PURE__ */ new WeakMap();
1730
+ function Vn(e) {
1731
+ let t = Bn.get(e);
1704
1732
  if (t !== void 0) return t;
1705
1733
  let n = JSON.stringify(e);
1706
- return Rn.set(e, n), n;
1734
+ return Bn.set(e, n), n;
1707
1735
  }
1708
1736
  var G = {
1709
- name: xt,
1737
+ name: yt,
1710
1738
  serialize(e) {
1711
1739
  let t = /* @__PURE__ */ new Map();
1712
1740
  for (let n of e) {
1713
- let e = zn(n.resource), r = t.get(e);
1741
+ let e = Vn(n.resource), r = t.get(e);
1714
1742
  if (r) {
1715
1743
  r.records.push(n);
1716
1744
  continue;
@@ -1724,8 +1752,8 @@ var G = {
1724
1752
  resource: { attributes: W(e.resource) },
1725
1753
  scopeLogs: [{
1726
1754
  scope: {
1727
- name: Le,
1728
- version: pt
1755
+ name: Fe,
1756
+ version: dt
1729
1757
  },
1730
1758
  logRecords: e.records.map((e) => ({
1731
1759
  timeUnixNano: e.timeUnixNano,
@@ -1742,27 +1770,27 @@ var G = {
1742
1770
  }));
1743
1771
  return {
1744
1772
  body: JSON.stringify({ resourceLogs: n }),
1745
- contentType: ue
1773
+ contentType: le
1746
1774
  };
1747
1775
  }
1748
1776
  };
1749
1777
  //#endregion
1750
1778
  //#region src/core/config.ts
1751
- function Bn(e) {
1779
+ function Hn(e) {
1752
1780
  return typeof e != "object" || !e ? !1 : typeof Reflect.get(e, "serialize") == "function";
1753
1781
  }
1754
- function Vn(e, t, n) {
1755
- return e === void 0 ? t ?? G : e === "otlp" ? G : e === "ecs" ? In : Bn(e) ? e : (n.report("config.invalid", `serializer must be "${xt}", "ecs" or an implementation`), G);
1782
+ function Un(e, t, n) {
1783
+ return e === void 0 ? t ?? G : e === "otlp" ? G : e === "ecs" ? Rn : Hn(e) ? e : (n.report("config.invalid", `serializer must be "${yt}", "ecs" or an implementation`), G);
1756
1784
  }
1757
- function Hn(e, t) {
1785
+ function Wn(e, t) {
1758
1786
  return e === void 0 ? t : e === !1 ? null : e === !0 ? l : e;
1759
1787
  }
1760
- function Un(e, t, n) {
1761
- let r = n ?? qe, i = {
1788
+ function Gn(e, t, n) {
1789
+ let r = n ?? Ge, i = {
1762
1790
  ...r,
1763
1791
  ...e,
1764
- serializer: Vn(e.serializer, n?.serializer, t),
1765
- console: Hn(e.console, r.console),
1792
+ serializer: Un(e.serializer, n?.serializer, t),
1793
+ console: Wn(e.console, r.console),
1766
1794
  sampling: {
1767
1795
  ...r.sampling,
1768
1796
  ...e.sampling,
@@ -1786,23 +1814,23 @@ function Un(e, t, n) {
1786
1814
  } catch (e) {
1787
1815
  t.report("config.invalid", `endpoint is not a valid absolute URL: ${i.endpoint}`, void 0, e);
1788
1816
  }
1789
- i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record will report service.name as '${rt}'.`), rt);
1817
+ i.serviceName ||= (t.report("config.invalid", `serviceName is missing. Every record will report service.name as '${tt}'.`), tt);
1790
1818
  let a = i.sampling.defaultRate;
1791
1819
  (typeof a != "number" || a < 0 || a > 1) && (t.report("config.invalid", `sampling.defaultRate must be 0..1, got ${String(a)}`), i.sampling.defaultRate = 1);
1792
1820
  let o = Object.entries(i.sampling.rates);
1793
1821
  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);
1794
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]);
1795
- let s = /* @__PURE__ */ new Set([...Object.keys(qe), ...ke]);
1823
+ let s = /* @__PURE__ */ new Set([...Object.keys(Ge), ...De]);
1796
1824
  for (let n of Object.keys(e)) s.has(n) || t.report("config.invalid", `unknown config key "${n}", ignored. Typo?`);
1797
1825
  return i;
1798
1826
  }
1799
- function Wn(e, t) {
1800
- for (let n of Object.keys(t)) _e.includes(n) || Object.assign(e, { [n]: t[n] });
1801
- for (let n of _e) Object.assign(e[n], t[n]);
1827
+ function Kn(e, t) {
1828
+ for (let n of Object.keys(t)) ge.includes(n) || Object.assign(e, { [n]: t[n] });
1829
+ for (let n of ge) Object.assign(e[n], t[n]);
1802
1830
  }
1803
1831
  //#endregion
1804
1832
  //#region src/core/context.ts
1805
- var Gn = class {
1833
+ var qn = class {
1806
1834
  map = /* @__PURE__ */ new Map();
1807
1835
  set(e, t) {
1808
1836
  this.map.set(e, t);
@@ -1822,12 +1850,12 @@ var Gn = class {
1822
1850
  getAll() {
1823
1851
  return Object.fromEntries(this.map);
1824
1852
  }
1825
- }, Kn = class {
1853
+ }, Jn = class {
1826
1854
  handler;
1827
1855
  throttleMs;
1828
1856
  counters = /* @__PURE__ */ new Map();
1829
1857
  lastEmitted = /* @__PURE__ */ new Map();
1830
- constructor(e, t = ce) {
1858
+ constructor(e, t = se) {
1831
1859
  this.handler = e, this.throttleMs = t;
1832
1860
  }
1833
1861
  setHandler(e) {
@@ -1852,7 +1880,7 @@ var Gn = class {
1852
1880
  if (this.handler) try {
1853
1881
  this.handler(o);
1854
1882
  } catch (e) {
1855
- this.count("handler.threw"), typeof console < "u" && console.warn(`${Ke} onDiagnostic handler threw`, e);
1883
+ this.count("handler.threw"), typeof console < "u" && console.warn(`${We} onDiagnostic handler threw`, e);
1856
1884
  }
1857
1885
  }
1858
1886
  guard(e, t, n) {
@@ -1877,22 +1905,22 @@ var Gn = class {
1877
1905
  reset() {
1878
1906
  this.counters.clear(), this.lastEmitted.clear();
1879
1907
  }
1880
- }, qn = {
1881
- maxAgeMs: Re,
1908
+ }, Yn = {
1909
+ maxAgeMs: Ie,
1882
1910
  endOnOwnerClose: !1,
1883
- urlParam: tt
1911
+ urlParam: $e
1884
1912
  };
1885
1913
  function K(e, t) {
1886
1914
  let n = Reflect.get(e, t);
1887
1915
  return typeof n == "string" && n !== "" ? n : void 0;
1888
1916
  }
1889
- function Jn(e, t) {
1917
+ function Xn(e, t) {
1890
1918
  let n = Reflect.get(e, t);
1891
1919
  return typeof n == "number" && Number.isFinite(n) ? n : void 0;
1892
1920
  }
1893
- function Yn(e) {
1921
+ function Zn(e) {
1894
1922
  if (typeof e != "object" || !e) return null;
1895
- let t = K(e, "id"), n = K(e, "name"), r = Jn(e, "startedAt");
1923
+ let t = K(e, "id"), n = K(e, "name"), r = Xn(e, "startedAt");
1896
1924
  return t === void 0 || n === void 0 || r === void 0 ? null : {
1897
1925
  id: t,
1898
1926
  name: n,
@@ -1901,35 +1929,35 @@ function Yn(e) {
1901
1929
  ownerContextId: K(e, "ownerContextId") ?? ""
1902
1930
  };
1903
1931
  }
1904
- function Xn(e) {
1932
+ function Qn(e) {
1905
1933
  if (typeof e != "object" || !e) return null;
1906
1934
  let t = K(e, "i"), n = K(e, "n");
1907
1935
  return t === void 0 || n === void 0 ? null : {
1908
1936
  id: t,
1909
1937
  name: n,
1910
- startedAt: Jn(e, "s") ?? Date.now(),
1938
+ startedAt: Xn(e, "s") ?? Date.now(),
1911
1939
  parentId: void 0,
1912
1940
  ownerContextId: ""
1913
1941
  };
1914
1942
  }
1915
- function Zn(e) {
1943
+ function $n(e) {
1916
1944
  let t = JSON.stringify({
1917
1945
  i: e.id,
1918
1946
  n: e.name.slice(0, 64),
1919
1947
  s: e.startedAt
1920
1948
  }), n = new TextEncoder().encode(t), r = "";
1921
1949
  for (let e of n) r += String.fromCharCode(e);
1922
- return btoa(r).replace(Be, "-").replace(Ee, "_").replace(He, "");
1950
+ return btoa(r).replace(Re, "-").replace(Te, "_").replace(Be, "");
1923
1951
  }
1924
- function Qn(e, t) {
1952
+ function er(e, t) {
1925
1953
  let n = new Promise((e, n) => {
1926
- C(setTimeout(() => {
1954
+ T(setTimeout(() => {
1927
1955
  n(/* @__PURE__ */ Error(`timed out after ${String(t)}ms`));
1928
1956
  }, t));
1929
1957
  });
1930
1958
  return Promise.race([e, n]);
1931
1959
  }
1932
- var $n = class {
1960
+ var tr = class {
1933
1961
  options;
1934
1962
  diagnostics;
1935
1963
  contextId;
@@ -1945,14 +1973,14 @@ var $n = class {
1945
1973
  async bootstrap() {
1946
1974
  let e = this.readUrlToken();
1947
1975
  if (e && this.adopt(e, "url")) return;
1948
- let t = this.diagnostics.guard("storage.unavailable", "reading the persisted journey", () => sessionStorage.getItem(x));
1976
+ let t = this.diagnostics.guard("storage.unavailable", "reading the persisted journey", () => sessionStorage.getItem(C));
1949
1977
  if (t && this.restore(t)) return;
1950
1978
  let n = await this.readOpenFinToken();
1951
1979
  n !== null && this.adopt(n, "openfin.customData");
1952
1980
  }
1953
1981
  start(e, t = {}) {
1954
1982
  let n = {
1955
- id: t.id ?? j(),
1983
+ id: t.id ?? P(),
1956
1984
  name: e,
1957
1985
  startedAt: Date.now(),
1958
1986
  parentId: t.parent ? this.journey?.id : void 0,
@@ -1970,7 +1998,7 @@ var $n = class {
1970
1998
  getToken() {
1971
1999
  let e = this.journey;
1972
2000
  if (e === null) return;
1973
- let t = Zn(e);
2001
+ let t = $n(e);
1974
2002
  if (t.length > 256) {
1975
2003
  this.diagnostics.report("journey.token_too_large", "journey token exceeded the size cap and was not issued", { length: t.length });
1976
2004
  return;
@@ -1994,7 +2022,7 @@ var $n = class {
1994
2022
  this.clearTimer();
1995
2023
  }
1996
2024
  restore(e) {
1997
- let t = Yn(this.diagnostics.guard("storage.degraded", "parsing the persisted journey", () => JSON.parse(e)));
2025
+ let t = Zn(this.diagnostics.guard("storage.degraded", "parsing the persisted journey", () => JSON.parse(e)));
1998
2026
  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}"`, {
1999
2027
  source: "sessionStorage",
2000
2028
  journeyId: t.id
@@ -2002,22 +2030,22 @@ var $n = class {
2002
2030
  }
2003
2031
  decodeToken(e) {
2004
2032
  return this.diagnostics.guard("config.invalid", "decoding a seeded journey token", () => {
2005
- let t = e.replace(at, "+").replace(Qe, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
2006
- return Xn(JSON.parse(new TextDecoder().decode(i)));
2033
+ let t = e.replace(rt, "+").replace(Xe, "/"), n = (4 - t.length % 4) % 4, r = "=".repeat(n), i = Uint8Array.from(atob(t + r), (e) => e.charCodeAt(0));
2034
+ return Qn(JSON.parse(new TextDecoder().decode(i)));
2007
2035
  }) ?? null;
2008
2036
  }
2009
2037
  setJourney(e) {
2010
2038
  if (this.journey = e, this.clearTimer(), this.diagnostics.guard("storage.unavailable", "persisting the journey", () => {
2011
- e === null ? sessionStorage.removeItem(x) : sessionStorage.setItem(x, JSON.stringify(e));
2039
+ e === null ? sessionStorage.removeItem(C) : sessionStorage.setItem(C, JSON.stringify(e));
2012
2040
  }), e === null) return;
2013
2041
  let t = Math.max(this.options.maxAgeMs - (Date.now() - e.startedAt), 0), n = setTimeout(() => {
2014
2042
  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();
2015
2043
  }, t);
2016
- this.expiryTimer = n, C(n);
2044
+ this.expiryTimer = n, T(n);
2017
2045
  }
2018
2046
  clearStored() {
2019
2047
  this.diagnostics.guard("storage.unavailable", "clearing the persisted journey", () => {
2020
- sessionStorage.removeItem(x);
2048
+ sessionStorage.removeItem(C);
2021
2049
  });
2022
2050
  }
2023
2051
  clearTimer() {
@@ -2029,14 +2057,14 @@ var $n = class {
2029
2057
  async readOpenFinToken() {
2030
2058
  let e = globalThis.fin?.me, t = e?.getOptions;
2031
2059
  if (t === void 0) return null;
2032
- let n = (await this.diagnostics.guardAsync("openfin.unavailable", "reading fin.me.getOptions()", () => Qn(t.call(e), $e)))?.customData?.[ot];
2060
+ let n = (await this.diagnostics.guardAsync("openfin.unavailable", "reading fin.me.getOptions()", () => er(t.call(e), Ze)))?.customData?.[it];
2033
2061
  return typeof n == "string" ? n : null;
2034
2062
  }
2035
2063
  };
2036
2064
  //#endregion
2037
2065
  //#region src/core/sampling.ts
2038
- function er(e) {
2039
- let t = be;
2066
+ function nr(e) {
2067
+ let t = ye;
2040
2068
  for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, h);
2041
2069
  return t >>> 0;
2042
2070
  }
@@ -2044,31 +2072,49 @@ function q(e, t) {
2044
2072
  let n = e.attributes[t];
2045
2073
  return typeof n == "string" ? n : "";
2046
2074
  }
2047
- function tr(e, t) {
2075
+ function rr(e, t) {
2048
2076
  let { rates: n, defaultRate: r } = t.sampling, i, a = -1;
2049
2077
  for (let [t, r] of Object.entries(n)) (e === t || e.startsWith(`${t}.`)) && t.length > a && (i = r, a = t.length);
2050
2078
  return i ?? r;
2051
2079
  }
2052
- function nr(e, t) {
2053
- if (e.severityText === "ERROR" || e.severityText === "FATAL" || t.sampling.alwaysSampleTypes.includes(q(e, "log.type"))) return !0;
2054
- let n = tr(q(e, y), t);
2055
- return n >= 1 ? !0 : n <= 0 ? !1 : er(q(e, "journey.id") || e.traceId) / Ge < n;
2056
- }
2080
+ function ir(e, t) {
2081
+ if (e.level === "ERROR" || e.level === "FATAL" || t.sampling.alwaysSampleTypes.includes(e.type)) return !0;
2082
+ let n = rr(e.namespace, t);
2083
+ return n >= 1 ? !0 : n <= 0 ? !1 : nr(e.journeyId || e.traceId) / Ue < n;
2084
+ }
2085
+ function ar(e, t) {
2086
+ return ir({
2087
+ level: e.severityText,
2088
+ type: q(e, b),
2089
+ namespace: q(e, x),
2090
+ journeyId: q(e, y),
2091
+ traceId: e.traceId
2092
+ }, t);
2093
+ }
2094
+ var or = class {
2095
+ windowStart = 0;
2096
+ count = 0;
2097
+ allow(e) {
2098
+ if (e.severityText !== "ERROR" && e.severityText !== "FATAL") return !0;
2099
+ let t = Date.now();
2100
+ return t - this.windowStart > 1e4 && (this.windowStart = t, this.count = 0), this.count++, this.count <= 500;
2101
+ }
2102
+ };
2057
2103
  //#endregion
2058
2104
  //#region src/core/pipeline.ts
2059
- function rr(e) {
2060
- return e.attributes[v] === it;
2105
+ function sr(e) {
2106
+ return e.attributes[b] === nt;
2061
2107
  }
2062
- var ir = {
2108
+ var cr = {
2063
2109
  logs: {
2064
- flushIntervalMs: Ae,
2110
+ flushIntervalMs: Oe,
2065
2111
  batchSize: 100
2066
2112
  },
2067
2113
  metrics: {
2068
- flushIntervalMs: Pe,
2114
+ flushIntervalMs: Me,
2069
2115
  batchSize: 500
2070
2116
  }
2071
- }, ar = class {
2117
+ }, lr = class {
2072
2118
  options;
2073
2119
  onFlush;
2074
2120
  pending = [];
@@ -2096,13 +2142,12 @@ var ir = {
2096
2142
  let e = setTimeout(() => {
2097
2143
  this.timer = null, this.onFlush(this);
2098
2144
  }, this.options.flushIntervalMs);
2099
- this.timer = e, C(e);
2145
+ this.timer = e, T(e);
2100
2146
  }
2101
2147
  clearTimer() {
2102
2148
  this.timer !== null && (clearTimeout(this.timer), this.timer = null);
2103
2149
  }
2104
- }, or = class {
2105
- config;
2150
+ }, ur = class {
2106
2151
  transport;
2107
2152
  storage;
2108
2153
  retry;
@@ -2110,43 +2155,50 @@ var ir = {
2110
2155
  streams;
2111
2156
  unconfirmed = /* @__PURE__ */ new Map();
2112
2157
  queue = [];
2158
+ ceiling = new or();
2113
2159
  inFlight = 0;
2114
2160
  pumpScheduled = !1;
2115
2161
  stopped = !1;
2116
- constructor(e, t, n, r, i, a = ir) {
2117
- this.config = e, this.transport = t, this.storage = n, this.retry = r, this.diagnostics = i;
2118
- let o = (e) => {
2162
+ constructor(e, t, n, r, i = cr) {
2163
+ this.transport = e, this.storage = t, this.retry = n, this.diagnostics = r;
2164
+ let a = (e) => {
2119
2165
  this.claim(e);
2120
2166
  };
2121
2167
  this.streams = {
2122
- logs: new ar(a.logs, o),
2123
- metrics: new ar(a.metrics, o)
2168
+ logs: new lr(i.logs, a),
2169
+ metrics: new lr(i.metrics, a)
2124
2170
  };
2125
2171
  }
2126
2172
  push(e) {
2127
- this.stopped || (e.observedTimeUnixNano = O(), this.route(e));
2173
+ this.stopped || (e.observedTimeUnixNano = Jt(), this.route(e));
2128
2174
  }
2129
2175
  drainPending() {
2130
- let e = [
2131
- ...[...this.unconfirmed.values()].flatMap((e) => e.records),
2176
+ return this.toBatch([...this.streams.metrics.take(), ...this.streams.logs.take()]);
2177
+ }
2178
+ drainForExit() {
2179
+ let e = [...this.unconfirmed.values()].flatMap((e) => e.records);
2180
+ return this.unconfirmed.clear(), this.toBatch([
2181
+ ...e,
2132
2182
  ...this.streams.metrics.take(),
2133
2183
  ...this.streams.logs.take()
2134
- ];
2135
- return this.unconfirmed.clear(), e.length === 0 ? null : {
2136
- id: j(),
2184
+ ]);
2185
+ }
2186
+ destroy() {
2187
+ this.stopped = !0, this.streams.logs.stop(), this.streams.metrics.stop(), this.queue.length = 0;
2188
+ }
2189
+ toBatch(e) {
2190
+ return e.length === 0 ? null : {
2191
+ id: P(),
2137
2192
  records: e,
2138
2193
  createdAt: Date.now(),
2139
2194
  attempts: 0
2140
2195
  };
2141
2196
  }
2142
- destroy() {
2143
- this.stopped = !0, this.streams.logs.stop(), this.streams.metrics.stop(), this.queue.length = 0;
2144
- }
2145
2197
  route(e) {
2146
2198
  try {
2147
- let t = rr(e) ? this.streams.metrics : this.streams.logs;
2148
- if (!nr(e, this.config)) {
2149
- this.diagnostics.count("record.dropped_by_sampling");
2199
+ let t = sr(e) ? this.streams.metrics : this.streams.logs;
2200
+ if (!this.ceiling.allow(e)) {
2201
+ this.diagnostics.count("record.dropped_by_ceiling");
2150
2202
  return;
2151
2203
  }
2152
2204
  t.add(e);
@@ -2156,7 +2208,7 @@ var ir = {
2156
2208
  }
2157
2209
  claim(e) {
2158
2210
  let t = e.take(), n = {
2159
- id: j(),
2211
+ id: P(),
2160
2212
  records: t,
2161
2213
  createdAt: Date.now(),
2162
2214
  attempts: 0
@@ -2221,7 +2273,7 @@ var ir = {
2221
2273
  function J(e) {
2222
2274
  return e;
2223
2275
  }
2224
- var sr = class {
2276
+ var dr = class {
2225
2277
  deps;
2226
2278
  resourceCache = null;
2227
2279
  constructor(e) {
@@ -2232,94 +2284,102 @@ var sr = class {
2232
2284
  }
2233
2285
  isEnabled(e) {
2234
2286
  let { config: t } = this.deps;
2235
- return t.enabled ? b[e] >= b[t.minLevel] : !1;
2287
+ return t.enabled ? S[e] >= S[t.minLevel] : !1;
2236
2288
  }
2237
2289
  build(e) {
2238
2290
  let { config: t, diagnostics: n, tracing: r, journey: i, sequence: a, limits: o } = this.deps;
2239
2291
  if (!this.isEnabled(e.level)) return n.count("record.dropped_by_level"), null;
2240
- let s = r.resolve(), c = i.current(), l = a.next(), u = Dn(), d, f = 0;
2292
+ let s = r.resolve(), c = i.current();
2293
+ if (!ir({
2294
+ level: e.level,
2295
+ type: e.type,
2296
+ namespace: e.namespace,
2297
+ journeyId: c?.id ?? "",
2298
+ traceId: s.traceId
2299
+ }, t)) return n.count("record.dropped_by_sampling"), null;
2300
+ let l = a.next(), u = Bt(), d = t.capture.fullUrls ? u : A(u), f, p = 0;
2241
2301
  try {
2242
- let t = L(this.deps.context.getAll(), o), n = L(e.scoped ?? {}, o), r = L(e.payload ?? {}, o);
2243
- f = t.bytes + n.bytes + r.bytes, d = {
2302
+ let t = z(this.deps.context.getAll(), o), n = z(e.scoped ?? {}, o), r = z(e.payload ?? {}, o);
2303
+ p = t.bytes + n.bytes + r.bytes, f = {
2244
2304
  ...J(t.value),
2245
2305
  ...J(n.value),
2246
2306
  ...J(r.value)
2247
2307
  };
2248
2308
  } catch (e) {
2249
- n.report("record.sanitize_failed", "attributes could not be sanitized", void 0, e), d = { [Fe]: !0 };
2309
+ n.report("record.sanitize_failed", "attributes could not be sanitized", void 0, e), f = { [Ne]: !0 };
2250
2310
  }
2251
- d[v] = e.type, d[Ne] = l, d[y] = e.namespace, d[mt] = u, c && (d[Oe] = c.id, d[nt] = c.name, c.parentId !== void 0 && (d[ut] = c.parentId));
2252
- let p = I(e.body, o.maxBodyChars);
2253
- p !== e.body && n.count("record.truncated");
2254
- let m = {
2255
- timeUnixNano: O(),
2311
+ f[b] = e.type, f[je] = l, f[x] = e.namespace, f[ft] = d, c && (f[y] = c.id, f[et] = c.name, c.parentId !== void 0 && (f[ct] = c.parentId));
2312
+ let m = R(e.body, o.maxBodyChars);
2313
+ m !== e.body && n.count("record.truncated");
2314
+ let h = {
2315
+ timeUnixNano: Jt(),
2256
2316
  traceId: s.traceId,
2257
2317
  spanId: s.spanId,
2258
2318
  traceFlags: s.traceFlags,
2259
- severityNumber: ye[e.level],
2319
+ severityNumber: ve[e.level],
2260
2320
  severityText: e.level,
2261
- body: p,
2262
- attributes: d,
2321
+ body: m,
2322
+ attributes: f,
2263
2323
  resource: this.resource()
2264
- }, h = t.redact;
2265
- if (h) {
2266
- let e = n.guard("record.sanitize_failed", "redact hook threw", () => h(m));
2324
+ }, g = t.redact;
2325
+ if (g) {
2326
+ let e = n.guard("record.sanitize_failed", "redact hook threw", () => g(h));
2267
2327
  if (e === null) return n.count("record.dropped_by_redact"), null;
2268
- if (e !== void 0 && e !== m) {
2269
- if (k(e)) {
2270
- let t = L(e.attributes, o);
2271
- m = {
2328
+ if (e !== void 0 && e !== h) {
2329
+ if (Yt(e)) {
2330
+ let t = z(e.attributes, o);
2331
+ h = {
2272
2332
  ...e,
2273
2333
  attributes: J(t.value)
2274
- }, f = t.bytes;
2334
+ }, p = t.bytes;
2275
2335
  } else n.report("record.sanitize_failed", "redact hook returned something that is not a record, keeping the original");
2276
2336
  }
2277
2337
  }
2278
- if (f > o.maxRecordBytes) {
2338
+ if (p > o.maxRecordBytes) {
2279
2339
  n.report("record.truncated", "attributes exceeded the size budget and were dropped", {
2280
- bytes: f,
2281
- body: m.body
2340
+ bytes: p,
2341
+ body: h.body
2282
2342
  });
2283
2343
  let t = {
2284
- [v]: e.type,
2285
- [Ne]: l,
2286
- [y]: e.namespace,
2287
- [mt]: u,
2288
- [We]: !0,
2289
- [ct]: f
2344
+ [b]: e.type,
2345
+ [je]: l,
2346
+ [x]: e.namespace,
2347
+ [ft]: d,
2348
+ [He]: !0,
2349
+ [ot]: p
2290
2350
  };
2291
- c && (t[Oe] = c.id, t[nt] = c.name), m.attributes = t;
2351
+ c && (t[y] = c.id, t[et] = c.name), h.attributes = t;
2292
2352
  }
2293
- return m;
2353
+ return h;
2294
2354
  }
2295
2355
  resource() {
2296
2356
  if (this.resourceCache) return this.resourceCache;
2297
2357
  let { config: e, identity: n, platform: i } = this.deps;
2298
2358
  return this.resourceCache = {
2299
2359
  [c]: e.serviceName,
2300
- [de]: e.serviceVersion,
2360
+ [ue]: e.serviceVersion,
2301
2361
  [o]: e.environment,
2302
- [se]: Le,
2303
- [le]: pt,
2304
- [Je]: t,
2305
- [_t]: i.platform,
2306
- [Xe]: n.sessionId,
2362
+ [oe]: Fe,
2363
+ [ce]: dt,
2364
+ [Ke]: t,
2365
+ [ht]: i.platform,
2366
+ [Je]: n.sessionId,
2307
2367
  [r]: n.tabId,
2308
- [ge]: n.contextId,
2309
- [yt]: i.userAgent,
2368
+ [he]: n.contextId,
2369
+ [_t]: i.userAgent,
2310
2370
  ...i.openfinUuid === void 0 ? {} : { [u]: i.openfinUuid },
2311
- ...i.openfinName === void 0 ? {} : { [ve]: i.openfinName }
2371
+ ...i.openfinName === void 0 ? {} : { [_e]: i.openfinName }
2312
2372
  }, this.resourceCache;
2313
2373
  }
2314
- }, Y = Symbol.for(ae), X = class e {
2374
+ }, Y = Symbol.for(ie), X = class e {
2315
2375
  diagnostics;
2316
2376
  config;
2317
2377
  platform;
2318
2378
  identity;
2319
- context = new Gn();
2379
+ context = new qn();
2320
2380
  breadcrumbs;
2321
2381
  tracing;
2322
- sequence = new On();
2382
+ sequence = new Tn();
2323
2383
  journey;
2324
2384
  builder;
2325
2385
  console;
@@ -2337,11 +2397,11 @@ var sr = class {
2337
2397
  destroyed = !1;
2338
2398
  lastGapAt = 0;
2339
2399
  constructor(e) {
2340
- this.diagnostics = new Kn(e.onDiagnostic), this.platform = wn(this.diagnostics), this.config = Un(e, this.diagnostics), this.identity = Zt(this.diagnostics), this.breadcrumbs = new Pn(50), this.tracing = new Nn(this.diagnostics), this.console = new Cn(this.config.console), this.journey = new $n(qn, this.diagnostics, this.identity.contextId, (e) => {
2400
+ this.diagnostics = new Jn(e.onDiagnostic), this.platform = Lt(this.diagnostics), this.config = Gn(e, this.diagnostics), this.identity = Zt(this.diagnostics), this.breadcrumbs = new In(50), this.tracing = new Fn(this.diagnostics, void 0, this.config.otelLoader), this.tracing.loadOtel(), this.console = new wn(this.config.console), this.journey = new tr(Yn, this.diagnostics, this.identity.contextId, (e) => {
2341
2401
  this.bus.broadcastJourney(e);
2342
- }), this.builder = new sr({
2402
+ }), this.builder = new dr({
2343
2403
  config: this.config,
2344
- limits: bt,
2404
+ limits: vt,
2345
2405
  diagnostics: this.diagnostics,
2346
2406
  context: this.context,
2347
2407
  journey: this.journey,
@@ -2349,7 +2409,7 @@ var sr = class {
2349
2409
  sequence: this.sequence,
2350
2410
  identity: this.identity,
2351
2411
  platform: this.platform
2352
- }), this.bus = new Ht(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
2412
+ }), this.bus = new It(this.config, this.diagnostics, this.platform, this.identity.contextId, this.identity.tabId, {
2353
2413
  onRecords: (e) => {
2354
2414
  this.ingestForwarded(e);
2355
2415
  },
@@ -2377,7 +2437,7 @@ var sr = class {
2377
2437
  return globalThis[Y] = r, r.init(), r;
2378
2438
  }
2379
2439
  reconfigure(e) {
2380
- Wn(this.config, Un(e, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.ready && this.reinstallCaptures(), this.diagnostics.report("config.reconfigured", "configure() was called again, the existing runtime was updated");
2440
+ Kn(this.config, Gn(e, this.diagnostics, this.config)), this.diagnostics.setHandler(this.config.onDiagnostic), this.builder.invalidateResource(), this.console.update(this.config.console), this.ready && this.reinstallCaptures(), this.diagnostics.report("config.reconfigured", "configure() was called again, the existing runtime was updated");
2381
2441
  }
2382
2442
  async init() {
2383
2443
  try {
@@ -2390,10 +2450,10 @@ var sr = class {
2390
2450
  }
2391
2451
  }
2392
2452
  async becomeSender() {
2393
- this.storage = await mn(this.config.storage, Se, m, this.diagnostics, this.reportGap), this.transport = new bn(this.config, this.diagnostics), this.retry = new xn(this.storage, this.transport, this.diagnostics, this.config), this.pipeline = new or(this.config, this.transport, this.storage, this.retry, this.diagnostics), this.exitFlush = new _n({
2453
+ this.storage = await hn(this.config.storage, xe, m, this.diagnostics, this.reportGap), this.transport = new xn(this.config, this.diagnostics), this.retry = new Sn(this.storage, this.transport, this.diagnostics, this.config), this.pipeline = new ur(this.transport, this.storage, this.retry, this.diagnostics), this.exitFlush = new vn({
2394
2454
  config: this.config,
2395
2455
  diagnostics: this.diagnostics,
2396
- drainPending: () => this.pipeline?.drainPending() ?? null
2456
+ drainForExit: () => this.pipeline?.drainForExit() ?? null
2397
2457
  }), await cn(this.storage, this.diagnostics), this.retry.start(), this.exitFlush.install();
2398
2458
  }
2399
2459
  installCaptures() {
@@ -2402,9 +2462,9 @@ var sr = class {
2402
2462
  diagnostics: this.diagnostics,
2403
2463
  breadcrumbs: this.breadcrumbs,
2404
2464
  tracing: this.tracing,
2405
- logger: new S(this, a)
2465
+ logger: new w(this, a)
2406
2466
  }, t = this.config.capture;
2407
- (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));
2467
+ (t.errors || t.rejections || t.resourceErrors) && this.captures.push(new Vt(e)), (t.fetch || t.xhr) && this.captures.push(new Gt(e)), (t.interactions || t.navigation) && this.captures.push(new Ut(e)), t.webVitals && this.captures.push(new qt(e));
2408
2468
  for (let e of this.captures) this.diagnostics.guard("capture.install_failed", `installing ${e.name}`, () => {
2409
2469
  e.install();
2410
2470
  });
@@ -2456,10 +2516,14 @@ var sr = class {
2456
2516
  return;
2457
2517
  }
2458
2518
  for (let t of e) {
2459
- if (!k(t)) {
2519
+ if (!Yt(t)) {
2460
2520
  this.diagnostics.count("record.dropped_malformed");
2461
2521
  continue;
2462
2522
  }
2523
+ if (!ar(t, this.config)) {
2524
+ this.diagnostics.count("record.dropped_by_sampling");
2525
+ continue;
2526
+ }
2463
2527
  this.pipeline?.push(t);
2464
2528
  }
2465
2529
  }
@@ -2471,19 +2535,19 @@ var sr = class {
2471
2535
  }
2472
2536
  reportGap = (e) => {
2473
2537
  let t = Date.now();
2474
- t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new S(this, ie).warn("stored records were dropped before delivery", {
2538
+ t - this.lastGapAt < 6e4 || (this.lastGapAt = t, new w(this, re).warn("stored records were dropped before delivery", {
2475
2539
  "gap.batches": e.batches,
2476
2540
  "gap.records": e.records,
2477
2541
  "gap.reason": e.reason
2478
2542
  }));
2479
2543
  };
2480
2544
  regenerateTabId() {
2481
- let e = j();
2545
+ let e = P();
2482
2546
  this.diagnostics.report("bus.role_resolved", "another context claimed this tab id, most likely a duplicated tab. Regenerating.", {
2483
2547
  was: this.identity.tabId,
2484
2548
  now: e
2485
2549
  }), this.identity.tabId = e, this.diagnostics.guard("storage.unavailable", "persisting the new tab id", () => {
2486
- sessionStorage.setItem(pe, e);
2550
+ sessionStorage.setItem(fe, e);
2487
2551
  }), this.builder.invalidateResource();
2488
2552
  }
2489
2553
  async queueDepth() {
@@ -2514,93 +2578,94 @@ var sr = class {
2514
2578
  function Q() {
2515
2579
  return X.current() || X.configure({});
2516
2580
  }
2517
- function cr(e) {
2581
+ function fr(e) {
2518
2582
  X.configure(e), Z.clear();
2519
2583
  }
2520
- function lr(e, t) {
2521
- let n = t ? `${e}::${JSON.stringify(t)}` : e, r = Z.get(n);
2522
- return r || (r = new S(Q(), e, t), Z.set(n, r)), r;
2584
+ function pr(e, t) {
2585
+ if (t) return new w(Q(), e, t);
2586
+ let n = Z.get(e);
2587
+ return n || (n = new w(Q(), e), Z.set(e, n)), n;
2523
2588
  }
2524
2589
  function $() {
2525
- return lr("app");
2590
+ return pr("app");
2526
2591
  }
2527
- function ur(e, t) {
2592
+ function mr(e, t) {
2528
2593
  $().trace(e, t);
2529
2594
  }
2530
- function dr(e, t) {
2595
+ function hr(e, t) {
2531
2596
  $().debug(e, t);
2532
2597
  }
2533
- function fr(e, t) {
2598
+ function gr(e, t) {
2534
2599
  $().info(e, t);
2535
2600
  }
2536
- function pr(e, t) {
2601
+ function _r(e, t) {
2537
2602
  $().warn(e, t);
2538
2603
  }
2539
- function mr(e, t, n) {
2604
+ function vr(e, t, n) {
2540
2605
  $().error(e, t, n);
2541
2606
  }
2542
- function hr(e, t) {
2607
+ function yr(e, t) {
2543
2608
  $().logAction(e, t);
2544
2609
  }
2545
- function gr(e, t) {
2610
+ function br(e, t) {
2546
2611
  $().logEvent(e, t);
2547
2612
  }
2548
- function _r(e, t, n, r, i) {
2613
+ function xr(e, t, n, r, i) {
2549
2614
  $().logMetric(e, t, n, r, i);
2550
2615
  }
2551
- function vr(e, t, n) {
2616
+ function Sr(e, t, n) {
2552
2617
  return $().timeSync(e, t, n);
2553
2618
  }
2554
- function yr(e, t, n) {
2619
+ function Cr(e, t, n) {
2555
2620
  return $().timeAsync(e, t, n);
2556
2621
  }
2557
- function br(e, t) {
2622
+ function wr(e, t) {
2558
2623
  Q().context.set(e, t);
2559
2624
  }
2560
- function xr(e) {
2625
+ function Tr(e) {
2561
2626
  Q().context.setMany(e);
2562
2627
  }
2563
- function Sr(e) {
2628
+ function Er(e) {
2564
2629
  Q().context.remove(e);
2565
2630
  }
2566
- function Cr(e, t) {
2631
+ function Dr(e, t) {
2567
2632
  return Q().journey.start(e, t);
2568
2633
  }
2569
- function wr() {
2634
+ function Or() {
2570
2635
  Q().journey.end();
2571
2636
  }
2572
- function Tr() {
2637
+ function kr() {
2573
2638
  return Q().journey.current();
2574
2639
  }
2575
- function Er() {
2640
+ function Ar() {
2576
2641
  return Q().journey.getToken();
2577
2642
  }
2578
- function Dr(e) {
2643
+ function jr(e) {
2579
2644
  return Q().journey.adopt(e, "manual", !0);
2580
2645
  }
2581
- function Or(e) {
2646
+ function Mr(e) {
2582
2647
  Q().registerWorker(e);
2583
2648
  }
2584
- function kr() {
2649
+ function Nr() {
2585
2650
  Q().tracing.rotate("explicit");
2586
2651
  }
2587
- function Ar() {
2652
+ function Pr() {
2588
2653
  return Q().tracing.headers();
2589
2654
  }
2590
- function jr() {
2655
+ function Fr() {
2591
2656
  return Q().flush();
2592
2657
  }
2593
- function Mr() {
2658
+ function Ir() {
2594
2659
  return Q().queueDepth();
2595
2660
  }
2596
- function Nr() {
2661
+ function Lr() {
2597
2662
  return Q().diagnostics.snapshot();
2598
2663
  }
2599
- async function Pr() {
2664
+ async function Rr() {
2600
2665
  let e = X.current();
2601
2666
  Z.clear(), await e?.destroy();
2602
2667
  }
2603
2668
  //#endregion
2604
- export { S as OneLogger, Dr as adoptJourney, cr as configure, Tr as currentJourney, dr as debug, wr as endJourney, mr as error, jr as flush, Nr as getDiagnosticCounters, Er as getJourneyToken, lr as getLogger, Mr as getQueueDepth, Ar as getTraceHeaders, fr as info, hr as logAction, gr as logEvent, _r as logMetric, Or as registerWorker, Sr as removeContext, br as setContext, xr as setContextMap, Pr as shutdown, Cr as startJourney, kr as startTrace, yr as timeAsync, vr as timeSync, ur as trace, pr as warn };
2669
+ export { w as OneLogger, jr as adoptJourney, fr as configure, kr as currentJourney, hr as debug, Or as endJourney, vr as error, Fr as flush, Lr as getDiagnosticCounters, Ar as getJourneyToken, pr as getLogger, Ir as getQueueDepth, Pr as getTraceHeaders, gr as info, yr as logAction, br as logEvent, xr as logMetric, Mr as registerWorker, Er as removeContext, wr as setContext, Tr as setContextMap, Rr as shutdown, Dr as startJourney, Nr as startTrace, Cr as timeAsync, Sr as timeSync, mr as trace, _r as warn };
2605
2670
 
2606
2671
  //# sourceMappingURL=index.js.map