@tracelog/lib 2.2.1 → 2.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/README.md +47 -2
- package/dist/browser/tracelog.esm.js +163 -147
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +1 -1
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/public-api.cjs +28 -8
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +19 -3
- package/dist/public-api.d.ts +19 -3
- package/dist/public-api.js +28 -8
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const Fr = 9e5;
|
|
2
|
+
const $r = 120, Br = 8192, Wr = 10, Gr = 10, Xr = 20;
|
|
3
|
+
const Qr = 1e3, jr = 500, zr = 100;
|
|
4
4
|
const w = "data-tlog", at = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
@@ -78,15 +78,15 @@ const m = {
|
|
|
78
78
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
79
79
|
/<embed\b[^>]*>/gi,
|
|
80
80
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
81
|
-
],
|
|
81
|
+
], _ = "tlog", x = `${_}:qa_mode`, ye = `${_}:uid`, We = "tlog_mode", be = "qa", Le = "qa_off", dt = (s) => s ? `${_}:${s}:queue` : `${_}:queue`, ht = (s) => s ? `${_}:${s}:session` : `${_}:session`, ft = (s) => s ? `${_}:${s}:broadcast` : `${_}:broadcast`, Ae = (s, e) => `${_}:${s}:session_counts:${e}`, Me = 10080 * 60 * 1e3, Ce = `${_}:session_counts_last_cleanup`, Re = 3600 * 1e3;
|
|
82
82
|
var U = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(U || {}), A = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(A || {}), ae = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(ae || {});
|
|
83
83
|
class O extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
85
|
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, O);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
var d = /* @__PURE__ */ ((s) => (s.PAGE_VIEW = "page_view", s.CLICK = "click", s.SCROLL = "scroll", s.SESSION_START = "session_start", s.CUSTOM = "custom", s.WEB_VITALS = "web_vitals", s.ERROR = "error", s.VIEWPORT_VISIBLE = "viewport_visible", s))(d || {}), Q = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(Q || {}),
|
|
89
|
-
const
|
|
88
|
+
var d = /* @__PURE__ */ ((s) => (s.PAGE_VIEW = "page_view", s.CLICK = "click", s.SCROLL = "scroll", s.SESSION_START = "session_start", s.CUSTOM = "custom", s.WEB_VITALS = "web_vitals", s.ERROR = "error", s.VIEWPORT_VISIBLE = "viewport_visible", s))(d || {}), Q = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(Q || {}), H = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(H || {}), K = /* @__PURE__ */ ((s) => (s.QA = "qa", s))(K || {});
|
|
89
|
+
const Kr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !0, Yr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !1;
|
|
90
90
|
class F extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -112,7 +112,7 @@ class V extends F {
|
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class qr extends F {
|
|
116
116
|
constructor(e, t, r = "runtime") {
|
|
117
117
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
118
118
|
}
|
|
@@ -140,7 +140,7 @@ const Ge = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
142
142
|
try {
|
|
143
|
-
return sessionStorage.getItem(
|
|
143
|
+
return sessionStorage.getItem(x) === "true";
|
|
144
144
|
} catch {
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
@@ -168,9 +168,9 @@ const Ge = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
170
|
let ce, Qe;
|
|
171
|
-
const
|
|
171
|
+
const It = () => {
|
|
172
172
|
typeof window < "u" && !ce && (ce = window.matchMedia("(pointer: coarse)"), Qe = window.matchMedia("(hover: none)"));
|
|
173
|
-
}, Y = "Unknown",
|
|
173
|
+
}, Y = "Unknown", _t = (s) => {
|
|
174
174
|
const e = s.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
176
176
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -200,7 +200,7 @@ const _t = () => {
|
|
|
200
200
|
const c = s.userAgentData.platform;
|
|
201
201
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? A.Tablet : s.userAgentData.mobile ? A.Mobile : A.Desktop;
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
It();
|
|
204
204
|
const e = window.innerWidth, t = ce?.matches ?? !1, r = Qe?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
205
205
|
return e <= 767 || o && n ? A.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? A.Tablet : A.Desktop;
|
|
206
206
|
} catch (s) {
|
|
@@ -211,7 +211,7 @@ const _t = () => {
|
|
|
211
211
|
const s = navigator;
|
|
212
212
|
return {
|
|
213
213
|
type: yt(),
|
|
214
|
-
os:
|
|
214
|
+
os: _t(s),
|
|
215
215
|
browser: wt(s)
|
|
216
216
|
};
|
|
217
217
|
} catch (s) {
|
|
@@ -236,7 +236,7 @@ const _t = () => {
|
|
|
236
236
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
237
237
|
// Passwords in connection strings (protocol://user:password@host)
|
|
238
238
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
239
|
-
], Oe = 500, Pe = 5e3, j = 50, Lt = j * 2, ze = 1, At = 1e3, Mt = 10, De = 5e3, Ct = 6e4,
|
|
239
|
+
], Oe = 500, Pe = 5e3, j = 50, Lt = j * 2, ze = 1, At = 1e3, Mt = 10, De = 5e3, Ct = 6e4, Jr = {
|
|
240
240
|
LCP: 2500,
|
|
241
241
|
// Good: ≤ 2.5s
|
|
242
242
|
FCP: 1800,
|
|
@@ -284,7 +284,7 @@ const _t = () => {
|
|
|
284
284
|
default:
|
|
285
285
|
return ke;
|
|
286
286
|
}
|
|
287
|
-
}, Nt = 1e3, Ot = 50, Pt = "2.2.
|
|
287
|
+
}, Nt = 1e3, Ot = 50, Pt = "2.2.1", Dt = Pt, Ke = () => typeof window < "u" && typeof sessionStorage < "u", kt = () => {
|
|
288
288
|
try {
|
|
289
289
|
const s = new URLSearchParams(window.location.search);
|
|
290
290
|
s.delete(We);
|
|
@@ -296,12 +296,12 @@ const _t = () => {
|
|
|
296
296
|
if (!Ke())
|
|
297
297
|
return !1;
|
|
298
298
|
try {
|
|
299
|
-
const e = new URLSearchParams(window.location.search).get(We), t = sessionStorage.getItem(
|
|
299
|
+
const e = new URLSearchParams(window.location.search).get(We), t = sessionStorage.getItem(x);
|
|
300
300
|
let r = null;
|
|
301
|
-
return e === be ? (r = !0, sessionStorage.setItem(
|
|
301
|
+
return e === be ? (r = !0, sessionStorage.setItem(x, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
302
|
visibility: "qa",
|
|
303
303
|
style: Ge
|
|
304
|
-
})) : e === Le && (r = !1, sessionStorage.setItem(
|
|
304
|
+
})) : e === Le && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
305
|
visibility: "qa",
|
|
306
306
|
style: Xe
|
|
307
307
|
})), (e === be || e === Le) && kt(), r ?? t === "true";
|
|
@@ -311,14 +311,14 @@ const _t = () => {
|
|
|
311
311
|
}, Ut = (s) => {
|
|
312
312
|
if (Ke())
|
|
313
313
|
try {
|
|
314
|
-
sessionStorage.setItem(
|
|
314
|
+
sessionStorage.setItem(x, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
316
|
style: s ? Ge : Xe
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
|
-
},
|
|
321
|
+
}, Ht = [
|
|
322
322
|
"co.uk",
|
|
323
323
|
"org.uk",
|
|
324
324
|
"com.au",
|
|
@@ -335,14 +335,14 @@ const _t = () => {
|
|
|
335
335
|
if (e.length <= 2)
|
|
336
336
|
return s.toLowerCase();
|
|
337
337
|
const t = e.slice(-2).join(".");
|
|
338
|
-
return
|
|
339
|
-
},
|
|
338
|
+
return Ht.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
339
|
+
}, xt = (s, e) => s === e ? !0 : Ue(s) === Ue(e), re = () => {
|
|
340
340
|
const s = document.referrer;
|
|
341
341
|
if (!s)
|
|
342
342
|
return "Direct";
|
|
343
343
|
try {
|
|
344
344
|
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
345
|
-
return
|
|
345
|
+
return xt(e, t) ? "Direct" : s;
|
|
346
346
|
} catch (e) {
|
|
347
347
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
348
348
|
}
|
|
@@ -428,7 +428,7 @@ const $t = () => {
|
|
|
428
428
|
} catch (t) {
|
|
429
429
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
430
430
|
}
|
|
431
|
-
},
|
|
431
|
+
}, He = (s) => {
|
|
432
432
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
433
433
|
return "";
|
|
434
434
|
let e = s;
|
|
@@ -443,12 +443,12 @@ const $t = () => {
|
|
|
443
443
|
patternMatches: t,
|
|
444
444
|
valueLength: s.length
|
|
445
445
|
}
|
|
446
|
-
}), e
|
|
446
|
+
}), e.trim();
|
|
447
447
|
}, he = (s, e = 0) => {
|
|
448
448
|
if (s == null)
|
|
449
449
|
return null;
|
|
450
450
|
if (typeof s == "string")
|
|
451
|
-
return
|
|
451
|
+
return He(s);
|
|
452
452
|
if (typeof s == "number")
|
|
453
453
|
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
454
454
|
if (typeof s == "boolean")
|
|
@@ -460,7 +460,7 @@ const $t = () => {
|
|
|
460
460
|
if (typeof s == "object") {
|
|
461
461
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
462
462
|
for (const [i, o] of n) {
|
|
463
|
-
const l =
|
|
463
|
+
const l = He(i);
|
|
464
464
|
if (l) {
|
|
465
465
|
const c = he(o, e + 1);
|
|
466
466
|
c !== null && (t[l] = c);
|
|
@@ -640,7 +640,7 @@ const $t = () => {
|
|
|
640
640
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
641
641
|
valid: !1,
|
|
642
642
|
error: "Event name cannot be a reserved word"
|
|
643
|
-
} : { valid: !0 },
|
|
643
|
+
} : { valid: !0 }, xe = (s, e, t) => {
|
|
644
644
|
const r = Gt(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
645
645
|
if (!Kt(r))
|
|
646
646
|
return {
|
|
@@ -700,7 +700,7 @@ const $t = () => {
|
|
|
700
700
|
valid: !1,
|
|
701
701
|
error: `${n}: array item at index ${i} must be an object.`
|
|
702
702
|
};
|
|
703
|
-
const l =
|
|
703
|
+
const l = xe(s, o, t);
|
|
704
704
|
if (!l.valid)
|
|
705
705
|
return {
|
|
706
706
|
valid: !1,
|
|
@@ -713,7 +713,7 @@ const $t = () => {
|
|
|
713
713
|
sanitizedMetadata: r
|
|
714
714
|
};
|
|
715
715
|
}
|
|
716
|
-
return
|
|
716
|
+
return xe(s, e, t);
|
|
717
717
|
}, qt = (s, e) => {
|
|
718
718
|
const t = Yt(s);
|
|
719
719
|
if (!t.valid)
|
|
@@ -878,7 +878,7 @@ function Ze(s, e, t) {
|
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
const ne = {};
|
|
881
|
-
class
|
|
881
|
+
class I {
|
|
882
882
|
/**
|
|
883
883
|
* Retrieves a value from global state.
|
|
884
884
|
*
|
|
@@ -936,7 +936,7 @@ class _ {
|
|
|
936
936
|
return { ...ne };
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
|
-
class Fe extends
|
|
939
|
+
class Fe extends I {
|
|
940
940
|
storeManager;
|
|
941
941
|
integrationId;
|
|
942
942
|
apiUrl;
|
|
@@ -1622,7 +1622,7 @@ class Fe extends _ {
|
|
|
1622
1622
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1623
1623
|
}
|
|
1624
1624
|
}
|
|
1625
|
-
class er extends
|
|
1625
|
+
class er extends I {
|
|
1626
1626
|
bootTime;
|
|
1627
1627
|
bootTimestamp;
|
|
1628
1628
|
hasPerformanceNow;
|
|
@@ -1771,7 +1771,7 @@ class er extends _ {
|
|
|
1771
1771
|
};
|
|
1772
1772
|
}
|
|
1773
1773
|
}
|
|
1774
|
-
class tr extends
|
|
1774
|
+
class tr extends I {
|
|
1775
1775
|
dataSenders;
|
|
1776
1776
|
emitter;
|
|
1777
1777
|
transformers;
|
|
@@ -2636,7 +2636,7 @@ class tr extends _ {
|
|
|
2636
2636
|
return;
|
|
2637
2637
|
}
|
|
2638
2638
|
}
|
|
2639
|
-
const t = this.get("userId") || "anonymous", r = `${
|
|
2639
|
+
const t = this.get("userId") || "anonymous", r = `${_}:${t}:session_counts:`, n = [];
|
|
2640
2640
|
for (let i = 0; i < localStorage.length; i++) {
|
|
2641
2641
|
const o = localStorage.key(i);
|
|
2642
2642
|
if (o?.startsWith(r))
|
|
@@ -2727,7 +2727,7 @@ class rr {
|
|
|
2727
2727
|
}
|
|
2728
2728
|
}
|
|
2729
2729
|
const sr = /^\d{13}-[a-z0-9]{9}$/;
|
|
2730
|
-
class nr extends
|
|
2730
|
+
class nr extends I {
|
|
2731
2731
|
storageManager;
|
|
2732
2732
|
eventManager;
|
|
2733
2733
|
projectId;
|
|
@@ -3047,7 +3047,7 @@ class nr extends _ {
|
|
|
3047
3047
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3048
3048
|
}
|
|
3049
3049
|
}
|
|
3050
|
-
class ir extends
|
|
3050
|
+
class ir extends I {
|
|
3051
3051
|
eventManager;
|
|
3052
3052
|
storageManager;
|
|
3053
3053
|
sessionManager = null;
|
|
@@ -3135,7 +3135,7 @@ class ir extends _ {
|
|
|
3135
3135
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3136
3136
|
}
|
|
3137
3137
|
}
|
|
3138
|
-
class or extends
|
|
3138
|
+
class or extends I {
|
|
3139
3139
|
eventManager;
|
|
3140
3140
|
onTrack;
|
|
3141
3141
|
originalPushState;
|
|
@@ -3211,7 +3211,7 @@ class or extends _ {
|
|
|
3211
3211
|
};
|
|
3212
3212
|
}
|
|
3213
3213
|
}
|
|
3214
|
-
class ar extends
|
|
3214
|
+
class ar extends I {
|
|
3215
3215
|
eventManager;
|
|
3216
3216
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3217
3217
|
clickHandler;
|
|
@@ -3468,7 +3468,7 @@ class ar extends _ {
|
|
|
3468
3468
|
};
|
|
3469
3469
|
}
|
|
3470
3470
|
}
|
|
3471
|
-
class lr extends
|
|
3471
|
+
class lr extends I {
|
|
3472
3472
|
eventManager;
|
|
3473
3473
|
containers = [];
|
|
3474
3474
|
limitWarningLogged = !1;
|
|
@@ -3696,7 +3696,7 @@ class lr extends _ {
|
|
|
3696
3696
|
e.isPrimary = t;
|
|
3697
3697
|
}
|
|
3698
3698
|
}
|
|
3699
|
-
class cr extends
|
|
3699
|
+
class cr extends I {
|
|
3700
3700
|
eventManager;
|
|
3701
3701
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3702
3702
|
observer = null;
|
|
@@ -4140,7 +4140,7 @@ class ur {
|
|
|
4140
4140
|
this.fallbackSessionStorage.delete(e);
|
|
4141
4141
|
}
|
|
4142
4142
|
}
|
|
4143
|
-
class dr extends
|
|
4143
|
+
class dr extends I {
|
|
4144
4144
|
eventManager;
|
|
4145
4145
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4146
4146
|
navigationHistory = [];
|
|
@@ -4373,7 +4373,7 @@ class dr extends _ {
|
|
|
4373
4373
|
return !(typeof r == "number" && t <= r);
|
|
4374
4374
|
}
|
|
4375
4375
|
}
|
|
4376
|
-
class hr extends
|
|
4376
|
+
class hr extends I {
|
|
4377
4377
|
eventManager;
|
|
4378
4378
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4379
4379
|
errorBurstCounter = 0;
|
|
@@ -4423,10 +4423,10 @@ class hr extends _ {
|
|
|
4423
4423
|
if (!this.shouldSample())
|
|
4424
4424
|
return;
|
|
4425
4425
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4426
|
-
this.shouldSuppressError(
|
|
4426
|
+
this.shouldSuppressError(H.JS_ERROR, t) || this.eventManager.track({
|
|
4427
4427
|
type: d.ERROR,
|
|
4428
4428
|
error_data: {
|
|
4429
|
-
type:
|
|
4429
|
+
type: H.JS_ERROR,
|
|
4430
4430
|
message: t,
|
|
4431
4431
|
...e.filename && { filename: e.filename },
|
|
4432
4432
|
...e.lineno && { line: e.lineno },
|
|
@@ -4438,10 +4438,10 @@ class hr extends _ {
|
|
|
4438
4438
|
if (!this.shouldSample())
|
|
4439
4439
|
return;
|
|
4440
4440
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4441
|
-
this.shouldSuppressError(
|
|
4441
|
+
this.shouldSuppressError(H.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4442
4442
|
type: d.ERROR,
|
|
4443
4443
|
error_data: {
|
|
4444
|
-
type:
|
|
4444
|
+
type: H.PROMISE_REJECTION,
|
|
4445
4445
|
message: r
|
|
4446
4446
|
}
|
|
4447
4447
|
});
|
|
@@ -4484,7 +4484,7 @@ class hr extends _ {
|
|
|
4484
4484
|
}
|
|
4485
4485
|
}
|
|
4486
4486
|
}
|
|
4487
|
-
class fr extends
|
|
4487
|
+
class fr extends I {
|
|
4488
4488
|
isInitialized = !1;
|
|
4489
4489
|
suppressNextScrollTimer = null;
|
|
4490
4490
|
emitter = new Jt();
|
|
@@ -4503,25 +4503,25 @@ class fr extends _ {
|
|
|
4503
4503
|
* @internal Called from api.init()
|
|
4504
4504
|
*/
|
|
4505
4505
|
async init(e = {}) {
|
|
4506
|
-
if (
|
|
4507
|
-
this.
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
}
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
}
|
|
4506
|
+
if (this.isInitialized)
|
|
4507
|
+
return { sessionId: this.get("sessionId") ?? "" };
|
|
4508
|
+
this.managers.storage = new ur();
|
|
4509
|
+
try {
|
|
4510
|
+
this.setupState(e);
|
|
4511
|
+
const t = e.integrations?.custom?.headers ?? {};
|
|
4512
|
+
return this.managers.event = new tr(
|
|
4513
|
+
this.managers.storage,
|
|
4514
|
+
this.emitter,
|
|
4515
|
+
this.transformers,
|
|
4516
|
+
t,
|
|
4517
|
+
this.customHeadersProvider
|
|
4518
|
+
), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4519
|
+
a("warn", "Failed to recover persisted events", { error: r });
|
|
4520
|
+
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
4521
|
+
} catch (t) {
|
|
4522
|
+
this.destroy(!0);
|
|
4523
|
+
const r = t instanceof Error ? t.message : String(t);
|
|
4524
|
+
throw new Error(`[TraceLog] TraceLog initialization failed: ${r}`);
|
|
4525
4525
|
}
|
|
4526
4526
|
}
|
|
4527
4527
|
/**
|
|
@@ -4643,6 +4643,15 @@ class fr extends _ {
|
|
|
4643
4643
|
getEventManager() {
|
|
4644
4644
|
return this.managers.event;
|
|
4645
4645
|
}
|
|
4646
|
+
/**
|
|
4647
|
+
* Returns the current session ID.
|
|
4648
|
+
*
|
|
4649
|
+
* @returns The session ID string, or null if not yet initialized
|
|
4650
|
+
* @internal Used by api.getSessionId()
|
|
4651
|
+
*/
|
|
4652
|
+
getSessionId() {
|
|
4653
|
+
return this.get("sessionId");
|
|
4654
|
+
}
|
|
4646
4655
|
/**
|
|
4647
4656
|
* Validates metadata object structure and values.
|
|
4648
4657
|
*
|
|
@@ -4718,35 +4727,41 @@ class fr extends _ {
|
|
|
4718
4727
|
const N = [], M = [];
|
|
4719
4728
|
let R = null, h = null, C = !1, v = !1;
|
|
4720
4729
|
const mr = async (s) => {
|
|
4721
|
-
if (
|
|
4722
|
-
|
|
4730
|
+
if (typeof window > "u" || typeof document > "u")
|
|
4731
|
+
return { sessionId: "" };
|
|
4732
|
+
if (v = !1, window.__traceLogDisabled === !0)
|
|
4733
|
+
return { sessionId: "" };
|
|
4734
|
+
if (h)
|
|
4735
|
+
return { sessionId: h.getSessionId() ?? "" };
|
|
4736
|
+
if (C)
|
|
4737
|
+
return { sessionId: "" };
|
|
4738
|
+
C = !0;
|
|
4739
|
+
try {
|
|
4740
|
+
const e = zt(s ?? {}), t = new fr();
|
|
4723
4741
|
try {
|
|
4724
|
-
|
|
4742
|
+
N.forEach(({ event: o, callback: l }) => {
|
|
4743
|
+
t.on(o, l);
|
|
4744
|
+
}), N.length = 0, M.forEach(({ hook: o, fn: l }) => {
|
|
4745
|
+
o === "beforeSend" ? t.setTransformer("beforeSend", l) : t.setTransformer("beforeBatch", l);
|
|
4746
|
+
}), M.length = 0, R && (t.setCustomHeaders(R), R = null);
|
|
4747
|
+
const r = t.init(e), n = new Promise((o, l) => {
|
|
4748
|
+
setTimeout(() => {
|
|
4749
|
+
l(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4750
|
+
}, 1e4);
|
|
4751
|
+
}), i = await Promise.race([r, n]);
|
|
4752
|
+
return h = t, i;
|
|
4753
|
+
} catch (r) {
|
|
4725
4754
|
try {
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4730
|
-
}), M.length = 0, R && (t.setCustomHeaders(R), R = null);
|
|
4731
|
-
const r = t.init(e), n = new Promise((i, o) => {
|
|
4732
|
-
setTimeout(() => {
|
|
4733
|
-
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4734
|
-
}, 1e4);
|
|
4735
|
-
});
|
|
4736
|
-
await Promise.race([r, n]), h = t;
|
|
4737
|
-
} catch (r) {
|
|
4738
|
-
try {
|
|
4739
|
-
t.destroy(!0);
|
|
4740
|
-
} catch (n) {
|
|
4741
|
-
a("error", "Failed to cleanup partially initialized app", { error: n });
|
|
4742
|
-
}
|
|
4743
|
-
throw r;
|
|
4755
|
+
t.destroy(!0);
|
|
4756
|
+
} catch (n) {
|
|
4757
|
+
a("error", "Failed to cleanup partially initialized app", { error: n });
|
|
4744
4758
|
}
|
|
4745
|
-
|
|
4746
|
-
throw h = null, e;
|
|
4747
|
-
} finally {
|
|
4748
|
-
C = !1;
|
|
4759
|
+
throw r;
|
|
4749
4760
|
}
|
|
4761
|
+
} catch (e) {
|
|
4762
|
+
throw h = null, e;
|
|
4763
|
+
} finally {
|
|
4764
|
+
C = !1;
|
|
4750
4765
|
}
|
|
4751
4766
|
}, gr = (s, e) => {
|
|
4752
4767
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
@@ -4811,7 +4826,7 @@ const Tr = (s) => {
|
|
|
4811
4826
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
4812
4827
|
h.setCustomHeaders(s);
|
|
4813
4828
|
}
|
|
4814
|
-
},
|
|
4829
|
+
}, Ir = () => {
|
|
4815
4830
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4816
4831
|
if (!h) {
|
|
4817
4832
|
R = null;
|
|
@@ -4821,7 +4836,7 @@ const Tr = (s) => {
|
|
|
4821
4836
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
4822
4837
|
h.removeCustomHeaders();
|
|
4823
4838
|
}
|
|
4824
|
-
},
|
|
4839
|
+
}, _r = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, wr = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), yr = () => {
|
|
4825
4840
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4826
4841
|
if (v)
|
|
4827
4842
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4836,9 +4851,9 @@ const Tr = (s) => {
|
|
|
4836
4851
|
h = null, C = !1, N.length = 0, M.length = 0, R = null, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4837
4852
|
}
|
|
4838
4853
|
}
|
|
4839
|
-
}, yr = (s) => {
|
|
4840
|
-
typeof window > "u" || typeof document > "u" || Ut(s);
|
|
4841
4854
|
}, br = (s) => {
|
|
4855
|
+
typeof window > "u" || typeof document > "u" || Ut(s);
|
|
4856
|
+
}, Lr = (s) => {
|
|
4842
4857
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4843
4858
|
if (!h)
|
|
4844
4859
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4846,7 +4861,7 @@ const Tr = (s) => {
|
|
|
4846
4861
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4847
4862
|
h.updateGlobalMetadata(s);
|
|
4848
4863
|
}
|
|
4849
|
-
},
|
|
4864
|
+
}, Ar = (s) => {
|
|
4850
4865
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4851
4866
|
if (!h)
|
|
4852
4867
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4854,7 +4869,7 @@ const Tr = (s) => {
|
|
|
4854
4869
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4855
4870
|
h.mergeGlobalMetadata(s);
|
|
4856
4871
|
}
|
|
4857
|
-
},
|
|
4872
|
+
}, Zr = {
|
|
4858
4873
|
init: mr,
|
|
4859
4874
|
event: gr,
|
|
4860
4875
|
on: Er,
|
|
@@ -4862,12 +4877,13 @@ const Tr = (s) => {
|
|
|
4862
4877
|
setTransformer: pr,
|
|
4863
4878
|
removeTransformer: Tr,
|
|
4864
4879
|
setCustomHeaders: vr,
|
|
4865
|
-
removeCustomHeaders:
|
|
4866
|
-
isInitialized:
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4880
|
+
removeCustomHeaders: Ir,
|
|
4881
|
+
isInitialized: _r,
|
|
4882
|
+
getSessionId: wr,
|
|
4883
|
+
destroy: yr,
|
|
4884
|
+
setQaMode: br,
|
|
4885
|
+
updateGlobalMetadata: Lr,
|
|
4886
|
+
mergeGlobalMetadata: Ar
|
|
4871
4887
|
};
|
|
4872
4888
|
var me, et = -1, D = function(s) {
|
|
4873
4889
|
addEventListener("pageshow", (function(e) {
|
|
@@ -4901,7 +4917,7 @@ var me, et = -1, D = function(s) {
|
|
|
4901
4917
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4902
4918
|
})(e.value, t), s(e));
|
|
4903
4919
|
};
|
|
4904
|
-
},
|
|
4920
|
+
}, Ie = function(s) {
|
|
4905
4921
|
requestAnimationFrame((function() {
|
|
4906
4922
|
return requestAnimationFrame((function() {
|
|
4907
4923
|
return s();
|
|
@@ -4911,7 +4927,7 @@ var me, et = -1, D = function(s) {
|
|
|
4911
4927
|
document.addEventListener("visibilitychange", (function() {
|
|
4912
4928
|
document.visibilityState === "hidden" && s();
|
|
4913
4929
|
}));
|
|
4914
|
-
},
|
|
4930
|
+
}, _e = function(s) {
|
|
4915
4931
|
var e = !1;
|
|
4916
4932
|
return function() {
|
|
4917
4933
|
e || (s(), e = !0);
|
|
@@ -4919,10 +4935,10 @@ var me, et = -1, D = function(s) {
|
|
|
4919
4935
|
}, P = -1, $e = function() {
|
|
4920
4936
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4921
4937
|
}, q = function(s) {
|
|
4922
|
-
document.visibilityState === "hidden" && P > -1 && (P = s.type === "visibilitychange" ? s.timeStamp : 0,
|
|
4938
|
+
document.visibilityState === "hidden" && P > -1 && (P = s.type === "visibilitychange" ? s.timeStamp : 0, Mr());
|
|
4923
4939
|
}, Be = function() {
|
|
4924
4940
|
addEventListener("visibilitychange", q, !0), addEventListener("prerenderingchange", q, !0);
|
|
4925
|
-
},
|
|
4941
|
+
}, Mr = function() {
|
|
4926
4942
|
removeEventListener("visibilitychange", q, !0), removeEventListener("prerenderingchange", q, !0);
|
|
4927
4943
|
}, tt = function() {
|
|
4928
4944
|
return P < 0 && (P = $e(), Be(), D((function() {
|
|
@@ -4944,13 +4960,13 @@ var me, et = -1, D = function(s) {
|
|
|
4944
4960
|
}));
|
|
4945
4961
|
}));
|
|
4946
4962
|
i && (t = L(s, n, ge, e.reportAllChanges), D((function(o) {
|
|
4947
|
-
n = b("FCP"), t = L(s, n, ge, e.reportAllChanges),
|
|
4963
|
+
n = b("FCP"), t = L(s, n, ge, e.reportAllChanges), Ie((function() {
|
|
4948
4964
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4949
4965
|
}));
|
|
4950
4966
|
})));
|
|
4951
4967
|
}));
|
|
4952
|
-
}, Ee = [0.1, 0.25],
|
|
4953
|
-
e = e || {}, rt(
|
|
4968
|
+
}, Ee = [0.1, 0.25], Cr = function(s, e) {
|
|
4969
|
+
e = e || {}, rt(_e((function() {
|
|
4954
4970
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4955
4971
|
c.forEach((function(u) {
|
|
4956
4972
|
if (!u.hadRecentInput) {
|
|
@@ -4962,24 +4978,24 @@ var me, et = -1, D = function(s) {
|
|
|
4962
4978
|
l && (t = L(s, r, Ee, e.reportAllChanges), Z((function() {
|
|
4963
4979
|
o(l.takeRecords()), t(!0);
|
|
4964
4980
|
})), D((function() {
|
|
4965
|
-
n = 0, r = b("CLS", 0), t = L(s, r, Ee, e.reportAllChanges),
|
|
4981
|
+
n = 0, r = b("CLS", 0), t = L(s, r, Ee, e.reportAllChanges), Ie((function() {
|
|
4966
4982
|
return t();
|
|
4967
4983
|
}));
|
|
4968
4984
|
})), setTimeout(t, 0));
|
|
4969
4985
|
})));
|
|
4970
|
-
}, st = 0, ie = 1 / 0, X = 0,
|
|
4986
|
+
}, st = 0, ie = 1 / 0, X = 0, Rr = function(s) {
|
|
4971
4987
|
s.forEach((function(e) {
|
|
4972
4988
|
e.interactionId && (ie = Math.min(ie, e.interactionId), X = Math.max(X, e.interactionId), st = X ? (X - ie) / 7 + 1 : 0);
|
|
4973
4989
|
}));
|
|
4974
4990
|
}, nt = function() {
|
|
4975
4991
|
return me ? st : performance.interactionCount || 0;
|
|
4976
|
-
},
|
|
4977
|
-
"interactionCount" in performance || me || (me = $("event",
|
|
4978
|
-
}, y = [], z = /* @__PURE__ */ new Map(), it = 0,
|
|
4992
|
+
}, Nr = function() {
|
|
4993
|
+
"interactionCount" in performance || me || (me = $("event", Rr, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4994
|
+
}, y = [], z = /* @__PURE__ */ new Map(), it = 0, Or = function() {
|
|
4979
4995
|
var s = Math.min(y.length - 1, Math.floor((nt() - it) / 50));
|
|
4980
4996
|
return y[s];
|
|
4981
|
-
},
|
|
4982
|
-
if (
|
|
4997
|
+
}, Pr = [], Dr = function(s) {
|
|
4998
|
+
if (Pr.forEach((function(n) {
|
|
4983
4999
|
return n(s);
|
|
4984
5000
|
})), s.interactionId || s.entryType === "first-input") {
|
|
4985
5001
|
var e = y[y.length - 1], t = z.get(s.interactionId);
|
|
@@ -4998,15 +5014,15 @@ var me, et = -1, D = function(s) {
|
|
|
4998
5014
|
}
|
|
4999
5015
|
}, ot = function(s) {
|
|
5000
5016
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5001
|
-
return s =
|
|
5002
|
-
}, Se = [200, 500],
|
|
5017
|
+
return s = _e(s), document.visibilityState === "hidden" ? s() : (t = e(s), Z(s)), t;
|
|
5018
|
+
}, Se = [200, 500], kr = function(s, e) {
|
|
5003
5019
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, ee((function() {
|
|
5004
5020
|
var t;
|
|
5005
|
-
|
|
5021
|
+
Nr();
|
|
5006
5022
|
var r, n = b("INP"), i = function(l) {
|
|
5007
5023
|
ot((function() {
|
|
5008
|
-
l.forEach(
|
|
5009
|
-
var c =
|
|
5024
|
+
l.forEach(Dr);
|
|
5025
|
+
var c = Or();
|
|
5010
5026
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
5011
5027
|
}));
|
|
5012
5028
|
}, o = $("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
@@ -5016,7 +5032,7 @@ var me, et = -1, D = function(s) {
|
|
|
5016
5032
|
it = nt(), y.length = 0, z.clear(), n = b("INP"), r = L(s, n, Se, e.reportAllChanges);
|
|
5017
5033
|
})));
|
|
5018
5034
|
})));
|
|
5019
|
-
}, pe = [2500, 4e3], oe = {},
|
|
5035
|
+
}, pe = [2500, 4e3], oe = {}, Vr = function(s, e) {
|
|
5020
5036
|
e = e || {}, ee((function() {
|
|
5021
5037
|
var t, r = tt(), n = b("LCP"), i = function(c) {
|
|
5022
5038
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
@@ -5025,7 +5041,7 @@ var me, et = -1, D = function(s) {
|
|
|
5025
5041
|
}, o = $("largest-contentful-paint", i);
|
|
5026
5042
|
if (o) {
|
|
5027
5043
|
t = L(s, n, pe, e.reportAllChanges);
|
|
5028
|
-
var l =
|
|
5044
|
+
var l = _e((function() {
|
|
5029
5045
|
oe[n.id] || (i(o.takeRecords()), o.disconnect(), oe[n.id] = !0, t(!0));
|
|
5030
5046
|
}));
|
|
5031
5047
|
["keydown", "click"].forEach((function(c) {
|
|
@@ -5033,22 +5049,22 @@ var me, et = -1, D = function(s) {
|
|
|
5033
5049
|
return ot(l);
|
|
5034
5050
|
}), { once: !0, capture: !0 });
|
|
5035
5051
|
})), Z(l), D((function(c) {
|
|
5036
|
-
n = b("LCP"), t = L(s, n, pe, e.reportAllChanges),
|
|
5052
|
+
n = b("LCP"), t = L(s, n, pe, e.reportAllChanges), Ie((function() {
|
|
5037
5053
|
n.value = performance.now() - c.timeStamp, oe[n.id] = !0, t(!0);
|
|
5038
5054
|
}));
|
|
5039
5055
|
}));
|
|
5040
5056
|
}
|
|
5041
5057
|
}));
|
|
5042
|
-
}, Te = [800, 1800],
|
|
5058
|
+
}, Te = [800, 1800], Ur = function s(e) {
|
|
5043
5059
|
document.prerendering ? ee((function() {
|
|
5044
5060
|
return s(e);
|
|
5045
5061
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5046
5062
|
return s(e);
|
|
5047
5063
|
}), !0) : setTimeout(e, 0);
|
|
5048
|
-
},
|
|
5064
|
+
}, Hr = function(s, e) {
|
|
5049
5065
|
e = e || {};
|
|
5050
5066
|
var t = b("TTFB"), r = L(s, t, Te, e.reportAllChanges);
|
|
5051
|
-
|
|
5067
|
+
Ur((function() {
|
|
5052
5068
|
var n = ve();
|
|
5053
5069
|
n && (t.value = Math.max(n.responseStart - J(), 0), t.entries = [n], r(!0), D((function() {
|
|
5054
5070
|
t = b("TTFB", 0), (r = L(s, t, Te, e.reportAllChanges))(!0);
|
|
@@ -5062,30 +5078,30 @@ const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5062
5078
|
INPThresholds: Se,
|
|
5063
5079
|
LCPThresholds: pe,
|
|
5064
5080
|
TTFBThresholds: Te,
|
|
5065
|
-
onCLS:
|
|
5081
|
+
onCLS: Cr,
|
|
5066
5082
|
onFCP: rt,
|
|
5067
|
-
onINP:
|
|
5068
|
-
onLCP:
|
|
5069
|
-
onTTFB:
|
|
5083
|
+
onINP: kr,
|
|
5084
|
+
onLCP: Vr,
|
|
5085
|
+
onTTFB: Hr
|
|
5070
5086
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5071
5087
|
export {
|
|
5072
5088
|
f as AppConfigValidationError,
|
|
5073
|
-
|
|
5089
|
+
Fr as DEFAULT_SESSION_TIMEOUT,
|
|
5074
5090
|
ue as DEFAULT_WEB_VITALS_MODE,
|
|
5075
5091
|
A as DeviceType,
|
|
5076
5092
|
ae as EmitterEvent,
|
|
5077
|
-
|
|
5093
|
+
H as ErrorType,
|
|
5078
5094
|
d as EventType,
|
|
5079
|
-
|
|
5095
|
+
qr as InitializationTimeoutError,
|
|
5080
5096
|
V as IntegrationValidationError,
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5097
|
+
zr as MAX_ARRAY_LENGTH,
|
|
5098
|
+
Gr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5099
|
+
Wr as MAX_CUSTOM_EVENT_KEYS,
|
|
5100
|
+
$r as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5101
|
+
Br as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5102
|
+
Xr as MAX_NESTED_OBJECT_KEYS,
|
|
5103
|
+
Qr as MAX_STRING_LENGTH,
|
|
5104
|
+
jr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5089
5105
|
K as Mode,
|
|
5090
5106
|
je as PII_PATTERNS,
|
|
5091
5107
|
O as PermanentError,
|
|
@@ -5094,11 +5110,11 @@ export {
|
|
|
5094
5110
|
mt as SessionTimeoutValidationError,
|
|
5095
5111
|
U as SpecialApiUrl,
|
|
5096
5112
|
F as TraceLogValidationError,
|
|
5097
|
-
|
|
5113
|
+
Jr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5098
5114
|
ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5099
5115
|
Rt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5100
5116
|
Ve as getWebVitalsThresholds,
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5117
|
+
Kr as isPrimaryScrollEvent,
|
|
5118
|
+
Yr as isSecondaryScrollEvent,
|
|
5119
|
+
Zr as tracelog
|
|
5104
5120
|
};
|