@tracelog/lib 2.8.1 → 2.8.2-rc.102.4
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 +277 -236
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +2 -2
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/public-api.cjs +2 -2
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +8 -0
- package/dist/public-api.d.ts +8 -0
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const dr = 9e5;
|
|
2
2
|
const ur = 120, hr = 49152, fr = 100, mr = 500, gr = 200;
|
|
3
|
-
const Er = 1e3,
|
|
4
|
-
const b = "data-tlog",
|
|
3
|
+
const Er = 1e3, pr = 500, Sr = 1e3;
|
|
4
|
+
const b = "data-tlog", bt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const b = "data-tlog", At = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], At = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], Lt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -72,14 +72,14 @@ const E = {
|
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number",
|
|
74
74
|
INVALID_SEND_INTERVAL: "Send interval must be between 1000ms (1 second) and 60000ms (60 seconds)"
|
|
75
|
-
},
|
|
75
|
+
}, Mt = [
|
|
76
76
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
77
77
|
/javascript:/gi,
|
|
78
78
|
/on\w+\s*=/gi,
|
|
79
79
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
80
80
|
/<embed\b[^>]*>/gi,
|
|
81
81
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
82
|
-
], I = "tlog", X = `${I}:qa_mode`, Te = `${I}:uid`,
|
|
82
|
+
], I = "tlog", X = `${I}:qa_mode`, Te = `${I}:uid`, rt = "tlog_mode", Ue = "qa", He = "qa_off", Ct = (r) => r ? `${I}:${r}:queue` : `${I}:queue`, Rt = (r) => r ? `${I}:${r}:session` : `${I}:session`, Nt = (r) => r ? `${I}:${r}:broadcast` : `${I}:broadcast`, Fe = (r, e) => `${I}:${r}:session_counts:${e}`, xe = 10080 * 60 * 1e3, $e = `${I}:session_counts_last_cleanup`, Be = 3600 * 1e3, fe = (r) => r ? `${I}:${r}:identity` : `${I}:identity`, U = `${I}:pending_identity`;
|
|
83
83
|
var $ = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))($ || {}), L = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(L || {}), se = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(se || {});
|
|
84
84
|
class O extends Error {
|
|
85
85
|
constructor(e, t) {
|
|
@@ -111,12 +111,12 @@ class m extends j {
|
|
|
111
111
|
super(e, "APP_CONFIG_INVALID", t);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
class
|
|
114
|
+
class Ot extends j {
|
|
115
115
|
constructor(e, t = "config") {
|
|
116
116
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class We extends j {
|
|
120
120
|
constructor(e, t = "config") {
|
|
121
121
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
122
122
|
}
|
|
@@ -132,7 +132,7 @@ class vr extends j {
|
|
|
132
132
|
}
|
|
133
133
|
timeoutMs;
|
|
134
134
|
}
|
|
135
|
-
const
|
|
135
|
+
const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", it = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Pt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Dt = (r, e) => {
|
|
136
136
|
if (e) {
|
|
137
137
|
if (e instanceof Error) {
|
|
138
138
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -151,7 +151,7 @@ const it = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
151
151
|
return `[TraceLog] ${r}: ${String(e)}`;
|
|
152
152
|
}
|
|
153
153
|
return `[TraceLog] ${r}`;
|
|
154
|
-
},
|
|
154
|
+
}, kt = () => {
|
|
155
155
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
156
156
|
return !1;
|
|
157
157
|
try {
|
|
@@ -160,12 +160,12 @@ const it = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
160
160
|
return !1;
|
|
161
161
|
}
|
|
162
162
|
}, a = (r, e, t) => {
|
|
163
|
-
const { error: s, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = s ?
|
|
164
|
-
if (!
|
|
163
|
+
const { error: s, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = s ? Dt(e, s) : `[TraceLog] ${e}`, d = r === "error" ? "error" : r === "warn" ? "warn" : "log";
|
|
164
|
+
if (!Vt(l, i))
|
|
165
165
|
return;
|
|
166
|
-
const g =
|
|
167
|
-
|
|
168
|
-
},
|
|
166
|
+
const g = Ut(l, o), T = n !== void 0 ? Ie(n) : void 0;
|
|
167
|
+
Ht(d, c, g, T);
|
|
168
|
+
}, Vt = (r, e) => r === "critical" ? !0 : r === "qa" || e ? kt() : !1, Ut = (r, e) => e !== void 0 && e !== "" ? e : r === "critical" ? Pt : "", Ht = (r, e, t, s) => {
|
|
169
169
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
170
170
|
s !== void 0 ? n ? console[r](i, t, s) : console[r](i, s) : n ? console[r](i, t) : console[r](i);
|
|
171
171
|
}, Ie = (r) => {
|
|
@@ -182,10 +182,10 @@ const it = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
182
182
|
}
|
|
183
183
|
return e;
|
|
184
184
|
};
|
|
185
|
-
let ve,
|
|
186
|
-
const
|
|
187
|
-
typeof window < "u" && !ve && (ve = window.matchMedia("(pointer: coarse)"),
|
|
188
|
-
}, oe = "Unknown",
|
|
185
|
+
let ve, ot;
|
|
186
|
+
const Ft = () => {
|
|
187
|
+
typeof window < "u" && !ve && (ve = window.matchMedia("(pointer: coarse)"), ot = window.matchMedia("(hover: none)"));
|
|
188
|
+
}, oe = "Unknown", xt = (r) => {
|
|
189
189
|
const e = r.userAgentData?.platform;
|
|
190
190
|
if (e != null && e !== "") {
|
|
191
191
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -197,7 +197,7 @@ const xt = () => {
|
|
|
197
197
|
}
|
|
198
198
|
const t = navigator.userAgent;
|
|
199
199
|
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" : oe;
|
|
200
|
-
},
|
|
200
|
+
}, $t = (r) => {
|
|
201
201
|
const e = r.userAgentData?.brands;
|
|
202
202
|
if (e != null && e.length > 0) {
|
|
203
203
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -208,26 +208,26 @@ const xt = () => {
|
|
|
208
208
|
}
|
|
209
209
|
const t = navigator.userAgent;
|
|
210
210
|
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" : oe;
|
|
211
|
-
},
|
|
211
|
+
}, Bt = () => {
|
|
212
212
|
try {
|
|
213
213
|
const r = navigator;
|
|
214
214
|
if (r.userAgentData != null && typeof r.userAgentData.mobile == "boolean") {
|
|
215
215
|
const c = r.userAgentData.platform;
|
|
216
216
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : r.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
const e = window.innerWidth, t = ve?.matches ?? !1, s =
|
|
218
|
+
Ft();
|
|
219
|
+
const e = window.innerWidth, t = ve?.matches ?? !1, s = ot?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
220
220
|
return e <= 767 || o && n ? L.Mobile : e >= 768 && e <= 1024 || l || t && s && n ? L.Tablet : L.Desktop;
|
|
221
221
|
} catch (r) {
|
|
222
222
|
return a("debug", "Device detection failed, defaulting to desktop", { error: r }), L.Desktop;
|
|
223
223
|
}
|
|
224
|
-
},
|
|
224
|
+
}, Wt = () => {
|
|
225
225
|
try {
|
|
226
226
|
const r = navigator;
|
|
227
227
|
return {
|
|
228
|
-
type:
|
|
229
|
-
os:
|
|
230
|
-
browser:
|
|
228
|
+
type: Bt(),
|
|
229
|
+
os: xt(r),
|
|
230
|
+
browser: $t(r)
|
|
231
231
|
};
|
|
232
232
|
} catch (r) {
|
|
233
233
|
return a("debug", "Device info detection failed, using defaults", { error: r }), {
|
|
@@ -236,7 +236,7 @@ const xt = () => {
|
|
|
236
236
|
browser: oe
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
},
|
|
239
|
+
}, at = [
|
|
240
240
|
// Email addresses
|
|
241
241
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
242
242
|
// US Phone numbers (various formats)
|
|
@@ -253,7 +253,7 @@ const xt = () => {
|
|
|
253
253
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
254
254
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, etc.)
|
|
255
255
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
256
|
-
],
|
|
256
|
+
], Xe = 500, Ge = 2e3, je = 5e3, ee = 50, Xt = ee * 2, lt = 1, Gt = 1e3, jt = 10, ze = 5e3, zt = 6e4, _r = {
|
|
257
257
|
LCP: 2500,
|
|
258
258
|
// Good: ≤ 2.5s
|
|
259
259
|
FCP: 1800,
|
|
@@ -265,7 +265,7 @@ const xt = () => {
|
|
|
265
265
|
TTFB: 800,
|
|
266
266
|
// Good: ≤ 800ms
|
|
267
267
|
LONG_TASK: 50
|
|
268
|
-
},
|
|
268
|
+
}, Qe = {
|
|
269
269
|
LCP: 2500,
|
|
270
270
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
271
271
|
FCP: 1800,
|
|
@@ -277,7 +277,7 @@ const xt = () => {
|
|
|
277
277
|
TTFB: 800,
|
|
278
278
|
// Needs improvement: > 800ms
|
|
279
279
|
LONG_TASK: 50
|
|
280
|
-
},
|
|
280
|
+
}, Qt = {
|
|
281
281
|
LCP: 4e3,
|
|
282
282
|
// Poor: > 4s
|
|
283
283
|
FCP: 3e3,
|
|
@@ -289,53 +289,53 @@ const xt = () => {
|
|
|
289
289
|
TTFB: 1800,
|
|
290
290
|
// Poor: > 1800ms
|
|
291
291
|
LONG_TASK: 50
|
|
292
|
-
}, _e = "needs-improvement",
|
|
292
|
+
}, _e = "needs-improvement", Ke = (r = _e) => {
|
|
293
293
|
switch (r) {
|
|
294
294
|
case "all":
|
|
295
295
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
296
296
|
// Track everything
|
|
297
297
|
case "needs-improvement":
|
|
298
|
-
return
|
|
298
|
+
return Qe;
|
|
299
299
|
case "poor":
|
|
300
|
-
return
|
|
300
|
+
return Qt;
|
|
301
301
|
default:
|
|
302
|
-
return
|
|
302
|
+
return Qe;
|
|
303
303
|
}
|
|
304
|
-
},
|
|
304
|
+
}, Kt = 1e3, Yt = 50, qt = "2.8.2", Jt = qt, ct = () => typeof window < "u" && typeof sessionStorage < "u", Zt = () => {
|
|
305
305
|
try {
|
|
306
306
|
const r = new URLSearchParams(window.location.search);
|
|
307
|
-
r.delete(
|
|
307
|
+
r.delete(rt);
|
|
308
308
|
const e = r.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
309
309
|
window.history.replaceState({}, "", t);
|
|
310
310
|
} catch {
|
|
311
311
|
}
|
|
312
|
-
},
|
|
313
|
-
if (!
|
|
312
|
+
}, es = () => {
|
|
313
|
+
if (!ct())
|
|
314
314
|
return !1;
|
|
315
315
|
try {
|
|
316
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
316
|
+
const e = new URLSearchParams(window.location.search).get(rt), t = sessionStorage.getItem(X);
|
|
317
317
|
let s = null;
|
|
318
|
-
return e ===
|
|
318
|
+
return e === Ue ? (s = !0, sessionStorage.setItem(X, "true"), a("info", "QA Mode ACTIVE", {
|
|
319
319
|
visibility: "qa",
|
|
320
|
-
style:
|
|
321
|
-
})) : e ===
|
|
320
|
+
style: nt
|
|
321
|
+
})) : e === He && (s = !1, sessionStorage.setItem(X, "false"), a("info", "QA Mode DISABLED", {
|
|
322
322
|
visibility: "qa",
|
|
323
|
-
style:
|
|
324
|
-
})), (e ===
|
|
323
|
+
style: it
|
|
324
|
+
})), (e === Ue || e === He) && Zt(), s ?? t === "true";
|
|
325
325
|
} catch {
|
|
326
326
|
return !1;
|
|
327
327
|
}
|
|
328
|
-
},
|
|
329
|
-
if (
|
|
328
|
+
}, ts = (r) => {
|
|
329
|
+
if (ct())
|
|
330
330
|
try {
|
|
331
331
|
sessionStorage.setItem(X, r ? "true" : "false"), a("info", r ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
332
332
|
visibility: "qa",
|
|
333
|
-
style: r ?
|
|
333
|
+
style: r ? nt : it
|
|
334
334
|
});
|
|
335
335
|
} catch {
|
|
336
336
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
337
337
|
}
|
|
338
|
-
},
|
|
338
|
+
}, ss = [
|
|
339
339
|
"co.uk",
|
|
340
340
|
"org.uk",
|
|
341
341
|
"com.au",
|
|
@@ -347,37 +347,37 @@ const xt = () => {
|
|
|
347
347
|
"co.in",
|
|
348
348
|
"com.cn",
|
|
349
349
|
"co.za"
|
|
350
|
-
],
|
|
350
|
+
], Ye = (r) => {
|
|
351
351
|
const e = r.toLowerCase().split(".");
|
|
352
352
|
if (e.length <= 2)
|
|
353
353
|
return r.toLowerCase();
|
|
354
354
|
const t = e.slice(-2).join(".");
|
|
355
|
-
return
|
|
356
|
-
},
|
|
355
|
+
return ss.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
356
|
+
}, rs = (r, e) => r === e ? !0 : Ye(r) === Ye(e), me = () => {
|
|
357
357
|
const r = document.referrer;
|
|
358
358
|
if (!r)
|
|
359
359
|
return "Direct";
|
|
360
360
|
try {
|
|
361
361
|
const e = new URL(r).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
362
|
-
return
|
|
362
|
+
return rs(e, t) ? "Direct" : r;
|
|
363
363
|
} catch (e) {
|
|
364
364
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: r } }), r;
|
|
365
365
|
}
|
|
366
366
|
}, ge = () => {
|
|
367
367
|
const r = new URLSearchParams(window.location.search), e = {};
|
|
368
|
-
return
|
|
368
|
+
return At.forEach((s) => {
|
|
369
369
|
const n = r.get(s);
|
|
370
370
|
if (n) {
|
|
371
371
|
const i = s.split("utm_")[1];
|
|
372
372
|
e[i] = n;
|
|
373
373
|
}
|
|
374
374
|
}), Object.keys(e).length ? e : void 0;
|
|
375
|
-
},
|
|
375
|
+
}, dt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
|
|
376
376
|
const e = Math.random() * 16 | 0;
|
|
377
377
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
378
378
|
});
|
|
379
379
|
let Y = 0, q = 0;
|
|
380
|
-
const
|
|
380
|
+
const ns = () => {
|
|
381
381
|
let r = Date.now();
|
|
382
382
|
r < q && (r = q), r === q ? Y = (Y + 1) % 1e3 : Y = 0, q = r;
|
|
383
383
|
const e = Y.toString().padStart(3, "0");
|
|
@@ -390,7 +390,7 @@ const ye = () => {
|
|
|
390
390
|
} catch {
|
|
391
391
|
}
|
|
392
392
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${r}-${e}-${t}`;
|
|
393
|
-
},
|
|
393
|
+
}, ut = (r, e = !1) => {
|
|
394
394
|
try {
|
|
395
395
|
const t = new URL(r), s = t.protocol === "https:", n = t.protocol === "http:";
|
|
396
396
|
return s || e && n;
|
|
@@ -415,7 +415,7 @@ const ye = () => {
|
|
|
415
415
|
if (s.length === 2 ? n = s.join(".") : n = s.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
416
416
|
throw new Error("Invalid domain structure for SaaS");
|
|
417
417
|
const i = `https://${r}.${n}/collect`;
|
|
418
|
-
if (!
|
|
418
|
+
if (!ut(i))
|
|
419
419
|
throw new Error("Generated URL failed validation");
|
|
420
420
|
return i;
|
|
421
421
|
} catch (e) {
|
|
@@ -427,16 +427,16 @@ const ye = () => {
|
|
|
427
427
|
const t = r.integrations?.custom?.collectApiUrl;
|
|
428
428
|
if (t) {
|
|
429
429
|
const s = r.integrations?.custom?.allowHttp ?? !1;
|
|
430
|
-
if (!
|
|
430
|
+
if (!ut(t, s))
|
|
431
431
|
throw new Error("Invalid custom API URL");
|
|
432
432
|
e.custom = t;
|
|
433
433
|
}
|
|
434
434
|
return e;
|
|
435
|
-
},
|
|
435
|
+
}, ye = (r, e = []) => {
|
|
436
436
|
if (!r || typeof r != "string")
|
|
437
437
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof r } }), r || "";
|
|
438
438
|
try {
|
|
439
|
-
const t = new URL(r), s = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
439
|
+
const t = new URL(r), s = t.searchParams, n = [.../* @__PURE__ */ new Set([...Lt, ...e])];
|
|
440
440
|
let i = !1;
|
|
441
441
|
const o = [];
|
|
442
442
|
return n.forEach((c) => {
|
|
@@ -445,13 +445,13 @@ const ye = () => {
|
|
|
445
445
|
} catch (t) {
|
|
446
446
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: r?.length } }), r;
|
|
447
447
|
}
|
|
448
|
-
},
|
|
448
|
+
}, qe = (r) => {
|
|
449
449
|
if (!r || typeof r != "string" || r.trim().length === 0)
|
|
450
450
|
return "";
|
|
451
451
|
let e = r;
|
|
452
452
|
r.length > 1e3 && (e = r.slice(0, Math.max(0, 1e3)));
|
|
453
453
|
let t = 0;
|
|
454
|
-
for (const n of
|
|
454
|
+
for (const n of Mt) {
|
|
455
455
|
const i = e;
|
|
456
456
|
e = e.replace(n, ""), i !== e && t++;
|
|
457
457
|
}
|
|
@@ -461,11 +461,11 @@ const ye = () => {
|
|
|
461
461
|
valueLength: r.length
|
|
462
462
|
}
|
|
463
463
|
}), e.trim();
|
|
464
|
-
},
|
|
464
|
+
}, we = (r, e = 0) => {
|
|
465
465
|
if (r == null)
|
|
466
466
|
return null;
|
|
467
467
|
if (typeof r == "string")
|
|
468
|
-
return
|
|
468
|
+
return qe(r);
|
|
469
469
|
if (typeof r == "number")
|
|
470
470
|
return !Number.isFinite(r) || r < -Number.MAX_SAFE_INTEGER || r > Number.MAX_SAFE_INTEGER ? 0 : r;
|
|
471
471
|
if (typeof r == "boolean")
|
|
@@ -473,13 +473,13 @@ const ye = () => {
|
|
|
473
473
|
if (e > 10)
|
|
474
474
|
return null;
|
|
475
475
|
if (Array.isArray(r))
|
|
476
|
-
return r.slice(0, 1e3).map((n) =>
|
|
476
|
+
return r.slice(0, 1e3).map((n) => we(n, e + 1)).filter((n) => n !== null);
|
|
477
477
|
if (typeof r == "object") {
|
|
478
478
|
const t = {}, n = Object.entries(r).slice(0, 200);
|
|
479
479
|
for (const [i, o] of n) {
|
|
480
|
-
const l =
|
|
480
|
+
const l = qe(i);
|
|
481
481
|
if (l) {
|
|
482
|
-
const c =
|
|
482
|
+
const c = we(o, e + 1);
|
|
483
483
|
c !== null && (t[l] = c);
|
|
484
484
|
}
|
|
485
485
|
}
|
|
@@ -490,7 +490,7 @@ const ye = () => {
|
|
|
490
490
|
if (typeof r != "object" || r === null)
|
|
491
491
|
return {};
|
|
492
492
|
try {
|
|
493
|
-
const e =
|
|
493
|
+
const e = we(r);
|
|
494
494
|
return typeof e == "object" && e !== null ? e : {};
|
|
495
495
|
} catch (e) {
|
|
496
496
|
const t = e instanceof Error ? e.message : String(e);
|
|
@@ -501,7 +501,7 @@ const ye = () => {
|
|
|
501
501
|
throw new m("Configuration must be an object", "config");
|
|
502
502
|
if (r) {
|
|
503
503
|
if (r.sessionTimeout !== void 0 && (typeof r.sessionTimeout != "number" || r.sessionTimeout < 3e4 || r.sessionTimeout > 864e5))
|
|
504
|
-
throw new
|
|
504
|
+
throw new Ot(E.INVALID_SESSION_TIMEOUT, "config");
|
|
505
505
|
if (r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null))
|
|
506
506
|
throw new m(E.INVALID_GLOBAL_METADATA, "config");
|
|
507
507
|
if (r.integrations && ds(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
@@ -512,9 +512,9 @@ const ye = () => {
|
|
|
512
512
|
throw new m("All sensitive query params must be strings", "config");
|
|
513
513
|
}
|
|
514
514
|
if (r.errorSampling !== void 0 && (typeof r.errorSampling != "number" || r.errorSampling < 0 || r.errorSampling > 1))
|
|
515
|
-
throw new
|
|
515
|
+
throw new We(E.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
516
516
|
if (r.samplingRate !== void 0 && (typeof r.samplingRate != "number" || r.samplingRate < 0 || r.samplingRate > 1))
|
|
517
|
-
throw new
|
|
517
|
+
throw new We(E.INVALID_SAMPLING_RATE, "config");
|
|
518
518
|
if (r.primaryScrollSelector !== void 0) {
|
|
519
519
|
if (typeof r.primaryScrollSelector != "string" || !r.primaryScrollSelector.trim())
|
|
520
520
|
throw new m(E.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -627,7 +627,7 @@ const ye = () => {
|
|
|
627
627
|
sessionTimeout: r?.sessionTimeout ?? 9e5,
|
|
628
628
|
globalMetadata: r?.globalMetadata ?? {},
|
|
629
629
|
sensitiveQueryParams: r?.sensitiveQueryParams ?? [],
|
|
630
|
-
errorSampling: r?.errorSampling ??
|
|
630
|
+
errorSampling: r?.errorSampling ?? lt,
|
|
631
631
|
samplingRate: r?.samplingRate ?? 1,
|
|
632
632
|
pageViewThrottleMs: r?.pageViewThrottleMs ?? 1e3,
|
|
633
633
|
clickThrottleMs: r?.clickThrottleMs ?? 300,
|
|
@@ -644,12 +644,12 @@ const ye = () => {
|
|
|
644
644
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
645
645
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
646
646
|
}), e;
|
|
647
|
-
},
|
|
647
|
+
}, be = (r, e = /* @__PURE__ */ new Set()) => {
|
|
648
648
|
if (r == null)
|
|
649
649
|
return !0;
|
|
650
650
|
const t = typeof r;
|
|
651
|
-
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(r) ? !1 : (e.add(r), Array.isArray(r) ? r.every((s) =>
|
|
652
|
-
}, hs = (r) => typeof r != "object" || r === null ? !1 :
|
|
651
|
+
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(r) ? !1 : (e.add(r), Array.isArray(r) ? r.every((s) => be(s, e)) : t === "object" ? Object.values(r).every((s) => be(s, e)) : !1);
|
|
652
|
+
}, hs = (r) => typeof r != "object" || r === null ? !1 : be(r), ht = (r) => {
|
|
653
653
|
if (typeof r != "object" || r === null || Array.isArray(r)) return;
|
|
654
654
|
const e = {};
|
|
655
655
|
for (const [t, s] of Object.entries(r))
|
|
@@ -670,7 +670,7 @@ const ye = () => {
|
|
|
670
670
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(r.toLowerCase()) ? {
|
|
671
671
|
valid: !1,
|
|
672
672
|
error: "Event name cannot be a reserved word"
|
|
673
|
-
} : { valid: !0 },
|
|
673
|
+
} : { valid: !0 }, Je = (r, e, t) => {
|
|
674
674
|
const s = as(e), n = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
|
|
675
675
|
if (!hs(s))
|
|
676
676
|
return {
|
|
@@ -720,7 +720,7 @@ const ye = () => {
|
|
|
720
720
|
valid: !0,
|
|
721
721
|
sanitizedMetadata: s
|
|
722
722
|
};
|
|
723
|
-
},
|
|
723
|
+
}, ft = (r, e, t) => {
|
|
724
724
|
if (Array.isArray(e)) {
|
|
725
725
|
const s = [], n = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
|
|
726
726
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -730,7 +730,7 @@ const ye = () => {
|
|
|
730
730
|
valid: !1,
|
|
731
731
|
error: `${n}: array item at index ${i} must be an object.`
|
|
732
732
|
};
|
|
733
|
-
const l =
|
|
733
|
+
const l = Je(r, o, t);
|
|
734
734
|
if (!l.valid)
|
|
735
735
|
return {
|
|
736
736
|
valid: !1,
|
|
@@ -743,7 +743,7 @@ const ye = () => {
|
|
|
743
743
|
sanitizedMetadata: s
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
|
-
return
|
|
746
|
+
return Je(r, e, t);
|
|
747
747
|
}, ms = (r, e) => {
|
|
748
748
|
const t = fs(r);
|
|
749
749
|
if (!t.valid)
|
|
@@ -752,7 +752,7 @@ const ye = () => {
|
|
|
752
752
|
}), t;
|
|
753
753
|
if (!e)
|
|
754
754
|
return { valid: !0 };
|
|
755
|
-
const s =
|
|
755
|
+
const s = ft(r, e, "customEvent");
|
|
756
756
|
return s.valid || a("error", "Event metadata validation failed", {
|
|
757
757
|
data: {
|
|
758
758
|
eventName: r,
|
|
@@ -877,7 +877,7 @@ class gs {
|
|
|
877
877
|
this.listeners.clear();
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
|
-
function
|
|
880
|
+
function mt(r, e, t) {
|
|
881
881
|
try {
|
|
882
882
|
const s = e(r);
|
|
883
883
|
return s === null ? null : typeof s == "object" && s !== null && "type" in s ? s : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), r);
|
|
@@ -889,9 +889,9 @@ function gt(r, e, t) {
|
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
function Es(r, e, t) {
|
|
892
|
-
return r.map((s) =>
|
|
892
|
+
return r.map((s) => mt(s, e, t)).filter((s) => s !== null);
|
|
893
893
|
}
|
|
894
|
-
function
|
|
894
|
+
function gt(r, e, t) {
|
|
895
895
|
try {
|
|
896
896
|
const s = e(r);
|
|
897
897
|
return s === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -966,7 +966,7 @@ class _ {
|
|
|
966
966
|
return { ...Ee };
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
|
-
class
|
|
969
|
+
class Ze extends _ {
|
|
970
970
|
storeManager;
|
|
971
971
|
integrationId;
|
|
972
972
|
apiUrl;
|
|
@@ -1051,7 +1051,7 @@ class et extends _ {
|
|
|
1051
1051
|
return { ...this.staticHeaders, ...e };
|
|
1052
1052
|
}
|
|
1053
1053
|
getQueueStorageKey() {
|
|
1054
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1054
|
+
const e = this.get("userId") || "anonymous", t = Ct(e);
|
|
1055
1055
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1056
1056
|
}
|
|
1057
1057
|
/**
|
|
@@ -1108,6 +1108,21 @@ class et extends _ {
|
|
|
1108
1108
|
}
|
|
1109
1109
|
), !0) : this.sendQueueSyncInternal(e);
|
|
1110
1110
|
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Persists events to localStorage for recovery without sending.
|
|
1113
|
+
*
|
|
1114
|
+
* Used when an async send is already in-flight to avoid sending the same
|
|
1115
|
+
* events through two paths (fetch + sendBeacon) with different idempotency tokens.
|
|
1116
|
+
* `ensureBatchMetadata()` assigns a stable token before persisting.
|
|
1117
|
+
* On next page load, `recoverPersistedEvents()` sends with the persisted token.
|
|
1118
|
+
*
|
|
1119
|
+
* @param body - Event queue to persist
|
|
1120
|
+
*/
|
|
1121
|
+
persistForRecovery(e) {
|
|
1122
|
+
if (this.shouldSkipSend()) return;
|
|
1123
|
+
const t = this.ensureBatchMetadata(e);
|
|
1124
|
+
this.persistEventsWithFailureCount(t, 0, !0);
|
|
1125
|
+
}
|
|
1111
1126
|
/**
|
|
1112
1127
|
* Sends events asynchronously using `fetch()` API with automatic persistence on failure.
|
|
1113
1128
|
*
|
|
@@ -1318,7 +1333,7 @@ class et extends _ {
|
|
|
1318
1333
|
if (this.integrationId === "saas")
|
|
1319
1334
|
return e;
|
|
1320
1335
|
const t = this.transformers.beforeBatch;
|
|
1321
|
-
return t ?
|
|
1336
|
+
return t ? gt(e, t, this.integrationId || "SenderManager") : e;
|
|
1322
1337
|
}
|
|
1323
1338
|
/**
|
|
1324
1339
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1569,7 +1584,7 @@ class et extends _ {
|
|
|
1569
1584
|
*
|
|
1570
1585
|
* **Idempotency Token**:
|
|
1571
1586
|
* - Set upstream by ensureBatchMetadata() before this method is called
|
|
1572
|
-
* - Fallback
|
|
1587
|
+
* - Fallback computeContentToken() is defensive only (should not trigger in normal flow)
|
|
1573
1588
|
* - Same token persists across all retry attempts of the same batch
|
|
1574
1589
|
* - Backend uses this to deduplicate retries
|
|
1575
1590
|
*
|
|
@@ -1584,10 +1599,10 @@ class et extends _ {
|
|
|
1584
1599
|
...e,
|
|
1585
1600
|
_metadata: {
|
|
1586
1601
|
...e._metadata,
|
|
1587
|
-
idempotency_token: e._metadata?.idempotency_token ??
|
|
1602
|
+
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1588
1603
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1589
1604
|
timestamp: t,
|
|
1590
|
-
client_version:
|
|
1605
|
+
client_version: Jt
|
|
1591
1606
|
}
|
|
1592
1607
|
};
|
|
1593
1608
|
return {
|
|
@@ -1596,7 +1611,7 @@ class et extends _ {
|
|
|
1596
1611
|
};
|
|
1597
1612
|
}
|
|
1598
1613
|
ensureBatchMetadata(e, t) {
|
|
1599
|
-
const s = e._metadata?.idempotency_token ?? t ??
|
|
1614
|
+
const s = e._metadata?.idempotency_token ?? t ?? this.computeContentToken(e);
|
|
1600
1615
|
return e._metadata?.idempotency_token === s ? e : {
|
|
1601
1616
|
...e,
|
|
1602
1617
|
_metadata: {
|
|
@@ -1605,6 +1620,25 @@ class et extends _ {
|
|
|
1605
1620
|
}
|
|
1606
1621
|
};
|
|
1607
1622
|
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Deterministic 32-bit FNV-1a hash of sorted event IDs.
|
|
1625
|
+
*
|
|
1626
|
+
* **Purpose**: Produces the same idempotency token for the same set of events
|
|
1627
|
+
* across retries, so the backend's success cache catches in-session retries
|
|
1628
|
+
* before any MongoDB work. Replaces a random token that caused the API to
|
|
1629
|
+
* treat retried batches as new and emit `high_duplicate_rate` warnings.
|
|
1630
|
+
*
|
|
1631
|
+
* @param body - Event queue whose events determine the token
|
|
1632
|
+
* @returns 8-char hex string
|
|
1633
|
+
* @private
|
|
1634
|
+
*/
|
|
1635
|
+
computeContentToken(e) {
|
|
1636
|
+
const t = e.events.map((n) => n.id).sort().join(",");
|
|
1637
|
+
let s = 2166136261;
|
|
1638
|
+
for (let n = 0; n < t.length; n++)
|
|
1639
|
+
s ^= t.charCodeAt(n), s = Math.imul(s, 16777619) >>> 0;
|
|
1640
|
+
return s.toString(16).padStart(8, "0");
|
|
1641
|
+
}
|
|
1608
1642
|
/**
|
|
1609
1643
|
* Retrieves persisted events from localStorage with error recovery.
|
|
1610
1644
|
*
|
|
@@ -1736,12 +1770,12 @@ class et extends _ {
|
|
|
1736
1770
|
}
|
|
1737
1771
|
logPermanentError(e, t) {
|
|
1738
1772
|
const s = Date.now();
|
|
1739
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >=
|
|
1773
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= zt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1740
1774
|
data: { status: t.statusCode, message: t.message }
|
|
1741
1775
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: s });
|
|
1742
1776
|
}
|
|
1743
1777
|
}
|
|
1744
|
-
class
|
|
1778
|
+
class ps extends _ {
|
|
1745
1779
|
bootTime;
|
|
1746
1780
|
bootTimestamp;
|
|
1747
1781
|
hasPerformanceNow;
|
|
@@ -1890,7 +1924,7 @@ class Ss extends _ {
|
|
|
1890
1924
|
};
|
|
1891
1925
|
}
|
|
1892
1926
|
}
|
|
1893
|
-
const
|
|
1927
|
+
const Ss = new Set(Object.values(u));
|
|
1894
1928
|
class Ts extends _ {
|
|
1895
1929
|
dataSenders;
|
|
1896
1930
|
emitter;
|
|
@@ -1930,10 +1964,10 @@ class Ts extends _ {
|
|
|
1930
1964
|
* @param fetchCredentials - Fetch credentials mode for custom backend. @default 'include'
|
|
1931
1965
|
*/
|
|
1932
1966
|
constructor(e, t = null, s = {}, n = {}, i, o = "include") {
|
|
1933
|
-
super(), this.emitter = t, this.transformers = s, this.timeManager = new
|
|
1967
|
+
super(), this.emitter = t, this.transformers = s, this.timeManager = new ps(), this.dataSenders = [];
|
|
1934
1968
|
const l = this.get("collectApiUrls");
|
|
1935
|
-
l?.saas && this.dataSenders.push(new
|
|
1936
|
-
new
|
|
1969
|
+
l?.saas && this.dataSenders.push(new Ze(e, "saas", l.saas, s)), l?.custom && this.dataSenders.push(
|
|
1970
|
+
new Ze(
|
|
1937
1971
|
e,
|
|
1938
1972
|
"custom",
|
|
1939
1973
|
l.custom,
|
|
@@ -2061,7 +2095,7 @@ class Ts extends _ {
|
|
|
2061
2095
|
a("error", "Event type is required - event will be ignored");
|
|
2062
2096
|
return;
|
|
2063
2097
|
}
|
|
2064
|
-
if (!
|
|
2098
|
+
if (!Ss.has(e)) {
|
|
2065
2099
|
a("error", "Invalid event type - event will be ignored", {
|
|
2066
2100
|
data: { type: e }
|
|
2067
2101
|
});
|
|
@@ -2091,25 +2125,25 @@ class Ts extends _ {
|
|
|
2091
2125
|
data: { sessionId: g }
|
|
2092
2126
|
}), !T && !this.checkRateLimit())
|
|
2093
2127
|
return;
|
|
2094
|
-
const
|
|
2128
|
+
const p = e;
|
|
2095
2129
|
if (!T) {
|
|
2096
2130
|
if (this.sessionEventCounts.total >= 1e3) {
|
|
2097
2131
|
a("warn", "Session event limit reached", {
|
|
2098
2132
|
data: {
|
|
2099
|
-
type:
|
|
2133
|
+
type: p,
|
|
2100
2134
|
total: this.sessionEventCounts.total,
|
|
2101
2135
|
limit: 1e3
|
|
2102
2136
|
}
|
|
2103
2137
|
});
|
|
2104
2138
|
return;
|
|
2105
2139
|
}
|
|
2106
|
-
const v = this.getTypeLimitForEvent(
|
|
2140
|
+
const v = this.getTypeLimitForEvent(p);
|
|
2107
2141
|
if (v) {
|
|
2108
|
-
const he = this.sessionEventCounts[
|
|
2142
|
+
const he = this.sessionEventCounts[p];
|
|
2109
2143
|
if (he !== void 0 && he >= v) {
|
|
2110
2144
|
a("warn", "Session event type limit reached", {
|
|
2111
2145
|
data: {
|
|
2112
|
-
type:
|
|
2146
|
+
type: p,
|
|
2113
2147
|
count: he,
|
|
2114
2148
|
limit: v
|
|
2115
2149
|
}
|
|
@@ -2118,13 +2152,13 @@ class Ts extends _ {
|
|
|
2118
2152
|
}
|
|
2119
2153
|
}
|
|
2120
2154
|
}
|
|
2121
|
-
if (
|
|
2155
|
+
if (p === u.CUSTOM && o?.name) {
|
|
2122
2156
|
const v = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
2123
2157
|
if (!this.checkPerEventRateLimit(o.name, v))
|
|
2124
2158
|
return;
|
|
2125
2159
|
}
|
|
2126
|
-
const
|
|
2127
|
-
type:
|
|
2160
|
+
const Ve = p === u.SESSION_START, K = t || this.get("pageUrl"), x = this.buildEventPayload({
|
|
2161
|
+
type: p,
|
|
2128
2162
|
page_url: K,
|
|
2129
2163
|
from_page_url: s,
|
|
2130
2164
|
scroll_data: n,
|
|
@@ -2136,7 +2170,7 @@ class Ts extends _ {
|
|
|
2136
2170
|
page_view: f
|
|
2137
2171
|
});
|
|
2138
2172
|
if (x && !(!T && !this.shouldSample())) {
|
|
2139
|
-
if (
|
|
2173
|
+
if (Ve) {
|
|
2140
2174
|
const v = this.get("sessionId");
|
|
2141
2175
|
if (!v) {
|
|
2142
2176
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2152,7 +2186,7 @@ class Ts extends _ {
|
|
|
2152
2186
|
}
|
|
2153
2187
|
if (!this.isDuplicateEvent(x)) {
|
|
2154
2188
|
if (this.get("mode") === ie.QA) {
|
|
2155
|
-
if (
|
|
2189
|
+
if (p === u.CUSTOM && o) {
|
|
2156
2190
|
a("info", `Custom Event: ${o.name}`, {
|
|
2157
2191
|
visibility: "qa",
|
|
2158
2192
|
data: {
|
|
@@ -2162,7 +2196,7 @@ class Ts extends _ {
|
|
|
2162
2196
|
}), this.emitEvent(x);
|
|
2163
2197
|
return;
|
|
2164
2198
|
}
|
|
2165
|
-
if (
|
|
2199
|
+
if (p === u.VIEWPORT_VISIBLE && d) {
|
|
2166
2200
|
const v = d.name || d.id || d.selector;
|
|
2167
2201
|
a("info", `Viewport Visible: ${v}`, {
|
|
2168
2202
|
visibility: "qa",
|
|
@@ -2178,7 +2212,7 @@ class Ts extends _ {
|
|
|
2178
2212
|
}
|
|
2179
2213
|
}
|
|
2180
2214
|
if (this.addToQueue(x), !T) {
|
|
2181
|
-
this.sessionEventCounts.total++, this.sessionEventCounts[
|
|
2215
|
+
this.sessionEventCounts.total++, this.sessionEventCounts[p] !== void 0 && this.sessionEventCounts[p]++;
|
|
2182
2216
|
const v = this.get("sessionId");
|
|
2183
2217
|
v && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(v);
|
|
2184
2218
|
}
|
|
@@ -2447,6 +2481,13 @@ class Ts extends _ {
|
|
|
2447
2481
|
const t = this.buildEventsPayload(), s = [...this.eventsQueue], n = s.map((i) => i.id);
|
|
2448
2482
|
if (this.dataSenders.length === 0)
|
|
2449
2483
|
return this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
2484
|
+
if (e && this.sendInProgress) {
|
|
2485
|
+
for (const i of this.dataSenders)
|
|
2486
|
+
i.persistForRecovery(t);
|
|
2487
|
+
return a("debug", "Sync flush deferred: async send in progress, events persisted for recovery", {
|
|
2488
|
+
data: { eventCount: n.length }
|
|
2489
|
+
}), !0;
|
|
2490
|
+
}
|
|
2450
2491
|
if (e) {
|
|
2451
2492
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2452
2493
|
return o ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : (this.clearSendTimeout(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
|
|
@@ -2519,7 +2560,7 @@ class Ts extends _ {
|
|
|
2519
2560
|
};
|
|
2520
2561
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2521
2562
|
if (!o && l) {
|
|
2522
|
-
const c =
|
|
2563
|
+
const c = gt(n, l, "EventManager");
|
|
2523
2564
|
c !== null && (n = c);
|
|
2524
2565
|
}
|
|
2525
2566
|
return n;
|
|
@@ -2531,7 +2572,7 @@ class Ts extends _ {
|
|
|
2531
2572
|
});
|
|
2532
2573
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2533
2574
|
let l = {
|
|
2534
|
-
id:
|
|
2575
|
+
id: ns(),
|
|
2535
2576
|
type: e.type,
|
|
2536
2577
|
page_url: t,
|
|
2537
2578
|
timestamp: s,
|
|
@@ -2546,9 +2587,9 @@ class Ts extends _ {
|
|
|
2546
2587
|
...e.page_view && { page_view: e.page_view },
|
|
2547
2588
|
...o && { utm: o }
|
|
2548
2589
|
};
|
|
2549
|
-
const c = this.get("collectApiUrls"), d = !!c?.custom, f = !!c?.saas, g = d || f, T = d && f,
|
|
2550
|
-
if (
|
|
2551
|
-
const K =
|
|
2590
|
+
const c = this.get("collectApiUrls"), d = !!c?.custom, f = !!c?.saas, g = d || f, T = d && f, p = this.transformers.beforeSend;
|
|
2591
|
+
if (p && (!g || d && !T)) {
|
|
2592
|
+
const K = mt(l, p, "EventManager");
|
|
2552
2593
|
if (K === null)
|
|
2553
2594
|
return null;
|
|
2554
2595
|
l = K;
|
|
@@ -2725,13 +2766,13 @@ class Ts extends _ {
|
|
|
2725
2766
|
loadSessionCounts(e) {
|
|
2726
2767
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2727
2768
|
return this.getInitialCounts();
|
|
2728
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2769
|
+
const t = this.get("userId") || "anonymous", s = Fe(t, e);
|
|
2729
2770
|
try {
|
|
2730
2771
|
const n = localStorage.getItem(s);
|
|
2731
2772
|
if (!n)
|
|
2732
2773
|
return this.getInitialCounts();
|
|
2733
2774
|
const i = JSON.parse(n);
|
|
2734
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2775
|
+
return i._timestamp && Date.now() - i._timestamp > xe ? (a("debug", "Session counts expired, clearing", {
|
|
2735
2776
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2736
2777
|
}), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[u.CLICK] == "number" && typeof i[u.PAGE_VIEW] == "number" && typeof i[u.CUSTOM] == "number" && typeof i[u.VIEWPORT_VISIBLE] == "number" && typeof i[u.SCROLL] == "number" ? {
|
|
2737
2778
|
total: i.total,
|
|
@@ -2776,12 +2817,12 @@ class Ts extends _ {
|
|
|
2776
2817
|
cleanupExpiredSessionCounts() {
|
|
2777
2818
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2778
2819
|
try {
|
|
2779
|
-
const e = localStorage.getItem(
|
|
2820
|
+
const e = localStorage.getItem($e);
|
|
2780
2821
|
if (e) {
|
|
2781
2822
|
const i = Date.now() - parseInt(e, 10);
|
|
2782
|
-
if (i <
|
|
2823
|
+
if (i < Be) {
|
|
2783
2824
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2784
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2825
|
+
data: { timeSinceLastCleanup: i, throttleMs: Be }
|
|
2785
2826
|
});
|
|
2786
2827
|
return;
|
|
2787
2828
|
}
|
|
@@ -2794,14 +2835,14 @@ class Ts extends _ {
|
|
|
2794
2835
|
const l = localStorage.getItem(o);
|
|
2795
2836
|
if (l) {
|
|
2796
2837
|
const c = JSON.parse(l);
|
|
2797
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2838
|
+
c._timestamp && Date.now() - c._timestamp > xe && n.push(o);
|
|
2798
2839
|
}
|
|
2799
2840
|
} catch {
|
|
2800
2841
|
}
|
|
2801
2842
|
}
|
|
2802
2843
|
n.forEach((i) => {
|
|
2803
2844
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2804
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2845
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem($e, Date.now().toString());
|
|
2805
2846
|
} catch (e) {
|
|
2806
2847
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2807
2848
|
}
|
|
@@ -2835,7 +2876,7 @@ class Ts extends _ {
|
|
|
2835
2876
|
* @internal
|
|
2836
2877
|
*/
|
|
2837
2878
|
saveSessionCounts(e) {
|
|
2838
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2879
|
+
const t = this.get("userId") || "anonymous", s = Fe(t, e);
|
|
2839
2880
|
try {
|
|
2840
2881
|
const n = {
|
|
2841
2882
|
...this.sessionEventCounts,
|
|
@@ -2872,7 +2913,7 @@ class Is {
|
|
|
2872
2913
|
const t = e.getItem(Te);
|
|
2873
2914
|
if (t)
|
|
2874
2915
|
return t;
|
|
2875
|
-
const s =
|
|
2916
|
+
const s = dt();
|
|
2876
2917
|
return e.setItem(Te, s), s;
|
|
2877
2918
|
}
|
|
2878
2919
|
}
|
|
@@ -2903,7 +2944,7 @@ class _s extends _ {
|
|
|
2903
2944
|
return;
|
|
2904
2945
|
}
|
|
2905
2946
|
const e = this.getProjectId();
|
|
2906
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2947
|
+
this.broadcastChannel = new BroadcastChannel(Nt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2907
2948
|
const { action: s, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2908
2949
|
o === e && (s === "session_start" && n && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", n), this.persistSession(n, i), this.isTracking && this.setupSessionTimeout()) : s && s !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: s } }));
|
|
2909
2950
|
};
|
|
@@ -2968,7 +3009,7 @@ class _s extends _ {
|
|
|
2968
3009
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2969
3010
|
}
|
|
2970
3011
|
getSessionStorageKey() {
|
|
2971
|
-
return
|
|
3012
|
+
return Rt(this.getProjectId());
|
|
2972
3013
|
}
|
|
2973
3014
|
getProjectId() {
|
|
2974
3015
|
return this.projectId;
|
|
@@ -3336,7 +3377,7 @@ class ws extends _ {
|
|
|
3336
3377
|
};
|
|
3337
3378
|
}
|
|
3338
3379
|
trackCurrentPage = () => {
|
|
3339
|
-
const e = window.location.href, t =
|
|
3380
|
+
const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
|
|
3340
3381
|
if (this.get("pageUrl") === t)
|
|
3341
3382
|
return;
|
|
3342
3383
|
const s = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3354,7 +3395,7 @@ class ws extends _ {
|
|
|
3354
3395
|
});
|
|
3355
3396
|
};
|
|
3356
3397
|
trackInitialPageView() {
|
|
3357
|
-
const e =
|
|
3398
|
+
const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3358
3399
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3359
3400
|
type: u.PAGE_VIEW,
|
|
3360
3401
|
page_url: e,
|
|
@@ -3510,7 +3551,7 @@ class bs extends _ {
|
|
|
3510
3551
|
return e.hasAttribute(`${b}-name`) ? e : e.closest(`[${b}-name]`);
|
|
3511
3552
|
}
|
|
3512
3553
|
getRelevantClickElement(e) {
|
|
3513
|
-
for (const t of
|
|
3554
|
+
for (const t of bt)
|
|
3514
3555
|
try {
|
|
3515
3556
|
if (e.matches(t))
|
|
3516
3557
|
return e;
|
|
@@ -3590,7 +3631,7 @@ class bs extends _ {
|
|
|
3590
3631
|
*/
|
|
3591
3632
|
sanitizeText(e) {
|
|
3592
3633
|
let t = e;
|
|
3593
|
-
for (const s of
|
|
3634
|
+
for (const s of at) {
|
|
3594
3635
|
const n = new RegExp(s.source, s.flags);
|
|
3595
3636
|
t = t.replace(n, "[REDACTED]");
|
|
3596
3637
|
}
|
|
@@ -3816,11 +3857,11 @@ class As extends _ {
|
|
|
3816
3857
|
const c = this.getViewportHeight(t), d = this.getScrollHeight(t), f = this.getScrollDirection(i, s), g = this.calculateScrollDepth(i, d, c);
|
|
3817
3858
|
let T;
|
|
3818
3859
|
n > 0 ? T = o - n : e.firstScrollEventTime !== null ? T = o - e.firstScrollEventTime : T = 250;
|
|
3819
|
-
const
|
|
3860
|
+
const p = Math.round(l / T * 1e3);
|
|
3820
3861
|
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3821
3862
|
depth: g,
|
|
3822
3863
|
direction: f,
|
|
3823
|
-
velocity:
|
|
3864
|
+
velocity: p,
|
|
3824
3865
|
max_depth_reached: e.maxDepthReached
|
|
3825
3866
|
};
|
|
3826
3867
|
}
|
|
@@ -4355,7 +4396,7 @@ class Ns extends _ {
|
|
|
4355
4396
|
navigationCounter = 0;
|
|
4356
4397
|
// Counter for handling simultaneous navigations edge case
|
|
4357
4398
|
constructor(e) {
|
|
4358
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4399
|
+
super(), this.eventManager = e, this.vitalThresholds = Ke(_e);
|
|
4359
4400
|
}
|
|
4360
4401
|
/**
|
|
4361
4402
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4373,7 +4414,7 @@ class Ns extends _ {
|
|
|
4373
4414
|
*/
|
|
4374
4415
|
async startTracking() {
|
|
4375
4416
|
const e = this.get("config"), t = e?.webVitalsMode ?? _e;
|
|
4376
|
-
this.vitalThresholds =
|
|
4417
|
+
this.vitalThresholds = Ke(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4377
4418
|
}
|
|
4378
4419
|
/**
|
|
4379
4420
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4470,7 +4511,7 @@ class Ns extends _ {
|
|
|
4470
4511
|
const t = e.getEntries();
|
|
4471
4512
|
for (const s of t) {
|
|
4472
4513
|
const n = Number(s.duration.toFixed(2)), i = Date.now();
|
|
4473
|
-
i - this.lastLongTaskSentAt >=
|
|
4514
|
+
i - this.lastLongTaskSentAt >= Kt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4474
4515
|
}
|
|
4475
4516
|
},
|
|
4476
4517
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4486,7 +4527,7 @@ class Ns extends _ {
|
|
|
4486
4527
|
return;
|
|
4487
4528
|
if (s)
|
|
4488
4529
|
s.add(e.type);
|
|
4489
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4530
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Yt) {
|
|
4490
4531
|
const i = this.navigationHistory.shift();
|
|
4491
4532
|
i && this.reportedByNav.delete(i);
|
|
4492
4533
|
}
|
|
@@ -4613,14 +4654,14 @@ class ae extends _ {
|
|
|
4613
4654
|
const e = Date.now();
|
|
4614
4655
|
if (e < this.burstBackoffUntil)
|
|
4615
4656
|
return !1;
|
|
4616
|
-
if (e - this.burstWindowStart >
|
|
4617
|
-
return this.burstBackoffUntil = e +
|
|
4657
|
+
if (e - this.burstWindowStart > Gt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > jt)
|
|
4658
|
+
return this.burstBackoffUntil = e + ze, a("debug", "Error burst detected - entering cooldown", {
|
|
4618
4659
|
data: {
|
|
4619
4660
|
errorsInWindow: this.errorBurstCounter,
|
|
4620
|
-
cooldownMs:
|
|
4661
|
+
cooldownMs: ze
|
|
4621
4662
|
}
|
|
4622
4663
|
}), !1;
|
|
4623
|
-
const s = this.get("config").errorSampling ??
|
|
4664
|
+
const s = this.get("config").errorSampling ?? lt;
|
|
4624
4665
|
return Math.random() < s;
|
|
4625
4666
|
}
|
|
4626
4667
|
handleError = (e) => {
|
|
@@ -4672,12 +4713,12 @@ class ae extends _ {
|
|
|
4672
4713
|
}
|
|
4673
4714
|
}
|
|
4674
4715
|
sanitize(e) {
|
|
4675
|
-
const t = e.length >
|
|
4716
|
+
const t = e.length > Xe ? e.slice(0, Xe) + "..." : e;
|
|
4676
4717
|
return this.sanitizePii(t);
|
|
4677
4718
|
}
|
|
4678
4719
|
sanitizePii(e) {
|
|
4679
4720
|
let t = e;
|
|
4680
|
-
for (const s of
|
|
4721
|
+
for (const s of at) {
|
|
4681
4722
|
const n = new RegExp(s.source, s.flags);
|
|
4682
4723
|
t = t.replace(n, "[REDACTED]");
|
|
4683
4724
|
}
|
|
@@ -4685,19 +4726,19 @@ class ae extends _ {
|
|
|
4685
4726
|
}
|
|
4686
4727
|
shouldSuppressError(e, t) {
|
|
4687
4728
|
const s = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4688
|
-
return i !== void 0 && s - i <
|
|
4729
|
+
return i !== void 0 && s - i < je ? (this.recentErrors.set(n, s), !0) : (this.recentErrors.set(n, s), this.recentErrors.size > Xt ? (this.recentErrors.clear(), this.recentErrors.set(n, s), !1) : (this.recentErrors.size > ee && this.pruneOldErrors(), !1));
|
|
4689
4730
|
}
|
|
4690
4731
|
static TRUNCATION_SUFFIX = `
|
|
4691
4732
|
...truncated`;
|
|
4692
4733
|
truncateStack(e) {
|
|
4693
|
-
if (e.length <=
|
|
4694
|
-
const t =
|
|
4734
|
+
if (e.length <= Ge) return this.sanitizePii(e);
|
|
4735
|
+
const t = Ge - ae.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ae.TRUNCATION_SUFFIX;
|
|
4695
4736
|
return this.sanitizePii(s);
|
|
4696
4737
|
}
|
|
4697
4738
|
pruneOldErrors() {
|
|
4698
4739
|
const e = Date.now();
|
|
4699
4740
|
for (const [n, i] of this.recentErrors.entries())
|
|
4700
|
-
e - i >
|
|
4741
|
+
e - i > je && this.recentErrors.delete(n);
|
|
4701
4742
|
if (this.recentErrors.size <= ee)
|
|
4702
4743
|
return;
|
|
4703
4744
|
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size - ee;
|
|
@@ -4838,10 +4879,10 @@ class Os extends _ {
|
|
|
4838
4879
|
this.set("userId", t);
|
|
4839
4880
|
const s = os(e);
|
|
4840
4881
|
this.set("collectApiUrls", s);
|
|
4841
|
-
const n =
|
|
4882
|
+
const n = Wt();
|
|
4842
4883
|
this.set("device", n);
|
|
4843
|
-
const i =
|
|
4844
|
-
this.set("pageUrl", i),
|
|
4884
|
+
const i = ye(window.location.href, e.sensitiveQueryParams);
|
|
4885
|
+
this.set("pageUrl", i), es() && this.set("mode", ie.QA);
|
|
4845
4886
|
}
|
|
4846
4887
|
/**
|
|
4847
4888
|
* Returns the current configuration object.
|
|
@@ -4892,7 +4933,7 @@ class Os extends _ {
|
|
|
4892
4933
|
valid: !1,
|
|
4893
4934
|
error: "Global metadata must be a plain object"
|
|
4894
4935
|
};
|
|
4895
|
-
const t =
|
|
4936
|
+
const t = ft("Global", e, "globalMetadata");
|
|
4896
4937
|
return t.valid ? { valid: !0 } : {
|
|
4897
4938
|
valid: !1,
|
|
4898
4939
|
error: t.error
|
|
@@ -4959,7 +5000,7 @@ class Os extends _ {
|
|
|
4959
5000
|
a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
|
|
4960
5001
|
return;
|
|
4961
5002
|
}
|
|
4962
|
-
const s = e.trim(), n =
|
|
5003
|
+
const s = e.trim(), n = ht(t), i = {
|
|
4963
5004
|
userId: s,
|
|
4964
5005
|
...n ? { traits: n } : {}
|
|
4965
5006
|
};
|
|
@@ -4978,7 +5019,7 @@ class Os extends _ {
|
|
|
4978
5019
|
*/
|
|
4979
5020
|
async resetIdentity() {
|
|
4980
5021
|
await this.managers.event?.flushImmediately(), this.set("identity", void 0), this.clearPersistedIdentity();
|
|
4981
|
-
const e =
|
|
5022
|
+
const e = dt();
|
|
4982
5023
|
this.managers.storage.setItem(Te, e), this.set("userId", e), this.set("hasStartSession", !1), this.set("sessionId", null), this.handlers.session?.stopTracking(), this.handlers.session?.startTracking(), a("debug", "Identity reset, new UUID generated");
|
|
4983
5024
|
}
|
|
4984
5025
|
/**
|
|
@@ -5088,8 +5129,8 @@ class Os extends _ {
|
|
|
5088
5129
|
}
|
|
5089
5130
|
}
|
|
5090
5131
|
const k = [], M = [];
|
|
5091
|
-
let D = null, h = null, R = !1,
|
|
5092
|
-
const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (
|
|
5132
|
+
let D = null, h = null, R = !1, S = !1, P = null;
|
|
5133
|
+
const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (S = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R && P || (R = !0, P = (async () => {
|
|
5093
5134
|
try {
|
|
5094
5135
|
const e = us(r ?? {}), t = new Os();
|
|
5095
5136
|
try {
|
|
@@ -5121,7 +5162,7 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5121
5162
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5122
5163
|
if (!h)
|
|
5123
5164
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
5124
|
-
if (
|
|
5165
|
+
if (S)
|
|
5125
5166
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
5126
5167
|
h.sendCustomEvent(r, e);
|
|
5127
5168
|
}
|
|
@@ -5152,7 +5193,7 @@ function Us(r, e) {
|
|
|
5152
5193
|
t !== -1 && M.splice(t, 1), M.push({ hook: r, fn: e });
|
|
5153
5194
|
return;
|
|
5154
5195
|
}
|
|
5155
|
-
if (
|
|
5196
|
+
if (S)
|
|
5156
5197
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
5157
5198
|
r === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
5158
5199
|
}
|
|
@@ -5164,7 +5205,7 @@ const Hs = (r) => {
|
|
|
5164
5205
|
e !== -1 && M.splice(e, 1);
|
|
5165
5206
|
return;
|
|
5166
5207
|
}
|
|
5167
|
-
if (
|
|
5208
|
+
if (S)
|
|
5168
5209
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
5169
5210
|
h.removeTransformer(r);
|
|
5170
5211
|
}
|
|
@@ -5176,7 +5217,7 @@ const Hs = (r) => {
|
|
|
5176
5217
|
D = r;
|
|
5177
5218
|
return;
|
|
5178
5219
|
}
|
|
5179
|
-
if (
|
|
5220
|
+
if (S)
|
|
5180
5221
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
5181
5222
|
h.setCustomHeaders(r);
|
|
5182
5223
|
}
|
|
@@ -5186,32 +5227,32 @@ const Hs = (r) => {
|
|
|
5186
5227
|
D = null;
|
|
5187
5228
|
return;
|
|
5188
5229
|
}
|
|
5189
|
-
if (
|
|
5230
|
+
if (S)
|
|
5190
5231
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
5191
5232
|
h.removeCustomHeaders();
|
|
5192
5233
|
}
|
|
5193
5234
|
}, $s = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Bs = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Ws = () => {
|
|
5194
5235
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5195
|
-
if (
|
|
5236
|
+
if (S)
|
|
5196
5237
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
5197
5238
|
if (!h) {
|
|
5198
|
-
|
|
5239
|
+
S = !1;
|
|
5199
5240
|
return;
|
|
5200
5241
|
}
|
|
5201
|
-
|
|
5242
|
+
S = !0;
|
|
5202
5243
|
try {
|
|
5203
|
-
h.destroy(), h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null,
|
|
5244
|
+
h.destroy(), h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, S = !1;
|
|
5204
5245
|
} catch (r) {
|
|
5205
|
-
h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null,
|
|
5246
|
+
h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, S = !1, a("warn", "Error during destroy, forced cleanup completed", { error: r });
|
|
5206
5247
|
}
|
|
5207
5248
|
}
|
|
5208
5249
|
}, Xs = (r) => {
|
|
5209
|
-
typeof window > "u" || typeof document > "u" ||
|
|
5250
|
+
typeof window > "u" || typeof document > "u" || ts(r);
|
|
5210
5251
|
}, Gs = (r) => {
|
|
5211
5252
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5212
5253
|
if (!h)
|
|
5213
5254
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
5214
|
-
if (
|
|
5255
|
+
if (S)
|
|
5215
5256
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5216
5257
|
h.updateGlobalMetadata(r);
|
|
5217
5258
|
}
|
|
@@ -5219,7 +5260,7 @@ const Hs = (r) => {
|
|
|
5219
5260
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5220
5261
|
if (!h)
|
|
5221
5262
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
5222
|
-
if (
|
|
5263
|
+
if (S)
|
|
5223
5264
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5224
5265
|
h.mergeGlobalMetadata(r);
|
|
5225
5266
|
}
|
|
@@ -5233,7 +5274,7 @@ const Hs = (r) => {
|
|
|
5233
5274
|
a("warn", "identify() userId exceeds 256 characters");
|
|
5234
5275
|
return;
|
|
5235
5276
|
}
|
|
5236
|
-
if (
|
|
5277
|
+
if (S) {
|
|
5237
5278
|
a("warn", "Cannot identify while TraceLog is being destroyed");
|
|
5238
5279
|
return;
|
|
5239
5280
|
}
|
|
@@ -5242,7 +5283,7 @@ const Hs = (r) => {
|
|
|
5242
5283
|
return;
|
|
5243
5284
|
}
|
|
5244
5285
|
try {
|
|
5245
|
-
const t =
|
|
5286
|
+
const t = ht(e), s = {
|
|
5246
5287
|
userId: r.trim(),
|
|
5247
5288
|
...t ? { traits: t } : {}
|
|
5248
5289
|
};
|
|
@@ -5260,7 +5301,7 @@ const Hs = (r) => {
|
|
|
5260
5301
|
}
|
|
5261
5302
|
return;
|
|
5262
5303
|
}
|
|
5263
|
-
if (
|
|
5304
|
+
if (S)
|
|
5264
5305
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
5265
5306
|
await h.resetIdentity();
|
|
5266
5307
|
}
|
|
@@ -5282,18 +5323,18 @@ const Hs = (r) => {
|
|
|
5282
5323
|
identify: zs,
|
|
5283
5324
|
resetIdentity: Qs
|
|
5284
5325
|
};
|
|
5285
|
-
var
|
|
5326
|
+
var Ae, C, G, Et, le, pt = -1, V = function(r) {
|
|
5286
5327
|
addEventListener("pageshow", (function(e) {
|
|
5287
5328
|
e.persisted && (pt = e.timeStamp, r(e));
|
|
5288
5329
|
}), !0);
|
|
5289
|
-
},
|
|
5330
|
+
}, Pe = function() {
|
|
5290
5331
|
var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
5291
5332
|
if (r && r.responseStart > 0 && r.responseStart < performance.now()) return r;
|
|
5292
5333
|
}, de = function() {
|
|
5293
|
-
var r =
|
|
5334
|
+
var r = Pe();
|
|
5294
5335
|
return r && r.activationStart || 0;
|
|
5295
5336
|
}, y = function(r, e) {
|
|
5296
|
-
var t =
|
|
5337
|
+
var t = Pe(), s = "navigate";
|
|
5297
5338
|
return pt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || de() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: r, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
|
|
5298
5339
|
}, F = function(r, e, t) {
|
|
5299
5340
|
try {
|
|
@@ -5314,7 +5355,7 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5314
5355
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
5315
5356
|
})(e.value, t), r(e));
|
|
5316
5357
|
};
|
|
5317
|
-
},
|
|
5358
|
+
}, De = function(r) {
|
|
5318
5359
|
requestAnimationFrame((function() {
|
|
5319
5360
|
return requestAnimationFrame((function() {
|
|
5320
5361
|
return r();
|
|
@@ -5329,18 +5370,18 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5329
5370
|
return function() {
|
|
5330
5371
|
e || (r(), e = !0);
|
|
5331
5372
|
};
|
|
5332
|
-
}, H = -1,
|
|
5373
|
+
}, H = -1, et = function() {
|
|
5333
5374
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
5334
5375
|
}, ce = function(r) {
|
|
5335
5376
|
document.visibilityState === "hidden" && H > -1 && (H = r.type === "visibilitychange" ? r.timeStamp : 0, Ks());
|
|
5336
|
-
},
|
|
5377
|
+
}, tt = function() {
|
|
5337
5378
|
addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
|
|
5338
5379
|
}, Ks = function() {
|
|
5339
5380
|
removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
|
|
5340
|
-
},
|
|
5341
|
-
return H < 0 && (H =
|
|
5381
|
+
}, ke = function() {
|
|
5382
|
+
return H < 0 && (H = et(), tt(), V((function() {
|
|
5342
5383
|
setTimeout((function() {
|
|
5343
|
-
H =
|
|
5384
|
+
H = et(), tt();
|
|
5344
5385
|
}), 0);
|
|
5345
5386
|
}))), { get firstHiddenTime() {
|
|
5346
5387
|
return H;
|
|
@@ -5349,21 +5390,21 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5349
5390
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
5350
5391
|
return r();
|
|
5351
5392
|
}), !0) : r();
|
|
5352
|
-
},
|
|
5393
|
+
}, Le = [1800, 3e3], St = function(r, e) {
|
|
5353
5394
|
e = e || {}, Q((function() {
|
|
5354
|
-
var t, s =
|
|
5395
|
+
var t, s = ke(), n = y("FCP"), i = F("paint", (function(o) {
|
|
5355
5396
|
o.forEach((function(l) {
|
|
5356
5397
|
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime - de(), 0), n.entries.push(l), t(!0)));
|
|
5357
5398
|
}));
|
|
5358
5399
|
}));
|
|
5359
|
-
i && (t = w(r, n,
|
|
5360
|
-
n = y("FCP"), t = w(r, n,
|
|
5400
|
+
i && (t = w(r, n, Le, e.reportAllChanges), V((function(o) {
|
|
5401
|
+
n = y("FCP"), t = w(r, n, Le, e.reportAllChanges), De((function() {
|
|
5361
5402
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
5362
5403
|
}));
|
|
5363
5404
|
})));
|
|
5364
5405
|
}));
|
|
5365
|
-
},
|
|
5366
|
-
e = e || {},
|
|
5406
|
+
}, Me = [0.1, 0.25], Ys = function(r, e) {
|
|
5407
|
+
e = e || {}, St(ue((function() {
|
|
5367
5408
|
var t, s = y("CLS", 0), n = 0, i = [], o = function(c) {
|
|
5368
5409
|
c.forEach((function(d) {
|
|
5369
5410
|
if (!d.hadRecentInput) {
|
|
@@ -5372,24 +5413,24 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5372
5413
|
}
|
|
5373
5414
|
})), n > s.value && (s.value = n, s.entries = i, t());
|
|
5374
5415
|
}, l = F("layout-shift", o);
|
|
5375
|
-
l && (t = w(r, s,
|
|
5416
|
+
l && (t = w(r, s, Me, e.reportAllChanges), z((function() {
|
|
5376
5417
|
o(l.takeRecords()), t(!0);
|
|
5377
5418
|
})), V((function() {
|
|
5378
|
-
n = 0, s = y("CLS", 0), t = w(r, s,
|
|
5419
|
+
n = 0, s = y("CLS", 0), t = w(r, s, Me, e.reportAllChanges), De((function() {
|
|
5379
5420
|
return t();
|
|
5380
5421
|
}));
|
|
5381
5422
|
})), setTimeout(t, 0));
|
|
5382
5423
|
})));
|
|
5383
|
-
},
|
|
5424
|
+
}, Tt = 0, pe = 1 / 0, J = 0, qs = function(r) {
|
|
5384
5425
|
r.forEach((function(e) {
|
|
5385
|
-
e.interactionId && (
|
|
5426
|
+
e.interactionId && (pe = Math.min(pe, e.interactionId), J = Math.max(J, e.interactionId), Tt = J ? (J - pe) / 7 + 1 : 0);
|
|
5386
5427
|
}));
|
|
5387
|
-
},
|
|
5388
|
-
return
|
|
5428
|
+
}, It = function() {
|
|
5429
|
+
return Ae ? Tt : performance.interactionCount || 0;
|
|
5389
5430
|
}, Js = function() {
|
|
5390
|
-
"interactionCount" in performance ||
|
|
5391
|
-
}, A = [], te = /* @__PURE__ */ new Map(),
|
|
5392
|
-
var r = Math.min(A.length - 1, Math.floor((
|
|
5431
|
+
"interactionCount" in performance || Ae || (Ae = F("event", qs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5432
|
+
}, A = [], te = /* @__PURE__ */ new Map(), vt = 0, Zs = function() {
|
|
5433
|
+
var r = Math.min(A.length - 1, Math.floor((It() - vt) / 50));
|
|
5393
5434
|
return A[r];
|
|
5394
5435
|
}, er = [], tr = function(r) {
|
|
5395
5436
|
if (er.forEach((function(n) {
|
|
@@ -5409,50 +5450,50 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5409
5450
|
}));
|
|
5410
5451
|
}
|
|
5411
5452
|
}
|
|
5412
|
-
},
|
|
5453
|
+
}, _t = function(r) {
|
|
5413
5454
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5414
5455
|
return r = ue(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
|
|
5415
|
-
},
|
|
5456
|
+
}, Ce = [200, 500], sr = function(r, e) {
|
|
5416
5457
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Q((function() {
|
|
5417
5458
|
var t;
|
|
5418
5459
|
Js();
|
|
5419
5460
|
var s, n = y("INP"), i = function(l) {
|
|
5420
|
-
|
|
5461
|
+
_t((function() {
|
|
5421
5462
|
l.forEach(tr);
|
|
5422
5463
|
var c = Zs();
|
|
5423
5464
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, s());
|
|
5424
5465
|
}));
|
|
5425
5466
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5426
|
-
s = w(r, n,
|
|
5467
|
+
s = w(r, n, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), z((function() {
|
|
5427
5468
|
i(o.takeRecords()), s(!0);
|
|
5428
5469
|
})), V((function() {
|
|
5429
|
-
|
|
5470
|
+
vt = It(), A.length = 0, te.clear(), n = y("INP"), s = w(r, n, Ce, e.reportAllChanges);
|
|
5430
5471
|
})));
|
|
5431
5472
|
})));
|
|
5432
|
-
},
|
|
5473
|
+
}, Re = [2500, 4e3], Se = {}, rr = function(r, e) {
|
|
5433
5474
|
e = e || {}, Q((function() {
|
|
5434
|
-
var t, s =
|
|
5475
|
+
var t, s = ke(), n = y("LCP"), i = function(c) {
|
|
5435
5476
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
|
|
5436
5477
|
d.startTime < s.firstHiddenTime && (n.value = Math.max(d.startTime - de(), 0), n.entries = [d], t());
|
|
5437
5478
|
}));
|
|
5438
5479
|
}, o = F("largest-contentful-paint", i);
|
|
5439
5480
|
if (o) {
|
|
5440
|
-
t = w(r, n,
|
|
5481
|
+
t = w(r, n, Re, e.reportAllChanges);
|
|
5441
5482
|
var l = ue((function() {
|
|
5442
|
-
|
|
5483
|
+
Se[n.id] || (i(o.takeRecords()), o.disconnect(), Se[n.id] = !0, t(!0));
|
|
5443
5484
|
}));
|
|
5444
5485
|
["keydown", "click"].forEach((function(c) {
|
|
5445
5486
|
addEventListener(c, (function() {
|
|
5446
|
-
return
|
|
5487
|
+
return _t(l);
|
|
5447
5488
|
}), { once: !0, capture: !0 });
|
|
5448
5489
|
})), z(l), V((function(c) {
|
|
5449
|
-
n = y("LCP"), t = w(r, n,
|
|
5450
|
-
n.value = performance.now() - c.timeStamp,
|
|
5490
|
+
n = y("LCP"), t = w(r, n, Re, e.reportAllChanges), De((function() {
|
|
5491
|
+
n.value = performance.now() - c.timeStamp, Se[n.id] = !0, t(!0);
|
|
5451
5492
|
}));
|
|
5452
5493
|
}));
|
|
5453
5494
|
}
|
|
5454
5495
|
}));
|
|
5455
|
-
},
|
|
5496
|
+
}, Ne = [800, 1800], nr = function r(e) {
|
|
5456
5497
|
document.prerendering ? Q((function() {
|
|
5457
5498
|
return r(e);
|
|
5458
5499
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
@@ -5460,17 +5501,17 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5460
5501
|
}), !0) : setTimeout(e, 0);
|
|
5461
5502
|
}, ir = function(r, e) {
|
|
5462
5503
|
e = e || {};
|
|
5463
|
-
var t = y("TTFB"), s = w(r, t,
|
|
5504
|
+
var t = y("TTFB"), s = w(r, t, Ne, e.reportAllChanges);
|
|
5464
5505
|
nr((function() {
|
|
5465
|
-
var n =
|
|
5506
|
+
var n = Pe();
|
|
5466
5507
|
n && (t.value = Math.max(n.responseStart - de(), 0), t.entries = [n], s(!0), V((function() {
|
|
5467
|
-
t = y("TTFB", 0), (s = w(r, t,
|
|
5508
|
+
t = y("TTFB", 0), (s = w(r, t, Ne, e.reportAllChanges))(!0);
|
|
5468
5509
|
})));
|
|
5469
5510
|
}));
|
|
5470
|
-
}, W = { passive: !0, capture: !0 }, or = /* @__PURE__ */ new Date(),
|
|
5471
|
-
C || (C = e, G = r,
|
|
5472
|
-
},
|
|
5473
|
-
if (G >= 0 && G <
|
|
5511
|
+
}, W = { passive: !0, capture: !0 }, or = /* @__PURE__ */ new Date(), st = function(r, e) {
|
|
5512
|
+
C || (C = e, G = r, Et = /* @__PURE__ */ new Date(), wt(removeEventListener), yt());
|
|
5513
|
+
}, yt = function() {
|
|
5514
|
+
if (G >= 0 && G < Et - or) {
|
|
5474
5515
|
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + G };
|
|
5475
5516
|
le.forEach((function(e) {
|
|
5476
5517
|
e(r);
|
|
@@ -5481,44 +5522,44 @@ var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
|
5481
5522
|
var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
|
|
5482
5523
|
r.type == "pointerdown" ? (function(t, s) {
|
|
5483
5524
|
var n = function() {
|
|
5484
|
-
|
|
5525
|
+
st(t, s), o();
|
|
5485
5526
|
}, i = function() {
|
|
5486
5527
|
o();
|
|
5487
5528
|
}, o = function() {
|
|
5488
5529
|
removeEventListener("pointerup", n, W), removeEventListener("pointercancel", i, W);
|
|
5489
5530
|
};
|
|
5490
5531
|
addEventListener("pointerup", n, W), addEventListener("pointercancel", i, W);
|
|
5491
|
-
})(e, r) :
|
|
5532
|
+
})(e, r) : st(e, r);
|
|
5492
5533
|
}
|
|
5493
|
-
},
|
|
5534
|
+
}, wt = function(r) {
|
|
5494
5535
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5495
5536
|
return r(e, ar, W);
|
|
5496
5537
|
}));
|
|
5497
|
-
},
|
|
5538
|
+
}, Oe = [100, 300], lr = function(r, e) {
|
|
5498
5539
|
e = e || {}, Q((function() {
|
|
5499
|
-
var t, s =
|
|
5540
|
+
var t, s = ke(), n = y("FID"), i = function(c) {
|
|
5500
5541
|
c.startTime < s.firstHiddenTime && (n.value = c.processingStart - c.startTime, n.entries.push(c), t(!0));
|
|
5501
5542
|
}, o = function(c) {
|
|
5502
5543
|
c.forEach(i);
|
|
5503
5544
|
}, l = F("first-input", o);
|
|
5504
|
-
t = w(r, n,
|
|
5545
|
+
t = w(r, n, Oe, e.reportAllChanges), l && (z(ue((function() {
|
|
5505
5546
|
o(l.takeRecords()), l.disconnect();
|
|
5506
5547
|
}))), V((function() {
|
|
5507
5548
|
var c;
|
|
5508
|
-
n = y("FID"), t = w(r, n,
|
|
5549
|
+
n = y("FID"), t = w(r, n, Oe, e.reportAllChanges), le = [], G = -1, C = null, wt(addEventListener), c = i, le.push(c), yt();
|
|
5509
5550
|
})));
|
|
5510
5551
|
}));
|
|
5511
5552
|
};
|
|
5512
5553
|
const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5513
5554
|
__proto__: null,
|
|
5514
|
-
CLSThresholds:
|
|
5515
|
-
FCPThresholds:
|
|
5516
|
-
FIDThresholds:
|
|
5517
|
-
INPThresholds:
|
|
5518
|
-
LCPThresholds:
|
|
5519
|
-
TTFBThresholds:
|
|
5555
|
+
CLSThresholds: Me,
|
|
5556
|
+
FCPThresholds: Le,
|
|
5557
|
+
FIDThresholds: Oe,
|
|
5558
|
+
INPThresholds: Ce,
|
|
5559
|
+
LCPThresholds: Re,
|
|
5560
|
+
TTFBThresholds: Ne,
|
|
5520
5561
|
onCLS: Ys,
|
|
5521
|
-
onFCP:
|
|
5562
|
+
onFCP: St,
|
|
5522
5563
|
onFID: lr,
|
|
5523
5564
|
onINP: sr,
|
|
5524
5565
|
onLCP: rr,
|
|
@@ -5534,28 +5575,28 @@ export {
|
|
|
5534
5575
|
u as EventType,
|
|
5535
5576
|
vr as InitializationTimeoutError,
|
|
5536
5577
|
N as IntegrationValidationError,
|
|
5537
|
-
|
|
5578
|
+
Sr as MAX_ARRAY_LENGTH,
|
|
5538
5579
|
mr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5539
5580
|
fr as MAX_CUSTOM_EVENT_KEYS,
|
|
5540
5581
|
ur as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5541
5582
|
hr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5542
5583
|
gr as MAX_NESTED_OBJECT_KEYS,
|
|
5543
5584
|
Er as MAX_STRING_LENGTH,
|
|
5544
|
-
|
|
5585
|
+
pr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5545
5586
|
ie as Mode,
|
|
5546
|
-
|
|
5587
|
+
at as PII_PATTERNS,
|
|
5547
5588
|
O as PermanentError,
|
|
5548
5589
|
re as RateLimitError,
|
|
5549
|
-
|
|
5590
|
+
We as SamplingRateValidationError,
|
|
5550
5591
|
Z as ScrollDirection,
|
|
5551
|
-
|
|
5592
|
+
Ot as SessionTimeoutValidationError,
|
|
5552
5593
|
$ as SpecialApiUrl,
|
|
5553
5594
|
ne as TimeoutError,
|
|
5554
5595
|
j as TraceLogValidationError,
|
|
5555
5596
|
_r as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5597
|
+
Qe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5598
|
+
Qt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5599
|
+
Ke as getWebVitalsThresholds,
|
|
5559
5600
|
Tr as isPrimaryScrollEvent,
|
|
5560
5601
|
Ir as isSecondaryScrollEvent,
|
|
5561
5602
|
yr as tracelog
|