@tracelog/lib 2.0.3 → 2.1.0-rc.74.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +694 -546
- 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 +347 -131
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +77 -9
- package/dist/public-api.d.ts +77 -9
- package/dist/public-api.js +347 -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, Fr = 500, $r = 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 || {}), z = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(z || {});
|
|
89
|
+
const Br = (n) => n.type === d.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !0, Wr = (n) => n.type === d.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !1;
|
|
90
|
+
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;", Fe = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ht = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ft = (n, e) => {
|
|
121
121
|
if (e) {
|
|
122
122
|
if (e instanceof Error) {
|
|
123
123
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -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, $e;
|
|
171
|
+
const pt = () => {
|
|
172
|
+
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"), $e = 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 = () => {
|
|
167
197
|
try {
|
|
168
198
|
const n = navigator;
|
|
169
|
-
if (n.userAgentData && typeof n.userAgentData.mobile == "boolean")
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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 = $e?.matches ?? !1, s = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
205
|
+
return e <= 767 || o && s ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && s ? L.Tablet : L.Desktop;
|
|
174
206
|
} catch (n) {
|
|
175
|
-
return a("
|
|
207
|
+
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), L.Desktop;
|
|
176
208
|
}
|
|
177
|
-
},
|
|
209
|
+
}, It = () => {
|
|
210
|
+
try {
|
|
211
|
+
const n = navigator;
|
|
212
|
+
return {
|
|
213
|
+
type: vt(),
|
|
214
|
+
os: Tt(n),
|
|
215
|
+
browser: _t(n)
|
|
216
|
+
};
|
|
217
|
+
} catch (n) {
|
|
218
|
+
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
219
|
+
type: L.Desktop,
|
|
220
|
+
os: K,
|
|
221
|
+
browser: K
|
|
222
|
+
};
|
|
223
|
+
}
|
|
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
|
-
|
|
304
|
+
})) : e === ve && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
|
+
visibility: "qa",
|
|
251
306
|
style: Fe
|
|
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";
|
|
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 : Fe
|
|
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
|
+
}, Ft = (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 && $t(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
|
+
}, $t = (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
|
+
Ft(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
|
+
}, je = (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 = je(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 jt {
|
|
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 ze(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 zt(n, e, t) {
|
|
871
|
+
return n.map((r) => ze(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 = zt(
|
|
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 $ = 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 ($) {
|
|
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") ===
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1974
|
+
if (!this.isDuplicateEvent(D)) {
|
|
1975
|
+
if (this.get("mode") === z.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,20 +2338,21 @@ 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
|
|
2279
|
-
if (
|
|
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 $ = ze(o, E, "EventManager");
|
|
2347
|
+
if ($ === null)
|
|
2280
2348
|
return null;
|
|
2281
|
-
o =
|
|
2349
|
+
o = $;
|
|
2282
2350
|
}
|
|
2283
2351
|
return o;
|
|
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,88 @@ 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;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* Checks if two hostnames belong to the same domain (including subdomains).
|
|
2628
|
+
* Extracts root domain and compares to handle cross-subdomain navigation.
|
|
2629
|
+
*
|
|
2630
|
+
* @example
|
|
2631
|
+
* isSameDomain('www.example.com', 'example.com') // true
|
|
2632
|
+
* isSameDomain('app.example.com', 'www.example.com') // true
|
|
2633
|
+
* isSameDomain('example.co.uk', 'app.example.co.uk') // true
|
|
2634
|
+
*
|
|
2635
|
+
* @param hostname1 - First hostname (e.g., 'www.example.com')
|
|
2636
|
+
* @param hostname2 - Second hostname (e.g., 'app.example.com')
|
|
2637
|
+
* @returns true if same root domain
|
|
2638
|
+
*
|
|
2639
|
+
* @internal
|
|
2640
|
+
*/
|
|
2641
|
+
isSameDomain(e, t) {
|
|
2642
|
+
return e === t ? !0 : this.getRootDomain(e) === this.getRootDomain(t);
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Extracts the root (registrable) domain from a hostname.
|
|
2646
|
+
* Handles both standard TLDs (.com, .org) and compound TLDs (.co.uk, .com.br).
|
|
2647
|
+
*
|
|
2648
|
+
* @example
|
|
2649
|
+
* getRootDomain('www.example.com') // 'example.com'
|
|
2650
|
+
* getRootDomain('app.blog.example.com') // 'example.com'
|
|
2651
|
+
* getRootDomain('shop.example.co.uk') // 'example.co.uk'
|
|
2652
|
+
*
|
|
2653
|
+
* @internal
|
|
2654
|
+
*/
|
|
2655
|
+
getRootDomain(e) {
|
|
2656
|
+
const t = e.toLowerCase().split(".");
|
|
2657
|
+
if (t.length <= 2)
|
|
2658
|
+
return e.toLowerCase();
|
|
2659
|
+
const r = [
|
|
2660
|
+
"co.uk",
|
|
2661
|
+
"org.uk",
|
|
2662
|
+
"com.au",
|
|
2663
|
+
"net.au",
|
|
2664
|
+
"com.br",
|
|
2665
|
+
"co.nz",
|
|
2666
|
+
"co.jp",
|
|
2667
|
+
"com.mx",
|
|
2668
|
+
"co.in",
|
|
2669
|
+
"com.cn",
|
|
2670
|
+
"co.za"
|
|
2671
|
+
], s = t.slice(-2).join(".");
|
|
2672
|
+
return r.includes(s) ? t.slice(-3).join(".") : t.slice(-2).join(".");
|
|
2673
|
+
}
|
|
2524
2674
|
/**
|
|
2525
2675
|
* Persists current session event counts to localStorage (debounced).
|
|
2526
2676
|
*
|
|
@@ -2550,7 +2700,7 @@ class xt extends p {
|
|
|
2550
2700
|
* @internal
|
|
2551
2701
|
*/
|
|
2552
2702
|
saveSessionCounts(e) {
|
|
2553
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2703
|
+
const t = this.get("userId") || "anonymous", r = Ie(t, e);
|
|
2554
2704
|
try {
|
|
2555
2705
|
const s = {
|
|
2556
2706
|
...this.sessionEventCounts,
|
|
@@ -2566,7 +2716,7 @@ class xt extends p {
|
|
|
2566
2716
|
}
|
|
2567
2717
|
}
|
|
2568
2718
|
}
|
|
2569
|
-
class
|
|
2719
|
+
class qt {
|
|
2570
2720
|
/**
|
|
2571
2721
|
* Gets or creates a unique user ID.
|
|
2572
2722
|
*
|
|
@@ -2584,15 +2734,15 @@ class Ht {
|
|
|
2584
2734
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2585
2735
|
*/
|
|
2586
2736
|
static getId(e) {
|
|
2587
|
-
const t = e.getItem(
|
|
2737
|
+
const t = e.getItem(Te);
|
|
2588
2738
|
if (t)
|
|
2589
2739
|
return t;
|
|
2590
|
-
const r =
|
|
2591
|
-
return e.setItem(
|
|
2740
|
+
const r = Vt();
|
|
2741
|
+
return e.setItem(Te, r), r;
|
|
2592
2742
|
}
|
|
2593
2743
|
}
|
|
2594
|
-
const
|
|
2595
|
-
class
|
|
2744
|
+
const Jt = /^\d{13}-[a-z0-9]{9}$/;
|
|
2745
|
+
class Zt extends _ {
|
|
2596
2746
|
storageManager;
|
|
2597
2747
|
eventManager;
|
|
2598
2748
|
projectId;
|
|
@@ -2613,11 +2763,11 @@ class $t extends p {
|
|
|
2613
2763
|
}
|
|
2614
2764
|
initCrossTabSync() {
|
|
2615
2765
|
if (typeof BroadcastChannel > "u") {
|
|
2616
|
-
a("
|
|
2766
|
+
a("debug", "BroadcastChannel not supported");
|
|
2617
2767
|
return;
|
|
2618
2768
|
}
|
|
2619
2769
|
const e = this.getProjectId();
|
|
2620
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2770
|
+
this.broadcastChannel = new BroadcastChannel(ut(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2621
2771
|
const { action: r, sessionId: s, timestamp: i, projectId: o } = t.data ?? {};
|
|
2622
2772
|
o === e && (r === "session_start" && s && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", s), this.persistSession(s, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2623
2773
|
};
|
|
@@ -2637,7 +2787,7 @@ class $t extends p {
|
|
|
2637
2787
|
const e = this.loadStoredSession();
|
|
2638
2788
|
if (!e)
|
|
2639
2789
|
return null;
|
|
2640
|
-
if (!
|
|
2790
|
+
if (!Jt.test(e.id))
|
|
2641
2791
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2642
2792
|
data: { sessionId: e.id }
|
|
2643
2793
|
}), this.clearStoredSession(), null;
|
|
@@ -2670,7 +2820,7 @@ class $t extends p {
|
|
|
2670
2820
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2671
2821
|
}
|
|
2672
2822
|
getSessionStorageKey() {
|
|
2673
|
-
return
|
|
2823
|
+
return ct(this.getProjectId());
|
|
2674
2824
|
}
|
|
2675
2825
|
getProjectId() {
|
|
2676
2826
|
return this.projectId;
|
|
@@ -2728,7 +2878,7 @@ class $t extends p {
|
|
|
2728
2878
|
*/
|
|
2729
2879
|
startTracking() {
|
|
2730
2880
|
if (this.isTracking) {
|
|
2731
|
-
a("
|
|
2881
|
+
a("debug", "Session tracking already active");
|
|
2732
2882
|
return;
|
|
2733
2883
|
}
|
|
2734
2884
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
@@ -2743,7 +2893,7 @@ class $t extends p {
|
|
|
2743
2893
|
this.set("sessionId", t), this.persistSession(t), this.initCrossTabSync(), this.shareSession(t), a("debug", "Emitting SESSION_START event", {
|
|
2744
2894
|
data: { sessionId: t }
|
|
2745
2895
|
}), this.eventManager.track({
|
|
2746
|
-
type:
|
|
2896
|
+
type: d.SESSION_START
|
|
2747
2897
|
}), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2748
2898
|
} catch (r) {
|
|
2749
2899
|
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), r;
|
|
@@ -2853,7 +3003,7 @@ class $t extends p {
|
|
|
2853
3003
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
2854
3004
|
}
|
|
2855
3005
|
}
|
|
2856
|
-
class
|
|
3006
|
+
class er extends _ {
|
|
2857
3007
|
eventManager;
|
|
2858
3008
|
storageManager;
|
|
2859
3009
|
sessionManager = null;
|
|
@@ -2883,12 +3033,12 @@ class Bt extends p {
|
|
|
2883
3033
|
if (this.isActive())
|
|
2884
3034
|
return;
|
|
2885
3035
|
if (this.destroyed) {
|
|
2886
|
-
a("
|
|
3036
|
+
a("debug", "Cannot start tracking on destroyed handler");
|
|
2887
3037
|
return;
|
|
2888
3038
|
}
|
|
2889
3039
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2890
3040
|
try {
|
|
2891
|
-
this.sessionManager = new
|
|
3041
|
+
this.sessionManager = new Zt(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2892
3042
|
} catch (r) {
|
|
2893
3043
|
if (this.sessionManager) {
|
|
2894
3044
|
try {
|
|
@@ -2941,7 +3091,7 @@ class Bt extends p {
|
|
|
2941
3091
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2942
3092
|
}
|
|
2943
3093
|
}
|
|
2944
|
-
class
|
|
3094
|
+
class tr extends _ {
|
|
2945
3095
|
eventManager;
|
|
2946
3096
|
onTrack;
|
|
2947
3097
|
originalPushState;
|
|
@@ -2981,7 +3131,7 @@ class Wt extends p {
|
|
|
2981
3131
|
};
|
|
2982
3132
|
}
|
|
2983
3133
|
trackCurrentPage = () => {
|
|
2984
|
-
const e = window.location.href, t =
|
|
3134
|
+
const e = window.location.href, t = le(e, this.get("config").sensitiveQueryParams);
|
|
2985
3135
|
if (this.get("pageUrl") === t)
|
|
2986
3136
|
return;
|
|
2987
3137
|
const r = Date.now(), s = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2992,16 +3142,16 @@ class Wt extends p {
|
|
|
2992
3142
|
this.set("pageUrl", t);
|
|
2993
3143
|
const o = this.extractPageViewData();
|
|
2994
3144
|
this.eventManager.track({
|
|
2995
|
-
type:
|
|
3145
|
+
type: d.PAGE_VIEW,
|
|
2996
3146
|
page_url: this.get("pageUrl"),
|
|
2997
3147
|
from_page_url: i,
|
|
2998
3148
|
...o && { page_view: o }
|
|
2999
3149
|
});
|
|
3000
3150
|
};
|
|
3001
3151
|
trackInitialPageView() {
|
|
3002
|
-
const e =
|
|
3152
|
+
const e = le(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3003
3153
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3004
|
-
type:
|
|
3154
|
+
type: d.PAGE_VIEW,
|
|
3005
3155
|
page_url: e,
|
|
3006
3156
|
...t && { page_view: t }
|
|
3007
3157
|
}), this.onTrack();
|
|
@@ -3017,7 +3167,7 @@ class Wt extends p {
|
|
|
3017
3167
|
};
|
|
3018
3168
|
}
|
|
3019
3169
|
}
|
|
3020
|
-
class
|
|
3170
|
+
class rr extends _ {
|
|
3021
3171
|
eventManager;
|
|
3022
3172
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3023
3173
|
clickHandler;
|
|
@@ -3042,7 +3192,7 @@ class Gt extends p {
|
|
|
3042
3192
|
this.clickHandler || (this.clickHandler = (e) => {
|
|
3043
3193
|
const t = e, r = t.target, s = typeof HTMLElement < "u" && r instanceof HTMLElement ? r : typeof HTMLElement < "u" && r instanceof Node && r.parentElement instanceof HTMLElement ? r.parentElement : null;
|
|
3044
3194
|
if (!s) {
|
|
3045
|
-
a("
|
|
3195
|
+
a("debug", "Click target not found or not an element");
|
|
3046
3196
|
return;
|
|
3047
3197
|
}
|
|
3048
3198
|
if (this.shouldIgnoreElement(s))
|
|
@@ -3052,22 +3202,22 @@ class Gt extends p {
|
|
|
3052
3202
|
return;
|
|
3053
3203
|
const o = this.findTrackingElement(s), l = this.getRelevantClickElement(s), c = this.calculateClickCoordinates(t, s);
|
|
3054
3204
|
if (o) {
|
|
3055
|
-
const
|
|
3056
|
-
if (
|
|
3057
|
-
const
|
|
3205
|
+
const S = this.extractTrackingData(o);
|
|
3206
|
+
if (S) {
|
|
3207
|
+
const g = this.createCustomEventData(S);
|
|
3058
3208
|
this.eventManager.track({
|
|
3059
|
-
type:
|
|
3209
|
+
type: d.CUSTOM,
|
|
3060
3210
|
custom_event: {
|
|
3061
|
-
name:
|
|
3062
|
-
...
|
|
3211
|
+
name: g.name,
|
|
3212
|
+
...g.value && { metadata: { value: g.value } }
|
|
3063
3213
|
}
|
|
3064
3214
|
});
|
|
3065
3215
|
}
|
|
3066
3216
|
}
|
|
3067
|
-
const
|
|
3217
|
+
const u = this.generateClickData(s, l, c);
|
|
3068
3218
|
this.eventManager.track({
|
|
3069
|
-
type:
|
|
3070
|
-
click_data:
|
|
3219
|
+
type: d.CLICK,
|
|
3220
|
+
click_data: u
|
|
3071
3221
|
});
|
|
3072
3222
|
}, window.addEventListener("click", this.clickHandler, !0));
|
|
3073
3223
|
}
|
|
@@ -3081,7 +3231,7 @@ class Gt extends p {
|
|
|
3081
3231
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
3082
3232
|
}
|
|
3083
3233
|
shouldIgnoreElement(e) {
|
|
3084
|
-
return e.hasAttribute(`${
|
|
3234
|
+
return e.hasAttribute(`${w}-ignore`) ? !0 : e.closest(`[${w}-ignore]`) !== null;
|
|
3085
3235
|
}
|
|
3086
3236
|
/**
|
|
3087
3237
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -3132,8 +3282,8 @@ class Gt extends p {
|
|
|
3132
3282
|
const t = e.getAttribute("data-testid");
|
|
3133
3283
|
if (t)
|
|
3134
3284
|
return `[data-testid="${t}"]`;
|
|
3135
|
-
const r = e.getAttribute(`${
|
|
3136
|
-
return r ? `[${
|
|
3285
|
+
const r = e.getAttribute(`${w}-name`);
|
|
3286
|
+
return r ? `[${w}-name="${r}"]` : this.getElementPath(e);
|
|
3137
3287
|
}
|
|
3138
3288
|
/**
|
|
3139
3289
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -3152,10 +3302,10 @@ class Gt extends p {
|
|
|
3152
3302
|
return t.join(">") || "unknown";
|
|
3153
3303
|
}
|
|
3154
3304
|
findTrackingElement(e) {
|
|
3155
|
-
return e.hasAttribute(`${
|
|
3305
|
+
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3156
3306
|
}
|
|
3157
3307
|
getRelevantClickElement(e) {
|
|
3158
|
-
for (const t of
|
|
3308
|
+
for (const t of st)
|
|
3159
3309
|
try {
|
|
3160
3310
|
if (e.matches(t))
|
|
3161
3311
|
return e;
|
|
@@ -3163,7 +3313,7 @@ class Gt extends p {
|
|
|
3163
3313
|
if (r)
|
|
3164
3314
|
return r;
|
|
3165
3315
|
} catch (r) {
|
|
3166
|
-
a("
|
|
3316
|
+
a("debug", "Invalid selector in element search", { error: r, data: { selector: t } });
|
|
3167
3317
|
continue;
|
|
3168
3318
|
}
|
|
3169
3319
|
return e;
|
|
@@ -3187,7 +3337,7 @@ class Gt extends p {
|
|
|
3187
3337
|
return { x: s, y: i, relativeX: o, relativeY: l };
|
|
3188
3338
|
}
|
|
3189
3339
|
extractTrackingData(e) {
|
|
3190
|
-
const t = e.getAttribute(`${
|
|
3340
|
+
const t = e.getAttribute(`${w}-name`), r = e.getAttribute(`${w}-value`);
|
|
3191
3341
|
if (t)
|
|
3192
3342
|
return {
|
|
3193
3343
|
element: e,
|
|
@@ -3196,7 +3346,7 @@ class Gt extends p {
|
|
|
3196
3346
|
};
|
|
3197
3347
|
}
|
|
3198
3348
|
generateClickData(e, t, r) {
|
|
3199
|
-
const { x: s, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t),
|
|
3349
|
+
const { x: s, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
3200
3350
|
return {
|
|
3201
3351
|
x: s,
|
|
3202
3352
|
y: i,
|
|
@@ -3206,12 +3356,12 @@ class Gt extends p {
|
|
|
3206
3356
|
...t.id && { id: t.id },
|
|
3207
3357
|
...t.className && { class: t.className },
|
|
3208
3358
|
...c && { text: c },
|
|
3209
|
-
...
|
|
3210
|
-
...
|
|
3211
|
-
...
|
|
3212
|
-
...
|
|
3213
|
-
...
|
|
3214
|
-
...Object.keys(
|
|
3359
|
+
...u.href && { href: u.href },
|
|
3360
|
+
...u.title && { title: u.title },
|
|
3361
|
+
...u.alt && { alt: u.alt },
|
|
3362
|
+
...u.role && { role: u.role },
|
|
3363
|
+
...u["aria-label"] && { ariaLabel: u["aria-label"] },
|
|
3364
|
+
...Object.keys(u).length > 0 && { dataAttributes: u }
|
|
3215
3365
|
};
|
|
3216
3366
|
}
|
|
3217
3367
|
/**
|
|
@@ -3235,7 +3385,7 @@ class Gt extends p {
|
|
|
3235
3385
|
*/
|
|
3236
3386
|
sanitizeText(e) {
|
|
3237
3387
|
let t = e;
|
|
3238
|
-
for (const r of
|
|
3388
|
+
for (const r of Be) {
|
|
3239
3389
|
const s = new RegExp(r.source, r.flags);
|
|
3240
3390
|
t = t.replace(s, "[REDACTED]");
|
|
3241
3391
|
}
|
|
@@ -3274,7 +3424,7 @@ class Gt extends p {
|
|
|
3274
3424
|
};
|
|
3275
3425
|
}
|
|
3276
3426
|
}
|
|
3277
|
-
class
|
|
3427
|
+
class nr extends _ {
|
|
3278
3428
|
eventManager;
|
|
3279
3429
|
containers = [];
|
|
3280
3430
|
limitWarningLogged = !1;
|
|
@@ -3375,7 +3525,7 @@ class Xt extends p {
|
|
|
3375
3525
|
return this.isWindowScrollable() ? e === window : this.containers.length === 0;
|
|
3376
3526
|
}
|
|
3377
3527
|
setupScrollContainer(e, t) {
|
|
3378
|
-
if (this.containers.some((
|
|
3528
|
+
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3379
3529
|
return;
|
|
3380
3530
|
const s = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3381
3531
|
s,
|
|
@@ -3395,10 +3545,10 @@ class Xt extends p {
|
|
|
3395
3545
|
listener: null
|
|
3396
3546
|
}, c = () => {
|
|
3397
3547
|
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,
|
|
3548
|
+
const u = this.calculateScrollData(l);
|
|
3549
|
+
if (u) {
|
|
3550
|
+
const S = Date.now();
|
|
3551
|
+
this.processScrollEvent(l, u, S);
|
|
3402
3552
|
}
|
|
3403
3553
|
l.debounceTimer = null;
|
|
3404
3554
|
}, 250));
|
|
@@ -3411,7 +3561,7 @@ class Xt extends p {
|
|
|
3411
3561
|
e.lastEventTime = r, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3412
3562
|
const s = this.get("scrollEventCount") ?? 0;
|
|
3413
3563
|
this.set("scrollEventCount", s + 1), this.eventManager.track({
|
|
3414
|
-
type:
|
|
3564
|
+
type: d.SCROLL,
|
|
3415
3565
|
scroll_data: {
|
|
3416
3566
|
...t,
|
|
3417
3567
|
container_selector: e.selector,
|
|
@@ -3432,7 +3582,7 @@ class Xt extends p {
|
|
|
3432
3582
|
return Math.abs(t - e.lastDepth) >= this.minDepthChange;
|
|
3433
3583
|
}
|
|
3434
3584
|
logLimitOnce() {
|
|
3435
|
-
this.limitWarningLogged || (this.limitWarningLogged = !0, a("
|
|
3585
|
+
this.limitWarningLogged || (this.limitWarningLogged = !0, a("debug", "Max scroll events per session reached", {
|
|
3436
3586
|
data: { limit: this.maxEventsPerSession }
|
|
3437
3587
|
}));
|
|
3438
3588
|
}
|
|
@@ -3458,14 +3608,14 @@ class Xt extends p {
|
|
|
3458
3608
|
const { element: t, lastScrollPos: r, lastEventTime: s } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - r);
|
|
3459
3609
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3460
3610
|
return null;
|
|
3461
|
-
const c = this.getViewportHeight(t),
|
|
3462
|
-
let
|
|
3463
|
-
s > 0 ?
|
|
3464
|
-
const
|
|
3465
|
-
return
|
|
3466
|
-
depth:
|
|
3467
|
-
direction:
|
|
3468
|
-
velocity:
|
|
3611
|
+
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), S = this.getScrollDirection(i, r), g = this.calculateScrollDepth(i, u, c);
|
|
3612
|
+
let E;
|
|
3613
|
+
s > 0 ? E = o - s : e.firstScrollEventTime !== null ? E = o - e.firstScrollEventTime : E = 250;
|
|
3614
|
+
const p = Math.round(l / E * 1e3);
|
|
3615
|
+
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3616
|
+
depth: g,
|
|
3617
|
+
direction: S,
|
|
3618
|
+
velocity: p,
|
|
3469
3619
|
max_depth_reached: e.maxDepthReached
|
|
3470
3620
|
};
|
|
3471
3621
|
}
|
|
@@ -3489,7 +3639,7 @@ class Xt extends p {
|
|
|
3489
3639
|
else {
|
|
3490
3640
|
const s = document.querySelector(e);
|
|
3491
3641
|
if (!(s instanceof HTMLElement)) {
|
|
3492
|
-
a("
|
|
3642
|
+
a("debug", `Selector "${e}" did not match an HTMLElement`);
|
|
3493
3643
|
return;
|
|
3494
3644
|
}
|
|
3495
3645
|
t = s;
|
|
@@ -3502,7 +3652,7 @@ class Xt extends p {
|
|
|
3502
3652
|
e.isPrimary = t;
|
|
3503
3653
|
}
|
|
3504
3654
|
}
|
|
3505
|
-
class
|
|
3655
|
+
class sr extends _ {
|
|
3506
3656
|
eventManager;
|
|
3507
3657
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3508
3658
|
observer = null;
|
|
@@ -3521,15 +3671,15 @@ class Qt extends p {
|
|
|
3521
3671
|
return;
|
|
3522
3672
|
const t = this.config.threshold ?? 0.5, r = this.config.minDwellTime ?? 1e3;
|
|
3523
3673
|
if (t < 0 || t > 1) {
|
|
3524
|
-
a("
|
|
3674
|
+
a("debug", "ViewportHandler: Invalid threshold, must be between 0 and 1");
|
|
3525
3675
|
return;
|
|
3526
3676
|
}
|
|
3527
3677
|
if (r < 0) {
|
|
3528
|
-
a("
|
|
3678
|
+
a("debug", "ViewportHandler: Invalid minDwellTime, must be non-negative");
|
|
3529
3679
|
return;
|
|
3530
3680
|
}
|
|
3531
3681
|
if (typeof IntersectionObserver > "u") {
|
|
3532
|
-
a("
|
|
3682
|
+
a("debug", "ViewportHandler: IntersectionObserver not supported in this browser");
|
|
3533
3683
|
return;
|
|
3534
3684
|
}
|
|
3535
3685
|
this.observer = new IntersectionObserver(this.handleIntersection, {
|
|
@@ -3557,7 +3707,7 @@ class Qt extends p {
|
|
|
3557
3707
|
const s = document.querySelectorAll(r.selector);
|
|
3558
3708
|
for (const i of Array.from(s)) {
|
|
3559
3709
|
if (t >= e) {
|
|
3560
|
-
a("
|
|
3710
|
+
a("debug", "ViewportHandler: Maximum tracked elements reached", {
|
|
3561
3711
|
data: {
|
|
3562
3712
|
limit: e,
|
|
3563
3713
|
selector: r.selector,
|
|
@@ -3566,7 +3716,7 @@ class Qt extends p {
|
|
|
3566
3716
|
});
|
|
3567
3717
|
return;
|
|
3568
3718
|
}
|
|
3569
|
-
i.hasAttribute(`${
|
|
3719
|
+
i.hasAttribute(`${w}-ignore`) || this.trackedElements.has(i) || (this.trackedElements.set(i, {
|
|
3570
3720
|
element: i,
|
|
3571
3721
|
selector: r.selector,
|
|
3572
3722
|
id: r.id,
|
|
@@ -3577,7 +3727,7 @@ class Qt extends p {
|
|
|
3577
3727
|
}), this.observer?.observe(i), t++);
|
|
3578
3728
|
}
|
|
3579
3729
|
} catch (s) {
|
|
3580
|
-
a("
|
|
3730
|
+
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error: s });
|
|
3581
3731
|
}
|
|
3582
3732
|
a("debug", "ViewportHandler: Elements tracked", {
|
|
3583
3733
|
data: { count: t, limit: e }
|
|
@@ -3603,7 +3753,7 @@ class Qt extends p {
|
|
|
3603
3753
|
fireViewportEvent(e, t) {
|
|
3604
3754
|
if (e.startTime === null) return;
|
|
3605
3755
|
const r = Math.round(performance.now() - e.startTime);
|
|
3606
|
-
if (e.element.hasAttribute(`${
|
|
3756
|
+
if (e.element.hasAttribute(`${w}-ignore`))
|
|
3607
3757
|
return;
|
|
3608
3758
|
const s = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3609
3759
|
if (e.lastFiredTime !== null && i - e.lastFiredTime < s) {
|
|
@@ -3623,7 +3773,7 @@ class Qt extends p {
|
|
|
3623
3773
|
...e.name !== void 0 && { name: e.name }
|
|
3624
3774
|
};
|
|
3625
3775
|
this.eventManager.track({
|
|
3626
|
-
type:
|
|
3776
|
+
type: d.VIEWPORT_VISIBLE,
|
|
3627
3777
|
viewport_data: o
|
|
3628
3778
|
}), e.startTime = null, e.timeoutId = null, e.lastFiredTime = i;
|
|
3629
3779
|
}
|
|
@@ -3633,7 +3783,7 @@ class Qt extends p {
|
|
|
3633
3783
|
setupMutationObserver() {
|
|
3634
3784
|
if (!(!this.config || typeof MutationObserver > "u")) {
|
|
3635
3785
|
if (!document.body) {
|
|
3636
|
-
a("
|
|
3786
|
+
a("debug", "ViewportHandler: document.body not available, skipping MutationObserver setup");
|
|
3637
3787
|
return;
|
|
3638
3788
|
}
|
|
3639
3789
|
this.mutationObserver = new MutationObserver((e) => {
|
|
@@ -3663,14 +3813,14 @@ class Qt extends p {
|
|
|
3663
3813
|
});
|
|
3664
3814
|
}
|
|
3665
3815
|
}
|
|
3666
|
-
class
|
|
3816
|
+
class ir {
|
|
3667
3817
|
storage;
|
|
3668
3818
|
sessionStorageRef;
|
|
3669
3819
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
3670
3820
|
fallbackSessionStorage = /* @__PURE__ */ new Map();
|
|
3671
3821
|
hasQuotaExceededError = !1;
|
|
3672
3822
|
constructor() {
|
|
3673
|
-
this.storage = this.initializeStorage("localStorage"), this.sessionStorageRef = this.initializeStorage("sessionStorage"), this.storage || a("
|
|
3823
|
+
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
3824
|
}
|
|
3675
3825
|
/**
|
|
3676
3826
|
* Retrieves an item from localStorage.
|
|
@@ -3946,7 +4096,7 @@ class zt {
|
|
|
3946
4096
|
this.fallbackSessionStorage.delete(e);
|
|
3947
4097
|
}
|
|
3948
4098
|
}
|
|
3949
|
-
class
|
|
4099
|
+
class or extends _ {
|
|
3950
4100
|
eventManager;
|
|
3951
4101
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3952
4102
|
navigationHistory = [];
|
|
@@ -3957,7 +4107,7 @@ class jt extends p {
|
|
|
3957
4107
|
navigationCounter = 0;
|
|
3958
4108
|
// Counter for handling simultaneous navigations edge case
|
|
3959
4109
|
constructor(e) {
|
|
3960
|
-
super(), this.eventManager = e, this.vitalThresholds = Ne(
|
|
4110
|
+
super(), this.eventManager = e, this.vitalThresholds = Ne(ae);
|
|
3961
4111
|
}
|
|
3962
4112
|
/**
|
|
3963
4113
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3974,7 +4124,7 @@ class jt extends p {
|
|
|
3974
4124
|
* @returns Promise that resolves when tracking is initialized
|
|
3975
4125
|
*/
|
|
3976
4126
|
async startTracking() {
|
|
3977
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4127
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ae;
|
|
3978
4128
|
this.vitalThresholds = Ne(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
3979
4129
|
}
|
|
3980
4130
|
/**
|
|
@@ -3991,7 +4141,7 @@ class jt extends p {
|
|
|
3991
4141
|
try {
|
|
3992
4142
|
e.disconnect();
|
|
3993
4143
|
} catch (r) {
|
|
3994
|
-
a("
|
|
4144
|
+
a("debug", "Failed to disconnect performance observer", { error: r, data: { observerIndex: t } });
|
|
3995
4145
|
}
|
|
3996
4146
|
}), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0;
|
|
3997
4147
|
}
|
|
@@ -4045,13 +4195,13 @@ class jt extends p {
|
|
|
4045
4195
|
}
|
|
4046
4196
|
async initWebVitals() {
|
|
4047
4197
|
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:
|
|
4198
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() => Nr), o = (l) => (c) => {
|
|
4199
|
+
const u = Number(c.value.toFixed(2));
|
|
4200
|
+
this.sendVital({ type: l, value: u });
|
|
4051
4201
|
};
|
|
4052
4202
|
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }), s(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
4053
4203
|
} catch (e) {
|
|
4054
|
-
a("
|
|
4204
|
+
a("debug", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
|
|
4055
4205
|
}
|
|
4056
4206
|
}
|
|
4057
4207
|
reportTTFB() {
|
|
@@ -4062,7 +4212,7 @@ class jt extends p {
|
|
|
4062
4212
|
const t = e.responseStart;
|
|
4063
4213
|
typeof t == "number" && Number.isFinite(t) && this.sendVital({ type: "TTFB", value: Number(t.toFixed(2)) });
|
|
4064
4214
|
} catch (e) {
|
|
4065
|
-
a("
|
|
4215
|
+
a("debug", "Failed to report TTFB", { error: e });
|
|
4066
4216
|
}
|
|
4067
4217
|
}
|
|
4068
4218
|
observeLongTasks() {
|
|
@@ -4072,7 +4222,7 @@ class jt extends p {
|
|
|
4072
4222
|
const t = e.getEntries();
|
|
4073
4223
|
for (const r of t) {
|
|
4074
4224
|
const s = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4075
|
-
i - this.lastLongTaskSentAt >=
|
|
4225
|
+
i - this.lastLongTaskSentAt >= Mt && (this.shouldSendVital("LONG_TASK", s) && this.trackWebVital("LONG_TASK", s), this.lastLongTaskSentAt = i);
|
|
4076
4226
|
}
|
|
4077
4227
|
},
|
|
4078
4228
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4088,7 +4238,7 @@ class jt extends p {
|
|
|
4088
4238
|
return;
|
|
4089
4239
|
if (r)
|
|
4090
4240
|
r.add(e.type);
|
|
4091
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4241
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Ct) {
|
|
4092
4242
|
const i = this.navigationHistory.shift();
|
|
4093
4243
|
i && this.reportedByNav.delete(i);
|
|
4094
4244
|
}
|
|
@@ -4097,11 +4247,11 @@ class jt extends p {
|
|
|
4097
4247
|
}
|
|
4098
4248
|
trackWebVital(e, t) {
|
|
4099
4249
|
if (!Number.isFinite(t)) {
|
|
4100
|
-
a("
|
|
4250
|
+
a("debug", "Invalid web vital value", { data: { type: e, value: t } });
|
|
4101
4251
|
return;
|
|
4102
4252
|
}
|
|
4103
4253
|
this.eventManager.track({
|
|
4104
|
-
type:
|
|
4254
|
+
type: d.WEB_VITALS,
|
|
4105
4255
|
web_vitals: {
|
|
4106
4256
|
type: e,
|
|
4107
4257
|
value: t
|
|
@@ -4137,7 +4287,7 @@ class jt extends p {
|
|
|
4137
4287
|
const t = e.startTime || performance.now(), r = ++this.navigationCounter, s = `${t.toFixed(2)}_${window.location.pathname}`;
|
|
4138
4288
|
return r > 1 ? `${s}_${r}` : s;
|
|
4139
4289
|
} catch (e) {
|
|
4140
|
-
return a("
|
|
4290
|
+
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
4141
4291
|
}
|
|
4142
4292
|
}
|
|
4143
4293
|
isObserverSupported(e) {
|
|
@@ -4153,7 +4303,7 @@ class jt extends p {
|
|
|
4153
4303
|
try {
|
|
4154
4304
|
t(o, l);
|
|
4155
4305
|
} catch (c) {
|
|
4156
|
-
a("
|
|
4306
|
+
a("debug", "Observer callback failed", {
|
|
4157
4307
|
error: c,
|
|
4158
4308
|
data: { type: e }
|
|
4159
4309
|
});
|
|
@@ -4166,7 +4316,7 @@ class jt extends p {
|
|
|
4166
4316
|
});
|
|
4167
4317
|
return i.observe(r ?? { type: e, buffered: !0 }), s || this.observers.push(i), !0;
|
|
4168
4318
|
} catch (i) {
|
|
4169
|
-
return a("
|
|
4319
|
+
return a("debug", "Failed to create performance observer", {
|
|
4170
4320
|
error: i,
|
|
4171
4321
|
data: { type: e }
|
|
4172
4322
|
}), !1;
|
|
@@ -4174,12 +4324,12 @@ class jt extends p {
|
|
|
4174
4324
|
}
|
|
4175
4325
|
shouldSendVital(e, t) {
|
|
4176
4326
|
if (typeof t != "number" || !Number.isFinite(t))
|
|
4177
|
-
return a("
|
|
4327
|
+
return a("debug", "Invalid web vital value", { data: { type: e, value: t } }), !1;
|
|
4178
4328
|
const r = this.vitalThresholds[e];
|
|
4179
4329
|
return !(typeof r == "number" && t <= r);
|
|
4180
4330
|
}
|
|
4181
4331
|
}
|
|
4182
|
-
class
|
|
4332
|
+
class ar extends _ {
|
|
4183
4333
|
eventManager;
|
|
4184
4334
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4185
4335
|
errorBurstCounter = 0;
|
|
@@ -4215,24 +4365,24 @@ class Kt extends p {
|
|
|
4215
4365
|
const e = Date.now();
|
|
4216
4366
|
if (e < this.burstBackoffUntil)
|
|
4217
4367
|
return !1;
|
|
4218
|
-
if (e - this.burstWindowStart >
|
|
4219
|
-
return this.burstBackoffUntil = e + Ce, a("
|
|
4368
|
+
if (e - this.burstWindowStart > yt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > bt)
|
|
4369
|
+
return this.burstBackoffUntil = e + Ce, a("debug", "Error burst detected - entering cooldown", {
|
|
4220
4370
|
data: {
|
|
4221
4371
|
errorsInWindow: this.errorBurstCounter,
|
|
4222
4372
|
cooldownMs: Ce
|
|
4223
4373
|
}
|
|
4224
4374
|
}), !1;
|
|
4225
|
-
const r = this.get("config")?.errorSampling ??
|
|
4375
|
+
const r = this.get("config")?.errorSampling ?? We;
|
|
4226
4376
|
return Math.random() < r;
|
|
4227
4377
|
}
|
|
4228
4378
|
handleError = (e) => {
|
|
4229
4379
|
if (!this.shouldSample())
|
|
4230
4380
|
return;
|
|
4231
4381
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4232
|
-
this.shouldSuppressError(
|
|
4233
|
-
type:
|
|
4382
|
+
this.shouldSuppressError(U.JS_ERROR, t) || this.eventManager.track({
|
|
4383
|
+
type: d.ERROR,
|
|
4234
4384
|
error_data: {
|
|
4235
|
-
type:
|
|
4385
|
+
type: U.JS_ERROR,
|
|
4236
4386
|
message: t,
|
|
4237
4387
|
...e.filename && { filename: e.filename },
|
|
4238
4388
|
...e.lineno && { line: e.lineno },
|
|
@@ -4244,10 +4394,10 @@ class Kt extends p {
|
|
|
4244
4394
|
if (!this.shouldSample())
|
|
4245
4395
|
return;
|
|
4246
4396
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4247
|
-
this.shouldSuppressError(
|
|
4248
|
-
type:
|
|
4397
|
+
this.shouldSuppressError(U.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4398
|
+
type: d.ERROR,
|
|
4249
4399
|
error_data: {
|
|
4250
|
-
type:
|
|
4400
|
+
type: U.PROMISE_REJECTION,
|
|
4251
4401
|
message: r
|
|
4252
4402
|
}
|
|
4253
4403
|
});
|
|
@@ -4266,8 +4416,8 @@ class Kt extends p {
|
|
|
4266
4416
|
}
|
|
4267
4417
|
}
|
|
4268
4418
|
sanitize(e) {
|
|
4269
|
-
let t = e.length >
|
|
4270
|
-
for (const r of
|
|
4419
|
+
let t = e.length > Le ? e.slice(0, Le) + "..." : e;
|
|
4420
|
+
for (const r of Be) {
|
|
4271
4421
|
const s = new RegExp(r.source, r.flags);
|
|
4272
4422
|
t = t.replace(s, "[REDACTED]");
|
|
4273
4423
|
}
|
|
@@ -4275,12 +4425,12 @@ class Kt extends p {
|
|
|
4275
4425
|
}
|
|
4276
4426
|
shouldSuppressError(e, t) {
|
|
4277
4427
|
const r = Date.now(), s = `${e}:${t}`, i = this.recentErrors.get(s);
|
|
4278
|
-
return i && r - i <
|
|
4428
|
+
return i && r - i < Me ? (this.recentErrors.set(s, r), !0) : (this.recentErrors.set(s, r), this.recentErrors.size > wt ? (this.recentErrors.clear(), this.recentErrors.set(s, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4279
4429
|
}
|
|
4280
4430
|
pruneOldErrors() {
|
|
4281
4431
|
const e = Date.now();
|
|
4282
4432
|
for (const [s, i] of this.recentErrors.entries())
|
|
4283
|
-
e - i >
|
|
4433
|
+
e - i > Me && this.recentErrors.delete(s);
|
|
4284
4434
|
if (this.recentErrors.size <= Q)
|
|
4285
4435
|
return;
|
|
4286
4436
|
const t = Array.from(this.recentErrors.entries()).sort((s, i) => s[1] - i[1]), r = this.recentErrors.size - Q;
|
|
@@ -4290,10 +4440,10 @@ class Kt extends p {
|
|
|
4290
4440
|
}
|
|
4291
4441
|
}
|
|
4292
4442
|
}
|
|
4293
|
-
class
|
|
4443
|
+
class lr extends _ {
|
|
4294
4444
|
isInitialized = !1;
|
|
4295
4445
|
suppressNextScrollTimer = null;
|
|
4296
|
-
emitter = new
|
|
4446
|
+
emitter = new jt();
|
|
4297
4447
|
transformers = {};
|
|
4298
4448
|
managers = {};
|
|
4299
4449
|
handlers = {};
|
|
@@ -4309,9 +4459,9 @@ class Yt extends p {
|
|
|
4309
4459
|
*/
|
|
4310
4460
|
async init(e = {}) {
|
|
4311
4461
|
if (!this.isInitialized) {
|
|
4312
|
-
this.managers.storage = new
|
|
4462
|
+
this.managers.storage = new ir();
|
|
4313
4463
|
try {
|
|
4314
|
-
this.setupState(e), this.managers.event = new
|
|
4464
|
+
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
4465
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
4316
4466
|
}), this.isInitialized = !0;
|
|
4317
4467
|
} catch (t) {
|
|
@@ -4335,14 +4485,14 @@ class Yt extends p {
|
|
|
4335
4485
|
}
|
|
4336
4486
|
let r = t;
|
|
4337
4487
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4338
|
-
const { valid: s, error: i, sanitizedMetadata: o } =
|
|
4488
|
+
const { valid: s, error: i, sanitizedMetadata: o } = Qt(e, r);
|
|
4339
4489
|
if (!s) {
|
|
4340
|
-
if (this.get("mode") ===
|
|
4490
|
+
if (this.get("mode") === z.QA)
|
|
4341
4491
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4342
4492
|
return;
|
|
4343
4493
|
}
|
|
4344
4494
|
this.managers.event.track({
|
|
4345
|
-
type:
|
|
4495
|
+
type: d.CUSTOM,
|
|
4346
4496
|
custom_event: {
|
|
4347
4497
|
name: e,
|
|
4348
4498
|
...o && { metadata: o }
|
|
@@ -4383,16 +4533,14 @@ class Yt extends p {
|
|
|
4383
4533
|
}
|
|
4384
4534
|
setupState(e = {}) {
|
|
4385
4535
|
this.set("config", e);
|
|
4386
|
-
const t =
|
|
4536
|
+
const t = qt.getId(this.managers.storage);
|
|
4387
4537
|
this.set("userId", t);
|
|
4388
|
-
const r =
|
|
4538
|
+
const r = xt(e);
|
|
4389
4539
|
this.set("collectApiUrls", r);
|
|
4390
|
-
const s =
|
|
4540
|
+
const s = It();
|
|
4391
4541
|
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);
|
|
4542
|
+
const i = le(window.location.href, e.sensitiveQueryParams);
|
|
4543
|
+
this.set("pageUrl", i), Pt() && this.set("mode", z.QA);
|
|
4396
4544
|
}
|
|
4397
4545
|
/**
|
|
4398
4546
|
* Returns the current configuration object.
|
|
@@ -4434,7 +4582,7 @@ class Yt extends p {
|
|
|
4434
4582
|
valid: !1,
|
|
4435
4583
|
error: "Global metadata must be a plain object"
|
|
4436
4584
|
};
|
|
4437
|
-
const t =
|
|
4585
|
+
const t = je("Global", e, "globalMetadata");
|
|
4438
4586
|
return t.valid ? { valid: !0 } : {
|
|
4439
4587
|
valid: !1,
|
|
4440
4588
|
error: t.error
|
|
@@ -4479,7 +4627,7 @@ class Yt extends p {
|
|
|
4479
4627
|
}
|
|
4480
4628
|
initializeHandlers() {
|
|
4481
4629
|
const e = this.get("config");
|
|
4482
|
-
this.handlers.session = new
|
|
4630
|
+
this.handlers.session = new er(
|
|
4483
4631
|
this.managers.storage,
|
|
4484
4632
|
this.managers.event
|
|
4485
4633
|
), this.handlers.session.startTracking();
|
|
@@ -4488,24 +4636,24 @@ class Yt extends p {
|
|
|
4488
4636
|
this.set("suppressNextScroll", !1);
|
|
4489
4637
|
}, 500);
|
|
4490
4638
|
};
|
|
4491
|
-
this.handlers.pageView = new
|
|
4639
|
+
this.handlers.pageView = new tr(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new rr(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new nr(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new or(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4492
4640
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4493
|
-
}), this.handlers.error = new
|
|
4641
|
+
}), this.handlers.error = new ar(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new sr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4494
4642
|
}
|
|
4495
4643
|
}
|
|
4496
|
-
const
|
|
4497
|
-
let f = null,
|
|
4498
|
-
const
|
|
4499
|
-
if (!(typeof window > "u" || typeof document > "u") && (
|
|
4500
|
-
|
|
4644
|
+
const R = [], M = [];
|
|
4645
|
+
let f = null, C = !1, v = !1;
|
|
4646
|
+
const cr = async (n) => {
|
|
4647
|
+
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !C)) {
|
|
4648
|
+
C = !0;
|
|
4501
4649
|
try {
|
|
4502
|
-
const e =
|
|
4650
|
+
const e = Wt(n ?? {}), t = new lr();
|
|
4503
4651
|
try {
|
|
4504
|
-
|
|
4652
|
+
R.forEach(({ event: i, callback: o }) => {
|
|
4505
4653
|
t.on(i, o);
|
|
4506
|
-
}),
|
|
4654
|
+
}), R.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4507
4655
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4508
|
-
}),
|
|
4656
|
+
}), M.length = 0;
|
|
4509
4657
|
const r = t.init(e), s = new Promise((i, o) => {
|
|
4510
4658
|
setTimeout(() => {
|
|
4511
4659
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4523,120 +4671,120 @@ const qt = async (n) => {
|
|
|
4523
4671
|
} catch (e) {
|
|
4524
4672
|
throw f = null, e;
|
|
4525
4673
|
} finally {
|
|
4526
|
-
|
|
4674
|
+
C = !1;
|
|
4527
4675
|
}
|
|
4528
4676
|
}
|
|
4529
|
-
},
|
|
4677
|
+
}, ur = (n, e) => {
|
|
4530
4678
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4531
4679
|
if (!f)
|
|
4532
4680
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4533
|
-
if (
|
|
4681
|
+
if (v)
|
|
4534
4682
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4535
4683
|
f.sendCustomEvent(n, e);
|
|
4536
4684
|
}
|
|
4537
|
-
},
|
|
4685
|
+
}, dr = (n, e) => {
|
|
4538
4686
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4539
|
-
if (!f ||
|
|
4540
|
-
|
|
4687
|
+
if (!f || C) {
|
|
4688
|
+
R.push({ event: n, callback: e });
|
|
4541
4689
|
return;
|
|
4542
4690
|
}
|
|
4543
4691
|
f.on(n, e);
|
|
4544
4692
|
}
|
|
4545
|
-
},
|
|
4693
|
+
}, hr = (n, e) => {
|
|
4546
4694
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4547
4695
|
if (!f) {
|
|
4548
|
-
const t =
|
|
4549
|
-
t !== -1 &&
|
|
4696
|
+
const t = R.findIndex((r) => r.event === n && r.callback === e);
|
|
4697
|
+
t !== -1 && R.splice(t, 1);
|
|
4550
4698
|
return;
|
|
4551
4699
|
}
|
|
4552
4700
|
f.off(n, e);
|
|
4553
4701
|
}
|
|
4554
4702
|
};
|
|
4555
|
-
function
|
|
4703
|
+
function fr(n, e) {
|
|
4556
4704
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4557
4705
|
if (typeof e != "function")
|
|
4558
4706
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4559
|
-
if (!f ||
|
|
4560
|
-
const t =
|
|
4561
|
-
t !== -1 &&
|
|
4707
|
+
if (!f || C) {
|
|
4708
|
+
const t = M.findIndex((r) => r.hook === n);
|
|
4709
|
+
t !== -1 && M.splice(t, 1), M.push({ hook: n, fn: e });
|
|
4562
4710
|
return;
|
|
4563
4711
|
}
|
|
4564
|
-
if (
|
|
4712
|
+
if (v)
|
|
4565
4713
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4566
4714
|
n === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4567
4715
|
}
|
|
4568
4716
|
}
|
|
4569
|
-
const
|
|
4717
|
+
const mr = (n) => {
|
|
4570
4718
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4571
4719
|
if (!f) {
|
|
4572
|
-
const e =
|
|
4573
|
-
e !== -1 &&
|
|
4720
|
+
const e = M.findIndex((t) => t.hook === n);
|
|
4721
|
+
e !== -1 && M.splice(e, 1);
|
|
4574
4722
|
return;
|
|
4575
4723
|
}
|
|
4576
|
-
if (
|
|
4724
|
+
if (v)
|
|
4577
4725
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4578
4726
|
f.removeTransformer(n);
|
|
4579
4727
|
}
|
|
4580
|
-
},
|
|
4728
|
+
}, gr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Er = () => {
|
|
4581
4729
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4582
|
-
if (
|
|
4730
|
+
if (v)
|
|
4583
4731
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
4584
4732
|
if (!f) {
|
|
4585
|
-
|
|
4733
|
+
v = !1;
|
|
4586
4734
|
return;
|
|
4587
4735
|
}
|
|
4588
|
-
|
|
4736
|
+
v = !0;
|
|
4589
4737
|
try {
|
|
4590
|
-
f.destroy(), f = null,
|
|
4738
|
+
f.destroy(), f = null, C = !1, R.length = 0, M.length = 0, v = !1;
|
|
4591
4739
|
} catch (n) {
|
|
4592
|
-
f = null,
|
|
4740
|
+
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4593
4741
|
}
|
|
4594
4742
|
}
|
|
4595
|
-
},
|
|
4596
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4597
|
-
},
|
|
4743
|
+
}, Sr = (n) => {
|
|
4744
|
+
typeof window > "u" || typeof document > "u" || Dt(n);
|
|
4745
|
+
}, pr = (n) => {
|
|
4598
4746
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4599
4747
|
if (!f)
|
|
4600
4748
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4601
|
-
if (
|
|
4749
|
+
if (v)
|
|
4602
4750
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4603
4751
|
f.updateGlobalMetadata(n);
|
|
4604
4752
|
}
|
|
4605
|
-
},
|
|
4753
|
+
}, Tr = (n) => {
|
|
4606
4754
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4607
4755
|
if (!f)
|
|
4608
4756
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4609
|
-
if (
|
|
4757
|
+
if (v)
|
|
4610
4758
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4611
4759
|
f.mergeGlobalMetadata(n);
|
|
4612
4760
|
}
|
|
4613
|
-
},
|
|
4614
|
-
init:
|
|
4615
|
-
event:
|
|
4616
|
-
on:
|
|
4617
|
-
off:
|
|
4618
|
-
setTransformer:
|
|
4619
|
-
removeTransformer:
|
|
4620
|
-
isInitialized:
|
|
4621
|
-
destroy:
|
|
4622
|
-
setQaMode:
|
|
4623
|
-
updateGlobalMetadata:
|
|
4624
|
-
mergeGlobalMetadata:
|
|
4761
|
+
}, Qr = {
|
|
4762
|
+
init: cr,
|
|
4763
|
+
event: ur,
|
|
4764
|
+
on: dr,
|
|
4765
|
+
off: hr,
|
|
4766
|
+
setTransformer: fr,
|
|
4767
|
+
removeTransformer: mr,
|
|
4768
|
+
isInitialized: gr,
|
|
4769
|
+
destroy: Er,
|
|
4770
|
+
setQaMode: Sr,
|
|
4771
|
+
updateGlobalMetadata: pr,
|
|
4772
|
+
mergeGlobalMetadata: Tr
|
|
4625
4773
|
};
|
|
4626
|
-
var
|
|
4774
|
+
var ue, Ye = -1, P = function(n) {
|
|
4627
4775
|
addEventListener("pageshow", (function(e) {
|
|
4628
|
-
e.persisted && (
|
|
4776
|
+
e.persisted && (Ye = e.timeStamp, n(e));
|
|
4629
4777
|
}), !0);
|
|
4630
|
-
},
|
|
4778
|
+
}, Ee = function() {
|
|
4631
4779
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4632
4780
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4633
|
-
},
|
|
4634
|
-
var n =
|
|
4781
|
+
}, q = function() {
|
|
4782
|
+
var n = Ee();
|
|
4635
4783
|
return n && n.activationStart || 0;
|
|
4636
|
-
},
|
|
4637
|
-
var t =
|
|
4638
|
-
return
|
|
4639
|
-
},
|
|
4784
|
+
}, b = function(n, e) {
|
|
4785
|
+
var t = Ee(), r = "navigate";
|
|
4786
|
+
return Ye >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: n, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: r };
|
|
4787
|
+
}, F = function(n, e, t) {
|
|
4640
4788
|
try {
|
|
4641
4789
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
4642
4790
|
var r = new PerformanceObserver((function(s) {
|
|
@@ -4655,205 +4803,205 @@ var ce, je = -1, O = function(n) {
|
|
|
4655
4803
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4656
4804
|
})(e.value, t), n(e));
|
|
4657
4805
|
};
|
|
4658
|
-
},
|
|
4806
|
+
}, Se = function(n) {
|
|
4659
4807
|
requestAnimationFrame((function() {
|
|
4660
4808
|
return requestAnimationFrame((function() {
|
|
4661
4809
|
return n();
|
|
4662
4810
|
}));
|
|
4663
4811
|
}));
|
|
4664
|
-
},
|
|
4812
|
+
}, J = function(n) {
|
|
4665
4813
|
document.addEventListener("visibilitychange", (function() {
|
|
4666
4814
|
document.visibilityState === "hidden" && n();
|
|
4667
4815
|
}));
|
|
4668
|
-
},
|
|
4816
|
+
}, pe = function(n) {
|
|
4669
4817
|
var e = !1;
|
|
4670
4818
|
return function() {
|
|
4671
4819
|
e || (n(), e = !0);
|
|
4672
4820
|
};
|
|
4673
|
-
},
|
|
4821
|
+
}, O = -1, ke = function() {
|
|
4674
4822
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4675
|
-
},
|
|
4676
|
-
document.visibilityState === "hidden" &&
|
|
4823
|
+
}, Y = function(n) {
|
|
4824
|
+
document.visibilityState === "hidden" && O > -1 && (O = n.type === "visibilitychange" ? n.timeStamp : 0, _r());
|
|
4677
4825
|
}, Ue = function() {
|
|
4678
|
-
addEventListener("visibilitychange",
|
|
4679
|
-
},
|
|
4680
|
-
removeEventListener("visibilitychange",
|
|
4681
|
-
},
|
|
4682
|
-
return
|
|
4826
|
+
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4827
|
+
}, _r = function() {
|
|
4828
|
+
removeEventListener("visibilitychange", Y, !0), removeEventListener("prerenderingchange", Y, !0);
|
|
4829
|
+
}, qe = function() {
|
|
4830
|
+
return O < 0 && (O = ke(), Ue(), P((function() {
|
|
4683
4831
|
setTimeout((function() {
|
|
4684
|
-
|
|
4832
|
+
O = ke(), Ue();
|
|
4685
4833
|
}), 0);
|
|
4686
4834
|
}))), { get firstHiddenTime() {
|
|
4687
|
-
return
|
|
4835
|
+
return O;
|
|
4688
4836
|
} };
|
|
4689
|
-
},
|
|
4837
|
+
}, Z = function(n) {
|
|
4690
4838
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4691
4839
|
return n();
|
|
4692
4840
|
}), !0) : n();
|
|
4693
|
-
},
|
|
4694
|
-
e = e || {},
|
|
4695
|
-
var t, r =
|
|
4841
|
+
}, de = [1800, 3e3], Je = function(n, e) {
|
|
4842
|
+
e = e || {}, Z((function() {
|
|
4843
|
+
var t, r = qe(), s = b("FCP"), i = F("paint", (function(o) {
|
|
4696
4844
|
o.forEach((function(l) {
|
|
4697
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime -
|
|
4845
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime - q(), 0), s.entries.push(l), t(!0)));
|
|
4698
4846
|
}));
|
|
4699
4847
|
}));
|
|
4700
|
-
i && (t = A(n, s,
|
|
4701
|
-
s =
|
|
4848
|
+
i && (t = A(n, s, de, e.reportAllChanges), P((function(o) {
|
|
4849
|
+
s = b("FCP"), t = A(n, s, de, e.reportAllChanges), Se((function() {
|
|
4702
4850
|
s.value = performance.now() - o.timeStamp, t(!0);
|
|
4703
4851
|
}));
|
|
4704
4852
|
})));
|
|
4705
4853
|
}));
|
|
4706
|
-
},
|
|
4707
|
-
e = e || {},
|
|
4708
|
-
var t, r =
|
|
4709
|
-
c.forEach((function(
|
|
4710
|
-
if (!
|
|
4711
|
-
var
|
|
4712
|
-
s &&
|
|
4854
|
+
}, he = [0.1, 0.25], vr = function(n, e) {
|
|
4855
|
+
e = e || {}, Je(pe((function() {
|
|
4856
|
+
var t, r = b("CLS", 0), s = 0, i = [], o = function(c) {
|
|
4857
|
+
c.forEach((function(u) {
|
|
4858
|
+
if (!u.hadRecentInput) {
|
|
4859
|
+
var S = i[0], g = i[i.length - 1];
|
|
4860
|
+
s && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (s += u.value, i.push(u)) : (s = u.value, i = [u]);
|
|
4713
4861
|
}
|
|
4714
4862
|
})), s > r.value && (r.value = s, r.entries = i, t());
|
|
4715
|
-
}, l =
|
|
4716
|
-
l && (t = A(n, r,
|
|
4863
|
+
}, l = F("layout-shift", o);
|
|
4864
|
+
l && (t = A(n, r, he, e.reportAllChanges), J((function() {
|
|
4717
4865
|
o(l.takeRecords()), t(!0);
|
|
4718
|
-
})),
|
|
4719
|
-
s = 0, r =
|
|
4866
|
+
})), P((function() {
|
|
4867
|
+
s = 0, r = b("CLS", 0), t = A(n, r, he, e.reportAllChanges), Se((function() {
|
|
4720
4868
|
return t();
|
|
4721
4869
|
}));
|
|
4722
4870
|
})), setTimeout(t, 0));
|
|
4723
4871
|
})));
|
|
4724
|
-
},
|
|
4872
|
+
}, Ze = 0, re = 1 / 0, G = 0, Ir = function(n) {
|
|
4725
4873
|
n.forEach((function(e) {
|
|
4726
|
-
e.interactionId && (
|
|
4874
|
+
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId), Ze = G ? (G - re) / 7 + 1 : 0);
|
|
4727
4875
|
}));
|
|
4728
|
-
},
|
|
4729
|
-
return
|
|
4730
|
-
},
|
|
4731
|
-
"interactionCount" in performance ||
|
|
4732
|
-
},
|
|
4733
|
-
var n = Math.min(
|
|
4734
|
-
return
|
|
4735
|
-
},
|
|
4736
|
-
if (
|
|
4876
|
+
}, et = function() {
|
|
4877
|
+
return ue ? Ze : performance.interactionCount || 0;
|
|
4878
|
+
}, wr = function() {
|
|
4879
|
+
"interactionCount" in performance || ue || (ue = F("event", Ir, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4880
|
+
}, y = [], j = /* @__PURE__ */ new Map(), tt = 0, yr = function() {
|
|
4881
|
+
var n = Math.min(y.length - 1, Math.floor((et() - tt) / 50));
|
|
4882
|
+
return y[n];
|
|
4883
|
+
}, br = [], Ar = function(n) {
|
|
4884
|
+
if (br.forEach((function(s) {
|
|
4737
4885
|
return s(n);
|
|
4738
4886
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4739
|
-
var e =
|
|
4740
|
-
if (t ||
|
|
4887
|
+
var e = y[y.length - 1], t = j.get(n.interactionId);
|
|
4888
|
+
if (t || y.length < 10 || n.duration > e.latency) {
|
|
4741
4889
|
if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
|
|
4742
4890
|
else {
|
|
4743
4891
|
var r = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4744
|
-
|
|
4892
|
+
j.set(r.id, r), y.push(r);
|
|
4745
4893
|
}
|
|
4746
|
-
|
|
4894
|
+
y.sort((function(s, i) {
|
|
4747
4895
|
return i.latency - s.latency;
|
|
4748
|
-
})),
|
|
4749
|
-
return
|
|
4896
|
+
})), y.length > 10 && y.splice(10).forEach((function(s) {
|
|
4897
|
+
return j.delete(s.id);
|
|
4750
4898
|
}));
|
|
4751
4899
|
}
|
|
4752
4900
|
}
|
|
4753
|
-
},
|
|
4901
|
+
}, rt = function(n) {
|
|
4754
4902
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4755
|
-
return n =
|
|
4756
|
-
},
|
|
4757
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
4903
|
+
return n = pe(n), document.visibilityState === "hidden" ? n() : (t = e(n), J(n)), t;
|
|
4904
|
+
}, fe = [200, 500], Lr = function(n, e) {
|
|
4905
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4758
4906
|
var t;
|
|
4759
|
-
|
|
4760
|
-
var r, s =
|
|
4761
|
-
|
|
4762
|
-
l.forEach(
|
|
4763
|
-
var c =
|
|
4907
|
+
wr();
|
|
4908
|
+
var r, s = b("INP"), i = function(l) {
|
|
4909
|
+
rt((function() {
|
|
4910
|
+
l.forEach(Ar);
|
|
4911
|
+
var c = yr();
|
|
4764
4912
|
c && c.latency !== s.value && (s.value = c.latency, s.entries = c.entries, r());
|
|
4765
4913
|
}));
|
|
4766
|
-
}, o =
|
|
4767
|
-
r = A(n, s,
|
|
4914
|
+
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4915
|
+
r = A(n, s, fe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4768
4916
|
i(o.takeRecords()), r(!0);
|
|
4769
|
-
})),
|
|
4770
|
-
|
|
4917
|
+
})), P((function() {
|
|
4918
|
+
tt = et(), y.length = 0, j.clear(), s = b("INP"), r = A(n, s, fe, e.reportAllChanges);
|
|
4771
4919
|
})));
|
|
4772
4920
|
})));
|
|
4773
|
-
},
|
|
4774
|
-
e = e || {},
|
|
4775
|
-
var t, r =
|
|
4776
|
-
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(
|
|
4777
|
-
|
|
4921
|
+
}, me = [2500, 4e3], ne = {}, Mr = function(n, e) {
|
|
4922
|
+
e = e || {}, Z((function() {
|
|
4923
|
+
var t, r = qe(), s = b("LCP"), i = function(c) {
|
|
4924
|
+
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4925
|
+
u.startTime < r.firstHiddenTime && (s.value = Math.max(u.startTime - q(), 0), s.entries = [u], t());
|
|
4778
4926
|
}));
|
|
4779
|
-
}, o =
|
|
4927
|
+
}, o = F("largest-contentful-paint", i);
|
|
4780
4928
|
if (o) {
|
|
4781
|
-
t = A(n, s,
|
|
4782
|
-
var l =
|
|
4783
|
-
|
|
4929
|
+
t = A(n, s, me, e.reportAllChanges);
|
|
4930
|
+
var l = pe((function() {
|
|
4931
|
+
ne[s.id] || (i(o.takeRecords()), o.disconnect(), ne[s.id] = !0, t(!0));
|
|
4784
4932
|
}));
|
|
4785
4933
|
["keydown", "click"].forEach((function(c) {
|
|
4786
4934
|
addEventListener(c, (function() {
|
|
4787
|
-
return
|
|
4935
|
+
return rt(l);
|
|
4788
4936
|
}), { once: !0, capture: !0 });
|
|
4789
|
-
})),
|
|
4790
|
-
s =
|
|
4791
|
-
s.value = performance.now() - c.timeStamp,
|
|
4937
|
+
})), J(l), P((function(c) {
|
|
4938
|
+
s = b("LCP"), t = A(n, s, me, e.reportAllChanges), Se((function() {
|
|
4939
|
+
s.value = performance.now() - c.timeStamp, ne[s.id] = !0, t(!0);
|
|
4792
4940
|
}));
|
|
4793
4941
|
}));
|
|
4794
4942
|
}
|
|
4795
4943
|
}));
|
|
4796
|
-
},
|
|
4797
|
-
document.prerendering ?
|
|
4944
|
+
}, ge = [800, 1800], Cr = function n(e) {
|
|
4945
|
+
document.prerendering ? Z((function() {
|
|
4798
4946
|
return n(e);
|
|
4799
4947
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4800
4948
|
return n(e);
|
|
4801
4949
|
}), !0) : setTimeout(e, 0);
|
|
4802
|
-
},
|
|
4950
|
+
}, Rr = function(n, e) {
|
|
4803
4951
|
e = e || {};
|
|
4804
|
-
var t =
|
|
4805
|
-
|
|
4806
|
-
var s =
|
|
4807
|
-
s && (t.value = Math.max(s.responseStart -
|
|
4808
|
-
t =
|
|
4952
|
+
var t = b("TTFB"), r = A(n, t, ge, e.reportAllChanges);
|
|
4953
|
+
Cr((function() {
|
|
4954
|
+
var s = Ee();
|
|
4955
|
+
s && (t.value = Math.max(s.responseStart - q(), 0), t.entries = [s], r(!0), P((function() {
|
|
4956
|
+
t = b("TTFB", 0), (r = A(n, t, ge, e.reportAllChanges))(!0);
|
|
4809
4957
|
})));
|
|
4810
4958
|
}));
|
|
4811
4959
|
};
|
|
4812
|
-
const
|
|
4960
|
+
const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4813
4961
|
__proto__: null,
|
|
4814
|
-
CLSThresholds:
|
|
4815
|
-
FCPThresholds:
|
|
4816
|
-
INPThresholds:
|
|
4817
|
-
LCPThresholds:
|
|
4818
|
-
TTFBThresholds:
|
|
4819
|
-
onCLS:
|
|
4820
|
-
onFCP:
|
|
4821
|
-
onINP:
|
|
4822
|
-
onLCP:
|
|
4823
|
-
onTTFB:
|
|
4962
|
+
CLSThresholds: he,
|
|
4963
|
+
FCPThresholds: de,
|
|
4964
|
+
INPThresholds: fe,
|
|
4965
|
+
LCPThresholds: me,
|
|
4966
|
+
TTFBThresholds: ge,
|
|
4967
|
+
onCLS: vr,
|
|
4968
|
+
onFCP: Je,
|
|
4969
|
+
onINP: Lr,
|
|
4970
|
+
onLCP: Mr,
|
|
4971
|
+
onTTFB: Rr
|
|
4824
4972
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4825
4973
|
export {
|
|
4826
4974
|
h as AppConfigValidationError,
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4975
|
+
Or as DEFAULT_SESSION_TIMEOUT,
|
|
4976
|
+
ae as DEFAULT_WEB_VITALS_MODE,
|
|
4977
|
+
L as DeviceType,
|
|
4978
|
+
se as EmitterEvent,
|
|
4979
|
+
U as ErrorType,
|
|
4980
|
+
d as EventType,
|
|
4981
|
+
Gr as InitializationTimeoutError,
|
|
4982
|
+
V as IntegrationValidationError,
|
|
4983
|
+
$r as MAX_ARRAY_LENGTH,
|
|
4984
|
+
kr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4985
|
+
Vr as MAX_CUSTOM_EVENT_KEYS,
|
|
4986
|
+
Pr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4987
|
+
Dr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4988
|
+
xr as MAX_METADATA_NESTING_DEPTH,
|
|
4989
|
+
Ur as MAX_NESTED_OBJECT_KEYS,
|
|
4990
|
+
Hr as MAX_STRING_LENGTH,
|
|
4991
|
+
Fr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4992
|
+
z as Mode,
|
|
4993
|
+
Be as PII_PATTERNS,
|
|
4994
|
+
N as PermanentError,
|
|
4995
|
+
Ae as SamplingRateValidationError,
|
|
4848
4996
|
X as ScrollDirection,
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4997
|
+
dt as SessionTimeoutValidationError,
|
|
4998
|
+
k as SpecialApiUrl,
|
|
4999
|
+
H as TraceLogValidationError,
|
|
5000
|
+
Xr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4853
5001
|
Re as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4854
|
-
|
|
5002
|
+
Lt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4855
5003
|
Ne as getWebVitalsThresholds,
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
5004
|
+
Br as isPrimaryScrollEvent,
|
|
5005
|
+
Wr as isSecondaryScrollEvent,
|
|
5006
|
+
Qr as tracelog
|
|
4859
5007
|
};
|