@tracelog/lib 2.1.0-rc.74.5 → 2.1.1-rc.75.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @tracelog/lib might be problematic. Click here for more details.
- package/dist/browser/tracelog.esm.js +725 -768
- 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 +84 -105
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +2 -52
- package/dist/public-api.d.ts +2 -52
- package/dist/public-api.js +84 -105
- 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 w = "data-tlog",
|
|
1
|
+
const kr = 9e5;
|
|
2
|
+
const Ur = 120, xr = 8192, Hr = 10, Fr = 10, $r = 20, Br = 1;
|
|
3
|
+
const Wr = 1e3, Gr = 500, Xr = 100;
|
|
4
|
+
const w = "data-tlog", ot = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const w = "data-tlog", st = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], at = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], lt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,22 +71,22 @@ 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
|
+
}, ct = [
|
|
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", x = `${I}:qa_mode`,
|
|
82
|
-
var k = /* @__PURE__ */ ((
|
|
81
|
+
], I = "tlog", x = `${I}:qa_mode`, _e = `${I}:uid`, $e = "tlog_mode", ve = "qa", Ie = "qa_off", ut = (s) => s ? `${I}:${s}:queue` : `${I}:queue`, dt = (s) => s ? `${I}:${s}:session` : `${I}:session`, ht = (s) => s ? `${I}:${s}:broadcast` : `${I}:broadcast`, we = (s, e) => `${I}:${s}:session_counts:${e}`, ye = 10080 * 60 * 1e3, be = `${I}:session_counts_last_cleanup`, Ae = 3600 * 1e3;
|
|
82
|
+
var k = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(k || {}), L = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(L || {}), ne = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(ne || {});
|
|
83
83
|
class N extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
85
|
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
var d = /* @__PURE__ */ ((
|
|
89
|
-
const
|
|
88
|
+
var d = /* @__PURE__ */ ((s) => (s.PAGE_VIEW = "page_view", s.CLICK = "click", s.SCROLL = "scroll", s.SESSION_START = "session_start", s.CUSTOM = "custom", s.WEB_VITALS = "web_vitals", s.ERROR = "error", s.VIEWPORT_VISIBLE = "viewport_visible", s))(d || {}), X = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(X || {}), U = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(U || {}), z = /* @__PURE__ */ ((s) => (s.QA = "qa", s))(z || {});
|
|
89
|
+
const Qr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !0, jr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !1;
|
|
90
90
|
class H extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -97,12 +97,12 @@ class h extends H {
|
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class ft extends H {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class Le extends H {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
@@ -112,31 +112,31 @@ class V extends H {
|
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class zr 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 Be = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", We = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", mt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", gt = (s, e) => {
|
|
121
121
|
if (e) {
|
|
122
122
|
if (e instanceof Error) {
|
|
123
123
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
124
|
-
return `[TraceLog] ${
|
|
124
|
+
return `[TraceLog] ${s}: ${t}`;
|
|
125
125
|
}
|
|
126
126
|
if (e instanceof Error)
|
|
127
|
-
return `[TraceLog] ${
|
|
127
|
+
return `[TraceLog] ${s}: ${e.message}`;
|
|
128
128
|
if (typeof e == "string")
|
|
129
|
-
return `[TraceLog] ${
|
|
129
|
+
return `[TraceLog] ${s}: ${e}`;
|
|
130
130
|
if (typeof e == "object")
|
|
131
131
|
try {
|
|
132
|
-
return `[TraceLog] ${
|
|
132
|
+
return `[TraceLog] ${s}: ${JSON.stringify(e)}`;
|
|
133
133
|
} catch {
|
|
134
|
-
return `[TraceLog] ${
|
|
134
|
+
return `[TraceLog] ${s}: [Unable to serialize error]`;
|
|
135
135
|
}
|
|
136
|
-
return `[TraceLog] ${
|
|
136
|
+
return `[TraceLog] ${s}: ${String(e)}`;
|
|
137
137
|
}
|
|
138
|
-
return `[TraceLog] ${
|
|
139
|
-
},
|
|
138
|
+
return `[TraceLog] ${s}`;
|
|
139
|
+
}, Et = () => {
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
142
142
|
try {
|
|
@@ -144,34 +144,34 @@ const He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
144
144
|
} catch {
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
147
|
-
}, a = (
|
|
148
|
-
const { error: r, data:
|
|
149
|
-
if (!
|
|
147
|
+
}, a = (s, e, t) => {
|
|
148
|
+
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? gt(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
|
|
149
|
+
if (!St(l, i))
|
|
150
150
|
return;
|
|
151
|
-
const g =
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
const
|
|
155
|
-
r !== void 0 ?
|
|
156
|
-
}, ie = (
|
|
151
|
+
const g = pt(l, o), p = n !== void 0 ? ie(n) : void 0;
|
|
152
|
+
Tt(u, c, g, p);
|
|
153
|
+
}, St = (s, e) => s === "critical" ? !0 : s === "qa" || e ? Et() : !1, pt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? mt : "", Tt = (s, e, t, r) => {
|
|
154
|
+
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
155
|
+
r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
|
|
156
|
+
}, ie = (s) => {
|
|
157
157
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
158
|
-
for (const [r,
|
|
158
|
+
for (const [r, n] of Object.entries(s)) {
|
|
159
159
|
const i = r.toLowerCase();
|
|
160
160
|
if (t.some((o) => i.includes(o))) {
|
|
161
161
|
e[r] = "[REDACTED]";
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] = ie(n) : Array.isArray(n) ? e[r] = n.map(
|
|
165
165
|
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ie(o) : o
|
|
166
|
-
) : e[r] =
|
|
166
|
+
) : e[r] = n;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let oe,
|
|
171
|
-
const
|
|
172
|
-
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"),
|
|
173
|
-
}, K = "Unknown",
|
|
174
|
-
const e =
|
|
170
|
+
let oe, Ge;
|
|
171
|
+
const _t = () => {
|
|
172
|
+
typeof window < "u" && !oe && (oe = window.matchMedia("(pointer: coarse)"), Ge = window.matchMedia("(hover: none)"));
|
|
173
|
+
}, K = "Unknown", vt = (s) => {
|
|
174
|
+
const e = s.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
176
176
|
if (/windows/i.test(e)) return "Windows";
|
|
177
177
|
if (/macos/i.test(e)) return "macOS";
|
|
@@ -182,46 +182,46 @@ const pt = () => {
|
|
|
182
182
|
}
|
|
183
183
|
const t = navigator.userAgent;
|
|
184
184
|
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : K;
|
|
185
|
-
},
|
|
186
|
-
const e =
|
|
185
|
+
}, It = (s) => {
|
|
186
|
+
const e = s.userAgentData?.brands;
|
|
187
187
|
if (e != null && e.length > 0) {
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
const i =
|
|
188
|
+
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
189
|
+
if (n != null) {
|
|
190
|
+
const i = n.brand;
|
|
191
191
|
return /google chrome/i.test(i) ? "Chrome" : /microsoft edge/i.test(i) ? "Edge" : /opera/i.test(i) ? "Opera" : i;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
const t = navigator.userAgent;
|
|
195
195
|
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : K;
|
|
196
|
-
},
|
|
196
|
+
}, wt = () => {
|
|
197
197
|
try {
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const c =
|
|
201
|
-
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet :
|
|
198
|
+
const s = navigator;
|
|
199
|
+
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
200
|
+
const c = s.userAgentData.platform;
|
|
201
|
+
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : s.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
const e = window.innerWidth, t = oe?.matches ?? !1, r =
|
|
205
|
-
return e <= 767 || o &&
|
|
206
|
-
} catch (
|
|
207
|
-
return a("debug", "Device detection failed, defaulting to desktop", { error:
|
|
203
|
+
_t();
|
|
204
|
+
const e = window.innerWidth, t = oe?.matches ?? !1, r = Ge?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
205
|
+
return e <= 767 || o && n ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? L.Tablet : L.Desktop;
|
|
206
|
+
} catch (s) {
|
|
207
|
+
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), L.Desktop;
|
|
208
208
|
}
|
|
209
|
-
},
|
|
209
|
+
}, yt = () => {
|
|
210
210
|
try {
|
|
211
|
-
const
|
|
211
|
+
const s = navigator;
|
|
212
212
|
return {
|
|
213
|
-
type:
|
|
214
|
-
os:
|
|
215
|
-
browser:
|
|
213
|
+
type: wt(),
|
|
214
|
+
os: vt(s),
|
|
215
|
+
browser: It(s)
|
|
216
216
|
};
|
|
217
|
-
} catch (
|
|
218
|
-
return a("debug", "Device info detection failed, using defaults", { error:
|
|
217
|
+
} catch (s) {
|
|
218
|
+
return a("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
219
219
|
type: L.Desktop,
|
|
220
220
|
os: K,
|
|
221
221
|
browser: K
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
},
|
|
224
|
+
}, Xe = [
|
|
225
225
|
// Email addresses
|
|
226
226
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
227
227
|
// US Phone numbers (various formats)
|
|
@@ -236,7 +236,7 @@ const pt = () => {
|
|
|
236
236
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
237
237
|
// Passwords in connection strings (protocol://user:password@host)
|
|
238
238
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
239
|
-
],
|
|
239
|
+
], Me = 500, Ce = 5e3, Q = 50, bt = Q * 2, Qe = 1, At = 1e3, Lt = 10, Re = 5e3, Mt = 6e4, Kr = {
|
|
240
240
|
LCP: 2500,
|
|
241
241
|
// Good: ≤ 2.5s
|
|
242
242
|
FCP: 1800,
|
|
@@ -248,7 +248,7 @@ const pt = () => {
|
|
|
248
248
|
TTFB: 800,
|
|
249
249
|
// Good: ≤ 800ms
|
|
250
250
|
LONG_TASK: 50
|
|
251
|
-
},
|
|
251
|
+
}, Ne = {
|
|
252
252
|
LCP: 2500,
|
|
253
253
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
254
254
|
FCP: 1800,
|
|
@@ -260,7 +260,7 @@ const pt = () => {
|
|
|
260
260
|
TTFB: 800,
|
|
261
261
|
// Needs improvement: > 800ms
|
|
262
262
|
LONG_TASK: 50
|
|
263
|
-
},
|
|
263
|
+
}, Ct = {
|
|
264
264
|
LCP: 4e3,
|
|
265
265
|
// Poor: > 4s
|
|
266
266
|
FCP: 3e3,
|
|
@@ -272,87 +272,115 @@ const pt = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
}, ae = "needs-improvement",
|
|
276
|
-
switch (
|
|
275
|
+
}, ae = "needs-improvement", Oe = (s = ae) => {
|
|
276
|
+
switch (s) {
|
|
277
277
|
case "all":
|
|
278
278
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
279
279
|
// Track everything
|
|
280
280
|
case "needs-improvement":
|
|
281
|
-
return
|
|
281
|
+
return Ne;
|
|
282
282
|
case "poor":
|
|
283
|
-
return
|
|
283
|
+
return Ct;
|
|
284
284
|
default:
|
|
285
|
-
return
|
|
285
|
+
return Ne;
|
|
286
286
|
}
|
|
287
|
-
},
|
|
287
|
+
}, Rt = 1e3, Nt = 50, Ot = "2.1.1", Pt = Ot, je = () => typeof window < "u" && typeof sessionStorage < "u", Dt = () => {
|
|
288
288
|
try {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
const e =
|
|
289
|
+
const s = new URLSearchParams(window.location.search);
|
|
290
|
+
s.delete($e);
|
|
291
|
+
const e = s.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
292
292
|
window.history.replaceState({}, "", t);
|
|
293
293
|
} catch {
|
|
294
294
|
}
|
|
295
|
-
},
|
|
296
|
-
if (!
|
|
295
|
+
}, Vt = () => {
|
|
296
|
+
if (!je())
|
|
297
297
|
return !1;
|
|
298
298
|
try {
|
|
299
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
299
|
+
const e = new URLSearchParams(window.location.search).get($e), t = sessionStorage.getItem(x);
|
|
300
300
|
let r = null;
|
|
301
|
-
return e ===
|
|
301
|
+
return e === ve ? (r = !0, sessionStorage.setItem(x, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
302
|
visibility: "qa",
|
|
303
|
-
style:
|
|
304
|
-
})) : e ===
|
|
303
|
+
style: Be
|
|
304
|
+
})) : e === Ie && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
305
|
visibility: "qa",
|
|
306
|
-
style:
|
|
307
|
-
})), (e ===
|
|
306
|
+
style: We
|
|
307
|
+
})), (e === ve || e === Ie) && Dt(), r ?? t === "true";
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
312
|
-
if (
|
|
311
|
+
}, kt = (s) => {
|
|
312
|
+
if (je())
|
|
313
313
|
try {
|
|
314
|
-
sessionStorage.setItem(x,
|
|
314
|
+
sessionStorage.setItem(x, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
|
-
style:
|
|
316
|
+
style: s ? Be : We
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
321
|
+
}, Ut = [
|
|
322
|
+
"co.uk",
|
|
323
|
+
"org.uk",
|
|
324
|
+
"com.au",
|
|
325
|
+
"net.au",
|
|
326
|
+
"com.br",
|
|
327
|
+
"co.nz",
|
|
328
|
+
"co.jp",
|
|
329
|
+
"com.mx",
|
|
330
|
+
"co.in",
|
|
331
|
+
"com.cn",
|
|
332
|
+
"co.za"
|
|
333
|
+
], Pe = (s) => {
|
|
334
|
+
const e = s.toLowerCase().split(".");
|
|
335
|
+
if (e.length <= 2)
|
|
336
|
+
return s.toLowerCase();
|
|
337
|
+
const t = e.slice(-2).join(".");
|
|
338
|
+
return Ut.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
339
|
+
}, xt = (s, e) => s === e ? !0 : Pe(s) === Pe(e), De = () => {
|
|
340
|
+
const s = document.referrer;
|
|
341
|
+
if (!s)
|
|
342
|
+
return "Direct";
|
|
343
|
+
try {
|
|
344
|
+
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
345
|
+
return xt(e, t) ? "Direct" : s;
|
|
346
|
+
} catch (e) {
|
|
347
|
+
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
348
|
+
}
|
|
349
|
+
}, Ve = () => {
|
|
350
|
+
const s = new URLSearchParams(window.location.search), e = {};
|
|
351
|
+
return at.forEach((r) => {
|
|
352
|
+
const n = s.get(r);
|
|
353
|
+
if (n) {
|
|
326
354
|
const i = r.split("utm_")[1];
|
|
327
|
-
e[i] =
|
|
355
|
+
e[i] = n;
|
|
328
356
|
}
|
|
329
357
|
}), Object.keys(e).length ? e : void 0;
|
|
330
|
-
},
|
|
358
|
+
}, Ht = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
331
359
|
const e = Math.random() * 16 | 0;
|
|
332
|
-
return (
|
|
360
|
+
return (s === "x" ? e : e & 3 | 8).toString(16);
|
|
333
361
|
});
|
|
334
362
|
let B = 0, W = 0;
|
|
335
|
-
const
|
|
336
|
-
let
|
|
337
|
-
|
|
363
|
+
const Ft = () => {
|
|
364
|
+
let s = Date.now();
|
|
365
|
+
s < W && (s = W), s === W ? B = (B + 1) % 1e3 : B = 0, W = s;
|
|
338
366
|
const e = B.toString().padStart(3, "0");
|
|
339
367
|
let t = "";
|
|
340
368
|
try {
|
|
341
369
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
342
370
|
const r = crypto.getRandomValues(new Uint8Array(3));
|
|
343
|
-
r && (t = Array.from(r, (
|
|
371
|
+
r && (t = Array.from(r, (n) => n.toString(16).padStart(2, "0")).join(""));
|
|
344
372
|
}
|
|
345
373
|
} catch {
|
|
346
374
|
}
|
|
347
|
-
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${
|
|
348
|
-
},
|
|
375
|
+
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${s}-${e}-${t}`;
|
|
376
|
+
}, ze = (s, e = !1) => {
|
|
349
377
|
try {
|
|
350
|
-
const t = new URL(
|
|
351
|
-
return r || e &&
|
|
378
|
+
const t = new URL(s), r = t.protocol === "https:", n = t.protocol === "http:";
|
|
379
|
+
return r || e && n;
|
|
352
380
|
} catch {
|
|
353
381
|
return !1;
|
|
354
382
|
}
|
|
355
|
-
},
|
|
383
|
+
}, $t = (s) => {
|
|
356
384
|
try {
|
|
357
385
|
const t = new URL(window.location.href).hostname;
|
|
358
386
|
if (!t || typeof t != "string")
|
|
@@ -366,71 +394,71 @@ const kt = () => {
|
|
|
366
394
|
throw new Error("Invalid hostname structure");
|
|
367
395
|
if (r.length === 1)
|
|
368
396
|
throw new Error("Single-part domain not supported for SaaS integration");
|
|
369
|
-
let
|
|
370
|
-
if (r.length === 2 ?
|
|
397
|
+
let n;
|
|
398
|
+
if (r.length === 2 ? n = r.join(".") : n = r.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
371
399
|
throw new Error("Invalid domain structure for SaaS");
|
|
372
|
-
const i = `https://${
|
|
373
|
-
if (!
|
|
400
|
+
const i = `https://${s}.${n}/collect`;
|
|
401
|
+
if (!ze(i))
|
|
374
402
|
throw new Error("Generated URL failed validation");
|
|
375
403
|
return i;
|
|
376
404
|
} catch (e) {
|
|
377
405
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
378
406
|
}
|
|
379
|
-
},
|
|
407
|
+
}, Bt = (s) => {
|
|
380
408
|
const e = {};
|
|
381
|
-
|
|
382
|
-
const t =
|
|
409
|
+
s.integrations?.tracelog?.projectId && (e.saas = $t(s.integrations.tracelog.projectId));
|
|
410
|
+
const t = s.integrations?.custom?.collectApiUrl;
|
|
383
411
|
if (t) {
|
|
384
|
-
const r =
|
|
385
|
-
if (!
|
|
412
|
+
const r = s.integrations?.custom?.allowHttp ?? !1;
|
|
413
|
+
if (!ze(t, r))
|
|
386
414
|
throw new Error("Invalid custom API URL");
|
|
387
415
|
e.custom = t;
|
|
388
416
|
}
|
|
389
417
|
return e;
|
|
390
|
-
}, le = (
|
|
391
|
-
if (!
|
|
392
|
-
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof
|
|
418
|
+
}, le = (s, e = []) => {
|
|
419
|
+
if (!s || typeof s != "string")
|
|
420
|
+
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof s } }), s || "";
|
|
393
421
|
try {
|
|
394
|
-
const t = new URL(
|
|
422
|
+
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...lt, ...e])];
|
|
395
423
|
let i = !1;
|
|
396
424
|
const o = [];
|
|
397
|
-
return
|
|
425
|
+
return n.forEach((c) => {
|
|
398
426
|
r.has(c) && (r.delete(c), i = !0, o.push(c));
|
|
399
|
-
}), !i &&
|
|
427
|
+
}), !i && s.includes("?") ? s : (t.search = r.toString(), t.toString());
|
|
400
428
|
} catch (t) {
|
|
401
|
-
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength:
|
|
429
|
+
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
402
430
|
}
|
|
403
|
-
},
|
|
404
|
-
if (!
|
|
431
|
+
}, ke = (s) => {
|
|
432
|
+
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
405
433
|
return "";
|
|
406
|
-
let e =
|
|
407
|
-
|
|
434
|
+
let e = s;
|
|
435
|
+
s.length > 1e3 && (e = s.slice(0, Math.max(0, 1e3)));
|
|
408
436
|
let t = 0;
|
|
409
|
-
for (const
|
|
437
|
+
for (const n of ct) {
|
|
410
438
|
const i = e;
|
|
411
|
-
e = e.replace(
|
|
439
|
+
e = e.replace(n, ""), i !== e && t++;
|
|
412
440
|
}
|
|
413
441
|
return t > 0 && a("warn", "XSS patterns detected and removed", {
|
|
414
442
|
data: {
|
|
415
443
|
patternMatches: t,
|
|
416
|
-
valueLength:
|
|
444
|
+
valueLength: s.length
|
|
417
445
|
}
|
|
418
446
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
419
|
-
}, ce = (
|
|
420
|
-
if (e > 3 ||
|
|
447
|
+
}, ce = (s, e = 0) => {
|
|
448
|
+
if (e > 3 || s == null)
|
|
421
449
|
return null;
|
|
422
|
-
if (typeof
|
|
423
|
-
return
|
|
424
|
-
if (typeof
|
|
425
|
-
return !Number.isFinite(
|
|
426
|
-
if (typeof
|
|
427
|
-
return
|
|
428
|
-
if (Array.isArray(
|
|
429
|
-
return
|
|
430
|
-
if (typeof
|
|
431
|
-
const t = {},
|
|
432
|
-
for (const [i, o] of
|
|
433
|
-
const l =
|
|
450
|
+
if (typeof s == "string")
|
|
451
|
+
return ke(s);
|
|
452
|
+
if (typeof s == "number")
|
|
453
|
+
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
454
|
+
if (typeof s == "boolean")
|
|
455
|
+
return s;
|
|
456
|
+
if (Array.isArray(s))
|
|
457
|
+
return s.slice(0, 100).map((n) => ce(n, e + 1)).filter((n) => n !== null);
|
|
458
|
+
if (typeof s == "object") {
|
|
459
|
+
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
460
|
+
for (const [i, o] of n) {
|
|
461
|
+
const l = ke(i);
|
|
434
462
|
if (l) {
|
|
435
463
|
const c = ce(o, e + 1);
|
|
436
464
|
c !== null && (t[l] = c);
|
|
@@ -439,72 +467,72 @@ const kt = () => {
|
|
|
439
467
|
return t;
|
|
440
468
|
}
|
|
441
469
|
return null;
|
|
442
|
-
},
|
|
443
|
-
if (typeof
|
|
470
|
+
}, Wt = (s) => {
|
|
471
|
+
if (typeof s != "object" || s === null)
|
|
444
472
|
return {};
|
|
445
473
|
try {
|
|
446
|
-
const e = ce(
|
|
474
|
+
const e = ce(s);
|
|
447
475
|
return typeof e == "object" && e !== null ? e : {};
|
|
448
476
|
} catch (e) {
|
|
449
477
|
const t = e instanceof Error ? e.message : String(e);
|
|
450
478
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
451
479
|
}
|
|
452
|
-
},
|
|
453
|
-
if (
|
|
480
|
+
}, Gt = (s) => {
|
|
481
|
+
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
454
482
|
throw new h("Configuration must be an object", "config");
|
|
455
|
-
if (
|
|
456
|
-
if (
|
|
457
|
-
throw new
|
|
458
|
-
if (
|
|
483
|
+
if (s) {
|
|
484
|
+
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
485
|
+
throw new ft(m.INVALID_SESSION_TIMEOUT, "config");
|
|
486
|
+
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
459
487
|
throw new h(m.INVALID_GLOBAL_METADATA, "config");
|
|
460
|
-
if (
|
|
461
|
-
if (!Array.isArray(
|
|
488
|
+
if (s.integrations && Qt(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
489
|
+
if (!Array.isArray(s.sensitiveQueryParams))
|
|
462
490
|
throw new h(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
463
|
-
for (const e of
|
|
491
|
+
for (const e of s.sensitiveQueryParams)
|
|
464
492
|
if (typeof e != "string")
|
|
465
493
|
throw new h("All sensitive query params must be strings", "config");
|
|
466
494
|
}
|
|
467
|
-
if (
|
|
468
|
-
throw new
|
|
469
|
-
if (
|
|
470
|
-
throw new
|
|
471
|
-
if (
|
|
472
|
-
if (typeof
|
|
495
|
+
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
496
|
+
throw new Le(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
497
|
+
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
498
|
+
throw new Le(m.INVALID_SAMPLING_RATE, "config");
|
|
499
|
+
if (s.primaryScrollSelector !== void 0) {
|
|
500
|
+
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
473
501
|
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
474
|
-
if (
|
|
502
|
+
if (s.primaryScrollSelector !== "window")
|
|
475
503
|
try {
|
|
476
|
-
document.querySelector(
|
|
504
|
+
document.querySelector(s.primaryScrollSelector);
|
|
477
505
|
} catch {
|
|
478
506
|
throw new h(
|
|
479
|
-
`${m.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${
|
|
507
|
+
`${m.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${s.primaryScrollSelector}"`,
|
|
480
508
|
"config"
|
|
481
509
|
);
|
|
482
510
|
}
|
|
483
511
|
}
|
|
484
|
-
if (
|
|
512
|
+
if (s.pageViewThrottleMs !== void 0 && (typeof s.pageViewThrottleMs != "number" || s.pageViewThrottleMs < 0))
|
|
485
513
|
throw new h(m.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
486
|
-
if (
|
|
514
|
+
if (s.clickThrottleMs !== void 0 && (typeof s.clickThrottleMs != "number" || s.clickThrottleMs < 0))
|
|
487
515
|
throw new h(m.INVALID_CLICK_THROTTLE, "config");
|
|
488
|
-
if (
|
|
516
|
+
if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
|
|
489
517
|
throw new h(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
490
|
-
if (
|
|
491
|
-
if (typeof
|
|
518
|
+
if (s.viewport !== void 0 && Xt(s.viewport), s.webVitalsMode !== void 0) {
|
|
519
|
+
if (typeof s.webVitalsMode != "string")
|
|
492
520
|
throw new h(
|
|
493
|
-
`Invalid webVitalsMode type: ${typeof
|
|
521
|
+
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
494
522
|
"config"
|
|
495
523
|
);
|
|
496
524
|
const e = ["all", "needs-improvement", "poor"];
|
|
497
|
-
if (!e.includes(
|
|
525
|
+
if (!e.includes(s.webVitalsMode))
|
|
498
526
|
throw new h(
|
|
499
|
-
`Invalid webVitalsMode: "${
|
|
527
|
+
`Invalid webVitalsMode: "${s.webVitalsMode}". Must be one of: ${e.join(", ")}`,
|
|
500
528
|
"config"
|
|
501
529
|
);
|
|
502
530
|
}
|
|
503
|
-
if (
|
|
504
|
-
if (typeof
|
|
531
|
+
if (s.webVitalsThresholds !== void 0) {
|
|
532
|
+
if (typeof s.webVitalsThresholds != "object" || s.webVitalsThresholds === null || Array.isArray(s.webVitalsThresholds))
|
|
505
533
|
throw new h("webVitalsThresholds must be an object", "config");
|
|
506
534
|
const e = ["LCP", "FCP", "CLS", "INP", "TTFB", "LONG_TASK"];
|
|
507
|
-
for (const [t, r] of Object.entries(
|
|
535
|
+
for (const [t, r] of Object.entries(s.webVitalsThresholds)) {
|
|
508
536
|
if (!e.includes(t))
|
|
509
537
|
throw new h(
|
|
510
538
|
`Invalid Web Vitals threshold key: "${t}". Must be one of: ${e.join(", ")}`,
|
|
@@ -518,15 +546,15 @@ const kt = () => {
|
|
|
518
546
|
}
|
|
519
547
|
}
|
|
520
548
|
}
|
|
521
|
-
},
|
|
522
|
-
if (typeof
|
|
549
|
+
}, Xt = (s) => {
|
|
550
|
+
if (typeof s != "object" || s === null)
|
|
523
551
|
throw new h(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
524
|
-
if (!
|
|
552
|
+
if (!s.elements || !Array.isArray(s.elements))
|
|
525
553
|
throw new h(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
526
|
-
if (
|
|
554
|
+
if (s.elements.length === 0)
|
|
527
555
|
throw new h(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
528
556
|
const e = /* @__PURE__ */ new Set();
|
|
529
|
-
for (const t of
|
|
557
|
+
for (const t of s.elements) {
|
|
530
558
|
if (!t.selector || typeof t.selector != "string" || !t.selector.trim())
|
|
531
559
|
throw new h(m.INVALID_VIEWPORT_ELEMENT, "config");
|
|
532
560
|
const r = t.selector.trim();
|
|
@@ -540,45 +568,45 @@ const kt = () => {
|
|
|
540
568
|
if (t.name !== void 0 && (typeof t.name != "string" || !t.name.trim()))
|
|
541
569
|
throw new h(m.INVALID_VIEWPORT_ELEMENT_NAME, "config");
|
|
542
570
|
}
|
|
543
|
-
if (
|
|
571
|
+
if (s.threshold !== void 0 && (typeof s.threshold != "number" || s.threshold < 0 || s.threshold > 1))
|
|
544
572
|
throw new h(m.INVALID_VIEWPORT_THRESHOLD, "config");
|
|
545
|
-
if (
|
|
573
|
+
if (s.minDwellTime !== void 0 && (typeof s.minDwellTime != "number" || s.minDwellTime < 0))
|
|
546
574
|
throw new h(m.INVALID_VIEWPORT_MIN_DWELL_TIME, "config");
|
|
547
|
-
if (
|
|
575
|
+
if (s.cooldownPeriod !== void 0 && (typeof s.cooldownPeriod != "number" || s.cooldownPeriod < 0))
|
|
548
576
|
throw new h(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
549
|
-
if (
|
|
577
|
+
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
550
578
|
throw new h(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
551
|
-
},
|
|
552
|
-
if (
|
|
553
|
-
if (
|
|
579
|
+
}, Qt = (s) => {
|
|
580
|
+
if (s) {
|
|
581
|
+
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
554
582
|
throw new V(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
555
|
-
if (
|
|
556
|
-
if (!
|
|
583
|
+
if (s.custom) {
|
|
584
|
+
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
557
585
|
throw new V(m.INVALID_CUSTOM_API_URL, "config");
|
|
558
|
-
if (
|
|
586
|
+
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
559
587
|
throw new V("allowHttp must be a boolean", "config");
|
|
560
|
-
const e =
|
|
588
|
+
const e = s.custom.collectApiUrl.trim();
|
|
561
589
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
562
590
|
throw new V('Custom API URL must start with "http://" or "https://"', "config");
|
|
563
|
-
if (!(
|
|
591
|
+
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
564
592
|
throw new V(
|
|
565
593
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
566
594
|
"config"
|
|
567
595
|
);
|
|
568
596
|
}
|
|
569
597
|
}
|
|
570
|
-
},
|
|
571
|
-
|
|
598
|
+
}, jt = (s) => {
|
|
599
|
+
Gt(s);
|
|
572
600
|
const e = {
|
|
573
|
-
...
|
|
574
|
-
sessionTimeout:
|
|
575
|
-
globalMetadata:
|
|
576
|
-
sensitiveQueryParams:
|
|
577
|
-
errorSampling:
|
|
578
|
-
samplingRate:
|
|
579
|
-
pageViewThrottleMs:
|
|
580
|
-
clickThrottleMs:
|
|
581
|
-
maxSameEventPerMinute:
|
|
601
|
+
...s ?? {},
|
|
602
|
+
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
603
|
+
globalMetadata: s?.globalMetadata ?? {},
|
|
604
|
+
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
605
|
+
errorSampling: s?.errorSampling ?? Qe,
|
|
606
|
+
samplingRate: s?.samplingRate ?? 1,
|
|
607
|
+
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
608
|
+
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
609
|
+
maxSameEventPerMinute: s?.maxSameEventPerMinute ?? 60
|
|
582
610
|
};
|
|
583
611
|
return e.integrations?.custom && (e.integrations.custom = {
|
|
584
612
|
...e.integrations.custom,
|
|
@@ -590,11 +618,11 @@ const kt = () => {
|
|
|
590
618
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
591
619
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
592
620
|
}), e;
|
|
593
|
-
},
|
|
594
|
-
if (typeof
|
|
621
|
+
}, zt = (s) => {
|
|
622
|
+
if (typeof s == "string")
|
|
595
623
|
return !0;
|
|
596
|
-
if (typeof
|
|
597
|
-
const e = Object.entries(
|
|
624
|
+
if (typeof s == "object" && s !== null && !Array.isArray(s)) {
|
|
625
|
+
const e = Object.entries(s);
|
|
598
626
|
if (e.length > 20)
|
|
599
627
|
return !1;
|
|
600
628
|
for (const [, t] of e) {
|
|
@@ -607,10 +635,10 @@ const kt = () => {
|
|
|
607
635
|
return !0;
|
|
608
636
|
}
|
|
609
637
|
return !1;
|
|
610
|
-
},
|
|
611
|
-
if (typeof
|
|
638
|
+
}, Ke = (s, e = 0) => {
|
|
639
|
+
if (typeof s != "object" || s === null || e > 1)
|
|
612
640
|
return !1;
|
|
613
|
-
for (const t of Object.values(
|
|
641
|
+
for (const t of Object.values(s)) {
|
|
614
642
|
if (t == null)
|
|
615
643
|
continue;
|
|
616
644
|
const r = typeof t;
|
|
@@ -621,12 +649,12 @@ const kt = () => {
|
|
|
621
649
|
if (typeof t[0] == "string") {
|
|
622
650
|
if (!t.every((o) => typeof o == "string"))
|
|
623
651
|
return !1;
|
|
624
|
-
} else if (!t.every((o) =>
|
|
652
|
+
} else if (!t.every((o) => zt(o)))
|
|
625
653
|
return !1;
|
|
626
654
|
continue;
|
|
627
655
|
}
|
|
628
656
|
if (r === "object" && e === 0) {
|
|
629
|
-
if (!
|
|
657
|
+
if (!Ke(t, e + 1))
|
|
630
658
|
return !1;
|
|
631
659
|
continue;
|
|
632
660
|
}
|
|
@@ -634,27 +662,27 @@ const kt = () => {
|
|
|
634
662
|
}
|
|
635
663
|
}
|
|
636
664
|
return !0;
|
|
637
|
-
},
|
|
665
|
+
}, Kt = (s) => typeof s != "string" ? {
|
|
638
666
|
valid: !1,
|
|
639
667
|
error: "Event name must be a string"
|
|
640
|
-
} :
|
|
668
|
+
} : s.length === 0 ? {
|
|
641
669
|
valid: !1,
|
|
642
670
|
error: "Event name cannot be empty"
|
|
643
|
-
} :
|
|
671
|
+
} : s.length > 120 ? {
|
|
644
672
|
valid: !1,
|
|
645
673
|
error: "Event name is too long (max 120 characters)"
|
|
646
|
-
} :
|
|
674
|
+
} : s.includes("<") || s.includes(">") || s.includes("&") ? {
|
|
647
675
|
valid: !1,
|
|
648
676
|
error: "Event name contains invalid characters"
|
|
649
|
-
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(
|
|
677
|
+
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
650
678
|
valid: !1,
|
|
651
679
|
error: "Event name cannot be a reserved word"
|
|
652
|
-
} : { valid: !0 },
|
|
653
|
-
const r =
|
|
654
|
-
if (!
|
|
680
|
+
} : { valid: !0 }, Ue = (s, e, t) => {
|
|
681
|
+
const r = Wt(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
682
|
+
if (!Ke(r))
|
|
655
683
|
return {
|
|
656
684
|
valid: !1,
|
|
657
|
-
error: `${
|
|
685
|
+
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
658
686
|
};
|
|
659
687
|
let i;
|
|
660
688
|
try {
|
|
@@ -662,58 +690,58 @@ const kt = () => {
|
|
|
662
690
|
} catch {
|
|
663
691
|
return {
|
|
664
692
|
valid: !1,
|
|
665
|
-
error: `${
|
|
693
|
+
error: `${n}: object contains circular references or cannot be serialized.`
|
|
666
694
|
};
|
|
667
695
|
}
|
|
668
696
|
if (i.length > 8192)
|
|
669
697
|
return {
|
|
670
698
|
valid: !1,
|
|
671
|
-
error: `${
|
|
699
|
+
error: `${n}: object is too large (max ${8192 / 1024} KB).`
|
|
672
700
|
};
|
|
673
701
|
if (Object.keys(r).length > 10)
|
|
674
702
|
return {
|
|
675
703
|
valid: !1,
|
|
676
|
-
error: `${
|
|
704
|
+
error: `${n}: object has too many keys (max 10 keys).`
|
|
677
705
|
};
|
|
678
706
|
for (const [l, c] of Object.entries(r)) {
|
|
679
707
|
if (Array.isArray(c)) {
|
|
680
708
|
if (c.length > 10)
|
|
681
709
|
return {
|
|
682
710
|
valid: !1,
|
|
683
|
-
error: `${
|
|
711
|
+
error: `${n}: array property "${l}" is too large (max 10 items).`
|
|
684
712
|
};
|
|
685
713
|
for (const u of c)
|
|
686
714
|
if (typeof u == "string" && u.length > 500)
|
|
687
715
|
return {
|
|
688
716
|
valid: !1,
|
|
689
|
-
error: `${
|
|
717
|
+
error: `${n}: array property "${l}" contains strings that are too long (max 500 characters).`
|
|
690
718
|
};
|
|
691
719
|
}
|
|
692
720
|
if (typeof c == "string" && c.length > 1e3)
|
|
693
721
|
return {
|
|
694
722
|
valid: !1,
|
|
695
|
-
error: `${
|
|
723
|
+
error: `${n}: property "${l}" is too long (max 1000 characters).`
|
|
696
724
|
};
|
|
697
725
|
}
|
|
698
726
|
return {
|
|
699
727
|
valid: !0,
|
|
700
728
|
sanitizedMetadata: r
|
|
701
729
|
};
|
|
702
|
-
},
|
|
730
|
+
}, Ye = (s, e, t) => {
|
|
703
731
|
if (Array.isArray(e)) {
|
|
704
|
-
const r = [],
|
|
732
|
+
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
705
733
|
for (let i = 0; i < e.length; i++) {
|
|
706
734
|
const o = e[i];
|
|
707
735
|
if (typeof o != "object" || o === null || Array.isArray(o))
|
|
708
736
|
return {
|
|
709
737
|
valid: !1,
|
|
710
|
-
error: `${
|
|
738
|
+
error: `${n}: array item at index ${i} must be an object.`
|
|
711
739
|
};
|
|
712
|
-
const l =
|
|
740
|
+
const l = Ue(s, o, t);
|
|
713
741
|
if (!l.valid)
|
|
714
742
|
return {
|
|
715
743
|
valid: !1,
|
|
716
|
-
error: `${
|
|
744
|
+
error: `${n}: array item at index ${i} is invalid: ${l.error}`
|
|
717
745
|
};
|
|
718
746
|
l.sanitizedMetadata && r.push(l.sanitizedMetadata);
|
|
719
747
|
}
|
|
@@ -722,24 +750,24 @@ const kt = () => {
|
|
|
722
750
|
sanitizedMetadata: r
|
|
723
751
|
};
|
|
724
752
|
}
|
|
725
|
-
return
|
|
726
|
-
},
|
|
727
|
-
const t =
|
|
753
|
+
return Ue(s, e, t);
|
|
754
|
+
}, Yt = (s, e) => {
|
|
755
|
+
const t = Kt(s);
|
|
728
756
|
if (!t.valid)
|
|
729
757
|
return a("error", "Event name validation failed", {
|
|
730
|
-
data: { eventName:
|
|
758
|
+
data: { eventName: s, error: t.error }
|
|
731
759
|
}), t;
|
|
732
760
|
if (!e)
|
|
733
761
|
return { valid: !0 };
|
|
734
|
-
const r =
|
|
762
|
+
const r = Ye(s, e, "customEvent");
|
|
735
763
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
736
764
|
data: {
|
|
737
|
-
eventName:
|
|
765
|
+
eventName: s,
|
|
738
766
|
error: r.error
|
|
739
767
|
}
|
|
740
768
|
}), r;
|
|
741
769
|
};
|
|
742
|
-
class
|
|
770
|
+
class qt {
|
|
743
771
|
listeners = /* @__PURE__ */ new Map();
|
|
744
772
|
/**
|
|
745
773
|
* Subscribes to an event channel
|
|
@@ -792,8 +820,8 @@ class jt {
|
|
|
792
820
|
off(e, t) {
|
|
793
821
|
const r = this.listeners.get(e);
|
|
794
822
|
if (r) {
|
|
795
|
-
const
|
|
796
|
-
|
|
823
|
+
const n = r.indexOf(t);
|
|
824
|
+
n > -1 && r.splice(n, 1);
|
|
797
825
|
}
|
|
798
826
|
}
|
|
799
827
|
/**
|
|
@@ -826,8 +854,8 @@ class jt {
|
|
|
826
854
|
*/
|
|
827
855
|
emit(e, t) {
|
|
828
856
|
const r = this.listeners.get(e);
|
|
829
|
-
r && r.forEach((
|
|
830
|
-
|
|
857
|
+
r && r.forEach((n) => {
|
|
858
|
+
n(t);
|
|
831
859
|
});
|
|
832
860
|
}
|
|
833
861
|
/**
|
|
@@ -856,34 +884,34 @@ class jt {
|
|
|
856
884
|
this.listeners.clear();
|
|
857
885
|
}
|
|
858
886
|
}
|
|
859
|
-
function
|
|
887
|
+
function qe(s, e, t) {
|
|
860
888
|
try {
|
|
861
|
-
const r = e(
|
|
862
|
-
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`),
|
|
889
|
+
const r = e(s);
|
|
890
|
+
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), s);
|
|
863
891
|
} catch (r) {
|
|
864
892
|
return a("error", `beforeSend transformer threw error, using original event [${t}]`, {
|
|
865
893
|
error: r,
|
|
866
894
|
visibility: "critical"
|
|
867
|
-
}),
|
|
895
|
+
}), s;
|
|
868
896
|
}
|
|
869
897
|
}
|
|
870
|
-
function
|
|
871
|
-
return
|
|
898
|
+
function Jt(s, e, t) {
|
|
899
|
+
return s.map((r) => qe(r, e, t)).filter((r) => r !== null);
|
|
872
900
|
}
|
|
873
|
-
function
|
|
901
|
+
function Je(s, e, t) {
|
|
874
902
|
try {
|
|
875
|
-
const r = e(
|
|
903
|
+
const r = e(s);
|
|
876
904
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
877
|
-
data: { eventCount:
|
|
905
|
+
data: { eventCount: s.events.length }
|
|
878
906
|
}), null) : typeof r == "object" && r !== null && Array.isArray(r.events) ? r : (a("warn", `beforeBatch transformer returned invalid data, using original [${t}]`, {
|
|
879
|
-
data: { eventCount:
|
|
880
|
-
}),
|
|
907
|
+
data: { eventCount: s.events.length }
|
|
908
|
+
}), s);
|
|
881
909
|
} catch (r) {
|
|
882
910
|
return a("error", `beforeBatch transformer threw error, using original batch [${t}]`, {
|
|
883
911
|
error: r,
|
|
884
|
-
data: { eventCount:
|
|
912
|
+
data: { eventCount: s.events.length },
|
|
885
913
|
visibility: "critical"
|
|
886
|
-
}),
|
|
914
|
+
}), s;
|
|
887
915
|
}
|
|
888
916
|
}
|
|
889
917
|
const te = {};
|
|
@@ -945,7 +973,7 @@ class _ {
|
|
|
945
973
|
return { ...te };
|
|
946
974
|
}
|
|
947
975
|
}
|
|
948
|
-
class
|
|
976
|
+
class xe extends _ {
|
|
949
977
|
storeManager;
|
|
950
978
|
integrationId;
|
|
951
979
|
apiUrl;
|
|
@@ -966,10 +994,10 @@ class Ve extends _ {
|
|
|
966
994
|
* @param transformers - Optional event transformation hooks
|
|
967
995
|
* @throws Error if integrationId and apiUrl are not both provided or both undefined
|
|
968
996
|
*/
|
|
969
|
-
constructor(e, t, r,
|
|
997
|
+
constructor(e, t, r, n = {}) {
|
|
970
998
|
if (super(), t && !r || !t && r)
|
|
971
999
|
throw new Error("SenderManager: integrationId and apiUrl must either both be provided or both be undefined");
|
|
972
|
-
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers =
|
|
1000
|
+
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers = n;
|
|
973
1001
|
}
|
|
974
1002
|
/**
|
|
975
1003
|
* Get the integration ID for this sender
|
|
@@ -979,7 +1007,7 @@ class Ve extends _ {
|
|
|
979
1007
|
return this.integrationId;
|
|
980
1008
|
}
|
|
981
1009
|
getQueueStorageKey() {
|
|
982
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1010
|
+
const e = this.get("userId") || "anonymous", t = ut(e);
|
|
983
1011
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
984
1012
|
}
|
|
985
1013
|
/**
|
|
@@ -1180,7 +1208,7 @@ class Ve extends _ {
|
|
|
1180
1208
|
const t = this.transformers.beforeSend;
|
|
1181
1209
|
if (!t)
|
|
1182
1210
|
return e;
|
|
1183
|
-
const r =
|
|
1211
|
+
const r = Jt(
|
|
1184
1212
|
e.events,
|
|
1185
1213
|
t,
|
|
1186
1214
|
this.integrationId || "SenderManager"
|
|
@@ -1225,7 +1253,7 @@ class Ve extends _ {
|
|
|
1225
1253
|
if (this.integrationId === "saas")
|
|
1226
1254
|
return e;
|
|
1227
1255
|
const t = this.transformers.beforeBatch;
|
|
1228
|
-
return t ?
|
|
1256
|
+
return t ? Je(e, t, this.integrationId || "SenderManager") : e;
|
|
1229
1257
|
}
|
|
1230
1258
|
/**
|
|
1231
1259
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1247,8 +1275,8 @@ class Ve extends _ {
|
|
|
1247
1275
|
* @returns Promise that resolves after calculated delay
|
|
1248
1276
|
*/
|
|
1249
1277
|
async backoffDelay(e) {
|
|
1250
|
-
const t = 100 * Math.pow(2, e), r = Math.random() * 100,
|
|
1251
|
-
return new Promise((i) => setTimeout(i,
|
|
1278
|
+
const t = 100 * Math.pow(2, e), r = Math.random() * 100, n = t + r;
|
|
1279
|
+
return new Promise((i) => setTimeout(i, n));
|
|
1252
1280
|
}
|
|
1253
1281
|
/**
|
|
1254
1282
|
* Sends event queue with automatic retry logic for transient failures.
|
|
@@ -1301,10 +1329,10 @@ class Ve extends _ {
|
|
|
1301
1329
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1302
1330
|
data: { events: r.events.length }
|
|
1303
1331
|
}), !0;
|
|
1304
|
-
const { url:
|
|
1332
|
+
const { url: n, payload: i } = this.prepareRequest(r);
|
|
1305
1333
|
for (let o = 1; o <= 3; o++)
|
|
1306
1334
|
try {
|
|
1307
|
-
return (await this.sendWithTimeout(
|
|
1335
|
+
return (await this.sendWithTimeout(n, i)).ok ? (o > 1 && a(
|
|
1308
1336
|
"info",
|
|
1309
1337
|
`Send succeeded after ${o - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1310
1338
|
{
|
|
@@ -1322,7 +1350,7 @@ class Ve extends _ {
|
|
|
1322
1350
|
error: l,
|
|
1323
1351
|
data: {
|
|
1324
1352
|
events: e.events.length,
|
|
1325
|
-
url:
|
|
1353
|
+
url: n.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1326
1354
|
attempt: o,
|
|
1327
1355
|
maxAttempts: 3
|
|
1328
1356
|
}
|
|
@@ -1359,7 +1387,7 @@ class Ve extends _ {
|
|
|
1359
1387
|
async sendWithTimeout(e, t) {
|
|
1360
1388
|
const r = new AbortController();
|
|
1361
1389
|
this.pendingControllers.add(r);
|
|
1362
|
-
const
|
|
1390
|
+
const n = setTimeout(() => {
|
|
1363
1391
|
r.abort();
|
|
1364
1392
|
}, 15e3);
|
|
1365
1393
|
try {
|
|
@@ -1377,7 +1405,7 @@ class Ve extends _ {
|
|
|
1377
1405
|
throw i.status >= 400 && i.status < 500 && i.status !== 408 && i.status !== 429 ? new N(`HTTP ${i.status}: ${i.statusText}`, i.status) : new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
1378
1406
|
return i;
|
|
1379
1407
|
} finally {
|
|
1380
|
-
clearTimeout(
|
|
1408
|
+
clearTimeout(n), this.pendingControllers.delete(r);
|
|
1381
1409
|
}
|
|
1382
1410
|
}
|
|
1383
1411
|
/**
|
|
@@ -1407,7 +1435,7 @@ class Ve extends _ {
|
|
|
1407
1435
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1408
1436
|
if (!r)
|
|
1409
1437
|
return !0;
|
|
1410
|
-
const { url:
|
|
1438
|
+
const { url: n, payload: i } = this.prepareRequest(r);
|
|
1411
1439
|
if (i.length > 65536)
|
|
1412
1440
|
return a(
|
|
1413
1441
|
"warn",
|
|
@@ -1426,7 +1454,7 @@ class Ve extends _ {
|
|
|
1426
1454
|
"warn",
|
|
1427
1455
|
`sendBeacon not available, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1428
1456
|
), this.persistEvents(r), !1;
|
|
1429
|
-
const l = navigator.sendBeacon(
|
|
1457
|
+
const l = navigator.sendBeacon(n, o);
|
|
1430
1458
|
return l || (a(
|
|
1431
1459
|
"warn",
|
|
1432
1460
|
`sendBeacon rejected request, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
@@ -1458,7 +1486,7 @@ class Ve extends _ {
|
|
|
1458
1486
|
_metadata: {
|
|
1459
1487
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1460
1488
|
timestamp: t,
|
|
1461
|
-
client_version:
|
|
1489
|
+
client_version: Pt
|
|
1462
1490
|
}
|
|
1463
1491
|
};
|
|
1464
1492
|
return {
|
|
@@ -1551,8 +1579,8 @@ class Ve extends _ {
|
|
|
1551
1579
|
const r = {
|
|
1552
1580
|
...e,
|
|
1553
1581
|
timestamp: Date.now()
|
|
1554
|
-
},
|
|
1555
|
-
return this.storeManager.setItem(
|
|
1582
|
+
}, n = this.getQueueStorageKey();
|
|
1583
|
+
return this.storeManager.setItem(n, JSON.stringify(r)), !!this.storeManager.getItem(n);
|
|
1556
1584
|
} catch (t) {
|
|
1557
1585
|
return a("debug", `Failed to persist events${this.integrationId ? ` [${this.integrationId}]` : ""}`, { error: t }), !1;
|
|
1558
1586
|
}
|
|
@@ -1579,12 +1607,12 @@ class Ve extends _ {
|
|
|
1579
1607
|
}
|
|
1580
1608
|
logPermanentError(e, t) {
|
|
1581
1609
|
const r = Date.now();
|
|
1582
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1610
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= Mt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1583
1611
|
data: { status: t.statusCode, message: t.message }
|
|
1584
1612
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1585
1613
|
}
|
|
1586
1614
|
}
|
|
1587
|
-
class
|
|
1615
|
+
class Zt extends _ {
|
|
1588
1616
|
bootTime;
|
|
1589
1617
|
bootTimestamp;
|
|
1590
1618
|
hasPerformanceNow;
|
|
@@ -1711,10 +1739,10 @@ class Kt extends _ {
|
|
|
1711
1739
|
* ```
|
|
1712
1740
|
*/
|
|
1713
1741
|
validateTimestamp(e) {
|
|
1714
|
-
const r = this.now(),
|
|
1715
|
-
return
|
|
1742
|
+
const r = this.now(), n = e - r;
|
|
1743
|
+
return n > 12e4 ? {
|
|
1716
1744
|
valid: !1,
|
|
1717
|
-
error: `Timestamp is ${(
|
|
1745
|
+
error: `Timestamp is ${(n / 1e3 / 60).toFixed(2)} minutes in the future (max allowed: 2 minutes)`
|
|
1718
1746
|
} : { valid: !0 };
|
|
1719
1747
|
}
|
|
1720
1748
|
/**
|
|
@@ -1733,7 +1761,7 @@ class Kt extends _ {
|
|
|
1733
1761
|
};
|
|
1734
1762
|
}
|
|
1735
1763
|
}
|
|
1736
|
-
class
|
|
1764
|
+
class er extends _ {
|
|
1737
1765
|
dataSenders;
|
|
1738
1766
|
emitter;
|
|
1739
1767
|
transformers;
|
|
@@ -1767,9 +1795,9 @@ class Yt extends _ {
|
|
|
1767
1795
|
* @param transformers - Optional event transformation hooks
|
|
1768
1796
|
*/
|
|
1769
1797
|
constructor(e, t = null, r = {}) {
|
|
1770
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1798
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new Zt(), this.dataSenders = [];
|
|
1799
|
+
const n = this.get("collectApiUrls");
|
|
1800
|
+
n?.saas && this.dataSenders.push(new xe(e, "saas", n.saas, r)), n?.custom && this.dataSenders.push(new xe(e, "custom", n.custom, r)), this.saveSessionCountsDebounced = this.debounce((i) => {
|
|
1773
1801
|
this.saveSessionCounts(i);
|
|
1774
1802
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1775
1803
|
}
|
|
@@ -1800,9 +1828,9 @@ class Yt extends _ {
|
|
|
1800
1828
|
async recoverPersistedEvents() {
|
|
1801
1829
|
const e = this.dataSenders.map(
|
|
1802
1830
|
async (t) => t.recoverPersistedEvents({
|
|
1803
|
-
onSuccess: (r,
|
|
1804
|
-
if (
|
|
1805
|
-
const o =
|
|
1831
|
+
onSuccess: (r, n, i) => {
|
|
1832
|
+
if (n && n.length > 0) {
|
|
1833
|
+
const o = n.map((l) => l.id);
|
|
1806
1834
|
this.removeProcessedEvents(o), i && this.emitEventsQueue(i);
|
|
1807
1835
|
}
|
|
1808
1836
|
},
|
|
@@ -1876,7 +1904,7 @@ class Yt extends _ {
|
|
|
1876
1904
|
type: e,
|
|
1877
1905
|
page_url: t,
|
|
1878
1906
|
from_page_url: r,
|
|
1879
|
-
scroll_data:
|
|
1907
|
+
scroll_data: n,
|
|
1880
1908
|
click_data: i,
|
|
1881
1909
|
custom_event: o,
|
|
1882
1910
|
web_vitals: l,
|
|
@@ -1896,7 +1924,7 @@ class Yt extends _ {
|
|
|
1896
1924
|
type: e,
|
|
1897
1925
|
page_url: t,
|
|
1898
1926
|
from_page_url: r,
|
|
1899
|
-
scroll_data:
|
|
1927
|
+
scroll_data: n,
|
|
1900
1928
|
click_data: i,
|
|
1901
1929
|
custom_event: o,
|
|
1902
1930
|
web_vitals: l,
|
|
@@ -1907,30 +1935,30 @@ class Yt extends _ {
|
|
|
1907
1935
|
return;
|
|
1908
1936
|
}
|
|
1909
1937
|
this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
|
|
1910
|
-
const
|
|
1911
|
-
if (
|
|
1938
|
+
const p = e === d.SESSION_START;
|
|
1939
|
+
if (p && a("debug", "Processing SESSION_START event", {
|
|
1912
1940
|
data: { sessionId: g }
|
|
1913
|
-
}), !
|
|
1941
|
+
}), !p && !this.checkRateLimit())
|
|
1914
1942
|
return;
|
|
1915
|
-
const
|
|
1916
|
-
if (!
|
|
1943
|
+
const E = e;
|
|
1944
|
+
if (!p) {
|
|
1917
1945
|
if (this.sessionEventCounts.total >= 1e3) {
|
|
1918
1946
|
a("warn", "Session event limit reached", {
|
|
1919
1947
|
data: {
|
|
1920
|
-
type:
|
|
1948
|
+
type: E,
|
|
1921
1949
|
total: this.sessionEventCounts.total,
|
|
1922
1950
|
limit: 1e3
|
|
1923
1951
|
}
|
|
1924
1952
|
});
|
|
1925
1953
|
return;
|
|
1926
1954
|
}
|
|
1927
|
-
const T = this.getTypeLimitForEvent(
|
|
1955
|
+
const T = this.getTypeLimitForEvent(E);
|
|
1928
1956
|
if (T) {
|
|
1929
|
-
const ee = this.sessionEventCounts[
|
|
1957
|
+
const ee = this.sessionEventCounts[E];
|
|
1930
1958
|
if (ee !== void 0 && ee >= T) {
|
|
1931
1959
|
a("warn", "Session event type limit reached", {
|
|
1932
1960
|
data: {
|
|
1933
|
-
type:
|
|
1961
|
+
type: E,
|
|
1934
1962
|
count: ee,
|
|
1935
1963
|
limit: T
|
|
1936
1964
|
}
|
|
@@ -1939,16 +1967,16 @@ class Yt extends _ {
|
|
|
1939
1967
|
}
|
|
1940
1968
|
}
|
|
1941
1969
|
}
|
|
1942
|
-
if (
|
|
1970
|
+
if (E === d.CUSTOM && o?.name) {
|
|
1943
1971
|
const T = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
1944
1972
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1945
1973
|
return;
|
|
1946
1974
|
}
|
|
1947
|
-
const
|
|
1948
|
-
type:
|
|
1949
|
-
page_url:
|
|
1975
|
+
const Te = E === d.SESSION_START, $ = t || this.get("pageUrl"), D = this.buildEventPayload({
|
|
1976
|
+
type: E,
|
|
1977
|
+
page_url: $,
|
|
1950
1978
|
from_page_url: r,
|
|
1951
|
-
scroll_data:
|
|
1979
|
+
scroll_data: n,
|
|
1952
1980
|
click_data: i,
|
|
1953
1981
|
custom_event: o,
|
|
1954
1982
|
web_vitals: l,
|
|
@@ -1956,8 +1984,8 @@ class Yt extends _ {
|
|
|
1956
1984
|
viewport_data: u,
|
|
1957
1985
|
page_view: S
|
|
1958
1986
|
});
|
|
1959
|
-
if (D && !(!
|
|
1960
|
-
if (
|
|
1987
|
+
if (D && !(!p && !this.shouldSample())) {
|
|
1988
|
+
if (Te) {
|
|
1961
1989
|
const T = this.get("sessionId");
|
|
1962
1990
|
if (!T) {
|
|
1963
1991
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -1973,7 +2001,7 @@ class Yt extends _ {
|
|
|
1973
2001
|
}
|
|
1974
2002
|
if (!this.isDuplicateEvent(D)) {
|
|
1975
2003
|
if (this.get("mode") === z.QA) {
|
|
1976
|
-
if (
|
|
2004
|
+
if (E === d.CUSTOM && o) {
|
|
1977
2005
|
a("info", `Custom Event: ${o.name}`, {
|
|
1978
2006
|
visibility: "qa",
|
|
1979
2007
|
data: {
|
|
@@ -1983,7 +2011,7 @@ class Yt extends _ {
|
|
|
1983
2011
|
}), this.emitEvent(D);
|
|
1984
2012
|
return;
|
|
1985
2013
|
}
|
|
1986
|
-
if (
|
|
2014
|
+
if (E === d.VIEWPORT_VISIBLE && u) {
|
|
1987
2015
|
const T = u.name || u.id || u.selector;
|
|
1988
2016
|
a("info", `Viewport Visible: ${T}`, {
|
|
1989
2017
|
visibility: "qa",
|
|
@@ -1998,8 +2026,8 @@ class Yt extends _ {
|
|
|
1998
2026
|
return;
|
|
1999
2027
|
}
|
|
2000
2028
|
}
|
|
2001
|
-
if (this.addToQueue(D), !
|
|
2002
|
-
this.sessionEventCounts.total++, this.sessionEventCounts[
|
|
2029
|
+
if (this.addToQueue(D), !p) {
|
|
2030
|
+
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2003
2031
|
const T = this.get("sessionId");
|
|
2004
2032
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
2005
2033
|
}
|
|
@@ -2246,13 +2274,13 @@ class Yt extends _ {
|
|
|
2246
2274
|
flushEvents(e) {
|
|
2247
2275
|
if (this.eventsQueue.length === 0)
|
|
2248
2276
|
return e ? !0 : Promise.resolve(!0);
|
|
2249
|
-
const t = this.buildEventsPayload(), r = [...this.eventsQueue],
|
|
2277
|
+
const t = this.buildEventsPayload(), r = [...this.eventsQueue], n = r.map((i) => i.id);
|
|
2250
2278
|
if (this.dataSenders.length === 0)
|
|
2251
|
-
return this.removeProcessedEvents(
|
|
2279
|
+
return this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
2252
2280
|
if (e) {
|
|
2253
2281
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2254
|
-
return o ? (this.removeProcessedEvents(
|
|
2255
|
-
data: { eventCount:
|
|
2282
|
+
return o ? (this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t)) : (this.clearSendInterval(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
|
|
2283
|
+
data: { eventCount: n.length }
|
|
2256
2284
|
})), o;
|
|
2257
2285
|
} else {
|
|
2258
2286
|
const i = this.dataSenders.map(
|
|
@@ -2265,7 +2293,7 @@ class Yt extends _ {
|
|
|
2265
2293
|
);
|
|
2266
2294
|
return Promise.allSettled(i).then((o) => {
|
|
2267
2295
|
const l = o.some((c) => this.isSuccessfulResult(c));
|
|
2268
|
-
return l ? (this.removeProcessedEvents(
|
|
2296
|
+
return l ? (this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
|
|
2269
2297
|
data: { eventCount: r.length }
|
|
2270
2298
|
}), l;
|
|
2271
2299
|
});
|
|
@@ -2279,14 +2307,14 @@ class Yt extends _ {
|
|
|
2279
2307
|
this.emitEventsQueue(e);
|
|
2280
2308
|
return;
|
|
2281
2309
|
}
|
|
2282
|
-
const t = [...this.eventsQueue], r = t.map((l) => l.id),
|
|
2310
|
+
const t = [...this.eventsQueue], r = t.map((l) => l.id), n = this.dataSenders.map(
|
|
2283
2311
|
async (l) => l.sendEventsQueue(e, {
|
|
2284
2312
|
onSuccess: () => {
|
|
2285
2313
|
},
|
|
2286
2314
|
onFailure: () => {
|
|
2287
2315
|
}
|
|
2288
2316
|
})
|
|
2289
|
-
), i = await Promise.allSettled(
|
|
2317
|
+
), i = await Promise.allSettled(n);
|
|
2290
2318
|
if (i.some((l) => this.isSuccessfulResult(l))) {
|
|
2291
2319
|
this.removeProcessedEvents(r), this.emitEventsQueue(e);
|
|
2292
2320
|
const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
@@ -2306,7 +2334,7 @@ class Yt extends _ {
|
|
|
2306
2334
|
e.has(u) || t.push(u), e.set(u, c);
|
|
2307
2335
|
}
|
|
2308
2336
|
const r = t.map((c) => e.get(c)).filter((c) => !!c).sort((c, u) => c.type === d.SESSION_START && u.type !== d.SESSION_START ? -1 : u.type === d.SESSION_START && c.type !== d.SESSION_START ? 1 : c.timestamp - u.timestamp);
|
|
2309
|
-
let
|
|
2337
|
+
let n = {
|
|
2310
2338
|
user_id: this.get("userId"),
|
|
2311
2339
|
session_id: this.get("sessionId"),
|
|
2312
2340
|
device: this.get("device"),
|
|
@@ -2315,22 +2343,23 @@ class Yt extends _ {
|
|
|
2315
2343
|
};
|
|
2316
2344
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2317
2345
|
if (!o && l) {
|
|
2318
|
-
const c =
|
|
2319
|
-
c !== null && (
|
|
2346
|
+
const c = Je(n, l, "EventManager");
|
|
2347
|
+
c !== null && (n = c);
|
|
2320
2348
|
}
|
|
2321
|
-
return
|
|
2349
|
+
return n;
|
|
2322
2350
|
}
|
|
2323
2351
|
buildEventPayload(e) {
|
|
2324
|
-
const t = e.
|
|
2325
|
-
|
|
2326
|
-
data: { type: e.type, error:
|
|
2352
|
+
const t = e.page_url ?? this.get("pageUrl"), r = this.timeManager.now(), n = this.timeManager.validateTimestamp(r);
|
|
2353
|
+
n.valid || a("warn", "Event timestamp validation failed", {
|
|
2354
|
+
data: { type: e.type, error: n.error }
|
|
2327
2355
|
});
|
|
2328
|
-
|
|
2329
|
-
|
|
2356
|
+
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2357
|
+
let l = {
|
|
2358
|
+
id: Ft(),
|
|
2330
2359
|
type: e.type,
|
|
2331
|
-
page_url:
|
|
2332
|
-
timestamp:
|
|
2333
|
-
...
|
|
2360
|
+
page_url: t,
|
|
2361
|
+
timestamp: r,
|
|
2362
|
+
...i && { referrer: i },
|
|
2334
2363
|
...e.from_page_url && { from_page_url: e.from_page_url },
|
|
2335
2364
|
...e.scroll_data && { scroll_data: e.scroll_data },
|
|
2336
2365
|
...e.click_data && { click_data: e.click_data },
|
|
@@ -2339,27 +2368,27 @@ class Yt extends _ {
|
|
|
2339
2368
|
...e.error_data && { error_data: e.error_data },
|
|
2340
2369
|
...e.viewport_data && { viewport_data: e.viewport_data },
|
|
2341
2370
|
...e.page_view && { page_view: e.page_view },
|
|
2342
|
-
...
|
|
2371
|
+
...o && { utm: o }
|
|
2343
2372
|
};
|
|
2344
|
-
const
|
|
2345
|
-
if (E && (!
|
|
2346
|
-
const $ =
|
|
2373
|
+
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2374
|
+
if (E && (!g || u && !p)) {
|
|
2375
|
+
const $ = qe(l, E, "EventManager");
|
|
2347
2376
|
if ($ === null)
|
|
2348
2377
|
return null;
|
|
2349
|
-
|
|
2378
|
+
l = $;
|
|
2350
2379
|
}
|
|
2351
|
-
return
|
|
2380
|
+
return l;
|
|
2352
2381
|
}
|
|
2353
2382
|
isDuplicateEvent(e) {
|
|
2354
|
-
const t = Date.now(), r = this.createEventFingerprint(e),
|
|
2355
|
-
return
|
|
2383
|
+
const t = Date.now(), r = this.createEventFingerprint(e), n = this.recentEventFingerprints.get(r);
|
|
2384
|
+
return n && t - n < 1e3 ? (this.recentEventFingerprints.set(r, t), !0) : (this.recentEventFingerprints.set(r, t), this.recentEventFingerprints.size > 1500 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 3e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(r, t), a("debug", "Event fingerprint cache exceeded hard limit, cleared", {
|
|
2356
2385
|
data: { hardLimit: 3e3 }
|
|
2357
2386
|
})), !1);
|
|
2358
2387
|
}
|
|
2359
2388
|
pruneOldFingerprints() {
|
|
2360
2389
|
const e = Date.now(), t = 1e3 * 10;
|
|
2361
|
-
for (const [r,
|
|
2362
|
-
e -
|
|
2390
|
+
for (const [r, n] of this.recentEventFingerprints.entries())
|
|
2391
|
+
e - n > t && this.recentEventFingerprints.delete(r);
|
|
2363
2392
|
a("debug", "Pruned old event fingerprints", {
|
|
2364
2393
|
data: {
|
|
2365
2394
|
remaining: this.recentEventFingerprints.size,
|
|
@@ -2370,8 +2399,8 @@ class Yt extends _ {
|
|
|
2370
2399
|
createEventFingerprint(e) {
|
|
2371
2400
|
let t = `${e.type}_${e.page_url}`;
|
|
2372
2401
|
if (e.click_data) {
|
|
2373
|
-
const r = Math.round((e.click_data.x || 0) / 10) * 10,
|
|
2374
|
-
t += `_click_${r}_${
|
|
2402
|
+
const r = Math.round((e.click_data.x || 0) / 10) * 10, n = Math.round((e.click_data.y || 0) / 10) * 10;
|
|
2403
|
+
t += `_click_${r}_${n}`;
|
|
2375
2404
|
}
|
|
2376
2405
|
return e.scroll_data && (t += `_scroll_${e.scroll_data.depth}_${e.scroll_data.direction}`), e.custom_event && (t += `_custom_${e.custom_event.name}`), e.web_vitals && (t += `_vitals_${e.web_vitals.type}`), e.error_data && (t += `_error_${e.error_data.type}_${e.error_data.message}`), t;
|
|
2377
2406
|
}
|
|
@@ -2380,7 +2409,7 @@ class Yt extends _ {
|
|
|
2380
2409
|
}
|
|
2381
2410
|
addToQueue(e) {
|
|
2382
2411
|
if (this.emitEvent(e), this.eventsQueue.push(e), this.eventsQueue.length > 100) {
|
|
2383
|
-
const t = this.eventsQueue.findIndex((
|
|
2412
|
+
const t = this.eventsQueue.findIndex((n) => n.type !== d.SESSION_START), r = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
|
|
2384
2413
|
a("warn", "Event queue overflow, oldest non-critical event removed", {
|
|
2385
2414
|
data: {
|
|
2386
2415
|
maxLength: 100,
|
|
@@ -2429,10 +2458,10 @@ class Yt extends _ {
|
|
|
2429
2458
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2430
2459
|
}
|
|
2431
2460
|
emitEvent(e) {
|
|
2432
|
-
this.emitter && this.emitter.emit(
|
|
2461
|
+
this.emitter && this.emitter.emit(ne.EVENT, e);
|
|
2433
2462
|
}
|
|
2434
2463
|
emitEventsQueue(e) {
|
|
2435
|
-
this.emitter && this.emitter.emit(
|
|
2464
|
+
this.emitter && this.emitter.emit(ne.QUEUE, e);
|
|
2436
2465
|
}
|
|
2437
2466
|
/**
|
|
2438
2467
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2456,9 +2485,9 @@ class Yt extends _ {
|
|
|
2456
2485
|
*/
|
|
2457
2486
|
debounce(e, t) {
|
|
2458
2487
|
let r = null;
|
|
2459
|
-
return ((...
|
|
2488
|
+
return ((...n) => {
|
|
2460
2489
|
r !== null && clearTimeout(r), r = setTimeout(() => {
|
|
2461
|
-
e(...
|
|
2490
|
+
e(...n), r = null;
|
|
2462
2491
|
}, t);
|
|
2463
2492
|
});
|
|
2464
2493
|
}
|
|
@@ -2508,13 +2537,13 @@ class Yt extends _ {
|
|
|
2508
2537
|
loadSessionCounts(e) {
|
|
2509
2538
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2510
2539
|
return this.getInitialCounts();
|
|
2511
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2540
|
+
const t = this.get("userId") || "anonymous", r = we(t, e);
|
|
2512
2541
|
try {
|
|
2513
|
-
const
|
|
2514
|
-
if (!
|
|
2542
|
+
const n = localStorage.getItem(r);
|
|
2543
|
+
if (!n)
|
|
2515
2544
|
return this.getInitialCounts();
|
|
2516
|
-
const i = JSON.parse(
|
|
2517
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2545
|
+
const i = JSON.parse(n);
|
|
2546
|
+
return i._timestamp && Date.now() - i._timestamp > ye ? (a("debug", "Session counts expired, clearing", {
|
|
2518
2547
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2519
2548
|
}), 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" ? {
|
|
2520
2549
|
total: i.total,
|
|
@@ -2528,9 +2557,9 @@ class Yt extends _ {
|
|
|
2528
2557
|
}), localStorage.removeItem(r), a("debug", "Session counts removed due to invalid/corrupted data", {
|
|
2529
2558
|
data: { sessionId: e, parsed: i }
|
|
2530
2559
|
}), this.getInitialCounts());
|
|
2531
|
-
} catch (
|
|
2560
|
+
} catch (n) {
|
|
2532
2561
|
return a("warn", "Failed to load session counts from localStorage", {
|
|
2533
|
-
error:
|
|
2562
|
+
error: n,
|
|
2534
2563
|
data: { sessionId: e }
|
|
2535
2564
|
}), this.getInitialCounts();
|
|
2536
2565
|
}
|
|
@@ -2559,17 +2588,17 @@ class Yt extends _ {
|
|
|
2559
2588
|
cleanupExpiredSessionCounts() {
|
|
2560
2589
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2561
2590
|
try {
|
|
2562
|
-
const e = localStorage.getItem(
|
|
2591
|
+
const e = localStorage.getItem(be);
|
|
2563
2592
|
if (e) {
|
|
2564
2593
|
const i = Date.now() - parseInt(e, 10);
|
|
2565
|
-
if (i <
|
|
2594
|
+
if (i < Ae) {
|
|
2566
2595
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2567
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2596
|
+
data: { timeSinceLastCleanup: i, throttleMs: Ae }
|
|
2568
2597
|
});
|
|
2569
2598
|
return;
|
|
2570
2599
|
}
|
|
2571
2600
|
}
|
|
2572
|
-
const t = this.get("userId") || "anonymous", r = `${I}:${t}:session_counts:`,
|
|
2601
|
+
const t = this.get("userId") || "anonymous", r = `${I}:${t}:session_counts:`, n = [];
|
|
2573
2602
|
for (let i = 0; i < localStorage.length; i++) {
|
|
2574
2603
|
const o = localStorage.key(i);
|
|
2575
2604
|
if (o?.startsWith(r))
|
|
@@ -2577,100 +2606,18 @@ class Yt extends _ {
|
|
|
2577
2606
|
const l = localStorage.getItem(o);
|
|
2578
2607
|
if (l) {
|
|
2579
2608
|
const c = JSON.parse(l);
|
|
2580
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2609
|
+
c._timestamp && Date.now() - c._timestamp > ye && n.push(o);
|
|
2581
2610
|
}
|
|
2582
2611
|
} catch {
|
|
2583
2612
|
}
|
|
2584
2613
|
}
|
|
2585
|
-
|
|
2614
|
+
n.forEach((i) => {
|
|
2586
2615
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2587
|
-
}),
|
|
2616
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(be, Date.now().toString());
|
|
2588
2617
|
} catch (e) {
|
|
2589
2618
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2590
2619
|
}
|
|
2591
2620
|
}
|
|
2592
|
-
/**
|
|
2593
|
-
* Returns the referrer if it's external, or 'Direct' if internal/empty.
|
|
2594
|
-
*
|
|
2595
|
-
* **Purpose**: Filter out internal referrers (same domain) to ensure
|
|
2596
|
-
* accurate traffic source attribution. Internal referrers occur when:
|
|
2597
|
-
* - Session expires and user navigates within the same site
|
|
2598
|
-
* - User opens new tab from an internal link
|
|
2599
|
-
* - Page refresh after session timeout
|
|
2600
|
-
*
|
|
2601
|
-
* **Logic**:
|
|
2602
|
-
* - Empty referrer → 'Direct'
|
|
2603
|
-
* - Referrer from same domain or subdomain → 'Direct' (internal navigation)
|
|
2604
|
-
* - External referrer → Returns original referrer
|
|
2605
|
-
*
|
|
2606
|
-
* **Subdomain Detection**:
|
|
2607
|
-
* - `www.example.com` → `example.com` ✓ (internal)
|
|
2608
|
-
* - `blog.example.com` → `example.com` ✓ (internal)
|
|
2609
|
-
* - `example.com` → `www.example.com` ✓ (internal)
|
|
2610
|
-
*
|
|
2611
|
-
* @returns External referrer URL or 'Direct'
|
|
2612
|
-
*
|
|
2613
|
-
* @internal
|
|
2614
|
-
*/
|
|
2615
|
-
getExternalReferrer() {
|
|
2616
|
-
const e = document.referrer;
|
|
2617
|
-
if (!e)
|
|
2618
|
-
return "Direct";
|
|
2619
|
-
try {
|
|
2620
|
-
const t = new URL(e).hostname.toLowerCase(), r = window.location.hostname.toLowerCase();
|
|
2621
|
-
return this.isSameDomain(t, r) ? "Direct" : e;
|
|
2622
|
-
} catch (t) {
|
|
2623
|
-
return a("debug", "Failed to parse referrer URL, using raw value", { error: t, data: { referrer: e } }), e;
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
/**
|
|
2627
|
-
* Checks if two hostnames belong to the same domain (including subdomains).
|
|
2628
|
-
* Extracts root domain and compares to handle cross-subdomain navigation.
|
|
2629
|
-
*
|
|
2630
|
-
* @example
|
|
2631
|
-
* isSameDomain('www.example.com', 'example.com') // true
|
|
2632
|
-
* isSameDomain('app.example.com', 'www.example.com') // true
|
|
2633
|
-
* isSameDomain('example.co.uk', 'app.example.co.uk') // true
|
|
2634
|
-
*
|
|
2635
|
-
* @param hostname1 - First hostname (e.g., 'www.example.com')
|
|
2636
|
-
* @param hostname2 - Second hostname (e.g., 'app.example.com')
|
|
2637
|
-
* @returns true if same root domain
|
|
2638
|
-
*
|
|
2639
|
-
* @internal
|
|
2640
|
-
*/
|
|
2641
|
-
isSameDomain(e, t) {
|
|
2642
|
-
return e === t ? !0 : this.getRootDomain(e) === this.getRootDomain(t);
|
|
2643
|
-
}
|
|
2644
|
-
/**
|
|
2645
|
-
* Extracts the root (registrable) domain from a hostname.
|
|
2646
|
-
* Handles both standard TLDs (.com, .org) and compound TLDs (.co.uk, .com.br).
|
|
2647
|
-
*
|
|
2648
|
-
* @example
|
|
2649
|
-
* getRootDomain('www.example.com') // 'example.com'
|
|
2650
|
-
* getRootDomain('app.blog.example.com') // 'example.com'
|
|
2651
|
-
* getRootDomain('shop.example.co.uk') // 'example.co.uk'
|
|
2652
|
-
*
|
|
2653
|
-
* @internal
|
|
2654
|
-
*/
|
|
2655
|
-
getRootDomain(e) {
|
|
2656
|
-
const t = e.toLowerCase().split(".");
|
|
2657
|
-
if (t.length <= 2)
|
|
2658
|
-
return e.toLowerCase();
|
|
2659
|
-
const r = [
|
|
2660
|
-
"co.uk",
|
|
2661
|
-
"org.uk",
|
|
2662
|
-
"com.au",
|
|
2663
|
-
"net.au",
|
|
2664
|
-
"com.br",
|
|
2665
|
-
"co.nz",
|
|
2666
|
-
"co.jp",
|
|
2667
|
-
"com.mx",
|
|
2668
|
-
"co.in",
|
|
2669
|
-
"com.cn",
|
|
2670
|
-
"co.za"
|
|
2671
|
-
], s = t.slice(-2).join(".");
|
|
2672
|
-
return r.includes(s) ? t.slice(-3).join(".") : t.slice(-2).join(".");
|
|
2673
|
-
}
|
|
2674
2621
|
/**
|
|
2675
2622
|
* Persists current session event counts to localStorage (debounced).
|
|
2676
2623
|
*
|
|
@@ -2700,23 +2647,23 @@ class Yt extends _ {
|
|
|
2700
2647
|
* @internal
|
|
2701
2648
|
*/
|
|
2702
2649
|
saveSessionCounts(e) {
|
|
2703
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2650
|
+
const t = this.get("userId") || "anonymous", r = we(t, e);
|
|
2704
2651
|
try {
|
|
2705
|
-
const
|
|
2652
|
+
const n = {
|
|
2706
2653
|
...this.sessionEventCounts,
|
|
2707
2654
|
_timestamp: Date.now(),
|
|
2708
2655
|
_version: 1
|
|
2709
2656
|
};
|
|
2710
|
-
localStorage.setItem(r, JSON.stringify(
|
|
2711
|
-
} catch (
|
|
2657
|
+
localStorage.setItem(r, JSON.stringify(n));
|
|
2658
|
+
} catch (n) {
|
|
2712
2659
|
a("warn", "Failed to persist session counts to localStorage", {
|
|
2713
|
-
error:
|
|
2660
|
+
error: n,
|
|
2714
2661
|
data: { sessionId: e }
|
|
2715
2662
|
});
|
|
2716
2663
|
}
|
|
2717
2664
|
}
|
|
2718
2665
|
}
|
|
2719
|
-
class
|
|
2666
|
+
class tr {
|
|
2720
2667
|
/**
|
|
2721
2668
|
* Gets or creates a unique user ID.
|
|
2722
2669
|
*
|
|
@@ -2734,15 +2681,15 @@ class qt {
|
|
|
2734
2681
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2735
2682
|
*/
|
|
2736
2683
|
static getId(e) {
|
|
2737
|
-
const t = e.getItem(
|
|
2684
|
+
const t = e.getItem(_e);
|
|
2738
2685
|
if (t)
|
|
2739
2686
|
return t;
|
|
2740
|
-
const r =
|
|
2741
|
-
return e.setItem(
|
|
2687
|
+
const r = Ht();
|
|
2688
|
+
return e.setItem(_e, r), r;
|
|
2742
2689
|
}
|
|
2743
2690
|
}
|
|
2744
|
-
const
|
|
2745
|
-
class
|
|
2691
|
+
const rr = /^\d{13}-[a-z0-9]{9}$/;
|
|
2692
|
+
class sr extends _ {
|
|
2746
2693
|
storageManager;
|
|
2747
2694
|
eventManager;
|
|
2748
2695
|
projectId;
|
|
@@ -2767,9 +2714,9 @@ class Zt extends _ {
|
|
|
2767
2714
|
return;
|
|
2768
2715
|
}
|
|
2769
2716
|
const e = this.getProjectId();
|
|
2770
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2771
|
-
const { action: r, sessionId:
|
|
2772
|
-
o === e && (r === "session_start" &&
|
|
2717
|
+
this.broadcastChannel = new BroadcastChannel(ht(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2718
|
+
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2719
|
+
o === e && (r === "session_start" && n && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", n), this.persistSession(n, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2773
2720
|
};
|
|
2774
2721
|
}
|
|
2775
2722
|
shareSession(e) {
|
|
@@ -2787,17 +2734,19 @@ class Zt extends _ {
|
|
|
2787
2734
|
const e = this.loadStoredSession();
|
|
2788
2735
|
if (!e)
|
|
2789
2736
|
return null;
|
|
2790
|
-
if (!
|
|
2737
|
+
if (!rr.test(e.id))
|
|
2791
2738
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2792
2739
|
data: { sessionId: e.id }
|
|
2793
2740
|
}), this.clearStoredSession(), null;
|
|
2794
2741
|
const t = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2795
2742
|
return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
|
|
2796
2743
|
}
|
|
2797
|
-
persistSession(e, t = Date.now()) {
|
|
2744
|
+
persistSession(e, t = Date.now(), r, n) {
|
|
2798
2745
|
this.saveStoredSession({
|
|
2799
2746
|
id: e,
|
|
2800
|
-
lastActivity: t
|
|
2747
|
+
lastActivity: t,
|
|
2748
|
+
...r && { referrer: r },
|
|
2749
|
+
...n && { utm: n }
|
|
2801
2750
|
});
|
|
2802
2751
|
}
|
|
2803
2752
|
clearStoredSession() {
|
|
@@ -2820,7 +2769,7 @@ class Zt extends _ {
|
|
|
2820
2769
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2821
2770
|
}
|
|
2822
2771
|
getSessionStorageKey() {
|
|
2823
|
-
return
|
|
2772
|
+
return dt(this.getProjectId());
|
|
2824
2773
|
}
|
|
2825
2774
|
getProjectId() {
|
|
2826
2775
|
return this.projectId;
|
|
@@ -2882,21 +2831,29 @@ class Zt extends _ {
|
|
|
2882
2831
|
return;
|
|
2883
2832
|
}
|
|
2884
2833
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
2834
|
+
let r, n;
|
|
2835
|
+
if (e) {
|
|
2836
|
+
const i = this.loadStoredSession();
|
|
2837
|
+
r = i?.referrer ?? De(), n = i?.utm ?? Ve();
|
|
2838
|
+
} else
|
|
2839
|
+
r = De(), n = Ve();
|
|
2885
2840
|
a("debug", "Session tracking initialized", {
|
|
2886
2841
|
data: {
|
|
2887
2842
|
sessionId: t,
|
|
2888
2843
|
wasRecovered: !!e,
|
|
2889
|
-
willEmitSessionStart: !0
|
|
2844
|
+
willEmitSessionStart: !0,
|
|
2845
|
+
sessionReferrer: r,
|
|
2846
|
+
hasUtm: !!n
|
|
2890
2847
|
}
|
|
2891
2848
|
}), this.isTracking = !0;
|
|
2892
2849
|
try {
|
|
2893
|
-
this.set("sessionId", t), this.persistSession(t), this.initCrossTabSync(), this.shareSession(t), a("debug", "Emitting SESSION_START event", {
|
|
2850
|
+
this.set("sessionId", t), this.set("sessionReferrer", r), this.set("sessionUtm", n), this.persistSession(t, Date.now(), r, n), this.initCrossTabSync(), this.shareSession(t), a("debug", "Emitting SESSION_START event", {
|
|
2894
2851
|
data: { sessionId: t }
|
|
2895
2852
|
}), this.eventManager.track({
|
|
2896
2853
|
type: d.SESSION_START
|
|
2897
2854
|
}), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2898
|
-
} catch (
|
|
2899
|
-
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null),
|
|
2855
|
+
} catch (i) {
|
|
2856
|
+
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
|
|
2900
2857
|
}
|
|
2901
2858
|
}
|
|
2902
2859
|
generateSessionId() {
|
|
@@ -2912,7 +2869,7 @@ class Zt extends _ {
|
|
|
2912
2869
|
resetSessionTimeout() {
|
|
2913
2870
|
this.setupSessionTimeout();
|
|
2914
2871
|
const e = this.get("sessionId");
|
|
2915
|
-
e && this.persistSession(e);
|
|
2872
|
+
e && this.persistSession(e, Date.now(), this.get("sessionReferrer"), this.get("sessionUtm"));
|
|
2916
2873
|
}
|
|
2917
2874
|
clearSessionTimeout() {
|
|
2918
2875
|
this.sessionTimeoutId && (clearTimeout(this.sessionTimeoutId), this.sessionTimeoutId = null);
|
|
@@ -2934,7 +2891,7 @@ class Zt extends _ {
|
|
|
2934
2891
|
this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null);
|
|
2935
2892
|
}
|
|
2936
2893
|
resetSessionState() {
|
|
2937
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.isTracking = !1;
|
|
2894
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.isTracking = !1;
|
|
2938
2895
|
}
|
|
2939
2896
|
/**
|
|
2940
2897
|
* Stops session tracking and cleans up all resources.
|
|
@@ -3003,7 +2960,7 @@ class Zt extends _ {
|
|
|
3003
2960
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
3004
2961
|
}
|
|
3005
2962
|
}
|
|
3006
|
-
class
|
|
2963
|
+
class nr extends _ {
|
|
3007
2964
|
eventManager;
|
|
3008
2965
|
storageManager;
|
|
3009
2966
|
sessionManager = null;
|
|
@@ -3038,7 +2995,7 @@ class er extends _ {
|
|
|
3038
2995
|
}
|
|
3039
2996
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3040
2997
|
try {
|
|
3041
|
-
this.sessionManager = new
|
|
2998
|
+
this.sessionManager = new sr(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3042
2999
|
} catch (r) {
|
|
3043
3000
|
if (this.sessionManager) {
|
|
3044
3001
|
try {
|
|
@@ -3091,7 +3048,7 @@ class er extends _ {
|
|
|
3091
3048
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3092
3049
|
}
|
|
3093
3050
|
}
|
|
3094
|
-
class
|
|
3051
|
+
class ir extends _ {
|
|
3095
3052
|
eventManager;
|
|
3096
3053
|
onTrack;
|
|
3097
3054
|
originalPushState;
|
|
@@ -3134,8 +3091,8 @@ class tr extends _ {
|
|
|
3134
3091
|
const e = window.location.href, t = le(e, this.get("config").sensitiveQueryParams);
|
|
3135
3092
|
if (this.get("pageUrl") === t)
|
|
3136
3093
|
return;
|
|
3137
|
-
const r = Date.now(),
|
|
3138
|
-
if (r - this.lastPageViewTime <
|
|
3094
|
+
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
3095
|
+
if (r - this.lastPageViewTime < n)
|
|
3139
3096
|
return;
|
|
3140
3097
|
this.lastPageViewTime = r, this.onTrack();
|
|
3141
3098
|
const i = this.get("pageUrl");
|
|
@@ -3157,9 +3114,9 @@ class tr extends _ {
|
|
|
3157
3114
|
}), this.onTrack();
|
|
3158
3115
|
}
|
|
3159
3116
|
extractPageViewData() {
|
|
3160
|
-
const { pathname: e, search: t, hash: r } = window.location, { referrer:
|
|
3161
|
-
return !
|
|
3162
|
-
...
|
|
3117
|
+
const { pathname: e, search: t, hash: r } = window.location, { referrer: n } = document, { title: i } = document;
|
|
3118
|
+
return !n && !i && !e && !t && !r ? void 0 : {
|
|
3119
|
+
...n && { referrer: n },
|
|
3163
3120
|
...i && { title: i },
|
|
3164
3121
|
...e && { pathname: e },
|
|
3165
3122
|
...t && { search: t },
|
|
@@ -3167,7 +3124,7 @@ class tr extends _ {
|
|
|
3167
3124
|
};
|
|
3168
3125
|
}
|
|
3169
3126
|
}
|
|
3170
|
-
class
|
|
3127
|
+
class or extends _ {
|
|
3171
3128
|
eventManager;
|
|
3172
3129
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3173
3130
|
clickHandler;
|
|
@@ -3190,17 +3147,17 @@ class rr extends _ {
|
|
|
3190
3147
|
*/
|
|
3191
3148
|
startTracking() {
|
|
3192
3149
|
this.clickHandler || (this.clickHandler = (e) => {
|
|
3193
|
-
const t = e, r = t.target,
|
|
3194
|
-
if (!
|
|
3150
|
+
const t = e, r = t.target, n = typeof HTMLElement < "u" && r instanceof HTMLElement ? r : typeof HTMLElement < "u" && r instanceof Node && r.parentElement instanceof HTMLElement ? r.parentElement : null;
|
|
3151
|
+
if (!n) {
|
|
3195
3152
|
a("debug", "Click target not found or not an element");
|
|
3196
3153
|
return;
|
|
3197
3154
|
}
|
|
3198
|
-
if (this.shouldIgnoreElement(
|
|
3155
|
+
if (this.shouldIgnoreElement(n))
|
|
3199
3156
|
return;
|
|
3200
3157
|
const i = this.get("config")?.clickThrottleMs ?? 300;
|
|
3201
|
-
if (i > 0 && !this.checkClickThrottle(
|
|
3158
|
+
if (i > 0 && !this.checkClickThrottle(n, i))
|
|
3202
3159
|
return;
|
|
3203
|
-
const o = this.findTrackingElement(
|
|
3160
|
+
const o = this.findTrackingElement(n), l = this.getRelevantClickElement(n), c = this.calculateClickCoordinates(t, n);
|
|
3204
3161
|
if (o) {
|
|
3205
3162
|
const S = this.extractTrackingData(o);
|
|
3206
3163
|
if (S) {
|
|
@@ -3214,7 +3171,7 @@ class rr extends _ {
|
|
|
3214
3171
|
});
|
|
3215
3172
|
}
|
|
3216
3173
|
}
|
|
3217
|
-
const u = this.generateClickData(
|
|
3174
|
+
const u = this.generateClickData(n, l, c);
|
|
3218
3175
|
this.eventManager.track({
|
|
3219
3176
|
type: d.CLICK,
|
|
3220
3177
|
click_data: u
|
|
@@ -3238,15 +3195,15 @@ class rr extends _ {
|
|
|
3238
3195
|
* Returns true if the click should be tracked, false if throttled
|
|
3239
3196
|
*/
|
|
3240
3197
|
checkClickThrottle(e, t) {
|
|
3241
|
-
const r = this.getElementSignature(e),
|
|
3242
|
-
this.pruneThrottleCache(
|
|
3198
|
+
const r = this.getElementSignature(e), n = Date.now();
|
|
3199
|
+
this.pruneThrottleCache(n);
|
|
3243
3200
|
const i = this.lastClickTimes.get(r);
|
|
3244
|
-
return i !== void 0 &&
|
|
3201
|
+
return i !== void 0 && n - i < t ? (a("debug", "ClickHandler: Click suppressed by throttle", {
|
|
3245
3202
|
data: {
|
|
3246
3203
|
signature: r,
|
|
3247
|
-
throttleRemaining: t - (
|
|
3204
|
+
throttleRemaining: t - (n - i)
|
|
3248
3205
|
}
|
|
3249
|
-
}), !1) : (this.lastClickTimes.set(r,
|
|
3206
|
+
}), !1) : (this.lastClickTimes.set(r, n), !0);
|
|
3250
3207
|
}
|
|
3251
3208
|
/**
|
|
3252
3209
|
* Prunes stale entries from the throttle cache to prevent memory leaks
|
|
@@ -3258,10 +3215,10 @@ class rr extends _ {
|
|
|
3258
3215
|
return;
|
|
3259
3216
|
this.lastPruneTime = e;
|
|
3260
3217
|
const t = e - 3e5;
|
|
3261
|
-
for (const [r,
|
|
3262
|
-
|
|
3218
|
+
for (const [r, n] of this.lastClickTimes.entries())
|
|
3219
|
+
n < t && this.lastClickTimes.delete(r);
|
|
3263
3220
|
if (this.lastClickTimes.size > 1e3) {
|
|
3264
|
-
const r = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]),
|
|
3221
|
+
const r = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]), n = this.lastClickTimes.size - 1e3, i = r.slice(0, n);
|
|
3265
3222
|
for (const [o] of i)
|
|
3266
3223
|
this.lastClickTimes.delete(o);
|
|
3267
3224
|
a("debug", "ClickHandler: Pruned throttle cache", {
|
|
@@ -3292,12 +3249,12 @@ class rr extends _ {
|
|
|
3292
3249
|
const t = [];
|
|
3293
3250
|
let r = e;
|
|
3294
3251
|
for (; r && r !== document.body; ) {
|
|
3295
|
-
let
|
|
3252
|
+
let n = r.tagName.toLowerCase();
|
|
3296
3253
|
if (r.className) {
|
|
3297
3254
|
const i = r.className.split(" ")[0];
|
|
3298
|
-
i && (
|
|
3255
|
+
i && (n += `.${i}`);
|
|
3299
3256
|
}
|
|
3300
|
-
t.unshift(
|
|
3257
|
+
t.unshift(n), r = r.parentElement;
|
|
3301
3258
|
}
|
|
3302
3259
|
return t.join(">") || "unknown";
|
|
3303
3260
|
}
|
|
@@ -3305,7 +3262,7 @@ class rr extends _ {
|
|
|
3305
3262
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3306
3263
|
}
|
|
3307
3264
|
getRelevantClickElement(e) {
|
|
3308
|
-
for (const t of
|
|
3265
|
+
for (const t of ot)
|
|
3309
3266
|
try {
|
|
3310
3267
|
if (e.matches(t))
|
|
3311
3268
|
return e;
|
|
@@ -3333,8 +3290,8 @@ class rr extends _ {
|
|
|
3333
3290
|
return Math.max(0, Math.min(1, Number(e.toFixed(3))));
|
|
3334
3291
|
}
|
|
3335
3292
|
calculateClickCoordinates(e, t) {
|
|
3336
|
-
const r = t.getBoundingClientRect(),
|
|
3337
|
-
return { x:
|
|
3293
|
+
const r = t.getBoundingClientRect(), n = e.clientX, i = e.clientY, o = r.width > 0 ? this.clamp((n - r.left) / r.width) : 0, l = r.height > 0 ? this.clamp((i - r.top) / r.height) : 0;
|
|
3294
|
+
return { x: n, y: i, relativeX: o, relativeY: l };
|
|
3338
3295
|
}
|
|
3339
3296
|
extractTrackingData(e) {
|
|
3340
3297
|
const t = e.getAttribute(`${w}-name`), r = e.getAttribute(`${w}-value`);
|
|
@@ -3346,9 +3303,9 @@ class rr extends _ {
|
|
|
3346
3303
|
};
|
|
3347
3304
|
}
|
|
3348
3305
|
generateClickData(e, t, r) {
|
|
3349
|
-
const { x:
|
|
3306
|
+
const { x: n, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
3350
3307
|
return {
|
|
3351
|
-
x:
|
|
3308
|
+
x: n,
|
|
3352
3309
|
y: i,
|
|
3353
3310
|
relativeX: o,
|
|
3354
3311
|
relativeY: l,
|
|
@@ -3385,18 +3342,18 @@ class rr extends _ {
|
|
|
3385
3342
|
*/
|
|
3386
3343
|
sanitizeText(e) {
|
|
3387
3344
|
let t = e;
|
|
3388
|
-
for (const r of
|
|
3389
|
-
const
|
|
3390
|
-
t = t.replace(
|
|
3345
|
+
for (const r of Xe) {
|
|
3346
|
+
const n = new RegExp(r.source, r.flags);
|
|
3347
|
+
t = t.replace(n, "[REDACTED]");
|
|
3391
3348
|
}
|
|
3392
3349
|
return t;
|
|
3393
3350
|
}
|
|
3394
3351
|
getRelevantText(e, t) {
|
|
3395
|
-
const r = e.textContent?.trim() ?? "",
|
|
3396
|
-
if (!r && !
|
|
3352
|
+
const r = e.textContent?.trim() ?? "", n = t.textContent?.trim() ?? "";
|
|
3353
|
+
if (!r && !n)
|
|
3397
3354
|
return "";
|
|
3398
3355
|
let i = "";
|
|
3399
|
-
return r && r.length <= 255 ? i = r :
|
|
3356
|
+
return r && r.length <= 255 ? i = r : n.length <= 255 ? i = n : i = n.slice(0, 252) + "...", this.sanitizeText(i);
|
|
3400
3357
|
}
|
|
3401
3358
|
extractElementAttributes(e) {
|
|
3402
3359
|
const t = [
|
|
@@ -3411,9 +3368,9 @@ class rr extends _ {
|
|
|
3411
3368
|
"alt",
|
|
3412
3369
|
"role"
|
|
3413
3370
|
], r = {};
|
|
3414
|
-
for (const
|
|
3415
|
-
const i = e.getAttribute(
|
|
3416
|
-
i && (r[
|
|
3371
|
+
for (const n of t) {
|
|
3372
|
+
const i = e.getAttribute(n);
|
|
3373
|
+
i && (r[n] = i);
|
|
3417
3374
|
}
|
|
3418
3375
|
return r;
|
|
3419
3376
|
}
|
|
@@ -3424,7 +3381,7 @@ class rr extends _ {
|
|
|
3424
3381
|
};
|
|
3425
3382
|
}
|
|
3426
3383
|
}
|
|
3427
|
-
class
|
|
3384
|
+
class ar extends _ {
|
|
3428
3385
|
eventManager;
|
|
3429
3386
|
containers = [];
|
|
3430
3387
|
limitWarningLogged = !1;
|
|
@@ -3471,8 +3428,8 @@ class nr extends _ {
|
|
|
3471
3428
|
const t = this.findScrollableElements();
|
|
3472
3429
|
if (this.isWindowScrollable() && this.setupScrollContainer(window, "window"), t.length > 0) {
|
|
3473
3430
|
for (const r of t) {
|
|
3474
|
-
const
|
|
3475
|
-
this.setupScrollContainer(r,
|
|
3431
|
+
const n = this.getElementSelector(r);
|
|
3432
|
+
this.setupScrollContainer(r, n);
|
|
3476
3433
|
}
|
|
3477
3434
|
this.applyPrimaryScrollSelectorIfConfigured();
|
|
3478
3435
|
return;
|
|
@@ -3493,8 +3450,8 @@ class nr extends _ {
|
|
|
3493
3450
|
if (!document.body)
|
|
3494
3451
|
return [];
|
|
3495
3452
|
const e = [], t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
3496
|
-
acceptNode: (
|
|
3497
|
-
const i =
|
|
3453
|
+
acceptNode: (n) => {
|
|
3454
|
+
const i = n;
|
|
3498
3455
|
if (!i.isConnected || !i.offsetParent)
|
|
3499
3456
|
return NodeFilter.FILTER_SKIP;
|
|
3500
3457
|
const o = getComputedStyle(i);
|
|
@@ -3503,8 +3460,8 @@ class nr extends _ {
|
|
|
3503
3460
|
});
|
|
3504
3461
|
let r;
|
|
3505
3462
|
for (; (r = t.nextNode()) && e.length < 10; ) {
|
|
3506
|
-
const
|
|
3507
|
-
this.isElementScrollable(
|
|
3463
|
+
const n = r;
|
|
3464
|
+
this.isElementScrollable(n) && e.push(n);
|
|
3508
3465
|
}
|
|
3509
3466
|
return e;
|
|
3510
3467
|
}
|
|
@@ -3515,7 +3472,7 @@ class nr extends _ {
|
|
|
3515
3472
|
if (t.id)
|
|
3516
3473
|
return `#${t.id}`;
|
|
3517
3474
|
if (t.className && typeof t.className == "string") {
|
|
3518
|
-
const r = t.className.split(" ").filter((
|
|
3475
|
+
const r = t.className.split(" ").filter((n) => n.trim())[0];
|
|
3519
3476
|
if (r)
|
|
3520
3477
|
return `.${r}`;
|
|
3521
3478
|
}
|
|
@@ -3527,15 +3484,15 @@ class nr extends _ {
|
|
|
3527
3484
|
setupScrollContainer(e, t) {
|
|
3528
3485
|
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3529
3486
|
return;
|
|
3530
|
-
const
|
|
3531
|
-
|
|
3487
|
+
const n = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3488
|
+
n,
|
|
3532
3489
|
this.getScrollHeight(e),
|
|
3533
3490
|
this.getViewportHeight(e)
|
|
3534
3491
|
), o = this.determineIfPrimary(e), l = {
|
|
3535
3492
|
element: e,
|
|
3536
3493
|
selector: t,
|
|
3537
3494
|
isPrimary: o,
|
|
3538
|
-
lastScrollPos:
|
|
3495
|
+
lastScrollPos: n,
|
|
3539
3496
|
lastDepth: i,
|
|
3540
3497
|
lastDirection: X.DOWN,
|
|
3541
3498
|
lastEventTime: 0,
|
|
@@ -3559,8 +3516,8 @@ class nr extends _ {
|
|
|
3559
3516
|
if (!this.shouldEmitScrollEvent(e, t, r))
|
|
3560
3517
|
return;
|
|
3561
3518
|
e.lastEventTime = r, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3562
|
-
const
|
|
3563
|
-
this.set("scrollEventCount",
|
|
3519
|
+
const n = this.get("scrollEventCount") ?? 0;
|
|
3520
|
+
this.set("scrollEventCount", n + 1), this.eventManager.track({
|
|
3564
3521
|
type: d.SCROLL,
|
|
3565
3522
|
scroll_data: {
|
|
3566
3523
|
...t,
|
|
@@ -3601,21 +3558,21 @@ class nr extends _ {
|
|
|
3601
3558
|
calculateScrollDepth(e, t, r) {
|
|
3602
3559
|
if (t <= r)
|
|
3603
3560
|
return 0;
|
|
3604
|
-
const
|
|
3605
|
-
return Math.min(100, Math.max(0, Math.floor(e /
|
|
3561
|
+
const n = t - r;
|
|
3562
|
+
return Math.min(100, Math.max(0, Math.floor(e / n * 100)));
|
|
3606
3563
|
}
|
|
3607
3564
|
calculateScrollData(e) {
|
|
3608
|
-
const { element: t, lastScrollPos: r, lastEventTime:
|
|
3565
|
+
const { element: t, lastScrollPos: r, lastEventTime: n } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - r);
|
|
3609
3566
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3610
3567
|
return null;
|
|
3611
3568
|
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), S = this.getScrollDirection(i, r), g = this.calculateScrollDepth(i, u, c);
|
|
3612
|
-
let
|
|
3613
|
-
|
|
3614
|
-
const
|
|
3569
|
+
let p;
|
|
3570
|
+
n > 0 ? p = o - n : e.firstScrollEventTime !== null ? p = o - e.firstScrollEventTime : p = 250;
|
|
3571
|
+
const E = Math.round(l / p * 1e3);
|
|
3615
3572
|
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3616
3573
|
depth: g,
|
|
3617
3574
|
direction: S,
|
|
3618
|
-
velocity:
|
|
3575
|
+
velocity: E,
|
|
3619
3576
|
max_depth_reached: e.maxDepthReached
|
|
3620
3577
|
};
|
|
3621
3578
|
}
|
|
@@ -3629,30 +3586,30 @@ class nr extends _ {
|
|
|
3629
3586
|
return e === window ? document.documentElement.scrollHeight : e.scrollHeight;
|
|
3630
3587
|
}
|
|
3631
3588
|
isElementScrollable(e) {
|
|
3632
|
-
const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll",
|
|
3633
|
-
return r &&
|
|
3589
|
+
const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll", n = e.scrollHeight > e.clientHeight;
|
|
3590
|
+
return r && n;
|
|
3634
3591
|
}
|
|
3635
3592
|
applyPrimaryScrollSelector(e) {
|
|
3636
3593
|
let t;
|
|
3637
3594
|
if (e === "window")
|
|
3638
3595
|
t = window;
|
|
3639
3596
|
else {
|
|
3640
|
-
const
|
|
3641
|
-
if (!(
|
|
3597
|
+
const n = document.querySelector(e);
|
|
3598
|
+
if (!(n instanceof HTMLElement)) {
|
|
3642
3599
|
a("debug", `Selector "${e}" did not match an HTMLElement`);
|
|
3643
3600
|
return;
|
|
3644
3601
|
}
|
|
3645
|
-
t =
|
|
3602
|
+
t = n;
|
|
3646
3603
|
}
|
|
3647
|
-
this.containers.forEach((
|
|
3648
|
-
this.updateContainerPrimary(
|
|
3649
|
-
}), !this.containers.some((
|
|
3604
|
+
this.containers.forEach((n) => {
|
|
3605
|
+
this.updateContainerPrimary(n, n.element === t);
|
|
3606
|
+
}), !this.containers.some((n) => n.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
|
|
3650
3607
|
}
|
|
3651
3608
|
updateContainerPrimary(e, t) {
|
|
3652
3609
|
e.isPrimary = t;
|
|
3653
3610
|
}
|
|
3654
3611
|
}
|
|
3655
|
-
class
|
|
3612
|
+
class lr extends _ {
|
|
3656
3613
|
eventManager;
|
|
3657
3614
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3658
3615
|
observer = null;
|
|
@@ -3704,8 +3661,8 @@ class sr extends _ {
|
|
|
3704
3661
|
let t = this.trackedElements.size;
|
|
3705
3662
|
for (const r of this.config.elements)
|
|
3706
3663
|
try {
|
|
3707
|
-
const
|
|
3708
|
-
for (const i of Array.from(
|
|
3664
|
+
const n = document.querySelectorAll(r.selector);
|
|
3665
|
+
for (const i of Array.from(n)) {
|
|
3709
3666
|
if (t >= e) {
|
|
3710
3667
|
a("debug", "ViewportHandler: Maximum tracked elements reached", {
|
|
3711
3668
|
data: {
|
|
@@ -3726,8 +3683,8 @@ class sr extends _ {
|
|
|
3726
3683
|
lastFiredTime: null
|
|
3727
3684
|
}), this.observer?.observe(i), t++);
|
|
3728
3685
|
}
|
|
3729
|
-
} catch (
|
|
3730
|
-
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error:
|
|
3686
|
+
} catch (n) {
|
|
3687
|
+
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error: n });
|
|
3731
3688
|
}
|
|
3732
3689
|
a("debug", "ViewportHandler: Elements tracked", {
|
|
3733
3690
|
data: { count: t, limit: e }
|
|
@@ -3740,11 +3697,11 @@ class sr extends _ {
|
|
|
3740
3697
|
if (!this.config) return;
|
|
3741
3698
|
const t = this.config.minDwellTime ?? 1e3;
|
|
3742
3699
|
for (const r of e) {
|
|
3743
|
-
const
|
|
3744
|
-
|
|
3700
|
+
const n = this.trackedElements.get(r.target);
|
|
3701
|
+
n && (r.isIntersecting ? n.startTime === null && (n.startTime = performance.now(), n.timeoutId = window.setTimeout(() => {
|
|
3745
3702
|
const i = Math.round(r.intersectionRatio * 100) / 100;
|
|
3746
|
-
this.fireViewportEvent(
|
|
3747
|
-
}, t)) :
|
|
3703
|
+
this.fireViewportEvent(n, i);
|
|
3704
|
+
}, t)) : n.startTime !== null && (n.timeoutId !== null && (window.clearTimeout(n.timeoutId), n.timeoutId = null), n.startTime = null));
|
|
3748
3705
|
}
|
|
3749
3706
|
};
|
|
3750
3707
|
/**
|
|
@@ -3755,12 +3712,12 @@ class sr extends _ {
|
|
|
3755
3712
|
const r = Math.round(performance.now() - e.startTime);
|
|
3756
3713
|
if (e.element.hasAttribute(`${w}-ignore`))
|
|
3757
3714
|
return;
|
|
3758
|
-
const
|
|
3759
|
-
if (e.lastFiredTime !== null && i - e.lastFiredTime <
|
|
3715
|
+
const n = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3716
|
+
if (e.lastFiredTime !== null && i - e.lastFiredTime < n) {
|
|
3760
3717
|
a("debug", "ViewportHandler: Event suppressed by cooldown period", {
|
|
3761
3718
|
data: {
|
|
3762
3719
|
selector: e.selector,
|
|
3763
|
-
cooldownRemaining:
|
|
3720
|
+
cooldownRemaining: n - (i - e.lastFiredTime)
|
|
3764
3721
|
}
|
|
3765
3722
|
}), e.startTime = null, e.timeoutId = null;
|
|
3766
3723
|
return;
|
|
@@ -3805,15 +3762,15 @@ class sr extends _ {
|
|
|
3805
3762
|
cleanupRemovedNodes(e) {
|
|
3806
3763
|
e.forEach((t) => {
|
|
3807
3764
|
if (t.nodeType !== 1) return;
|
|
3808
|
-
const r = t,
|
|
3809
|
-
|
|
3765
|
+
const r = t, n = this.trackedElements.get(r);
|
|
3766
|
+
n && (n.timeoutId !== null && window.clearTimeout(n.timeoutId), this.observer?.unobserve(r), this.trackedElements.delete(r)), Array.from(this.trackedElements.keys()).filter((o) => r.contains(o)).forEach((o) => {
|
|
3810
3767
|
const l = this.trackedElements.get(o);
|
|
3811
3768
|
l && l.timeoutId !== null && window.clearTimeout(l.timeoutId), this.observer?.unobserve(o), this.trackedElements.delete(o);
|
|
3812
3769
|
});
|
|
3813
3770
|
});
|
|
3814
3771
|
}
|
|
3815
3772
|
}
|
|
3816
|
-
class
|
|
3773
|
+
class cr {
|
|
3817
3774
|
storage;
|
|
3818
3775
|
sessionStorageRef;
|
|
3819
3776
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3993,8 +3950,8 @@ class ir {
|
|
|
3993
3950
|
} catch {
|
|
3994
3951
|
}
|
|
3995
3952
|
}), !0;
|
|
3996
|
-
const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"],
|
|
3997
|
-
return
|
|
3953
|
+
const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], n = e.filter((i) => !r.some((o) => i.startsWith(o)));
|
|
3954
|
+
return n.length > 0 ? (n.slice(0, 5).forEach((o) => {
|
|
3998
3955
|
try {
|
|
3999
3956
|
this.storage.removeItem(o);
|
|
4000
3957
|
} catch {
|
|
@@ -4096,7 +4053,7 @@ class ir {
|
|
|
4096
4053
|
this.fallbackSessionStorage.delete(e);
|
|
4097
4054
|
}
|
|
4098
4055
|
}
|
|
4099
|
-
class
|
|
4056
|
+
class ur extends _ {
|
|
4100
4057
|
eventManager;
|
|
4101
4058
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4102
4059
|
navigationHistory = [];
|
|
@@ -4107,7 +4064,7 @@ class or extends _ {
|
|
|
4107
4064
|
navigationCounter = 0;
|
|
4108
4065
|
// Counter for handling simultaneous navigations edge case
|
|
4109
4066
|
constructor(e) {
|
|
4110
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4067
|
+
super(), this.eventManager = e, this.vitalThresholds = Oe(ae);
|
|
4111
4068
|
}
|
|
4112
4069
|
/**
|
|
4113
4070
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4125,7 +4082,7 @@ class or extends _ {
|
|
|
4125
4082
|
*/
|
|
4126
4083
|
async startTracking() {
|
|
4127
4084
|
const e = this.get("config"), t = e?.webVitalsMode ?? ae;
|
|
4128
|
-
this.vitalThresholds =
|
|
4085
|
+
this.vitalThresholds = Oe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4129
4086
|
}
|
|
4130
4087
|
/**
|
|
4131
4088
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4149,7 +4106,7 @@ class or extends _ {
|
|
|
4149
4106
|
this.reportTTFB(), this.safeObserve(
|
|
4150
4107
|
"largest-contentful-paint",
|
|
4151
4108
|
(r) => {
|
|
4152
|
-
const
|
|
4109
|
+
const n = r.getEntries(), i = n[n.length - 1];
|
|
4153
4110
|
i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(2)) });
|
|
4154
4111
|
},
|
|
4155
4112
|
{ type: "largest-contentful-paint", buffered: !0 },
|
|
@@ -4159,8 +4116,8 @@ class or extends _ {
|
|
|
4159
4116
|
this.safeObserve(
|
|
4160
4117
|
"layout-shift",
|
|
4161
4118
|
(r) => {
|
|
4162
|
-
const
|
|
4163
|
-
|
|
4119
|
+
const n = this.getNavigationId();
|
|
4120
|
+
n !== t && (e = 0, t = n);
|
|
4164
4121
|
const i = r.getEntries();
|
|
4165
4122
|
for (const o of i) {
|
|
4166
4123
|
if (o.hadRecentInput === !0)
|
|
@@ -4174,32 +4131,32 @@ class or extends _ {
|
|
|
4174
4131
|
), this.safeObserve(
|
|
4175
4132
|
"paint",
|
|
4176
4133
|
(r) => {
|
|
4177
|
-
for (const
|
|
4178
|
-
|
|
4134
|
+
for (const n of r.getEntries())
|
|
4135
|
+
n.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(n.startTime.toFixed(2)) });
|
|
4179
4136
|
},
|
|
4180
4137
|
{ type: "paint", buffered: !0 },
|
|
4181
4138
|
!0
|
|
4182
4139
|
), this.safeObserve(
|
|
4183
4140
|
"event",
|
|
4184
4141
|
(r) => {
|
|
4185
|
-
let
|
|
4142
|
+
let n = 0;
|
|
4186
4143
|
const i = r.getEntries();
|
|
4187
4144
|
for (const o of i) {
|
|
4188
4145
|
const l = (o.processingEnd ?? 0) - (o.startTime ?? 0);
|
|
4189
|
-
|
|
4146
|
+
n = Math.max(n, l);
|
|
4190
4147
|
}
|
|
4191
|
-
|
|
4148
|
+
n > 0 && this.sendVital({ type: "INP", value: Number(n.toFixed(2)) });
|
|
4192
4149
|
},
|
|
4193
4150
|
{ type: "event", buffered: !0 }
|
|
4194
4151
|
);
|
|
4195
4152
|
}
|
|
4196
4153
|
async initWebVitals() {
|
|
4197
4154
|
try {
|
|
4198
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB:
|
|
4155
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => Vr), o = (l) => (c) => {
|
|
4199
4156
|
const u = Number(c.value.toFixed(2));
|
|
4200
4157
|
this.sendVital({ type: l, value: u });
|
|
4201
4158
|
};
|
|
4202
|
-
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }),
|
|
4159
|
+
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }), n(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
4203
4160
|
} catch (e) {
|
|
4204
4161
|
a("debug", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
|
|
4205
4162
|
}
|
|
@@ -4221,8 +4178,8 @@ class or extends _ {
|
|
|
4221
4178
|
(e) => {
|
|
4222
4179
|
const t = e.getEntries();
|
|
4223
4180
|
for (const r of t) {
|
|
4224
|
-
const
|
|
4225
|
-
i - this.lastLongTaskSentAt >=
|
|
4181
|
+
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4182
|
+
i - this.lastLongTaskSentAt >= Rt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4226
4183
|
}
|
|
4227
4184
|
},
|
|
4228
4185
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4238,7 +4195,7 @@ class or extends _ {
|
|
|
4238
4195
|
return;
|
|
4239
4196
|
if (r)
|
|
4240
4197
|
r.add(e.type);
|
|
4241
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4198
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Nt) {
|
|
4242
4199
|
const i = this.navigationHistory.shift();
|
|
4243
4200
|
i && this.reportedByNav.delete(i);
|
|
4244
4201
|
}
|
|
@@ -4284,8 +4241,8 @@ class or extends _ {
|
|
|
4284
4241
|
const e = performance.getEntriesByType("navigation")[0];
|
|
4285
4242
|
if (!e)
|
|
4286
4243
|
return null;
|
|
4287
|
-
const t = e.startTime || performance.now(), r = ++this.navigationCounter,
|
|
4288
|
-
return r > 1 ? `${
|
|
4244
|
+
const t = e.startTime || performance.now(), r = ++this.navigationCounter, n = `${t.toFixed(2)}_${window.location.pathname}`;
|
|
4245
|
+
return r > 1 ? `${n}_${r}` : n;
|
|
4289
4246
|
} catch (e) {
|
|
4290
4247
|
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
4291
4248
|
}
|
|
@@ -4295,7 +4252,7 @@ class or extends _ {
|
|
|
4295
4252
|
const t = PerformanceObserver.supportedEntryTypes;
|
|
4296
4253
|
return !t || t.includes(e);
|
|
4297
4254
|
}
|
|
4298
|
-
safeObserve(e, t, r,
|
|
4255
|
+
safeObserve(e, t, r, n = !1) {
|
|
4299
4256
|
try {
|
|
4300
4257
|
if (!this.isObserverSupported(e))
|
|
4301
4258
|
return !1;
|
|
@@ -4308,13 +4265,13 @@ class or extends _ {
|
|
|
4308
4265
|
data: { type: e }
|
|
4309
4266
|
});
|
|
4310
4267
|
}
|
|
4311
|
-
if (
|
|
4268
|
+
if (n)
|
|
4312
4269
|
try {
|
|
4313
4270
|
l.disconnect();
|
|
4314
4271
|
} catch {
|
|
4315
4272
|
}
|
|
4316
4273
|
});
|
|
4317
|
-
return i.observe(r ?? { type: e, buffered: !0 }),
|
|
4274
|
+
return i.observe(r ?? { type: e, buffered: !0 }), n || this.observers.push(i), !0;
|
|
4318
4275
|
} catch (i) {
|
|
4319
4276
|
return a("debug", "Failed to create performance observer", {
|
|
4320
4277
|
error: i,
|
|
@@ -4329,7 +4286,7 @@ class or extends _ {
|
|
|
4329
4286
|
return !(typeof r == "number" && t <= r);
|
|
4330
4287
|
}
|
|
4331
4288
|
}
|
|
4332
|
-
class
|
|
4289
|
+
class dr extends _ {
|
|
4333
4290
|
eventManager;
|
|
4334
4291
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4335
4292
|
errorBurstCounter = 0;
|
|
@@ -4365,14 +4322,14 @@ class ar extends _ {
|
|
|
4365
4322
|
const e = Date.now();
|
|
4366
4323
|
if (e < this.burstBackoffUntil)
|
|
4367
4324
|
return !1;
|
|
4368
|
-
if (e - this.burstWindowStart >
|
|
4369
|
-
return this.burstBackoffUntil = e +
|
|
4325
|
+
if (e - this.burstWindowStart > At && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Lt)
|
|
4326
|
+
return this.burstBackoffUntil = e + Re, a("debug", "Error burst detected - entering cooldown", {
|
|
4370
4327
|
data: {
|
|
4371
4328
|
errorsInWindow: this.errorBurstCounter,
|
|
4372
|
-
cooldownMs:
|
|
4329
|
+
cooldownMs: Re
|
|
4373
4330
|
}
|
|
4374
4331
|
}), !1;
|
|
4375
|
-
const r = this.get("config")?.errorSampling ??
|
|
4332
|
+
const r = this.get("config")?.errorSampling ?? Qe;
|
|
4376
4333
|
return Math.random() < r;
|
|
4377
4334
|
}
|
|
4378
4335
|
handleError = (e) => {
|
|
@@ -4416,34 +4373,34 @@ class ar extends _ {
|
|
|
4416
4373
|
}
|
|
4417
4374
|
}
|
|
4418
4375
|
sanitize(e) {
|
|
4419
|
-
let t = e.length >
|
|
4420
|
-
for (const r of
|
|
4421
|
-
const
|
|
4422
|
-
t = t.replace(
|
|
4376
|
+
let t = e.length > Me ? e.slice(0, Me) + "..." : e;
|
|
4377
|
+
for (const r of Xe) {
|
|
4378
|
+
const n = new RegExp(r.source, r.flags);
|
|
4379
|
+
t = t.replace(n, "[REDACTED]");
|
|
4423
4380
|
}
|
|
4424
4381
|
return t;
|
|
4425
4382
|
}
|
|
4426
4383
|
shouldSuppressError(e, t) {
|
|
4427
|
-
const r = Date.now(),
|
|
4428
|
-
return i && r - i <
|
|
4384
|
+
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4385
|
+
return i && r - i < Ce ? (this.recentErrors.set(n, r), !0) : (this.recentErrors.set(n, r), this.recentErrors.size > bt ? (this.recentErrors.clear(), this.recentErrors.set(n, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4429
4386
|
}
|
|
4430
4387
|
pruneOldErrors() {
|
|
4431
4388
|
const e = Date.now();
|
|
4432
|
-
for (const [
|
|
4433
|
-
e - i >
|
|
4389
|
+
for (const [n, i] of this.recentErrors.entries())
|
|
4390
|
+
e - i > Ce && this.recentErrors.delete(n);
|
|
4434
4391
|
if (this.recentErrors.size <= Q)
|
|
4435
4392
|
return;
|
|
4436
|
-
const t = Array.from(this.recentErrors.entries()).sort((
|
|
4437
|
-
for (let
|
|
4438
|
-
const i = t[
|
|
4393
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - Q;
|
|
4394
|
+
for (let n = 0; n < r; n += 1) {
|
|
4395
|
+
const i = t[n];
|
|
4439
4396
|
i && this.recentErrors.delete(i[0]);
|
|
4440
4397
|
}
|
|
4441
4398
|
}
|
|
4442
4399
|
}
|
|
4443
|
-
class
|
|
4400
|
+
class hr extends _ {
|
|
4444
4401
|
isInitialized = !1;
|
|
4445
4402
|
suppressNextScrollTimer = null;
|
|
4446
|
-
emitter = new
|
|
4403
|
+
emitter = new qt();
|
|
4447
4404
|
transformers = {};
|
|
4448
4405
|
managers = {};
|
|
4449
4406
|
handlers = {};
|
|
@@ -4459,9 +4416,9 @@ class lr extends _ {
|
|
|
4459
4416
|
*/
|
|
4460
4417
|
async init(e = {}) {
|
|
4461
4418
|
if (!this.isInitialized) {
|
|
4462
|
-
this.managers.storage = new
|
|
4419
|
+
this.managers.storage = new cr();
|
|
4463
4420
|
try {
|
|
4464
|
-
this.setupState(e), this.managers.event = new
|
|
4421
|
+
this.setupState(e), this.managers.event = new er(this.managers.storage, this.emitter, this.transformers), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
4465
4422
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
4466
4423
|
}), this.isInitialized = !0;
|
|
4467
4424
|
} catch (t) {
|
|
@@ -4485,8 +4442,8 @@ class lr extends _ {
|
|
|
4485
4442
|
}
|
|
4486
4443
|
let r = t;
|
|
4487
4444
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4488
|
-
const { valid:
|
|
4489
|
-
if (!
|
|
4445
|
+
const { valid: n, error: i, sanitizedMetadata: o } = Yt(e, r);
|
|
4446
|
+
if (!n) {
|
|
4490
4447
|
if (this.get("mode") === z.QA)
|
|
4491
4448
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4492
4449
|
return;
|
|
@@ -4533,14 +4490,14 @@ class lr extends _ {
|
|
|
4533
4490
|
}
|
|
4534
4491
|
setupState(e = {}) {
|
|
4535
4492
|
this.set("config", e);
|
|
4536
|
-
const t =
|
|
4493
|
+
const t = tr.getId(this.managers.storage);
|
|
4537
4494
|
this.set("userId", t);
|
|
4538
|
-
const r =
|
|
4495
|
+
const r = Bt(e);
|
|
4539
4496
|
this.set("collectApiUrls", r);
|
|
4540
|
-
const
|
|
4541
|
-
this.set("device",
|
|
4497
|
+
const n = yt();
|
|
4498
|
+
this.set("device", n);
|
|
4542
4499
|
const i = le(window.location.href, e.sensitiveQueryParams);
|
|
4543
|
-
this.set("pageUrl", i),
|
|
4500
|
+
this.set("pageUrl", i), Vt() && this.set("mode", z.QA);
|
|
4544
4501
|
}
|
|
4545
4502
|
/**
|
|
4546
4503
|
* Returns the current configuration object.
|
|
@@ -4582,7 +4539,7 @@ class lr extends _ {
|
|
|
4582
4539
|
valid: !1,
|
|
4583
4540
|
error: "Global metadata must be a plain object"
|
|
4584
4541
|
};
|
|
4585
|
-
const t =
|
|
4542
|
+
const t = Ye("Global", e, "globalMetadata");
|
|
4586
4543
|
return t.valid ? { valid: !0 } : {
|
|
4587
4544
|
valid: !1,
|
|
4588
4545
|
error: t.error
|
|
@@ -4599,11 +4556,11 @@ class lr extends _ {
|
|
|
4599
4556
|
const t = this.validateGlobalMetadata(e);
|
|
4600
4557
|
if (!t.valid)
|
|
4601
4558
|
throw new Error(`[TraceLog] Invalid global metadata: ${t.error}`);
|
|
4602
|
-
const
|
|
4559
|
+
const n = {
|
|
4603
4560
|
...this.get("config"),
|
|
4604
4561
|
globalMetadata: e
|
|
4605
4562
|
};
|
|
4606
|
-
this.set("config",
|
|
4563
|
+
this.set("config", n), a("debug", "Global metadata updated (replaced)", { data: { keys: Object.keys(e) } });
|
|
4607
4564
|
}
|
|
4608
4565
|
/**
|
|
4609
4566
|
* Merges new metadata with existing global metadata.
|
|
@@ -4627,7 +4584,7 @@ class lr extends _ {
|
|
|
4627
4584
|
}
|
|
4628
4585
|
initializeHandlers() {
|
|
4629
4586
|
const e = this.get("config");
|
|
4630
|
-
this.handlers.session = new
|
|
4587
|
+
this.handlers.session = new nr(
|
|
4631
4588
|
this.managers.storage,
|
|
4632
4589
|
this.managers.event
|
|
4633
4590
|
), this.handlers.session.startTracking();
|
|
@@ -4636,35 +4593,35 @@ class lr extends _ {
|
|
|
4636
4593
|
this.set("suppressNextScroll", !1);
|
|
4637
4594
|
}, 500);
|
|
4638
4595
|
};
|
|
4639
|
-
this.handlers.pageView = new
|
|
4596
|
+
this.handlers.pageView = new ir(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new or(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new ar(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new ur(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4640
4597
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4641
|
-
}), this.handlers.error = new
|
|
4598
|
+
}), this.handlers.error = new dr(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new lr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4642
4599
|
}
|
|
4643
4600
|
}
|
|
4644
4601
|
const R = [], M = [];
|
|
4645
4602
|
let f = null, C = !1, v = !1;
|
|
4646
|
-
const
|
|
4603
|
+
const fr = async (s) => {
|
|
4647
4604
|
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !C)) {
|
|
4648
4605
|
C = !0;
|
|
4649
4606
|
try {
|
|
4650
|
-
const e =
|
|
4607
|
+
const e = jt(s ?? {}), t = new hr();
|
|
4651
4608
|
try {
|
|
4652
4609
|
R.forEach(({ event: i, callback: o }) => {
|
|
4653
4610
|
t.on(i, o);
|
|
4654
4611
|
}), R.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4655
4612
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4656
4613
|
}), M.length = 0;
|
|
4657
|
-
const r = t.init(e),
|
|
4614
|
+
const r = t.init(e), n = new Promise((i, o) => {
|
|
4658
4615
|
setTimeout(() => {
|
|
4659
4616
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4660
4617
|
}, 1e4);
|
|
4661
4618
|
});
|
|
4662
|
-
await Promise.race([r,
|
|
4619
|
+
await Promise.race([r, n]), f = t;
|
|
4663
4620
|
} catch (r) {
|
|
4664
4621
|
try {
|
|
4665
4622
|
t.destroy(!0);
|
|
4666
|
-
} catch (
|
|
4667
|
-
a("error", "Failed to cleanup partially initialized app", { error:
|
|
4623
|
+
} catch (n) {
|
|
4624
|
+
a("error", "Failed to cleanup partially initialized app", { error: n });
|
|
4668
4625
|
}
|
|
4669
4626
|
throw r;
|
|
4670
4627
|
}
|
|
@@ -4674,58 +4631,58 @@ const cr = async (n) => {
|
|
|
4674
4631
|
C = !1;
|
|
4675
4632
|
}
|
|
4676
4633
|
}
|
|
4677
|
-
},
|
|
4634
|
+
}, mr = (s, e) => {
|
|
4678
4635
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4679
4636
|
if (!f)
|
|
4680
4637
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4681
4638
|
if (v)
|
|
4682
4639
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4683
|
-
f.sendCustomEvent(
|
|
4640
|
+
f.sendCustomEvent(s, e);
|
|
4684
4641
|
}
|
|
4685
|
-
},
|
|
4642
|
+
}, gr = (s, e) => {
|
|
4686
4643
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4687
4644
|
if (!f || C) {
|
|
4688
|
-
R.push({ event:
|
|
4645
|
+
R.push({ event: s, callback: e });
|
|
4689
4646
|
return;
|
|
4690
4647
|
}
|
|
4691
|
-
f.on(
|
|
4648
|
+
f.on(s, e);
|
|
4692
4649
|
}
|
|
4693
|
-
},
|
|
4650
|
+
}, Er = (s, e) => {
|
|
4694
4651
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4695
4652
|
if (!f) {
|
|
4696
|
-
const t = R.findIndex((r) => r.event ===
|
|
4653
|
+
const t = R.findIndex((r) => r.event === s && r.callback === e);
|
|
4697
4654
|
t !== -1 && R.splice(t, 1);
|
|
4698
4655
|
return;
|
|
4699
4656
|
}
|
|
4700
|
-
f.off(
|
|
4657
|
+
f.off(s, e);
|
|
4701
4658
|
}
|
|
4702
4659
|
};
|
|
4703
|
-
function
|
|
4660
|
+
function Sr(s, e) {
|
|
4704
4661
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4705
4662
|
if (typeof e != "function")
|
|
4706
4663
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4707
4664
|
if (!f || C) {
|
|
4708
|
-
const t = M.findIndex((r) => r.hook ===
|
|
4709
|
-
t !== -1 && M.splice(t, 1), M.push({ hook:
|
|
4665
|
+
const t = M.findIndex((r) => r.hook === s);
|
|
4666
|
+
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4710
4667
|
return;
|
|
4711
4668
|
}
|
|
4712
4669
|
if (v)
|
|
4713
4670
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4714
|
-
|
|
4671
|
+
s === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4715
4672
|
}
|
|
4716
4673
|
}
|
|
4717
|
-
const
|
|
4674
|
+
const pr = (s) => {
|
|
4718
4675
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4719
4676
|
if (!f) {
|
|
4720
|
-
const e = M.findIndex((t) => t.hook ===
|
|
4677
|
+
const e = M.findIndex((t) => t.hook === s);
|
|
4721
4678
|
e !== -1 && M.splice(e, 1);
|
|
4722
4679
|
return;
|
|
4723
4680
|
}
|
|
4724
4681
|
if (v)
|
|
4725
4682
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4726
|
-
f.removeTransformer(
|
|
4683
|
+
f.removeTransformer(s);
|
|
4727
4684
|
}
|
|
4728
|
-
},
|
|
4685
|
+
}, Tr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, _r = () => {
|
|
4729
4686
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4730
4687
|
if (v)
|
|
4731
4688
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4736,272 +4693,272 @@ const mr = (n) => {
|
|
|
4736
4693
|
v = !0;
|
|
4737
4694
|
try {
|
|
4738
4695
|
f.destroy(), f = null, C = !1, R.length = 0, M.length = 0, v = !1;
|
|
4739
|
-
} catch (
|
|
4740
|
-
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error:
|
|
4696
|
+
} catch (s) {
|
|
4697
|
+
f = null, C = !1, R.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4741
4698
|
}
|
|
4742
4699
|
}
|
|
4743
|
-
},
|
|
4744
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4745
|
-
},
|
|
4700
|
+
}, vr = (s) => {
|
|
4701
|
+
typeof window > "u" || typeof document > "u" || kt(s);
|
|
4702
|
+
}, Ir = (s) => {
|
|
4746
4703
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4747
4704
|
if (!f)
|
|
4748
4705
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4749
4706
|
if (v)
|
|
4750
4707
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4751
|
-
f.updateGlobalMetadata(
|
|
4708
|
+
f.updateGlobalMetadata(s);
|
|
4752
4709
|
}
|
|
4753
|
-
},
|
|
4710
|
+
}, wr = (s) => {
|
|
4754
4711
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4755
4712
|
if (!f)
|
|
4756
4713
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4757
4714
|
if (v)
|
|
4758
4715
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4759
|
-
f.mergeGlobalMetadata(
|
|
4760
|
-
}
|
|
4761
|
-
},
|
|
4762
|
-
init:
|
|
4763
|
-
event:
|
|
4764
|
-
on:
|
|
4765
|
-
off:
|
|
4766
|
-
setTransformer:
|
|
4767
|
-
removeTransformer:
|
|
4768
|
-
isInitialized:
|
|
4769
|
-
destroy:
|
|
4770
|
-
setQaMode:
|
|
4771
|
-
updateGlobalMetadata:
|
|
4772
|
-
mergeGlobalMetadata:
|
|
4716
|
+
f.mergeGlobalMetadata(s);
|
|
4717
|
+
}
|
|
4718
|
+
}, Yr = {
|
|
4719
|
+
init: fr,
|
|
4720
|
+
event: mr,
|
|
4721
|
+
on: gr,
|
|
4722
|
+
off: Er,
|
|
4723
|
+
setTransformer: Sr,
|
|
4724
|
+
removeTransformer: pr,
|
|
4725
|
+
isInitialized: Tr,
|
|
4726
|
+
destroy: _r,
|
|
4727
|
+
setQaMode: vr,
|
|
4728
|
+
updateGlobalMetadata: Ir,
|
|
4729
|
+
mergeGlobalMetadata: wr
|
|
4773
4730
|
};
|
|
4774
|
-
var ue,
|
|
4731
|
+
var ue, Ze = -1, P = function(s) {
|
|
4775
4732
|
addEventListener("pageshow", (function(e) {
|
|
4776
|
-
e.persisted && (
|
|
4733
|
+
e.persisted && (Ze = e.timeStamp, s(e));
|
|
4777
4734
|
}), !0);
|
|
4778
4735
|
}, Ee = function() {
|
|
4779
|
-
var
|
|
4780
|
-
if (
|
|
4736
|
+
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4737
|
+
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4781
4738
|
}, q = function() {
|
|
4782
|
-
var
|
|
4783
|
-
return
|
|
4784
|
-
}, b = function(
|
|
4739
|
+
var s = Ee();
|
|
4740
|
+
return s && s.activationStart || 0;
|
|
4741
|
+
}, b = function(s, e) {
|
|
4785
4742
|
var t = Ee(), r = "navigate";
|
|
4786
|
-
return
|
|
4787
|
-
}, F = function(
|
|
4743
|
+
return Ze >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: s, 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 };
|
|
4744
|
+
}, F = function(s, e, t) {
|
|
4788
4745
|
try {
|
|
4789
|
-
if (PerformanceObserver.supportedEntryTypes.includes(
|
|
4790
|
-
var r = new PerformanceObserver((function(
|
|
4746
|
+
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4747
|
+
var r = new PerformanceObserver((function(n) {
|
|
4791
4748
|
Promise.resolve().then((function() {
|
|
4792
|
-
e(
|
|
4749
|
+
e(n.getEntries());
|
|
4793
4750
|
}));
|
|
4794
4751
|
}));
|
|
4795
|
-
return r.observe(Object.assign({ type:
|
|
4752
|
+
return r.observe(Object.assign({ type: s, buffered: !0 }, t || {})), r;
|
|
4796
4753
|
}
|
|
4797
4754
|
} catch {
|
|
4798
4755
|
}
|
|
4799
|
-
}, A = function(
|
|
4800
|
-
var
|
|
4756
|
+
}, A = function(s, e, t, r) {
|
|
4757
|
+
var n, i;
|
|
4801
4758
|
return function(o) {
|
|
4802
|
-
e.value >= 0 && (o || r) && ((i = e.value - (
|
|
4759
|
+
e.value >= 0 && (o || r) && ((i = e.value - (n || 0)) || n === void 0) && (n = e.value, e.delta = i, e.rating = (function(l, c) {
|
|
4803
4760
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4804
|
-
})(e.value, t),
|
|
4761
|
+
})(e.value, t), s(e));
|
|
4805
4762
|
};
|
|
4806
|
-
}, Se = function(
|
|
4763
|
+
}, Se = function(s) {
|
|
4807
4764
|
requestAnimationFrame((function() {
|
|
4808
4765
|
return requestAnimationFrame((function() {
|
|
4809
|
-
return
|
|
4766
|
+
return s();
|
|
4810
4767
|
}));
|
|
4811
4768
|
}));
|
|
4812
|
-
}, J = function(
|
|
4769
|
+
}, J = function(s) {
|
|
4813
4770
|
document.addEventListener("visibilitychange", (function() {
|
|
4814
|
-
document.visibilityState === "hidden" &&
|
|
4771
|
+
document.visibilityState === "hidden" && s();
|
|
4815
4772
|
}));
|
|
4816
|
-
}, pe = function(
|
|
4773
|
+
}, pe = function(s) {
|
|
4817
4774
|
var e = !1;
|
|
4818
4775
|
return function() {
|
|
4819
|
-
e || (
|
|
4776
|
+
e || (s(), e = !0);
|
|
4820
4777
|
};
|
|
4821
|
-
}, O = -1,
|
|
4778
|
+
}, O = -1, He = function() {
|
|
4822
4779
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4823
|
-
}, Y = function(
|
|
4824
|
-
document.visibilityState === "hidden" && O > -1 && (O =
|
|
4825
|
-
},
|
|
4780
|
+
}, Y = function(s) {
|
|
4781
|
+
document.visibilityState === "hidden" && O > -1 && (O = s.type === "visibilitychange" ? s.timeStamp : 0, yr());
|
|
4782
|
+
}, Fe = function() {
|
|
4826
4783
|
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4827
|
-
},
|
|
4784
|
+
}, yr = function() {
|
|
4828
4785
|
removeEventListener("visibilitychange", Y, !0), removeEventListener("prerenderingchange", Y, !0);
|
|
4829
|
-
},
|
|
4830
|
-
return O < 0 && (O =
|
|
4786
|
+
}, et = function() {
|
|
4787
|
+
return O < 0 && (O = He(), Fe(), P((function() {
|
|
4831
4788
|
setTimeout((function() {
|
|
4832
|
-
O =
|
|
4789
|
+
O = He(), Fe();
|
|
4833
4790
|
}), 0);
|
|
4834
4791
|
}))), { get firstHiddenTime() {
|
|
4835
4792
|
return O;
|
|
4836
4793
|
} };
|
|
4837
|
-
}, Z = function(
|
|
4794
|
+
}, Z = function(s) {
|
|
4838
4795
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4839
|
-
return
|
|
4840
|
-
}), !0) :
|
|
4841
|
-
}, de = [1800, 3e3],
|
|
4796
|
+
return s();
|
|
4797
|
+
}), !0) : s();
|
|
4798
|
+
}, de = [1800, 3e3], tt = function(s, e) {
|
|
4842
4799
|
e = e || {}, Z((function() {
|
|
4843
|
-
var t, r =
|
|
4800
|
+
var t, r = et(), n = b("FCP"), i = F("paint", (function(o) {
|
|
4844
4801
|
o.forEach((function(l) {
|
|
4845
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (
|
|
4802
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime - q(), 0), n.entries.push(l), t(!0)));
|
|
4846
4803
|
}));
|
|
4847
4804
|
}));
|
|
4848
|
-
i && (t = A(
|
|
4849
|
-
|
|
4850
|
-
|
|
4805
|
+
i && (t = A(s, n, de, e.reportAllChanges), P((function(o) {
|
|
4806
|
+
n = b("FCP"), t = A(s, n, de, e.reportAllChanges), Se((function() {
|
|
4807
|
+
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4851
4808
|
}));
|
|
4852
4809
|
})));
|
|
4853
4810
|
}));
|
|
4854
|
-
}, he = [0.1, 0.25],
|
|
4855
|
-
e = e || {},
|
|
4856
|
-
var t, r = b("CLS", 0),
|
|
4811
|
+
}, he = [0.1, 0.25], br = function(s, e) {
|
|
4812
|
+
e = e || {}, tt(pe((function() {
|
|
4813
|
+
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4857
4814
|
c.forEach((function(u) {
|
|
4858
4815
|
if (!u.hadRecentInput) {
|
|
4859
4816
|
var S = i[0], g = i[i.length - 1];
|
|
4860
|
-
|
|
4817
|
+
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
4861
4818
|
}
|
|
4862
|
-
})),
|
|
4819
|
+
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4863
4820
|
}, l = F("layout-shift", o);
|
|
4864
|
-
l && (t = A(
|
|
4821
|
+
l && (t = A(s, r, he, e.reportAllChanges), J((function() {
|
|
4865
4822
|
o(l.takeRecords()), t(!0);
|
|
4866
4823
|
})), P((function() {
|
|
4867
|
-
|
|
4824
|
+
n = 0, r = b("CLS", 0), t = A(s, r, he, e.reportAllChanges), Se((function() {
|
|
4868
4825
|
return t();
|
|
4869
4826
|
}));
|
|
4870
4827
|
})), setTimeout(t, 0));
|
|
4871
4828
|
})));
|
|
4872
|
-
},
|
|
4873
|
-
|
|
4874
|
-
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId),
|
|
4829
|
+
}, rt = 0, re = 1 / 0, G = 0, Ar = function(s) {
|
|
4830
|
+
s.forEach((function(e) {
|
|
4831
|
+
e.interactionId && (re = Math.min(re, e.interactionId), G = Math.max(G, e.interactionId), rt = G ? (G - re) / 7 + 1 : 0);
|
|
4875
4832
|
}));
|
|
4876
|
-
},
|
|
4877
|
-
return ue ?
|
|
4878
|
-
},
|
|
4879
|
-
"interactionCount" in performance || ue || (ue = F("event",
|
|
4880
|
-
}, y = [], j = /* @__PURE__ */ new Map(),
|
|
4881
|
-
var
|
|
4882
|
-
return y[
|
|
4883
|
-
},
|
|
4884
|
-
if (
|
|
4885
|
-
return s
|
|
4886
|
-
})),
|
|
4887
|
-
var e = y[y.length - 1], t = j.get(
|
|
4888
|
-
if (t || y.length < 10 ||
|
|
4889
|
-
if (t)
|
|
4833
|
+
}, st = function() {
|
|
4834
|
+
return ue ? rt : performance.interactionCount || 0;
|
|
4835
|
+
}, Lr = function() {
|
|
4836
|
+
"interactionCount" in performance || ue || (ue = F("event", Ar, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4837
|
+
}, y = [], j = /* @__PURE__ */ new Map(), nt = 0, Mr = function() {
|
|
4838
|
+
var s = Math.min(y.length - 1, Math.floor((st() - nt) / 50));
|
|
4839
|
+
return y[s];
|
|
4840
|
+
}, Cr = [], Rr = function(s) {
|
|
4841
|
+
if (Cr.forEach((function(n) {
|
|
4842
|
+
return n(s);
|
|
4843
|
+
})), s.interactionId || s.entryType === "first-input") {
|
|
4844
|
+
var e = y[y.length - 1], t = j.get(s.interactionId);
|
|
4845
|
+
if (t || y.length < 10 || s.duration > e.latency) {
|
|
4846
|
+
if (t) s.duration > t.latency ? (t.entries = [s], t.latency = s.duration) : s.duration === t.latency && s.startTime === t.entries[0].startTime && t.entries.push(s);
|
|
4890
4847
|
else {
|
|
4891
|
-
var r = { id:
|
|
4848
|
+
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
4892
4849
|
j.set(r.id, r), y.push(r);
|
|
4893
4850
|
}
|
|
4894
|
-
y.sort((function(
|
|
4895
|
-
return i.latency -
|
|
4896
|
-
})), y.length > 10 && y.splice(10).forEach((function(
|
|
4897
|
-
return j.delete(
|
|
4851
|
+
y.sort((function(n, i) {
|
|
4852
|
+
return i.latency - n.latency;
|
|
4853
|
+
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
4854
|
+
return j.delete(n.id);
|
|
4898
4855
|
}));
|
|
4899
4856
|
}
|
|
4900
4857
|
}
|
|
4901
|
-
},
|
|
4858
|
+
}, it = function(s) {
|
|
4902
4859
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4903
|
-
return
|
|
4904
|
-
}, fe = [200, 500],
|
|
4860
|
+
return s = pe(s), document.visibilityState === "hidden" ? s() : (t = e(s), J(s)), t;
|
|
4861
|
+
}, fe = [200, 500], Nr = function(s, e) {
|
|
4905
4862
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4906
4863
|
var t;
|
|
4907
|
-
|
|
4908
|
-
var r,
|
|
4909
|
-
|
|
4910
|
-
l.forEach(
|
|
4911
|
-
var c =
|
|
4912
|
-
c && c.latency !==
|
|
4864
|
+
Lr();
|
|
4865
|
+
var r, n = b("INP"), i = function(l) {
|
|
4866
|
+
it((function() {
|
|
4867
|
+
l.forEach(Rr);
|
|
4868
|
+
var c = Mr();
|
|
4869
|
+
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
4913
4870
|
}));
|
|
4914
4871
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4915
|
-
r = A(
|
|
4872
|
+
r = A(s, n, fe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4916
4873
|
i(o.takeRecords()), r(!0);
|
|
4917
4874
|
})), P((function() {
|
|
4918
|
-
|
|
4875
|
+
nt = st(), y.length = 0, j.clear(), n = b("INP"), r = A(s, n, fe, e.reportAllChanges);
|
|
4919
4876
|
})));
|
|
4920
4877
|
})));
|
|
4921
|
-
}, me = [2500, 4e3],
|
|
4878
|
+
}, me = [2500, 4e3], se = {}, Or = function(s, e) {
|
|
4922
4879
|
e = e || {}, Z((function() {
|
|
4923
|
-
var t, r =
|
|
4880
|
+
var t, r = et(), n = b("LCP"), i = function(c) {
|
|
4924
4881
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4925
|
-
u.startTime < r.firstHiddenTime && (
|
|
4882
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - q(), 0), n.entries = [u], t());
|
|
4926
4883
|
}));
|
|
4927
4884
|
}, o = F("largest-contentful-paint", i);
|
|
4928
4885
|
if (o) {
|
|
4929
|
-
t = A(
|
|
4886
|
+
t = A(s, n, me, e.reportAllChanges);
|
|
4930
4887
|
var l = pe((function() {
|
|
4931
|
-
|
|
4888
|
+
se[n.id] || (i(o.takeRecords()), o.disconnect(), se[n.id] = !0, t(!0));
|
|
4932
4889
|
}));
|
|
4933
4890
|
["keydown", "click"].forEach((function(c) {
|
|
4934
4891
|
addEventListener(c, (function() {
|
|
4935
|
-
return
|
|
4892
|
+
return it(l);
|
|
4936
4893
|
}), { once: !0, capture: !0 });
|
|
4937
4894
|
})), J(l), P((function(c) {
|
|
4938
|
-
|
|
4939
|
-
|
|
4895
|
+
n = b("LCP"), t = A(s, n, me, e.reportAllChanges), Se((function() {
|
|
4896
|
+
n.value = performance.now() - c.timeStamp, se[n.id] = !0, t(!0);
|
|
4940
4897
|
}));
|
|
4941
4898
|
}));
|
|
4942
4899
|
}
|
|
4943
4900
|
}));
|
|
4944
|
-
}, ge = [800, 1800],
|
|
4901
|
+
}, ge = [800, 1800], Pr = function s(e) {
|
|
4945
4902
|
document.prerendering ? Z((function() {
|
|
4946
|
-
return
|
|
4903
|
+
return s(e);
|
|
4947
4904
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4948
|
-
return
|
|
4905
|
+
return s(e);
|
|
4949
4906
|
}), !0) : setTimeout(e, 0);
|
|
4950
|
-
},
|
|
4907
|
+
}, Dr = function(s, e) {
|
|
4951
4908
|
e = e || {};
|
|
4952
|
-
var t = b("TTFB"), r = A(
|
|
4953
|
-
|
|
4954
|
-
var
|
|
4955
|
-
|
|
4956
|
-
t = b("TTFB", 0), (r = A(
|
|
4909
|
+
var t = b("TTFB"), r = A(s, t, ge, e.reportAllChanges);
|
|
4910
|
+
Pr((function() {
|
|
4911
|
+
var n = Ee();
|
|
4912
|
+
n && (t.value = Math.max(n.responseStart - q(), 0), t.entries = [n], r(!0), P((function() {
|
|
4913
|
+
t = b("TTFB", 0), (r = A(s, t, ge, e.reportAllChanges))(!0);
|
|
4957
4914
|
})));
|
|
4958
4915
|
}));
|
|
4959
4916
|
};
|
|
4960
|
-
const
|
|
4917
|
+
const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4961
4918
|
__proto__: null,
|
|
4962
4919
|
CLSThresholds: he,
|
|
4963
4920
|
FCPThresholds: de,
|
|
4964
4921
|
INPThresholds: fe,
|
|
4965
4922
|
LCPThresholds: me,
|
|
4966
4923
|
TTFBThresholds: ge,
|
|
4967
|
-
onCLS:
|
|
4968
|
-
onFCP:
|
|
4969
|
-
onINP:
|
|
4970
|
-
onLCP:
|
|
4971
|
-
onTTFB:
|
|
4924
|
+
onCLS: br,
|
|
4925
|
+
onFCP: tt,
|
|
4926
|
+
onINP: Nr,
|
|
4927
|
+
onLCP: Or,
|
|
4928
|
+
onTTFB: Dr
|
|
4972
4929
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4973
4930
|
export {
|
|
4974
4931
|
h as AppConfigValidationError,
|
|
4975
|
-
|
|
4932
|
+
kr as DEFAULT_SESSION_TIMEOUT,
|
|
4976
4933
|
ae as DEFAULT_WEB_VITALS_MODE,
|
|
4977
4934
|
L as DeviceType,
|
|
4978
|
-
|
|
4935
|
+
ne as EmitterEvent,
|
|
4979
4936
|
U as ErrorType,
|
|
4980
4937
|
d as EventType,
|
|
4981
|
-
|
|
4938
|
+
zr as InitializationTimeoutError,
|
|
4982
4939
|
V as IntegrationValidationError,
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4940
|
+
Xr as MAX_ARRAY_LENGTH,
|
|
4941
|
+
Fr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4942
|
+
Hr as MAX_CUSTOM_EVENT_KEYS,
|
|
4943
|
+
Ur as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4944
|
+
xr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4945
|
+
Br as MAX_METADATA_NESTING_DEPTH,
|
|
4946
|
+
$r as MAX_NESTED_OBJECT_KEYS,
|
|
4947
|
+
Wr as MAX_STRING_LENGTH,
|
|
4948
|
+
Gr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4992
4949
|
z as Mode,
|
|
4993
|
-
|
|
4950
|
+
Xe as PII_PATTERNS,
|
|
4994
4951
|
N as PermanentError,
|
|
4995
|
-
|
|
4952
|
+
Le as SamplingRateValidationError,
|
|
4996
4953
|
X as ScrollDirection,
|
|
4997
|
-
|
|
4954
|
+
ft as SessionTimeoutValidationError,
|
|
4998
4955
|
k as SpecialApiUrl,
|
|
4999
4956
|
H as TraceLogValidationError,
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
4957
|
+
Kr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4958
|
+
Ne as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4959
|
+
Ct as WEB_VITALS_POOR_THRESHOLDS,
|
|
4960
|
+
Oe as getWebVitalsThresholds,
|
|
4961
|
+
Qr as isPrimaryScrollEvent,
|
|
4962
|
+
jr as isSecondaryScrollEvent,
|
|
4963
|
+
Yr as tracelog
|
|
5007
4964
|
};
|