@tracelog/lib 2.0.3 → 2.1.0-rc.74.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +654 -542
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +1 -1
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/public-api.cjs +306 -131
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +59 -9
- package/dist/public-api.d.ts +59 -9
- package/dist/public-api.js +306 -131
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
const Or = 9e5;
|
|
2
|
+
const Pr = 120, Dr = 8192, Vr = 10, kr = 10, Ur = 20, xr = 1;
|
|
3
|
+
const Hr = 1e3, $r = 500, Fr = 100;
|
|
4
|
+
const w = "data-tlog", st = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const v = "data-tlog", tt = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], it = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], ot = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,53 +71,53 @@ const m = {
|
|
|
71
71
|
INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
},
|
|
74
|
+
}, at = [
|
|
75
75
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
76
76
|
/javascript:/gi,
|
|
77
77
|
/on\w+\s*=/gi,
|
|
78
78
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
79
79
|
/<embed\b[^>]*>/gi,
|
|
80
80
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
81
|
-
], I = "tlog",
|
|
82
|
-
var
|
|
83
|
-
class
|
|
81
|
+
], I = "tlog", x = `${I}:qa_mode`, Te = `${I}:uid`, xe = "tlog_mode", _e = "qa", ve = "qa_off", lt = (n) => n ? `${I}:${n}:queue` : `${I}:queue`, ct = (n) => n ? `${I}:${n}:session` : `${I}:session`, ut = (n) => n ? `${I}:${n}:broadcast` : `${I}:broadcast`, Ie = (n, e) => `${I}:${n}:session_counts:${e}`, we = 10080 * 60 * 1e3, ye = `${I}:session_counts_last_cleanup`, be = 3600 * 1e3;
|
|
82
|
+
var k = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(k || {}), L = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(L || {}), se = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(se || {});
|
|
83
|
+
class N extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
85
|
+
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
var
|
|
89
|
-
const
|
|
90
|
-
class
|
|
88
|
+
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n.VIEWPORT_VISIBLE = "viewport_visible", n))(d || {}), X = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(X || {}), U = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(U || {}), j = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(j || {});
|
|
89
|
+
const Br = (n) => n.type === d.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !0, Wr = (n) => n.type === d.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !1;
|
|
90
|
+
class H extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
class h extends
|
|
95
|
+
class h extends H {
|
|
96
96
|
constructor(e, t = "config") {
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class dt extends H {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class Ae extends H {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
class
|
|
110
|
+
class V extends H {
|
|
111
111
|
constructor(e, t = "config") {
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class Gr extends H {
|
|
116
116
|
constructor(e, t, r = "runtime") {
|
|
117
117
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
const
|
|
120
|
+
const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", $e = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ht = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ft = (n, e) => {
|
|
121
121
|
if (e) {
|
|
122
122
|
if (e instanceof Error) {
|
|
123
123
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -136,17 +136,24 @@ const ct = (n, e) => {
|
|
|
136
136
|
return `[TraceLog] ${n}: ${String(e)}`;
|
|
137
137
|
}
|
|
138
138
|
return `[TraceLog] ${n}`;
|
|
139
|
+
}, mt = () => {
|
|
140
|
+
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
|
+
return !1;
|
|
142
|
+
try {
|
|
143
|
+
return sessionStorage.getItem(x) === "true";
|
|
144
|
+
} catch {
|
|
145
|
+
return !1;
|
|
146
|
+
}
|
|
139
147
|
}, a = (n, e, t) => {
|
|
140
|
-
const { error: r, data: s, showToClient: i = !1, style: o } = t ?? {},
|
|
141
|
-
if (
|
|
148
|
+
const { error: r, data: s, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? ft(e, r) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
149
|
+
if (!gt(l, i))
|
|
142
150
|
return;
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}, se = (n) => {
|
|
151
|
+
const g = Et(l, o), E = s !== void 0 ? ie(s) : void 0;
|
|
152
|
+
St(u, c, g, E);
|
|
153
|
+
}, gt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? mt() : !1, Et = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? ht : "", St = (n, e, t, r) => {
|
|
154
|
+
const s = t !== void 0 && t !== "", i = s ? `%c${e}` : e;
|
|
155
|
+
r !== void 0 ? s ? console[n](i, t, r) : console[n](i, r) : s ? console[n](i, t) : console[n](i);
|
|
156
|
+
}, ie = (n) => {
|
|
150
157
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
151
158
|
for (const [r, s] of Object.entries(n)) {
|
|
152
159
|
const i = r.toLowerCase();
|
|
@@ -154,27 +161,67 @@ const ct = (n, e) => {
|
|
|
154
161
|
e[r] = "[REDACTED]";
|
|
155
162
|
continue;
|
|
156
163
|
}
|
|
157
|
-
s !== null && typeof s == "object" && !Array.isArray(s) ? e[r] =
|
|
158
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
164
|
+
s !== null && typeof s == "object" && !Array.isArray(s) ? e[r] = ie(s) : Array.isArray(s) ? e[r] = s.map(
|
|
165
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ie(o) : o
|
|
159
166
|
) : e[r] = s;
|
|
160
167
|
}
|
|
161
168
|
return e;
|
|
162
169
|
};
|
|
163
|
-
let
|
|
164
|
-
const
|
|
165
|
-
typeof window < "u" && !
|
|
166
|
-
},
|
|
170
|
+
let oe, Fe;
|
|
171
|
+
const pt = () => {
|
|
172
|
+
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"), Fe = window.matchMedia("(hover: none)"));
|
|
173
|
+
}, K = "Unknown", Tt = (n) => {
|
|
174
|
+
const e = n.userAgentData?.platform;
|
|
175
|
+
if (e != null && e !== "") {
|
|
176
|
+
if (/windows/i.test(e)) return "Windows";
|
|
177
|
+
if (/macos/i.test(e)) return "macOS";
|
|
178
|
+
if (/android/i.test(e)) return "Android";
|
|
179
|
+
if (/linux/i.test(e)) return "Linux";
|
|
180
|
+
if (/chromeos/i.test(e)) return "ChromeOS";
|
|
181
|
+
if (/ios/i.test(e)) return "iOS";
|
|
182
|
+
}
|
|
183
|
+
const t = navigator.userAgent;
|
|
184
|
+
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : K;
|
|
185
|
+
}, _t = (n) => {
|
|
186
|
+
const e = n.userAgentData?.brands;
|
|
187
|
+
if (e != null && e.length > 0) {
|
|
188
|
+
const s = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
189
|
+
if (s != null) {
|
|
190
|
+
const i = s.brand;
|
|
191
|
+
return /google chrome/i.test(i) ? "Chrome" : /microsoft edge/i.test(i) ? "Edge" : /opera/i.test(i) ? "Opera" : i;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const t = navigator.userAgent;
|
|
195
|
+
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : K;
|
|
196
|
+
}, vt = () => {
|
|
197
|
+
try {
|
|
198
|
+
const n = navigator;
|
|
199
|
+
if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
|
|
200
|
+
const c = n.userAgentData.platform;
|
|
201
|
+
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : n.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
202
|
+
}
|
|
203
|
+
pt();
|
|
204
|
+
const e = window.innerWidth, t = oe?.matches ?? !1, r = Fe?.matches ?? !1, s = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
205
|
+
return e <= 767 || o && s ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && s ? L.Tablet : L.Desktop;
|
|
206
|
+
} catch (n) {
|
|
207
|
+
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), L.Desktop;
|
|
208
|
+
}
|
|
209
|
+
}, It = () => {
|
|
167
210
|
try {
|
|
168
211
|
const n = navigator;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
212
|
+
return {
|
|
213
|
+
type: vt(),
|
|
214
|
+
os: Tt(n),
|
|
215
|
+
browser: _t(n)
|
|
216
|
+
};
|
|
174
217
|
} catch (n) {
|
|
175
|
-
return a("
|
|
218
|
+
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
219
|
+
type: L.Desktop,
|
|
220
|
+
os: K,
|
|
221
|
+
browser: K
|
|
222
|
+
};
|
|
176
223
|
}
|
|
177
|
-
},
|
|
224
|
+
}, Be = [
|
|
178
225
|
// Email addresses
|
|
179
226
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
180
227
|
// US Phone numbers (various formats)
|
|
@@ -189,7 +236,7 @@ const ut = () => {
|
|
|
189
236
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
190
237
|
// Passwords in connection strings (protocol://user:password@host)
|
|
191
238
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
192
|
-
],
|
|
239
|
+
], Le = 500, Me = 5e3, Q = 50, wt = Q * 2, We = 1, yt = 1e3, bt = 10, Ce = 5e3, At = 6e4, Xr = {
|
|
193
240
|
LCP: 2500,
|
|
194
241
|
// Good: ≤ 2.5s
|
|
195
242
|
FCP: 1800,
|
|
@@ -213,7 +260,7 @@ const ut = () => {
|
|
|
213
260
|
TTFB: 800,
|
|
214
261
|
// Needs improvement: > 800ms
|
|
215
262
|
LONG_TASK: 50
|
|
216
|
-
},
|
|
263
|
+
}, Lt = {
|
|
217
264
|
LCP: 4e3,
|
|
218
265
|
// Poor: > 4s
|
|
219
266
|
FCP: 3e3,
|
|
@@ -225,7 +272,7 @@ const ut = () => {
|
|
|
225
272
|
TTFB: 1800,
|
|
226
273
|
// Poor: > 1800ms
|
|
227
274
|
LONG_TASK: 50
|
|
228
|
-
},
|
|
275
|
+
}, ae = "needs-improvement", Ne = (n = ae) => {
|
|
229
276
|
switch (n) {
|
|
230
277
|
case "all":
|
|
231
278
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
@@ -233,61 +280,59 @@ const ut = () => {
|
|
|
233
280
|
case "needs-improvement":
|
|
234
281
|
return Re;
|
|
235
282
|
case "poor":
|
|
236
|
-
return
|
|
283
|
+
return Lt;
|
|
237
284
|
default:
|
|
238
285
|
return Re;
|
|
239
286
|
}
|
|
240
|
-
},
|
|
241
|
-
|
|
287
|
+
}, Mt = 1e3, Ct = 50, Rt = "2.1.0", Nt = Rt, Ge = () => typeof window < "u" && typeof sessionStorage < "u", Ot = () => {
|
|
288
|
+
try {
|
|
289
|
+
const n = new URLSearchParams(window.location.search);
|
|
290
|
+
n.delete(xe);
|
|
291
|
+
const e = n.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
292
|
+
window.history.replaceState({}, "", t);
|
|
293
|
+
} catch {
|
|
294
|
+
}
|
|
295
|
+
}, Pt = () => {
|
|
296
|
+
if (!Ge())
|
|
242
297
|
return !1;
|
|
243
298
|
try {
|
|
244
|
-
const
|
|
299
|
+
const e = new URLSearchParams(window.location.search).get(xe), t = sessionStorage.getItem(x);
|
|
245
300
|
let r = null;
|
|
246
|
-
|
|
247
|
-
|
|
301
|
+
return e === _e ? (r = !0, sessionStorage.setItem(x, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
|
+
visibility: "qa",
|
|
248
303
|
style: He
|
|
249
|
-
})) : e ===
|
|
250
|
-
|
|
251
|
-
style:
|
|
252
|
-
})), e === _e || e ===
|
|
253
|
-
try {
|
|
254
|
-
n.delete(Te);
|
|
255
|
-
const s = n.toString(), i = window.location.pathname + (s ? "?" + s : "") + window.location.hash;
|
|
256
|
-
window.history.replaceState({}, "", i);
|
|
257
|
-
} catch {
|
|
258
|
-
}
|
|
259
|
-
return r ?? t === "true";
|
|
304
|
+
})) : e === ve && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
|
+
visibility: "qa",
|
|
306
|
+
style: $e
|
|
307
|
+
})), (e === _e || e === ve) && Ot(), r ?? t === "true";
|
|
260
308
|
} catch {
|
|
261
309
|
return !1;
|
|
262
310
|
}
|
|
263
|
-
},
|
|
264
|
-
if (
|
|
311
|
+
}, Dt = (n) => {
|
|
312
|
+
if (Ge())
|
|
265
313
|
try {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
style: He
|
|
269
|
-
})
|
|
270
|
-
showToClient: !0,
|
|
271
|
-
style: Fe
|
|
272
|
-
}));
|
|
314
|
+
sessionStorage.setItem(x, n ? "true" : "false"), a("info", n ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
|
+
visibility: "qa",
|
|
316
|
+
style: n ? He : $e
|
|
317
|
+
});
|
|
273
318
|
} catch {
|
|
274
|
-
a("
|
|
319
|
+
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
275
320
|
}
|
|
276
321
|
}, Oe = () => {
|
|
277
322
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
278
|
-
return
|
|
323
|
+
return it.forEach((r) => {
|
|
279
324
|
const s = n.get(r);
|
|
280
325
|
if (s) {
|
|
281
326
|
const i = r.split("utm_")[1];
|
|
282
327
|
e[i] = s;
|
|
283
328
|
}
|
|
284
329
|
}), Object.keys(e).length ? e : void 0;
|
|
285
|
-
},
|
|
330
|
+
}, Vt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
286
331
|
const e = Math.random() * 16 | 0;
|
|
287
332
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
288
333
|
});
|
|
289
334
|
let B = 0, W = 0;
|
|
290
|
-
const
|
|
335
|
+
const kt = () => {
|
|
291
336
|
let n = Date.now();
|
|
292
337
|
n < W && (n = W), n === W ? B = (B + 1) % 1e3 : B = 0, W = n;
|
|
293
338
|
const e = B.toString().padStart(3, "0");
|
|
@@ -300,14 +345,14 @@ const yt = () => {
|
|
|
300
345
|
} catch {
|
|
301
346
|
}
|
|
302
347
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
303
|
-
},
|
|
348
|
+
}, Xe = (n, e = !1) => {
|
|
304
349
|
try {
|
|
305
350
|
const t = new URL(n), r = t.protocol === "https:", s = t.protocol === "http:";
|
|
306
351
|
return r || e && s;
|
|
307
352
|
} catch {
|
|
308
353
|
return !1;
|
|
309
354
|
}
|
|
310
|
-
},
|
|
355
|
+
}, Ut = (n) => {
|
|
311
356
|
try {
|
|
312
357
|
const t = new URL(window.location.href).hostname;
|
|
313
358
|
if (!t || typeof t != "string")
|
|
@@ -325,36 +370,35 @@ const yt = () => {
|
|
|
325
370
|
if (r.length === 2 ? s = r.join(".") : s = r.slice(-2).join("."), !s || s.split(".").length < 2)
|
|
326
371
|
throw new Error("Invalid domain structure for SaaS");
|
|
327
372
|
const i = `https://${n}.${s}/collect`;
|
|
328
|
-
if (!
|
|
373
|
+
if (!Xe(i))
|
|
329
374
|
throw new Error("Generated URL failed validation");
|
|
330
375
|
return i;
|
|
331
376
|
} catch (e) {
|
|
332
377
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
333
378
|
}
|
|
334
|
-
},
|
|
379
|
+
}, xt = (n) => {
|
|
335
380
|
const e = {};
|
|
336
|
-
n.integrations?.tracelog?.projectId && (e.saas =
|
|
381
|
+
n.integrations?.tracelog?.projectId && (e.saas = Ut(n.integrations.tracelog.projectId));
|
|
337
382
|
const t = n.integrations?.custom?.collectApiUrl;
|
|
338
383
|
if (t) {
|
|
339
384
|
const r = n.integrations?.custom?.allowHttp ?? !1;
|
|
340
|
-
if (!
|
|
385
|
+
if (!Xe(t, r))
|
|
341
386
|
throw new Error("Invalid custom API URL");
|
|
342
387
|
e.custom = t;
|
|
343
388
|
}
|
|
344
389
|
return e;
|
|
345
|
-
},
|
|
390
|
+
}, le = (n, e = []) => {
|
|
346
391
|
if (!n || typeof n != "string")
|
|
347
|
-
return a("warn", "Invalid URL provided to normalizeUrl", { data: {
|
|
392
|
+
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
348
393
|
try {
|
|
349
|
-
const t = new URL(n), r = t.searchParams, s = [.../* @__PURE__ */ new Set([...
|
|
394
|
+
const t = new URL(n), r = t.searchParams, s = [.../* @__PURE__ */ new Set([...ot, ...e])];
|
|
350
395
|
let i = !1;
|
|
351
396
|
const o = [];
|
|
352
397
|
return s.forEach((c) => {
|
|
353
398
|
r.has(c) && (r.delete(c), i = !0, o.push(c));
|
|
354
399
|
}), !i && n.includes("?") ? n : (t.search = r.toString(), t.toString());
|
|
355
400
|
} catch (t) {
|
|
356
|
-
|
|
357
|
-
return a("warn", "URL normalization failed, returning original", { error: t, data: { url: r } }), n;
|
|
401
|
+
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
358
402
|
}
|
|
359
403
|
}, Pe = (n) => {
|
|
360
404
|
if (!n || typeof n != "string" || n.trim().length === 0)
|
|
@@ -362,17 +406,17 @@ const yt = () => {
|
|
|
362
406
|
let e = n;
|
|
363
407
|
n.length > 1e3 && (e = n.slice(0, Math.max(0, 1e3)));
|
|
364
408
|
let t = 0;
|
|
365
|
-
for (const s of
|
|
409
|
+
for (const s of at) {
|
|
366
410
|
const i = e;
|
|
367
411
|
e = e.replace(s, ""), i !== e && t++;
|
|
368
412
|
}
|
|
369
413
|
return t > 0 && a("warn", "XSS patterns detected and removed", {
|
|
370
414
|
data: {
|
|
371
415
|
patternMatches: t,
|
|
372
|
-
|
|
416
|
+
valueLength: n.length
|
|
373
417
|
}
|
|
374
418
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
375
|
-
},
|
|
419
|
+
}, ce = (n, e = 0) => {
|
|
376
420
|
if (e > 3 || n == null)
|
|
377
421
|
return null;
|
|
378
422
|
if (typeof n == "string")
|
|
@@ -382,38 +426,38 @@ const yt = () => {
|
|
|
382
426
|
if (typeof n == "boolean")
|
|
383
427
|
return n;
|
|
384
428
|
if (Array.isArray(n))
|
|
385
|
-
return n.slice(0, 100).map((s) =>
|
|
429
|
+
return n.slice(0, 100).map((s) => ce(s, e + 1)).filter((s) => s !== null);
|
|
386
430
|
if (typeof n == "object") {
|
|
387
431
|
const t = {}, s = Object.entries(n).slice(0, 20);
|
|
388
432
|
for (const [i, o] of s) {
|
|
389
433
|
const l = Pe(i);
|
|
390
434
|
if (l) {
|
|
391
|
-
const c =
|
|
435
|
+
const c = ce(o, e + 1);
|
|
392
436
|
c !== null && (t[l] = c);
|
|
393
437
|
}
|
|
394
438
|
}
|
|
395
439
|
return t;
|
|
396
440
|
}
|
|
397
441
|
return null;
|
|
398
|
-
},
|
|
442
|
+
}, Ht = (n) => {
|
|
399
443
|
if (typeof n != "object" || n === null)
|
|
400
444
|
return {};
|
|
401
445
|
try {
|
|
402
|
-
const e =
|
|
446
|
+
const e = ce(n);
|
|
403
447
|
return typeof e == "object" && e !== null ? e : {};
|
|
404
448
|
} catch (e) {
|
|
405
449
|
const t = e instanceof Error ? e.message : String(e);
|
|
406
450
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
407
451
|
}
|
|
408
|
-
},
|
|
452
|
+
}, $t = (n) => {
|
|
409
453
|
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
410
454
|
throw new h("Configuration must be an object", "config");
|
|
411
455
|
if (n) {
|
|
412
456
|
if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
|
|
413
|
-
throw new
|
|
457
|
+
throw new dt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
414
458
|
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
415
459
|
throw new h(m.INVALID_GLOBAL_METADATA, "config");
|
|
416
|
-
if (n.integrations &&
|
|
460
|
+
if (n.integrations && Bt(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
417
461
|
if (!Array.isArray(n.sensitiveQueryParams))
|
|
418
462
|
throw new h(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
419
463
|
for (const e of n.sensitiveQueryParams)
|
|
@@ -421,9 +465,9 @@ const yt = () => {
|
|
|
421
465
|
throw new h("All sensitive query params must be strings", "config");
|
|
422
466
|
}
|
|
423
467
|
if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
|
|
424
|
-
throw new
|
|
468
|
+
throw new Ae(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
425
469
|
if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
|
|
426
|
-
throw new
|
|
470
|
+
throw new Ae(m.INVALID_SAMPLING_RATE, "config");
|
|
427
471
|
if (n.primaryScrollSelector !== void 0) {
|
|
428
472
|
if (typeof n.primaryScrollSelector != "string" || !n.primaryScrollSelector.trim())
|
|
429
473
|
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -443,7 +487,7 @@ const yt = () => {
|
|
|
443
487
|
throw new h(m.INVALID_CLICK_THROTTLE, "config");
|
|
444
488
|
if (n.maxSameEventPerMinute !== void 0 && (typeof n.maxSameEventPerMinute != "number" || n.maxSameEventPerMinute <= 0))
|
|
445
489
|
throw new h(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
446
|
-
if (n.viewport !== void 0 &&
|
|
490
|
+
if (n.viewport !== void 0 && Ft(n.viewport), n.webVitalsMode !== void 0) {
|
|
447
491
|
if (typeof n.webVitalsMode != "string")
|
|
448
492
|
throw new h(
|
|
449
493
|
`Invalid webVitalsMode type: ${typeof n.webVitalsMode}. Must be a string`,
|
|
@@ -474,7 +518,7 @@ const yt = () => {
|
|
|
474
518
|
}
|
|
475
519
|
}
|
|
476
520
|
}
|
|
477
|
-
},
|
|
521
|
+
}, Ft = (n) => {
|
|
478
522
|
if (typeof n != "object" || n === null)
|
|
479
523
|
throw new h(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
480
524
|
if (!n.elements || !Array.isArray(n.elements))
|
|
@@ -504,33 +548,33 @@ const yt = () => {
|
|
|
504
548
|
throw new h(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
505
549
|
if (n.maxTrackedElements !== void 0 && (typeof n.maxTrackedElements != "number" || n.maxTrackedElements <= 0))
|
|
506
550
|
throw new h(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
507
|
-
},
|
|
551
|
+
}, Bt = (n) => {
|
|
508
552
|
if (n) {
|
|
509
553
|
if (n.tracelog && (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === ""))
|
|
510
|
-
throw new
|
|
554
|
+
throw new V(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
511
555
|
if (n.custom) {
|
|
512
556
|
if (!n.custom.collectApiUrl || typeof n.custom.collectApiUrl != "string" || n.custom.collectApiUrl.trim() === "")
|
|
513
|
-
throw new
|
|
557
|
+
throw new V(m.INVALID_CUSTOM_API_URL, "config");
|
|
514
558
|
if (n.custom.allowHttp !== void 0 && typeof n.custom.allowHttp != "boolean")
|
|
515
|
-
throw new
|
|
559
|
+
throw new V("allowHttp must be a boolean", "config");
|
|
516
560
|
const e = n.custom.collectApiUrl.trim();
|
|
517
561
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
518
|
-
throw new
|
|
562
|
+
throw new V('Custom API URL must start with "http://" or "https://"', "config");
|
|
519
563
|
if (!(n.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
520
|
-
throw new
|
|
564
|
+
throw new V(
|
|
521
565
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
522
566
|
"config"
|
|
523
567
|
);
|
|
524
568
|
}
|
|
525
569
|
}
|
|
526
|
-
},
|
|
527
|
-
|
|
570
|
+
}, Wt = (n) => {
|
|
571
|
+
$t(n);
|
|
528
572
|
const e = {
|
|
529
573
|
...n ?? {},
|
|
530
574
|
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
531
575
|
globalMetadata: n?.globalMetadata ?? {},
|
|
532
576
|
sensitiveQueryParams: n?.sensitiveQueryParams ?? [],
|
|
533
|
-
errorSampling: n?.errorSampling ??
|
|
577
|
+
errorSampling: n?.errorSampling ?? We,
|
|
534
578
|
samplingRate: n?.samplingRate ?? 1,
|
|
535
579
|
pageViewThrottleMs: n?.pageViewThrottleMs ?? 1e3,
|
|
536
580
|
clickThrottleMs: n?.clickThrottleMs ?? 300,
|
|
@@ -546,7 +590,7 @@ const yt = () => {
|
|
|
546
590
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
547
591
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
548
592
|
}), e;
|
|
549
|
-
},
|
|
593
|
+
}, Gt = (n) => {
|
|
550
594
|
if (typeof n == "string")
|
|
551
595
|
return !0;
|
|
552
596
|
if (typeof n == "object" && n !== null && !Array.isArray(n)) {
|
|
@@ -563,7 +607,7 @@ const yt = () => {
|
|
|
563
607
|
return !0;
|
|
564
608
|
}
|
|
565
609
|
return !1;
|
|
566
|
-
},
|
|
610
|
+
}, Qe = (n, e = 0) => {
|
|
567
611
|
if (typeof n != "object" || n === null || e > 1)
|
|
568
612
|
return !1;
|
|
569
613
|
for (const t of Object.values(n)) {
|
|
@@ -577,12 +621,12 @@ const yt = () => {
|
|
|
577
621
|
if (typeof t[0] == "string") {
|
|
578
622
|
if (!t.every((o) => typeof o == "string"))
|
|
579
623
|
return !1;
|
|
580
|
-
} else if (!t.every((o) =>
|
|
624
|
+
} else if (!t.every((o) => Gt(o)))
|
|
581
625
|
return !1;
|
|
582
626
|
continue;
|
|
583
627
|
}
|
|
584
628
|
if (r === "object" && e === 0) {
|
|
585
|
-
if (!
|
|
629
|
+
if (!Qe(t, e + 1))
|
|
586
630
|
return !1;
|
|
587
631
|
continue;
|
|
588
632
|
}
|
|
@@ -590,7 +634,7 @@ const yt = () => {
|
|
|
590
634
|
}
|
|
591
635
|
}
|
|
592
636
|
return !0;
|
|
593
|
-
},
|
|
637
|
+
}, Xt = (n) => typeof n != "string" ? {
|
|
594
638
|
valid: !1,
|
|
595
639
|
error: "Event name must be a string"
|
|
596
640
|
} : n.length === 0 ? {
|
|
@@ -606,8 +650,8 @@ const yt = () => {
|
|
|
606
650
|
valid: !1,
|
|
607
651
|
error: "Event name cannot be a reserved word"
|
|
608
652
|
} : { valid: !0 }, De = (n, e, t) => {
|
|
609
|
-
const r =
|
|
610
|
-
if (!
|
|
653
|
+
const r = Ht(e), s = t && t === "customEvent" ? `${t} "${n}" metadata error` : `${n} metadata error`;
|
|
654
|
+
if (!Qe(r))
|
|
611
655
|
return {
|
|
612
656
|
valid: !1,
|
|
613
657
|
error: `${s}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -638,8 +682,8 @@ const yt = () => {
|
|
|
638
682
|
valid: !1,
|
|
639
683
|
error: `${s}: array property "${l}" is too large (max 10 items).`
|
|
640
684
|
};
|
|
641
|
-
for (const
|
|
642
|
-
if (typeof
|
|
685
|
+
for (const u of c)
|
|
686
|
+
if (typeof u == "string" && u.length > 500)
|
|
643
687
|
return {
|
|
644
688
|
valid: !1,
|
|
645
689
|
error: `${s}: array property "${l}" contains strings that are too long (max 500 characters).`
|
|
@@ -655,7 +699,7 @@ const yt = () => {
|
|
|
655
699
|
valid: !0,
|
|
656
700
|
sanitizedMetadata: r
|
|
657
701
|
};
|
|
658
|
-
},
|
|
702
|
+
}, ze = (n, e, t) => {
|
|
659
703
|
if (Array.isArray(e)) {
|
|
660
704
|
const r = [], s = t && t === "customEvent" ? `${t} "${n}" metadata error` : `${n} metadata error`;
|
|
661
705
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -679,25 +723,23 @@ const yt = () => {
|
|
|
679
723
|
};
|
|
680
724
|
}
|
|
681
725
|
return De(n, e, t);
|
|
682
|
-
},
|
|
683
|
-
const t =
|
|
726
|
+
}, Qt = (n, e) => {
|
|
727
|
+
const t = Xt(n);
|
|
684
728
|
if (!t.valid)
|
|
685
729
|
return a("error", "Event name validation failed", {
|
|
686
|
-
showToClient: !0,
|
|
687
730
|
data: { eventName: n, error: t.error }
|
|
688
731
|
}), t;
|
|
689
732
|
if (!e)
|
|
690
733
|
return { valid: !0 };
|
|
691
|
-
const r =
|
|
734
|
+
const r = ze(n, e, "customEvent");
|
|
692
735
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
693
|
-
showToClient: !0,
|
|
694
736
|
data: {
|
|
695
737
|
eventName: n,
|
|
696
738
|
error: r.error
|
|
697
739
|
}
|
|
698
740
|
}), r;
|
|
699
741
|
};
|
|
700
|
-
class
|
|
742
|
+
class zt {
|
|
701
743
|
listeners = /* @__PURE__ */ new Map();
|
|
702
744
|
/**
|
|
703
745
|
* Subscribes to an event channel
|
|
@@ -814,18 +856,21 @@ class Vt {
|
|
|
814
856
|
this.listeners.clear();
|
|
815
857
|
}
|
|
816
858
|
}
|
|
817
|
-
function
|
|
859
|
+
function je(n, e, t) {
|
|
818
860
|
try {
|
|
819
861
|
const r = e(n);
|
|
820
862
|
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), n);
|
|
821
863
|
} catch (r) {
|
|
822
|
-
return a("error", `beforeSend transformer threw error, using original event [${t}]`, {
|
|
864
|
+
return a("error", `beforeSend transformer threw error, using original event [${t}]`, {
|
|
865
|
+
error: r,
|
|
866
|
+
visibility: "critical"
|
|
867
|
+
}), n;
|
|
823
868
|
}
|
|
824
869
|
}
|
|
825
|
-
function
|
|
826
|
-
return n.map((r) =>
|
|
870
|
+
function jt(n, e, t) {
|
|
871
|
+
return n.map((r) => je(r, e, t)).filter((r) => r !== null);
|
|
827
872
|
}
|
|
828
|
-
function
|
|
873
|
+
function Ke(n, e, t) {
|
|
829
874
|
try {
|
|
830
875
|
const r = e(n);
|
|
831
876
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -836,12 +881,13 @@ function ze(n, e, t) {
|
|
|
836
881
|
} catch (r) {
|
|
837
882
|
return a("error", `beforeBatch transformer threw error, using original batch [${t}]`, {
|
|
838
883
|
error: r,
|
|
839
|
-
data: { eventCount: n.events.length }
|
|
884
|
+
data: { eventCount: n.events.length },
|
|
885
|
+
visibility: "critical"
|
|
840
886
|
}), n;
|
|
841
887
|
}
|
|
842
888
|
}
|
|
843
|
-
const
|
|
844
|
-
class
|
|
889
|
+
const te = {};
|
|
890
|
+
class _ {
|
|
845
891
|
/**
|
|
846
892
|
* Retrieves a value from global state.
|
|
847
893
|
*
|
|
@@ -859,7 +905,7 @@ class p {
|
|
|
859
905
|
* ```
|
|
860
906
|
*/
|
|
861
907
|
get(e) {
|
|
862
|
-
return
|
|
908
|
+
return te[e];
|
|
863
909
|
}
|
|
864
910
|
/**
|
|
865
911
|
* Sets a value in global state.
|
|
@@ -879,7 +925,7 @@ class p {
|
|
|
879
925
|
* ```
|
|
880
926
|
*/
|
|
881
927
|
set(e, t) {
|
|
882
|
-
|
|
928
|
+
te[e] = t;
|
|
883
929
|
}
|
|
884
930
|
/**
|
|
885
931
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -896,10 +942,10 @@ class p {
|
|
|
896
942
|
* ```
|
|
897
943
|
*/
|
|
898
944
|
getState() {
|
|
899
|
-
return { ...
|
|
945
|
+
return { ...te };
|
|
900
946
|
}
|
|
901
947
|
}
|
|
902
|
-
class Ve extends
|
|
948
|
+
class Ve extends _ {
|
|
903
949
|
storeManager;
|
|
904
950
|
integrationId;
|
|
905
951
|
apiUrl;
|
|
@@ -933,7 +979,7 @@ class Ve extends p {
|
|
|
933
979
|
return this.integrationId;
|
|
934
980
|
}
|
|
935
981
|
getQueueStorageKey() {
|
|
936
|
-
const e = this.get("userId") || "anonymous", t =
|
|
982
|
+
const e = this.get("userId") || "anonymous", t = lt(e);
|
|
937
983
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
938
984
|
}
|
|
939
985
|
/**
|
|
@@ -965,13 +1011,13 @@ class Ve extends p {
|
|
|
965
1011
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
966
1012
|
*/
|
|
967
1013
|
sendEventsQueueSync(e) {
|
|
968
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1014
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(k.Fail) ? (a(
|
|
969
1015
|
"warn",
|
|
970
1016
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
971
1017
|
{
|
|
972
1018
|
data: { events: e.events.length }
|
|
973
1019
|
}
|
|
974
|
-
), !1) : this.apiUrl?.includes(
|
|
1020
|
+
), !1) : this.apiUrl?.includes(k.Localhost) ? (a(
|
|
975
1021
|
"debug",
|
|
976
1022
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
977
1023
|
{
|
|
@@ -1013,7 +1059,7 @@ class Ve extends p {
|
|
|
1013
1059
|
const r = await this.send(e);
|
|
1014
1060
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
|
|
1015
1061
|
} catch (r) {
|
|
1016
|
-
return r instanceof
|
|
1062
|
+
return r instanceof N ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1017
1063
|
}
|
|
1018
1064
|
}
|
|
1019
1065
|
/**
|
|
@@ -1080,7 +1126,7 @@ class Ve extends p {
|
|
|
1080
1126
|
const r = this.createRecoveryBody(t);
|
|
1081
1127
|
await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
|
|
1082
1128
|
} catch (t) {
|
|
1083
|
-
if (t instanceof
|
|
1129
|
+
if (t instanceof N) {
|
|
1084
1130
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1085
1131
|
return;
|
|
1086
1132
|
}
|
|
@@ -1134,7 +1180,7 @@ class Ve extends p {
|
|
|
1134
1180
|
const t = this.transformers.beforeSend;
|
|
1135
1181
|
if (!t)
|
|
1136
1182
|
return e;
|
|
1137
|
-
const r =
|
|
1183
|
+
const r = jt(
|
|
1138
1184
|
e.events,
|
|
1139
1185
|
t,
|
|
1140
1186
|
this.integrationId || "SenderManager"
|
|
@@ -1179,7 +1225,7 @@ class Ve extends p {
|
|
|
1179
1225
|
if (this.integrationId === "saas")
|
|
1180
1226
|
return e;
|
|
1181
1227
|
const t = this.transformers.beforeBatch;
|
|
1182
|
-
return t ?
|
|
1228
|
+
return t ? Ke(e, t, this.integrationId || "SenderManager") : e;
|
|
1183
1229
|
}
|
|
1184
1230
|
/**
|
|
1185
1231
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1247,11 +1293,11 @@ class Ve extends p {
|
|
|
1247
1293
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1248
1294
|
if (!r)
|
|
1249
1295
|
return !0;
|
|
1250
|
-
if (this.apiUrl?.includes(
|
|
1251
|
-
return a("
|
|
1296
|
+
if (this.apiUrl?.includes(k.Fail))
|
|
1297
|
+
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1252
1298
|
data: { events: r.events.length }
|
|
1253
1299
|
}), !1;
|
|
1254
|
-
if (this.apiUrl?.includes(
|
|
1300
|
+
if (this.apiUrl?.includes(k.Localhost))
|
|
1255
1301
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1256
1302
|
data: { events: r.events.length }
|
|
1257
1303
|
}), !0;
|
|
@@ -1267,7 +1313,7 @@ class Ve extends p {
|
|
|
1267
1313
|
), !0) : !1;
|
|
1268
1314
|
} catch (l) {
|
|
1269
1315
|
const c = o === 3;
|
|
1270
|
-
if (l instanceof
|
|
1316
|
+
if (l instanceof N)
|
|
1271
1317
|
throw l;
|
|
1272
1318
|
if (a(
|
|
1273
1319
|
c ? "error" : "warn",
|
|
@@ -1328,7 +1374,7 @@ class Ve extends p {
|
|
|
1328
1374
|
}
|
|
1329
1375
|
});
|
|
1330
1376
|
if (!i.ok)
|
|
1331
|
-
throw i.status >= 400 && i.status < 500 && i.status !== 408 && i.status !== 429 ? new
|
|
1377
|
+
throw i.status >= 400 && i.status < 500 && i.status !== 408 && i.status !== 429 ? new N(`HTTP ${i.status}: ${i.statusText}`, i.status) : new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
1332
1378
|
return i;
|
|
1333
1379
|
} finally {
|
|
1334
1380
|
clearTimeout(s), this.pendingControllers.delete(r);
|
|
@@ -1412,7 +1458,7 @@ class Ve extends p {
|
|
|
1412
1458
|
_metadata: {
|
|
1413
1459
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1414
1460
|
timestamp: t,
|
|
1415
|
-
client_version:
|
|
1461
|
+
client_version: Nt
|
|
1416
1462
|
}
|
|
1417
1463
|
};
|
|
1418
1464
|
return {
|
|
@@ -1438,7 +1484,7 @@ class Ve extends p {
|
|
|
1438
1484
|
if (t)
|
|
1439
1485
|
return JSON.parse(t);
|
|
1440
1486
|
} catch (e) {
|
|
1441
|
-
a("
|
|
1487
|
+
a("debug", `Failed to parse persisted data${this.integrationId ? ` [${this.integrationId}]` : ""}`, { error: e }), this.clearPersistedEvents();
|
|
1442
1488
|
}
|
|
1443
1489
|
return null;
|
|
1444
1490
|
}
|
|
@@ -1508,7 +1554,7 @@ class Ve extends p {
|
|
|
1508
1554
|
}, s = this.getQueueStorageKey();
|
|
1509
1555
|
return this.storeManager.setItem(s, JSON.stringify(r)), !!this.storeManager.getItem(s);
|
|
1510
1556
|
} catch (t) {
|
|
1511
|
-
return a("
|
|
1557
|
+
return a("debug", `Failed to persist events${this.integrationId ? ` [${this.integrationId}]` : ""}`, { error: t }), !1;
|
|
1512
1558
|
}
|
|
1513
1559
|
}
|
|
1514
1560
|
clearPersistedEvents() {
|
|
@@ -1516,7 +1562,9 @@ class Ve extends p {
|
|
|
1516
1562
|
const e = this.getQueueStorageKey();
|
|
1517
1563
|
this.storeManager.removeItem(e);
|
|
1518
1564
|
} catch (e) {
|
|
1519
|
-
a("
|
|
1565
|
+
a("debug", `Failed to clear persisted events${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1566
|
+
error: e
|
|
1567
|
+
});
|
|
1520
1568
|
}
|
|
1521
1569
|
}
|
|
1522
1570
|
shouldSkipSend() {
|
|
@@ -1531,12 +1579,12 @@ class Ve extends p {
|
|
|
1531
1579
|
}
|
|
1532
1580
|
logPermanentError(e, t) {
|
|
1533
1581
|
const r = Date.now();
|
|
1534
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1582
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= At) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1535
1583
|
data: { status: t.statusCode, message: t.message }
|
|
1536
1584
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1537
1585
|
}
|
|
1538
1586
|
}
|
|
1539
|
-
class
|
|
1587
|
+
class Kt extends _ {
|
|
1540
1588
|
bootTime;
|
|
1541
1589
|
bootTimestamp;
|
|
1542
1590
|
hasPerformanceNow;
|
|
@@ -1566,7 +1614,7 @@ class Ut extends p {
|
|
|
1566
1614
|
bootTime: this.bootTime.toFixed(3),
|
|
1567
1615
|
bootTimestamp: this.bootTimestamp
|
|
1568
1616
|
}
|
|
1569
|
-
})) : (this.bootTime = 0, this.bootTimestamp = Date.now(), a("
|
|
1617
|
+
})) : (this.bootTime = 0, this.bootTimestamp = Date.now(), a("debug", "performance.now() not available, falling back to Date.now()"));
|
|
1570
1618
|
}
|
|
1571
1619
|
/**
|
|
1572
1620
|
* Returns current timestamp in milliseconds since epoch.
|
|
@@ -1685,7 +1733,7 @@ class Ut extends p {
|
|
|
1685
1733
|
};
|
|
1686
1734
|
}
|
|
1687
1735
|
}
|
|
1688
|
-
class
|
|
1736
|
+
class Yt extends _ {
|
|
1689
1737
|
dataSenders;
|
|
1690
1738
|
emitter;
|
|
1691
1739
|
transformers;
|
|
@@ -1700,11 +1748,11 @@ class xt extends p {
|
|
|
1700
1748
|
lastSessionId = null;
|
|
1701
1749
|
sessionEventCounts = {
|
|
1702
1750
|
total: 0,
|
|
1703
|
-
[
|
|
1704
|
-
[
|
|
1705
|
-
[
|
|
1706
|
-
[
|
|
1707
|
-
[
|
|
1751
|
+
[d.CLICK]: 0,
|
|
1752
|
+
[d.PAGE_VIEW]: 0,
|
|
1753
|
+
[d.CUSTOM]: 0,
|
|
1754
|
+
[d.VIEWPORT_VISIBLE]: 0,
|
|
1755
|
+
[d.SCROLL]: 0
|
|
1708
1756
|
};
|
|
1709
1757
|
saveSessionCountsDebounced = null;
|
|
1710
1758
|
/**
|
|
@@ -1719,7 +1767,7 @@ class xt extends p {
|
|
|
1719
1767
|
* @param transformers - Optional event transformation hooks
|
|
1720
1768
|
*/
|
|
1721
1769
|
constructor(e, t = null, r = {}) {
|
|
1722
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1770
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new Kt(), this.dataSenders = [];
|
|
1723
1771
|
const s = this.get("collectApiUrls");
|
|
1724
1772
|
s?.saas && this.dataSenders.push(new Ve(e, "saas", s.saas, r)), s?.custom && this.dataSenders.push(new Ve(e, "custom", s.custom, r)), this.saveSessionCountsDebounced = this.debounce((i) => {
|
|
1725
1773
|
this.saveSessionCounts(i);
|
|
@@ -1759,7 +1807,7 @@ class xt extends p {
|
|
|
1759
1807
|
}
|
|
1760
1808
|
},
|
|
1761
1809
|
onFailure: () => {
|
|
1762
|
-
a("
|
|
1810
|
+
a("debug", "Failed to recover persisted events");
|
|
1763
1811
|
}
|
|
1764
1812
|
})
|
|
1765
1813
|
);
|
|
@@ -1833,7 +1881,8 @@ class xt extends p {
|
|
|
1833
1881
|
custom_event: o,
|
|
1834
1882
|
web_vitals: l,
|
|
1835
1883
|
error_data: c,
|
|
1836
|
-
viewport_data:
|
|
1884
|
+
viewport_data: u,
|
|
1885
|
+
page_view: S
|
|
1837
1886
|
}) {
|
|
1838
1887
|
if (!e) {
|
|
1839
1888
|
a("error", "Event type is required - event will be ignored");
|
|
@@ -1841,7 +1890,7 @@ class xt extends p {
|
|
|
1841
1890
|
}
|
|
1842
1891
|
const g = this.get("sessionId");
|
|
1843
1892
|
if (!g) {
|
|
1844
|
-
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("
|
|
1893
|
+
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("debug", "Pending events buffer full - dropping oldest event", {
|
|
1845
1894
|
data: { maxBufferSize: 100 }
|
|
1846
1895
|
})), this.pendingEventsBuffer.push({
|
|
1847
1896
|
type: e,
|
|
@@ -1852,36 +1901,37 @@ class xt extends p {
|
|
|
1852
1901
|
custom_event: o,
|
|
1853
1902
|
web_vitals: l,
|
|
1854
1903
|
error_data: c,
|
|
1855
|
-
viewport_data:
|
|
1904
|
+
viewport_data: u,
|
|
1905
|
+
page_view: S
|
|
1856
1906
|
});
|
|
1857
1907
|
return;
|
|
1858
1908
|
}
|
|
1859
1909
|
this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
|
|
1860
|
-
const E = e ===
|
|
1910
|
+
const E = e === d.SESSION_START;
|
|
1861
1911
|
if (E && a("debug", "Processing SESSION_START event", {
|
|
1862
1912
|
data: { sessionId: g }
|
|
1863
1913
|
}), !E && !this.checkRateLimit())
|
|
1864
1914
|
return;
|
|
1865
|
-
const
|
|
1915
|
+
const p = e;
|
|
1866
1916
|
if (!E) {
|
|
1867
1917
|
if (this.sessionEventCounts.total >= 1e3) {
|
|
1868
1918
|
a("warn", "Session event limit reached", {
|
|
1869
1919
|
data: {
|
|
1870
|
-
type:
|
|
1920
|
+
type: p,
|
|
1871
1921
|
total: this.sessionEventCounts.total,
|
|
1872
1922
|
limit: 1e3
|
|
1873
1923
|
}
|
|
1874
1924
|
});
|
|
1875
1925
|
return;
|
|
1876
1926
|
}
|
|
1877
|
-
const T = this.getTypeLimitForEvent(
|
|
1927
|
+
const T = this.getTypeLimitForEvent(p);
|
|
1878
1928
|
if (T) {
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1929
|
+
const ee = this.sessionEventCounts[p];
|
|
1930
|
+
if (ee !== void 0 && ee >= T) {
|
|
1881
1931
|
a("warn", "Session event type limit reached", {
|
|
1882
1932
|
data: {
|
|
1883
|
-
type:
|
|
1884
|
-
count:
|
|
1933
|
+
type: p,
|
|
1934
|
+
count: ee,
|
|
1885
1935
|
limit: T
|
|
1886
1936
|
}
|
|
1887
1937
|
});
|
|
@@ -1889,50 +1939,67 @@ class xt extends p {
|
|
|
1889
1939
|
}
|
|
1890
1940
|
}
|
|
1891
1941
|
}
|
|
1892
|
-
if (
|
|
1942
|
+
if (p === d.CUSTOM && o?.name) {
|
|
1893
1943
|
const T = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
1894
1944
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1895
1945
|
return;
|
|
1896
1946
|
}
|
|
1897
|
-
const
|
|
1898
|
-
type:
|
|
1899
|
-
page_url:
|
|
1947
|
+
const F = p === d.SESSION_START, nt = t || this.get("pageUrl"), D = this.buildEventPayload({
|
|
1948
|
+
type: p,
|
|
1949
|
+
page_url: nt,
|
|
1900
1950
|
from_page_url: r,
|
|
1901
1951
|
scroll_data: s,
|
|
1902
1952
|
click_data: i,
|
|
1903
1953
|
custom_event: o,
|
|
1904
1954
|
web_vitals: l,
|
|
1905
1955
|
error_data: c,
|
|
1906
|
-
viewport_data:
|
|
1956
|
+
viewport_data: u,
|
|
1957
|
+
page_view: S
|
|
1907
1958
|
});
|
|
1908
|
-
if (
|
|
1909
|
-
if (
|
|
1959
|
+
if (D && !(!E && !this.shouldSample())) {
|
|
1960
|
+
if (F) {
|
|
1910
1961
|
const T = this.get("sessionId");
|
|
1911
1962
|
if (!T) {
|
|
1912
1963
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
1913
1964
|
return;
|
|
1914
1965
|
}
|
|
1915
1966
|
if (this.get("hasStartSession")) {
|
|
1916
|
-
a("
|
|
1967
|
+
a("debug", "Duplicate session_start detected", {
|
|
1917
1968
|
data: { sessionId: T }
|
|
1918
1969
|
});
|
|
1919
1970
|
return;
|
|
1920
1971
|
}
|
|
1921
1972
|
this.set("hasStartSession", !0);
|
|
1922
1973
|
}
|
|
1923
|
-
if (!this.isDuplicateEvent(
|
|
1924
|
-
if (this.get("mode") === j.QA
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1974
|
+
if (!this.isDuplicateEvent(D)) {
|
|
1975
|
+
if (this.get("mode") === j.QA) {
|
|
1976
|
+
if (p === d.CUSTOM && o) {
|
|
1977
|
+
a("info", `Custom Event: ${o.name}`, {
|
|
1978
|
+
visibility: "qa",
|
|
1979
|
+
data: {
|
|
1980
|
+
name: o.name,
|
|
1981
|
+
...o.metadata && { metadata: o.metadata }
|
|
1982
|
+
}
|
|
1983
|
+
}), this.emitEvent(D);
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
if (p === d.VIEWPORT_VISIBLE && u) {
|
|
1987
|
+
const T = u.name || u.id || u.selector;
|
|
1988
|
+
a("info", `Viewport Visible: ${T}`, {
|
|
1989
|
+
visibility: "qa",
|
|
1990
|
+
data: {
|
|
1991
|
+
selector: u.selector,
|
|
1992
|
+
...u.name && { name: u.name },
|
|
1993
|
+
...u.id && { id: u.id },
|
|
1994
|
+
visibilityRatio: u.visibilityRatio,
|
|
1995
|
+
dwellTime: u.dwellTime
|
|
1996
|
+
}
|
|
1997
|
+
}), this.emitEvent(D);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
1933
2000
|
}
|
|
1934
|
-
if (this.addToQueue(
|
|
1935
|
-
this.sessionEventCounts.total++, this.sessionEventCounts[
|
|
2001
|
+
if (this.addToQueue(D), !E) {
|
|
2002
|
+
this.sessionEventCounts.total++, this.sessionEventCounts[p] !== void 0 && this.sessionEventCounts[p]++;
|
|
1936
2003
|
const T = this.get("sessionId");
|
|
1937
2004
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
1938
2005
|
}
|
|
@@ -1978,11 +2045,11 @@ class xt extends p {
|
|
|
1978
2045
|
const e = this.get("sessionId");
|
|
1979
2046
|
e && this.saveSessionCounts(e), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
|
|
1980
2047
|
total: 0,
|
|
1981
|
-
[
|
|
1982
|
-
[
|
|
1983
|
-
[
|
|
1984
|
-
[
|
|
1985
|
-
[
|
|
2048
|
+
[d.CLICK]: 0,
|
|
2049
|
+
[d.PAGE_VIEW]: 0,
|
|
2050
|
+
[d.CUSTOM]: 0,
|
|
2051
|
+
[d.VIEWPORT_VISIBLE]: 0,
|
|
2052
|
+
[d.SCROLL]: 0
|
|
1986
2053
|
}, this.lastSessionId = null, this.set("hasStartSession", !1), this.dataSenders.forEach((t) => {
|
|
1987
2054
|
t.stop();
|
|
1988
2055
|
});
|
|
@@ -2160,7 +2227,7 @@ class xt extends p {
|
|
|
2160
2227
|
if (this.pendingEventsBuffer.length === 0)
|
|
2161
2228
|
return;
|
|
2162
2229
|
if (!this.get("sessionId")) {
|
|
2163
|
-
a("
|
|
2230
|
+
a("debug", "Cannot flush pending events: session not initialized - keeping in buffer", {
|
|
2164
2231
|
data: { bufferedEventCount: this.pendingEventsBuffer.length }
|
|
2165
2232
|
});
|
|
2166
2233
|
return;
|
|
@@ -2184,7 +2251,7 @@ class xt extends p {
|
|
|
2184
2251
|
return this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
2185
2252
|
if (e) {
|
|
2186
2253
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2187
|
-
return o ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("
|
|
2254
|
+
return o ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
|
|
2188
2255
|
data: { eventCount: s.length }
|
|
2189
2256
|
})), o;
|
|
2190
2257
|
} else {
|
|
@@ -2198,7 +2265,7 @@ class xt extends p {
|
|
|
2198
2265
|
);
|
|
2199
2266
|
return Promise.allSettled(i).then((o) => {
|
|
2200
2267
|
const l = o.some((c) => this.isSuccessfulResult(c));
|
|
2201
|
-
return l ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : a("
|
|
2268
|
+
return l ? (this.removeProcessedEvents(s), this.clearSendInterval(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
|
|
2202
2269
|
data: { eventCount: r.length }
|
|
2203
2270
|
}), l;
|
|
2204
2271
|
});
|
|
@@ -2223,11 +2290,11 @@ class xt extends p {
|
|
|
2223
2290
|
if (i.some((l) => this.isSuccessfulResult(l))) {
|
|
2224
2291
|
this.removeProcessedEvents(r), this.emitEventsQueue(e);
|
|
2225
2292
|
const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
2226
|
-
l > 0 && a("
|
|
2293
|
+
l > 0 && a("debug", "Periodic send completed with some failures, removed from queue and persisted per-integration", {
|
|
2227
2294
|
data: { eventCount: t.length, failedCount: l }
|
|
2228
2295
|
});
|
|
2229
2296
|
} else
|
|
2230
|
-
a("
|
|
2297
|
+
a("debug", "Periodic send complete failure, events kept in queue for retry", {
|
|
2231
2298
|
data: { eventCount: t.length }
|
|
2232
2299
|
});
|
|
2233
2300
|
this.eventsQueue.length === 0 && this.clearSendInterval();
|
|
@@ -2235,10 +2302,10 @@ class xt extends p {
|
|
|
2235
2302
|
buildEventsPayload() {
|
|
2236
2303
|
const e = /* @__PURE__ */ new Map(), t = [];
|
|
2237
2304
|
for (const c of this.eventsQueue) {
|
|
2238
|
-
const
|
|
2239
|
-
e.has(
|
|
2305
|
+
const u = this.createEventSignature(c);
|
|
2306
|
+
e.has(u) || t.push(u), e.set(u, c);
|
|
2240
2307
|
}
|
|
2241
|
-
const r = t.map((c) => e.get(c)).filter((c) => !!c).sort((c,
|
|
2308
|
+
const r = t.map((c) => e.get(c)).filter((c) => !!c).sort((c, u) => c.type === d.SESSION_START && u.type !== d.SESSION_START ? -1 : u.type === d.SESSION_START && c.type !== d.SESSION_START ? 1 : c.timestamp - u.timestamp);
|
|
2242
2309
|
let s = {
|
|
2243
2310
|
user_id: this.get("userId"),
|
|
2244
2311
|
session_id: this.get("sessionId"),
|
|
@@ -2248,22 +2315,22 @@ class xt extends p {
|
|
|
2248
2315
|
};
|
|
2249
2316
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2250
2317
|
if (!o && l) {
|
|
2251
|
-
const c =
|
|
2318
|
+
const c = Ke(s, l, "EventManager");
|
|
2252
2319
|
c !== null && (s = c);
|
|
2253
2320
|
}
|
|
2254
2321
|
return s;
|
|
2255
2322
|
}
|
|
2256
2323
|
buildEventPayload(e) {
|
|
2257
|
-
const t = e.type ===
|
|
2324
|
+
const t = e.type === d.SESSION_START, r = e.page_url ?? this.get("pageUrl"), s = this.timeManager.now(), i = this.timeManager.validateTimestamp(s);
|
|
2258
2325
|
i.valid || a("warn", "Event timestamp validation failed", {
|
|
2259
2326
|
data: { type: e.type, error: i.error }
|
|
2260
2327
|
});
|
|
2261
2328
|
let o = {
|
|
2262
|
-
id:
|
|
2329
|
+
id: kt(),
|
|
2263
2330
|
type: e.type,
|
|
2264
2331
|
page_url: r,
|
|
2265
2332
|
timestamp: s,
|
|
2266
|
-
...t && { referrer:
|
|
2333
|
+
...t && { referrer: this.getExternalReferrer() },
|
|
2267
2334
|
...e.from_page_url && { from_page_url: e.from_page_url },
|
|
2268
2335
|
...e.scroll_data && { scroll_data: e.scroll_data },
|
|
2269
2336
|
...e.click_data && { click_data: e.click_data },
|
|
@@ -2271,11 +2338,12 @@ class xt extends p {
|
|
|
2271
2338
|
...e.web_vitals && { web_vitals: e.web_vitals },
|
|
2272
2339
|
...e.error_data && { error_data: e.error_data },
|
|
2273
2340
|
...e.viewport_data && { viewport_data: e.viewport_data },
|
|
2341
|
+
...e.page_view && { page_view: e.page_view },
|
|
2274
2342
|
...t && Oe() && { utm: Oe() }
|
|
2275
2343
|
};
|
|
2276
|
-
const l = this.get("collectApiUrls"), c = !!l?.custom,
|
|
2277
|
-
if (
|
|
2278
|
-
const F =
|
|
2344
|
+
const l = this.get("collectApiUrls"), c = !!l?.custom, u = !!l?.saas, S = c || u, g = c && u, E = this.transformers.beforeSend;
|
|
2345
|
+
if (E && (!S || c && !g)) {
|
|
2346
|
+
const F = je(o, E, "EventManager");
|
|
2279
2347
|
if (F === null)
|
|
2280
2348
|
return null;
|
|
2281
2349
|
o = F;
|
|
@@ -2284,7 +2352,7 @@ class xt extends p {
|
|
|
2284
2352
|
}
|
|
2285
2353
|
isDuplicateEvent(e) {
|
|
2286
2354
|
const t = Date.now(), r = this.createEventFingerprint(e), s = this.recentEventFingerprints.get(r);
|
|
2287
|
-
return s && t - s < 1e3 ? (this.recentEventFingerprints.set(r, t), !0) : (this.recentEventFingerprints.set(r, t), this.recentEventFingerprints.size > 1500 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 3e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(r, t), a("
|
|
2355
|
+
return s && t - s < 1e3 ? (this.recentEventFingerprints.set(r, t), !0) : (this.recentEventFingerprints.set(r, t), this.recentEventFingerprints.size > 1500 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 3e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(r, t), a("debug", "Event fingerprint cache exceeded hard limit, cleared", {
|
|
2288
2356
|
data: { hardLimit: 3e3 }
|
|
2289
2357
|
})), !1);
|
|
2290
2358
|
}
|
|
@@ -2312,13 +2380,13 @@ class xt extends p {
|
|
|
2312
2380
|
}
|
|
2313
2381
|
addToQueue(e) {
|
|
2314
2382
|
if (this.emitEvent(e), this.eventsQueue.push(e), this.eventsQueue.length > 100) {
|
|
2315
|
-
const t = this.eventsQueue.findIndex((s) => s.type !==
|
|
2383
|
+
const t = this.eventsQueue.findIndex((s) => s.type !== d.SESSION_START), r = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
|
|
2316
2384
|
a("warn", "Event queue overflow, oldest non-critical event removed", {
|
|
2317
2385
|
data: {
|
|
2318
2386
|
maxLength: 100,
|
|
2319
2387
|
currentLength: this.eventsQueue.length,
|
|
2320
2388
|
removedEventType: r?.type,
|
|
2321
|
-
wasCritical: r?.type ===
|
|
2389
|
+
wasCritical: r?.type === d.SESSION_START
|
|
2322
2390
|
}
|
|
2323
2391
|
});
|
|
2324
2392
|
}
|
|
@@ -2349,11 +2417,11 @@ class xt extends p {
|
|
|
2349
2417
|
}
|
|
2350
2418
|
getTypeLimitForEvent(e) {
|
|
2351
2419
|
return {
|
|
2352
|
-
[
|
|
2353
|
-
[
|
|
2354
|
-
[
|
|
2355
|
-
[
|
|
2356
|
-
[
|
|
2420
|
+
[d.CLICK]: 500,
|
|
2421
|
+
[d.PAGE_VIEW]: 100,
|
|
2422
|
+
[d.CUSTOM]: 500,
|
|
2423
|
+
[d.VIEWPORT_VISIBLE]: 200,
|
|
2424
|
+
[d.SCROLL]: 120
|
|
2357
2425
|
}[e] ?? null;
|
|
2358
2426
|
}
|
|
2359
2427
|
removeProcessedEvents(e) {
|
|
@@ -2361,10 +2429,10 @@ class xt extends p {
|
|
|
2361
2429
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2362
2430
|
}
|
|
2363
2431
|
emitEvent(e) {
|
|
2364
|
-
this.emitter && this.emitter.emit(
|
|
2432
|
+
this.emitter && this.emitter.emit(se.EVENT, e);
|
|
2365
2433
|
}
|
|
2366
2434
|
emitEventsQueue(e) {
|
|
2367
|
-
this.emitter && this.emitter.emit(
|
|
2435
|
+
this.emitter && this.emitter.emit(se.QUEUE, e);
|
|
2368
2436
|
}
|
|
2369
2437
|
/**
|
|
2370
2438
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2407,11 +2475,11 @@ class xt extends p {
|
|
|
2407
2475
|
getInitialCounts() {
|
|
2408
2476
|
return {
|
|
2409
2477
|
total: 0,
|
|
2410
|
-
[
|
|
2411
|
-
[
|
|
2412
|
-
[
|
|
2413
|
-
[
|
|
2414
|
-
[
|
|
2478
|
+
[d.CLICK]: 0,
|
|
2479
|
+
[d.PAGE_VIEW]: 0,
|
|
2480
|
+
[d.CUSTOM]: 0,
|
|
2481
|
+
[d.VIEWPORT_VISIBLE]: 0,
|
|
2482
|
+
[d.SCROLL]: 0
|
|
2415
2483
|
};
|
|
2416
2484
|
}
|
|
2417
2485
|
/**
|
|
@@ -2440,7 +2508,7 @@ class xt extends p {
|
|
|
2440
2508
|
loadSessionCounts(e) {
|
|
2441
2509
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2442
2510
|
return this.getInitialCounts();
|
|
2443
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2511
|
+
const t = this.get("userId") || "anonymous", r = Ie(t, e);
|
|
2444
2512
|
try {
|
|
2445
2513
|
const s = localStorage.getItem(r);
|
|
2446
2514
|
if (!s)
|
|
@@ -2448,13 +2516,13 @@ class xt extends p {
|
|
|
2448
2516
|
const i = JSON.parse(s);
|
|
2449
2517
|
return i._timestamp && Date.now() - i._timestamp > we ? (a("debug", "Session counts expired, clearing", {
|
|
2450
2518
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2451
|
-
}), localStorage.removeItem(r), this.getInitialCounts()) : typeof i.total == "number" && typeof i[
|
|
2519
|
+
}), localStorage.removeItem(r), this.getInitialCounts()) : typeof i.total == "number" && typeof i[d.CLICK] == "number" && typeof i[d.PAGE_VIEW] == "number" && typeof i[d.CUSTOM] == "number" && typeof i[d.VIEWPORT_VISIBLE] == "number" && typeof i[d.SCROLL] == "number" ? {
|
|
2452
2520
|
total: i.total,
|
|
2453
|
-
[
|
|
2454
|
-
[
|
|
2455
|
-
[
|
|
2456
|
-
[
|
|
2457
|
-
[
|
|
2521
|
+
[d.CLICK]: i[d.CLICK],
|
|
2522
|
+
[d.PAGE_VIEW]: i[d.PAGE_VIEW],
|
|
2523
|
+
[d.CUSTOM]: i[d.CUSTOM],
|
|
2524
|
+
[d.VIEWPORT_VISIBLE]: i[d.VIEWPORT_VISIBLE],
|
|
2525
|
+
[d.SCROLL]: i[d.SCROLL]
|
|
2458
2526
|
} : (a("warn", "Invalid session counts structure in localStorage, resetting", {
|
|
2459
2527
|
data: { sessionId: e, parsed: i }
|
|
2460
2528
|
}), localStorage.removeItem(r), a("debug", "Session counts removed due to invalid/corrupted data", {
|
|
@@ -2494,9 +2562,9 @@ class xt extends p {
|
|
|
2494
2562
|
const e = localStorage.getItem(ye);
|
|
2495
2563
|
if (e) {
|
|
2496
2564
|
const i = Date.now() - parseInt(e, 10);
|
|
2497
|
-
if (i <
|
|
2565
|
+
if (i < be) {
|
|
2498
2566
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2499
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2567
|
+
data: { timeSinceLastCleanup: i, throttleMs: be }
|
|
2500
2568
|
});
|
|
2501
2569
|
return;
|
|
2502
2570
|
}
|
|
@@ -2521,6 +2589,52 @@ class xt extends p {
|
|
|
2521
2589
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2522
2590
|
}
|
|
2523
2591
|
}
|
|
2592
|
+
/**
|
|
2593
|
+
* Returns the referrer if it's external, or 'Direct' if internal/empty.
|
|
2594
|
+
*
|
|
2595
|
+
* **Purpose**: Filter out internal referrers (same domain) to ensure
|
|
2596
|
+
* accurate traffic source attribution. Internal referrers occur when:
|
|
2597
|
+
* - Session expires and user navigates within the same site
|
|
2598
|
+
* - User opens new tab from an internal link
|
|
2599
|
+
* - Page refresh after session timeout
|
|
2600
|
+
*
|
|
2601
|
+
* **Logic**:
|
|
2602
|
+
* - Empty referrer → 'Direct'
|
|
2603
|
+
* - Referrer from same domain or subdomain → 'Direct' (internal navigation)
|
|
2604
|
+
* - External referrer → Returns original referrer
|
|
2605
|
+
*
|
|
2606
|
+
* **Subdomain Detection**:
|
|
2607
|
+
* - `www.example.com` → `example.com` ✓ (internal)
|
|
2608
|
+
* - `blog.example.com` → `example.com` ✓ (internal)
|
|
2609
|
+
* - `example.com` → `www.example.com` ✓ (internal)
|
|
2610
|
+
*
|
|
2611
|
+
* @returns External referrer URL or 'Direct'
|
|
2612
|
+
*
|
|
2613
|
+
* @internal
|
|
2614
|
+
*/
|
|
2615
|
+
getExternalReferrer() {
|
|
2616
|
+
const e = document.referrer;
|
|
2617
|
+
if (!e)
|
|
2618
|
+
return "Direct";
|
|
2619
|
+
try {
|
|
2620
|
+
const t = new URL(e).hostname.toLowerCase(), r = window.location.hostname.toLowerCase();
|
|
2621
|
+
return this.isSameDomain(t, r) ? "Direct" : e;
|
|
2622
|
+
} catch {
|
|
2623
|
+
return e || "Direct";
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* Checks if two hostnames belong to the same domain (including subdomains).
|
|
2628
|
+
*
|
|
2629
|
+
* @param hostname1 - First hostname (e.g., 'www.example.com')
|
|
2630
|
+
* @param hostname2 - Second hostname (e.g., 'example.com')
|
|
2631
|
+
* @returns true if same domain or subdomain relationship exists
|
|
2632
|
+
*
|
|
2633
|
+
* @internal
|
|
2634
|
+
*/
|
|
2635
|
+
isSameDomain(e, t) {
|
|
2636
|
+
return e === t ? !0 : e.endsWith(`.${t}`) || t.endsWith(`.${e}`);
|
|
2637
|
+
}
|
|
2524
2638
|
/**
|
|
2525
2639
|
* Persists current session event counts to localStorage (debounced).
|
|
2526
2640
|
*
|
|
@@ -2550,7 +2664,7 @@ class xt extends p {
|
|
|
2550
2664
|
* @internal
|
|
2551
2665
|
*/
|
|
2552
2666
|
saveSessionCounts(e) {
|
|
2553
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2667
|
+
const t = this.get("userId") || "anonymous", r = Ie(t, e);
|
|
2554
2668
|
try {
|
|
2555
2669
|
const s = {
|
|
2556
2670
|
...this.sessionEventCounts,
|
|
@@ -2566,7 +2680,7 @@ class xt extends p {
|
|
|
2566
2680
|
}
|
|
2567
2681
|
}
|
|
2568
2682
|
}
|
|
2569
|
-
class
|
|
2683
|
+
class qt {
|
|
2570
2684
|
/**
|
|
2571
2685
|
* Gets or creates a unique user ID.
|
|
2572
2686
|
*
|
|
@@ -2584,15 +2698,15 @@ class Ht {
|
|
|
2584
2698
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2585
2699
|
*/
|
|
2586
2700
|
static getId(e) {
|
|
2587
|
-
const t = e.getItem(
|
|
2701
|
+
const t = e.getItem(Te);
|
|
2588
2702
|
if (t)
|
|
2589
2703
|
return t;
|
|
2590
|
-
const r =
|
|
2591
|
-
return e.setItem(
|
|
2704
|
+
const r = Vt();
|
|
2705
|
+
return e.setItem(Te, r), r;
|
|
2592
2706
|
}
|
|
2593
2707
|
}
|
|
2594
|
-
const
|
|
2595
|
-
class
|
|
2708
|
+
const Jt = /^\d{13}-[a-z0-9]{9}$/;
|
|
2709
|
+
class Zt extends _ {
|
|
2596
2710
|
storageManager;
|
|
2597
2711
|
eventManager;
|
|
2598
2712
|
projectId;
|
|
@@ -2613,11 +2727,11 @@ class $t extends p {
|
|
|
2613
2727
|
}
|
|
2614
2728
|
initCrossTabSync() {
|
|
2615
2729
|
if (typeof BroadcastChannel > "u") {
|
|
2616
|
-
a("
|
|
2730
|
+
a("debug", "BroadcastChannel not supported");
|
|
2617
2731
|
return;
|
|
2618
2732
|
}
|
|
2619
2733
|
const e = this.getProjectId();
|
|
2620
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2734
|
+
this.broadcastChannel = new BroadcastChannel(ut(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2621
2735
|
const { action: r, sessionId: s, timestamp: i, projectId: o } = t.data ?? {};
|
|
2622
2736
|
o === e && (r === "session_start" && s && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", s), this.persistSession(s, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2623
2737
|
};
|
|
@@ -2637,7 +2751,7 @@ class $t extends p {
|
|
|
2637
2751
|
const e = this.loadStoredSession();
|
|
2638
2752
|
if (!e)
|
|
2639
2753
|
return null;
|
|
2640
|
-
if (!
|
|
2754
|
+
if (!Jt.test(e.id))
|
|
2641
2755
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2642
2756
|
data: { sessionId: e.id }
|
|
2643
2757
|
}), this.clearStoredSession(), null;
|
|
@@ -2670,7 +2784,7 @@ class $t extends p {
|
|
|
2670
2784
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2671
2785
|
}
|
|
2672
2786
|
getSessionStorageKey() {
|
|
2673
|
-
return
|
|
2787
|
+
return ct(this.getProjectId());
|
|
2674
2788
|
}
|
|
2675
2789
|
getProjectId() {
|
|
2676
2790
|
return this.projectId;
|
|
@@ -2728,7 +2842,7 @@ class $t extends p {
|
|
|
2728
2842
|
*/
|
|
2729
2843
|
startTracking() {
|
|
2730
2844
|
if (this.isTracking) {
|
|
2731
|
-
a("
|
|
2845
|
+
a("debug", "Session tracking already active");
|
|
2732
2846
|
return;
|
|
2733
2847
|
}
|
|
2734
2848
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
@@ -2743,7 +2857,7 @@ class $t extends p {
|
|
|
2743
2857
|
this.set("sessionId", t), this.persistSession(t), this.initCrossTabSync(), this.shareSession(t), a("debug", "Emitting SESSION_START event", {
|
|
2744
2858
|
data: { sessionId: t }
|
|
2745
2859
|
}), this.eventManager.track({
|
|
2746
|
-
type:
|
|
2860
|
+
type: d.SESSION_START
|
|
2747
2861
|
}), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2748
2862
|
} catch (r) {
|
|
2749
2863
|
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), r;
|
|
@@ -2853,7 +2967,7 @@ class $t extends p {
|
|
|
2853
2967
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
2854
2968
|
}
|
|
2855
2969
|
}
|
|
2856
|
-
class
|
|
2970
|
+
class er extends _ {
|
|
2857
2971
|
eventManager;
|
|
2858
2972
|
storageManager;
|
|
2859
2973
|
sessionManager = null;
|
|
@@ -2883,12 +2997,12 @@ class Bt extends p {
|
|
|
2883
2997
|
if (this.isActive())
|
|
2884
2998
|
return;
|
|
2885
2999
|
if (this.destroyed) {
|
|
2886
|
-
a("
|
|
3000
|
+
a("debug", "Cannot start tracking on destroyed handler");
|
|
2887
3001
|
return;
|
|
2888
3002
|
}
|
|
2889
3003
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2890
3004
|
try {
|
|
2891
|
-
this.sessionManager = new
|
|
3005
|
+
this.sessionManager = new Zt(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2892
3006
|
} catch (r) {
|
|
2893
3007
|
if (this.sessionManager) {
|
|
2894
3008
|
try {
|
|
@@ -2941,7 +3055,7 @@ class Bt extends p {
|
|
|
2941
3055
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2942
3056
|
}
|
|
2943
3057
|
}
|
|
2944
|
-
class
|
|
3058
|
+
class tr extends _ {
|
|
2945
3059
|
eventManager;
|
|
2946
3060
|
onTrack;
|
|
2947
3061
|
originalPushState;
|
|
@@ -2981,7 +3095,7 @@ class Wt extends p {
|
|
|
2981
3095
|
};
|
|
2982
3096
|
}
|
|
2983
3097
|
trackCurrentPage = () => {
|
|
2984
|
-
const e = window.location.href, t =
|
|
3098
|
+
const e = window.location.href, t = le(e, this.get("config").sensitiveQueryParams);
|
|
2985
3099
|
if (this.get("pageUrl") === t)
|
|
2986
3100
|
return;
|
|
2987
3101
|
const r = Date.now(), s = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2992,16 +3106,16 @@ class Wt extends p {
|
|
|
2992
3106
|
this.set("pageUrl", t);
|
|
2993
3107
|
const o = this.extractPageViewData();
|
|
2994
3108
|
this.eventManager.track({
|
|
2995
|
-
type:
|
|
3109
|
+
type: d.PAGE_VIEW,
|
|
2996
3110
|
page_url: this.get("pageUrl"),
|
|
2997
3111
|
from_page_url: i,
|
|
2998
3112
|
...o && { page_view: o }
|
|
2999
3113
|
});
|
|
3000
3114
|
};
|
|
3001
3115
|
trackInitialPageView() {
|
|
3002
|
-
const e =
|
|
3116
|
+
const e = le(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3003
3117
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3004
|
-
type:
|
|
3118
|
+
type: d.PAGE_VIEW,
|
|
3005
3119
|
page_url: e,
|
|
3006
3120
|
...t && { page_view: t }
|
|
3007
3121
|
}), this.onTrack();
|
|
@@ -3017,7 +3131,7 @@ class Wt extends p {
|
|
|
3017
3131
|
};
|
|
3018
3132
|
}
|
|
3019
3133
|
}
|
|
3020
|
-
class
|
|
3134
|
+
class rr extends _ {
|
|
3021
3135
|
eventManager;
|
|
3022
3136
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3023
3137
|
clickHandler;
|
|
@@ -3042,7 +3156,7 @@ class Gt extends p {
|
|
|
3042
3156
|
this.clickHandler || (this.clickHandler = (e) => {
|
|
3043
3157
|
const t = e, r = t.target, s = typeof HTMLElement < "u" && r instanceof HTMLElement ? r : typeof HTMLElement < "u" && r instanceof Node && r.parentElement instanceof HTMLElement ? r.parentElement : null;
|
|
3044
3158
|
if (!s) {
|
|
3045
|
-
a("
|
|
3159
|
+
a("debug", "Click target not found or not an element");
|
|
3046
3160
|
return;
|
|
3047
3161
|
}
|
|
3048
3162
|
if (this.shouldIgnoreElement(s))
|
|
@@ -3052,22 +3166,22 @@ class Gt extends p {
|
|
|
3052
3166
|
return;
|
|
3053
3167
|
const o = this.findTrackingElement(s), l = this.getRelevantClickElement(s), c = this.calculateClickCoordinates(t, s);
|
|
3054
3168
|
if (o) {
|
|
3055
|
-
const
|
|
3056
|
-
if (
|
|
3057
|
-
const
|
|
3169
|
+
const S = this.extractTrackingData(o);
|
|
3170
|
+
if (S) {
|
|
3171
|
+
const g = this.createCustomEventData(S);
|
|
3058
3172
|
this.eventManager.track({
|
|
3059
|
-
type:
|
|
3173
|
+
type: d.CUSTOM,
|
|
3060
3174
|
custom_event: {
|
|
3061
|
-
name:
|
|
3062
|
-
...
|
|
3175
|
+
name: g.name,
|
|
3176
|
+
...g.value && { metadata: { value: g.value } }
|
|
3063
3177
|
}
|
|
3064
3178
|
});
|
|
3065
3179
|
}
|
|
3066
3180
|
}
|
|
3067
|
-
const
|
|
3181
|
+
const u = this.generateClickData(s, l, c);
|
|
3068
3182
|
this.eventManager.track({
|
|
3069
|
-
type:
|
|
3070
|
-
click_data:
|
|
3183
|
+
type: d.CLICK,
|
|
3184
|
+
click_data: u
|
|
3071
3185
|
});
|
|
3072
3186
|
}, window.addEventListener("click", this.clickHandler, !0));
|
|
3073
3187
|
}
|
|
@@ -3081,7 +3195,7 @@ class Gt extends p {
|
|
|
3081
3195
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
3082
3196
|
}
|
|
3083
3197
|
shouldIgnoreElement(e) {
|
|
3084
|
-
return e.hasAttribute(`${
|
|
3198
|
+
return e.hasAttribute(`${w}-ignore`) ? !0 : e.closest(`[${w}-ignore]`) !== null;
|
|
3085
3199
|
}
|
|
3086
3200
|
/**
|
|
3087
3201
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -3132,8 +3246,8 @@ class Gt extends p {
|
|
|
3132
3246
|
const t = e.getAttribute("data-testid");
|
|
3133
3247
|
if (t)
|
|
3134
3248
|
return `[data-testid="${t}"]`;
|
|
3135
|
-
const r = e.getAttribute(`${
|
|
3136
|
-
return r ? `[${
|
|
3249
|
+
const r = e.getAttribute(`${w}-name`);
|
|
3250
|
+
return r ? `[${w}-name="${r}"]` : this.getElementPath(e);
|
|
3137
3251
|
}
|
|
3138
3252
|
/**
|
|
3139
3253
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -3152,10 +3266,10 @@ class Gt extends p {
|
|
|
3152
3266
|
return t.join(">") || "unknown";
|
|
3153
3267
|
}
|
|
3154
3268
|
findTrackingElement(e) {
|
|
3155
|
-
return e.hasAttribute(`${
|
|
3269
|
+
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3156
3270
|
}
|
|
3157
3271
|
getRelevantClickElement(e) {
|
|
3158
|
-
for (const t of
|
|
3272
|
+
for (const t of st)
|
|
3159
3273
|
try {
|
|
3160
3274
|
if (e.matches(t))
|
|
3161
3275
|
return e;
|
|
@@ -3163,7 +3277,7 @@ class Gt extends p {
|
|
|
3163
3277
|
if (r)
|
|
3164
3278
|
return r;
|
|
3165
3279
|
} catch (r) {
|
|
3166
|
-
a("
|
|
3280
|
+
a("debug", "Invalid selector in element search", { error: r, data: { selector: t } });
|
|
3167
3281
|
continue;
|
|
3168
3282
|
}
|
|
3169
3283
|
return e;
|
|
@@ -3187,7 +3301,7 @@ class Gt extends p {
|
|
|
3187
3301
|
return { x: s, y: i, relativeX: o, relativeY: l };
|
|
3188
3302
|
}
|
|
3189
3303
|
extractTrackingData(e) {
|
|
3190
|
-
const t = e.getAttribute(`${
|
|
3304
|
+
const t = e.getAttribute(`${w}-name`), r = e.getAttribute(`${w}-value`);
|
|
3191
3305
|
if (t)
|
|
3192
3306
|
return {
|
|
3193
3307
|
element: e,
|
|
@@ -3196,7 +3310,7 @@ class Gt extends p {
|
|
|
3196
3310
|
};
|
|
3197
3311
|
}
|
|
3198
3312
|
generateClickData(e, t, r) {
|
|
3199
|
-
const { x: s, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t),
|
|
3313
|
+
const { x: s, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
3200
3314
|
return {
|
|
3201
3315
|
x: s,
|
|
3202
3316
|
y: i,
|
|
@@ -3206,12 +3320,12 @@ class Gt extends p {
|
|
|
3206
3320
|
...t.id && { id: t.id },
|
|
3207
3321
|
...t.className && { class: t.className },
|
|
3208
3322
|
...c && { text: c },
|
|
3209
|
-
...
|
|
3210
|
-
...
|
|
3211
|
-
...
|
|
3212
|
-
...
|
|
3213
|
-
...
|
|
3214
|
-
...Object.keys(
|
|
3323
|
+
...u.href && { href: u.href },
|
|
3324
|
+
...u.title && { title: u.title },
|
|
3325
|
+
...u.alt && { alt: u.alt },
|
|
3326
|
+
...u.role && { role: u.role },
|
|
3327
|
+
...u["aria-label"] && { ariaLabel: u["aria-label"] },
|
|
3328
|
+
...Object.keys(u).length > 0 && { dataAttributes: u }
|
|
3215
3329
|
};
|
|
3216
3330
|
}
|
|
3217
3331
|
/**
|
|
@@ -3235,7 +3349,7 @@ class Gt extends p {
|
|
|
3235
3349
|
*/
|
|
3236
3350
|
sanitizeText(e) {
|
|
3237
3351
|
let t = e;
|
|
3238
|
-
for (const r of
|
|
3352
|
+
for (const r of Be) {
|
|
3239
3353
|
const s = new RegExp(r.source, r.flags);
|
|
3240
3354
|
t = t.replace(s, "[REDACTED]");
|
|
3241
3355
|
}
|
|
@@ -3274,7 +3388,7 @@ class Gt extends p {
|
|
|
3274
3388
|
};
|
|
3275
3389
|
}
|
|
3276
3390
|
}
|
|
3277
|
-
class
|
|
3391
|
+
class nr extends _ {
|
|
3278
3392
|
eventManager;
|
|
3279
3393
|
containers = [];
|
|
3280
3394
|
limitWarningLogged = !1;
|
|
@@ -3375,7 +3489,7 @@ class Xt extends p {
|
|
|
3375
3489
|
return this.isWindowScrollable() ? e === window : this.containers.length === 0;
|
|
3376
3490
|
}
|
|
3377
3491
|
setupScrollContainer(e, t) {
|
|
3378
|
-
if (this.containers.some((
|
|
3492
|
+
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3379
3493
|
return;
|
|
3380
3494
|
const s = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3381
3495
|
s,
|
|
@@ -3395,10 +3509,10 @@ class Xt extends p {
|
|
|
3395
3509
|
listener: null
|
|
3396
3510
|
}, c = () => {
|
|
3397
3511
|
this.get("suppressNextScroll") || (l.firstScrollEventTime === null && (l.firstScrollEventTime = Date.now()), this.clearContainerTimer(l), l.debounceTimer = window.setTimeout(() => {
|
|
3398
|
-
const
|
|
3399
|
-
if (
|
|
3400
|
-
const
|
|
3401
|
-
this.processScrollEvent(l,
|
|
3512
|
+
const u = this.calculateScrollData(l);
|
|
3513
|
+
if (u) {
|
|
3514
|
+
const S = Date.now();
|
|
3515
|
+
this.processScrollEvent(l, u, S);
|
|
3402
3516
|
}
|
|
3403
3517
|
l.debounceTimer = null;
|
|
3404
3518
|
}, 250));
|
|
@@ -3411,7 +3525,7 @@ class Xt extends p {
|
|
|
3411
3525
|
e.lastEventTime = r, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3412
3526
|
const s = this.get("scrollEventCount") ?? 0;
|
|
3413
3527
|
this.set("scrollEventCount", s + 1), this.eventManager.track({
|
|
3414
|
-
type:
|
|
3528
|
+
type: d.SCROLL,
|
|
3415
3529
|
scroll_data: {
|
|
3416
3530
|
...t,
|
|
3417
3531
|
container_selector: e.selector,
|
|
@@ -3432,7 +3546,7 @@ class Xt extends p {
|
|
|
3432
3546
|
return Math.abs(t - e.lastDepth) >= this.minDepthChange;
|
|
3433
3547
|
}
|
|
3434
3548
|
logLimitOnce() {
|
|
3435
|
-
this.limitWarningLogged || (this.limitWarningLogged = !0, a("
|
|
3549
|
+
this.limitWarningLogged || (this.limitWarningLogged = !0, a("debug", "Max scroll events per session reached", {
|
|
3436
3550
|
data: { limit: this.maxEventsPerSession }
|
|
3437
3551
|
}));
|
|
3438
3552
|
}
|
|
@@ -3458,14 +3572,14 @@ class Xt extends p {
|
|
|
3458
3572
|
const { element: t, lastScrollPos: r, lastEventTime: s } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - r);
|
|
3459
3573
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3460
3574
|
return null;
|
|
3461
|
-
const c = this.getViewportHeight(t),
|
|
3462
|
-
let
|
|
3463
|
-
s > 0 ?
|
|
3464
|
-
const
|
|
3465
|
-
return
|
|
3466
|
-
depth:
|
|
3467
|
-
direction:
|
|
3468
|
-
velocity:
|
|
3575
|
+
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), S = this.getScrollDirection(i, r), g = this.calculateScrollDepth(i, u, c);
|
|
3576
|
+
let E;
|
|
3577
|
+
s > 0 ? E = o - s : e.firstScrollEventTime !== null ? E = o - e.firstScrollEventTime : E = 250;
|
|
3578
|
+
const p = Math.round(l / E * 1e3);
|
|
3579
|
+
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3580
|
+
depth: g,
|
|
3581
|
+
direction: S,
|
|
3582
|
+
velocity: p,
|
|
3469
3583
|
max_depth_reached: e.maxDepthReached
|
|
3470
3584
|
};
|
|
3471
3585
|
}
|
|
@@ -3489,7 +3603,7 @@ class Xt extends p {
|
|
|
3489
3603
|
else {
|
|
3490
3604
|
const s = document.querySelector(e);
|
|
3491
3605
|
if (!(s instanceof HTMLElement)) {
|
|
3492
|
-
a("
|
|
3606
|
+
a("debug", `Selector "${e}" did not match an HTMLElement`);
|
|
3493
3607
|
return;
|
|
3494
3608
|
}
|
|
3495
3609
|
t = s;
|
|
@@ -3502,7 +3616,7 @@ class Xt extends p {
|
|
|
3502
3616
|
e.isPrimary = t;
|
|
3503
3617
|
}
|
|
3504
3618
|
}
|
|
3505
|
-
class
|
|
3619
|
+
class sr extends _ {
|
|
3506
3620
|
eventManager;
|
|
3507
3621
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3508
3622
|
observer = null;
|
|
@@ -3521,15 +3635,15 @@ class Qt extends p {
|
|
|
3521
3635
|
return;
|
|
3522
3636
|
const t = this.config.threshold ?? 0.5, r = this.config.minDwellTime ?? 1e3;
|
|
3523
3637
|
if (t < 0 || t > 1) {
|
|
3524
|
-
a("
|
|
3638
|
+
a("debug", "ViewportHandler: Invalid threshold, must be between 0 and 1");
|
|
3525
3639
|
return;
|
|
3526
3640
|
}
|
|
3527
3641
|
if (r < 0) {
|
|
3528
|
-
a("
|
|
3642
|
+
a("debug", "ViewportHandler: Invalid minDwellTime, must be non-negative");
|
|
3529
3643
|
return;
|
|
3530
3644
|
}
|
|
3531
3645
|
if (typeof IntersectionObserver > "u") {
|
|
3532
|
-
a("
|
|
3646
|
+
a("debug", "ViewportHandler: IntersectionObserver not supported in this browser");
|
|
3533
3647
|
return;
|
|
3534
3648
|
}
|
|
3535
3649
|
this.observer = new IntersectionObserver(this.handleIntersection, {
|
|
@@ -3557,7 +3671,7 @@ class Qt extends p {
|
|
|
3557
3671
|
const s = document.querySelectorAll(r.selector);
|
|
3558
3672
|
for (const i of Array.from(s)) {
|
|
3559
3673
|
if (t >= e) {
|
|
3560
|
-
a("
|
|
3674
|
+
a("debug", "ViewportHandler: Maximum tracked elements reached", {
|
|
3561
3675
|
data: {
|
|
3562
3676
|
limit: e,
|
|
3563
3677
|
selector: r.selector,
|
|
@@ -3566,7 +3680,7 @@ class Qt extends p {
|
|
|
3566
3680
|
});
|
|
3567
3681
|
return;
|
|
3568
3682
|
}
|
|
3569
|
-
i.hasAttribute(`${
|
|
3683
|
+
i.hasAttribute(`${w}-ignore`) || this.trackedElements.has(i) || (this.trackedElements.set(i, {
|
|
3570
3684
|
element: i,
|
|
3571
3685
|
selector: r.selector,
|
|
3572
3686
|
id: r.id,
|
|
@@ -3577,7 +3691,7 @@ class Qt extends p {
|
|
|
3577
3691
|
}), this.observer?.observe(i), t++);
|
|
3578
3692
|
}
|
|
3579
3693
|
} catch (s) {
|
|
3580
|
-
a("
|
|
3694
|
+
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error: s });
|
|
3581
3695
|
}
|
|
3582
3696
|
a("debug", "ViewportHandler: Elements tracked", {
|
|
3583
3697
|
data: { count: t, limit: e }
|
|
@@ -3603,7 +3717,7 @@ class Qt extends p {
|
|
|
3603
3717
|
fireViewportEvent(e, t) {
|
|
3604
3718
|
if (e.startTime === null) return;
|
|
3605
3719
|
const r = Math.round(performance.now() - e.startTime);
|
|
3606
|
-
if (e.element.hasAttribute(`${
|
|
3720
|
+
if (e.element.hasAttribute(`${w}-ignore`))
|
|
3607
3721
|
return;
|
|
3608
3722
|
const s = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3609
3723
|
if (e.lastFiredTime !== null && i - e.lastFiredTime < s) {
|
|
@@ -3623,7 +3737,7 @@ class Qt extends p {
|
|
|
3623
3737
|
...e.name !== void 0 && { name: e.name }
|
|
3624
3738
|
};
|
|
3625
3739
|
this.eventManager.track({
|
|
3626
|
-
type:
|
|
3740
|
+
type: d.VIEWPORT_VISIBLE,
|
|
3627
3741
|
viewport_data: o
|
|
3628
3742
|
}), e.startTime = null, e.timeoutId = null, e.lastFiredTime = i;
|
|
3629
3743
|
}
|
|
@@ -3633,7 +3747,7 @@ class Qt extends p {
|
|
|
3633
3747
|
setupMutationObserver() {
|
|
3634
3748
|
if (!(!this.config || typeof MutationObserver > "u")) {
|
|
3635
3749
|
if (!document.body) {
|
|
3636
|
-
a("
|
|
3750
|
+
a("debug", "ViewportHandler: document.body not available, skipping MutationObserver setup");
|
|
3637
3751
|
return;
|
|
3638
3752
|
}
|
|
3639
3753
|
this.mutationObserver = new MutationObserver((e) => {
|
|
@@ -3663,14 +3777,14 @@ class Qt extends p {
|
|
|
3663
3777
|
});
|
|
3664
3778
|
}
|
|
3665
3779
|
}
|
|
3666
|
-
class
|
|
3780
|
+
class ir {
|
|
3667
3781
|
storage;
|
|
3668
3782
|
sessionStorageRef;
|
|
3669
3783
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
3670
3784
|
fallbackSessionStorage = /* @__PURE__ */ new Map();
|
|
3671
3785
|
hasQuotaExceededError = !1;
|
|
3672
3786
|
constructor() {
|
|
3673
|
-
this.storage = this.initializeStorage("localStorage"), this.sessionStorageRef = this.initializeStorage("sessionStorage"), this.storage || a("
|
|
3787
|
+
this.storage = this.initializeStorage("localStorage"), this.sessionStorageRef = this.initializeStorage("sessionStorage"), this.storage || a("debug", "localStorage not available, using memory fallback"), this.sessionStorageRef || a("debug", "sessionStorage not available, using memory fallback");
|
|
3674
3788
|
}
|
|
3675
3789
|
/**
|
|
3676
3790
|
* Retrieves an item from localStorage.
|
|
@@ -3946,7 +4060,7 @@ class zt {
|
|
|
3946
4060
|
this.fallbackSessionStorage.delete(e);
|
|
3947
4061
|
}
|
|
3948
4062
|
}
|
|
3949
|
-
class
|
|
4063
|
+
class or extends _ {
|
|
3950
4064
|
eventManager;
|
|
3951
4065
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3952
4066
|
navigationHistory = [];
|
|
@@ -3957,7 +4071,7 @@ class jt extends p {
|
|
|
3957
4071
|
navigationCounter = 0;
|
|
3958
4072
|
// Counter for handling simultaneous navigations edge case
|
|
3959
4073
|
constructor(e) {
|
|
3960
|
-
super(), this.eventManager = e, this.vitalThresholds = Ne(
|
|
4074
|
+
super(), this.eventManager = e, this.vitalThresholds = Ne(ae);
|
|
3961
4075
|
}
|
|
3962
4076
|
/**
|
|
3963
4077
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3974,7 +4088,7 @@ class jt extends p {
|
|
|
3974
4088
|
* @returns Promise that resolves when tracking is initialized
|
|
3975
4089
|
*/
|
|
3976
4090
|
async startTracking() {
|
|
3977
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4091
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ae;
|
|
3978
4092
|
this.vitalThresholds = Ne(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
3979
4093
|
}
|
|
3980
4094
|
/**
|
|
@@ -3991,7 +4105,7 @@ class jt extends p {
|
|
|
3991
4105
|
try {
|
|
3992
4106
|
e.disconnect();
|
|
3993
4107
|
} catch (r) {
|
|
3994
|
-
a("
|
|
4108
|
+
a("debug", "Failed to disconnect performance observer", { error: r, data: { observerIndex: t } });
|
|
3995
4109
|
}
|
|
3996
4110
|
}), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0;
|
|
3997
4111
|
}
|
|
@@ -4045,13 +4159,13 @@ class jt extends p {
|
|
|
4045
4159
|
}
|
|
4046
4160
|
async initWebVitals() {
|
|
4047
4161
|
try {
|
|
4048
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() =>
|
|
4049
|
-
const
|
|
4050
|
-
this.sendVital({ type: l, value:
|
|
4162
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() => Nr), o = (l) => (c) => {
|
|
4163
|
+
const u = Number(c.value.toFixed(2));
|
|
4164
|
+
this.sendVital({ type: l, value: u });
|
|
4051
4165
|
};
|
|
4052
4166
|
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }), s(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
4053
4167
|
} catch (e) {
|
|
4054
|
-
a("
|
|
4168
|
+
a("debug", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
|
|
4055
4169
|
}
|
|
4056
4170
|
}
|
|
4057
4171
|
reportTTFB() {
|
|
@@ -4062,7 +4176,7 @@ class jt extends p {
|
|
|
4062
4176
|
const t = e.responseStart;
|
|
4063
4177
|
typeof t == "number" && Number.isFinite(t) && this.sendVital({ type: "TTFB", value: Number(t.toFixed(2)) });
|
|
4064
4178
|
} catch (e) {
|
|
4065
|
-
a("
|
|
4179
|
+
a("debug", "Failed to report TTFB", { error: e });
|
|
4066
4180
|
}
|
|
4067
4181
|
}
|
|
4068
4182
|
observeLongTasks() {
|
|
@@ -4072,7 +4186,7 @@ class jt extends p {
|
|
|
4072
4186
|
const t = e.getEntries();
|
|
4073
4187
|
for (const r of t) {
|
|
4074
4188
|
const s = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4075
|
-
i - this.lastLongTaskSentAt >=
|
|
4189
|
+
i - this.lastLongTaskSentAt >= Mt && (this.shouldSendVital("LONG_TASK", s) && this.trackWebVital("LONG_TASK", s), this.lastLongTaskSentAt = i);
|
|
4076
4190
|
}
|
|
4077
4191
|
},
|
|
4078
4192
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4088,7 +4202,7 @@ class jt extends p {
|
|
|
4088
4202
|
return;
|
|
4089
4203
|
if (r)
|
|
4090
4204
|
r.add(e.type);
|
|
4091
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4205
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Ct) {
|
|
4092
4206
|
const i = this.navigationHistory.shift();
|
|
4093
4207
|
i && this.reportedByNav.delete(i);
|
|
4094
4208
|
}
|
|
@@ -4097,11 +4211,11 @@ class jt extends p {
|
|
|
4097
4211
|
}
|
|
4098
4212
|
trackWebVital(e, t) {
|
|
4099
4213
|
if (!Number.isFinite(t)) {
|
|
4100
|
-
a("
|
|
4214
|
+
a("debug", "Invalid web vital value", { data: { type: e, value: t } });
|
|
4101
4215
|
return;
|
|
4102
4216
|
}
|
|
4103
4217
|
this.eventManager.track({
|
|
4104
|
-
type:
|
|
4218
|
+
type: d.WEB_VITALS,
|
|
4105
4219
|
web_vitals: {
|
|
4106
4220
|
type: e,
|
|
4107
4221
|
value: t
|
|
@@ -4137,7 +4251,7 @@ class jt extends p {
|
|
|
4137
4251
|
const t = e.startTime || performance.now(), r = ++this.navigationCounter, s = `${t.toFixed(2)}_${window.location.pathname}`;
|
|
4138
4252
|
return r > 1 ? `${s}_${r}` : s;
|
|
4139
4253
|
} catch (e) {
|
|
4140
|
-
return a("
|
|
4254
|
+
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
4141
4255
|
}
|
|
4142
4256
|
}
|
|
4143
4257
|
isObserverSupported(e) {
|
|
@@ -4153,7 +4267,7 @@ class jt extends p {
|
|
|
4153
4267
|
try {
|
|
4154
4268
|
t(o, l);
|
|
4155
4269
|
} catch (c) {
|
|
4156
|
-
a("
|
|
4270
|
+
a("debug", "Observer callback failed", {
|
|
4157
4271
|
error: c,
|
|
4158
4272
|
data: { type: e }
|
|
4159
4273
|
});
|
|
@@ -4166,7 +4280,7 @@ class jt extends p {
|
|
|
4166
4280
|
});
|
|
4167
4281
|
return i.observe(r ?? { type: e, buffered: !0 }), s || this.observers.push(i), !0;
|
|
4168
4282
|
} catch (i) {
|
|
4169
|
-
return a("
|
|
4283
|
+
return a("debug", "Failed to create performance observer", {
|
|
4170
4284
|
error: i,
|
|
4171
4285
|
data: { type: e }
|
|
4172
4286
|
}), !1;
|
|
@@ -4174,12 +4288,12 @@ class jt extends p {
|
|
|
4174
4288
|
}
|
|
4175
4289
|
shouldSendVital(e, t) {
|
|
4176
4290
|
if (typeof t != "number" || !Number.isFinite(t))
|
|
4177
|
-
return a("
|
|
4291
|
+
return a("debug", "Invalid web vital value", { data: { type: e, value: t } }), !1;
|
|
4178
4292
|
const r = this.vitalThresholds[e];
|
|
4179
4293
|
return !(typeof r == "number" && t <= r);
|
|
4180
4294
|
}
|
|
4181
4295
|
}
|
|
4182
|
-
class
|
|
4296
|
+
class ar extends _ {
|
|
4183
4297
|
eventManager;
|
|
4184
4298
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4185
4299
|
errorBurstCounter = 0;
|
|
@@ -4215,24 +4329,24 @@ class Kt extends p {
|
|
|
4215
4329
|
const e = Date.now();
|
|
4216
4330
|
if (e < this.burstBackoffUntil)
|
|
4217
4331
|
return !1;
|
|
4218
|
-
if (e - this.burstWindowStart >
|
|
4219
|
-
return this.burstBackoffUntil = e + Ce, a("
|
|
4332
|
+
if (e - this.burstWindowStart > yt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > bt)
|
|
4333
|
+
return this.burstBackoffUntil = e + Ce, a("debug", "Error burst detected - entering cooldown", {
|
|
4220
4334
|
data: {
|
|
4221
4335
|
errorsInWindow: this.errorBurstCounter,
|
|
4222
4336
|
cooldownMs: Ce
|
|
4223
4337
|
}
|
|
4224
4338
|
}), !1;
|
|
4225
|
-
const r = this.get("config")?.errorSampling ??
|
|
4339
|
+
const r = this.get("config")?.errorSampling ?? We;
|
|
4226
4340
|
return Math.random() < r;
|
|
4227
4341
|
}
|
|
4228
4342
|
handleError = (e) => {
|
|
4229
4343
|
if (!this.shouldSample())
|
|
4230
4344
|
return;
|
|
4231
4345
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4232
|
-
this.shouldSuppressError(
|
|
4233
|
-
type:
|
|
4346
|
+
this.shouldSuppressError(U.JS_ERROR, t) || this.eventManager.track({
|
|
4347
|
+
type: d.ERROR,
|
|
4234
4348
|
error_data: {
|
|
4235
|
-
type:
|
|
4349
|
+
type: U.JS_ERROR,
|
|
4236
4350
|
message: t,
|
|
4237
4351
|
...e.filename && { filename: e.filename },
|
|
4238
4352
|
...e.lineno && { line: e.lineno },
|
|
@@ -4244,10 +4358,10 @@ class Kt extends p {
|
|
|
4244
4358
|
if (!this.shouldSample())
|
|
4245
4359
|
return;
|
|
4246
4360
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4247
|
-
this.shouldSuppressError(
|
|
4248
|
-
type:
|
|
4361
|
+
this.shouldSuppressError(U.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4362
|
+
type: d.ERROR,
|
|
4249
4363
|
error_data: {
|
|
4250
|
-
type:
|
|
4364
|
+
type: U.PROMISE_REJECTION,
|
|
4251
4365
|
message: r
|
|
4252
4366
|
}
|
|
4253
4367
|
});
|
|
@@ -4266,8 +4380,8 @@ class Kt extends p {
|
|
|
4266
4380
|
}
|
|
4267
4381
|
}
|
|
4268
4382
|
sanitize(e) {
|
|
4269
|
-
let t = e.length >
|
|
4270
|
-
for (const r of
|
|
4383
|
+
let t = e.length > Le ? e.slice(0, Le) + "..." : e;
|
|
4384
|
+
for (const r of Be) {
|
|
4271
4385
|
const s = new RegExp(r.source, r.flags);
|
|
4272
4386
|
t = t.replace(s, "[REDACTED]");
|
|
4273
4387
|
}
|
|
@@ -4275,12 +4389,12 @@ class Kt extends p {
|
|
|
4275
4389
|
}
|
|
4276
4390
|
shouldSuppressError(e, t) {
|
|
4277
4391
|
const r = Date.now(), s = `${e}:${t}`, i = this.recentErrors.get(s);
|
|
4278
|
-
return i && r - i <
|
|
4392
|
+
return i && r - i < Me ? (this.recentErrors.set(s, r), !0) : (this.recentErrors.set(s, r), this.recentErrors.size > wt ? (this.recentErrors.clear(), this.recentErrors.set(s, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4279
4393
|
}
|
|
4280
4394
|
pruneOldErrors() {
|
|
4281
4395
|
const e = Date.now();
|
|
4282
4396
|
for (const [s, i] of this.recentErrors.entries())
|
|
4283
|
-
e - i >
|
|
4397
|
+
e - i > Me && this.recentErrors.delete(s);
|
|
4284
4398
|
if (this.recentErrors.size <= Q)
|
|
4285
4399
|
return;
|
|
4286
4400
|
const t = Array.from(this.recentErrors.entries()).sort((s, i) => s[1] - i[1]), r = this.recentErrors.size - Q;
|
|
@@ -4290,10 +4404,10 @@ class Kt extends p {
|
|
|
4290
4404
|
}
|
|
4291
4405
|
}
|
|
4292
4406
|
}
|
|
4293
|
-
class
|
|
4407
|
+
class lr extends _ {
|
|
4294
4408
|
isInitialized = !1;
|
|
4295
4409
|
suppressNextScrollTimer = null;
|
|
4296
|
-
emitter = new
|
|
4410
|
+
emitter = new zt();
|
|
4297
4411
|
transformers = {};
|
|
4298
4412
|
managers = {};
|
|
4299
4413
|
handlers = {};
|
|
@@ -4309,9 +4423,9 @@ class Yt extends p {
|
|
|
4309
4423
|
*/
|
|
4310
4424
|
async init(e = {}) {
|
|
4311
4425
|
if (!this.isInitialized) {
|
|
4312
|
-
this.managers.storage = new
|
|
4426
|
+
this.managers.storage = new ir();
|
|
4313
4427
|
try {
|
|
4314
|
-
this.setupState(e), this.managers.event = new
|
|
4428
|
+
this.setupState(e), this.managers.event = new Yt(this.managers.storage, this.emitter, this.transformers), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
4315
4429
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
4316
4430
|
}), this.isInitialized = !0;
|
|
4317
4431
|
} catch (t) {
|
|
@@ -4335,14 +4449,14 @@ class Yt extends p {
|
|
|
4335
4449
|
}
|
|
4336
4450
|
let r = t;
|
|
4337
4451
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4338
|
-
const { valid: s, error: i, sanitizedMetadata: o } =
|
|
4452
|
+
const { valid: s, error: i, sanitizedMetadata: o } = Qt(e, r);
|
|
4339
4453
|
if (!s) {
|
|
4340
4454
|
if (this.get("mode") === j.QA)
|
|
4341
4455
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4342
4456
|
return;
|
|
4343
4457
|
}
|
|
4344
4458
|
this.managers.event.track({
|
|
4345
|
-
type:
|
|
4459
|
+
type: d.CUSTOM,
|
|
4346
4460
|
custom_event: {
|
|
4347
4461
|
name: e,
|
|
4348
4462
|
...o && { metadata: o }
|
|
@@ -4383,16 +4497,14 @@ class Yt extends p {
|
|
|
4383
4497
|
}
|
|
4384
4498
|
setupState(e = {}) {
|
|
4385
4499
|
this.set("config", e);
|
|
4386
|
-
const t =
|
|
4500
|
+
const t = qt.getId(this.managers.storage);
|
|
4387
4501
|
this.set("userId", t);
|
|
4388
|
-
const r =
|
|
4502
|
+
const r = xt(e);
|
|
4389
4503
|
this.set("collectApiUrls", r);
|
|
4390
|
-
const s =
|
|
4504
|
+
const s = It();
|
|
4391
4505
|
this.set("device", s);
|
|
4392
|
-
const i =
|
|
4393
|
-
this.set("pageUrl", i);
|
|
4394
|
-
const o = It() ? j.QA : void 0;
|
|
4395
|
-
o && this.set("mode", o);
|
|
4506
|
+
const i = le(window.location.href, e.sensitiveQueryParams);
|
|
4507
|
+
this.set("pageUrl", i), Pt() && this.set("mode", j.QA);
|
|
4396
4508
|
}
|
|
4397
4509
|
/**
|
|
4398
4510
|
* Returns the current configuration object.
|
|
@@ -4434,7 +4546,7 @@ class Yt extends p {
|
|
|
4434
4546
|
valid: !1,
|
|
4435
4547
|
error: "Global metadata must be a plain object"
|
|
4436
4548
|
};
|
|
4437
|
-
const t =
|
|
4549
|
+
const t = ze("Global", e, "globalMetadata");
|
|
4438
4550
|
return t.valid ? { valid: !0 } : {
|
|
4439
4551
|
valid: !1,
|
|
4440
4552
|
error: t.error
|
|
@@ -4479,7 +4591,7 @@ class Yt extends p {
|
|
|
4479
4591
|
}
|
|
4480
4592
|
initializeHandlers() {
|
|
4481
4593
|
const e = this.get("config");
|
|
4482
|
-
this.handlers.session = new
|
|
4594
|
+
this.handlers.session = new er(
|
|
4483
4595
|
this.managers.storage,
|
|
4484
4596
|
this.managers.event
|
|
4485
4597
|
), this.handlers.session.startTracking();
|
|
@@ -4488,24 +4600,24 @@ class Yt extends p {
|
|
|
4488
4600
|
this.set("suppressNextScroll", !1);
|
|
4489
4601
|
}, 500);
|
|
4490
4602
|
};
|
|
4491
|
-
this.handlers.pageView = new
|
|
4603
|
+
this.handlers.pageView = new tr(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new rr(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new nr(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new or(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4492
4604
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4493
|
-
}), this.handlers.error = new
|
|
4605
|
+
}), this.handlers.error = new ar(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new sr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4494
4606
|
}
|
|
4495
4607
|
}
|
|
4496
|
-
const
|
|
4497
|
-
let f = null,
|
|
4498
|
-
const
|
|
4499
|
-
if (!(typeof window > "u" || typeof document > "u") && (
|
|
4500
|
-
|
|
4608
|
+
const R = [], M = [];
|
|
4609
|
+
let f = null, C = !1, v = !1;
|
|
4610
|
+
const cr = async (n) => {
|
|
4611
|
+
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !C)) {
|
|
4612
|
+
C = !0;
|
|
4501
4613
|
try {
|
|
4502
|
-
const e =
|
|
4614
|
+
const e = Wt(n ?? {}), t = new lr();
|
|
4503
4615
|
try {
|
|
4504
|
-
|
|
4616
|
+
R.forEach(({ event: i, callback: o }) => {
|
|
4505
4617
|
t.on(i, o);
|
|
4506
|
-
}),
|
|
4618
|
+
}), R.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4507
4619
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4508
|
-
}),
|
|
4620
|
+
}), M.length = 0;
|
|
4509
4621
|
const r = t.init(e), s = new Promise((i, o) => {
|
|
4510
4622
|
setTimeout(() => {
|
|
4511
4623
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4523,120 +4635,120 @@ const qt = async (n) => {
|
|
|
4523
4635
|
} catch (e) {
|
|
4524
4636
|
throw f = null, e;
|
|
4525
4637
|
} finally {
|
|
4526
|
-
|
|
4638
|
+
C = !1;
|
|
4527
4639
|
}
|
|
4528
4640
|
}
|
|
4529
|
-
},
|
|
4641
|
+
}, ur = (n, e) => {
|
|
4530
4642
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4531
4643
|
if (!f)
|
|
4532
4644
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4533
|
-
if (
|
|
4645
|
+
if (v)
|
|
4534
4646
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4535
4647
|
f.sendCustomEvent(n, e);
|
|
4536
4648
|
}
|
|
4537
|
-
},
|
|
4649
|
+
}, dr = (n, e) => {
|
|
4538
4650
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4539
|
-
if (!f ||
|
|
4540
|
-
|
|
4651
|
+
if (!f || C) {
|
|
4652
|
+
R.push({ event: n, callback: e });
|
|
4541
4653
|
return;
|
|
4542
4654
|
}
|
|
4543
4655
|
f.on(n, e);
|
|
4544
4656
|
}
|
|
4545
|
-
},
|
|
4657
|
+
}, hr = (n, e) => {
|
|
4546
4658
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4547
4659
|
if (!f) {
|
|
4548
|
-
const t =
|
|
4549
|
-
t !== -1 &&
|
|
4660
|
+
const t = R.findIndex((r) => r.event === n && r.callback === e);
|
|
4661
|
+
t !== -1 && R.splice(t, 1);
|
|
4550
4662
|
return;
|
|
4551
4663
|
}
|
|
4552
4664
|
f.off(n, e);
|
|
4553
4665
|
}
|
|
4554
4666
|
};
|
|
4555
|
-
function
|
|
4667
|
+
function fr(n, e) {
|
|
4556
4668
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4557
4669
|
if (typeof e != "function")
|
|
4558
4670
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4559
|
-
if (!f ||
|
|
4560
|
-
const t =
|
|
4561
|
-
t !== -1 &&
|
|
4671
|
+
if (!f || C) {
|
|
4672
|
+
const t = M.findIndex((r) => r.hook === n);
|
|
4673
|
+
t !== -1 && M.splice(t, 1), M.push({ hook: n, fn: e });
|
|
4562
4674
|
return;
|
|
4563
4675
|
}
|
|
4564
|
-
if (
|
|
4676
|
+
if (v)
|
|
4565
4677
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4566
4678
|
n === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4567
4679
|
}
|
|
4568
4680
|
}
|
|
4569
|
-
const
|
|
4681
|
+
const mr = (n) => {
|
|
4570
4682
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4571
4683
|
if (!f) {
|
|
4572
|
-
const e =
|
|
4573
|
-
e !== -1 &&
|
|
4684
|
+
const e = M.findIndex((t) => t.hook === n);
|
|
4685
|
+
e !== -1 && M.splice(e, 1);
|
|
4574
4686
|
return;
|
|
4575
4687
|
}
|
|
4576
|
-
if (
|
|
4688
|
+
if (v)
|
|
4577
4689
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4578
4690
|
f.removeTransformer(n);
|
|
4579
4691
|
}
|
|
4580
|
-
},
|
|
4692
|
+
}, gr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Er = () => {
|
|
4581
4693
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4582
|
-
if (
|
|
4694
|
+
if (v)
|
|
4583
4695
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
4584
4696
|
if (!f) {
|
|
4585
|
-
|
|
4697
|
+
v = !1;
|
|
4586
4698
|
return;
|
|
4587
4699
|
}
|
|
4588
|
-
|
|
4700
|
+
v = !0;
|
|
4589
4701
|
try {
|
|
4590
|
-
f.destroy(), f = null,
|
|
4702
|
+
f.destroy(), f = null, C = !1, R.length = 0, M.length = 0, v = !1;
|
|
4591
4703
|
} catch (n) {
|
|
4592
|
-
f = null,
|
|
4704
|
+
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4593
4705
|
}
|
|
4594
4706
|
}
|
|
4595
|
-
},
|
|
4596
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4597
|
-
},
|
|
4707
|
+
}, Sr = (n) => {
|
|
4708
|
+
typeof window > "u" || typeof document > "u" || Dt(n);
|
|
4709
|
+
}, pr = (n) => {
|
|
4598
4710
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4599
4711
|
if (!f)
|
|
4600
4712
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4601
|
-
if (
|
|
4713
|
+
if (v)
|
|
4602
4714
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4603
4715
|
f.updateGlobalMetadata(n);
|
|
4604
4716
|
}
|
|
4605
|
-
},
|
|
4717
|
+
}, Tr = (n) => {
|
|
4606
4718
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4607
4719
|
if (!f)
|
|
4608
4720
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4609
|
-
if (
|
|
4721
|
+
if (v)
|
|
4610
4722
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4611
4723
|
f.mergeGlobalMetadata(n);
|
|
4612
4724
|
}
|
|
4613
|
-
},
|
|
4614
|
-
init:
|
|
4615
|
-
event:
|
|
4616
|
-
on:
|
|
4617
|
-
off:
|
|
4618
|
-
setTransformer:
|
|
4619
|
-
removeTransformer:
|
|
4620
|
-
isInitialized:
|
|
4621
|
-
destroy:
|
|
4622
|
-
setQaMode:
|
|
4623
|
-
updateGlobalMetadata:
|
|
4624
|
-
mergeGlobalMetadata:
|
|
4725
|
+
}, Qr = {
|
|
4726
|
+
init: cr,
|
|
4727
|
+
event: ur,
|
|
4728
|
+
on: dr,
|
|
4729
|
+
off: hr,
|
|
4730
|
+
setTransformer: fr,
|
|
4731
|
+
removeTransformer: mr,
|
|
4732
|
+
isInitialized: gr,
|
|
4733
|
+
destroy: Er,
|
|
4734
|
+
setQaMode: Sr,
|
|
4735
|
+
updateGlobalMetadata: pr,
|
|
4736
|
+
mergeGlobalMetadata: Tr
|
|
4625
4737
|
};
|
|
4626
|
-
var
|
|
4738
|
+
var ue, Ye = -1, P = function(n) {
|
|
4627
4739
|
addEventListener("pageshow", (function(e) {
|
|
4628
|
-
e.persisted && (
|
|
4740
|
+
e.persisted && (Ye = e.timeStamp, n(e));
|
|
4629
4741
|
}), !0);
|
|
4630
|
-
},
|
|
4742
|
+
}, Ee = function() {
|
|
4631
4743
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4632
4744
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4633
|
-
},
|
|
4634
|
-
var n =
|
|
4745
|
+
}, q = function() {
|
|
4746
|
+
var n = Ee();
|
|
4635
4747
|
return n && n.activationStart || 0;
|
|
4636
|
-
},
|
|
4637
|
-
var t =
|
|
4638
|
-
return
|
|
4639
|
-
},
|
|
4748
|
+
}, b = function(n, e) {
|
|
4749
|
+
var t = Ee(), r = "navigate";
|
|
4750
|
+
return Ye >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: n, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: r };
|
|
4751
|
+
}, $ = function(n, e, t) {
|
|
4640
4752
|
try {
|
|
4641
4753
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
4642
4754
|
var r = new PerformanceObserver((function(s) {
|
|
@@ -4655,205 +4767,205 @@ var ce, je = -1, O = function(n) {
|
|
|
4655
4767
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4656
4768
|
})(e.value, t), n(e));
|
|
4657
4769
|
};
|
|
4658
|
-
},
|
|
4770
|
+
}, Se = function(n) {
|
|
4659
4771
|
requestAnimationFrame((function() {
|
|
4660
4772
|
return requestAnimationFrame((function() {
|
|
4661
4773
|
return n();
|
|
4662
4774
|
}));
|
|
4663
4775
|
}));
|
|
4664
|
-
},
|
|
4776
|
+
}, J = function(n) {
|
|
4665
4777
|
document.addEventListener("visibilitychange", (function() {
|
|
4666
4778
|
document.visibilityState === "hidden" && n();
|
|
4667
4779
|
}));
|
|
4668
|
-
},
|
|
4780
|
+
}, pe = function(n) {
|
|
4669
4781
|
var e = !1;
|
|
4670
4782
|
return function() {
|
|
4671
4783
|
e || (n(), e = !0);
|
|
4672
4784
|
};
|
|
4673
|
-
},
|
|
4785
|
+
}, O = -1, ke = function() {
|
|
4674
4786
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4675
|
-
},
|
|
4676
|
-
document.visibilityState === "hidden" &&
|
|
4787
|
+
}, Y = function(n) {
|
|
4788
|
+
document.visibilityState === "hidden" && O > -1 && (O = n.type === "visibilitychange" ? n.timeStamp : 0, _r());
|
|
4677
4789
|
}, Ue = function() {
|
|
4678
|
-
addEventListener("visibilitychange",
|
|
4679
|
-
},
|
|
4680
|
-
removeEventListener("visibilitychange",
|
|
4681
|
-
},
|
|
4682
|
-
return
|
|
4790
|
+
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4791
|
+
}, _r = function() {
|
|
4792
|
+
removeEventListener("visibilitychange", Y, !0), removeEventListener("prerenderingchange", Y, !0);
|
|
4793
|
+
}, qe = function() {
|
|
4794
|
+
return O < 0 && (O = ke(), Ue(), P((function() {
|
|
4683
4795
|
setTimeout((function() {
|
|
4684
|
-
|
|
4796
|
+
O = ke(), Ue();
|
|
4685
4797
|
}), 0);
|
|
4686
4798
|
}))), { get firstHiddenTime() {
|
|
4687
|
-
return
|
|
4799
|
+
return O;
|
|
4688
4800
|
} };
|
|
4689
|
-
},
|
|
4801
|
+
}, Z = function(n) {
|
|
4690
4802
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4691
4803
|
return n();
|
|
4692
4804
|
}), !0) : n();
|
|
4693
|
-
},
|
|
4694
|
-
e = e || {},
|
|
4695
|
-
var t, r =
|
|
4805
|
+
}, de = [1800, 3e3], Je = function(n, e) {
|
|
4806
|
+
e = e || {}, Z((function() {
|
|
4807
|
+
var t, r = qe(), s = b("FCP"), i = $("paint", (function(o) {
|
|
4696
4808
|
o.forEach((function(l) {
|
|
4697
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime -
|
|
4809
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime - q(), 0), s.entries.push(l), t(!0)));
|
|
4698
4810
|
}));
|
|
4699
4811
|
}));
|
|
4700
|
-
i && (t = A(n, s,
|
|
4701
|
-
s =
|
|
4812
|
+
i && (t = A(n, s, de, e.reportAllChanges), P((function(o) {
|
|
4813
|
+
s = b("FCP"), t = A(n, s, de, e.reportAllChanges), Se((function() {
|
|
4702
4814
|
s.value = performance.now() - o.timeStamp, t(!0);
|
|
4703
4815
|
}));
|
|
4704
4816
|
})));
|
|
4705
4817
|
}));
|
|
4706
|
-
},
|
|
4707
|
-
e = e || {},
|
|
4708
|
-
var t, r =
|
|
4709
|
-
c.forEach((function(
|
|
4710
|
-
if (!
|
|
4711
|
-
var
|
|
4712
|
-
s &&
|
|
4818
|
+
}, he = [0.1, 0.25], vr = function(n, e) {
|
|
4819
|
+
e = e || {}, Je(pe((function() {
|
|
4820
|
+
var t, r = b("CLS", 0), s = 0, i = [], o = function(c) {
|
|
4821
|
+
c.forEach((function(u) {
|
|
4822
|
+
if (!u.hadRecentInput) {
|
|
4823
|
+
var S = i[0], g = i[i.length - 1];
|
|
4824
|
+
s && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (s += u.value, i.push(u)) : (s = u.value, i = [u]);
|
|
4713
4825
|
}
|
|
4714
4826
|
})), s > r.value && (r.value = s, r.entries = i, t());
|
|
4715
|
-
}, l =
|
|
4716
|
-
l && (t = A(n, r,
|
|
4827
|
+
}, l = $("layout-shift", o);
|
|
4828
|
+
l && (t = A(n, r, he, e.reportAllChanges), J((function() {
|
|
4717
4829
|
o(l.takeRecords()), t(!0);
|
|
4718
|
-
})),
|
|
4719
|
-
s = 0, r =
|
|
4830
|
+
})), P((function() {
|
|
4831
|
+
s = 0, r = b("CLS", 0), t = A(n, r, he, e.reportAllChanges), Se((function() {
|
|
4720
4832
|
return t();
|
|
4721
4833
|
}));
|
|
4722
4834
|
})), setTimeout(t, 0));
|
|
4723
4835
|
})));
|
|
4724
|
-
},
|
|
4836
|
+
}, Ze = 0, re = 1 / 0, G = 0, Ir = function(n) {
|
|
4725
4837
|
n.forEach((function(e) {
|
|
4726
|
-
e.interactionId && (
|
|
4838
|
+
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId), Ze = G ? (G - re) / 7 + 1 : 0);
|
|
4727
4839
|
}));
|
|
4728
|
-
},
|
|
4729
|
-
return
|
|
4730
|
-
},
|
|
4731
|
-
"interactionCount" in performance ||
|
|
4732
|
-
},
|
|
4733
|
-
var n = Math.min(
|
|
4734
|
-
return
|
|
4735
|
-
},
|
|
4736
|
-
if (
|
|
4840
|
+
}, et = function() {
|
|
4841
|
+
return ue ? Ze : performance.interactionCount || 0;
|
|
4842
|
+
}, wr = function() {
|
|
4843
|
+
"interactionCount" in performance || ue || (ue = $("event", Ir, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4844
|
+
}, y = [], z = /* @__PURE__ */ new Map(), tt = 0, yr = function() {
|
|
4845
|
+
var n = Math.min(y.length - 1, Math.floor((et() - tt) / 50));
|
|
4846
|
+
return y[n];
|
|
4847
|
+
}, br = [], Ar = function(n) {
|
|
4848
|
+
if (br.forEach((function(s) {
|
|
4737
4849
|
return s(n);
|
|
4738
4850
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4739
|
-
var e =
|
|
4740
|
-
if (t ||
|
|
4851
|
+
var e = y[y.length - 1], t = z.get(n.interactionId);
|
|
4852
|
+
if (t || y.length < 10 || n.duration > e.latency) {
|
|
4741
4853
|
if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
|
|
4742
4854
|
else {
|
|
4743
4855
|
var r = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4744
|
-
z.set(r.id, r),
|
|
4856
|
+
z.set(r.id, r), y.push(r);
|
|
4745
4857
|
}
|
|
4746
|
-
|
|
4858
|
+
y.sort((function(s, i) {
|
|
4747
4859
|
return i.latency - s.latency;
|
|
4748
|
-
})),
|
|
4860
|
+
})), y.length > 10 && y.splice(10).forEach((function(s) {
|
|
4749
4861
|
return z.delete(s.id);
|
|
4750
4862
|
}));
|
|
4751
4863
|
}
|
|
4752
4864
|
}
|
|
4753
|
-
},
|
|
4865
|
+
}, rt = function(n) {
|
|
4754
4866
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4755
|
-
return n =
|
|
4756
|
-
},
|
|
4757
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
4867
|
+
return n = pe(n), document.visibilityState === "hidden" ? n() : (t = e(n), J(n)), t;
|
|
4868
|
+
}, fe = [200, 500], Lr = function(n, e) {
|
|
4869
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4758
4870
|
var t;
|
|
4759
|
-
|
|
4760
|
-
var r, s =
|
|
4761
|
-
|
|
4762
|
-
l.forEach(
|
|
4763
|
-
var c =
|
|
4871
|
+
wr();
|
|
4872
|
+
var r, s = b("INP"), i = function(l) {
|
|
4873
|
+
rt((function() {
|
|
4874
|
+
l.forEach(Ar);
|
|
4875
|
+
var c = yr();
|
|
4764
4876
|
c && c.latency !== s.value && (s.value = c.latency, s.entries = c.entries, r());
|
|
4765
4877
|
}));
|
|
4766
|
-
}, o =
|
|
4767
|
-
r = A(n, s,
|
|
4878
|
+
}, o = $("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4879
|
+
r = A(n, s, fe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4768
4880
|
i(o.takeRecords()), r(!0);
|
|
4769
|
-
})),
|
|
4770
|
-
|
|
4881
|
+
})), P((function() {
|
|
4882
|
+
tt = et(), y.length = 0, z.clear(), s = b("INP"), r = A(n, s, fe, e.reportAllChanges);
|
|
4771
4883
|
})));
|
|
4772
4884
|
})));
|
|
4773
|
-
},
|
|
4774
|
-
e = e || {},
|
|
4775
|
-
var t, r =
|
|
4776
|
-
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(
|
|
4777
|
-
|
|
4885
|
+
}, me = [2500, 4e3], ne = {}, Mr = function(n, e) {
|
|
4886
|
+
e = e || {}, Z((function() {
|
|
4887
|
+
var t, r = qe(), s = b("LCP"), i = function(c) {
|
|
4888
|
+
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4889
|
+
u.startTime < r.firstHiddenTime && (s.value = Math.max(u.startTime - q(), 0), s.entries = [u], t());
|
|
4778
4890
|
}));
|
|
4779
|
-
}, o =
|
|
4891
|
+
}, o = $("largest-contentful-paint", i);
|
|
4780
4892
|
if (o) {
|
|
4781
|
-
t = A(n, s,
|
|
4782
|
-
var l =
|
|
4783
|
-
|
|
4893
|
+
t = A(n, s, me, e.reportAllChanges);
|
|
4894
|
+
var l = pe((function() {
|
|
4895
|
+
ne[s.id] || (i(o.takeRecords()), o.disconnect(), ne[s.id] = !0, t(!0));
|
|
4784
4896
|
}));
|
|
4785
4897
|
["keydown", "click"].forEach((function(c) {
|
|
4786
4898
|
addEventListener(c, (function() {
|
|
4787
|
-
return
|
|
4899
|
+
return rt(l);
|
|
4788
4900
|
}), { once: !0, capture: !0 });
|
|
4789
|
-
})),
|
|
4790
|
-
s =
|
|
4791
|
-
s.value = performance.now() - c.timeStamp,
|
|
4901
|
+
})), J(l), P((function(c) {
|
|
4902
|
+
s = b("LCP"), t = A(n, s, me, e.reportAllChanges), Se((function() {
|
|
4903
|
+
s.value = performance.now() - c.timeStamp, ne[s.id] = !0, t(!0);
|
|
4792
4904
|
}));
|
|
4793
4905
|
}));
|
|
4794
4906
|
}
|
|
4795
4907
|
}));
|
|
4796
|
-
},
|
|
4797
|
-
document.prerendering ?
|
|
4908
|
+
}, ge = [800, 1800], Cr = function n(e) {
|
|
4909
|
+
document.prerendering ? Z((function() {
|
|
4798
4910
|
return n(e);
|
|
4799
4911
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4800
4912
|
return n(e);
|
|
4801
4913
|
}), !0) : setTimeout(e, 0);
|
|
4802
|
-
},
|
|
4914
|
+
}, Rr = function(n, e) {
|
|
4803
4915
|
e = e || {};
|
|
4804
|
-
var t =
|
|
4805
|
-
|
|
4806
|
-
var s =
|
|
4807
|
-
s && (t.value = Math.max(s.responseStart -
|
|
4808
|
-
t =
|
|
4916
|
+
var t = b("TTFB"), r = A(n, t, ge, e.reportAllChanges);
|
|
4917
|
+
Cr((function() {
|
|
4918
|
+
var s = Ee();
|
|
4919
|
+
s && (t.value = Math.max(s.responseStart - q(), 0), t.entries = [s], r(!0), P((function() {
|
|
4920
|
+
t = b("TTFB", 0), (r = A(n, t, ge, e.reportAllChanges))(!0);
|
|
4809
4921
|
})));
|
|
4810
4922
|
}));
|
|
4811
4923
|
};
|
|
4812
|
-
const
|
|
4924
|
+
const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4813
4925
|
__proto__: null,
|
|
4814
|
-
CLSThresholds:
|
|
4815
|
-
FCPThresholds:
|
|
4816
|
-
INPThresholds:
|
|
4817
|
-
LCPThresholds:
|
|
4818
|
-
TTFBThresholds:
|
|
4819
|
-
onCLS:
|
|
4820
|
-
onFCP:
|
|
4821
|
-
onINP:
|
|
4822
|
-
onLCP:
|
|
4823
|
-
onTTFB:
|
|
4926
|
+
CLSThresholds: he,
|
|
4927
|
+
FCPThresholds: de,
|
|
4928
|
+
INPThresholds: fe,
|
|
4929
|
+
LCPThresholds: me,
|
|
4930
|
+
TTFBThresholds: ge,
|
|
4931
|
+
onCLS: vr,
|
|
4932
|
+
onFCP: Je,
|
|
4933
|
+
onINP: Lr,
|
|
4934
|
+
onLCP: Mr,
|
|
4935
|
+
onTTFB: Rr
|
|
4824
4936
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4825
4937
|
export {
|
|
4826
4938
|
h as AppConfigValidationError,
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4939
|
+
Or as DEFAULT_SESSION_TIMEOUT,
|
|
4940
|
+
ae as DEFAULT_WEB_VITALS_MODE,
|
|
4941
|
+
L as DeviceType,
|
|
4942
|
+
se as EmitterEvent,
|
|
4943
|
+
U as ErrorType,
|
|
4944
|
+
d as EventType,
|
|
4945
|
+
Gr as InitializationTimeoutError,
|
|
4946
|
+
V as IntegrationValidationError,
|
|
4947
|
+
Fr as MAX_ARRAY_LENGTH,
|
|
4948
|
+
kr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4949
|
+
Vr as MAX_CUSTOM_EVENT_KEYS,
|
|
4950
|
+
Pr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4951
|
+
Dr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4952
|
+
xr as MAX_METADATA_NESTING_DEPTH,
|
|
4953
|
+
Ur as MAX_NESTED_OBJECT_KEYS,
|
|
4954
|
+
Hr as MAX_STRING_LENGTH,
|
|
4955
|
+
$r as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4844
4956
|
j as Mode,
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4957
|
+
Be as PII_PATTERNS,
|
|
4958
|
+
N as PermanentError,
|
|
4959
|
+
Ae as SamplingRateValidationError,
|
|
4848
4960
|
X as ScrollDirection,
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4961
|
+
dt as SessionTimeoutValidationError,
|
|
4962
|
+
k as SpecialApiUrl,
|
|
4963
|
+
H as TraceLogValidationError,
|
|
4964
|
+
Xr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4853
4965
|
Re as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4854
|
-
|
|
4966
|
+
Lt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4855
4967
|
Ne as getWebVitalsThresholds,
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4968
|
+
Br as isPrimaryScrollEvent,
|
|
4969
|
+
Wr as isSecondaryScrollEvent,
|
|
4970
|
+
Qr as tracelog
|
|
4859
4971
|
};
|