@tracelog/lib 2.1.0 → 2.1.1-rc.75.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +341 -302
- 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 +84 -9
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +2 -0
- package/dist/public-api.d.ts +2 -0
- package/dist/public-api.js +84 -9
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const w = "data-tlog",
|
|
1
|
+
const kr = 9e5;
|
|
2
|
+
const Ur = 120, xr = 8192, Hr = 10, Fr = 10, $r = 20, Br = 1;
|
|
3
|
+
const Wr = 1e3, Gr = 500, Xr = 100;
|
|
4
|
+
const w = "data-tlog", ot = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const w = "data-tlog", nt = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], at = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], lt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,22 +71,22 @@ const m = {
|
|
|
71
71
|
INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
},
|
|
74
|
+
}, ct = [
|
|
75
75
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
76
76
|
/javascript:/gi,
|
|
77
77
|
/on\w+\s*=/gi,
|
|
78
78
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
79
79
|
/<embed\b[^>]*>/gi,
|
|
80
80
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
81
|
-
], I = "tlog", x = `${I}:qa_mode`,
|
|
81
|
+
], I = "tlog", x = `${I}:qa_mode`, _e = `${I}:uid`, $e = "tlog_mode", ve = "qa", Ie = "qa_off", ut = (s) => s ? `${I}:${s}:queue` : `${I}:queue`, dt = (s) => s ? `${I}:${s}:session` : `${I}:session`, ht = (s) => s ? `${I}:${s}:broadcast` : `${I}:broadcast`, we = (s, e) => `${I}:${s}:session_counts:${e}`, ye = 10080 * 60 * 1e3, be = `${I}:session_counts_last_cleanup`, Ae = 3600 * 1e3;
|
|
82
82
|
var k = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(k || {}), L = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(L || {}), ne = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(ne || {});
|
|
83
83
|
class N extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
85
|
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
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 || {}), X = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(X || {}), U = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(U || {}),
|
|
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 || {}), X = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(X || {}), U = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(U || {}), z = /* @__PURE__ */ ((s) => (s.QA = "qa", s))(z || {});
|
|
89
|
+
const Qr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !0, jr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !1;
|
|
90
90
|
class H 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);
|
|
@@ -97,12 +97,12 @@ class h extends H {
|
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class ft extends H {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class Le extends H {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
@@ -112,12 +112,12 @@ class V extends H {
|
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class zr extends H {
|
|
116
116
|
constructor(e, t, r = "runtime") {
|
|
117
117
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
const
|
|
120
|
+
const Be = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", We = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", mt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", gt = (s, e) => {
|
|
121
121
|
if (e) {
|
|
122
122
|
if (e instanceof Error) {
|
|
123
123
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -136,7 +136,7 @@ const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
136
136
|
return `[TraceLog] ${s}: ${String(e)}`;
|
|
137
137
|
}
|
|
138
138
|
return `[TraceLog] ${s}`;
|
|
139
|
-
},
|
|
139
|
+
}, Et = () => {
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
142
142
|
try {
|
|
@@ -145,12 +145,12 @@ const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
147
147
|
}, a = (s, e, t) => {
|
|
148
|
-
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ?
|
|
149
|
-
if (!
|
|
148
|
+
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? gt(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
|
|
149
|
+
if (!St(l, i))
|
|
150
150
|
return;
|
|
151
|
-
const g =
|
|
152
|
-
|
|
153
|
-
},
|
|
151
|
+
const g = pt(l, o), p = n !== void 0 ? ie(n) : void 0;
|
|
152
|
+
Tt(u, c, g, p);
|
|
153
|
+
}, St = (s, e) => s === "critical" ? !0 : s === "qa" || e ? Et() : !1, pt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? mt : "", Tt = (s, e, t, r) => {
|
|
154
154
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
155
155
|
r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
|
|
156
156
|
}, ie = (s) => {
|
|
@@ -167,10 +167,10 @@ const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let oe,
|
|
171
|
-
const
|
|
172
|
-
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"),
|
|
173
|
-
}, K = "Unknown",
|
|
170
|
+
let oe, Ge;
|
|
171
|
+
const _t = () => {
|
|
172
|
+
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"), Ge = window.matchMedia("(hover: none)"));
|
|
173
|
+
}, K = "Unknown", vt = (s) => {
|
|
174
174
|
const e = s.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
176
176
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -182,7 +182,7 @@ const pt = () => {
|
|
|
182
182
|
}
|
|
183
183
|
const t = navigator.userAgent;
|
|
184
184
|
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : K;
|
|
185
|
-
},
|
|
185
|
+
}, It = (s) => {
|
|
186
186
|
const e = s.userAgentData?.brands;
|
|
187
187
|
if (e != null && e.length > 0) {
|
|
188
188
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -193,26 +193,26 @@ const pt = () => {
|
|
|
193
193
|
}
|
|
194
194
|
const t = navigator.userAgent;
|
|
195
195
|
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : K;
|
|
196
|
-
},
|
|
196
|
+
}, wt = () => {
|
|
197
197
|
try {
|
|
198
198
|
const s = navigator;
|
|
199
199
|
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
200
200
|
const c = s.userAgentData.platform;
|
|
201
201
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : s.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
const e = window.innerWidth, t = oe?.matches ?? !1, r =
|
|
203
|
+
_t();
|
|
204
|
+
const e = window.innerWidth, t = oe?.matches ?? !1, r = Ge?.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 ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? L.Tablet : L.Desktop;
|
|
206
206
|
} catch (s) {
|
|
207
207
|
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), L.Desktop;
|
|
208
208
|
}
|
|
209
|
-
},
|
|
209
|
+
}, yt = () => {
|
|
210
210
|
try {
|
|
211
211
|
const s = navigator;
|
|
212
212
|
return {
|
|
213
|
-
type:
|
|
214
|
-
os:
|
|
215
|
-
browser:
|
|
213
|
+
type: wt(),
|
|
214
|
+
os: vt(s),
|
|
215
|
+
browser: It(s)
|
|
216
216
|
};
|
|
217
217
|
} catch (s) {
|
|
218
218
|
return a("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
@@ -221,7 +221,7 @@ const pt = () => {
|
|
|
221
221
|
browser: K
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
},
|
|
224
|
+
}, Xe = [
|
|
225
225
|
// Email addresses
|
|
226
226
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
227
227
|
// US Phone numbers (various formats)
|
|
@@ -236,7 +236,7 @@ const pt = () => {
|
|
|
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
|
-
],
|
|
239
|
+
], Me = 500, Ce = 5e3, Q = 50, bt = Q * 2, Qe = 1, At = 1e3, Lt = 10, Re = 5e3, Mt = 6e4, Kr = {
|
|
240
240
|
LCP: 2500,
|
|
241
241
|
// Good: ≤ 2.5s
|
|
242
242
|
FCP: 1800,
|
|
@@ -248,7 +248,7 @@ const pt = () => {
|
|
|
248
248
|
TTFB: 800,
|
|
249
249
|
// Good: ≤ 800ms
|
|
250
250
|
LONG_TASK: 50
|
|
251
|
-
},
|
|
251
|
+
}, Ne = {
|
|
252
252
|
LCP: 2500,
|
|
253
253
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
254
254
|
FCP: 1800,
|
|
@@ -260,7 +260,7 @@ const pt = () => {
|
|
|
260
260
|
TTFB: 800,
|
|
261
261
|
// Needs improvement: > 800ms
|
|
262
262
|
LONG_TASK: 50
|
|
263
|
-
},
|
|
263
|
+
}, Ct = {
|
|
264
264
|
LCP: 4e3,
|
|
265
265
|
// Poor: > 4s
|
|
266
266
|
FCP: 3e3,
|
|
@@ -272,67 +272,95 @@ const pt = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
}, ae = "needs-improvement",
|
|
275
|
+
}, ae = "needs-improvement", Oe = (s = ae) => {
|
|
276
276
|
switch (s) {
|
|
277
277
|
case "all":
|
|
278
278
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
279
279
|
// Track everything
|
|
280
280
|
case "needs-improvement":
|
|
281
|
-
return
|
|
281
|
+
return Ne;
|
|
282
282
|
case "poor":
|
|
283
|
-
return
|
|
283
|
+
return Ct;
|
|
284
284
|
default:
|
|
285
|
-
return
|
|
285
|
+
return Ne;
|
|
286
286
|
}
|
|
287
|
-
},
|
|
287
|
+
}, Rt = 1e3, Nt = 50, Ot = "2.1.1", Pt = Ot, je = () => typeof window < "u" && typeof sessionStorage < "u", Dt = () => {
|
|
288
288
|
try {
|
|
289
289
|
const s = new URLSearchParams(window.location.search);
|
|
290
|
-
s.delete(
|
|
290
|
+
s.delete($e);
|
|
291
291
|
const e = s.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
292
292
|
window.history.replaceState({}, "", t);
|
|
293
293
|
} catch {
|
|
294
294
|
}
|
|
295
|
-
},
|
|
296
|
-
if (!
|
|
295
|
+
}, Vt = () => {
|
|
296
|
+
if (!je())
|
|
297
297
|
return !1;
|
|
298
298
|
try {
|
|
299
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
299
|
+
const e = new URLSearchParams(window.location.search).get($e), t = sessionStorage.getItem(x);
|
|
300
300
|
let r = null;
|
|
301
|
-
return e ===
|
|
301
|
+
return e === ve ? (r = !0, sessionStorage.setItem(x, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
302
|
visibility: "qa",
|
|
303
|
-
style:
|
|
304
|
-
})) : e ===
|
|
303
|
+
style: Be
|
|
304
|
+
})) : e === Ie && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
305
|
visibility: "qa",
|
|
306
|
-
style:
|
|
307
|
-
})), (e ===
|
|
306
|
+
style: We
|
|
307
|
+
})), (e === ve || e === Ie) && Dt(), r ?? t === "true";
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
312
|
-
if (
|
|
311
|
+
}, kt = (s) => {
|
|
312
|
+
if (je())
|
|
313
313
|
try {
|
|
314
314
|
sessionStorage.setItem(x, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
|
-
style: s ?
|
|
316
|
+
style: s ? Be : We
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
|
-
},
|
|
321
|
+
}, Ut = [
|
|
322
|
+
"co.uk",
|
|
323
|
+
"org.uk",
|
|
324
|
+
"com.au",
|
|
325
|
+
"net.au",
|
|
326
|
+
"com.br",
|
|
327
|
+
"co.nz",
|
|
328
|
+
"co.jp",
|
|
329
|
+
"com.mx",
|
|
330
|
+
"co.in",
|
|
331
|
+
"com.cn",
|
|
332
|
+
"co.za"
|
|
333
|
+
], Pe = (s) => {
|
|
334
|
+
const e = s.toLowerCase().split(".");
|
|
335
|
+
if (e.length <= 2)
|
|
336
|
+
return s.toLowerCase();
|
|
337
|
+
const t = e.slice(-2).join(".");
|
|
338
|
+
return Ut.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
339
|
+
}, xt = (s, e) => s === e ? !0 : Pe(s) === Pe(e), De = () => {
|
|
340
|
+
const s = document.referrer;
|
|
341
|
+
if (!s)
|
|
342
|
+
return "Direct";
|
|
343
|
+
try {
|
|
344
|
+
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
345
|
+
return xt(e, t) ? "Direct" : s;
|
|
346
|
+
} catch (e) {
|
|
347
|
+
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
348
|
+
}
|
|
349
|
+
}, Ve = () => {
|
|
322
350
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
323
|
-
return
|
|
351
|
+
return at.forEach((r) => {
|
|
324
352
|
const n = s.get(r);
|
|
325
353
|
if (n) {
|
|
326
354
|
const i = r.split("utm_")[1];
|
|
327
355
|
e[i] = n;
|
|
328
356
|
}
|
|
329
357
|
}), Object.keys(e).length ? e : void 0;
|
|
330
|
-
},
|
|
358
|
+
}, Ht = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
331
359
|
const e = Math.random() * 16 | 0;
|
|
332
360
|
return (s === "x" ? e : e & 3 | 8).toString(16);
|
|
333
361
|
});
|
|
334
362
|
let B = 0, W = 0;
|
|
335
|
-
const
|
|
363
|
+
const Ft = () => {
|
|
336
364
|
let s = Date.now();
|
|
337
365
|
s < W && (s = W), s === W ? B = (B + 1) % 1e3 : B = 0, W = s;
|
|
338
366
|
const e = B.toString().padStart(3, "0");
|
|
@@ -345,14 +373,14 @@ const kt = () => {
|
|
|
345
373
|
} catch {
|
|
346
374
|
}
|
|
347
375
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${s}-${e}-${t}`;
|
|
348
|
-
},
|
|
376
|
+
}, ze = (s, e = !1) => {
|
|
349
377
|
try {
|
|
350
378
|
const t = new URL(s), r = t.protocol === "https:", n = t.protocol === "http:";
|
|
351
379
|
return r || e && n;
|
|
352
380
|
} catch {
|
|
353
381
|
return !1;
|
|
354
382
|
}
|
|
355
|
-
},
|
|
383
|
+
}, $t = (s) => {
|
|
356
384
|
try {
|
|
357
385
|
const t = new URL(window.location.href).hostname;
|
|
358
386
|
if (!t || typeof t != "string")
|
|
@@ -370,19 +398,19 @@ const kt = () => {
|
|
|
370
398
|
if (r.length === 2 ? n = r.join(".") : n = r.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
371
399
|
throw new Error("Invalid domain structure for SaaS");
|
|
372
400
|
const i = `https://${s}.${n}/collect`;
|
|
373
|
-
if (!
|
|
401
|
+
if (!ze(i))
|
|
374
402
|
throw new Error("Generated URL failed validation");
|
|
375
403
|
return i;
|
|
376
404
|
} catch (e) {
|
|
377
405
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
378
406
|
}
|
|
379
|
-
},
|
|
407
|
+
}, Bt = (s) => {
|
|
380
408
|
const e = {};
|
|
381
|
-
s.integrations?.tracelog?.projectId && (e.saas =
|
|
409
|
+
s.integrations?.tracelog?.projectId && (e.saas = $t(s.integrations.tracelog.projectId));
|
|
382
410
|
const t = s.integrations?.custom?.collectApiUrl;
|
|
383
411
|
if (t) {
|
|
384
412
|
const r = s.integrations?.custom?.allowHttp ?? !1;
|
|
385
|
-
if (!
|
|
413
|
+
if (!ze(t, r))
|
|
386
414
|
throw new Error("Invalid custom API URL");
|
|
387
415
|
e.custom = t;
|
|
388
416
|
}
|
|
@@ -391,7 +419,7 @@ const kt = () => {
|
|
|
391
419
|
if (!s || typeof s != "string")
|
|
392
420
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof s } }), s || "";
|
|
393
421
|
try {
|
|
394
|
-
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
422
|
+
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...lt, ...e])];
|
|
395
423
|
let i = !1;
|
|
396
424
|
const o = [];
|
|
397
425
|
return n.forEach((c) => {
|
|
@@ -400,13 +428,13 @@ const kt = () => {
|
|
|
400
428
|
} catch (t) {
|
|
401
429
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
402
430
|
}
|
|
403
|
-
},
|
|
431
|
+
}, ke = (s) => {
|
|
404
432
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
405
433
|
return "";
|
|
406
434
|
let e = s;
|
|
407
435
|
s.length > 1e3 && (e = s.slice(0, Math.max(0, 1e3)));
|
|
408
436
|
let t = 0;
|
|
409
|
-
for (const n of
|
|
437
|
+
for (const n of ct) {
|
|
410
438
|
const i = e;
|
|
411
439
|
e = e.replace(n, ""), i !== e && t++;
|
|
412
440
|
}
|
|
@@ -420,7 +448,7 @@ const kt = () => {
|
|
|
420
448
|
if (e > 3 || s == null)
|
|
421
449
|
return null;
|
|
422
450
|
if (typeof s == "string")
|
|
423
|
-
return
|
|
451
|
+
return ke(s);
|
|
424
452
|
if (typeof s == "number")
|
|
425
453
|
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
426
454
|
if (typeof s == "boolean")
|
|
@@ -430,7 +458,7 @@ const kt = () => {
|
|
|
430
458
|
if (typeof s == "object") {
|
|
431
459
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
432
460
|
for (const [i, o] of n) {
|
|
433
|
-
const l =
|
|
461
|
+
const l = ke(i);
|
|
434
462
|
if (l) {
|
|
435
463
|
const c = ce(o, e + 1);
|
|
436
464
|
c !== null && (t[l] = c);
|
|
@@ -439,7 +467,7 @@ const kt = () => {
|
|
|
439
467
|
return t;
|
|
440
468
|
}
|
|
441
469
|
return null;
|
|
442
|
-
},
|
|
470
|
+
}, Wt = (s) => {
|
|
443
471
|
if (typeof s != "object" || s === null)
|
|
444
472
|
return {};
|
|
445
473
|
try {
|
|
@@ -449,15 +477,15 @@ const kt = () => {
|
|
|
449
477
|
const t = e instanceof Error ? e.message : String(e);
|
|
450
478
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
451
479
|
}
|
|
452
|
-
},
|
|
480
|
+
}, Gt = (s) => {
|
|
453
481
|
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
454
482
|
throw new h("Configuration must be an object", "config");
|
|
455
483
|
if (s) {
|
|
456
484
|
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
457
|
-
throw new
|
|
485
|
+
throw new ft(m.INVALID_SESSION_TIMEOUT, "config");
|
|
458
486
|
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
459
487
|
throw new h(m.INVALID_GLOBAL_METADATA, "config");
|
|
460
|
-
if (s.integrations &&
|
|
488
|
+
if (s.integrations && Qt(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
461
489
|
if (!Array.isArray(s.sensitiveQueryParams))
|
|
462
490
|
throw new h(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
463
491
|
for (const e of s.sensitiveQueryParams)
|
|
@@ -465,9 +493,9 @@ const kt = () => {
|
|
|
465
493
|
throw new h("All sensitive query params must be strings", "config");
|
|
466
494
|
}
|
|
467
495
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
468
|
-
throw new
|
|
496
|
+
throw new Le(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
469
497
|
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
470
|
-
throw new
|
|
498
|
+
throw new Le(m.INVALID_SAMPLING_RATE, "config");
|
|
471
499
|
if (s.primaryScrollSelector !== void 0) {
|
|
472
500
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
473
501
|
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -487,7 +515,7 @@ const kt = () => {
|
|
|
487
515
|
throw new h(m.INVALID_CLICK_THROTTLE, "config");
|
|
488
516
|
if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
|
|
489
517
|
throw new h(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
490
|
-
if (s.viewport !== void 0 &&
|
|
518
|
+
if (s.viewport !== void 0 && Xt(s.viewport), s.webVitalsMode !== void 0) {
|
|
491
519
|
if (typeof s.webVitalsMode != "string")
|
|
492
520
|
throw new h(
|
|
493
521
|
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
@@ -518,7 +546,7 @@ const kt = () => {
|
|
|
518
546
|
}
|
|
519
547
|
}
|
|
520
548
|
}
|
|
521
|
-
},
|
|
549
|
+
}, Xt = (s) => {
|
|
522
550
|
if (typeof s != "object" || s === null)
|
|
523
551
|
throw new h(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
524
552
|
if (!s.elements || !Array.isArray(s.elements))
|
|
@@ -548,7 +576,7 @@ const kt = () => {
|
|
|
548
576
|
throw new h(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
549
577
|
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
550
578
|
throw new h(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
551
|
-
},
|
|
579
|
+
}, Qt = (s) => {
|
|
552
580
|
if (s) {
|
|
553
581
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
554
582
|
throw new V(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
@@ -567,14 +595,14 @@ const kt = () => {
|
|
|
567
595
|
);
|
|
568
596
|
}
|
|
569
597
|
}
|
|
570
|
-
},
|
|
571
|
-
|
|
598
|
+
}, jt = (s) => {
|
|
599
|
+
Gt(s);
|
|
572
600
|
const e = {
|
|
573
601
|
...s ?? {},
|
|
574
602
|
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
575
603
|
globalMetadata: s?.globalMetadata ?? {},
|
|
576
604
|
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
577
|
-
errorSampling: s?.errorSampling ??
|
|
605
|
+
errorSampling: s?.errorSampling ?? Qe,
|
|
578
606
|
samplingRate: s?.samplingRate ?? 1,
|
|
579
607
|
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
580
608
|
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
@@ -590,7 +618,7 @@ const kt = () => {
|
|
|
590
618
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
591
619
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
592
620
|
}), e;
|
|
593
|
-
},
|
|
621
|
+
}, zt = (s) => {
|
|
594
622
|
if (typeof s == "string")
|
|
595
623
|
return !0;
|
|
596
624
|
if (typeof s == "object" && s !== null && !Array.isArray(s)) {
|
|
@@ -607,7 +635,7 @@ const kt = () => {
|
|
|
607
635
|
return !0;
|
|
608
636
|
}
|
|
609
637
|
return !1;
|
|
610
|
-
},
|
|
638
|
+
}, Ke = (s, e = 0) => {
|
|
611
639
|
if (typeof s != "object" || s === null || e > 1)
|
|
612
640
|
return !1;
|
|
613
641
|
for (const t of Object.values(s)) {
|
|
@@ -621,12 +649,12 @@ const kt = () => {
|
|
|
621
649
|
if (typeof t[0] == "string") {
|
|
622
650
|
if (!t.every((o) => typeof o == "string"))
|
|
623
651
|
return !1;
|
|
624
|
-
} else if (!t.every((o) =>
|
|
652
|
+
} else if (!t.every((o) => zt(o)))
|
|
625
653
|
return !1;
|
|
626
654
|
continue;
|
|
627
655
|
}
|
|
628
656
|
if (r === "object" && e === 0) {
|
|
629
|
-
if (!
|
|
657
|
+
if (!Ke(t, e + 1))
|
|
630
658
|
return !1;
|
|
631
659
|
continue;
|
|
632
660
|
}
|
|
@@ -634,7 +662,7 @@ const kt = () => {
|
|
|
634
662
|
}
|
|
635
663
|
}
|
|
636
664
|
return !0;
|
|
637
|
-
},
|
|
665
|
+
}, Kt = (s) => typeof s != "string" ? {
|
|
638
666
|
valid: !1,
|
|
639
667
|
error: "Event name must be a string"
|
|
640
668
|
} : s.length === 0 ? {
|
|
@@ -649,9 +677,9 @@ const kt = () => {
|
|
|
649
677
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
650
678
|
valid: !1,
|
|
651
679
|
error: "Event name cannot be a reserved word"
|
|
652
|
-
} : { valid: !0 },
|
|
653
|
-
const r =
|
|
654
|
-
if (!
|
|
680
|
+
} : { valid: !0 }, Ue = (s, e, t) => {
|
|
681
|
+
const r = Wt(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
682
|
+
if (!Ke(r))
|
|
655
683
|
return {
|
|
656
684
|
valid: !1,
|
|
657
685
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -699,7 +727,7 @@ const kt = () => {
|
|
|
699
727
|
valid: !0,
|
|
700
728
|
sanitizedMetadata: r
|
|
701
729
|
};
|
|
702
|
-
},
|
|
730
|
+
}, Ye = (s, e, t) => {
|
|
703
731
|
if (Array.isArray(e)) {
|
|
704
732
|
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
705
733
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -709,7 +737,7 @@ const kt = () => {
|
|
|
709
737
|
valid: !1,
|
|
710
738
|
error: `${n}: array item at index ${i} must be an object.`
|
|
711
739
|
};
|
|
712
|
-
const l =
|
|
740
|
+
const l = Ue(s, o, t);
|
|
713
741
|
if (!l.valid)
|
|
714
742
|
return {
|
|
715
743
|
valid: !1,
|
|
@@ -722,16 +750,16 @@ const kt = () => {
|
|
|
722
750
|
sanitizedMetadata: r
|
|
723
751
|
};
|
|
724
752
|
}
|
|
725
|
-
return
|
|
726
|
-
},
|
|
727
|
-
const t =
|
|
753
|
+
return Ue(s, e, t);
|
|
754
|
+
}, Yt = (s, e) => {
|
|
755
|
+
const t = Kt(s);
|
|
728
756
|
if (!t.valid)
|
|
729
757
|
return a("error", "Event name validation failed", {
|
|
730
758
|
data: { eventName: s, error: t.error }
|
|
731
759
|
}), t;
|
|
732
760
|
if (!e)
|
|
733
761
|
return { valid: !0 };
|
|
734
|
-
const r =
|
|
762
|
+
const r = Ye(s, e, "customEvent");
|
|
735
763
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
736
764
|
data: {
|
|
737
765
|
eventName: s,
|
|
@@ -739,7 +767,7 @@ const kt = () => {
|
|
|
739
767
|
}
|
|
740
768
|
}), r;
|
|
741
769
|
};
|
|
742
|
-
class
|
|
770
|
+
class qt {
|
|
743
771
|
listeners = /* @__PURE__ */ new Map();
|
|
744
772
|
/**
|
|
745
773
|
* Subscribes to an event channel
|
|
@@ -856,7 +884,7 @@ class zt {
|
|
|
856
884
|
this.listeners.clear();
|
|
857
885
|
}
|
|
858
886
|
}
|
|
859
|
-
function
|
|
887
|
+
function qe(s, e, t) {
|
|
860
888
|
try {
|
|
861
889
|
const r = e(s);
|
|
862
890
|
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), s);
|
|
@@ -867,10 +895,10 @@ function je(s, e, t) {
|
|
|
867
895
|
}), s;
|
|
868
896
|
}
|
|
869
897
|
}
|
|
870
|
-
function
|
|
871
|
-
return s.map((r) =>
|
|
898
|
+
function Jt(s, e, t) {
|
|
899
|
+
return s.map((r) => qe(r, e, t)).filter((r) => r !== null);
|
|
872
900
|
}
|
|
873
|
-
function
|
|
901
|
+
function Je(s, e, t) {
|
|
874
902
|
try {
|
|
875
903
|
const r = e(s);
|
|
876
904
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -945,7 +973,7 @@ class _ {
|
|
|
945
973
|
return { ...te };
|
|
946
974
|
}
|
|
947
975
|
}
|
|
948
|
-
class
|
|
976
|
+
class xe extends _ {
|
|
949
977
|
storeManager;
|
|
950
978
|
integrationId;
|
|
951
979
|
apiUrl;
|
|
@@ -979,7 +1007,7 @@ class Ve extends _ {
|
|
|
979
1007
|
return this.integrationId;
|
|
980
1008
|
}
|
|
981
1009
|
getQueueStorageKey() {
|
|
982
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1010
|
+
const e = this.get("userId") || "anonymous", t = ut(e);
|
|
983
1011
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
984
1012
|
}
|
|
985
1013
|
/**
|
|
@@ -1180,7 +1208,7 @@ class Ve extends _ {
|
|
|
1180
1208
|
const t = this.transformers.beforeSend;
|
|
1181
1209
|
if (!t)
|
|
1182
1210
|
return e;
|
|
1183
|
-
const r =
|
|
1211
|
+
const r = Jt(
|
|
1184
1212
|
e.events,
|
|
1185
1213
|
t,
|
|
1186
1214
|
this.integrationId || "SenderManager"
|
|
@@ -1225,7 +1253,7 @@ class Ve extends _ {
|
|
|
1225
1253
|
if (this.integrationId === "saas")
|
|
1226
1254
|
return e;
|
|
1227
1255
|
const t = this.transformers.beforeBatch;
|
|
1228
|
-
return t ?
|
|
1256
|
+
return t ? Je(e, t, this.integrationId || "SenderManager") : e;
|
|
1229
1257
|
}
|
|
1230
1258
|
/**
|
|
1231
1259
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1458,7 +1486,7 @@ class Ve extends _ {
|
|
|
1458
1486
|
_metadata: {
|
|
1459
1487
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1460
1488
|
timestamp: t,
|
|
1461
|
-
client_version:
|
|
1489
|
+
client_version: Pt
|
|
1462
1490
|
}
|
|
1463
1491
|
};
|
|
1464
1492
|
return {
|
|
@@ -1579,12 +1607,12 @@ class Ve extends _ {
|
|
|
1579
1607
|
}
|
|
1580
1608
|
logPermanentError(e, t) {
|
|
1581
1609
|
const r = Date.now();
|
|
1582
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1610
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= Mt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1583
1611
|
data: { status: t.statusCode, message: t.message }
|
|
1584
1612
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1585
1613
|
}
|
|
1586
1614
|
}
|
|
1587
|
-
class
|
|
1615
|
+
class Zt extends _ {
|
|
1588
1616
|
bootTime;
|
|
1589
1617
|
bootTimestamp;
|
|
1590
1618
|
hasPerformanceNow;
|
|
@@ -1733,7 +1761,7 @@ class Kt extends _ {
|
|
|
1733
1761
|
};
|
|
1734
1762
|
}
|
|
1735
1763
|
}
|
|
1736
|
-
class
|
|
1764
|
+
class er extends _ {
|
|
1737
1765
|
dataSenders;
|
|
1738
1766
|
emitter;
|
|
1739
1767
|
transformers;
|
|
@@ -1767,9 +1795,9 @@ class Yt extends _ {
|
|
|
1767
1795
|
* @param transformers - Optional event transformation hooks
|
|
1768
1796
|
*/
|
|
1769
1797
|
constructor(e, t = null, r = {}) {
|
|
1770
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1798
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new Zt(), this.dataSenders = [];
|
|
1771
1799
|
const n = this.get("collectApiUrls");
|
|
1772
|
-
n?.saas && this.dataSenders.push(new
|
|
1800
|
+
n?.saas && this.dataSenders.push(new xe(e, "saas", n.saas, r)), n?.custom && this.dataSenders.push(new xe(e, "custom", n.custom, r)), this.saveSessionCountsDebounced = this.debounce((i) => {
|
|
1773
1801
|
this.saveSessionCounts(i);
|
|
1774
1802
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1775
1803
|
}
|
|
@@ -1907,30 +1935,30 @@ class Yt extends _ {
|
|
|
1907
1935
|
return;
|
|
1908
1936
|
}
|
|
1909
1937
|
this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
|
|
1910
|
-
const
|
|
1911
|
-
if (
|
|
1938
|
+
const p = e === d.SESSION_START;
|
|
1939
|
+
if (p && a("debug", "Processing SESSION_START event", {
|
|
1912
1940
|
data: { sessionId: g }
|
|
1913
|
-
}), !
|
|
1941
|
+
}), !p && !this.checkRateLimit())
|
|
1914
1942
|
return;
|
|
1915
|
-
const
|
|
1916
|
-
if (!
|
|
1943
|
+
const E = e;
|
|
1944
|
+
if (!p) {
|
|
1917
1945
|
if (this.sessionEventCounts.total >= 1e3) {
|
|
1918
1946
|
a("warn", "Session event limit reached", {
|
|
1919
1947
|
data: {
|
|
1920
|
-
type:
|
|
1948
|
+
type: E,
|
|
1921
1949
|
total: this.sessionEventCounts.total,
|
|
1922
1950
|
limit: 1e3
|
|
1923
1951
|
}
|
|
1924
1952
|
});
|
|
1925
1953
|
return;
|
|
1926
1954
|
}
|
|
1927
|
-
const T = this.getTypeLimitForEvent(
|
|
1955
|
+
const T = this.getTypeLimitForEvent(E);
|
|
1928
1956
|
if (T) {
|
|
1929
|
-
const ee = this.sessionEventCounts[
|
|
1957
|
+
const ee = this.sessionEventCounts[E];
|
|
1930
1958
|
if (ee !== void 0 && ee >= T) {
|
|
1931
1959
|
a("warn", "Session event type limit reached", {
|
|
1932
1960
|
data: {
|
|
1933
|
-
type:
|
|
1961
|
+
type: E,
|
|
1934
1962
|
count: ee,
|
|
1935
1963
|
limit: T
|
|
1936
1964
|
}
|
|
@@ -1939,14 +1967,14 @@ class Yt extends _ {
|
|
|
1939
1967
|
}
|
|
1940
1968
|
}
|
|
1941
1969
|
}
|
|
1942
|
-
if (
|
|
1970
|
+
if (E === d.CUSTOM && o?.name) {
|
|
1943
1971
|
const T = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
1944
1972
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1945
1973
|
return;
|
|
1946
1974
|
}
|
|
1947
|
-
const
|
|
1948
|
-
type:
|
|
1949
|
-
page_url:
|
|
1975
|
+
const Te = E === d.SESSION_START, $ = t || this.get("pageUrl"), D = this.buildEventPayload({
|
|
1976
|
+
type: E,
|
|
1977
|
+
page_url: $,
|
|
1950
1978
|
from_page_url: r,
|
|
1951
1979
|
scroll_data: n,
|
|
1952
1980
|
click_data: i,
|
|
@@ -1956,8 +1984,8 @@ class Yt extends _ {
|
|
|
1956
1984
|
viewport_data: u,
|
|
1957
1985
|
page_view: S
|
|
1958
1986
|
});
|
|
1959
|
-
if (D && !(!
|
|
1960
|
-
if (
|
|
1987
|
+
if (D && !(!p && !this.shouldSample())) {
|
|
1988
|
+
if (Te) {
|
|
1961
1989
|
const T = this.get("sessionId");
|
|
1962
1990
|
if (!T) {
|
|
1963
1991
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -1972,8 +2000,8 @@ class Yt extends _ {
|
|
|
1972
2000
|
this.set("hasStartSession", !0);
|
|
1973
2001
|
}
|
|
1974
2002
|
if (!this.isDuplicateEvent(D)) {
|
|
1975
|
-
if (this.get("mode") ===
|
|
1976
|
-
if (
|
|
2003
|
+
if (this.get("mode") === z.QA) {
|
|
2004
|
+
if (E === d.CUSTOM && o) {
|
|
1977
2005
|
a("info", `Custom Event: ${o.name}`, {
|
|
1978
2006
|
visibility: "qa",
|
|
1979
2007
|
data: {
|
|
@@ -1983,7 +2011,7 @@ class Yt extends _ {
|
|
|
1983
2011
|
}), this.emitEvent(D);
|
|
1984
2012
|
return;
|
|
1985
2013
|
}
|
|
1986
|
-
if (
|
|
2014
|
+
if (E === d.VIEWPORT_VISIBLE && u) {
|
|
1987
2015
|
const T = u.name || u.id || u.selector;
|
|
1988
2016
|
a("info", `Viewport Visible: ${T}`, {
|
|
1989
2017
|
visibility: "qa",
|
|
@@ -1998,8 +2026,8 @@ class Yt extends _ {
|
|
|
1998
2026
|
return;
|
|
1999
2027
|
}
|
|
2000
2028
|
}
|
|
2001
|
-
if (this.addToQueue(D), !
|
|
2002
|
-
this.sessionEventCounts.total++, this.sessionEventCounts[
|
|
2029
|
+
if (this.addToQueue(D), !p) {
|
|
2030
|
+
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2003
2031
|
const T = this.get("sessionId");
|
|
2004
2032
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
2005
2033
|
}
|
|
@@ -2315,22 +2343,23 @@ class Yt extends _ {
|
|
|
2315
2343
|
};
|
|
2316
2344
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2317
2345
|
if (!o && l) {
|
|
2318
|
-
const c =
|
|
2346
|
+
const c = Je(n, l, "EventManager");
|
|
2319
2347
|
c !== null && (n = c);
|
|
2320
2348
|
}
|
|
2321
2349
|
return n;
|
|
2322
2350
|
}
|
|
2323
2351
|
buildEventPayload(e) {
|
|
2324
|
-
const t = e.
|
|
2325
|
-
|
|
2326
|
-
data: { type: e.type, error:
|
|
2352
|
+
const t = e.page_url ?? this.get("pageUrl"), r = this.timeManager.now(), n = this.timeManager.validateTimestamp(r);
|
|
2353
|
+
n.valid || a("warn", "Event timestamp validation failed", {
|
|
2354
|
+
data: { type: e.type, error: n.error }
|
|
2327
2355
|
});
|
|
2328
|
-
|
|
2329
|
-
|
|
2356
|
+
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2357
|
+
let l = {
|
|
2358
|
+
id: Ft(),
|
|
2330
2359
|
type: e.type,
|
|
2331
|
-
page_url:
|
|
2332
|
-
timestamp:
|
|
2333
|
-
...
|
|
2360
|
+
page_url: t,
|
|
2361
|
+
timestamp: r,
|
|
2362
|
+
...i && { referrer: i },
|
|
2334
2363
|
...e.from_page_url && { from_page_url: e.from_page_url },
|
|
2335
2364
|
...e.scroll_data && { scroll_data: e.scroll_data },
|
|
2336
2365
|
...e.click_data && { click_data: e.click_data },
|
|
@@ -2339,16 +2368,16 @@ class Yt extends _ {
|
|
|
2339
2368
|
...e.error_data && { error_data: e.error_data },
|
|
2340
2369
|
...e.viewport_data && { viewport_data: e.viewport_data },
|
|
2341
2370
|
...e.page_view && { page_view: e.page_view },
|
|
2342
|
-
...
|
|
2371
|
+
...o && { utm: o }
|
|
2343
2372
|
};
|
|
2344
|
-
const
|
|
2345
|
-
if (E && (!
|
|
2346
|
-
const $ =
|
|
2373
|
+
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2374
|
+
if (E && (!g || u && !p)) {
|
|
2375
|
+
const $ = qe(l, E, "EventManager");
|
|
2347
2376
|
if ($ === null)
|
|
2348
2377
|
return null;
|
|
2349
|
-
|
|
2378
|
+
l = $;
|
|
2350
2379
|
}
|
|
2351
|
-
return
|
|
2380
|
+
return l;
|
|
2352
2381
|
}
|
|
2353
2382
|
isDuplicateEvent(e) {
|
|
2354
2383
|
const t = Date.now(), r = this.createEventFingerprint(e), n = this.recentEventFingerprints.get(r);
|
|
@@ -2508,13 +2537,13 @@ class Yt extends _ {
|
|
|
2508
2537
|
loadSessionCounts(e) {
|
|
2509
2538
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2510
2539
|
return this.getInitialCounts();
|
|
2511
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2540
|
+
const t = this.get("userId") || "anonymous", r = we(t, e);
|
|
2512
2541
|
try {
|
|
2513
2542
|
const n = localStorage.getItem(r);
|
|
2514
2543
|
if (!n)
|
|
2515
2544
|
return this.getInitialCounts();
|
|
2516
2545
|
const i = JSON.parse(n);
|
|
2517
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2546
|
+
return i._timestamp && Date.now() - i._timestamp > ye ? (a("debug", "Session counts expired, clearing", {
|
|
2518
2547
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2519
2548
|
}), localStorage.removeItem(r), this.getInitialCounts()) : typeof i.total == "number" && typeof i[d.CLICK] == "number" && typeof i[d.PAGE_VIEW] == "number" && typeof i[d.CUSTOM] == "number" && typeof i[d.VIEWPORT_VISIBLE] == "number" && typeof i[d.SCROLL] == "number" ? {
|
|
2520
2549
|
total: i.total,
|
|
@@ -2559,12 +2588,12 @@ class Yt extends _ {
|
|
|
2559
2588
|
cleanupExpiredSessionCounts() {
|
|
2560
2589
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2561
2590
|
try {
|
|
2562
|
-
const e = localStorage.getItem(
|
|
2591
|
+
const e = localStorage.getItem(be);
|
|
2563
2592
|
if (e) {
|
|
2564
2593
|
const i = Date.now() - parseInt(e, 10);
|
|
2565
|
-
if (i <
|
|
2594
|
+
if (i < Ae) {
|
|
2566
2595
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2567
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2596
|
+
data: { timeSinceLastCleanup: i, throttleMs: Ae }
|
|
2568
2597
|
});
|
|
2569
2598
|
return;
|
|
2570
2599
|
}
|
|
@@ -2577,14 +2606,14 @@ class Yt extends _ {
|
|
|
2577
2606
|
const l = localStorage.getItem(o);
|
|
2578
2607
|
if (l) {
|
|
2579
2608
|
const c = JSON.parse(l);
|
|
2580
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2609
|
+
c._timestamp && Date.now() - c._timestamp > ye && n.push(o);
|
|
2581
2610
|
}
|
|
2582
2611
|
} catch {
|
|
2583
2612
|
}
|
|
2584
2613
|
}
|
|
2585
2614
|
n.forEach((i) => {
|
|
2586
2615
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2587
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2616
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(be, Date.now().toString());
|
|
2588
2617
|
} catch (e) {
|
|
2589
2618
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2590
2619
|
}
|
|
@@ -2618,7 +2647,7 @@ class Yt extends _ {
|
|
|
2618
2647
|
* @internal
|
|
2619
2648
|
*/
|
|
2620
2649
|
saveSessionCounts(e) {
|
|
2621
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2650
|
+
const t = this.get("userId") || "anonymous", r = we(t, e);
|
|
2622
2651
|
try {
|
|
2623
2652
|
const n = {
|
|
2624
2653
|
...this.sessionEventCounts,
|
|
@@ -2634,7 +2663,7 @@ class Yt extends _ {
|
|
|
2634
2663
|
}
|
|
2635
2664
|
}
|
|
2636
2665
|
}
|
|
2637
|
-
class
|
|
2666
|
+
class tr {
|
|
2638
2667
|
/**
|
|
2639
2668
|
* Gets or creates a unique user ID.
|
|
2640
2669
|
*
|
|
@@ -2652,15 +2681,15 @@ class qt {
|
|
|
2652
2681
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2653
2682
|
*/
|
|
2654
2683
|
static getId(e) {
|
|
2655
|
-
const t = e.getItem(
|
|
2684
|
+
const t = e.getItem(_e);
|
|
2656
2685
|
if (t)
|
|
2657
2686
|
return t;
|
|
2658
|
-
const r =
|
|
2659
|
-
return e.setItem(
|
|
2687
|
+
const r = Ht();
|
|
2688
|
+
return e.setItem(_e, r), r;
|
|
2660
2689
|
}
|
|
2661
2690
|
}
|
|
2662
|
-
const
|
|
2663
|
-
class
|
|
2691
|
+
const rr = /^\d{13}-[a-z0-9]{9}$/;
|
|
2692
|
+
class sr extends _ {
|
|
2664
2693
|
storageManager;
|
|
2665
2694
|
eventManager;
|
|
2666
2695
|
projectId;
|
|
@@ -2685,7 +2714,7 @@ class Zt extends _ {
|
|
|
2685
2714
|
return;
|
|
2686
2715
|
}
|
|
2687
2716
|
const e = this.getProjectId();
|
|
2688
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2717
|
+
this.broadcastChannel = new BroadcastChannel(ht(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2689
2718
|
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2690
2719
|
o === e && (r === "session_start" && n && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", n), this.persistSession(n, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2691
2720
|
};
|
|
@@ -2705,17 +2734,19 @@ class Zt extends _ {
|
|
|
2705
2734
|
const e = this.loadStoredSession();
|
|
2706
2735
|
if (!e)
|
|
2707
2736
|
return null;
|
|
2708
|
-
if (!
|
|
2737
|
+
if (!rr.test(e.id))
|
|
2709
2738
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2710
2739
|
data: { sessionId: e.id }
|
|
2711
2740
|
}), this.clearStoredSession(), null;
|
|
2712
2741
|
const t = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2713
2742
|
return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
|
|
2714
2743
|
}
|
|
2715
|
-
persistSession(e, t = Date.now()) {
|
|
2744
|
+
persistSession(e, t = Date.now(), r, n) {
|
|
2716
2745
|
this.saveStoredSession({
|
|
2717
2746
|
id: e,
|
|
2718
|
-
lastActivity: t
|
|
2747
|
+
lastActivity: t,
|
|
2748
|
+
...r && { referrer: r },
|
|
2749
|
+
...n && { utm: n }
|
|
2719
2750
|
});
|
|
2720
2751
|
}
|
|
2721
2752
|
clearStoredSession() {
|
|
@@ -2738,7 +2769,7 @@ class Zt extends _ {
|
|
|
2738
2769
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2739
2770
|
}
|
|
2740
2771
|
getSessionStorageKey() {
|
|
2741
|
-
return
|
|
2772
|
+
return dt(this.getProjectId());
|
|
2742
2773
|
}
|
|
2743
2774
|
getProjectId() {
|
|
2744
2775
|
return this.projectId;
|
|
@@ -2800,21 +2831,29 @@ class Zt extends _ {
|
|
|
2800
2831
|
return;
|
|
2801
2832
|
}
|
|
2802
2833
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
2834
|
+
let r, n;
|
|
2835
|
+
if (e) {
|
|
2836
|
+
const i = this.loadStoredSession();
|
|
2837
|
+
r = i?.referrer ?? De(), n = i?.utm ?? Ve();
|
|
2838
|
+
} else
|
|
2839
|
+
r = De(), n = Ve();
|
|
2803
2840
|
a("debug", "Session tracking initialized", {
|
|
2804
2841
|
data: {
|
|
2805
2842
|
sessionId: t,
|
|
2806
2843
|
wasRecovered: !!e,
|
|
2807
|
-
willEmitSessionStart: !0
|
|
2844
|
+
willEmitSessionStart: !0,
|
|
2845
|
+
sessionReferrer: r,
|
|
2846
|
+
hasUtm: !!n
|
|
2808
2847
|
}
|
|
2809
2848
|
}), this.isTracking = !0;
|
|
2810
2849
|
try {
|
|
2811
|
-
this.set("sessionId", t), this.persistSession(t), this.initCrossTabSync(), this.shareSession(t), a("debug", "Emitting SESSION_START event", {
|
|
2850
|
+
this.set("sessionId", t), this.set("sessionReferrer", r), this.set("sessionUtm", n), this.persistSession(t, Date.now(), r, n), this.initCrossTabSync(), this.shareSession(t), a("debug", "Emitting SESSION_START event", {
|
|
2812
2851
|
data: { sessionId: t }
|
|
2813
2852
|
}), this.eventManager.track({
|
|
2814
2853
|
type: d.SESSION_START
|
|
2815
2854
|
}), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2816
|
-
} catch (
|
|
2817
|
-
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null),
|
|
2855
|
+
} catch (i) {
|
|
2856
|
+
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
|
|
2818
2857
|
}
|
|
2819
2858
|
}
|
|
2820
2859
|
generateSessionId() {
|
|
@@ -2830,7 +2869,7 @@ class Zt extends _ {
|
|
|
2830
2869
|
resetSessionTimeout() {
|
|
2831
2870
|
this.setupSessionTimeout();
|
|
2832
2871
|
const e = this.get("sessionId");
|
|
2833
|
-
e && this.persistSession(e);
|
|
2872
|
+
e && this.persistSession(e, Date.now(), this.get("sessionReferrer"), this.get("sessionUtm"));
|
|
2834
2873
|
}
|
|
2835
2874
|
clearSessionTimeout() {
|
|
2836
2875
|
this.sessionTimeoutId && (clearTimeout(this.sessionTimeoutId), this.sessionTimeoutId = null);
|
|
@@ -2852,7 +2891,7 @@ class Zt extends _ {
|
|
|
2852
2891
|
this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null);
|
|
2853
2892
|
}
|
|
2854
2893
|
resetSessionState() {
|
|
2855
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.isTracking = !1;
|
|
2894
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.isTracking = !1;
|
|
2856
2895
|
}
|
|
2857
2896
|
/**
|
|
2858
2897
|
* Stops session tracking and cleans up all resources.
|
|
@@ -2921,7 +2960,7 @@ class Zt extends _ {
|
|
|
2921
2960
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
2922
2961
|
}
|
|
2923
2962
|
}
|
|
2924
|
-
class
|
|
2963
|
+
class nr extends _ {
|
|
2925
2964
|
eventManager;
|
|
2926
2965
|
storageManager;
|
|
2927
2966
|
sessionManager = null;
|
|
@@ -2956,7 +2995,7 @@ class er extends _ {
|
|
|
2956
2995
|
}
|
|
2957
2996
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2958
2997
|
try {
|
|
2959
|
-
this.sessionManager = new
|
|
2998
|
+
this.sessionManager = new sr(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2960
2999
|
} catch (r) {
|
|
2961
3000
|
if (this.sessionManager) {
|
|
2962
3001
|
try {
|
|
@@ -3009,7 +3048,7 @@ class er extends _ {
|
|
|
3009
3048
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3010
3049
|
}
|
|
3011
3050
|
}
|
|
3012
|
-
class
|
|
3051
|
+
class ir extends _ {
|
|
3013
3052
|
eventManager;
|
|
3014
3053
|
onTrack;
|
|
3015
3054
|
originalPushState;
|
|
@@ -3085,7 +3124,7 @@ class tr extends _ {
|
|
|
3085
3124
|
};
|
|
3086
3125
|
}
|
|
3087
3126
|
}
|
|
3088
|
-
class
|
|
3127
|
+
class or extends _ {
|
|
3089
3128
|
eventManager;
|
|
3090
3129
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3091
3130
|
clickHandler;
|
|
@@ -3223,7 +3262,7 @@ class rr extends _ {
|
|
|
3223
3262
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3224
3263
|
}
|
|
3225
3264
|
getRelevantClickElement(e) {
|
|
3226
|
-
for (const t of
|
|
3265
|
+
for (const t of ot)
|
|
3227
3266
|
try {
|
|
3228
3267
|
if (e.matches(t))
|
|
3229
3268
|
return e;
|
|
@@ -3303,7 +3342,7 @@ class rr extends _ {
|
|
|
3303
3342
|
*/
|
|
3304
3343
|
sanitizeText(e) {
|
|
3305
3344
|
let t = e;
|
|
3306
|
-
for (const r of
|
|
3345
|
+
for (const r of Xe) {
|
|
3307
3346
|
const n = new RegExp(r.source, r.flags);
|
|
3308
3347
|
t = t.replace(n, "[REDACTED]");
|
|
3309
3348
|
}
|
|
@@ -3342,7 +3381,7 @@ class rr extends _ {
|
|
|
3342
3381
|
};
|
|
3343
3382
|
}
|
|
3344
3383
|
}
|
|
3345
|
-
class
|
|
3384
|
+
class ar extends _ {
|
|
3346
3385
|
eventManager;
|
|
3347
3386
|
containers = [];
|
|
3348
3387
|
limitWarningLogged = !1;
|
|
@@ -3527,13 +3566,13 @@ class sr extends _ {
|
|
|
3527
3566
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3528
3567
|
return null;
|
|
3529
3568
|
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), S = this.getScrollDirection(i, r), g = this.calculateScrollDepth(i, u, c);
|
|
3530
|
-
let
|
|
3531
|
-
n > 0 ?
|
|
3532
|
-
const
|
|
3569
|
+
let p;
|
|
3570
|
+
n > 0 ? p = o - n : e.firstScrollEventTime !== null ? p = o - e.firstScrollEventTime : p = 250;
|
|
3571
|
+
const E = Math.round(l / p * 1e3);
|
|
3533
3572
|
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3534
3573
|
depth: g,
|
|
3535
3574
|
direction: S,
|
|
3536
|
-
velocity:
|
|
3575
|
+
velocity: E,
|
|
3537
3576
|
max_depth_reached: e.maxDepthReached
|
|
3538
3577
|
};
|
|
3539
3578
|
}
|
|
@@ -3570,7 +3609,7 @@ class sr extends _ {
|
|
|
3570
3609
|
e.isPrimary = t;
|
|
3571
3610
|
}
|
|
3572
3611
|
}
|
|
3573
|
-
class
|
|
3612
|
+
class lr extends _ {
|
|
3574
3613
|
eventManager;
|
|
3575
3614
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3576
3615
|
observer = null;
|
|
@@ -3731,7 +3770,7 @@ class nr extends _ {
|
|
|
3731
3770
|
});
|
|
3732
3771
|
}
|
|
3733
3772
|
}
|
|
3734
|
-
class
|
|
3773
|
+
class cr {
|
|
3735
3774
|
storage;
|
|
3736
3775
|
sessionStorageRef;
|
|
3737
3776
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4014,7 +4053,7 @@ class ir {
|
|
|
4014
4053
|
this.fallbackSessionStorage.delete(e);
|
|
4015
4054
|
}
|
|
4016
4055
|
}
|
|
4017
|
-
class
|
|
4056
|
+
class ur extends _ {
|
|
4018
4057
|
eventManager;
|
|
4019
4058
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4020
4059
|
navigationHistory = [];
|
|
@@ -4025,7 +4064,7 @@ class or extends _ {
|
|
|
4025
4064
|
navigationCounter = 0;
|
|
4026
4065
|
// Counter for handling simultaneous navigations edge case
|
|
4027
4066
|
constructor(e) {
|
|
4028
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4067
|
+
super(), this.eventManager = e, this.vitalThresholds = Oe(ae);
|
|
4029
4068
|
}
|
|
4030
4069
|
/**
|
|
4031
4070
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4043,7 +4082,7 @@ class or extends _ {
|
|
|
4043
4082
|
*/
|
|
4044
4083
|
async startTracking() {
|
|
4045
4084
|
const e = this.get("config"), t = e?.webVitalsMode ?? ae;
|
|
4046
|
-
this.vitalThresholds =
|
|
4085
|
+
this.vitalThresholds = Oe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4047
4086
|
}
|
|
4048
4087
|
/**
|
|
4049
4088
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4113,7 +4152,7 @@ class or extends _ {
|
|
|
4113
4152
|
}
|
|
4114
4153
|
async initWebVitals() {
|
|
4115
4154
|
try {
|
|
4116
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4155
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => Vr), o = (l) => (c) => {
|
|
4117
4156
|
const u = Number(c.value.toFixed(2));
|
|
4118
4157
|
this.sendVital({ type: l, value: u });
|
|
4119
4158
|
};
|
|
@@ -4140,7 +4179,7 @@ class or extends _ {
|
|
|
4140
4179
|
const t = e.getEntries();
|
|
4141
4180
|
for (const r of t) {
|
|
4142
4181
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4143
|
-
i - this.lastLongTaskSentAt >=
|
|
4182
|
+
i - this.lastLongTaskSentAt >= Rt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4144
4183
|
}
|
|
4145
4184
|
},
|
|
4146
4185
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4156,7 +4195,7 @@ class or extends _ {
|
|
|
4156
4195
|
return;
|
|
4157
4196
|
if (r)
|
|
4158
4197
|
r.add(e.type);
|
|
4159
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4198
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Nt) {
|
|
4160
4199
|
const i = this.navigationHistory.shift();
|
|
4161
4200
|
i && this.reportedByNav.delete(i);
|
|
4162
4201
|
}
|
|
@@ -4247,7 +4286,7 @@ class or extends _ {
|
|
|
4247
4286
|
return !(typeof r == "number" && t <= r);
|
|
4248
4287
|
}
|
|
4249
4288
|
}
|
|
4250
|
-
class
|
|
4289
|
+
class dr extends _ {
|
|
4251
4290
|
eventManager;
|
|
4252
4291
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4253
4292
|
errorBurstCounter = 0;
|
|
@@ -4283,14 +4322,14 @@ class ar extends _ {
|
|
|
4283
4322
|
const e = Date.now();
|
|
4284
4323
|
if (e < this.burstBackoffUntil)
|
|
4285
4324
|
return !1;
|
|
4286
|
-
if (e - this.burstWindowStart >
|
|
4287
|
-
return this.burstBackoffUntil = e +
|
|
4325
|
+
if (e - this.burstWindowStart > At && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Lt)
|
|
4326
|
+
return this.burstBackoffUntil = e + Re, a("debug", "Error burst detected - entering cooldown", {
|
|
4288
4327
|
data: {
|
|
4289
4328
|
errorsInWindow: this.errorBurstCounter,
|
|
4290
|
-
cooldownMs:
|
|
4329
|
+
cooldownMs: Re
|
|
4291
4330
|
}
|
|
4292
4331
|
}), !1;
|
|
4293
|
-
const r = this.get("config")?.errorSampling ??
|
|
4332
|
+
const r = this.get("config")?.errorSampling ?? Qe;
|
|
4294
4333
|
return Math.random() < r;
|
|
4295
4334
|
}
|
|
4296
4335
|
handleError = (e) => {
|
|
@@ -4334,8 +4373,8 @@ class ar extends _ {
|
|
|
4334
4373
|
}
|
|
4335
4374
|
}
|
|
4336
4375
|
sanitize(e) {
|
|
4337
|
-
let t = e.length >
|
|
4338
|
-
for (const r of
|
|
4376
|
+
let t = e.length > Me ? e.slice(0, Me) + "..." : e;
|
|
4377
|
+
for (const r of Xe) {
|
|
4339
4378
|
const n = new RegExp(r.source, r.flags);
|
|
4340
4379
|
t = t.replace(n, "[REDACTED]");
|
|
4341
4380
|
}
|
|
@@ -4343,12 +4382,12 @@ class ar extends _ {
|
|
|
4343
4382
|
}
|
|
4344
4383
|
shouldSuppressError(e, t) {
|
|
4345
4384
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4346
|
-
return i && r - i <
|
|
4385
|
+
return i && r - i < Ce ? (this.recentErrors.set(n, r), !0) : (this.recentErrors.set(n, r), this.recentErrors.size > bt ? (this.recentErrors.clear(), this.recentErrors.set(n, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4347
4386
|
}
|
|
4348
4387
|
pruneOldErrors() {
|
|
4349
4388
|
const e = Date.now();
|
|
4350
4389
|
for (const [n, i] of this.recentErrors.entries())
|
|
4351
|
-
e - i >
|
|
4390
|
+
e - i > Ce && this.recentErrors.delete(n);
|
|
4352
4391
|
if (this.recentErrors.size <= Q)
|
|
4353
4392
|
return;
|
|
4354
4393
|
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - Q;
|
|
@@ -4358,10 +4397,10 @@ class ar extends _ {
|
|
|
4358
4397
|
}
|
|
4359
4398
|
}
|
|
4360
4399
|
}
|
|
4361
|
-
class
|
|
4400
|
+
class hr extends _ {
|
|
4362
4401
|
isInitialized = !1;
|
|
4363
4402
|
suppressNextScrollTimer = null;
|
|
4364
|
-
emitter = new
|
|
4403
|
+
emitter = new qt();
|
|
4365
4404
|
transformers = {};
|
|
4366
4405
|
managers = {};
|
|
4367
4406
|
handlers = {};
|
|
@@ -4377,9 +4416,9 @@ class lr extends _ {
|
|
|
4377
4416
|
*/
|
|
4378
4417
|
async init(e = {}) {
|
|
4379
4418
|
if (!this.isInitialized) {
|
|
4380
|
-
this.managers.storage = new
|
|
4419
|
+
this.managers.storage = new cr();
|
|
4381
4420
|
try {
|
|
4382
|
-
this.setupState(e), this.managers.event = new
|
|
4421
|
+
this.setupState(e), this.managers.event = new er(this.managers.storage, this.emitter, this.transformers), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
4383
4422
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
4384
4423
|
}), this.isInitialized = !0;
|
|
4385
4424
|
} catch (t) {
|
|
@@ -4403,9 +4442,9 @@ class lr extends _ {
|
|
|
4403
4442
|
}
|
|
4404
4443
|
let r = t;
|
|
4405
4444
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4406
|
-
const { valid: n, error: i, sanitizedMetadata: o } =
|
|
4445
|
+
const { valid: n, error: i, sanitizedMetadata: o } = Yt(e, r);
|
|
4407
4446
|
if (!n) {
|
|
4408
|
-
if (this.get("mode") ===
|
|
4447
|
+
if (this.get("mode") === z.QA)
|
|
4409
4448
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4410
4449
|
return;
|
|
4411
4450
|
}
|
|
@@ -4451,14 +4490,14 @@ class lr extends _ {
|
|
|
4451
4490
|
}
|
|
4452
4491
|
setupState(e = {}) {
|
|
4453
4492
|
this.set("config", e);
|
|
4454
|
-
const t =
|
|
4493
|
+
const t = tr.getId(this.managers.storage);
|
|
4455
4494
|
this.set("userId", t);
|
|
4456
|
-
const r =
|
|
4495
|
+
const r = Bt(e);
|
|
4457
4496
|
this.set("collectApiUrls", r);
|
|
4458
|
-
const n =
|
|
4497
|
+
const n = yt();
|
|
4459
4498
|
this.set("device", n);
|
|
4460
4499
|
const i = le(window.location.href, e.sensitiveQueryParams);
|
|
4461
|
-
this.set("pageUrl", i),
|
|
4500
|
+
this.set("pageUrl", i), Vt() && this.set("mode", z.QA);
|
|
4462
4501
|
}
|
|
4463
4502
|
/**
|
|
4464
4503
|
* Returns the current configuration object.
|
|
@@ -4500,7 +4539,7 @@ class lr extends _ {
|
|
|
4500
4539
|
valid: !1,
|
|
4501
4540
|
error: "Global metadata must be a plain object"
|
|
4502
4541
|
};
|
|
4503
|
-
const t =
|
|
4542
|
+
const t = Ye("Global", e, "globalMetadata");
|
|
4504
4543
|
return t.valid ? { valid: !0 } : {
|
|
4505
4544
|
valid: !1,
|
|
4506
4545
|
error: t.error
|
|
@@ -4545,7 +4584,7 @@ class lr extends _ {
|
|
|
4545
4584
|
}
|
|
4546
4585
|
initializeHandlers() {
|
|
4547
4586
|
const e = this.get("config");
|
|
4548
|
-
this.handlers.session = new
|
|
4587
|
+
this.handlers.session = new nr(
|
|
4549
4588
|
this.managers.storage,
|
|
4550
4589
|
this.managers.event
|
|
4551
4590
|
), this.handlers.session.startTracking();
|
|
@@ -4554,18 +4593,18 @@ class lr extends _ {
|
|
|
4554
4593
|
this.set("suppressNextScroll", !1);
|
|
4555
4594
|
}, 500);
|
|
4556
4595
|
};
|
|
4557
|
-
this.handlers.pageView = new
|
|
4596
|
+
this.handlers.pageView = new ir(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new or(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new ar(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new ur(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4558
4597
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4559
|
-
}), this.handlers.error = new
|
|
4598
|
+
}), this.handlers.error = new dr(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new lr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4560
4599
|
}
|
|
4561
4600
|
}
|
|
4562
4601
|
const R = [], M = [];
|
|
4563
4602
|
let f = null, C = !1, v = !1;
|
|
4564
|
-
const
|
|
4603
|
+
const fr = async (s) => {
|
|
4565
4604
|
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !C)) {
|
|
4566
4605
|
C = !0;
|
|
4567
4606
|
try {
|
|
4568
|
-
const e =
|
|
4607
|
+
const e = jt(s ?? {}), t = new hr();
|
|
4569
4608
|
try {
|
|
4570
4609
|
R.forEach(({ event: i, callback: o }) => {
|
|
4571
4610
|
t.on(i, o);
|
|
@@ -4592,7 +4631,7 @@ const cr = async (s) => {
|
|
|
4592
4631
|
C = !1;
|
|
4593
4632
|
}
|
|
4594
4633
|
}
|
|
4595
|
-
},
|
|
4634
|
+
}, mr = (s, e) => {
|
|
4596
4635
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4597
4636
|
if (!f)
|
|
4598
4637
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4600,7 +4639,7 @@ const cr = async (s) => {
|
|
|
4600
4639
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4601
4640
|
f.sendCustomEvent(s, e);
|
|
4602
4641
|
}
|
|
4603
|
-
},
|
|
4642
|
+
}, gr = (s, e) => {
|
|
4604
4643
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4605
4644
|
if (!f || C) {
|
|
4606
4645
|
R.push({ event: s, callback: e });
|
|
@@ -4608,7 +4647,7 @@ const cr = async (s) => {
|
|
|
4608
4647
|
}
|
|
4609
4648
|
f.on(s, e);
|
|
4610
4649
|
}
|
|
4611
|
-
},
|
|
4650
|
+
}, Er = (s, e) => {
|
|
4612
4651
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4613
4652
|
if (!f) {
|
|
4614
4653
|
const t = R.findIndex((r) => r.event === s && r.callback === e);
|
|
@@ -4618,7 +4657,7 @@ const cr = async (s) => {
|
|
|
4618
4657
|
f.off(s, e);
|
|
4619
4658
|
}
|
|
4620
4659
|
};
|
|
4621
|
-
function
|
|
4660
|
+
function Sr(s, e) {
|
|
4622
4661
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4623
4662
|
if (typeof e != "function")
|
|
4624
4663
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
@@ -4632,7 +4671,7 @@ function fr(s, e) {
|
|
|
4632
4671
|
s === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4633
4672
|
}
|
|
4634
4673
|
}
|
|
4635
|
-
const
|
|
4674
|
+
const pr = (s) => {
|
|
4636
4675
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4637
4676
|
if (!f) {
|
|
4638
4677
|
const e = M.findIndex((t) => t.hook === s);
|
|
@@ -4643,7 +4682,7 @@ const mr = (s) => {
|
|
|
4643
4682
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4644
4683
|
f.removeTransformer(s);
|
|
4645
4684
|
}
|
|
4646
|
-
},
|
|
4685
|
+
}, Tr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, _r = () => {
|
|
4647
4686
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4648
4687
|
if (v)
|
|
4649
4688
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4658,9 +4697,9 @@ const mr = (s) => {
|
|
|
4658
4697
|
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4659
4698
|
}
|
|
4660
4699
|
}
|
|
4661
|
-
},
|
|
4662
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4663
|
-
},
|
|
4700
|
+
}, vr = (s) => {
|
|
4701
|
+
typeof window > "u" || typeof document > "u" || kt(s);
|
|
4702
|
+
}, Ir = (s) => {
|
|
4664
4703
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4665
4704
|
if (!f)
|
|
4666
4705
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4668,7 +4707,7 @@ const mr = (s) => {
|
|
|
4668
4707
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4669
4708
|
f.updateGlobalMetadata(s);
|
|
4670
4709
|
}
|
|
4671
|
-
},
|
|
4710
|
+
}, wr = (s) => {
|
|
4672
4711
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4673
4712
|
if (!f)
|
|
4674
4713
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4676,22 +4715,22 @@ const mr = (s) => {
|
|
|
4676
4715
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4677
4716
|
f.mergeGlobalMetadata(s);
|
|
4678
4717
|
}
|
|
4679
|
-
},
|
|
4680
|
-
init:
|
|
4681
|
-
event:
|
|
4682
|
-
on:
|
|
4683
|
-
off:
|
|
4684
|
-
setTransformer:
|
|
4685
|
-
removeTransformer:
|
|
4686
|
-
isInitialized:
|
|
4687
|
-
destroy:
|
|
4688
|
-
setQaMode:
|
|
4689
|
-
updateGlobalMetadata:
|
|
4690
|
-
mergeGlobalMetadata:
|
|
4718
|
+
}, Yr = {
|
|
4719
|
+
init: fr,
|
|
4720
|
+
event: mr,
|
|
4721
|
+
on: gr,
|
|
4722
|
+
off: Er,
|
|
4723
|
+
setTransformer: Sr,
|
|
4724
|
+
removeTransformer: pr,
|
|
4725
|
+
isInitialized: Tr,
|
|
4726
|
+
destroy: _r,
|
|
4727
|
+
setQaMode: vr,
|
|
4728
|
+
updateGlobalMetadata: Ir,
|
|
4729
|
+
mergeGlobalMetadata: wr
|
|
4691
4730
|
};
|
|
4692
|
-
var ue,
|
|
4731
|
+
var ue, Ze = -1, P = function(s) {
|
|
4693
4732
|
addEventListener("pageshow", (function(e) {
|
|
4694
|
-
e.persisted && (
|
|
4733
|
+
e.persisted && (Ze = e.timeStamp, s(e));
|
|
4695
4734
|
}), !0);
|
|
4696
4735
|
}, Ee = function() {
|
|
4697
4736
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
@@ -4701,7 +4740,7 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4701
4740
|
return s && s.activationStart || 0;
|
|
4702
4741
|
}, b = function(s, e) {
|
|
4703
4742
|
var t = Ee(), r = "navigate";
|
|
4704
|
-
return
|
|
4743
|
+
return Ze >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: s, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: r };
|
|
4705
4744
|
}, F = function(s, e, t) {
|
|
4706
4745
|
try {
|
|
4707
4746
|
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
@@ -4736,18 +4775,18 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4736
4775
|
return function() {
|
|
4737
4776
|
e || (s(), e = !0);
|
|
4738
4777
|
};
|
|
4739
|
-
}, O = -1,
|
|
4778
|
+
}, O = -1, He = function() {
|
|
4740
4779
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4741
4780
|
}, Y = function(s) {
|
|
4742
|
-
document.visibilityState === "hidden" && O > -1 && (O = s.type === "visibilitychange" ? s.timeStamp : 0,
|
|
4743
|
-
},
|
|
4781
|
+
document.visibilityState === "hidden" && O > -1 && (O = s.type === "visibilitychange" ? s.timeStamp : 0, yr());
|
|
4782
|
+
}, Fe = function() {
|
|
4744
4783
|
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4745
|
-
},
|
|
4784
|
+
}, yr = function() {
|
|
4746
4785
|
removeEventListener("visibilitychange", Y, !0), removeEventListener("prerenderingchange", Y, !0);
|
|
4747
|
-
},
|
|
4748
|
-
return O < 0 && (O =
|
|
4786
|
+
}, et = function() {
|
|
4787
|
+
return O < 0 && (O = He(), Fe(), P((function() {
|
|
4749
4788
|
setTimeout((function() {
|
|
4750
|
-
O =
|
|
4789
|
+
O = He(), Fe();
|
|
4751
4790
|
}), 0);
|
|
4752
4791
|
}))), { get firstHiddenTime() {
|
|
4753
4792
|
return O;
|
|
@@ -4756,9 +4795,9 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4756
4795
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4757
4796
|
return s();
|
|
4758
4797
|
}), !0) : s();
|
|
4759
|
-
}, de = [1800, 3e3],
|
|
4798
|
+
}, de = [1800, 3e3], tt = function(s, e) {
|
|
4760
4799
|
e = e || {}, Z((function() {
|
|
4761
|
-
var t, r =
|
|
4800
|
+
var t, r = et(), n = b("FCP"), i = F("paint", (function(o) {
|
|
4762
4801
|
o.forEach((function(l) {
|
|
4763
4802
|
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime - q(), 0), n.entries.push(l), t(!0)));
|
|
4764
4803
|
}));
|
|
@@ -4769,8 +4808,8 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4769
4808
|
}));
|
|
4770
4809
|
})));
|
|
4771
4810
|
}));
|
|
4772
|
-
}, he = [0.1, 0.25],
|
|
4773
|
-
e = e || {},
|
|
4811
|
+
}, he = [0.1, 0.25], br = function(s, e) {
|
|
4812
|
+
e = e || {}, tt(pe((function() {
|
|
4774
4813
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4775
4814
|
c.forEach((function(u) {
|
|
4776
4815
|
if (!u.hadRecentInput) {
|
|
@@ -4787,58 +4826,58 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4787
4826
|
}));
|
|
4788
4827
|
})), setTimeout(t, 0));
|
|
4789
4828
|
})));
|
|
4790
|
-
},
|
|
4829
|
+
}, rt = 0, re = 1 / 0, G = 0, Ar = function(s) {
|
|
4791
4830
|
s.forEach((function(e) {
|
|
4792
|
-
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId),
|
|
4831
|
+
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId), rt = G ? (G - re) / 7 + 1 : 0);
|
|
4793
4832
|
}));
|
|
4794
|
-
},
|
|
4795
|
-
return ue ?
|
|
4796
|
-
},
|
|
4797
|
-
"interactionCount" in performance || ue || (ue = F("event",
|
|
4798
|
-
}, y = [],
|
|
4799
|
-
var s = Math.min(y.length - 1, Math.floor((
|
|
4833
|
+
}, st = function() {
|
|
4834
|
+
return ue ? rt : performance.interactionCount || 0;
|
|
4835
|
+
}, Lr = function() {
|
|
4836
|
+
"interactionCount" in performance || ue || (ue = F("event", Ar, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4837
|
+
}, y = [], j = /* @__PURE__ */ new Map(), nt = 0, Mr = function() {
|
|
4838
|
+
var s = Math.min(y.length - 1, Math.floor((st() - nt) / 50));
|
|
4800
4839
|
return y[s];
|
|
4801
|
-
},
|
|
4802
|
-
if (
|
|
4840
|
+
}, Cr = [], Rr = function(s) {
|
|
4841
|
+
if (Cr.forEach((function(n) {
|
|
4803
4842
|
return n(s);
|
|
4804
4843
|
})), s.interactionId || s.entryType === "first-input") {
|
|
4805
|
-
var e = y[y.length - 1], t =
|
|
4844
|
+
var e = y[y.length - 1], t = j.get(s.interactionId);
|
|
4806
4845
|
if (t || y.length < 10 || s.duration > e.latency) {
|
|
4807
4846
|
if (t) s.duration > t.latency ? (t.entries = [s], t.latency = s.duration) : s.duration === t.latency && s.startTime === t.entries[0].startTime && t.entries.push(s);
|
|
4808
4847
|
else {
|
|
4809
4848
|
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
4810
|
-
|
|
4849
|
+
j.set(r.id, r), y.push(r);
|
|
4811
4850
|
}
|
|
4812
4851
|
y.sort((function(n, i) {
|
|
4813
4852
|
return i.latency - n.latency;
|
|
4814
4853
|
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
4815
|
-
return
|
|
4854
|
+
return j.delete(n.id);
|
|
4816
4855
|
}));
|
|
4817
4856
|
}
|
|
4818
4857
|
}
|
|
4819
|
-
},
|
|
4858
|
+
}, it = function(s) {
|
|
4820
4859
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4821
4860
|
return s = pe(s), document.visibilityState === "hidden" ? s() : (t = e(s), J(s)), t;
|
|
4822
|
-
}, fe = [200, 500],
|
|
4861
|
+
}, fe = [200, 500], Nr = function(s, e) {
|
|
4823
4862
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4824
4863
|
var t;
|
|
4825
|
-
|
|
4864
|
+
Lr();
|
|
4826
4865
|
var r, n = b("INP"), i = function(l) {
|
|
4827
|
-
|
|
4828
|
-
l.forEach(
|
|
4829
|
-
var c =
|
|
4866
|
+
it((function() {
|
|
4867
|
+
l.forEach(Rr);
|
|
4868
|
+
var c = Mr();
|
|
4830
4869
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
4831
4870
|
}));
|
|
4832
4871
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4833
4872
|
r = A(s, n, fe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4834
4873
|
i(o.takeRecords()), r(!0);
|
|
4835
4874
|
})), P((function() {
|
|
4836
|
-
|
|
4875
|
+
nt = st(), y.length = 0, j.clear(), n = b("INP"), r = A(s, n, fe, e.reportAllChanges);
|
|
4837
4876
|
})));
|
|
4838
4877
|
})));
|
|
4839
|
-
}, me = [2500, 4e3], se = {},
|
|
4878
|
+
}, me = [2500, 4e3], se = {}, Or = function(s, e) {
|
|
4840
4879
|
e = e || {}, Z((function() {
|
|
4841
|
-
var t, r =
|
|
4880
|
+
var t, r = et(), n = b("LCP"), i = function(c) {
|
|
4842
4881
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4843
4882
|
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - q(), 0), n.entries = [u], t());
|
|
4844
4883
|
}));
|
|
@@ -4850,7 +4889,7 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4850
4889
|
}));
|
|
4851
4890
|
["keydown", "click"].forEach((function(c) {
|
|
4852
4891
|
addEventListener(c, (function() {
|
|
4853
|
-
return
|
|
4892
|
+
return it(l);
|
|
4854
4893
|
}), { once: !0, capture: !0 });
|
|
4855
4894
|
})), J(l), P((function(c) {
|
|
4856
4895
|
n = b("LCP"), t = A(s, n, me, e.reportAllChanges), Se((function() {
|
|
@@ -4859,67 +4898,67 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4859
4898
|
}));
|
|
4860
4899
|
}
|
|
4861
4900
|
}));
|
|
4862
|
-
}, ge = [800, 1800],
|
|
4901
|
+
}, ge = [800, 1800], Pr = function s(e) {
|
|
4863
4902
|
document.prerendering ? Z((function() {
|
|
4864
4903
|
return s(e);
|
|
4865
4904
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4866
4905
|
return s(e);
|
|
4867
4906
|
}), !0) : setTimeout(e, 0);
|
|
4868
|
-
},
|
|
4907
|
+
}, Dr = function(s, e) {
|
|
4869
4908
|
e = e || {};
|
|
4870
4909
|
var t = b("TTFB"), r = A(s, t, ge, e.reportAllChanges);
|
|
4871
|
-
|
|
4910
|
+
Pr((function() {
|
|
4872
4911
|
var n = Ee();
|
|
4873
4912
|
n && (t.value = Math.max(n.responseStart - q(), 0), t.entries = [n], r(!0), P((function() {
|
|
4874
4913
|
t = b("TTFB", 0), (r = A(s, t, ge, e.reportAllChanges))(!0);
|
|
4875
4914
|
})));
|
|
4876
4915
|
}));
|
|
4877
4916
|
};
|
|
4878
|
-
const
|
|
4917
|
+
const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4879
4918
|
__proto__: null,
|
|
4880
4919
|
CLSThresholds: he,
|
|
4881
4920
|
FCPThresholds: de,
|
|
4882
4921
|
INPThresholds: fe,
|
|
4883
4922
|
LCPThresholds: me,
|
|
4884
4923
|
TTFBThresholds: ge,
|
|
4885
|
-
onCLS:
|
|
4886
|
-
onFCP:
|
|
4887
|
-
onINP:
|
|
4888
|
-
onLCP:
|
|
4889
|
-
onTTFB:
|
|
4924
|
+
onCLS: br,
|
|
4925
|
+
onFCP: tt,
|
|
4926
|
+
onINP: Nr,
|
|
4927
|
+
onLCP: Or,
|
|
4928
|
+
onTTFB: Dr
|
|
4890
4929
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4891
4930
|
export {
|
|
4892
4931
|
h as AppConfigValidationError,
|
|
4893
|
-
|
|
4932
|
+
kr as DEFAULT_SESSION_TIMEOUT,
|
|
4894
4933
|
ae as DEFAULT_WEB_VITALS_MODE,
|
|
4895
4934
|
L as DeviceType,
|
|
4896
4935
|
ne as EmitterEvent,
|
|
4897
4936
|
U as ErrorType,
|
|
4898
4937
|
d as EventType,
|
|
4899
|
-
|
|
4938
|
+
zr as InitializationTimeoutError,
|
|
4900
4939
|
V as IntegrationValidationError,
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4940
|
+
Xr as MAX_ARRAY_LENGTH,
|
|
4941
|
+
Fr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4942
|
+
Hr as MAX_CUSTOM_EVENT_KEYS,
|
|
4943
|
+
Ur as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4944
|
+
xr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4945
|
+
Br as MAX_METADATA_NESTING_DEPTH,
|
|
4946
|
+
$r as MAX_NESTED_OBJECT_KEYS,
|
|
4947
|
+
Wr as MAX_STRING_LENGTH,
|
|
4948
|
+
Gr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4949
|
+
z as Mode,
|
|
4950
|
+
Xe as PII_PATTERNS,
|
|
4912
4951
|
N as PermanentError,
|
|
4913
|
-
|
|
4952
|
+
Le as SamplingRateValidationError,
|
|
4914
4953
|
X as ScrollDirection,
|
|
4915
|
-
|
|
4954
|
+
ft as SessionTimeoutValidationError,
|
|
4916
4955
|
k as SpecialApiUrl,
|
|
4917
4956
|
H as TraceLogValidationError,
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4957
|
+
Kr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4958
|
+
Ne as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4959
|
+
Ct as WEB_VITALS_POOR_THRESHOLDS,
|
|
4960
|
+
Oe as getWebVitalsThresholds,
|
|
4961
|
+
Qr as isPrimaryScrollEvent,
|
|
4962
|
+
jr as isSecondaryScrollEvent,
|
|
4963
|
+
Yr as tracelog
|
|
4925
4964
|
};
|