@tracelog/lib 2.8.2 → 2.8.3
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 +339 -314
- 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
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const ur = 9e5;
|
|
2
|
+
const dr = 120, hr = 49152, fr = 100, mr = 500, gr = 200;
|
|
3
3
|
const Er = 1e3, pr = 500, Sr = 1e3;
|
|
4
|
-
const b = "data-tlog",
|
|
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) {
|
|
@@ -97,8 +97,8 @@ class ne extends Error {
|
|
|
97
97
|
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ne);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
var
|
|
101
|
-
const Tr = (r) => r.type ===
|
|
100
|
+
var d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r.VIEWPORT_VISIBLE = "viewport_visible", r))(d || {}), Z = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(Z || {}), B = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(B || {}), ie = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(ie || {});
|
|
101
|
+
const Tr = (r) => r.type === d.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !0, Ir = (r) => r.type === d.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !1;
|
|
102
102
|
class j extends Error {
|
|
103
103
|
constructor(e, t, s) {
|
|
104
104
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -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}`, u = 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(u, 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,25 +347,25 @@ 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];
|
|
@@ -377,7 +377,7 @@ const xt = () => {
|
|
|
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
|
+
}, dt = (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 (!dt(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 (!dt(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,10 +501,10 @@ 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
|
-
if (r.integrations &&
|
|
507
|
+
if (r.integrations && us(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
508
508
|
if (!Array.isArray(r.sensitiveQueryParams))
|
|
509
509
|
throw new m(E.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
510
510
|
for (const e of r.sensitiveQueryParams)
|
|
@@ -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");
|
|
@@ -597,7 +597,7 @@ const ye = () => {
|
|
|
597
597
|
throw new m(E.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
598
598
|
if (r.maxTrackedElements !== void 0 && (typeof r.maxTrackedElements != "number" || r.maxTrackedElements <= 0))
|
|
599
599
|
throw new m(E.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
600
|
-
},
|
|
600
|
+
}, us = (r) => {
|
|
601
601
|
if (r) {
|
|
602
602
|
if (r.tracelog && (!r.tracelog.projectId || typeof r.tracelog.projectId != "string" || r.tracelog.projectId.trim() === ""))
|
|
603
603
|
throw new N(E.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
@@ -620,14 +620,14 @@ const ye = () => {
|
|
|
620
620
|
if (r.tracelog?.shopify !== void 0 && typeof r.tracelog.shopify != "boolean")
|
|
621
621
|
throw new N("tracelog.shopify must be a boolean", "config");
|
|
622
622
|
}
|
|
623
|
-
},
|
|
623
|
+
}, ds = (r) => {
|
|
624
624
|
ls(r);
|
|
625
625
|
const e = {
|
|
626
626
|
...r ?? {},
|
|
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 {
|
|
@@ -696,21 +696,21 @@ const ye = () => {
|
|
|
696
696
|
valid: !1,
|
|
697
697
|
error: `${n}: object has too many keys (max 100 keys).`
|
|
698
698
|
};
|
|
699
|
-
for (const [c,
|
|
700
|
-
if (Array.isArray(
|
|
701
|
-
if (
|
|
699
|
+
for (const [c, u] of Object.entries(s)) {
|
|
700
|
+
if (Array.isArray(u)) {
|
|
701
|
+
if (u.length > 500)
|
|
702
702
|
return {
|
|
703
703
|
valid: !1,
|
|
704
704
|
error: `${n}: array property "${c}" is too large (max 500 items).`
|
|
705
705
|
};
|
|
706
|
-
for (const f of
|
|
706
|
+
for (const f of u)
|
|
707
707
|
if (typeof f == "string" && f.length > 500)
|
|
708
708
|
return {
|
|
709
709
|
valid: !1,
|
|
710
710
|
error: `${n}: array property "${c}" contains strings that are too long (max 500 characters).`
|
|
711
711
|
};
|
|
712
712
|
}
|
|
713
|
-
if (typeof
|
|
713
|
+
if (typeof u == "string" && u.length > 1e3)
|
|
714
714
|
return {
|
|
715
715
|
valid: !1,
|
|
716
716
|
error: `${n}: property "${c}" is too long (max 1000 characters).`
|
|
@@ -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
|
/**
|
|
@@ -1333,7 +1333,7 @@ class et extends _ {
|
|
|
1333
1333
|
if (this.integrationId === "saas")
|
|
1334
1334
|
return e;
|
|
1335
1335
|
const t = this.transformers.beforeBatch;
|
|
1336
|
-
return t ?
|
|
1336
|
+
return t ? gt(e, t, this.integrationId || "SenderManager") : e;
|
|
1337
1337
|
}
|
|
1338
1338
|
/**
|
|
1339
1339
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1411,50 +1411,50 @@ class et extends _ {
|
|
|
1411
1411
|
data: { events: n.events.length }
|
|
1412
1412
|
}), !0;
|
|
1413
1413
|
if (this.consecutiveNetworkFailures >= 3) {
|
|
1414
|
-
const
|
|
1415
|
-
if (
|
|
1414
|
+
const u = Date.now() - this.circuitOpenedAt;
|
|
1415
|
+
if (u < 12e4)
|
|
1416
1416
|
return a("debug", `Network circuit open, skipping send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1417
1417
|
data: {
|
|
1418
1418
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
1419
|
-
cooldownRemainingMs: 12e4 -
|
|
1419
|
+
cooldownRemainingMs: 12e4 - u
|
|
1420
1420
|
}
|
|
1421
1421
|
}), !1;
|
|
1422
1422
|
}
|
|
1423
1423
|
const { url: i, payload: o } = this.prepareRequest(n);
|
|
1424
1424
|
let l = !0, c = !1;
|
|
1425
|
-
for (let
|
|
1425
|
+
for (let u = 1; u <= 3; u++)
|
|
1426
1426
|
try {
|
|
1427
|
-
return (await this.sendWithTimeout(i, o)).ok ? (
|
|
1427
|
+
return (await this.sendWithTimeout(i, o)).ok ? (u > 1 && a(
|
|
1428
1428
|
"info",
|
|
1429
|
-
`Send succeeded after ${
|
|
1429
|
+
`Send succeeded after ${u - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1430
1430
|
{
|
|
1431
|
-
data: { events: n.events.length, attempt:
|
|
1431
|
+
data: { events: n.events.length, attempt: u }
|
|
1432
1432
|
}
|
|
1433
1433
|
), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
|
|
1434
1434
|
} catch (f) {
|
|
1435
|
-
const g =
|
|
1435
|
+
const g = u === 3;
|
|
1436
1436
|
if (f instanceof O)
|
|
1437
1437
|
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, f;
|
|
1438
1438
|
if (f instanceof re) {
|
|
1439
1439
|
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l = !1, c = !0, a("warn", `Rate limited, skipping retries${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1440
|
-
data: { events: e.events.length, attempt:
|
|
1440
|
+
data: { events: e.events.length, attempt: u }
|
|
1441
1441
|
});
|
|
1442
1442
|
break;
|
|
1443
1443
|
}
|
|
1444
1444
|
if (f instanceof ne || (l = !1), f instanceof TypeError || (c = !0), a(
|
|
1445
1445
|
g ? "error" : "warn",
|
|
1446
|
-
`Send attempt ${
|
|
1446
|
+
`Send attempt ${u} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${g ? " (all retries exhausted)" : ", will retry"}`,
|
|
1447
1447
|
{
|
|
1448
1448
|
error: f,
|
|
1449
1449
|
data: {
|
|
1450
1450
|
events: e.events.length,
|
|
1451
1451
|
url: i.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1452
|
-
attempt:
|
|
1452
|
+
attempt: u,
|
|
1453
1453
|
maxAttempts: 3
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
1456
1456
|
), !g) {
|
|
1457
|
-
await this.backoffDelay(
|
|
1457
|
+
await this.backoffDelay(u);
|
|
1458
1458
|
continue;
|
|
1459
1459
|
}
|
|
1460
1460
|
return l ? (a(
|
|
@@ -1567,11 +1567,11 @@ class et extends _ {
|
|
|
1567
1567
|
"warn",
|
|
1568
1568
|
`sendBeacon not available, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1569
1569
|
), this.persistEvents(t), !1;
|
|
1570
|
-
const
|
|
1571
|
-
return
|
|
1570
|
+
const u = navigator.sendBeacon(o, c);
|
|
1571
|
+
return u || (a(
|
|
1572
1572
|
"warn",
|
|
1573
1573
|
`sendBeacon rejected request, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1574
|
-
), this.persistEvents(t)),
|
|
1574
|
+
), this.persistEvents(t)), u;
|
|
1575
1575
|
}
|
|
1576
1576
|
/**
|
|
1577
1577
|
* Prepares request by enriching payload with metadata and serializing to JSON.
|
|
@@ -1584,7 +1584,7 @@ class et extends _ {
|
|
|
1584
1584
|
*
|
|
1585
1585
|
* **Idempotency Token**:
|
|
1586
1586
|
* - Set upstream by ensureBatchMetadata() before this method is called
|
|
1587
|
-
* - Fallback
|
|
1587
|
+
* - Fallback computeContentToken() is defensive only (should not trigger in normal flow)
|
|
1588
1588
|
* - Same token persists across all retry attempts of the same batch
|
|
1589
1589
|
* - Backend uses this to deduplicate retries
|
|
1590
1590
|
*
|
|
@@ -1599,10 +1599,10 @@ class et extends _ {
|
|
|
1599
1599
|
...e,
|
|
1600
1600
|
_metadata: {
|
|
1601
1601
|
...e._metadata,
|
|
1602
|
-
idempotency_token: e._metadata?.idempotency_token ??
|
|
1602
|
+
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1603
1603
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1604
1604
|
timestamp: t,
|
|
1605
|
-
client_version:
|
|
1605
|
+
client_version: Jt
|
|
1606
1606
|
}
|
|
1607
1607
|
};
|
|
1608
1608
|
return {
|
|
@@ -1611,7 +1611,7 @@ class et extends _ {
|
|
|
1611
1611
|
};
|
|
1612
1612
|
}
|
|
1613
1613
|
ensureBatchMetadata(e, t) {
|
|
1614
|
-
const s = e._metadata?.idempotency_token ?? t ??
|
|
1614
|
+
const s = e._metadata?.idempotency_token ?? t ?? this.computeContentToken(e);
|
|
1615
1615
|
return e._metadata?.idempotency_token === s ? e : {
|
|
1616
1616
|
...e,
|
|
1617
1617
|
_metadata: {
|
|
@@ -1620,6 +1620,31 @@ class et extends _ {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
};
|
|
1622
1622
|
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Deterministic 32-bit FNV-1a hash of sorted event IDs, salted with
|
|
1625
|
+
* `user_id` and `session_id`.
|
|
1626
|
+
*
|
|
1627
|
+
* **Purpose**: Produces the same idempotency token for the same set of events
|
|
1628
|
+
* across retries, so the backend's success cache catches in-session retries
|
|
1629
|
+
* before any MongoDB work. Replaces a random token that caused the API to
|
|
1630
|
+
* treat retried batches as new and emit `high_duplicate_rate` warnings.
|
|
1631
|
+
*
|
|
1632
|
+
* **Salting**: Scoping the hash by `user_id` + `session_id` ensures that
|
|
1633
|
+
* batches from different users/sessions cannot share a token even if their
|
|
1634
|
+
* event IDs hypothetically collided, eliminating cross-scope dedup risk
|
|
1635
|
+
* regardless of how the backend keys its success cache.
|
|
1636
|
+
*
|
|
1637
|
+
* @param body - Event queue whose events determine the token
|
|
1638
|
+
* @returns 8-char hex string
|
|
1639
|
+
* @private
|
|
1640
|
+
*/
|
|
1641
|
+
computeContentToken(e) {
|
|
1642
|
+
const t = e.events.map((i) => i.id).sort().join(","), s = `${e.user_id}|${e.session_id}|${t}`;
|
|
1643
|
+
let n = 2166136261;
|
|
1644
|
+
for (let i = 0; i < s.length; i++)
|
|
1645
|
+
n ^= s.charCodeAt(i), n = Math.imul(n, 16777619) >>> 0;
|
|
1646
|
+
return n.toString(16).padStart(8, "0");
|
|
1647
|
+
}
|
|
1623
1648
|
/**
|
|
1624
1649
|
* Retrieves persisted events from localStorage with error recovery.
|
|
1625
1650
|
*
|
|
@@ -1751,7 +1776,7 @@ class et extends _ {
|
|
|
1751
1776
|
}
|
|
1752
1777
|
logPermanentError(e, t) {
|
|
1753
1778
|
const s = Date.now();
|
|
1754
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >=
|
|
1779
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= zt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1755
1780
|
data: { status: t.statusCode, message: t.message }
|
|
1756
1781
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: s });
|
|
1757
1782
|
}
|
|
@@ -1905,7 +1930,7 @@ class ps extends _ {
|
|
|
1905
1930
|
};
|
|
1906
1931
|
}
|
|
1907
1932
|
}
|
|
1908
|
-
const Ss = new Set(Object.values(
|
|
1933
|
+
const Ss = new Set(Object.values(d));
|
|
1909
1934
|
class Ts extends _ {
|
|
1910
1935
|
dataSenders;
|
|
1911
1936
|
emitter;
|
|
@@ -1923,11 +1948,11 @@ class Ts extends _ {
|
|
|
1923
1948
|
lastSessionId = null;
|
|
1924
1949
|
sessionEventCounts = {
|
|
1925
1950
|
total: 0,
|
|
1926
|
-
[
|
|
1927
|
-
[
|
|
1928
|
-
[
|
|
1929
|
-
[
|
|
1930
|
-
[
|
|
1951
|
+
[d.CLICK]: 0,
|
|
1952
|
+
[d.PAGE_VIEW]: 0,
|
|
1953
|
+
[d.CUSTOM]: 0,
|
|
1954
|
+
[d.VIEWPORT_VISIBLE]: 0,
|
|
1955
|
+
[d.SCROLL]: 0
|
|
1931
1956
|
};
|
|
1932
1957
|
saveSessionCountsDebounced = null;
|
|
1933
1958
|
/**
|
|
@@ -1947,8 +1972,8 @@ class Ts extends _ {
|
|
|
1947
1972
|
constructor(e, t = null, s = {}, n = {}, i, o = "include") {
|
|
1948
1973
|
super(), this.emitter = t, this.transformers = s, this.timeManager = new ps(), this.dataSenders = [];
|
|
1949
1974
|
const l = this.get("collectApiUrls");
|
|
1950
|
-
l?.saas && this.dataSenders.push(new
|
|
1951
|
-
new
|
|
1975
|
+
l?.saas && this.dataSenders.push(new Ze(e, "saas", l.saas, s)), l?.custom && this.dataSenders.push(
|
|
1976
|
+
new Ze(
|
|
1952
1977
|
e,
|
|
1953
1978
|
"custom",
|
|
1954
1979
|
l.custom,
|
|
@@ -2069,7 +2094,7 @@ class Ts extends _ {
|
|
|
2069
2094
|
custom_event: o,
|
|
2070
2095
|
web_vitals: l,
|
|
2071
2096
|
error_data: c,
|
|
2072
|
-
viewport_data:
|
|
2097
|
+
viewport_data: u,
|
|
2073
2098
|
page_view: f
|
|
2074
2099
|
}) {
|
|
2075
2100
|
if (!e) {
|
|
@@ -2095,13 +2120,13 @@ class Ts extends _ {
|
|
|
2095
2120
|
custom_event: o,
|
|
2096
2121
|
web_vitals: l,
|
|
2097
2122
|
error_data: c,
|
|
2098
|
-
viewport_data:
|
|
2123
|
+
viewport_data: u,
|
|
2099
2124
|
page_view: f
|
|
2100
2125
|
});
|
|
2101
2126
|
return;
|
|
2102
2127
|
}
|
|
2103
2128
|
this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
|
|
2104
|
-
const T = e ===
|
|
2129
|
+
const T = e === d.SESSION_START;
|
|
2105
2130
|
if (T && a("debug", "Processing SESSION_START event", {
|
|
2106
2131
|
data: { sessionId: g }
|
|
2107
2132
|
}), !T && !this.checkRateLimit())
|
|
@@ -2133,12 +2158,12 @@ class Ts extends _ {
|
|
|
2133
2158
|
}
|
|
2134
2159
|
}
|
|
2135
2160
|
}
|
|
2136
|
-
if (p ===
|
|
2161
|
+
if (p === d.CUSTOM && o?.name) {
|
|
2137
2162
|
const v = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
2138
2163
|
if (!this.checkPerEventRateLimit(o.name, v))
|
|
2139
2164
|
return;
|
|
2140
2165
|
}
|
|
2141
|
-
const
|
|
2166
|
+
const Ve = p === d.SESSION_START, K = t || this.get("pageUrl"), x = this.buildEventPayload({
|
|
2142
2167
|
type: p,
|
|
2143
2168
|
page_url: K,
|
|
2144
2169
|
from_page_url: s,
|
|
@@ -2147,11 +2172,11 @@ class Ts extends _ {
|
|
|
2147
2172
|
custom_event: o,
|
|
2148
2173
|
web_vitals: l,
|
|
2149
2174
|
error_data: c,
|
|
2150
|
-
viewport_data:
|
|
2175
|
+
viewport_data: u,
|
|
2151
2176
|
page_view: f
|
|
2152
2177
|
});
|
|
2153
2178
|
if (x && !(!T && !this.shouldSample())) {
|
|
2154
|
-
if (
|
|
2179
|
+
if (Ve) {
|
|
2155
2180
|
const v = this.get("sessionId");
|
|
2156
2181
|
if (!v) {
|
|
2157
2182
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2167,7 +2192,7 @@ class Ts extends _ {
|
|
|
2167
2192
|
}
|
|
2168
2193
|
if (!this.isDuplicateEvent(x)) {
|
|
2169
2194
|
if (this.get("mode") === ie.QA) {
|
|
2170
|
-
if (p ===
|
|
2195
|
+
if (p === d.CUSTOM && o) {
|
|
2171
2196
|
a("info", `Custom Event: ${o.name}`, {
|
|
2172
2197
|
visibility: "qa",
|
|
2173
2198
|
data: {
|
|
@@ -2177,16 +2202,16 @@ class Ts extends _ {
|
|
|
2177
2202
|
}), this.emitEvent(x);
|
|
2178
2203
|
return;
|
|
2179
2204
|
}
|
|
2180
|
-
if (p ===
|
|
2181
|
-
const v =
|
|
2205
|
+
if (p === d.VIEWPORT_VISIBLE && u) {
|
|
2206
|
+
const v = u.name || u.id || u.selector;
|
|
2182
2207
|
a("info", `Viewport Visible: ${v}`, {
|
|
2183
2208
|
visibility: "qa",
|
|
2184
2209
|
data: {
|
|
2185
|
-
selector:
|
|
2186
|
-
...
|
|
2187
|
-
...
|
|
2188
|
-
visibilityRatio:
|
|
2189
|
-
dwellTime:
|
|
2210
|
+
selector: u.selector,
|
|
2211
|
+
...u.name && { name: u.name },
|
|
2212
|
+
...u.id && { id: u.id },
|
|
2213
|
+
visibilityRatio: u.visibilityRatio,
|
|
2214
|
+
dwellTime: u.dwellTime
|
|
2190
2215
|
}
|
|
2191
2216
|
}), this.emitEvent(x);
|
|
2192
2217
|
return;
|
|
@@ -2239,11 +2264,11 @@ class Ts extends _ {
|
|
|
2239
2264
|
const e = this.get("sessionId");
|
|
2240
2265
|
e && this.saveSessionCounts(e), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
|
|
2241
2266
|
total: 0,
|
|
2242
|
-
[
|
|
2243
|
-
[
|
|
2244
|
-
[
|
|
2245
|
-
[
|
|
2246
|
-
[
|
|
2267
|
+
[d.CLICK]: 0,
|
|
2268
|
+
[d.PAGE_VIEW]: 0,
|
|
2269
|
+
[d.CUSTOM]: 0,
|
|
2270
|
+
[d.VIEWPORT_VISIBLE]: 0,
|
|
2271
|
+
[d.SCROLL]: 0
|
|
2247
2272
|
}, this.lastSessionId = null, this.set("hasStartSession", !1), this.dataSenders.forEach((t) => {
|
|
2248
2273
|
t.stop();
|
|
2249
2274
|
});
|
|
@@ -2527,10 +2552,10 @@ class Ts extends _ {
|
|
|
2527
2552
|
buildEventsPayload() {
|
|
2528
2553
|
const e = /* @__PURE__ */ new Map(), t = [];
|
|
2529
2554
|
for (const c of this.eventsQueue) {
|
|
2530
|
-
const
|
|
2531
|
-
e.has(
|
|
2555
|
+
const u = this.createEventSignature(c);
|
|
2556
|
+
e.has(u) || t.push(u), e.set(u, c);
|
|
2532
2557
|
}
|
|
2533
|
-
const s = t.map((c) => e.get(c)).filter((c) => !!c).sort((c,
|
|
2558
|
+
const s = 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);
|
|
2534
2559
|
let n = {
|
|
2535
2560
|
user_id: this.get("userId"),
|
|
2536
2561
|
session_id: this.get("sessionId"),
|
|
@@ -2541,7 +2566,7 @@ class Ts extends _ {
|
|
|
2541
2566
|
};
|
|
2542
2567
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2543
2568
|
if (!o && l) {
|
|
2544
|
-
const c =
|
|
2569
|
+
const c = gt(n, l, "EventManager");
|
|
2545
2570
|
c !== null && (n = c);
|
|
2546
2571
|
}
|
|
2547
2572
|
return n;
|
|
@@ -2553,7 +2578,7 @@ class Ts extends _ {
|
|
|
2553
2578
|
});
|
|
2554
2579
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2555
2580
|
let l = {
|
|
2556
|
-
id:
|
|
2581
|
+
id: ns(),
|
|
2557
2582
|
type: e.type,
|
|
2558
2583
|
page_url: t,
|
|
2559
2584
|
timestamp: s,
|
|
@@ -2568,9 +2593,9 @@ class Ts extends _ {
|
|
|
2568
2593
|
...e.page_view && { page_view: e.page_view },
|
|
2569
2594
|
...o && { utm: o }
|
|
2570
2595
|
};
|
|
2571
|
-
const c = this.get("collectApiUrls"),
|
|
2572
|
-
if (p && (!g ||
|
|
2573
|
-
const K =
|
|
2596
|
+
const c = this.get("collectApiUrls"), u = !!c?.custom, f = !!c?.saas, g = u || f, T = u && f, p = this.transformers.beforeSend;
|
|
2597
|
+
if (p && (!g || u && !T)) {
|
|
2598
|
+
const K = mt(l, p, "EventManager");
|
|
2574
2599
|
if (K === null)
|
|
2575
2600
|
return null;
|
|
2576
2601
|
l = K;
|
|
@@ -2611,13 +2636,13 @@ class Ts extends _ {
|
|
|
2611
2636
|
}
|
|
2612
2637
|
addToQueue(e) {
|
|
2613
2638
|
if (this.emitEvent(e), this.eventsQueue.push(e), this.eventsQueue.length > 100) {
|
|
2614
|
-
const t = this.eventsQueue.findIndex((n) => n.type !==
|
|
2639
|
+
const t = this.eventsQueue.findIndex((n) => n.type !== d.SESSION_START), s = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
|
|
2615
2640
|
a("warn", "Event queue overflow, oldest non-critical event removed", {
|
|
2616
2641
|
data: {
|
|
2617
2642
|
maxLength: 100,
|
|
2618
2643
|
currentLength: this.eventsQueue.length,
|
|
2619
2644
|
removedEventType: s?.type,
|
|
2620
|
-
wasCritical: s?.type ===
|
|
2645
|
+
wasCritical: s?.type === d.SESSION_START
|
|
2621
2646
|
}
|
|
2622
2647
|
});
|
|
2623
2648
|
}
|
|
@@ -2656,11 +2681,11 @@ class Ts extends _ {
|
|
|
2656
2681
|
}
|
|
2657
2682
|
getTypeLimitForEvent(e) {
|
|
2658
2683
|
return {
|
|
2659
|
-
[
|
|
2660
|
-
[
|
|
2661
|
-
[
|
|
2662
|
-
[
|
|
2663
|
-
[
|
|
2684
|
+
[d.CLICK]: 500,
|
|
2685
|
+
[d.PAGE_VIEW]: 100,
|
|
2686
|
+
[d.CUSTOM]: 500,
|
|
2687
|
+
[d.VIEWPORT_VISIBLE]: 200,
|
|
2688
|
+
[d.SCROLL]: 120
|
|
2664
2689
|
}[e] ?? null;
|
|
2665
2690
|
}
|
|
2666
2691
|
removeProcessedEvents(e) {
|
|
@@ -2714,11 +2739,11 @@ class Ts extends _ {
|
|
|
2714
2739
|
getInitialCounts() {
|
|
2715
2740
|
return {
|
|
2716
2741
|
total: 0,
|
|
2717
|
-
[
|
|
2718
|
-
[
|
|
2719
|
-
[
|
|
2720
|
-
[
|
|
2721
|
-
[
|
|
2742
|
+
[d.CLICK]: 0,
|
|
2743
|
+
[d.PAGE_VIEW]: 0,
|
|
2744
|
+
[d.CUSTOM]: 0,
|
|
2745
|
+
[d.VIEWPORT_VISIBLE]: 0,
|
|
2746
|
+
[d.SCROLL]: 0
|
|
2722
2747
|
};
|
|
2723
2748
|
}
|
|
2724
2749
|
/**
|
|
@@ -2747,21 +2772,21 @@ class Ts extends _ {
|
|
|
2747
2772
|
loadSessionCounts(e) {
|
|
2748
2773
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2749
2774
|
return this.getInitialCounts();
|
|
2750
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2775
|
+
const t = this.get("userId") || "anonymous", s = Fe(t, e);
|
|
2751
2776
|
try {
|
|
2752
2777
|
const n = localStorage.getItem(s);
|
|
2753
2778
|
if (!n)
|
|
2754
2779
|
return this.getInitialCounts();
|
|
2755
2780
|
const i = JSON.parse(n);
|
|
2756
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2781
|
+
return i._timestamp && Date.now() - i._timestamp > xe ? (a("debug", "Session counts expired, clearing", {
|
|
2757
2782
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2758
|
-
}), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[
|
|
2783
|
+
}), localStorage.removeItem(s), 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" ? {
|
|
2759
2784
|
total: i.total,
|
|
2760
|
-
[
|
|
2761
|
-
[
|
|
2762
|
-
[
|
|
2763
|
-
[
|
|
2764
|
-
[
|
|
2785
|
+
[d.CLICK]: i[d.CLICK],
|
|
2786
|
+
[d.PAGE_VIEW]: i[d.PAGE_VIEW],
|
|
2787
|
+
[d.CUSTOM]: i[d.CUSTOM],
|
|
2788
|
+
[d.VIEWPORT_VISIBLE]: i[d.VIEWPORT_VISIBLE],
|
|
2789
|
+
[d.SCROLL]: i[d.SCROLL]
|
|
2765
2790
|
} : (a("warn", "Invalid session counts structure in localStorage, resetting", {
|
|
2766
2791
|
data: { sessionId: e, parsed: i }
|
|
2767
2792
|
}), localStorage.removeItem(s), a("debug", "Session counts removed due to invalid/corrupted data", {
|
|
@@ -2798,12 +2823,12 @@ class Ts extends _ {
|
|
|
2798
2823
|
cleanupExpiredSessionCounts() {
|
|
2799
2824
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2800
2825
|
try {
|
|
2801
|
-
const e = localStorage.getItem(
|
|
2826
|
+
const e = localStorage.getItem($e);
|
|
2802
2827
|
if (e) {
|
|
2803
2828
|
const i = Date.now() - parseInt(e, 10);
|
|
2804
|
-
if (i <
|
|
2829
|
+
if (i < Be) {
|
|
2805
2830
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2806
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2831
|
+
data: { timeSinceLastCleanup: i, throttleMs: Be }
|
|
2807
2832
|
});
|
|
2808
2833
|
return;
|
|
2809
2834
|
}
|
|
@@ -2816,14 +2841,14 @@ class Ts extends _ {
|
|
|
2816
2841
|
const l = localStorage.getItem(o);
|
|
2817
2842
|
if (l) {
|
|
2818
2843
|
const c = JSON.parse(l);
|
|
2819
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2844
|
+
c._timestamp && Date.now() - c._timestamp > xe && n.push(o);
|
|
2820
2845
|
}
|
|
2821
2846
|
} catch {
|
|
2822
2847
|
}
|
|
2823
2848
|
}
|
|
2824
2849
|
n.forEach((i) => {
|
|
2825
2850
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2826
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2851
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem($e, Date.now().toString());
|
|
2827
2852
|
} catch (e) {
|
|
2828
2853
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2829
2854
|
}
|
|
@@ -2857,7 +2882,7 @@ class Ts extends _ {
|
|
|
2857
2882
|
* @internal
|
|
2858
2883
|
*/
|
|
2859
2884
|
saveSessionCounts(e) {
|
|
2860
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2885
|
+
const t = this.get("userId") || "anonymous", s = Fe(t, e);
|
|
2861
2886
|
try {
|
|
2862
2887
|
const n = {
|
|
2863
2888
|
...this.sessionEventCounts,
|
|
@@ -2925,7 +2950,7 @@ class _s extends _ {
|
|
|
2925
2950
|
return;
|
|
2926
2951
|
}
|
|
2927
2952
|
const e = this.getProjectId();
|
|
2928
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2953
|
+
this.broadcastChannel = new BroadcastChannel(Nt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2929
2954
|
const { action: s, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2930
2955
|
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 } }));
|
|
2931
2956
|
};
|
|
@@ -2990,7 +3015,7 @@ class _s extends _ {
|
|
|
2990
3015
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2991
3016
|
}
|
|
2992
3017
|
getSessionStorageKey() {
|
|
2993
|
-
return
|
|
3018
|
+
return Rt(this.getProjectId());
|
|
2994
3019
|
}
|
|
2995
3020
|
getProjectId() {
|
|
2996
3021
|
return this.projectId;
|
|
@@ -3074,7 +3099,7 @@ class _s extends _ {
|
|
|
3074
3099
|
}) : (a("debug", "Emitting SESSION_START event", {
|
|
3075
3100
|
data: { sessionId: t }
|
|
3076
3101
|
}), this.eventManager.track({
|
|
3077
|
-
type:
|
|
3102
|
+
type: d.SESSION_START
|
|
3078
3103
|
})), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
3079
3104
|
} catch (i) {
|
|
3080
3105
|
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
|
|
@@ -3113,7 +3138,7 @@ class _s extends _ {
|
|
|
3113
3138
|
a("debug", "Renewing session after timeout", {
|
|
3114
3139
|
data: { newSessionId: e }
|
|
3115
3140
|
}), this.set("sessionId", e), this.set("sessionReferrer", t), this.set("sessionUtm", s), this.persistSession(e, Date.now(), t, s), this.cleanupCrossTabSync(), this.initCrossTabSync(), this.shareSession(e), this.eventManager.track({
|
|
3116
|
-
type:
|
|
3141
|
+
type: d.SESSION_START
|
|
3117
3142
|
}), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
|
|
3118
3143
|
}
|
|
3119
3144
|
cleanupActivityListeners() {
|
|
@@ -3358,7 +3383,7 @@ class ws extends _ {
|
|
|
3358
3383
|
};
|
|
3359
3384
|
}
|
|
3360
3385
|
trackCurrentPage = () => {
|
|
3361
|
-
const e = window.location.href, t =
|
|
3386
|
+
const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
|
|
3362
3387
|
if (this.get("pageUrl") === t)
|
|
3363
3388
|
return;
|
|
3364
3389
|
const s = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3369,16 +3394,16 @@ class ws extends _ {
|
|
|
3369
3394
|
this.set("pageUrl", t);
|
|
3370
3395
|
const o = this.extractPageViewData();
|
|
3371
3396
|
this.eventManager.track({
|
|
3372
|
-
type:
|
|
3397
|
+
type: d.PAGE_VIEW,
|
|
3373
3398
|
page_url: this.get("pageUrl"),
|
|
3374
3399
|
from_page_url: i,
|
|
3375
3400
|
...o && { page_view: o }
|
|
3376
3401
|
});
|
|
3377
3402
|
};
|
|
3378
3403
|
trackInitialPageView() {
|
|
3379
|
-
const e =
|
|
3404
|
+
const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3380
3405
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3381
|
-
type:
|
|
3406
|
+
type: d.PAGE_VIEW,
|
|
3382
3407
|
page_url: e,
|
|
3383
3408
|
...t && { page_view: t }
|
|
3384
3409
|
}), this.onTrack();
|
|
@@ -3433,7 +3458,7 @@ class bs extends _ {
|
|
|
3433
3458
|
if (f) {
|
|
3434
3459
|
const g = this.createCustomEventData(f);
|
|
3435
3460
|
this.eventManager.track({
|
|
3436
|
-
type:
|
|
3461
|
+
type: d.CUSTOM,
|
|
3437
3462
|
custom_event: {
|
|
3438
3463
|
name: g.name,
|
|
3439
3464
|
...g.value && { metadata: { value: g.value } }
|
|
@@ -3441,10 +3466,10 @@ class bs extends _ {
|
|
|
3441
3466
|
});
|
|
3442
3467
|
}
|
|
3443
3468
|
}
|
|
3444
|
-
const
|
|
3469
|
+
const u = this.generateClickData(n, l, c);
|
|
3445
3470
|
this.eventManager.track({
|
|
3446
|
-
type:
|
|
3447
|
-
click_data:
|
|
3471
|
+
type: d.CLICK,
|
|
3472
|
+
click_data: u
|
|
3448
3473
|
});
|
|
3449
3474
|
}, window.addEventListener("click", this.clickHandler, !0));
|
|
3450
3475
|
}
|
|
@@ -3532,7 +3557,7 @@ class bs extends _ {
|
|
|
3532
3557
|
return e.hasAttribute(`${b}-name`) ? e : e.closest(`[${b}-name]`);
|
|
3533
3558
|
}
|
|
3534
3559
|
getRelevantClickElement(e) {
|
|
3535
|
-
for (const t of
|
|
3560
|
+
for (const t of bt)
|
|
3536
3561
|
try {
|
|
3537
3562
|
if (e.matches(t))
|
|
3538
3563
|
return e;
|
|
@@ -3573,7 +3598,7 @@ class bs extends _ {
|
|
|
3573
3598
|
};
|
|
3574
3599
|
}
|
|
3575
3600
|
generateClickData(e, t, s) {
|
|
3576
|
-
const { x: n, y: i, relativeX: o, relativeY: l } = s, c = this.getRelevantText(e, t),
|
|
3601
|
+
const { x: n, y: i, relativeX: o, relativeY: l } = s, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
3577
3602
|
return {
|
|
3578
3603
|
x: n,
|
|
3579
3604
|
y: i,
|
|
@@ -3583,12 +3608,12 @@ class bs extends _ {
|
|
|
3583
3608
|
...t.id && { id: t.id },
|
|
3584
3609
|
...t.className && { class: t.className },
|
|
3585
3610
|
...c && { text: c },
|
|
3586
|
-
...
|
|
3587
|
-
...
|
|
3588
|
-
...
|
|
3589
|
-
...
|
|
3590
|
-
...
|
|
3591
|
-
...Object.keys(
|
|
3611
|
+
...u.href && { href: u.href },
|
|
3612
|
+
...u.title && { title: u.title },
|
|
3613
|
+
...u.alt && { alt: u.alt },
|
|
3614
|
+
...u.role && { role: u.role },
|
|
3615
|
+
...u["aria-label"] && { ariaLabel: u["aria-label"] },
|
|
3616
|
+
...Object.keys(u).length > 0 && { dataAttributes: u }
|
|
3592
3617
|
};
|
|
3593
3618
|
}
|
|
3594
3619
|
/**
|
|
@@ -3612,7 +3637,7 @@ class bs extends _ {
|
|
|
3612
3637
|
*/
|
|
3613
3638
|
sanitizeText(e) {
|
|
3614
3639
|
let t = e;
|
|
3615
|
-
for (const s of
|
|
3640
|
+
for (const s of at) {
|
|
3616
3641
|
const n = new RegExp(s.source, s.flags);
|
|
3617
3642
|
t = t.replace(n, "[REDACTED]");
|
|
3618
3643
|
}
|
|
@@ -3752,7 +3777,7 @@ class As extends _ {
|
|
|
3752
3777
|
return this.isWindowScrollable() ? e === window : this.containers.length === 0;
|
|
3753
3778
|
}
|
|
3754
3779
|
setupScrollContainer(e, t) {
|
|
3755
|
-
if (this.containers.some((
|
|
3780
|
+
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3756
3781
|
return;
|
|
3757
3782
|
const n = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3758
3783
|
n,
|
|
@@ -3772,10 +3797,10 @@ class As extends _ {
|
|
|
3772
3797
|
listener: null
|
|
3773
3798
|
}, c = () => {
|
|
3774
3799
|
this.get("suppressNextScroll") || (l.firstScrollEventTime === null && (l.firstScrollEventTime = Date.now()), this.clearContainerTimer(l), l.debounceTimer = window.setTimeout(() => {
|
|
3775
|
-
const
|
|
3776
|
-
if (
|
|
3800
|
+
const u = this.calculateScrollData(l);
|
|
3801
|
+
if (u) {
|
|
3777
3802
|
const f = Date.now();
|
|
3778
|
-
this.processScrollEvent(l,
|
|
3803
|
+
this.processScrollEvent(l, u, f);
|
|
3779
3804
|
}
|
|
3780
3805
|
l.debounceTimer = null;
|
|
3781
3806
|
}, 250));
|
|
@@ -3788,7 +3813,7 @@ class As extends _ {
|
|
|
3788
3813
|
e.lastEventTime = s, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3789
3814
|
const n = this.get("scrollEventCount") ?? 0;
|
|
3790
3815
|
this.set("scrollEventCount", n + 1), this.eventManager.track({
|
|
3791
|
-
type:
|
|
3816
|
+
type: d.SCROLL,
|
|
3792
3817
|
scroll_data: {
|
|
3793
3818
|
...t,
|
|
3794
3819
|
container_selector: e.selector,
|
|
@@ -3835,7 +3860,7 @@ class As extends _ {
|
|
|
3835
3860
|
const { element: t, lastScrollPos: s, lastEventTime: n } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - s);
|
|
3836
3861
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3837
3862
|
return null;
|
|
3838
|
-
const c = this.getViewportHeight(t),
|
|
3863
|
+
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), f = this.getScrollDirection(i, s), g = this.calculateScrollDepth(i, u, c);
|
|
3839
3864
|
let T;
|
|
3840
3865
|
n > 0 ? T = o - n : e.firstScrollEventTime !== null ? T = o - e.firstScrollEventTime : T = 250;
|
|
3841
3866
|
const p = Math.round(l / T * 1e3);
|
|
@@ -4000,7 +4025,7 @@ class Ls extends _ {
|
|
|
4000
4025
|
...e.name !== void 0 && { name: e.name }
|
|
4001
4026
|
};
|
|
4002
4027
|
this.eventManager.track({
|
|
4003
|
-
type:
|
|
4028
|
+
type: d.VIEWPORT_VISIBLE,
|
|
4004
4029
|
viewport_data: o
|
|
4005
4030
|
}), e.startTime = null, e.timeoutId = null, e.lastFiredTime = i;
|
|
4006
4031
|
}
|
|
@@ -4377,7 +4402,7 @@ class Ns extends _ {
|
|
|
4377
4402
|
navigationCounter = 0;
|
|
4378
4403
|
// Counter for handling simultaneous navigations edge case
|
|
4379
4404
|
constructor(e) {
|
|
4380
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4405
|
+
super(), this.eventManager = e, this.vitalThresholds = Ke(_e);
|
|
4381
4406
|
}
|
|
4382
4407
|
/**
|
|
4383
4408
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4395,7 +4420,7 @@ class Ns extends _ {
|
|
|
4395
4420
|
*/
|
|
4396
4421
|
async startTracking() {
|
|
4397
4422
|
const e = this.get("config"), t = e?.webVitalsMode ?? _e;
|
|
4398
|
-
this.vitalThresholds =
|
|
4423
|
+
this.vitalThresholds = Ke(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4399
4424
|
}
|
|
4400
4425
|
/**
|
|
4401
4426
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4466,8 +4491,8 @@ class Ns extends _ {
|
|
|
4466
4491
|
async initWebVitals() {
|
|
4467
4492
|
try {
|
|
4468
4493
|
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() => cr), o = (l) => (c) => {
|
|
4469
|
-
const
|
|
4470
|
-
this.sendVital({ type: l, value:
|
|
4494
|
+
const u = Number(c.value.toFixed(2));
|
|
4495
|
+
this.sendVital({ type: l, value: u });
|
|
4471
4496
|
};
|
|
4472
4497
|
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), s(o("FCP"), { reportAllChanges: !1 }), n(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
4473
4498
|
} catch (e) {
|
|
@@ -4492,7 +4517,7 @@ class Ns extends _ {
|
|
|
4492
4517
|
const t = e.getEntries();
|
|
4493
4518
|
for (const s of t) {
|
|
4494
4519
|
const n = Number(s.duration.toFixed(2)), i = Date.now();
|
|
4495
|
-
i - this.lastLongTaskSentAt >=
|
|
4520
|
+
i - this.lastLongTaskSentAt >= Kt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4496
4521
|
}
|
|
4497
4522
|
},
|
|
4498
4523
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4508,7 +4533,7 @@ class Ns extends _ {
|
|
|
4508
4533
|
return;
|
|
4509
4534
|
if (s)
|
|
4510
4535
|
s.add(e.type);
|
|
4511
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4536
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Yt) {
|
|
4512
4537
|
const i = this.navigationHistory.shift();
|
|
4513
4538
|
i && this.reportedByNav.delete(i);
|
|
4514
4539
|
}
|
|
@@ -4521,7 +4546,7 @@ class Ns extends _ {
|
|
|
4521
4546
|
return;
|
|
4522
4547
|
}
|
|
4523
4548
|
this.eventManager.track({
|
|
4524
|
-
type:
|
|
4549
|
+
type: d.WEB_VITALS,
|
|
4525
4550
|
web_vitals: {
|
|
4526
4551
|
type: e,
|
|
4527
4552
|
value: t
|
|
@@ -4635,14 +4660,14 @@ class ae extends _ {
|
|
|
4635
4660
|
const e = Date.now();
|
|
4636
4661
|
if (e < this.burstBackoffUntil)
|
|
4637
4662
|
return !1;
|
|
4638
|
-
if (e - this.burstWindowStart >
|
|
4639
|
-
return this.burstBackoffUntil = e +
|
|
4663
|
+
if (e - this.burstWindowStart > Gt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > jt)
|
|
4664
|
+
return this.burstBackoffUntil = e + ze, a("debug", "Error burst detected - entering cooldown", {
|
|
4640
4665
|
data: {
|
|
4641
4666
|
errorsInWindow: this.errorBurstCounter,
|
|
4642
|
-
cooldownMs:
|
|
4667
|
+
cooldownMs: ze
|
|
4643
4668
|
}
|
|
4644
4669
|
}), !1;
|
|
4645
|
-
const s = this.get("config").errorSampling ??
|
|
4670
|
+
const s = this.get("config").errorSampling ?? lt;
|
|
4646
4671
|
return Math.random() < s;
|
|
4647
4672
|
}
|
|
4648
4673
|
handleError = (e) => {
|
|
@@ -4653,7 +4678,7 @@ class ae extends _ {
|
|
|
4653
4678
|
return;
|
|
4654
4679
|
const s = typeof e.error?.stack == "string" ? this.truncateStack(e.error.stack) : void 0;
|
|
4655
4680
|
this.eventManager.track({
|
|
4656
|
-
type:
|
|
4681
|
+
type: d.ERROR,
|
|
4657
4682
|
error_data: {
|
|
4658
4683
|
type: B.JS_ERROR,
|
|
4659
4684
|
message: t,
|
|
@@ -4672,7 +4697,7 @@ class ae extends _ {
|
|
|
4672
4697
|
return;
|
|
4673
4698
|
const n = e.reason instanceof Error && typeof e.reason.stack == "string" ? this.truncateStack(e.reason.stack) : void 0;
|
|
4674
4699
|
this.eventManager.track({
|
|
4675
|
-
type:
|
|
4700
|
+
type: d.ERROR,
|
|
4676
4701
|
error_data: {
|
|
4677
4702
|
type: B.PROMISE_REJECTION,
|
|
4678
4703
|
message: s,
|
|
@@ -4694,12 +4719,12 @@ class ae extends _ {
|
|
|
4694
4719
|
}
|
|
4695
4720
|
}
|
|
4696
4721
|
sanitize(e) {
|
|
4697
|
-
const t = e.length >
|
|
4722
|
+
const t = e.length > Xe ? e.slice(0, Xe) + "..." : e;
|
|
4698
4723
|
return this.sanitizePii(t);
|
|
4699
4724
|
}
|
|
4700
4725
|
sanitizePii(e) {
|
|
4701
4726
|
let t = e;
|
|
4702
|
-
for (const s of
|
|
4727
|
+
for (const s of at) {
|
|
4703
4728
|
const n = new RegExp(s.source, s.flags);
|
|
4704
4729
|
t = t.replace(n, "[REDACTED]");
|
|
4705
4730
|
}
|
|
@@ -4707,19 +4732,19 @@ class ae extends _ {
|
|
|
4707
4732
|
}
|
|
4708
4733
|
shouldSuppressError(e, t) {
|
|
4709
4734
|
const s = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4710
|
-
return i !== void 0 && s - i <
|
|
4735
|
+
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));
|
|
4711
4736
|
}
|
|
4712
4737
|
static TRUNCATION_SUFFIX = `
|
|
4713
4738
|
...truncated`;
|
|
4714
4739
|
truncateStack(e) {
|
|
4715
|
-
if (e.length <=
|
|
4716
|
-
const t =
|
|
4740
|
+
if (e.length <= Ge) return this.sanitizePii(e);
|
|
4741
|
+
const t = Ge - ae.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ae.TRUNCATION_SUFFIX;
|
|
4717
4742
|
return this.sanitizePii(s);
|
|
4718
4743
|
}
|
|
4719
4744
|
pruneOldErrors() {
|
|
4720
4745
|
const e = Date.now();
|
|
4721
4746
|
for (const [n, i] of this.recentErrors.entries())
|
|
4722
|
-
e - i >
|
|
4747
|
+
e - i > je && this.recentErrors.delete(n);
|
|
4723
4748
|
if (this.recentErrors.size <= ee)
|
|
4724
4749
|
return;
|
|
4725
4750
|
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size - ee;
|
|
@@ -4794,7 +4819,7 @@ class Os extends _ {
|
|
|
4794
4819
|
return;
|
|
4795
4820
|
}
|
|
4796
4821
|
this.managers.event.track({
|
|
4797
|
-
type:
|
|
4822
|
+
type: d.CUSTOM,
|
|
4798
4823
|
custom_event: {
|
|
4799
4824
|
name: e,
|
|
4800
4825
|
...o && { metadata: o }
|
|
@@ -4860,10 +4885,10 @@ class Os extends _ {
|
|
|
4860
4885
|
this.set("userId", t);
|
|
4861
4886
|
const s = os(e);
|
|
4862
4887
|
this.set("collectApiUrls", s);
|
|
4863
|
-
const n =
|
|
4888
|
+
const n = Wt();
|
|
4864
4889
|
this.set("device", n);
|
|
4865
|
-
const i =
|
|
4866
|
-
this.set("pageUrl", i),
|
|
4890
|
+
const i = ye(window.location.href, e.sensitiveQueryParams);
|
|
4891
|
+
this.set("pageUrl", i), es() && this.set("mode", ie.QA);
|
|
4867
4892
|
}
|
|
4868
4893
|
/**
|
|
4869
4894
|
* Returns the current configuration object.
|
|
@@ -4914,7 +4939,7 @@ class Os extends _ {
|
|
|
4914
4939
|
valid: !1,
|
|
4915
4940
|
error: "Global metadata must be a plain object"
|
|
4916
4941
|
};
|
|
4917
|
-
const t =
|
|
4942
|
+
const t = ft("Global", e, "globalMetadata");
|
|
4918
4943
|
return t.valid ? { valid: !0 } : {
|
|
4919
4944
|
valid: !1,
|
|
4920
4945
|
error: t.error
|
|
@@ -4981,7 +5006,7 @@ class Os extends _ {
|
|
|
4981
5006
|
a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
|
|
4982
5007
|
return;
|
|
4983
5008
|
}
|
|
4984
|
-
const s = e.trim(), n =
|
|
5009
|
+
const s = e.trim(), n = ht(t), i = {
|
|
4985
5010
|
userId: s,
|
|
4986
5011
|
...n ? { traits: n } : {}
|
|
4987
5012
|
};
|
|
@@ -5104,7 +5129,7 @@ class Os extends _ {
|
|
|
5104
5129
|
}), this.handlers.error = new ae(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new Ls(this.managers.event), this.handlers.viewport.startTracking()), e.integrations?.tracelog?.shopify) {
|
|
5105
5130
|
const s = new Cs();
|
|
5106
5131
|
s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(se.EVENT, (n) => {
|
|
5107
|
-
n.type ===
|
|
5132
|
+
n.type === d.SESSION_START && s.onSessionChange();
|
|
5108
5133
|
});
|
|
5109
5134
|
}
|
|
5110
5135
|
}
|
|
@@ -5113,7 +5138,7 @@ const k = [], M = [];
|
|
|
5113
5138
|
let D = null, h = null, R = !1, S = !1, P = null;
|
|
5114
5139
|
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 () => {
|
|
5115
5140
|
try {
|
|
5116
|
-
const e =
|
|
5141
|
+
const e = ds(r ?? {}), t = new Os();
|
|
5117
5142
|
try {
|
|
5118
5143
|
k.forEach(({ event: o, callback: l }) => {
|
|
5119
5144
|
t.on(o, l);
|
|
@@ -5228,7 +5253,7 @@ const Hs = (r) => {
|
|
|
5228
5253
|
}
|
|
5229
5254
|
}
|
|
5230
5255
|
}, Xs = (r) => {
|
|
5231
|
-
typeof window > "u" || typeof document > "u" ||
|
|
5256
|
+
typeof window > "u" || typeof document > "u" || ts(r);
|
|
5232
5257
|
}, Gs = (r) => {
|
|
5233
5258
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5234
5259
|
if (!h)
|
|
@@ -5264,7 +5289,7 @@ const Hs = (r) => {
|
|
|
5264
5289
|
return;
|
|
5265
5290
|
}
|
|
5266
5291
|
try {
|
|
5267
|
-
const t =
|
|
5292
|
+
const t = ht(e), s = {
|
|
5268
5293
|
userId: r.trim(),
|
|
5269
5294
|
...t ? { traits: t } : {}
|
|
5270
5295
|
};
|
|
@@ -5304,19 +5329,19 @@ const Hs = (r) => {
|
|
|
5304
5329
|
identify: zs,
|
|
5305
5330
|
resetIdentity: Qs
|
|
5306
5331
|
};
|
|
5307
|
-
var
|
|
5332
|
+
var Ae, C, G, Et, le, pt = -1, V = function(r) {
|
|
5308
5333
|
addEventListener("pageshow", (function(e) {
|
|
5309
|
-
e.persisted && (
|
|
5334
|
+
e.persisted && (pt = e.timeStamp, r(e));
|
|
5310
5335
|
}), !0);
|
|
5311
|
-
},
|
|
5336
|
+
}, Pe = function() {
|
|
5312
5337
|
var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
5313
5338
|
if (r && r.responseStart > 0 && r.responseStart < performance.now()) return r;
|
|
5314
|
-
},
|
|
5315
|
-
var r =
|
|
5339
|
+
}, ue = function() {
|
|
5340
|
+
var r = Pe();
|
|
5316
5341
|
return r && r.activationStart || 0;
|
|
5317
5342
|
}, y = function(r, e) {
|
|
5318
|
-
var t =
|
|
5319
|
-
return
|
|
5343
|
+
var t = Pe(), s = "navigate";
|
|
5344
|
+
return pt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || ue() > 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 };
|
|
5320
5345
|
}, F = function(r, e, t) {
|
|
5321
5346
|
try {
|
|
5322
5347
|
if (PerformanceObserver.supportedEntryTypes.includes(r)) {
|
|
@@ -5336,7 +5361,7 @@ var Le, C, G, pt, le, St = -1, V = function(r) {
|
|
|
5336
5361
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
5337
5362
|
})(e.value, t), r(e));
|
|
5338
5363
|
};
|
|
5339
|
-
},
|
|
5364
|
+
}, De = function(r) {
|
|
5340
5365
|
requestAnimationFrame((function() {
|
|
5341
5366
|
return requestAnimationFrame((function() {
|
|
5342
5367
|
return r();
|
|
@@ -5346,23 +5371,23 @@ var Le, C, G, pt, le, St = -1, V = function(r) {
|
|
|
5346
5371
|
document.addEventListener("visibilitychange", (function() {
|
|
5347
5372
|
document.visibilityState === "hidden" && r();
|
|
5348
5373
|
}));
|
|
5349
|
-
},
|
|
5374
|
+
}, de = function(r) {
|
|
5350
5375
|
var e = !1;
|
|
5351
5376
|
return function() {
|
|
5352
5377
|
e || (r(), e = !0);
|
|
5353
5378
|
};
|
|
5354
|
-
}, H = -1,
|
|
5379
|
+
}, H = -1, et = function() {
|
|
5355
5380
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
5356
5381
|
}, ce = function(r) {
|
|
5357
5382
|
document.visibilityState === "hidden" && H > -1 && (H = r.type === "visibilitychange" ? r.timeStamp : 0, Ks());
|
|
5358
|
-
},
|
|
5383
|
+
}, tt = function() {
|
|
5359
5384
|
addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
|
|
5360
5385
|
}, Ks = function() {
|
|
5361
5386
|
removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
|
|
5362
|
-
},
|
|
5363
|
-
return H < 0 && (H =
|
|
5387
|
+
}, ke = function() {
|
|
5388
|
+
return H < 0 && (H = et(), tt(), V((function() {
|
|
5364
5389
|
setTimeout((function() {
|
|
5365
|
-
H =
|
|
5390
|
+
H = et(), tt();
|
|
5366
5391
|
}), 0);
|
|
5367
5392
|
}))), { get firstHiddenTime() {
|
|
5368
5393
|
return H;
|
|
@@ -5371,47 +5396,47 @@ var Le, C, G, pt, le, St = -1, V = function(r) {
|
|
|
5371
5396
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
5372
5397
|
return r();
|
|
5373
5398
|
}), !0) : r();
|
|
5374
|
-
},
|
|
5399
|
+
}, Le = [1800, 3e3], St = function(r, e) {
|
|
5375
5400
|
e = e || {}, Q((function() {
|
|
5376
|
-
var t, s =
|
|
5401
|
+
var t, s = ke(), n = y("FCP"), i = F("paint", (function(o) {
|
|
5377
5402
|
o.forEach((function(l) {
|
|
5378
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime -
|
|
5403
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime - ue(), 0), n.entries.push(l), t(!0)));
|
|
5379
5404
|
}));
|
|
5380
5405
|
}));
|
|
5381
|
-
i && (t = w(r, n,
|
|
5382
|
-
n = y("FCP"), t = w(r, n,
|
|
5406
|
+
i && (t = w(r, n, Le, e.reportAllChanges), V((function(o) {
|
|
5407
|
+
n = y("FCP"), t = w(r, n, Le, e.reportAllChanges), De((function() {
|
|
5383
5408
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
5384
5409
|
}));
|
|
5385
5410
|
})));
|
|
5386
5411
|
}));
|
|
5387
|
-
},
|
|
5388
|
-
e = e || {},
|
|
5412
|
+
}, Me = [0.1, 0.25], Ys = function(r, e) {
|
|
5413
|
+
e = e || {}, St(de((function() {
|
|
5389
5414
|
var t, s = y("CLS", 0), n = 0, i = [], o = function(c) {
|
|
5390
|
-
c.forEach((function(
|
|
5391
|
-
if (!
|
|
5415
|
+
c.forEach((function(u) {
|
|
5416
|
+
if (!u.hadRecentInput) {
|
|
5392
5417
|
var f = i[0], g = i[i.length - 1];
|
|
5393
|
-
n &&
|
|
5418
|
+
n && u.startTime - g.startTime < 1e3 && u.startTime - f.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
5394
5419
|
}
|
|
5395
5420
|
})), n > s.value && (s.value = n, s.entries = i, t());
|
|
5396
5421
|
}, l = F("layout-shift", o);
|
|
5397
|
-
l && (t = w(r, s,
|
|
5422
|
+
l && (t = w(r, s, Me, e.reportAllChanges), z((function() {
|
|
5398
5423
|
o(l.takeRecords()), t(!0);
|
|
5399
5424
|
})), V((function() {
|
|
5400
|
-
n = 0, s = y("CLS", 0), t = w(r, s,
|
|
5425
|
+
n = 0, s = y("CLS", 0), t = w(r, s, Me, e.reportAllChanges), De((function() {
|
|
5401
5426
|
return t();
|
|
5402
5427
|
}));
|
|
5403
5428
|
})), setTimeout(t, 0));
|
|
5404
5429
|
})));
|
|
5405
|
-
},
|
|
5430
|
+
}, Tt = 0, pe = 1 / 0, J = 0, qs = function(r) {
|
|
5406
5431
|
r.forEach((function(e) {
|
|
5407
|
-
e.interactionId && (pe = Math.min(pe, e.interactionId), J = Math.max(J, e.interactionId),
|
|
5432
|
+
e.interactionId && (pe = Math.min(pe, e.interactionId), J = Math.max(J, e.interactionId), Tt = J ? (J - pe) / 7 + 1 : 0);
|
|
5408
5433
|
}));
|
|
5409
|
-
},
|
|
5410
|
-
return
|
|
5434
|
+
}, It = function() {
|
|
5435
|
+
return Ae ? Tt : performance.interactionCount || 0;
|
|
5411
5436
|
}, Js = function() {
|
|
5412
|
-
"interactionCount" in performance ||
|
|
5413
|
-
}, A = [], te = /* @__PURE__ */ new Map(),
|
|
5414
|
-
var r = Math.min(A.length - 1, Math.floor((
|
|
5437
|
+
"interactionCount" in performance || Ae || (Ae = F("event", qs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5438
|
+
}, A = [], te = /* @__PURE__ */ new Map(), vt = 0, Zs = function() {
|
|
5439
|
+
var r = Math.min(A.length - 1, Math.floor((It() - vt) / 50));
|
|
5415
5440
|
return A[r];
|
|
5416
5441
|
}, er = [], tr = function(r) {
|
|
5417
5442
|
if (er.forEach((function(n) {
|
|
@@ -5431,50 +5456,50 @@ var Le, C, G, pt, le, St = -1, V = function(r) {
|
|
|
5431
5456
|
}));
|
|
5432
5457
|
}
|
|
5433
5458
|
}
|
|
5434
|
-
},
|
|
5459
|
+
}, _t = function(r) {
|
|
5435
5460
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5436
|
-
return r =
|
|
5437
|
-
},
|
|
5461
|
+
return r = de(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
|
|
5462
|
+
}, Ce = [200, 500], sr = function(r, e) {
|
|
5438
5463
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Q((function() {
|
|
5439
5464
|
var t;
|
|
5440
5465
|
Js();
|
|
5441
5466
|
var s, n = y("INP"), i = function(l) {
|
|
5442
|
-
|
|
5467
|
+
_t((function() {
|
|
5443
5468
|
l.forEach(tr);
|
|
5444
5469
|
var c = Zs();
|
|
5445
5470
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, s());
|
|
5446
5471
|
}));
|
|
5447
5472
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5448
|
-
s = w(r, n,
|
|
5473
|
+
s = w(r, n, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), z((function() {
|
|
5449
5474
|
i(o.takeRecords()), s(!0);
|
|
5450
5475
|
})), V((function() {
|
|
5451
|
-
|
|
5476
|
+
vt = It(), A.length = 0, te.clear(), n = y("INP"), s = w(r, n, Ce, e.reportAllChanges);
|
|
5452
5477
|
})));
|
|
5453
5478
|
})));
|
|
5454
|
-
},
|
|
5479
|
+
}, Re = [2500, 4e3], Se = {}, rr = function(r, e) {
|
|
5455
5480
|
e = e || {}, Q((function() {
|
|
5456
|
-
var t, s =
|
|
5457
|
-
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(
|
|
5458
|
-
|
|
5481
|
+
var t, s = ke(), n = y("LCP"), i = function(c) {
|
|
5482
|
+
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
5483
|
+
u.startTime < s.firstHiddenTime && (n.value = Math.max(u.startTime - ue(), 0), n.entries = [u], t());
|
|
5459
5484
|
}));
|
|
5460
5485
|
}, o = F("largest-contentful-paint", i);
|
|
5461
5486
|
if (o) {
|
|
5462
|
-
t = w(r, n,
|
|
5463
|
-
var l =
|
|
5487
|
+
t = w(r, n, Re, e.reportAllChanges);
|
|
5488
|
+
var l = de((function() {
|
|
5464
5489
|
Se[n.id] || (i(o.takeRecords()), o.disconnect(), Se[n.id] = !0, t(!0));
|
|
5465
5490
|
}));
|
|
5466
5491
|
["keydown", "click"].forEach((function(c) {
|
|
5467
5492
|
addEventListener(c, (function() {
|
|
5468
|
-
return
|
|
5493
|
+
return _t(l);
|
|
5469
5494
|
}), { once: !0, capture: !0 });
|
|
5470
5495
|
})), z(l), V((function(c) {
|
|
5471
|
-
n = y("LCP"), t = w(r, n,
|
|
5496
|
+
n = y("LCP"), t = w(r, n, Re, e.reportAllChanges), De((function() {
|
|
5472
5497
|
n.value = performance.now() - c.timeStamp, Se[n.id] = !0, t(!0);
|
|
5473
5498
|
}));
|
|
5474
5499
|
}));
|
|
5475
5500
|
}
|
|
5476
5501
|
}));
|
|
5477
|
-
},
|
|
5502
|
+
}, Ne = [800, 1800], nr = function r(e) {
|
|
5478
5503
|
document.prerendering ? Q((function() {
|
|
5479
5504
|
return r(e);
|
|
5480
5505
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
@@ -5482,17 +5507,17 @@ var Le, C, G, pt, le, St = -1, V = function(r) {
|
|
|
5482
5507
|
}), !0) : setTimeout(e, 0);
|
|
5483
5508
|
}, ir = function(r, e) {
|
|
5484
5509
|
e = e || {};
|
|
5485
|
-
var t = y("TTFB"), s = w(r, t,
|
|
5510
|
+
var t = y("TTFB"), s = w(r, t, Ne, e.reportAllChanges);
|
|
5486
5511
|
nr((function() {
|
|
5487
|
-
var n =
|
|
5488
|
-
n && (t.value = Math.max(n.responseStart -
|
|
5489
|
-
t = y("TTFB", 0), (s = w(r, t,
|
|
5512
|
+
var n = Pe();
|
|
5513
|
+
n && (t.value = Math.max(n.responseStart - ue(), 0), t.entries = [n], s(!0), V((function() {
|
|
5514
|
+
t = y("TTFB", 0), (s = w(r, t, Ne, e.reportAllChanges))(!0);
|
|
5490
5515
|
})));
|
|
5491
5516
|
}));
|
|
5492
|
-
}, W = { passive: !0, capture: !0 }, or = /* @__PURE__ */ new Date(),
|
|
5493
|
-
C || (C = e, G = r,
|
|
5494
|
-
},
|
|
5495
|
-
if (G >= 0 && G <
|
|
5517
|
+
}, W = { passive: !0, capture: !0 }, or = /* @__PURE__ */ new Date(), st = function(r, e) {
|
|
5518
|
+
C || (C = e, G = r, Et = /* @__PURE__ */ new Date(), wt(removeEventListener), yt());
|
|
5519
|
+
}, yt = function() {
|
|
5520
|
+
if (G >= 0 && G < Et - or) {
|
|
5496
5521
|
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + G };
|
|
5497
5522
|
le.forEach((function(e) {
|
|
5498
5523
|
e(r);
|
|
@@ -5503,44 +5528,44 @@ var Le, C, G, pt, le, St = -1, V = function(r) {
|
|
|
5503
5528
|
var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
|
|
5504
5529
|
r.type == "pointerdown" ? (function(t, s) {
|
|
5505
5530
|
var n = function() {
|
|
5506
|
-
|
|
5531
|
+
st(t, s), o();
|
|
5507
5532
|
}, i = function() {
|
|
5508
5533
|
o();
|
|
5509
5534
|
}, o = function() {
|
|
5510
5535
|
removeEventListener("pointerup", n, W), removeEventListener("pointercancel", i, W);
|
|
5511
5536
|
};
|
|
5512
5537
|
addEventListener("pointerup", n, W), addEventListener("pointercancel", i, W);
|
|
5513
|
-
})(e, r) :
|
|
5538
|
+
})(e, r) : st(e, r);
|
|
5514
5539
|
}
|
|
5515
|
-
},
|
|
5540
|
+
}, wt = function(r) {
|
|
5516
5541
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5517
5542
|
return r(e, ar, W);
|
|
5518
5543
|
}));
|
|
5519
|
-
},
|
|
5544
|
+
}, Oe = [100, 300], lr = function(r, e) {
|
|
5520
5545
|
e = e || {}, Q((function() {
|
|
5521
|
-
var t, s =
|
|
5546
|
+
var t, s = ke(), n = y("FID"), i = function(c) {
|
|
5522
5547
|
c.startTime < s.firstHiddenTime && (n.value = c.processingStart - c.startTime, n.entries.push(c), t(!0));
|
|
5523
5548
|
}, o = function(c) {
|
|
5524
5549
|
c.forEach(i);
|
|
5525
5550
|
}, l = F("first-input", o);
|
|
5526
|
-
t = w(r, n,
|
|
5551
|
+
t = w(r, n, Oe, e.reportAllChanges), l && (z(de((function() {
|
|
5527
5552
|
o(l.takeRecords()), l.disconnect();
|
|
5528
5553
|
}))), V((function() {
|
|
5529
5554
|
var c;
|
|
5530
|
-
n = y("FID"), t = w(r, n,
|
|
5555
|
+
n = y("FID"), t = w(r, n, Oe, e.reportAllChanges), le = [], G = -1, C = null, wt(addEventListener), c = i, le.push(c), yt();
|
|
5531
5556
|
})));
|
|
5532
5557
|
}));
|
|
5533
5558
|
};
|
|
5534
5559
|
const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5535
5560
|
__proto__: null,
|
|
5536
|
-
CLSThresholds:
|
|
5537
|
-
FCPThresholds:
|
|
5538
|
-
FIDThresholds:
|
|
5539
|
-
INPThresholds:
|
|
5540
|
-
LCPThresholds:
|
|
5541
|
-
TTFBThresholds:
|
|
5561
|
+
CLSThresholds: Me,
|
|
5562
|
+
FCPThresholds: Le,
|
|
5563
|
+
FIDThresholds: Oe,
|
|
5564
|
+
INPThresholds: Ce,
|
|
5565
|
+
LCPThresholds: Re,
|
|
5566
|
+
TTFBThresholds: Ne,
|
|
5542
5567
|
onCLS: Ys,
|
|
5543
|
-
onFCP:
|
|
5568
|
+
onFCP: St,
|
|
5544
5569
|
onFID: lr,
|
|
5545
5570
|
onINP: sr,
|
|
5546
5571
|
onLCP: rr,
|
|
@@ -5548,36 +5573,36 @@ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5548
5573
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5549
5574
|
export {
|
|
5550
5575
|
m as AppConfigValidationError,
|
|
5551
|
-
|
|
5576
|
+
ur as DEFAULT_SESSION_TIMEOUT,
|
|
5552
5577
|
_e as DEFAULT_WEB_VITALS_MODE,
|
|
5553
5578
|
L as DeviceType,
|
|
5554
5579
|
se as EmitterEvent,
|
|
5555
5580
|
B as ErrorType,
|
|
5556
|
-
|
|
5581
|
+
d as EventType,
|
|
5557
5582
|
vr as InitializationTimeoutError,
|
|
5558
5583
|
N as IntegrationValidationError,
|
|
5559
5584
|
Sr as MAX_ARRAY_LENGTH,
|
|
5560
5585
|
mr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5561
5586
|
fr as MAX_CUSTOM_EVENT_KEYS,
|
|
5562
|
-
|
|
5587
|
+
dr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5563
5588
|
hr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5564
5589
|
gr as MAX_NESTED_OBJECT_KEYS,
|
|
5565
5590
|
Er as MAX_STRING_LENGTH,
|
|
5566
5591
|
pr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5567
5592
|
ie as Mode,
|
|
5568
|
-
|
|
5593
|
+
at as PII_PATTERNS,
|
|
5569
5594
|
O as PermanentError,
|
|
5570
5595
|
re as RateLimitError,
|
|
5571
|
-
|
|
5596
|
+
We as SamplingRateValidationError,
|
|
5572
5597
|
Z as ScrollDirection,
|
|
5573
|
-
|
|
5598
|
+
Ot as SessionTimeoutValidationError,
|
|
5574
5599
|
$ as SpecialApiUrl,
|
|
5575
5600
|
ne as TimeoutError,
|
|
5576
5601
|
j as TraceLogValidationError,
|
|
5577
5602
|
_r as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5603
|
+
Qe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5604
|
+
Qt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5605
|
+
Ke as getWebVitalsThresholds,
|
|
5581
5606
|
Tr as isPrimaryScrollEvent,
|
|
5582
5607
|
Ir as isSecondaryScrollEvent,
|
|
5583
5608
|
yr as tracelog
|