@tracelog/lib 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +583 -501
- 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 +98 -2
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +52 -0
- package/dist/public-api.d.ts +52 -0
- package/dist/public-api.js +98 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const Or = 9e5;
|
|
2
2
|
const Pr = 120, Dr = 8192, Vr = 10, kr = 10, Ur = 20, xr = 1;
|
|
3
3
|
const Hr = 1e3, Fr = 500, $r = 100;
|
|
4
|
-
const w = "data-tlog",
|
|
4
|
+
const w = "data-tlog", st = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -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
|
-
], I = "tlog", x = `${I}:qa_mode`, Te = `${I}:uid`, xe = "tlog_mode", _e = "qa", ve = "qa_off", lt = (
|
|
82
|
-
var k = /* @__PURE__ */ ((
|
|
81
|
+
], I = "tlog", x = `${I}:qa_mode`, Te = `${I}:uid`, xe = "tlog_mode", _e = "qa", ve = "qa_off", lt = (n) => n ? `${I}:${n}:queue` : `${I}:queue`, ct = (n) => n ? `${I}:${n}:session` : `${I}:session`, ut = (n) => n ? `${I}:${n}:broadcast` : `${I}:broadcast`, Ie = (n, e) => `${I}:${n}:session_counts:${e}`, we = 10080 * 60 * 1e3, ye = `${I}:session_counts_last_cleanup`, be = 3600 * 1e3;
|
|
82
|
+
var k = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(k || {}), L = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(L || {}), se = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(se || {});
|
|
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__ */ ((
|
|
89
|
-
const Br = (
|
|
88
|
+
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n.VIEWPORT_VISIBLE = "viewport_visible", n))(d || {}), X = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(X || {}), U = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(U || {}), z = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(z || {});
|
|
89
|
+
const Br = (n) => n.type === d.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !0, Wr = (n) => n.type === d.SCROLL && "scroll_data" in n && n.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);
|
|
@@ -117,25 +117,25 @@ class Gr extends H {
|
|
|
117
117
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Fe = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ht = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ft = (
|
|
120
|
+
const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Fe = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ht = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ft = (n, 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, "");
|
|
124
|
-
return `[TraceLog] ${
|
|
124
|
+
return `[TraceLog] ${n}: ${t}`;
|
|
125
125
|
}
|
|
126
126
|
if (e instanceof Error)
|
|
127
|
-
return `[TraceLog] ${
|
|
127
|
+
return `[TraceLog] ${n}: ${e.message}`;
|
|
128
128
|
if (typeof e == "string")
|
|
129
|
-
return `[TraceLog] ${
|
|
129
|
+
return `[TraceLog] ${n}: ${e}`;
|
|
130
130
|
if (typeof e == "object")
|
|
131
131
|
try {
|
|
132
|
-
return `[TraceLog] ${
|
|
132
|
+
return `[TraceLog] ${n}: ${JSON.stringify(e)}`;
|
|
133
133
|
} catch {
|
|
134
|
-
return `[TraceLog] ${
|
|
134
|
+
return `[TraceLog] ${n}: [Unable to serialize error]`;
|
|
135
135
|
}
|
|
136
|
-
return `[TraceLog] ${
|
|
136
|
+
return `[TraceLog] ${n}: ${String(e)}`;
|
|
137
137
|
}
|
|
138
|
-
return `[TraceLog] ${
|
|
138
|
+
return `[TraceLog] ${n}`;
|
|
139
139
|
}, mt = () => {
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
@@ -144,34 +144,34 @@ const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
144
144
|
} catch {
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
147
|
-
}, a = (
|
|
148
|
-
const { error: r, data:
|
|
147
|
+
}, a = (n, e, t) => {
|
|
148
|
+
const { error: r, data: s, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? ft(e, r) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
149
149
|
if (!gt(l, i))
|
|
150
150
|
return;
|
|
151
|
-
const g = Et(l, o), E =
|
|
151
|
+
const g = Et(l, o), E = s !== void 0 ? ie(s) : void 0;
|
|
152
152
|
St(u, c, g, E);
|
|
153
|
-
}, gt = (
|
|
154
|
-
const
|
|
155
|
-
r !== void 0 ?
|
|
156
|
-
}, ie = (
|
|
153
|
+
}, gt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? mt() : !1, Et = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? ht : "", St = (n, e, t, r) => {
|
|
154
|
+
const s = t !== void 0 && t !== "", i = s ? `%c${e}` : e;
|
|
155
|
+
r !== void 0 ? s ? console[n](i, t, r) : console[n](i, r) : s ? console[n](i, t) : console[n](i);
|
|
156
|
+
}, ie = (n) => {
|
|
157
157
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
158
|
-
for (const [r,
|
|
158
|
+
for (const [r, s] of Object.entries(n)) {
|
|
159
159
|
const i = r.toLowerCase();
|
|
160
160
|
if (t.some((o) => i.includes(o))) {
|
|
161
161
|
e[r] = "[REDACTED]";
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
s !== null && typeof s == "object" && !Array.isArray(s) ? e[r] = ie(s) : Array.isArray(s) ? e[r] = s.map(
|
|
165
165
|
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ie(o) : o
|
|
166
|
-
) : e[r] =
|
|
166
|
+
) : e[r] = s;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
170
|
let oe, $e;
|
|
171
171
|
const pt = () => {
|
|
172
172
|
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"), $e = window.matchMedia("(hover: none)"));
|
|
173
|
-
}, K = "Unknown", Tt = (
|
|
174
|
-
const e =
|
|
173
|
+
}, K = "Unknown", Tt = (n) => {
|
|
174
|
+
const e = n.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
176
176
|
if (/windows/i.test(e)) return "Windows";
|
|
177
177
|
if (/macos/i.test(e)) return "macOS";
|
|
@@ -182,12 +182,12 @@ 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
|
-
}, _t = (
|
|
186
|
-
const e =
|
|
185
|
+
}, _t = (n) => {
|
|
186
|
+
const e = n.userAgentData?.brands;
|
|
187
187
|
if (e != null && e.length > 0) {
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
const i =
|
|
188
|
+
const s = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
189
|
+
if (s != null) {
|
|
190
|
+
const i = s.brand;
|
|
191
191
|
return /google chrome/i.test(i) ? "Chrome" : /microsoft edge/i.test(i) ? "Edge" : /opera/i.test(i) ? "Opera" : i;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -195,27 +195,27 @@ const pt = () => {
|
|
|
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
|
}, vt = () => {
|
|
197
197
|
try {
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const c =
|
|
201
|
-
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet :
|
|
198
|
+
const n = navigator;
|
|
199
|
+
if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
|
|
200
|
+
const c = n.userAgentData.platform;
|
|
201
|
+
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : n.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
202
202
|
}
|
|
203
203
|
pt();
|
|
204
|
-
const e = window.innerWidth, t = oe?.matches ?? !1, r = $e?.matches ?? !1,
|
|
205
|
-
return e <= 767 || o &&
|
|
206
|
-
} catch (
|
|
207
|
-
return a("debug", "Device detection failed, defaulting to desktop", { error:
|
|
204
|
+
const e = window.innerWidth, t = oe?.matches ?? !1, r = $e?.matches ?? !1, s = "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
|
+
return e <= 767 || o && s ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && s ? L.Tablet : L.Desktop;
|
|
206
|
+
} catch (n) {
|
|
207
|
+
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), L.Desktop;
|
|
208
208
|
}
|
|
209
209
|
}, It = () => {
|
|
210
210
|
try {
|
|
211
|
-
const
|
|
211
|
+
const n = navigator;
|
|
212
212
|
return {
|
|
213
213
|
type: vt(),
|
|
214
|
-
os: Tt(
|
|
215
|
-
browser: _t(
|
|
214
|
+
os: Tt(n),
|
|
215
|
+
browser: _t(n)
|
|
216
216
|
};
|
|
217
|
-
} catch (
|
|
218
|
-
return a("debug", "Device info detection failed, using defaults", { error:
|
|
217
|
+
} catch (n) {
|
|
218
|
+
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
219
219
|
type: L.Desktop,
|
|
220
220
|
os: K,
|
|
221
221
|
browser: K
|
|
@@ -272,8 +272,8 @@ const pt = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
}, ae = "needs-improvement", Ne = (
|
|
276
|
-
switch (
|
|
275
|
+
}, ae = "needs-improvement", Ne = (n = ae) => {
|
|
276
|
+
switch (n) {
|
|
277
277
|
case "all":
|
|
278
278
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
279
279
|
// Track everything
|
|
@@ -284,11 +284,11 @@ const pt = () => {
|
|
|
284
284
|
default:
|
|
285
285
|
return Re;
|
|
286
286
|
}
|
|
287
|
-
}, Mt = 1e3, Ct = 50, Rt = "2.0
|
|
287
|
+
}, Mt = 1e3, Ct = 50, Rt = "2.1.0", Nt = Rt, Ge = () => typeof window < "u" && typeof sessionStorage < "u", Ot = () => {
|
|
288
288
|
try {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
const e =
|
|
289
|
+
const n = new URLSearchParams(window.location.search);
|
|
290
|
+
n.delete(xe);
|
|
291
|
+
const e = n.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
292
292
|
window.history.replaceState({}, "", t);
|
|
293
293
|
} catch {
|
|
294
294
|
}
|
|
@@ -308,51 +308,51 @@ const pt = () => {
|
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
}, Dt = (
|
|
311
|
+
}, Dt = (n) => {
|
|
312
312
|
if (Ge())
|
|
313
313
|
try {
|
|
314
|
-
sessionStorage.setItem(x,
|
|
314
|
+
sessionStorage.setItem(x, n ? "true" : "false"), a("info", n ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
|
-
style:
|
|
316
|
+
style: n ? He : Fe
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
321
|
}, Oe = () => {
|
|
322
|
-
const
|
|
322
|
+
const n = new URLSearchParams(window.location.search), e = {};
|
|
323
323
|
return it.forEach((r) => {
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
324
|
+
const s = n.get(r);
|
|
325
|
+
if (s) {
|
|
326
326
|
const i = r.split("utm_")[1];
|
|
327
|
-
e[i] =
|
|
327
|
+
e[i] = s;
|
|
328
328
|
}
|
|
329
329
|
}), Object.keys(e).length ? e : void 0;
|
|
330
|
-
}, Vt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (
|
|
330
|
+
}, Vt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
331
331
|
const e = Math.random() * 16 | 0;
|
|
332
|
-
return (
|
|
332
|
+
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
333
333
|
});
|
|
334
334
|
let B = 0, W = 0;
|
|
335
335
|
const kt = () => {
|
|
336
|
-
let
|
|
337
|
-
|
|
336
|
+
let n = Date.now();
|
|
337
|
+
n < W && (n = W), n === W ? B = (B + 1) % 1e3 : B = 0, W = n;
|
|
338
338
|
const e = B.toString().padStart(3, "0");
|
|
339
339
|
let t = "";
|
|
340
340
|
try {
|
|
341
341
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
342
342
|
const r = crypto.getRandomValues(new Uint8Array(3));
|
|
343
|
-
r && (t = Array.from(r, (
|
|
343
|
+
r && (t = Array.from(r, (s) => s.toString(16).padStart(2, "0")).join(""));
|
|
344
344
|
}
|
|
345
345
|
} catch {
|
|
346
346
|
}
|
|
347
|
-
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${
|
|
348
|
-
}, Xe = (
|
|
347
|
+
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
348
|
+
}, Xe = (n, e = !1) => {
|
|
349
349
|
try {
|
|
350
|
-
const t = new URL(
|
|
351
|
-
return r || e &&
|
|
350
|
+
const t = new URL(n), r = t.protocol === "https:", s = t.protocol === "http:";
|
|
351
|
+
return r || e && s;
|
|
352
352
|
} catch {
|
|
353
353
|
return !1;
|
|
354
354
|
}
|
|
355
|
-
}, Ut = (
|
|
355
|
+
}, Ut = (n) => {
|
|
356
356
|
try {
|
|
357
357
|
const t = new URL(window.location.href).hostname;
|
|
358
358
|
if (!t || typeof t != "string")
|
|
@@ -366,70 +366,70 @@ const kt = () => {
|
|
|
366
366
|
throw new Error("Invalid hostname structure");
|
|
367
367
|
if (r.length === 1)
|
|
368
368
|
throw new Error("Single-part domain not supported for SaaS integration");
|
|
369
|
-
let
|
|
370
|
-
if (r.length === 2 ?
|
|
369
|
+
let s;
|
|
370
|
+
if (r.length === 2 ? s = r.join(".") : s = r.slice(-2).join("."), !s || s.split(".").length < 2)
|
|
371
371
|
throw new Error("Invalid domain structure for SaaS");
|
|
372
|
-
const i = `https://${
|
|
372
|
+
const i = `https://${n}.${s}/collect`;
|
|
373
373
|
if (!Xe(i))
|
|
374
374
|
throw new Error("Generated URL failed validation");
|
|
375
375
|
return i;
|
|
376
376
|
} catch (e) {
|
|
377
377
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
378
378
|
}
|
|
379
|
-
}, xt = (
|
|
379
|
+
}, xt = (n) => {
|
|
380
380
|
const e = {};
|
|
381
|
-
|
|
382
|
-
const t =
|
|
381
|
+
n.integrations?.tracelog?.projectId && (e.saas = Ut(n.integrations.tracelog.projectId));
|
|
382
|
+
const t = n.integrations?.custom?.collectApiUrl;
|
|
383
383
|
if (t) {
|
|
384
|
-
const r =
|
|
384
|
+
const r = n.integrations?.custom?.allowHttp ?? !1;
|
|
385
385
|
if (!Xe(t, r))
|
|
386
386
|
throw new Error("Invalid custom API URL");
|
|
387
387
|
e.custom = t;
|
|
388
388
|
}
|
|
389
389
|
return e;
|
|
390
|
-
}, le = (
|
|
391
|
-
if (!
|
|
392
|
-
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof
|
|
390
|
+
}, le = (n, e = []) => {
|
|
391
|
+
if (!n || typeof n != "string")
|
|
392
|
+
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
393
393
|
try {
|
|
394
|
-
const t = new URL(
|
|
394
|
+
const t = new URL(n), r = t.searchParams, s = [.../* @__PURE__ */ new Set([...ot, ...e])];
|
|
395
395
|
let i = !1;
|
|
396
396
|
const o = [];
|
|
397
|
-
return
|
|
397
|
+
return s.forEach((c) => {
|
|
398
398
|
r.has(c) && (r.delete(c), i = !0, o.push(c));
|
|
399
|
-
}), !i &&
|
|
399
|
+
}), !i && n.includes("?") ? n : (t.search = r.toString(), t.toString());
|
|
400
400
|
} catch (t) {
|
|
401
|
-
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength:
|
|
401
|
+
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
402
402
|
}
|
|
403
|
-
}, Pe = (
|
|
404
|
-
if (!
|
|
403
|
+
}, Pe = (n) => {
|
|
404
|
+
if (!n || typeof n != "string" || n.trim().length === 0)
|
|
405
405
|
return "";
|
|
406
|
-
let e =
|
|
407
|
-
|
|
406
|
+
let e = n;
|
|
407
|
+
n.length > 1e3 && (e = n.slice(0, Math.max(0, 1e3)));
|
|
408
408
|
let t = 0;
|
|
409
|
-
for (const
|
|
409
|
+
for (const s of at) {
|
|
410
410
|
const i = e;
|
|
411
|
-
e = e.replace(
|
|
411
|
+
e = e.replace(s, ""), i !== e && t++;
|
|
412
412
|
}
|
|
413
413
|
return t > 0 && a("warn", "XSS patterns detected and removed", {
|
|
414
414
|
data: {
|
|
415
415
|
patternMatches: t,
|
|
416
|
-
valueLength:
|
|
416
|
+
valueLength: n.length
|
|
417
417
|
}
|
|
418
418
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
419
|
-
}, ce = (
|
|
420
|
-
if (e > 3 ||
|
|
419
|
+
}, ce = (n, e = 0) => {
|
|
420
|
+
if (e > 3 || n == null)
|
|
421
421
|
return null;
|
|
422
|
-
if (typeof
|
|
423
|
-
return Pe(
|
|
424
|
-
if (typeof
|
|
425
|
-
return !Number.isFinite(
|
|
426
|
-
if (typeof
|
|
427
|
-
return
|
|
428
|
-
if (Array.isArray(
|
|
429
|
-
return
|
|
430
|
-
if (typeof
|
|
431
|
-
const t = {},
|
|
432
|
-
for (const [i, o] of
|
|
422
|
+
if (typeof n == "string")
|
|
423
|
+
return Pe(n);
|
|
424
|
+
if (typeof n == "number")
|
|
425
|
+
return !Number.isFinite(n) || n < -Number.MAX_SAFE_INTEGER || n > Number.MAX_SAFE_INTEGER ? 0 : n;
|
|
426
|
+
if (typeof n == "boolean")
|
|
427
|
+
return n;
|
|
428
|
+
if (Array.isArray(n))
|
|
429
|
+
return n.slice(0, 100).map((s) => ce(s, e + 1)).filter((s) => s !== null);
|
|
430
|
+
if (typeof n == "object") {
|
|
431
|
+
const t = {}, s = Object.entries(n).slice(0, 20);
|
|
432
|
+
for (const [i, o] of s) {
|
|
433
433
|
const l = Pe(i);
|
|
434
434
|
if (l) {
|
|
435
435
|
const c = ce(o, e + 1);
|
|
@@ -439,72 +439,72 @@ const kt = () => {
|
|
|
439
439
|
return t;
|
|
440
440
|
}
|
|
441
441
|
return null;
|
|
442
|
-
}, Ht = (
|
|
443
|
-
if (typeof
|
|
442
|
+
}, Ht = (n) => {
|
|
443
|
+
if (typeof n != "object" || n === null)
|
|
444
444
|
return {};
|
|
445
445
|
try {
|
|
446
|
-
const e = ce(
|
|
446
|
+
const e = ce(n);
|
|
447
447
|
return typeof e == "object" && e !== null ? e : {};
|
|
448
448
|
} catch (e) {
|
|
449
449
|
const t = e instanceof Error ? e.message : String(e);
|
|
450
450
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
451
451
|
}
|
|
452
|
-
}, Ft = (
|
|
453
|
-
if (
|
|
452
|
+
}, Ft = (n) => {
|
|
453
|
+
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
454
454
|
throw new h("Configuration must be an object", "config");
|
|
455
|
-
if (
|
|
456
|
-
if (
|
|
455
|
+
if (n) {
|
|
456
|
+
if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
|
|
457
457
|
throw new dt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
458
|
-
if (
|
|
458
|
+
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
459
459
|
throw new h(m.INVALID_GLOBAL_METADATA, "config");
|
|
460
|
-
if (
|
|
461
|
-
if (!Array.isArray(
|
|
460
|
+
if (n.integrations && Bt(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
461
|
+
if (!Array.isArray(n.sensitiveQueryParams))
|
|
462
462
|
throw new h(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
463
|
-
for (const e of
|
|
463
|
+
for (const e of n.sensitiveQueryParams)
|
|
464
464
|
if (typeof e != "string")
|
|
465
465
|
throw new h("All sensitive query params must be strings", "config");
|
|
466
466
|
}
|
|
467
|
-
if (
|
|
467
|
+
if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
|
|
468
468
|
throw new Ae(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
469
|
-
if (
|
|
469
|
+
if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
|
|
470
470
|
throw new Ae(m.INVALID_SAMPLING_RATE, "config");
|
|
471
|
-
if (
|
|
472
|
-
if (typeof
|
|
471
|
+
if (n.primaryScrollSelector !== void 0) {
|
|
472
|
+
if (typeof n.primaryScrollSelector != "string" || !n.primaryScrollSelector.trim())
|
|
473
473
|
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
474
|
-
if (
|
|
474
|
+
if (n.primaryScrollSelector !== "window")
|
|
475
475
|
try {
|
|
476
|
-
document.querySelector(
|
|
476
|
+
document.querySelector(n.primaryScrollSelector);
|
|
477
477
|
} catch {
|
|
478
478
|
throw new h(
|
|
479
|
-
`${m.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${
|
|
479
|
+
`${m.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${n.primaryScrollSelector}"`,
|
|
480
480
|
"config"
|
|
481
481
|
);
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
if (
|
|
484
|
+
if (n.pageViewThrottleMs !== void 0 && (typeof n.pageViewThrottleMs != "number" || n.pageViewThrottleMs < 0))
|
|
485
485
|
throw new h(m.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
486
|
-
if (
|
|
486
|
+
if (n.clickThrottleMs !== void 0 && (typeof n.clickThrottleMs != "number" || n.clickThrottleMs < 0))
|
|
487
487
|
throw new h(m.INVALID_CLICK_THROTTLE, "config");
|
|
488
|
-
if (
|
|
488
|
+
if (n.maxSameEventPerMinute !== void 0 && (typeof n.maxSameEventPerMinute != "number" || n.maxSameEventPerMinute <= 0))
|
|
489
489
|
throw new h(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
490
|
-
if (
|
|
491
|
-
if (typeof
|
|
490
|
+
if (n.viewport !== void 0 && $t(n.viewport), n.webVitalsMode !== void 0) {
|
|
491
|
+
if (typeof n.webVitalsMode != "string")
|
|
492
492
|
throw new h(
|
|
493
|
-
`Invalid webVitalsMode type: ${typeof
|
|
493
|
+
`Invalid webVitalsMode type: ${typeof n.webVitalsMode}. Must be a string`,
|
|
494
494
|
"config"
|
|
495
495
|
);
|
|
496
496
|
const e = ["all", "needs-improvement", "poor"];
|
|
497
|
-
if (!e.includes(
|
|
497
|
+
if (!e.includes(n.webVitalsMode))
|
|
498
498
|
throw new h(
|
|
499
|
-
`Invalid webVitalsMode: "${
|
|
499
|
+
`Invalid webVitalsMode: "${n.webVitalsMode}". Must be one of: ${e.join(", ")}`,
|
|
500
500
|
"config"
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
|
-
if (
|
|
504
|
-
if (typeof
|
|
503
|
+
if (n.webVitalsThresholds !== void 0) {
|
|
504
|
+
if (typeof n.webVitalsThresholds != "object" || n.webVitalsThresholds === null || Array.isArray(n.webVitalsThresholds))
|
|
505
505
|
throw new h("webVitalsThresholds must be an object", "config");
|
|
506
506
|
const e = ["LCP", "FCP", "CLS", "INP", "TTFB", "LONG_TASK"];
|
|
507
|
-
for (const [t, r] of Object.entries(
|
|
507
|
+
for (const [t, r] of Object.entries(n.webVitalsThresholds)) {
|
|
508
508
|
if (!e.includes(t))
|
|
509
509
|
throw new h(
|
|
510
510
|
`Invalid Web Vitals threshold key: "${t}". Must be one of: ${e.join(", ")}`,
|
|
@@ -518,15 +518,15 @@ const kt = () => {
|
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
}, $t = (
|
|
522
|
-
if (typeof
|
|
521
|
+
}, $t = (n) => {
|
|
522
|
+
if (typeof n != "object" || n === null)
|
|
523
523
|
throw new h(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
524
|
-
if (!
|
|
524
|
+
if (!n.elements || !Array.isArray(n.elements))
|
|
525
525
|
throw new h(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
526
|
-
if (
|
|
526
|
+
if (n.elements.length === 0)
|
|
527
527
|
throw new h(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
528
528
|
const e = /* @__PURE__ */ new Set();
|
|
529
|
-
for (const t of
|
|
529
|
+
for (const t of n.elements) {
|
|
530
530
|
if (!t.selector || typeof t.selector != "string" || !t.selector.trim())
|
|
531
531
|
throw new h(m.INVALID_VIEWPORT_ELEMENT, "config");
|
|
532
532
|
const r = t.selector.trim();
|
|
@@ -540,45 +540,45 @@ const kt = () => {
|
|
|
540
540
|
if (t.name !== void 0 && (typeof t.name != "string" || !t.name.trim()))
|
|
541
541
|
throw new h(m.INVALID_VIEWPORT_ELEMENT_NAME, "config");
|
|
542
542
|
}
|
|
543
|
-
if (
|
|
543
|
+
if (n.threshold !== void 0 && (typeof n.threshold != "number" || n.threshold < 0 || n.threshold > 1))
|
|
544
544
|
throw new h(m.INVALID_VIEWPORT_THRESHOLD, "config");
|
|
545
|
-
if (
|
|
545
|
+
if (n.minDwellTime !== void 0 && (typeof n.minDwellTime != "number" || n.minDwellTime < 0))
|
|
546
546
|
throw new h(m.INVALID_VIEWPORT_MIN_DWELL_TIME, "config");
|
|
547
|
-
if (
|
|
547
|
+
if (n.cooldownPeriod !== void 0 && (typeof n.cooldownPeriod != "number" || n.cooldownPeriod < 0))
|
|
548
548
|
throw new h(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
549
|
-
if (
|
|
549
|
+
if (n.maxTrackedElements !== void 0 && (typeof n.maxTrackedElements != "number" || n.maxTrackedElements <= 0))
|
|
550
550
|
throw new h(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
551
|
-
}, Bt = (
|
|
552
|
-
if (
|
|
553
|
-
if (
|
|
551
|
+
}, Bt = (n) => {
|
|
552
|
+
if (n) {
|
|
553
|
+
if (n.tracelog && (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === ""))
|
|
554
554
|
throw new V(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
555
|
-
if (
|
|
556
|
-
if (!
|
|
555
|
+
if (n.custom) {
|
|
556
|
+
if (!n.custom.collectApiUrl || typeof n.custom.collectApiUrl != "string" || n.custom.collectApiUrl.trim() === "")
|
|
557
557
|
throw new V(m.INVALID_CUSTOM_API_URL, "config");
|
|
558
|
-
if (
|
|
558
|
+
if (n.custom.allowHttp !== void 0 && typeof n.custom.allowHttp != "boolean")
|
|
559
559
|
throw new V("allowHttp must be a boolean", "config");
|
|
560
|
-
const e =
|
|
560
|
+
const e = n.custom.collectApiUrl.trim();
|
|
561
561
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
562
562
|
throw new V('Custom API URL must start with "http://" or "https://"', "config");
|
|
563
|
-
if (!(
|
|
563
|
+
if (!(n.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
564
564
|
throw new V(
|
|
565
565
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
566
566
|
"config"
|
|
567
567
|
);
|
|
568
568
|
}
|
|
569
569
|
}
|
|
570
|
-
}, Wt = (
|
|
571
|
-
Ft(
|
|
570
|
+
}, Wt = (n) => {
|
|
571
|
+
Ft(n);
|
|
572
572
|
const e = {
|
|
573
|
-
...
|
|
574
|
-
sessionTimeout:
|
|
575
|
-
globalMetadata:
|
|
576
|
-
sensitiveQueryParams:
|
|
577
|
-
errorSampling:
|
|
578
|
-
samplingRate:
|
|
579
|
-
pageViewThrottleMs:
|
|
580
|
-
clickThrottleMs:
|
|
581
|
-
maxSameEventPerMinute:
|
|
573
|
+
...n ?? {},
|
|
574
|
+
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
575
|
+
globalMetadata: n?.globalMetadata ?? {},
|
|
576
|
+
sensitiveQueryParams: n?.sensitiveQueryParams ?? [],
|
|
577
|
+
errorSampling: n?.errorSampling ?? We,
|
|
578
|
+
samplingRate: n?.samplingRate ?? 1,
|
|
579
|
+
pageViewThrottleMs: n?.pageViewThrottleMs ?? 1e3,
|
|
580
|
+
clickThrottleMs: n?.clickThrottleMs ?? 300,
|
|
581
|
+
maxSameEventPerMinute: n?.maxSameEventPerMinute ?? 60
|
|
582
582
|
};
|
|
583
583
|
return e.integrations?.custom && (e.integrations.custom = {
|
|
584
584
|
...e.integrations.custom,
|
|
@@ -590,11 +590,11 @@ const kt = () => {
|
|
|
590
590
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
591
591
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
592
592
|
}), e;
|
|
593
|
-
}, Gt = (
|
|
594
|
-
if (typeof
|
|
593
|
+
}, Gt = (n) => {
|
|
594
|
+
if (typeof n == "string")
|
|
595
595
|
return !0;
|
|
596
|
-
if (typeof
|
|
597
|
-
const e = Object.entries(
|
|
596
|
+
if (typeof n == "object" && n !== null && !Array.isArray(n)) {
|
|
597
|
+
const e = Object.entries(n);
|
|
598
598
|
if (e.length > 20)
|
|
599
599
|
return !1;
|
|
600
600
|
for (const [, t] of e) {
|
|
@@ -607,10 +607,10 @@ const kt = () => {
|
|
|
607
607
|
return !0;
|
|
608
608
|
}
|
|
609
609
|
return !1;
|
|
610
|
-
}, Qe = (
|
|
611
|
-
if (typeof
|
|
610
|
+
}, Qe = (n, e = 0) => {
|
|
611
|
+
if (typeof n != "object" || n === null || e > 1)
|
|
612
612
|
return !1;
|
|
613
|
-
for (const t of Object.values(
|
|
613
|
+
for (const t of Object.values(n)) {
|
|
614
614
|
if (t == null)
|
|
615
615
|
continue;
|
|
616
616
|
const r = typeof t;
|
|
@@ -634,27 +634,27 @@ const kt = () => {
|
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
return !0;
|
|
637
|
-
}, Xt = (
|
|
637
|
+
}, Xt = (n) => typeof n != "string" ? {
|
|
638
638
|
valid: !1,
|
|
639
639
|
error: "Event name must be a string"
|
|
640
|
-
} :
|
|
640
|
+
} : n.length === 0 ? {
|
|
641
641
|
valid: !1,
|
|
642
642
|
error: "Event name cannot be empty"
|
|
643
|
-
} :
|
|
643
|
+
} : n.length > 120 ? {
|
|
644
644
|
valid: !1,
|
|
645
645
|
error: "Event name is too long (max 120 characters)"
|
|
646
|
-
} :
|
|
646
|
+
} : n.includes("<") || n.includes(">") || n.includes("&") ? {
|
|
647
647
|
valid: !1,
|
|
648
648
|
error: "Event name contains invalid characters"
|
|
649
|
-
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(
|
|
649
|
+
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(n.toLowerCase()) ? {
|
|
650
650
|
valid: !1,
|
|
651
651
|
error: "Event name cannot be a reserved word"
|
|
652
|
-
} : { valid: !0 }, De = (
|
|
653
|
-
const r = Ht(e),
|
|
652
|
+
} : { valid: !0 }, De = (n, e, t) => {
|
|
653
|
+
const r = Ht(e), s = t && t === "customEvent" ? `${t} "${n}" metadata error` : `${n} metadata error`;
|
|
654
654
|
if (!Qe(r))
|
|
655
655
|
return {
|
|
656
656
|
valid: !1,
|
|
657
|
-
error: `${
|
|
657
|
+
error: `${s}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
658
658
|
};
|
|
659
659
|
let i;
|
|
660
660
|
try {
|
|
@@ -662,58 +662,58 @@ const kt = () => {
|
|
|
662
662
|
} catch {
|
|
663
663
|
return {
|
|
664
664
|
valid: !1,
|
|
665
|
-
error: `${
|
|
665
|
+
error: `${s}: object contains circular references or cannot be serialized.`
|
|
666
666
|
};
|
|
667
667
|
}
|
|
668
668
|
if (i.length > 8192)
|
|
669
669
|
return {
|
|
670
670
|
valid: !1,
|
|
671
|
-
error: `${
|
|
671
|
+
error: `${s}: object is too large (max ${8192 / 1024} KB).`
|
|
672
672
|
};
|
|
673
673
|
if (Object.keys(r).length > 10)
|
|
674
674
|
return {
|
|
675
675
|
valid: !1,
|
|
676
|
-
error: `${
|
|
676
|
+
error: `${s}: object has too many keys (max 10 keys).`
|
|
677
677
|
};
|
|
678
678
|
for (const [l, c] of Object.entries(r)) {
|
|
679
679
|
if (Array.isArray(c)) {
|
|
680
680
|
if (c.length > 10)
|
|
681
681
|
return {
|
|
682
682
|
valid: !1,
|
|
683
|
-
error: `${
|
|
683
|
+
error: `${s}: array property "${l}" is too large (max 10 items).`
|
|
684
684
|
};
|
|
685
685
|
for (const u of c)
|
|
686
686
|
if (typeof u == "string" && u.length > 500)
|
|
687
687
|
return {
|
|
688
688
|
valid: !1,
|
|
689
|
-
error: `${
|
|
689
|
+
error: `${s}: array property "${l}" contains strings that are too long (max 500 characters).`
|
|
690
690
|
};
|
|
691
691
|
}
|
|
692
692
|
if (typeof c == "string" && c.length > 1e3)
|
|
693
693
|
return {
|
|
694
694
|
valid: !1,
|
|
695
|
-
error: `${
|
|
695
|
+
error: `${s}: property "${l}" is too long (max 1000 characters).`
|
|
696
696
|
};
|
|
697
697
|
}
|
|
698
698
|
return {
|
|
699
699
|
valid: !0,
|
|
700
700
|
sanitizedMetadata: r
|
|
701
701
|
};
|
|
702
|
-
},
|
|
702
|
+
}, je = (n, e, t) => {
|
|
703
703
|
if (Array.isArray(e)) {
|
|
704
|
-
const r = [],
|
|
704
|
+
const r = [], s = t && t === "customEvent" ? `${t} "${n}" metadata error` : `${n} metadata error`;
|
|
705
705
|
for (let i = 0; i < e.length; i++) {
|
|
706
706
|
const o = e[i];
|
|
707
707
|
if (typeof o != "object" || o === null || Array.isArray(o))
|
|
708
708
|
return {
|
|
709
709
|
valid: !1,
|
|
710
|
-
error: `${
|
|
710
|
+
error: `${s}: array item at index ${i} must be an object.`
|
|
711
711
|
};
|
|
712
|
-
const l = De(
|
|
712
|
+
const l = De(n, o, t);
|
|
713
713
|
if (!l.valid)
|
|
714
714
|
return {
|
|
715
715
|
valid: !1,
|
|
716
|
-
error: `${
|
|
716
|
+
error: `${s}: array item at index ${i} is invalid: ${l.error}`
|
|
717
717
|
};
|
|
718
718
|
l.sanitizedMetadata && r.push(l.sanitizedMetadata);
|
|
719
719
|
}
|
|
@@ -722,24 +722,24 @@ const kt = () => {
|
|
|
722
722
|
sanitizedMetadata: r
|
|
723
723
|
};
|
|
724
724
|
}
|
|
725
|
-
return De(
|
|
726
|
-
}, Qt = (
|
|
727
|
-
const t = Xt(
|
|
725
|
+
return De(n, e, t);
|
|
726
|
+
}, Qt = (n, e) => {
|
|
727
|
+
const t = Xt(n);
|
|
728
728
|
if (!t.valid)
|
|
729
729
|
return a("error", "Event name validation failed", {
|
|
730
|
-
data: { eventName:
|
|
730
|
+
data: { eventName: n, error: t.error }
|
|
731
731
|
}), t;
|
|
732
732
|
if (!e)
|
|
733
733
|
return { valid: !0 };
|
|
734
|
-
const r =
|
|
734
|
+
const r = je(n, e, "customEvent");
|
|
735
735
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
736
736
|
data: {
|
|
737
|
-
eventName:
|
|
737
|
+
eventName: n,
|
|
738
738
|
error: r.error
|
|
739
739
|
}
|
|
740
740
|
}), r;
|
|
741
741
|
};
|
|
742
|
-
class
|
|
742
|
+
class jt {
|
|
743
743
|
listeners = /* @__PURE__ */ new Map();
|
|
744
744
|
/**
|
|
745
745
|
* Subscribes to an event channel
|
|
@@ -792,8 +792,8 @@ class zt {
|
|
|
792
792
|
off(e, t) {
|
|
793
793
|
const r = this.listeners.get(e);
|
|
794
794
|
if (r) {
|
|
795
|
-
const
|
|
796
|
-
|
|
795
|
+
const s = r.indexOf(t);
|
|
796
|
+
s > -1 && r.splice(s, 1);
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
/**
|
|
@@ -826,8 +826,8 @@ class zt {
|
|
|
826
826
|
*/
|
|
827
827
|
emit(e, t) {
|
|
828
828
|
const r = this.listeners.get(e);
|
|
829
|
-
r && r.forEach((
|
|
830
|
-
|
|
829
|
+
r && r.forEach((s) => {
|
|
830
|
+
s(t);
|
|
831
831
|
});
|
|
832
832
|
}
|
|
833
833
|
/**
|
|
@@ -856,34 +856,34 @@ class zt {
|
|
|
856
856
|
this.listeners.clear();
|
|
857
857
|
}
|
|
858
858
|
}
|
|
859
|
-
function
|
|
859
|
+
function ze(n, e, t) {
|
|
860
860
|
try {
|
|
861
|
-
const r = e(
|
|
862
|
-
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`),
|
|
861
|
+
const r = e(n);
|
|
862
|
+
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), n);
|
|
863
863
|
} catch (r) {
|
|
864
864
|
return a("error", `beforeSend transformer threw error, using original event [${t}]`, {
|
|
865
865
|
error: r,
|
|
866
866
|
visibility: "critical"
|
|
867
|
-
}),
|
|
867
|
+
}), n;
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
function
|
|
871
|
-
return
|
|
870
|
+
function zt(n, e, t) {
|
|
871
|
+
return n.map((r) => ze(r, e, t)).filter((r) => r !== null);
|
|
872
872
|
}
|
|
873
|
-
function Ke(
|
|
873
|
+
function Ke(n, e, t) {
|
|
874
874
|
try {
|
|
875
|
-
const r = e(
|
|
875
|
+
const r = e(n);
|
|
876
876
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
877
|
-
data: { eventCount:
|
|
877
|
+
data: { eventCount: n.events.length }
|
|
878
878
|
}), null) : typeof r == "object" && r !== null && Array.isArray(r.events) ? r : (a("warn", `beforeBatch transformer returned invalid data, using original [${t}]`, {
|
|
879
|
-
data: { eventCount:
|
|
880
|
-
}),
|
|
879
|
+
data: { eventCount: n.events.length }
|
|
880
|
+
}), n);
|
|
881
881
|
} catch (r) {
|
|
882
882
|
return a("error", `beforeBatch transformer threw error, using original batch [${t}]`, {
|
|
883
883
|
error: r,
|
|
884
|
-
data: { eventCount:
|
|
884
|
+
data: { eventCount: n.events.length },
|
|
885
885
|
visibility: "critical"
|
|
886
|
-
}),
|
|
886
|
+
}), n;
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
const te = {};
|
|
@@ -966,10 +966,10 @@ class Ve extends _ {
|
|
|
966
966
|
* @param transformers - Optional event transformation hooks
|
|
967
967
|
* @throws Error if integrationId and apiUrl are not both provided or both undefined
|
|
968
968
|
*/
|
|
969
|
-
constructor(e, t, r,
|
|
969
|
+
constructor(e, t, r, s = {}) {
|
|
970
970
|
if (super(), t && !r || !t && r)
|
|
971
971
|
throw new Error("SenderManager: integrationId and apiUrl must either both be provided or both be undefined");
|
|
972
|
-
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers =
|
|
972
|
+
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers = s;
|
|
973
973
|
}
|
|
974
974
|
/**
|
|
975
975
|
* Get the integration ID for this sender
|
|
@@ -1180,7 +1180,7 @@ class Ve extends _ {
|
|
|
1180
1180
|
const t = this.transformers.beforeSend;
|
|
1181
1181
|
if (!t)
|
|
1182
1182
|
return e;
|
|
1183
|
-
const r =
|
|
1183
|
+
const r = zt(
|
|
1184
1184
|
e.events,
|
|
1185
1185
|
t,
|
|
1186
1186
|
this.integrationId || "SenderManager"
|
|
@@ -1247,8 +1247,8 @@ class Ve extends _ {
|
|
|
1247
1247
|
* @returns Promise that resolves after calculated delay
|
|
1248
1248
|
*/
|
|
1249
1249
|
async backoffDelay(e) {
|
|
1250
|
-
const t = 100 * Math.pow(2, e), r = Math.random() * 100,
|
|
1251
|
-
return new Promise((i) => setTimeout(i,
|
|
1250
|
+
const t = 100 * Math.pow(2, e), r = Math.random() * 100, s = t + r;
|
|
1251
|
+
return new Promise((i) => setTimeout(i, s));
|
|
1252
1252
|
}
|
|
1253
1253
|
/**
|
|
1254
1254
|
* Sends event queue with automatic retry logic for transient failures.
|
|
@@ -1301,10 +1301,10 @@ class Ve extends _ {
|
|
|
1301
1301
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1302
1302
|
data: { events: r.events.length }
|
|
1303
1303
|
}), !0;
|
|
1304
|
-
const { url:
|
|
1304
|
+
const { url: s, payload: i } = this.prepareRequest(r);
|
|
1305
1305
|
for (let o = 1; o <= 3; o++)
|
|
1306
1306
|
try {
|
|
1307
|
-
return (await this.sendWithTimeout(
|
|
1307
|
+
return (await this.sendWithTimeout(s, i)).ok ? (o > 1 && a(
|
|
1308
1308
|
"info",
|
|
1309
1309
|
`Send succeeded after ${o - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1310
1310
|
{
|
|
@@ -1322,7 +1322,7 @@ class Ve extends _ {
|
|
|
1322
1322
|
error: l,
|
|
1323
1323
|
data: {
|
|
1324
1324
|
events: e.events.length,
|
|
1325
|
-
url:
|
|
1325
|
+
url: s.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1326
1326
|
attempt: o,
|
|
1327
1327
|
maxAttempts: 3
|
|
1328
1328
|
}
|
|
@@ -1359,7 +1359,7 @@ class Ve extends _ {
|
|
|
1359
1359
|
async sendWithTimeout(e, t) {
|
|
1360
1360
|
const r = new AbortController();
|
|
1361
1361
|
this.pendingControllers.add(r);
|
|
1362
|
-
const
|
|
1362
|
+
const s = setTimeout(() => {
|
|
1363
1363
|
r.abort();
|
|
1364
1364
|
}, 15e3);
|
|
1365
1365
|
try {
|
|
@@ -1377,7 +1377,7 @@ class Ve extends _ {
|
|
|
1377
1377
|
throw i.status >= 400 && i.status < 500 && i.status !== 408 && i.status !== 429 ? new N(`HTTP ${i.status}: ${i.statusText}`, i.status) : new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
1378
1378
|
return i;
|
|
1379
1379
|
} finally {
|
|
1380
|
-
clearTimeout(
|
|
1380
|
+
clearTimeout(s), this.pendingControllers.delete(r);
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
1383
|
/**
|
|
@@ -1407,7 +1407,7 @@ class Ve extends _ {
|
|
|
1407
1407
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1408
1408
|
if (!r)
|
|
1409
1409
|
return !0;
|
|
1410
|
-
const { url:
|
|
1410
|
+
const { url: s, payload: i } = this.prepareRequest(r);
|
|
1411
1411
|
if (i.length > 65536)
|
|
1412
1412
|
return a(
|
|
1413
1413
|
"warn",
|
|
@@ -1426,7 +1426,7 @@ class Ve extends _ {
|
|
|
1426
1426
|
"warn",
|
|
1427
1427
|
`sendBeacon not available, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1428
1428
|
), this.persistEvents(r), !1;
|
|
1429
|
-
const l = navigator.sendBeacon(
|
|
1429
|
+
const l = navigator.sendBeacon(s, o);
|
|
1430
1430
|
return l || (a(
|
|
1431
1431
|
"warn",
|
|
1432
1432
|
`sendBeacon rejected request, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
@@ -1551,8 +1551,8 @@ class Ve extends _ {
|
|
|
1551
1551
|
const r = {
|
|
1552
1552
|
...e,
|
|
1553
1553
|
timestamp: Date.now()
|
|
1554
|
-
},
|
|
1555
|
-
return this.storeManager.setItem(
|
|
1554
|
+
}, s = this.getQueueStorageKey();
|
|
1555
|
+
return this.storeManager.setItem(s, JSON.stringify(r)), !!this.storeManager.getItem(s);
|
|
1556
1556
|
} catch (t) {
|
|
1557
1557
|
return a("debug", `Failed to persist events${this.integrationId ? ` [${this.integrationId}]` : ""}`, { error: t }), !1;
|
|
1558
1558
|
}
|
|
@@ -1711,10 +1711,10 @@ class Kt extends _ {
|
|
|
1711
1711
|
* ```
|
|
1712
1712
|
*/
|
|
1713
1713
|
validateTimestamp(e) {
|
|
1714
|
-
const r = this.now(),
|
|
1715
|
-
return
|
|
1714
|
+
const r = this.now(), s = e - r;
|
|
1715
|
+
return s > 12e4 ? {
|
|
1716
1716
|
valid: !1,
|
|
1717
|
-
error: `Timestamp is ${(
|
|
1717
|
+
error: `Timestamp is ${(s / 1e3 / 60).toFixed(2)} minutes in the future (max allowed: 2 minutes)`
|
|
1718
1718
|
} : { valid: !0 };
|
|
1719
1719
|
}
|
|
1720
1720
|
/**
|
|
@@ -1768,8 +1768,8 @@ class Yt extends _ {
|
|
|
1768
1768
|
*/
|
|
1769
1769
|
constructor(e, t = null, r = {}) {
|
|
1770
1770
|
super(), this.emitter = t, this.transformers = r, this.timeManager = new Kt(), this.dataSenders = [];
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1771
|
+
const s = this.get("collectApiUrls");
|
|
1772
|
+
s?.saas && this.dataSenders.push(new Ve(e, "saas", s.saas, r)), s?.custom && this.dataSenders.push(new Ve(e, "custom", s.custom, r)), this.saveSessionCountsDebounced = this.debounce((i) => {
|
|
1773
1773
|
this.saveSessionCounts(i);
|
|
1774
1774
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1775
1775
|
}
|
|
@@ -1800,9 +1800,9 @@ class Yt extends _ {
|
|
|
1800
1800
|
async recoverPersistedEvents() {
|
|
1801
1801
|
const e = this.dataSenders.map(
|
|
1802
1802
|
async (t) => t.recoverPersistedEvents({
|
|
1803
|
-
onSuccess: (r,
|
|
1804
|
-
if (
|
|
1805
|
-
const o =
|
|
1803
|
+
onSuccess: (r, s, i) => {
|
|
1804
|
+
if (s && s.length > 0) {
|
|
1805
|
+
const o = s.map((l) => l.id);
|
|
1806
1806
|
this.removeProcessedEvents(o), i && this.emitEventsQueue(i);
|
|
1807
1807
|
}
|
|
1808
1808
|
},
|
|
@@ -1876,7 +1876,7 @@ class Yt extends _ {
|
|
|
1876
1876
|
type: e,
|
|
1877
1877
|
page_url: t,
|
|
1878
1878
|
from_page_url: r,
|
|
1879
|
-
scroll_data:
|
|
1879
|
+
scroll_data: s,
|
|
1880
1880
|
click_data: i,
|
|
1881
1881
|
custom_event: o,
|
|
1882
1882
|
web_vitals: l,
|
|
@@ -1896,7 +1896,7 @@ class Yt extends _ {
|
|
|
1896
1896
|
type: e,
|
|
1897
1897
|
page_url: t,
|
|
1898
1898
|
from_page_url: r,
|
|
1899
|
-
scroll_data:
|
|
1899
|
+
scroll_data: s,
|
|
1900
1900
|
click_data: i,
|
|
1901
1901
|
custom_event: o,
|
|
1902
1902
|
web_vitals: l,
|
|
@@ -1944,11 +1944,11 @@ class Yt extends _ {
|
|
|
1944
1944
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1945
1945
|
return;
|
|
1946
1946
|
}
|
|
1947
|
-
const $ = p === d.SESSION_START,
|
|
1947
|
+
const $ = p === d.SESSION_START, nt = t || this.get("pageUrl"), D = this.buildEventPayload({
|
|
1948
1948
|
type: p,
|
|
1949
|
-
page_url:
|
|
1949
|
+
page_url: nt,
|
|
1950
1950
|
from_page_url: r,
|
|
1951
|
-
scroll_data:
|
|
1951
|
+
scroll_data: s,
|
|
1952
1952
|
click_data: i,
|
|
1953
1953
|
custom_event: o,
|
|
1954
1954
|
web_vitals: l,
|
|
@@ -1972,7 +1972,7 @@ class Yt extends _ {
|
|
|
1972
1972
|
this.set("hasStartSession", !0);
|
|
1973
1973
|
}
|
|
1974
1974
|
if (!this.isDuplicateEvent(D)) {
|
|
1975
|
-
if (this.get("mode") ===
|
|
1975
|
+
if (this.get("mode") === z.QA) {
|
|
1976
1976
|
if (p === d.CUSTOM && o) {
|
|
1977
1977
|
a("info", `Custom Event: ${o.name}`, {
|
|
1978
1978
|
visibility: "qa",
|
|
@@ -2246,13 +2246,13 @@ class Yt extends _ {
|
|
|
2246
2246
|
flushEvents(e) {
|
|
2247
2247
|
if (this.eventsQueue.length === 0)
|
|
2248
2248
|
return e ? !0 : Promise.resolve(!0);
|
|
2249
|
-
const t = this.buildEventsPayload(), r = [...this.eventsQueue],
|
|
2249
|
+
const t = this.buildEventsPayload(), r = [...this.eventsQueue], s = r.map((i) => i.id);
|
|
2250
2250
|
if (this.dataSenders.length === 0)
|
|
2251
|
-
return this.removeProcessedEvents(
|
|
2251
|
+
return this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
2252
2252
|
if (e) {
|
|
2253
2253
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2254
|
-
return o ? (this.removeProcessedEvents(
|
|
2255
|
-
data: { eventCount:
|
|
2254
|
+
return o ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
|
|
2255
|
+
data: { eventCount: s.length }
|
|
2256
2256
|
})), o;
|
|
2257
2257
|
} else {
|
|
2258
2258
|
const i = this.dataSenders.map(
|
|
@@ -2265,7 +2265,7 @@ class Yt extends _ {
|
|
|
2265
2265
|
);
|
|
2266
2266
|
return Promise.allSettled(i).then((o) => {
|
|
2267
2267
|
const l = o.some((c) => this.isSuccessfulResult(c));
|
|
2268
|
-
return l ? (this.removeProcessedEvents(
|
|
2268
|
+
return l ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
|
|
2269
2269
|
data: { eventCount: r.length }
|
|
2270
2270
|
}), l;
|
|
2271
2271
|
});
|
|
@@ -2279,14 +2279,14 @@ class Yt extends _ {
|
|
|
2279
2279
|
this.emitEventsQueue(e);
|
|
2280
2280
|
return;
|
|
2281
2281
|
}
|
|
2282
|
-
const t = [...this.eventsQueue], r = t.map((l) => l.id),
|
|
2282
|
+
const t = [...this.eventsQueue], r = t.map((l) => l.id), s = this.dataSenders.map(
|
|
2283
2283
|
async (l) => l.sendEventsQueue(e, {
|
|
2284
2284
|
onSuccess: () => {
|
|
2285
2285
|
},
|
|
2286
2286
|
onFailure: () => {
|
|
2287
2287
|
}
|
|
2288
2288
|
})
|
|
2289
|
-
), i = await Promise.allSettled(
|
|
2289
|
+
), i = await Promise.allSettled(s);
|
|
2290
2290
|
if (i.some((l) => this.isSuccessfulResult(l))) {
|
|
2291
2291
|
this.removeProcessedEvents(r), this.emitEventsQueue(e);
|
|
2292
2292
|
const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
@@ -2306,7 +2306,7 @@ class Yt extends _ {
|
|
|
2306
2306
|
e.has(u) || t.push(u), e.set(u, c);
|
|
2307
2307
|
}
|
|
2308
2308
|
const r = t.map((c) => e.get(c)).filter((c) => !!c).sort((c, u) => c.type === d.SESSION_START && u.type !== d.SESSION_START ? -1 : u.type === d.SESSION_START && c.type !== d.SESSION_START ? 1 : c.timestamp - u.timestamp);
|
|
2309
|
-
let
|
|
2309
|
+
let s = {
|
|
2310
2310
|
user_id: this.get("userId"),
|
|
2311
2311
|
session_id: this.get("sessionId"),
|
|
2312
2312
|
device: this.get("device"),
|
|
@@ -2315,13 +2315,13 @@ class Yt extends _ {
|
|
|
2315
2315
|
};
|
|
2316
2316
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2317
2317
|
if (!o && l) {
|
|
2318
|
-
const c = Ke(
|
|
2319
|
-
c !== null && (
|
|
2318
|
+
const c = Ke(s, l, "EventManager");
|
|
2319
|
+
c !== null && (s = c);
|
|
2320
2320
|
}
|
|
2321
|
-
return
|
|
2321
|
+
return s;
|
|
2322
2322
|
}
|
|
2323
2323
|
buildEventPayload(e) {
|
|
2324
|
-
const t = e.type === d.SESSION_START, r = e.page_url ?? this.get("pageUrl"),
|
|
2324
|
+
const t = e.type === d.SESSION_START, r = e.page_url ?? this.get("pageUrl"), s = this.timeManager.now(), i = this.timeManager.validateTimestamp(s);
|
|
2325
2325
|
i.valid || a("warn", "Event timestamp validation failed", {
|
|
2326
2326
|
data: { type: e.type, error: i.error }
|
|
2327
2327
|
});
|
|
@@ -2329,8 +2329,8 @@ class Yt extends _ {
|
|
|
2329
2329
|
id: kt(),
|
|
2330
2330
|
type: e.type,
|
|
2331
2331
|
page_url: r,
|
|
2332
|
-
timestamp:
|
|
2333
|
-
...t && { referrer:
|
|
2332
|
+
timestamp: s,
|
|
2333
|
+
...t && { referrer: this.getExternalReferrer() },
|
|
2334
2334
|
...e.from_page_url && { from_page_url: e.from_page_url },
|
|
2335
2335
|
...e.scroll_data && { scroll_data: e.scroll_data },
|
|
2336
2336
|
...e.click_data && { click_data: e.click_data },
|
|
@@ -2343,7 +2343,7 @@ class Yt extends _ {
|
|
|
2343
2343
|
};
|
|
2344
2344
|
const l = this.get("collectApiUrls"), c = !!l?.custom, u = !!l?.saas, S = c || u, g = c && u, E = this.transformers.beforeSend;
|
|
2345
2345
|
if (E && (!S || c && !g)) {
|
|
2346
|
-
const $ =
|
|
2346
|
+
const $ = ze(o, E, "EventManager");
|
|
2347
2347
|
if ($ === null)
|
|
2348
2348
|
return null;
|
|
2349
2349
|
o = $;
|
|
@@ -2351,15 +2351,15 @@ class Yt extends _ {
|
|
|
2351
2351
|
return o;
|
|
2352
2352
|
}
|
|
2353
2353
|
isDuplicateEvent(e) {
|
|
2354
|
-
const t = Date.now(), r = this.createEventFingerprint(e),
|
|
2355
|
-
return
|
|
2354
|
+
const t = Date.now(), r = this.createEventFingerprint(e), s = this.recentEventFingerprints.get(r);
|
|
2355
|
+
return s && t - s < 1e3 ? (this.recentEventFingerprints.set(r, t), !0) : (this.recentEventFingerprints.set(r, t), this.recentEventFingerprints.size > 1500 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 3e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(r, t), a("debug", "Event fingerprint cache exceeded hard limit, cleared", {
|
|
2356
2356
|
data: { hardLimit: 3e3 }
|
|
2357
2357
|
})), !1);
|
|
2358
2358
|
}
|
|
2359
2359
|
pruneOldFingerprints() {
|
|
2360
2360
|
const e = Date.now(), t = 1e3 * 10;
|
|
2361
|
-
for (const [r,
|
|
2362
|
-
e -
|
|
2361
|
+
for (const [r, s] of this.recentEventFingerprints.entries())
|
|
2362
|
+
e - s > t && this.recentEventFingerprints.delete(r);
|
|
2363
2363
|
a("debug", "Pruned old event fingerprints", {
|
|
2364
2364
|
data: {
|
|
2365
2365
|
remaining: this.recentEventFingerprints.size,
|
|
@@ -2370,8 +2370,8 @@ class Yt extends _ {
|
|
|
2370
2370
|
createEventFingerprint(e) {
|
|
2371
2371
|
let t = `${e.type}_${e.page_url}`;
|
|
2372
2372
|
if (e.click_data) {
|
|
2373
|
-
const r = Math.round((e.click_data.x || 0) / 10) * 10,
|
|
2374
|
-
t += `_click_${r}_${
|
|
2373
|
+
const r = Math.round((e.click_data.x || 0) / 10) * 10, s = Math.round((e.click_data.y || 0) / 10) * 10;
|
|
2374
|
+
t += `_click_${r}_${s}`;
|
|
2375
2375
|
}
|
|
2376
2376
|
return e.scroll_data && (t += `_scroll_${e.scroll_data.depth}_${e.scroll_data.direction}`), e.custom_event && (t += `_custom_${e.custom_event.name}`), e.web_vitals && (t += `_vitals_${e.web_vitals.type}`), e.error_data && (t += `_error_${e.error_data.type}_${e.error_data.message}`), t;
|
|
2377
2377
|
}
|
|
@@ -2380,7 +2380,7 @@ class Yt extends _ {
|
|
|
2380
2380
|
}
|
|
2381
2381
|
addToQueue(e) {
|
|
2382
2382
|
if (this.emitEvent(e), this.eventsQueue.push(e), this.eventsQueue.length > 100) {
|
|
2383
|
-
const t = this.eventsQueue.findIndex((
|
|
2383
|
+
const t = this.eventsQueue.findIndex((s) => s.type !== d.SESSION_START), r = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
|
|
2384
2384
|
a("warn", "Event queue overflow, oldest non-critical event removed", {
|
|
2385
2385
|
data: {
|
|
2386
2386
|
maxLength: 100,
|
|
@@ -2429,10 +2429,10 @@ class Yt extends _ {
|
|
|
2429
2429
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2430
2430
|
}
|
|
2431
2431
|
emitEvent(e) {
|
|
2432
|
-
this.emitter && this.emitter.emit(
|
|
2432
|
+
this.emitter && this.emitter.emit(se.EVENT, e);
|
|
2433
2433
|
}
|
|
2434
2434
|
emitEventsQueue(e) {
|
|
2435
|
-
this.emitter && this.emitter.emit(
|
|
2435
|
+
this.emitter && this.emitter.emit(se.QUEUE, e);
|
|
2436
2436
|
}
|
|
2437
2437
|
/**
|
|
2438
2438
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2456,9 +2456,9 @@ class Yt extends _ {
|
|
|
2456
2456
|
*/
|
|
2457
2457
|
debounce(e, t) {
|
|
2458
2458
|
let r = null;
|
|
2459
|
-
return ((...
|
|
2459
|
+
return ((...s) => {
|
|
2460
2460
|
r !== null && clearTimeout(r), r = setTimeout(() => {
|
|
2461
|
-
e(...
|
|
2461
|
+
e(...s), r = null;
|
|
2462
2462
|
}, t);
|
|
2463
2463
|
});
|
|
2464
2464
|
}
|
|
@@ -2510,10 +2510,10 @@ class Yt extends _ {
|
|
|
2510
2510
|
return this.getInitialCounts();
|
|
2511
2511
|
const t = this.get("userId") || "anonymous", r = Ie(t, e);
|
|
2512
2512
|
try {
|
|
2513
|
-
const
|
|
2514
|
-
if (!
|
|
2513
|
+
const s = localStorage.getItem(r);
|
|
2514
|
+
if (!s)
|
|
2515
2515
|
return this.getInitialCounts();
|
|
2516
|
-
const i = JSON.parse(
|
|
2516
|
+
const i = JSON.parse(s);
|
|
2517
2517
|
return i._timestamp && Date.now() - i._timestamp > we ? (a("debug", "Session counts expired, clearing", {
|
|
2518
2518
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2519
2519
|
}), 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" ? {
|
|
@@ -2528,9 +2528,9 @@ class Yt extends _ {
|
|
|
2528
2528
|
}), localStorage.removeItem(r), a("debug", "Session counts removed due to invalid/corrupted data", {
|
|
2529
2529
|
data: { sessionId: e, parsed: i }
|
|
2530
2530
|
}), this.getInitialCounts());
|
|
2531
|
-
} catch (
|
|
2531
|
+
} catch (s) {
|
|
2532
2532
|
return a("warn", "Failed to load session counts from localStorage", {
|
|
2533
|
-
error:
|
|
2533
|
+
error: s,
|
|
2534
2534
|
data: { sessionId: e }
|
|
2535
2535
|
}), this.getInitialCounts();
|
|
2536
2536
|
}
|
|
@@ -2569,7 +2569,7 @@ class Yt extends _ {
|
|
|
2569
2569
|
return;
|
|
2570
2570
|
}
|
|
2571
2571
|
}
|
|
2572
|
-
const t = this.get("userId") || "anonymous", r = `${I}:${t}:session_counts:`,
|
|
2572
|
+
const t = this.get("userId") || "anonymous", r = `${I}:${t}:session_counts:`, s = [];
|
|
2573
2573
|
for (let i = 0; i < localStorage.length; i++) {
|
|
2574
2574
|
const o = localStorage.key(i);
|
|
2575
2575
|
if (o?.startsWith(r))
|
|
@@ -2577,18 +2577,100 @@ class Yt extends _ {
|
|
|
2577
2577
|
const l = localStorage.getItem(o);
|
|
2578
2578
|
if (l) {
|
|
2579
2579
|
const c = JSON.parse(l);
|
|
2580
|
-
c._timestamp && Date.now() - c._timestamp > we &&
|
|
2580
|
+
c._timestamp && Date.now() - c._timestamp > we && s.push(o);
|
|
2581
2581
|
}
|
|
2582
2582
|
} catch {
|
|
2583
2583
|
}
|
|
2584
2584
|
}
|
|
2585
|
-
|
|
2585
|
+
s.forEach((i) => {
|
|
2586
2586
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2587
|
-
}),
|
|
2587
|
+
}), s.length > 0 && a("info", `Cleaned up ${s.length} expired session counts entries`), localStorage.setItem(ye, Date.now().toString());
|
|
2588
2588
|
} catch (e) {
|
|
2589
2589
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2590
2590
|
}
|
|
2591
2591
|
}
|
|
2592
|
+
/**
|
|
2593
|
+
* Returns the referrer if it's external, or 'Direct' if internal/empty.
|
|
2594
|
+
*
|
|
2595
|
+
* **Purpose**: Filter out internal referrers (same domain) to ensure
|
|
2596
|
+
* accurate traffic source attribution. Internal referrers occur when:
|
|
2597
|
+
* - Session expires and user navigates within the same site
|
|
2598
|
+
* - User opens new tab from an internal link
|
|
2599
|
+
* - Page refresh after session timeout
|
|
2600
|
+
*
|
|
2601
|
+
* **Logic**:
|
|
2602
|
+
* - Empty referrer → 'Direct'
|
|
2603
|
+
* - Referrer from same domain or subdomain → 'Direct' (internal navigation)
|
|
2604
|
+
* - External referrer → Returns original referrer
|
|
2605
|
+
*
|
|
2606
|
+
* **Subdomain Detection**:
|
|
2607
|
+
* - `www.example.com` → `example.com` ✓ (internal)
|
|
2608
|
+
* - `blog.example.com` → `example.com` ✓ (internal)
|
|
2609
|
+
* - `example.com` → `www.example.com` ✓ (internal)
|
|
2610
|
+
*
|
|
2611
|
+
* @returns External referrer URL or 'Direct'
|
|
2612
|
+
*
|
|
2613
|
+
* @internal
|
|
2614
|
+
*/
|
|
2615
|
+
getExternalReferrer() {
|
|
2616
|
+
const e = document.referrer;
|
|
2617
|
+
if (!e)
|
|
2618
|
+
return "Direct";
|
|
2619
|
+
try {
|
|
2620
|
+
const t = new URL(e).hostname.toLowerCase(), r = window.location.hostname.toLowerCase();
|
|
2621
|
+
return this.isSameDomain(t, r) ? "Direct" : e;
|
|
2622
|
+
} catch (t) {
|
|
2623
|
+
return a("debug", "Failed to parse referrer URL, using raw value", { error: t, data: { referrer: e } }), e;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* Checks if two hostnames belong to the same domain (including subdomains).
|
|
2628
|
+
* Extracts root domain and compares to handle cross-subdomain navigation.
|
|
2629
|
+
*
|
|
2630
|
+
* @example
|
|
2631
|
+
* isSameDomain('www.example.com', 'example.com') // true
|
|
2632
|
+
* isSameDomain('app.example.com', 'www.example.com') // true
|
|
2633
|
+
* isSameDomain('example.co.uk', 'app.example.co.uk') // true
|
|
2634
|
+
*
|
|
2635
|
+
* @param hostname1 - First hostname (e.g., 'www.example.com')
|
|
2636
|
+
* @param hostname2 - Second hostname (e.g., 'app.example.com')
|
|
2637
|
+
* @returns true if same root domain
|
|
2638
|
+
*
|
|
2639
|
+
* @internal
|
|
2640
|
+
*/
|
|
2641
|
+
isSameDomain(e, t) {
|
|
2642
|
+
return e === t ? !0 : this.getRootDomain(e) === this.getRootDomain(t);
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Extracts the root (registrable) domain from a hostname.
|
|
2646
|
+
* Handles both standard TLDs (.com, .org) and compound TLDs (.co.uk, .com.br).
|
|
2647
|
+
*
|
|
2648
|
+
* @example
|
|
2649
|
+
* getRootDomain('www.example.com') // 'example.com'
|
|
2650
|
+
* getRootDomain('app.blog.example.com') // 'example.com'
|
|
2651
|
+
* getRootDomain('shop.example.co.uk') // 'example.co.uk'
|
|
2652
|
+
*
|
|
2653
|
+
* @internal
|
|
2654
|
+
*/
|
|
2655
|
+
getRootDomain(e) {
|
|
2656
|
+
const t = e.toLowerCase().split(".");
|
|
2657
|
+
if (t.length <= 2)
|
|
2658
|
+
return e.toLowerCase();
|
|
2659
|
+
const r = [
|
|
2660
|
+
"co.uk",
|
|
2661
|
+
"org.uk",
|
|
2662
|
+
"com.au",
|
|
2663
|
+
"net.au",
|
|
2664
|
+
"com.br",
|
|
2665
|
+
"co.nz",
|
|
2666
|
+
"co.jp",
|
|
2667
|
+
"com.mx",
|
|
2668
|
+
"co.in",
|
|
2669
|
+
"com.cn",
|
|
2670
|
+
"co.za"
|
|
2671
|
+
], s = t.slice(-2).join(".");
|
|
2672
|
+
return r.includes(s) ? t.slice(-3).join(".") : t.slice(-2).join(".");
|
|
2673
|
+
}
|
|
2592
2674
|
/**
|
|
2593
2675
|
* Persists current session event counts to localStorage (debounced).
|
|
2594
2676
|
*
|
|
@@ -2620,15 +2702,15 @@ class Yt extends _ {
|
|
|
2620
2702
|
saveSessionCounts(e) {
|
|
2621
2703
|
const t = this.get("userId") || "anonymous", r = Ie(t, e);
|
|
2622
2704
|
try {
|
|
2623
|
-
const
|
|
2705
|
+
const s = {
|
|
2624
2706
|
...this.sessionEventCounts,
|
|
2625
2707
|
_timestamp: Date.now(),
|
|
2626
2708
|
_version: 1
|
|
2627
2709
|
};
|
|
2628
|
-
localStorage.setItem(r, JSON.stringify(
|
|
2629
|
-
} catch (
|
|
2710
|
+
localStorage.setItem(r, JSON.stringify(s));
|
|
2711
|
+
} catch (s) {
|
|
2630
2712
|
a("warn", "Failed to persist session counts to localStorage", {
|
|
2631
|
-
error:
|
|
2713
|
+
error: s,
|
|
2632
2714
|
data: { sessionId: e }
|
|
2633
2715
|
});
|
|
2634
2716
|
}
|
|
@@ -2686,8 +2768,8 @@ class Zt extends _ {
|
|
|
2686
2768
|
}
|
|
2687
2769
|
const e = this.getProjectId();
|
|
2688
2770
|
this.broadcastChannel = new BroadcastChannel(ut(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2689
|
-
const { action: r, sessionId:
|
|
2690
|
-
o === e && (r === "session_start" &&
|
|
2771
|
+
const { action: r, sessionId: s, timestamp: i, projectId: o } = t.data ?? {};
|
|
2772
|
+
o === e && (r === "session_start" && s && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", s), this.persistSession(s, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2691
2773
|
};
|
|
2692
2774
|
}
|
|
2693
2775
|
shareSession(e) {
|
|
@@ -3052,8 +3134,8 @@ class tr extends _ {
|
|
|
3052
3134
|
const e = window.location.href, t = le(e, this.get("config").sensitiveQueryParams);
|
|
3053
3135
|
if (this.get("pageUrl") === t)
|
|
3054
3136
|
return;
|
|
3055
|
-
const r = Date.now(),
|
|
3056
|
-
if (r - this.lastPageViewTime <
|
|
3137
|
+
const r = Date.now(), s = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
3138
|
+
if (r - this.lastPageViewTime < s)
|
|
3057
3139
|
return;
|
|
3058
3140
|
this.lastPageViewTime = r, this.onTrack();
|
|
3059
3141
|
const i = this.get("pageUrl");
|
|
@@ -3075,9 +3157,9 @@ class tr extends _ {
|
|
|
3075
3157
|
}), this.onTrack();
|
|
3076
3158
|
}
|
|
3077
3159
|
extractPageViewData() {
|
|
3078
|
-
const { pathname: e, search: t, hash: r } = window.location, { referrer:
|
|
3079
|
-
return !
|
|
3080
|
-
...
|
|
3160
|
+
const { pathname: e, search: t, hash: r } = window.location, { referrer: s } = document, { title: i } = document;
|
|
3161
|
+
return !s && !i && !e && !t && !r ? void 0 : {
|
|
3162
|
+
...s && { referrer: s },
|
|
3081
3163
|
...i && { title: i },
|
|
3082
3164
|
...e && { pathname: e },
|
|
3083
3165
|
...t && { search: t },
|
|
@@ -3108,17 +3190,17 @@ class rr extends _ {
|
|
|
3108
3190
|
*/
|
|
3109
3191
|
startTracking() {
|
|
3110
3192
|
this.clickHandler || (this.clickHandler = (e) => {
|
|
3111
|
-
const t = e, r = t.target,
|
|
3112
|
-
if (!
|
|
3193
|
+
const t = e, r = t.target, s = typeof HTMLElement < "u" && r instanceof HTMLElement ? r : typeof HTMLElement < "u" && r instanceof Node && r.parentElement instanceof HTMLElement ? r.parentElement : null;
|
|
3194
|
+
if (!s) {
|
|
3113
3195
|
a("debug", "Click target not found or not an element");
|
|
3114
3196
|
return;
|
|
3115
3197
|
}
|
|
3116
|
-
if (this.shouldIgnoreElement(
|
|
3198
|
+
if (this.shouldIgnoreElement(s))
|
|
3117
3199
|
return;
|
|
3118
3200
|
const i = this.get("config")?.clickThrottleMs ?? 300;
|
|
3119
|
-
if (i > 0 && !this.checkClickThrottle(
|
|
3201
|
+
if (i > 0 && !this.checkClickThrottle(s, i))
|
|
3120
3202
|
return;
|
|
3121
|
-
const o = this.findTrackingElement(
|
|
3203
|
+
const o = this.findTrackingElement(s), l = this.getRelevantClickElement(s), c = this.calculateClickCoordinates(t, s);
|
|
3122
3204
|
if (o) {
|
|
3123
3205
|
const S = this.extractTrackingData(o);
|
|
3124
3206
|
if (S) {
|
|
@@ -3132,7 +3214,7 @@ class rr extends _ {
|
|
|
3132
3214
|
});
|
|
3133
3215
|
}
|
|
3134
3216
|
}
|
|
3135
|
-
const u = this.generateClickData(
|
|
3217
|
+
const u = this.generateClickData(s, l, c);
|
|
3136
3218
|
this.eventManager.track({
|
|
3137
3219
|
type: d.CLICK,
|
|
3138
3220
|
click_data: u
|
|
@@ -3156,15 +3238,15 @@ class rr extends _ {
|
|
|
3156
3238
|
* Returns true if the click should be tracked, false if throttled
|
|
3157
3239
|
*/
|
|
3158
3240
|
checkClickThrottle(e, t) {
|
|
3159
|
-
const r = this.getElementSignature(e),
|
|
3160
|
-
this.pruneThrottleCache(
|
|
3241
|
+
const r = this.getElementSignature(e), s = Date.now();
|
|
3242
|
+
this.pruneThrottleCache(s);
|
|
3161
3243
|
const i = this.lastClickTimes.get(r);
|
|
3162
|
-
return i !== void 0 &&
|
|
3244
|
+
return i !== void 0 && s - i < t ? (a("debug", "ClickHandler: Click suppressed by throttle", {
|
|
3163
3245
|
data: {
|
|
3164
3246
|
signature: r,
|
|
3165
|
-
throttleRemaining: t - (
|
|
3247
|
+
throttleRemaining: t - (s - i)
|
|
3166
3248
|
}
|
|
3167
|
-
}), !1) : (this.lastClickTimes.set(r,
|
|
3249
|
+
}), !1) : (this.lastClickTimes.set(r, s), !0);
|
|
3168
3250
|
}
|
|
3169
3251
|
/**
|
|
3170
3252
|
* Prunes stale entries from the throttle cache to prevent memory leaks
|
|
@@ -3176,10 +3258,10 @@ class rr extends _ {
|
|
|
3176
3258
|
return;
|
|
3177
3259
|
this.lastPruneTime = e;
|
|
3178
3260
|
const t = e - 3e5;
|
|
3179
|
-
for (const [r,
|
|
3180
|
-
|
|
3261
|
+
for (const [r, s] of this.lastClickTimes.entries())
|
|
3262
|
+
s < t && this.lastClickTimes.delete(r);
|
|
3181
3263
|
if (this.lastClickTimes.size > 1e3) {
|
|
3182
|
-
const r = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]),
|
|
3264
|
+
const r = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]), s = this.lastClickTimes.size - 1e3, i = r.slice(0, s);
|
|
3183
3265
|
for (const [o] of i)
|
|
3184
3266
|
this.lastClickTimes.delete(o);
|
|
3185
3267
|
a("debug", "ClickHandler: Pruned throttle cache", {
|
|
@@ -3210,12 +3292,12 @@ class rr extends _ {
|
|
|
3210
3292
|
const t = [];
|
|
3211
3293
|
let r = e;
|
|
3212
3294
|
for (; r && r !== document.body; ) {
|
|
3213
|
-
let
|
|
3295
|
+
let s = r.tagName.toLowerCase();
|
|
3214
3296
|
if (r.className) {
|
|
3215
3297
|
const i = r.className.split(" ")[0];
|
|
3216
|
-
i && (
|
|
3298
|
+
i && (s += `.${i}`);
|
|
3217
3299
|
}
|
|
3218
|
-
t.unshift(
|
|
3300
|
+
t.unshift(s), r = r.parentElement;
|
|
3219
3301
|
}
|
|
3220
3302
|
return t.join(">") || "unknown";
|
|
3221
3303
|
}
|
|
@@ -3223,7 +3305,7 @@ class rr extends _ {
|
|
|
3223
3305
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3224
3306
|
}
|
|
3225
3307
|
getRelevantClickElement(e) {
|
|
3226
|
-
for (const t of
|
|
3308
|
+
for (const t of st)
|
|
3227
3309
|
try {
|
|
3228
3310
|
if (e.matches(t))
|
|
3229
3311
|
return e;
|
|
@@ -3251,8 +3333,8 @@ class rr extends _ {
|
|
|
3251
3333
|
return Math.max(0, Math.min(1, Number(e.toFixed(3))));
|
|
3252
3334
|
}
|
|
3253
3335
|
calculateClickCoordinates(e, t) {
|
|
3254
|
-
const r = t.getBoundingClientRect(),
|
|
3255
|
-
return { x:
|
|
3336
|
+
const r = t.getBoundingClientRect(), s = e.clientX, i = e.clientY, o = r.width > 0 ? this.clamp((s - r.left) / r.width) : 0, l = r.height > 0 ? this.clamp((i - r.top) / r.height) : 0;
|
|
3337
|
+
return { x: s, y: i, relativeX: o, relativeY: l };
|
|
3256
3338
|
}
|
|
3257
3339
|
extractTrackingData(e) {
|
|
3258
3340
|
const t = e.getAttribute(`${w}-name`), r = e.getAttribute(`${w}-value`);
|
|
@@ -3264,9 +3346,9 @@ class rr extends _ {
|
|
|
3264
3346
|
};
|
|
3265
3347
|
}
|
|
3266
3348
|
generateClickData(e, t, r) {
|
|
3267
|
-
const { x:
|
|
3349
|
+
const { x: s, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
3268
3350
|
return {
|
|
3269
|
-
x:
|
|
3351
|
+
x: s,
|
|
3270
3352
|
y: i,
|
|
3271
3353
|
relativeX: o,
|
|
3272
3354
|
relativeY: l,
|
|
@@ -3304,17 +3386,17 @@ class rr extends _ {
|
|
|
3304
3386
|
sanitizeText(e) {
|
|
3305
3387
|
let t = e;
|
|
3306
3388
|
for (const r of Be) {
|
|
3307
|
-
const
|
|
3308
|
-
t = t.replace(
|
|
3389
|
+
const s = new RegExp(r.source, r.flags);
|
|
3390
|
+
t = t.replace(s, "[REDACTED]");
|
|
3309
3391
|
}
|
|
3310
3392
|
return t;
|
|
3311
3393
|
}
|
|
3312
3394
|
getRelevantText(e, t) {
|
|
3313
|
-
const r = e.textContent?.trim() ?? "",
|
|
3314
|
-
if (!r && !
|
|
3395
|
+
const r = e.textContent?.trim() ?? "", s = t.textContent?.trim() ?? "";
|
|
3396
|
+
if (!r && !s)
|
|
3315
3397
|
return "";
|
|
3316
3398
|
let i = "";
|
|
3317
|
-
return r && r.length <= 255 ? i = r :
|
|
3399
|
+
return r && r.length <= 255 ? i = r : s.length <= 255 ? i = s : i = s.slice(0, 252) + "...", this.sanitizeText(i);
|
|
3318
3400
|
}
|
|
3319
3401
|
extractElementAttributes(e) {
|
|
3320
3402
|
const t = [
|
|
@@ -3329,9 +3411,9 @@ class rr extends _ {
|
|
|
3329
3411
|
"alt",
|
|
3330
3412
|
"role"
|
|
3331
3413
|
], r = {};
|
|
3332
|
-
for (const
|
|
3333
|
-
const i = e.getAttribute(
|
|
3334
|
-
i && (r[
|
|
3414
|
+
for (const s of t) {
|
|
3415
|
+
const i = e.getAttribute(s);
|
|
3416
|
+
i && (r[s] = i);
|
|
3335
3417
|
}
|
|
3336
3418
|
return r;
|
|
3337
3419
|
}
|
|
@@ -3342,7 +3424,7 @@ class rr extends _ {
|
|
|
3342
3424
|
};
|
|
3343
3425
|
}
|
|
3344
3426
|
}
|
|
3345
|
-
class
|
|
3427
|
+
class nr extends _ {
|
|
3346
3428
|
eventManager;
|
|
3347
3429
|
containers = [];
|
|
3348
3430
|
limitWarningLogged = !1;
|
|
@@ -3389,8 +3471,8 @@ class sr extends _ {
|
|
|
3389
3471
|
const t = this.findScrollableElements();
|
|
3390
3472
|
if (this.isWindowScrollable() && this.setupScrollContainer(window, "window"), t.length > 0) {
|
|
3391
3473
|
for (const r of t) {
|
|
3392
|
-
const
|
|
3393
|
-
this.setupScrollContainer(r,
|
|
3474
|
+
const s = this.getElementSelector(r);
|
|
3475
|
+
this.setupScrollContainer(r, s);
|
|
3394
3476
|
}
|
|
3395
3477
|
this.applyPrimaryScrollSelectorIfConfigured();
|
|
3396
3478
|
return;
|
|
@@ -3411,8 +3493,8 @@ class sr extends _ {
|
|
|
3411
3493
|
if (!document.body)
|
|
3412
3494
|
return [];
|
|
3413
3495
|
const e = [], t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
3414
|
-
acceptNode: (
|
|
3415
|
-
const i =
|
|
3496
|
+
acceptNode: (s) => {
|
|
3497
|
+
const i = s;
|
|
3416
3498
|
if (!i.isConnected || !i.offsetParent)
|
|
3417
3499
|
return NodeFilter.FILTER_SKIP;
|
|
3418
3500
|
const o = getComputedStyle(i);
|
|
@@ -3421,8 +3503,8 @@ class sr extends _ {
|
|
|
3421
3503
|
});
|
|
3422
3504
|
let r;
|
|
3423
3505
|
for (; (r = t.nextNode()) && e.length < 10; ) {
|
|
3424
|
-
const
|
|
3425
|
-
this.isElementScrollable(
|
|
3506
|
+
const s = r;
|
|
3507
|
+
this.isElementScrollable(s) && e.push(s);
|
|
3426
3508
|
}
|
|
3427
3509
|
return e;
|
|
3428
3510
|
}
|
|
@@ -3433,7 +3515,7 @@ class sr extends _ {
|
|
|
3433
3515
|
if (t.id)
|
|
3434
3516
|
return `#${t.id}`;
|
|
3435
3517
|
if (t.className && typeof t.className == "string") {
|
|
3436
|
-
const r = t.className.split(" ").filter((
|
|
3518
|
+
const r = t.className.split(" ").filter((s) => s.trim())[0];
|
|
3437
3519
|
if (r)
|
|
3438
3520
|
return `.${r}`;
|
|
3439
3521
|
}
|
|
@@ -3445,15 +3527,15 @@ class sr extends _ {
|
|
|
3445
3527
|
setupScrollContainer(e, t) {
|
|
3446
3528
|
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3447
3529
|
return;
|
|
3448
|
-
const
|
|
3449
|
-
|
|
3530
|
+
const s = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3531
|
+
s,
|
|
3450
3532
|
this.getScrollHeight(e),
|
|
3451
3533
|
this.getViewportHeight(e)
|
|
3452
3534
|
), o = this.determineIfPrimary(e), l = {
|
|
3453
3535
|
element: e,
|
|
3454
3536
|
selector: t,
|
|
3455
3537
|
isPrimary: o,
|
|
3456
|
-
lastScrollPos:
|
|
3538
|
+
lastScrollPos: s,
|
|
3457
3539
|
lastDepth: i,
|
|
3458
3540
|
lastDirection: X.DOWN,
|
|
3459
3541
|
lastEventTime: 0,
|
|
@@ -3477,8 +3559,8 @@ class sr extends _ {
|
|
|
3477
3559
|
if (!this.shouldEmitScrollEvent(e, t, r))
|
|
3478
3560
|
return;
|
|
3479
3561
|
e.lastEventTime = r, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3480
|
-
const
|
|
3481
|
-
this.set("scrollEventCount",
|
|
3562
|
+
const s = this.get("scrollEventCount") ?? 0;
|
|
3563
|
+
this.set("scrollEventCount", s + 1), this.eventManager.track({
|
|
3482
3564
|
type: d.SCROLL,
|
|
3483
3565
|
scroll_data: {
|
|
3484
3566
|
...t,
|
|
@@ -3519,16 +3601,16 @@ class sr extends _ {
|
|
|
3519
3601
|
calculateScrollDepth(e, t, r) {
|
|
3520
3602
|
if (t <= r)
|
|
3521
3603
|
return 0;
|
|
3522
|
-
const
|
|
3523
|
-
return Math.min(100, Math.max(0, Math.floor(e /
|
|
3604
|
+
const s = t - r;
|
|
3605
|
+
return Math.min(100, Math.max(0, Math.floor(e / s * 100)));
|
|
3524
3606
|
}
|
|
3525
3607
|
calculateScrollData(e) {
|
|
3526
|
-
const { element: t, lastScrollPos: r, lastEventTime:
|
|
3608
|
+
const { element: t, lastScrollPos: r, lastEventTime: s } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - r);
|
|
3527
3609
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3528
3610
|
return null;
|
|
3529
3611
|
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), S = this.getScrollDirection(i, r), g = this.calculateScrollDepth(i, u, c);
|
|
3530
3612
|
let E;
|
|
3531
|
-
|
|
3613
|
+
s > 0 ? E = o - s : e.firstScrollEventTime !== null ? E = o - e.firstScrollEventTime : E = 250;
|
|
3532
3614
|
const p = Math.round(l / E * 1e3);
|
|
3533
3615
|
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3534
3616
|
depth: g,
|
|
@@ -3547,30 +3629,30 @@ class sr extends _ {
|
|
|
3547
3629
|
return e === window ? document.documentElement.scrollHeight : e.scrollHeight;
|
|
3548
3630
|
}
|
|
3549
3631
|
isElementScrollable(e) {
|
|
3550
|
-
const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll",
|
|
3551
|
-
return r &&
|
|
3632
|
+
const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll", s = e.scrollHeight > e.clientHeight;
|
|
3633
|
+
return r && s;
|
|
3552
3634
|
}
|
|
3553
3635
|
applyPrimaryScrollSelector(e) {
|
|
3554
3636
|
let t;
|
|
3555
3637
|
if (e === "window")
|
|
3556
3638
|
t = window;
|
|
3557
3639
|
else {
|
|
3558
|
-
const
|
|
3559
|
-
if (!(
|
|
3640
|
+
const s = document.querySelector(e);
|
|
3641
|
+
if (!(s instanceof HTMLElement)) {
|
|
3560
3642
|
a("debug", `Selector "${e}" did not match an HTMLElement`);
|
|
3561
3643
|
return;
|
|
3562
3644
|
}
|
|
3563
|
-
t =
|
|
3645
|
+
t = s;
|
|
3564
3646
|
}
|
|
3565
|
-
this.containers.forEach((
|
|
3566
|
-
this.updateContainerPrimary(
|
|
3567
|
-
}), !this.containers.some((
|
|
3647
|
+
this.containers.forEach((s) => {
|
|
3648
|
+
this.updateContainerPrimary(s, s.element === t);
|
|
3649
|
+
}), !this.containers.some((s) => s.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
|
|
3568
3650
|
}
|
|
3569
3651
|
updateContainerPrimary(e, t) {
|
|
3570
3652
|
e.isPrimary = t;
|
|
3571
3653
|
}
|
|
3572
3654
|
}
|
|
3573
|
-
class
|
|
3655
|
+
class sr extends _ {
|
|
3574
3656
|
eventManager;
|
|
3575
3657
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3576
3658
|
observer = null;
|
|
@@ -3622,8 +3704,8 @@ class nr extends _ {
|
|
|
3622
3704
|
let t = this.trackedElements.size;
|
|
3623
3705
|
for (const r of this.config.elements)
|
|
3624
3706
|
try {
|
|
3625
|
-
const
|
|
3626
|
-
for (const i of Array.from(
|
|
3707
|
+
const s = document.querySelectorAll(r.selector);
|
|
3708
|
+
for (const i of Array.from(s)) {
|
|
3627
3709
|
if (t >= e) {
|
|
3628
3710
|
a("debug", "ViewportHandler: Maximum tracked elements reached", {
|
|
3629
3711
|
data: {
|
|
@@ -3644,8 +3726,8 @@ class nr extends _ {
|
|
|
3644
3726
|
lastFiredTime: null
|
|
3645
3727
|
}), this.observer?.observe(i), t++);
|
|
3646
3728
|
}
|
|
3647
|
-
} catch (
|
|
3648
|
-
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error:
|
|
3729
|
+
} catch (s) {
|
|
3730
|
+
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error: s });
|
|
3649
3731
|
}
|
|
3650
3732
|
a("debug", "ViewportHandler: Elements tracked", {
|
|
3651
3733
|
data: { count: t, limit: e }
|
|
@@ -3658,11 +3740,11 @@ class nr extends _ {
|
|
|
3658
3740
|
if (!this.config) return;
|
|
3659
3741
|
const t = this.config.minDwellTime ?? 1e3;
|
|
3660
3742
|
for (const r of e) {
|
|
3661
|
-
const
|
|
3662
|
-
|
|
3743
|
+
const s = this.trackedElements.get(r.target);
|
|
3744
|
+
s && (r.isIntersecting ? s.startTime === null && (s.startTime = performance.now(), s.timeoutId = window.setTimeout(() => {
|
|
3663
3745
|
const i = Math.round(r.intersectionRatio * 100) / 100;
|
|
3664
|
-
this.fireViewportEvent(
|
|
3665
|
-
}, t)) :
|
|
3746
|
+
this.fireViewportEvent(s, i);
|
|
3747
|
+
}, t)) : s.startTime !== null && (s.timeoutId !== null && (window.clearTimeout(s.timeoutId), s.timeoutId = null), s.startTime = null));
|
|
3666
3748
|
}
|
|
3667
3749
|
};
|
|
3668
3750
|
/**
|
|
@@ -3673,12 +3755,12 @@ class nr extends _ {
|
|
|
3673
3755
|
const r = Math.round(performance.now() - e.startTime);
|
|
3674
3756
|
if (e.element.hasAttribute(`${w}-ignore`))
|
|
3675
3757
|
return;
|
|
3676
|
-
const
|
|
3677
|
-
if (e.lastFiredTime !== null && i - e.lastFiredTime <
|
|
3758
|
+
const s = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3759
|
+
if (e.lastFiredTime !== null && i - e.lastFiredTime < s) {
|
|
3678
3760
|
a("debug", "ViewportHandler: Event suppressed by cooldown period", {
|
|
3679
3761
|
data: {
|
|
3680
3762
|
selector: e.selector,
|
|
3681
|
-
cooldownRemaining:
|
|
3763
|
+
cooldownRemaining: s - (i - e.lastFiredTime)
|
|
3682
3764
|
}
|
|
3683
3765
|
}), e.startTime = null, e.timeoutId = null;
|
|
3684
3766
|
return;
|
|
@@ -3723,8 +3805,8 @@ class nr extends _ {
|
|
|
3723
3805
|
cleanupRemovedNodes(e) {
|
|
3724
3806
|
e.forEach((t) => {
|
|
3725
3807
|
if (t.nodeType !== 1) return;
|
|
3726
|
-
const r = t,
|
|
3727
|
-
|
|
3808
|
+
const r = t, s = this.trackedElements.get(r);
|
|
3809
|
+
s && (s.timeoutId !== null && window.clearTimeout(s.timeoutId), this.observer?.unobserve(r), this.trackedElements.delete(r)), Array.from(this.trackedElements.keys()).filter((o) => r.contains(o)).forEach((o) => {
|
|
3728
3810
|
const l = this.trackedElements.get(o);
|
|
3729
3811
|
l && l.timeoutId !== null && window.clearTimeout(l.timeoutId), this.observer?.unobserve(o), this.trackedElements.delete(o);
|
|
3730
3812
|
});
|
|
@@ -3911,8 +3993,8 @@ class ir {
|
|
|
3911
3993
|
} catch {
|
|
3912
3994
|
}
|
|
3913
3995
|
}), !0;
|
|
3914
|
-
const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"],
|
|
3915
|
-
return
|
|
3996
|
+
const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], s = e.filter((i) => !r.some((o) => i.startsWith(o)));
|
|
3997
|
+
return s.length > 0 ? (s.slice(0, 5).forEach((o) => {
|
|
3916
3998
|
try {
|
|
3917
3999
|
this.storage.removeItem(o);
|
|
3918
4000
|
} catch {
|
|
@@ -4067,7 +4149,7 @@ class or extends _ {
|
|
|
4067
4149
|
this.reportTTFB(), this.safeObserve(
|
|
4068
4150
|
"largest-contentful-paint",
|
|
4069
4151
|
(r) => {
|
|
4070
|
-
const
|
|
4152
|
+
const s = r.getEntries(), i = s[s.length - 1];
|
|
4071
4153
|
i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(2)) });
|
|
4072
4154
|
},
|
|
4073
4155
|
{ type: "largest-contentful-paint", buffered: !0 },
|
|
@@ -4077,8 +4159,8 @@ class or extends _ {
|
|
|
4077
4159
|
this.safeObserve(
|
|
4078
4160
|
"layout-shift",
|
|
4079
4161
|
(r) => {
|
|
4080
|
-
const
|
|
4081
|
-
|
|
4162
|
+
const s = this.getNavigationId();
|
|
4163
|
+
s !== t && (e = 0, t = s);
|
|
4082
4164
|
const i = r.getEntries();
|
|
4083
4165
|
for (const o of i) {
|
|
4084
4166
|
if (o.hadRecentInput === !0)
|
|
@@ -4092,32 +4174,32 @@ class or extends _ {
|
|
|
4092
4174
|
), this.safeObserve(
|
|
4093
4175
|
"paint",
|
|
4094
4176
|
(r) => {
|
|
4095
|
-
for (const
|
|
4096
|
-
|
|
4177
|
+
for (const s of r.getEntries())
|
|
4178
|
+
s.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(s.startTime.toFixed(2)) });
|
|
4097
4179
|
},
|
|
4098
4180
|
{ type: "paint", buffered: !0 },
|
|
4099
4181
|
!0
|
|
4100
4182
|
), this.safeObserve(
|
|
4101
4183
|
"event",
|
|
4102
4184
|
(r) => {
|
|
4103
|
-
let
|
|
4185
|
+
let s = 0;
|
|
4104
4186
|
const i = r.getEntries();
|
|
4105
4187
|
for (const o of i) {
|
|
4106
4188
|
const l = (o.processingEnd ?? 0) - (o.startTime ?? 0);
|
|
4107
|
-
|
|
4189
|
+
s = Math.max(s, l);
|
|
4108
4190
|
}
|
|
4109
|
-
|
|
4191
|
+
s > 0 && this.sendVital({ type: "INP", value: Number(s.toFixed(2)) });
|
|
4110
4192
|
},
|
|
4111
4193
|
{ type: "event", buffered: !0 }
|
|
4112
4194
|
);
|
|
4113
4195
|
}
|
|
4114
4196
|
async initWebVitals() {
|
|
4115
4197
|
try {
|
|
4116
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB:
|
|
4198
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() => Nr), o = (l) => (c) => {
|
|
4117
4199
|
const u = Number(c.value.toFixed(2));
|
|
4118
4200
|
this.sendVital({ type: l, value: u });
|
|
4119
4201
|
};
|
|
4120
|
-
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }),
|
|
4202
|
+
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }), s(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
4121
4203
|
} catch (e) {
|
|
4122
4204
|
a("debug", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
|
|
4123
4205
|
}
|
|
@@ -4139,8 +4221,8 @@ class or extends _ {
|
|
|
4139
4221
|
(e) => {
|
|
4140
4222
|
const t = e.getEntries();
|
|
4141
4223
|
for (const r of t) {
|
|
4142
|
-
const
|
|
4143
|
-
i - this.lastLongTaskSentAt >= Mt && (this.shouldSendVital("LONG_TASK",
|
|
4224
|
+
const s = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4225
|
+
i - this.lastLongTaskSentAt >= Mt && (this.shouldSendVital("LONG_TASK", s) && this.trackWebVital("LONG_TASK", s), this.lastLongTaskSentAt = i);
|
|
4144
4226
|
}
|
|
4145
4227
|
},
|
|
4146
4228
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4202,8 +4284,8 @@ class or extends _ {
|
|
|
4202
4284
|
const e = performance.getEntriesByType("navigation")[0];
|
|
4203
4285
|
if (!e)
|
|
4204
4286
|
return null;
|
|
4205
|
-
const t = e.startTime || performance.now(), r = ++this.navigationCounter,
|
|
4206
|
-
return r > 1 ? `${
|
|
4287
|
+
const t = e.startTime || performance.now(), r = ++this.navigationCounter, s = `${t.toFixed(2)}_${window.location.pathname}`;
|
|
4288
|
+
return r > 1 ? `${s}_${r}` : s;
|
|
4207
4289
|
} catch (e) {
|
|
4208
4290
|
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
4209
4291
|
}
|
|
@@ -4213,7 +4295,7 @@ class or extends _ {
|
|
|
4213
4295
|
const t = PerformanceObserver.supportedEntryTypes;
|
|
4214
4296
|
return !t || t.includes(e);
|
|
4215
4297
|
}
|
|
4216
|
-
safeObserve(e, t, r,
|
|
4298
|
+
safeObserve(e, t, r, s = !1) {
|
|
4217
4299
|
try {
|
|
4218
4300
|
if (!this.isObserverSupported(e))
|
|
4219
4301
|
return !1;
|
|
@@ -4226,13 +4308,13 @@ class or extends _ {
|
|
|
4226
4308
|
data: { type: e }
|
|
4227
4309
|
});
|
|
4228
4310
|
}
|
|
4229
|
-
if (
|
|
4311
|
+
if (s)
|
|
4230
4312
|
try {
|
|
4231
4313
|
l.disconnect();
|
|
4232
4314
|
} catch {
|
|
4233
4315
|
}
|
|
4234
4316
|
});
|
|
4235
|
-
return i.observe(r ?? { type: e, buffered: !0 }),
|
|
4317
|
+
return i.observe(r ?? { type: e, buffered: !0 }), s || this.observers.push(i), !0;
|
|
4236
4318
|
} catch (i) {
|
|
4237
4319
|
return a("debug", "Failed to create performance observer", {
|
|
4238
4320
|
error: i,
|
|
@@ -4336,24 +4418,24 @@ class ar extends _ {
|
|
|
4336
4418
|
sanitize(e) {
|
|
4337
4419
|
let t = e.length > Le ? e.slice(0, Le) + "..." : e;
|
|
4338
4420
|
for (const r of Be) {
|
|
4339
|
-
const
|
|
4340
|
-
t = t.replace(
|
|
4421
|
+
const s = new RegExp(r.source, r.flags);
|
|
4422
|
+
t = t.replace(s, "[REDACTED]");
|
|
4341
4423
|
}
|
|
4342
4424
|
return t;
|
|
4343
4425
|
}
|
|
4344
4426
|
shouldSuppressError(e, t) {
|
|
4345
|
-
const r = Date.now(),
|
|
4346
|
-
return i && r - i < Me ? (this.recentErrors.set(
|
|
4427
|
+
const r = Date.now(), s = `${e}:${t}`, i = this.recentErrors.get(s);
|
|
4428
|
+
return i && r - i < Me ? (this.recentErrors.set(s, r), !0) : (this.recentErrors.set(s, r), this.recentErrors.size > wt ? (this.recentErrors.clear(), this.recentErrors.set(s, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4347
4429
|
}
|
|
4348
4430
|
pruneOldErrors() {
|
|
4349
4431
|
const e = Date.now();
|
|
4350
|
-
for (const [
|
|
4351
|
-
e - i > Me && this.recentErrors.delete(
|
|
4432
|
+
for (const [s, i] of this.recentErrors.entries())
|
|
4433
|
+
e - i > Me && this.recentErrors.delete(s);
|
|
4352
4434
|
if (this.recentErrors.size <= Q)
|
|
4353
4435
|
return;
|
|
4354
|
-
const t = Array.from(this.recentErrors.entries()).sort((
|
|
4355
|
-
for (let
|
|
4356
|
-
const i = t[
|
|
4436
|
+
const t = Array.from(this.recentErrors.entries()).sort((s, i) => s[1] - i[1]), r = this.recentErrors.size - Q;
|
|
4437
|
+
for (let s = 0; s < r; s += 1) {
|
|
4438
|
+
const i = t[s];
|
|
4357
4439
|
i && this.recentErrors.delete(i[0]);
|
|
4358
4440
|
}
|
|
4359
4441
|
}
|
|
@@ -4361,7 +4443,7 @@ class ar extends _ {
|
|
|
4361
4443
|
class lr extends _ {
|
|
4362
4444
|
isInitialized = !1;
|
|
4363
4445
|
suppressNextScrollTimer = null;
|
|
4364
|
-
emitter = new
|
|
4446
|
+
emitter = new jt();
|
|
4365
4447
|
transformers = {};
|
|
4366
4448
|
managers = {};
|
|
4367
4449
|
handlers = {};
|
|
@@ -4403,9 +4485,9 @@ class lr extends _ {
|
|
|
4403
4485
|
}
|
|
4404
4486
|
let r = t;
|
|
4405
4487
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4406
|
-
const { valid:
|
|
4407
|
-
if (!
|
|
4408
|
-
if (this.get("mode") ===
|
|
4488
|
+
const { valid: s, error: i, sanitizedMetadata: o } = Qt(e, r);
|
|
4489
|
+
if (!s) {
|
|
4490
|
+
if (this.get("mode") === z.QA)
|
|
4409
4491
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4410
4492
|
return;
|
|
4411
4493
|
}
|
|
@@ -4455,10 +4537,10 @@ class lr extends _ {
|
|
|
4455
4537
|
this.set("userId", t);
|
|
4456
4538
|
const r = xt(e);
|
|
4457
4539
|
this.set("collectApiUrls", r);
|
|
4458
|
-
const
|
|
4459
|
-
this.set("device",
|
|
4540
|
+
const s = It();
|
|
4541
|
+
this.set("device", s);
|
|
4460
4542
|
const i = le(window.location.href, e.sensitiveQueryParams);
|
|
4461
|
-
this.set("pageUrl", i), Pt() && this.set("mode",
|
|
4543
|
+
this.set("pageUrl", i), Pt() && this.set("mode", z.QA);
|
|
4462
4544
|
}
|
|
4463
4545
|
/**
|
|
4464
4546
|
* Returns the current configuration object.
|
|
@@ -4500,7 +4582,7 @@ class lr extends _ {
|
|
|
4500
4582
|
valid: !1,
|
|
4501
4583
|
error: "Global metadata must be a plain object"
|
|
4502
4584
|
};
|
|
4503
|
-
const t =
|
|
4585
|
+
const t = je("Global", e, "globalMetadata");
|
|
4504
4586
|
return t.valid ? { valid: !0 } : {
|
|
4505
4587
|
valid: !1,
|
|
4506
4588
|
error: t.error
|
|
@@ -4517,11 +4599,11 @@ class lr extends _ {
|
|
|
4517
4599
|
const t = this.validateGlobalMetadata(e);
|
|
4518
4600
|
if (!t.valid)
|
|
4519
4601
|
throw new Error(`[TraceLog] Invalid global metadata: ${t.error}`);
|
|
4520
|
-
const
|
|
4602
|
+
const s = {
|
|
4521
4603
|
...this.get("config"),
|
|
4522
4604
|
globalMetadata: e
|
|
4523
4605
|
};
|
|
4524
|
-
this.set("config",
|
|
4606
|
+
this.set("config", s), a("debug", "Global metadata updated (replaced)", { data: { keys: Object.keys(e) } });
|
|
4525
4607
|
}
|
|
4526
4608
|
/**
|
|
4527
4609
|
* Merges new metadata with existing global metadata.
|
|
@@ -4554,35 +4636,35 @@ class lr extends _ {
|
|
|
4554
4636
|
this.set("suppressNextScroll", !1);
|
|
4555
4637
|
}, 500);
|
|
4556
4638
|
};
|
|
4557
|
-
this.handlers.pageView = new tr(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new rr(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new
|
|
4639
|
+
this.handlers.pageView = new tr(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new rr(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new nr(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new or(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4558
4640
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4559
|
-
}), this.handlers.error = new ar(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new
|
|
4641
|
+
}), this.handlers.error = new ar(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new sr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4560
4642
|
}
|
|
4561
4643
|
}
|
|
4562
4644
|
const R = [], M = [];
|
|
4563
4645
|
let f = null, C = !1, v = !1;
|
|
4564
|
-
const cr = async (
|
|
4646
|
+
const cr = async (n) => {
|
|
4565
4647
|
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !C)) {
|
|
4566
4648
|
C = !0;
|
|
4567
4649
|
try {
|
|
4568
|
-
const e = Wt(
|
|
4650
|
+
const e = Wt(n ?? {}), t = new lr();
|
|
4569
4651
|
try {
|
|
4570
4652
|
R.forEach(({ event: i, callback: o }) => {
|
|
4571
4653
|
t.on(i, o);
|
|
4572
4654
|
}), R.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4573
4655
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4574
4656
|
}), M.length = 0;
|
|
4575
|
-
const r = t.init(e),
|
|
4657
|
+
const r = t.init(e), s = new Promise((i, o) => {
|
|
4576
4658
|
setTimeout(() => {
|
|
4577
4659
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4578
4660
|
}, 1e4);
|
|
4579
4661
|
});
|
|
4580
|
-
await Promise.race([r,
|
|
4662
|
+
await Promise.race([r, s]), f = t;
|
|
4581
4663
|
} catch (r) {
|
|
4582
4664
|
try {
|
|
4583
4665
|
t.destroy(!0);
|
|
4584
|
-
} catch (
|
|
4585
|
-
a("error", "Failed to cleanup partially initialized app", { error:
|
|
4666
|
+
} catch (s) {
|
|
4667
|
+
a("error", "Failed to cleanup partially initialized app", { error: s });
|
|
4586
4668
|
}
|
|
4587
4669
|
throw r;
|
|
4588
4670
|
}
|
|
@@ -4592,56 +4674,56 @@ const cr = async (s) => {
|
|
|
4592
4674
|
C = !1;
|
|
4593
4675
|
}
|
|
4594
4676
|
}
|
|
4595
|
-
}, ur = (
|
|
4677
|
+
}, ur = (n, e) => {
|
|
4596
4678
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4597
4679
|
if (!f)
|
|
4598
4680
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4599
4681
|
if (v)
|
|
4600
4682
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4601
|
-
f.sendCustomEvent(
|
|
4683
|
+
f.sendCustomEvent(n, e);
|
|
4602
4684
|
}
|
|
4603
|
-
}, dr = (
|
|
4685
|
+
}, dr = (n, e) => {
|
|
4604
4686
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4605
4687
|
if (!f || C) {
|
|
4606
|
-
R.push({ event:
|
|
4688
|
+
R.push({ event: n, callback: e });
|
|
4607
4689
|
return;
|
|
4608
4690
|
}
|
|
4609
|
-
f.on(
|
|
4691
|
+
f.on(n, e);
|
|
4610
4692
|
}
|
|
4611
|
-
}, hr = (
|
|
4693
|
+
}, hr = (n, e) => {
|
|
4612
4694
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4613
4695
|
if (!f) {
|
|
4614
|
-
const t = R.findIndex((r) => r.event ===
|
|
4696
|
+
const t = R.findIndex((r) => r.event === n && r.callback === e);
|
|
4615
4697
|
t !== -1 && R.splice(t, 1);
|
|
4616
4698
|
return;
|
|
4617
4699
|
}
|
|
4618
|
-
f.off(
|
|
4700
|
+
f.off(n, e);
|
|
4619
4701
|
}
|
|
4620
4702
|
};
|
|
4621
|
-
function fr(
|
|
4703
|
+
function fr(n, e) {
|
|
4622
4704
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4623
4705
|
if (typeof e != "function")
|
|
4624
4706
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4625
4707
|
if (!f || C) {
|
|
4626
|
-
const t = M.findIndex((r) => r.hook ===
|
|
4627
|
-
t !== -1 && M.splice(t, 1), M.push({ hook:
|
|
4708
|
+
const t = M.findIndex((r) => r.hook === n);
|
|
4709
|
+
t !== -1 && M.splice(t, 1), M.push({ hook: n, fn: e });
|
|
4628
4710
|
return;
|
|
4629
4711
|
}
|
|
4630
4712
|
if (v)
|
|
4631
4713
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4632
|
-
|
|
4714
|
+
n === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4633
4715
|
}
|
|
4634
4716
|
}
|
|
4635
|
-
const mr = (
|
|
4717
|
+
const mr = (n) => {
|
|
4636
4718
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4637
4719
|
if (!f) {
|
|
4638
|
-
const e = M.findIndex((t) => t.hook ===
|
|
4720
|
+
const e = M.findIndex((t) => t.hook === n);
|
|
4639
4721
|
e !== -1 && M.splice(e, 1);
|
|
4640
4722
|
return;
|
|
4641
4723
|
}
|
|
4642
4724
|
if (v)
|
|
4643
4725
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4644
|
-
f.removeTransformer(
|
|
4726
|
+
f.removeTransformer(n);
|
|
4645
4727
|
}
|
|
4646
4728
|
}, gr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Er = () => {
|
|
4647
4729
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
@@ -4654,27 +4736,27 @@ const mr = (s) => {
|
|
|
4654
4736
|
v = !0;
|
|
4655
4737
|
try {
|
|
4656
4738
|
f.destroy(), f = null, C = !1, R.length = 0, M.length = 0, v = !1;
|
|
4657
|
-
} catch (
|
|
4658
|
-
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error:
|
|
4739
|
+
} catch (n) {
|
|
4740
|
+
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4659
4741
|
}
|
|
4660
4742
|
}
|
|
4661
|
-
}, Sr = (
|
|
4662
|
-
typeof window > "u" || typeof document > "u" || Dt(
|
|
4663
|
-
}, pr = (
|
|
4743
|
+
}, Sr = (n) => {
|
|
4744
|
+
typeof window > "u" || typeof document > "u" || Dt(n);
|
|
4745
|
+
}, pr = (n) => {
|
|
4664
4746
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4665
4747
|
if (!f)
|
|
4666
4748
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4667
4749
|
if (v)
|
|
4668
4750
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4669
|
-
f.updateGlobalMetadata(
|
|
4751
|
+
f.updateGlobalMetadata(n);
|
|
4670
4752
|
}
|
|
4671
|
-
}, Tr = (
|
|
4753
|
+
}, Tr = (n) => {
|
|
4672
4754
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4673
4755
|
if (!f)
|
|
4674
4756
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4675
4757
|
if (v)
|
|
4676
4758
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4677
|
-
f.mergeGlobalMetadata(
|
|
4759
|
+
f.mergeGlobalMetadata(n);
|
|
4678
4760
|
}
|
|
4679
4761
|
}, Qr = {
|
|
4680
4762
|
init: cr,
|
|
@@ -4689,57 +4771,57 @@ const mr = (s) => {
|
|
|
4689
4771
|
updateGlobalMetadata: pr,
|
|
4690
4772
|
mergeGlobalMetadata: Tr
|
|
4691
4773
|
};
|
|
4692
|
-
var ue, Ye = -1, P = function(
|
|
4774
|
+
var ue, Ye = -1, P = function(n) {
|
|
4693
4775
|
addEventListener("pageshow", (function(e) {
|
|
4694
|
-
e.persisted && (Ye = e.timeStamp,
|
|
4776
|
+
e.persisted && (Ye = e.timeStamp, n(e));
|
|
4695
4777
|
}), !0);
|
|
4696
4778
|
}, Ee = function() {
|
|
4697
|
-
var
|
|
4698
|
-
if (
|
|
4779
|
+
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4780
|
+
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4699
4781
|
}, q = function() {
|
|
4700
|
-
var
|
|
4701
|
-
return
|
|
4702
|
-
}, b = function(
|
|
4782
|
+
var n = Ee();
|
|
4783
|
+
return n && n.activationStart || 0;
|
|
4784
|
+
}, b = function(n, e) {
|
|
4703
4785
|
var t = Ee(), r = "navigate";
|
|
4704
|
-
return Ye >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name:
|
|
4705
|
-
}, F = function(
|
|
4786
|
+
return Ye >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: n, 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 };
|
|
4787
|
+
}, F = function(n, e, t) {
|
|
4706
4788
|
try {
|
|
4707
|
-
if (PerformanceObserver.supportedEntryTypes.includes(
|
|
4708
|
-
var r = new PerformanceObserver((function(
|
|
4789
|
+
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
4790
|
+
var r = new PerformanceObserver((function(s) {
|
|
4709
4791
|
Promise.resolve().then((function() {
|
|
4710
|
-
e(
|
|
4792
|
+
e(s.getEntries());
|
|
4711
4793
|
}));
|
|
4712
4794
|
}));
|
|
4713
|
-
return r.observe(Object.assign({ type:
|
|
4795
|
+
return r.observe(Object.assign({ type: n, buffered: !0 }, t || {})), r;
|
|
4714
4796
|
}
|
|
4715
4797
|
} catch {
|
|
4716
4798
|
}
|
|
4717
|
-
}, A = function(
|
|
4718
|
-
var
|
|
4799
|
+
}, A = function(n, e, t, r) {
|
|
4800
|
+
var s, i;
|
|
4719
4801
|
return function(o) {
|
|
4720
|
-
e.value >= 0 && (o || r) && ((i = e.value - (
|
|
4802
|
+
e.value >= 0 && (o || r) && ((i = e.value - (s || 0)) || s === void 0) && (s = e.value, e.delta = i, e.rating = (function(l, c) {
|
|
4721
4803
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4722
|
-
})(e.value, t),
|
|
4804
|
+
})(e.value, t), n(e));
|
|
4723
4805
|
};
|
|
4724
|
-
}, Se = function(
|
|
4806
|
+
}, Se = function(n) {
|
|
4725
4807
|
requestAnimationFrame((function() {
|
|
4726
4808
|
return requestAnimationFrame((function() {
|
|
4727
|
-
return
|
|
4809
|
+
return n();
|
|
4728
4810
|
}));
|
|
4729
4811
|
}));
|
|
4730
|
-
}, J = function(
|
|
4812
|
+
}, J = function(n) {
|
|
4731
4813
|
document.addEventListener("visibilitychange", (function() {
|
|
4732
|
-
document.visibilityState === "hidden" &&
|
|
4814
|
+
document.visibilityState === "hidden" && n();
|
|
4733
4815
|
}));
|
|
4734
|
-
}, pe = function(
|
|
4816
|
+
}, pe = function(n) {
|
|
4735
4817
|
var e = !1;
|
|
4736
4818
|
return function() {
|
|
4737
|
-
e || (
|
|
4819
|
+
e || (n(), e = !0);
|
|
4738
4820
|
};
|
|
4739
4821
|
}, O = -1, ke = function() {
|
|
4740
4822
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4741
|
-
}, Y = function(
|
|
4742
|
-
document.visibilityState === "hidden" && O > -1 && (O =
|
|
4823
|
+
}, Y = function(n) {
|
|
4824
|
+
document.visibilityState === "hidden" && O > -1 && (O = n.type === "visibilitychange" ? n.timeStamp : 0, _r());
|
|
4743
4825
|
}, Ue = function() {
|
|
4744
4826
|
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4745
4827
|
}, _r = function() {
|
|
@@ -4752,126 +4834,126 @@ var ue, Ye = -1, P = function(s) {
|
|
|
4752
4834
|
}))), { get firstHiddenTime() {
|
|
4753
4835
|
return O;
|
|
4754
4836
|
} };
|
|
4755
|
-
}, Z = function(
|
|
4837
|
+
}, Z = function(n) {
|
|
4756
4838
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4757
|
-
return
|
|
4758
|
-
}), !0) :
|
|
4759
|
-
}, de = [1800, 3e3], Je = function(
|
|
4839
|
+
return n();
|
|
4840
|
+
}), !0) : n();
|
|
4841
|
+
}, de = [1800, 3e3], Je = function(n, e) {
|
|
4760
4842
|
e = e || {}, Z((function() {
|
|
4761
|
-
var t, r = qe(),
|
|
4843
|
+
var t, r = qe(), s = b("FCP"), i = F("paint", (function(o) {
|
|
4762
4844
|
o.forEach((function(l) {
|
|
4763
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (
|
|
4845
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime - q(), 0), s.entries.push(l), t(!0)));
|
|
4764
4846
|
}));
|
|
4765
4847
|
}));
|
|
4766
|
-
i && (t = A(
|
|
4767
|
-
|
|
4768
|
-
|
|
4848
|
+
i && (t = A(n, s, de, e.reportAllChanges), P((function(o) {
|
|
4849
|
+
s = b("FCP"), t = A(n, s, de, e.reportAllChanges), Se((function() {
|
|
4850
|
+
s.value = performance.now() - o.timeStamp, t(!0);
|
|
4769
4851
|
}));
|
|
4770
4852
|
})));
|
|
4771
4853
|
}));
|
|
4772
|
-
}, he = [0.1, 0.25], vr = function(
|
|
4854
|
+
}, he = [0.1, 0.25], vr = function(n, e) {
|
|
4773
4855
|
e = e || {}, Je(pe((function() {
|
|
4774
|
-
var t, r = b("CLS", 0),
|
|
4856
|
+
var t, r = b("CLS", 0), s = 0, i = [], o = function(c) {
|
|
4775
4857
|
c.forEach((function(u) {
|
|
4776
4858
|
if (!u.hadRecentInput) {
|
|
4777
4859
|
var S = i[0], g = i[i.length - 1];
|
|
4778
|
-
|
|
4860
|
+
s && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (s += u.value, i.push(u)) : (s = u.value, i = [u]);
|
|
4779
4861
|
}
|
|
4780
|
-
})),
|
|
4862
|
+
})), s > r.value && (r.value = s, r.entries = i, t());
|
|
4781
4863
|
}, l = F("layout-shift", o);
|
|
4782
|
-
l && (t = A(
|
|
4864
|
+
l && (t = A(n, r, he, e.reportAllChanges), J((function() {
|
|
4783
4865
|
o(l.takeRecords()), t(!0);
|
|
4784
4866
|
})), P((function() {
|
|
4785
|
-
|
|
4867
|
+
s = 0, r = b("CLS", 0), t = A(n, r, he, e.reportAllChanges), Se((function() {
|
|
4786
4868
|
return t();
|
|
4787
4869
|
}));
|
|
4788
4870
|
})), setTimeout(t, 0));
|
|
4789
4871
|
})));
|
|
4790
|
-
}, Ze = 0, re = 1 / 0, G = 0, Ir = function(
|
|
4791
|
-
|
|
4872
|
+
}, Ze = 0, re = 1 / 0, G = 0, Ir = function(n) {
|
|
4873
|
+
n.forEach((function(e) {
|
|
4792
4874
|
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId), Ze = G ? (G - re) / 7 + 1 : 0);
|
|
4793
4875
|
}));
|
|
4794
4876
|
}, et = function() {
|
|
4795
4877
|
return ue ? Ze : performance.interactionCount || 0;
|
|
4796
4878
|
}, wr = function() {
|
|
4797
4879
|
"interactionCount" in performance || ue || (ue = F("event", Ir, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4798
|
-
}, y = [],
|
|
4799
|
-
var
|
|
4800
|
-
return y[
|
|
4801
|
-
}, br = [], Ar = function(
|
|
4802
|
-
if (br.forEach((function(
|
|
4803
|
-
return n
|
|
4804
|
-
})),
|
|
4805
|
-
var e = y[y.length - 1], t =
|
|
4806
|
-
if (t || y.length < 10 ||
|
|
4807
|
-
if (t)
|
|
4880
|
+
}, y = [], j = /* @__PURE__ */ new Map(), tt = 0, yr = function() {
|
|
4881
|
+
var n = Math.min(y.length - 1, Math.floor((et() - tt) / 50));
|
|
4882
|
+
return y[n];
|
|
4883
|
+
}, br = [], Ar = function(n) {
|
|
4884
|
+
if (br.forEach((function(s) {
|
|
4885
|
+
return s(n);
|
|
4886
|
+
})), n.interactionId || n.entryType === "first-input") {
|
|
4887
|
+
var e = y[y.length - 1], t = j.get(n.interactionId);
|
|
4888
|
+
if (t || y.length < 10 || n.duration > e.latency) {
|
|
4889
|
+
if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
|
|
4808
4890
|
else {
|
|
4809
|
-
var r = { id:
|
|
4810
|
-
|
|
4891
|
+
var r = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4892
|
+
j.set(r.id, r), y.push(r);
|
|
4811
4893
|
}
|
|
4812
|
-
y.sort((function(
|
|
4813
|
-
return i.latency -
|
|
4814
|
-
})), y.length > 10 && y.splice(10).forEach((function(
|
|
4815
|
-
return
|
|
4894
|
+
y.sort((function(s, i) {
|
|
4895
|
+
return i.latency - s.latency;
|
|
4896
|
+
})), y.length > 10 && y.splice(10).forEach((function(s) {
|
|
4897
|
+
return j.delete(s.id);
|
|
4816
4898
|
}));
|
|
4817
4899
|
}
|
|
4818
4900
|
}
|
|
4819
|
-
}, rt = function(
|
|
4901
|
+
}, rt = function(n) {
|
|
4820
4902
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4821
|
-
return
|
|
4822
|
-
}, fe = [200, 500], Lr = function(
|
|
4903
|
+
return n = pe(n), document.visibilityState === "hidden" ? n() : (t = e(n), J(n)), t;
|
|
4904
|
+
}, fe = [200, 500], Lr = function(n, e) {
|
|
4823
4905
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4824
4906
|
var t;
|
|
4825
4907
|
wr();
|
|
4826
|
-
var r,
|
|
4908
|
+
var r, s = b("INP"), i = function(l) {
|
|
4827
4909
|
rt((function() {
|
|
4828
4910
|
l.forEach(Ar);
|
|
4829
4911
|
var c = yr();
|
|
4830
|
-
c && c.latency !==
|
|
4912
|
+
c && c.latency !== s.value && (s.value = c.latency, s.entries = c.entries, r());
|
|
4831
4913
|
}));
|
|
4832
4914
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4833
|
-
r = A(
|
|
4915
|
+
r = A(n, s, fe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4834
4916
|
i(o.takeRecords()), r(!0);
|
|
4835
4917
|
})), P((function() {
|
|
4836
|
-
tt = et(), y.length = 0,
|
|
4918
|
+
tt = et(), y.length = 0, j.clear(), s = b("INP"), r = A(n, s, fe, e.reportAllChanges);
|
|
4837
4919
|
})));
|
|
4838
4920
|
})));
|
|
4839
|
-
}, me = [2500, 4e3],
|
|
4921
|
+
}, me = [2500, 4e3], ne = {}, Mr = function(n, e) {
|
|
4840
4922
|
e = e || {}, Z((function() {
|
|
4841
|
-
var t, r = qe(),
|
|
4923
|
+
var t, r = qe(), s = b("LCP"), i = function(c) {
|
|
4842
4924
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4843
|
-
u.startTime < r.firstHiddenTime && (
|
|
4925
|
+
u.startTime < r.firstHiddenTime && (s.value = Math.max(u.startTime - q(), 0), s.entries = [u], t());
|
|
4844
4926
|
}));
|
|
4845
4927
|
}, o = F("largest-contentful-paint", i);
|
|
4846
4928
|
if (o) {
|
|
4847
|
-
t = A(
|
|
4929
|
+
t = A(n, s, me, e.reportAllChanges);
|
|
4848
4930
|
var l = pe((function() {
|
|
4849
|
-
|
|
4931
|
+
ne[s.id] || (i(o.takeRecords()), o.disconnect(), ne[s.id] = !0, t(!0));
|
|
4850
4932
|
}));
|
|
4851
4933
|
["keydown", "click"].forEach((function(c) {
|
|
4852
4934
|
addEventListener(c, (function() {
|
|
4853
4935
|
return rt(l);
|
|
4854
4936
|
}), { once: !0, capture: !0 });
|
|
4855
4937
|
})), J(l), P((function(c) {
|
|
4856
|
-
|
|
4857
|
-
|
|
4938
|
+
s = b("LCP"), t = A(n, s, me, e.reportAllChanges), Se((function() {
|
|
4939
|
+
s.value = performance.now() - c.timeStamp, ne[s.id] = !0, t(!0);
|
|
4858
4940
|
}));
|
|
4859
4941
|
}));
|
|
4860
4942
|
}
|
|
4861
4943
|
}));
|
|
4862
|
-
}, ge = [800, 1800], Cr = function
|
|
4944
|
+
}, ge = [800, 1800], Cr = function n(e) {
|
|
4863
4945
|
document.prerendering ? Z((function() {
|
|
4864
|
-
return
|
|
4946
|
+
return n(e);
|
|
4865
4947
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4866
|
-
return
|
|
4948
|
+
return n(e);
|
|
4867
4949
|
}), !0) : setTimeout(e, 0);
|
|
4868
|
-
}, Rr = function(
|
|
4950
|
+
}, Rr = function(n, e) {
|
|
4869
4951
|
e = e || {};
|
|
4870
|
-
var t = b("TTFB"), r = A(
|
|
4952
|
+
var t = b("TTFB"), r = A(n, t, ge, e.reportAllChanges);
|
|
4871
4953
|
Cr((function() {
|
|
4872
|
-
var
|
|
4873
|
-
|
|
4874
|
-
t = b("TTFB", 0), (r = A(
|
|
4954
|
+
var s = Ee();
|
|
4955
|
+
s && (t.value = Math.max(s.responseStart - q(), 0), t.entries = [s], r(!0), P((function() {
|
|
4956
|
+
t = b("TTFB", 0), (r = A(n, t, ge, e.reportAllChanges))(!0);
|
|
4875
4957
|
})));
|
|
4876
4958
|
}));
|
|
4877
4959
|
};
|
|
@@ -4893,7 +4975,7 @@ export {
|
|
|
4893
4975
|
Or as DEFAULT_SESSION_TIMEOUT,
|
|
4894
4976
|
ae as DEFAULT_WEB_VITALS_MODE,
|
|
4895
4977
|
L as DeviceType,
|
|
4896
|
-
|
|
4978
|
+
se as EmitterEvent,
|
|
4897
4979
|
U as ErrorType,
|
|
4898
4980
|
d as EventType,
|
|
4899
4981
|
Gr as InitializationTimeoutError,
|
|
@@ -4907,7 +4989,7 @@ export {
|
|
|
4907
4989
|
Ur as MAX_NESTED_OBJECT_KEYS,
|
|
4908
4990
|
Hr as MAX_STRING_LENGTH,
|
|
4909
4991
|
Fr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4910
|
-
|
|
4992
|
+
z as Mode,
|
|
4911
4993
|
Be as PII_PATTERNS,
|
|
4912
4994
|
N as PermanentError,
|
|
4913
4995
|
Ae as SamplingRateValidationError,
|