@tracelog/lib 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +821 -815
- 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 +6144 -6820
- 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 +6112 -6820
- 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 Vr = 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
|
|
81
|
+
], I = "tlog", x = `${I}:qa_mode`, Ie = `${I}:uid`, $e = "tlog_mode", we = "qa", ye = "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`, be = (s, e) => `${I}:${s}:session_counts:${e}`, Ae = 10080 * 60 * 1e3, Le = `${I}:session_counts_last_cleanup`, Me = 3600 * 1e3;
|
|
82
|
+
var V = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(V || {}), L = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(L || {}), oe = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(oe || {});
|
|
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,46 +97,46 @@ 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 Re extends H {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
class
|
|
110
|
+
class k extends H {
|
|
111
111
|
constructor(e, t = "config") {
|
|
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
|
-
},
|
|
151
|
+
const g = pt(l, o), p = n !== void 0 ? ae(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
|
+
}, ae = (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
|
-
|
|
165
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
166
|
-
) : e[r] =
|
|
164
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] = ae(n) : Array.isArray(n) ? e[r] = n.map(
|
|
165
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ae(o) : o
|
|
166
|
+
) : e[r] = n;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let
|
|
171
|
-
const
|
|
172
|
-
typeof window < "u" && !
|
|
173
|
-
}, K = "Unknown",
|
|
174
|
-
const e =
|
|
170
|
+
let le, Ge;
|
|
171
|
+
const _t = () => {
|
|
172
|
+
typeof window < "u" && !le && (le = 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 =
|
|
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 = le?.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
|
+
], Ce = 500, Ne = 5e3, Q = 50, bt = Q * 2, Qe = 1, At = 1e3, Lt = 10, Oe = 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
|
+
}, Pe = {
|
|
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
|
+
}, Rt = {
|
|
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
|
-
},
|
|
276
|
-
switch (
|
|
275
|
+
}, ce = "needs-improvement", De = (s = ce) => {
|
|
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 Pe;
|
|
282
282
|
case "poor":
|
|
283
|
-
return
|
|
283
|
+
return Rt;
|
|
284
284
|
default:
|
|
285
|
-
return
|
|
285
|
+
return Pe;
|
|
286
286
|
}
|
|
287
|
-
},
|
|
287
|
+
}, Ct = 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
|
+
}, kt = () => {
|
|
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 === we ? (r = !0, sessionStorage.setItem(x, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
302
|
visibility: "qa",
|
|
303
|
-
style:
|
|
304
|
-
})) : e ===
|
|
303
|
+
style: Be
|
|
304
|
+
})) : e === ye && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
305
|
visibility: "qa",
|
|
306
|
-
style:
|
|
307
|
-
})), (e ===
|
|
306
|
+
style: We
|
|
307
|
+
})), (e === we || e === ye) && Dt(), r ?? t === "true";
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
312
|
-
if (
|
|
311
|
+
}, Vt = (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
|
+
], ke = (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 : ke(s) === ke(e), te = () => {
|
|
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
|
+
}, re = () => {
|
|
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,145 +394,145 @@ 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
|
-
},
|
|
391
|
-
if (!
|
|
392
|
-
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof
|
|
418
|
+
}, ue = (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
|
+
}, Ve = (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
|
-
},
|
|
420
|
-
if (e > 3 ||
|
|
447
|
+
}, de = (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 Ve(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) => de(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 = Ve(i);
|
|
434
462
|
if (l) {
|
|
435
|
-
const c =
|
|
463
|
+
const c = de(o, e + 1);
|
|
436
464
|
c !== null && (t[l] = c);
|
|
437
465
|
}
|
|
438
466
|
}
|
|
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 =
|
|
474
|
+
const e = de(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 Re(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 Re(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 (
|
|
554
|
-
throw new
|
|
555
|
-
if (
|
|
556
|
-
if (!
|
|
557
|
-
throw new
|
|
558
|
-
if (
|
|
559
|
-
throw new
|
|
560
|
-
const e =
|
|
579
|
+
}, Qt = (s) => {
|
|
580
|
+
if (s) {
|
|
581
|
+
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
582
|
+
throw new k(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
583
|
+
if (s.custom) {
|
|
584
|
+
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
585
|
+
throw new k(m.INVALID_CUSTOM_API_URL, "config");
|
|
586
|
+
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
587
|
+
throw new k("allowHttp must be a boolean", "config");
|
|
588
|
+
const e = s.custom.collectApiUrl.trim();
|
|
561
589
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
562
|
-
throw new
|
|
563
|
-
if (!(
|
|
564
|
-
throw new
|
|
590
|
+
throw new k('Custom API URL must start with "http://" or "https://"', "config");
|
|
591
|
+
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
592
|
+
throw new k(
|
|
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,37 +884,37 @@ 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
|
-
const
|
|
917
|
+
const se = {};
|
|
890
918
|
class _ {
|
|
891
919
|
/**
|
|
892
920
|
* Retrieves a value from global state.
|
|
@@ -905,7 +933,7 @@ class _ {
|
|
|
905
933
|
* ```
|
|
906
934
|
*/
|
|
907
935
|
get(e) {
|
|
908
|
-
return
|
|
936
|
+
return se[e];
|
|
909
937
|
}
|
|
910
938
|
/**
|
|
911
939
|
* Sets a value in global state.
|
|
@@ -925,7 +953,7 @@ class _ {
|
|
|
925
953
|
* ```
|
|
926
954
|
*/
|
|
927
955
|
set(e, t) {
|
|
928
|
-
|
|
956
|
+
se[e] = t;
|
|
929
957
|
}
|
|
930
958
|
/**
|
|
931
959
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -942,10 +970,10 @@ class _ {
|
|
|
942
970
|
* ```
|
|
943
971
|
*/
|
|
944
972
|
getState() {
|
|
945
|
-
return { ...
|
|
973
|
+
return { ...se };
|
|
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
|
/**
|
|
@@ -1011,13 +1039,13 @@ class Ve extends _ {
|
|
|
1011
1039
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1012
1040
|
*/
|
|
1013
1041
|
sendEventsQueueSync(e) {
|
|
1014
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1042
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(V.Fail) ? (a(
|
|
1015
1043
|
"warn",
|
|
1016
1044
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1017
1045
|
{
|
|
1018
1046
|
data: { events: e.events.length }
|
|
1019
1047
|
}
|
|
1020
|
-
), !1) : this.apiUrl?.includes(
|
|
1048
|
+
), !1) : this.apiUrl?.includes(V.Localhost) ? (a(
|
|
1021
1049
|
"debug",
|
|
1022
1050
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1023
1051
|
{
|
|
@@ -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.
|
|
@@ -1293,18 +1321,18 @@ class Ve extends _ {
|
|
|
1293
1321
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1294
1322
|
if (!r)
|
|
1295
1323
|
return !0;
|
|
1296
|
-
if (this.apiUrl?.includes(
|
|
1324
|
+
if (this.apiUrl?.includes(V.Fail))
|
|
1297
1325
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1298
1326
|
data: { events: r.events.length }
|
|
1299
1327
|
}), !1;
|
|
1300
|
-
if (this.apiUrl?.includes(
|
|
1328
|
+
if (this.apiUrl?.includes(V.Localhost))
|
|
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 ve = 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 (ve) {
|
|
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(oe.EVENT, e);
|
|
2433
2462
|
}
|
|
2434
2463
|
emitEventsQueue(e) {
|
|
2435
|
-
this.emitter && this.emitter.emit(
|
|
2464
|
+
this.emitter && this.emitter.emit(oe.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 = be(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 > Ae ? (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(Le);
|
|
2563
2592
|
if (e) {
|
|
2564
2593
|
const i = Date.now() - parseInt(e, 10);
|
|
2565
|
-
if (i <
|
|
2594
|
+
if (i < Me) {
|
|
2566
2595
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2567
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2596
|
+
data: { timeSinceLastCleanup: i, throttleMs: Me }
|
|
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 > Ae && 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(Le, 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 = be(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(Ie);
|
|
2738
2685
|
if (t)
|
|
2739
2686
|
return t;
|
|
2740
|
-
const r =
|
|
2741
|
-
return e.setItem(
|
|
2687
|
+
const r = Ht();
|
|
2688
|
+
return e.setItem(Ie, 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;
|
|
@@ -2751,6 +2698,7 @@ class Zt extends _ {
|
|
|
2751
2698
|
sessionTimeoutId = null;
|
|
2752
2699
|
broadcastChannel = null;
|
|
2753
2700
|
isTracking = !1;
|
|
2701
|
+
needsRenewal = !1;
|
|
2754
2702
|
/**
|
|
2755
2703
|
* Creates a SessionManager instance.
|
|
2756
2704
|
*
|
|
@@ -2767,9 +2715,9 @@ class Zt extends _ {
|
|
|
2767
2715
|
return;
|
|
2768
2716
|
}
|
|
2769
2717
|
const e = this.getProjectId();
|
|
2770
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2771
|
-
const { action: r, sessionId:
|
|
2772
|
-
o === e && (r === "session_start" &&
|
|
2718
|
+
this.broadcastChannel = new BroadcastChannel(ht(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2719
|
+
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2720
|
+
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
2721
|
};
|
|
2774
2722
|
}
|
|
2775
2723
|
shareSession(e) {
|
|
@@ -2787,17 +2735,19 @@ class Zt extends _ {
|
|
|
2787
2735
|
const e = this.loadStoredSession();
|
|
2788
2736
|
if (!e)
|
|
2789
2737
|
return null;
|
|
2790
|
-
if (!
|
|
2738
|
+
if (!rr.test(e.id))
|
|
2791
2739
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2792
2740
|
data: { sessionId: e.id }
|
|
2793
2741
|
}), this.clearStoredSession(), null;
|
|
2794
2742
|
const t = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2795
2743
|
return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
|
|
2796
2744
|
}
|
|
2797
|
-
persistSession(e, t = Date.now()) {
|
|
2745
|
+
persistSession(e, t = Date.now(), r, n) {
|
|
2798
2746
|
this.saveStoredSession({
|
|
2799
2747
|
id: e,
|
|
2800
|
-
lastActivity: t
|
|
2748
|
+
lastActivity: t,
|
|
2749
|
+
...r && { referrer: r },
|
|
2750
|
+
...n && { utm: n }
|
|
2801
2751
|
});
|
|
2802
2752
|
}
|
|
2803
2753
|
clearStoredSession() {
|
|
@@ -2820,7 +2770,7 @@ class Zt extends _ {
|
|
|
2820
2770
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2821
2771
|
}
|
|
2822
2772
|
getSessionStorageKey() {
|
|
2823
|
-
return
|
|
2773
|
+
return dt(this.getProjectId());
|
|
2824
2774
|
}
|
|
2825
2775
|
getProjectId() {
|
|
2826
2776
|
return this.projectId;
|
|
@@ -2882,21 +2832,31 @@ class Zt extends _ {
|
|
|
2882
2832
|
return;
|
|
2883
2833
|
}
|
|
2884
2834
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
2835
|
+
let r, n;
|
|
2836
|
+
if (e) {
|
|
2837
|
+
const i = this.loadStoredSession();
|
|
2838
|
+
r = i?.referrer ?? te(), n = i?.utm ?? re();
|
|
2839
|
+
} else
|
|
2840
|
+
r = te(), n = re();
|
|
2885
2841
|
a("debug", "Session tracking initialized", {
|
|
2886
2842
|
data: {
|
|
2887
2843
|
sessionId: t,
|
|
2888
2844
|
wasRecovered: !!e,
|
|
2889
|
-
willEmitSessionStart: !
|
|
2845
|
+
willEmitSessionStart: !e,
|
|
2846
|
+
sessionReferrer: r,
|
|
2847
|
+
hasUtm: !!n
|
|
2890
2848
|
}
|
|
2891
2849
|
}), this.isTracking = !0;
|
|
2892
2850
|
try {
|
|
2893
|
-
this.set("sessionId", t), this.persistSession(t), this.initCrossTabSync(), this.shareSession(t), a("debug", "
|
|
2851
|
+
this.set("sessionId", t), this.set("sessionReferrer", r), this.set("sessionUtm", n), this.persistSession(t, Date.now(), r, n), this.initCrossTabSync(), this.shareSession(t), e ? a("debug", "Session recovered, skipping SESSION_START", {
|
|
2852
|
+
data: { sessionId: t }
|
|
2853
|
+
}) : (a("debug", "Emitting SESSION_START event", {
|
|
2894
2854
|
data: { sessionId: t }
|
|
2895
2855
|
}), this.eventManager.track({
|
|
2896
2856
|
type: d.SESSION_START
|
|
2897
|
-
}), 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),
|
|
2857
|
+
})), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2858
|
+
} catch (i) {
|
|
2859
|
+
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
|
|
2900
2860
|
}
|
|
2901
2861
|
}
|
|
2902
2862
|
generateSessionId() {
|
|
@@ -2906,35 +2866,81 @@ class Zt extends _ {
|
|
|
2906
2866
|
this.clearSessionTimeout();
|
|
2907
2867
|
const e = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2908
2868
|
this.sessionTimeoutId = setTimeout(() => {
|
|
2909
|
-
this.
|
|
2869
|
+
this.enterRenewalMode();
|
|
2910
2870
|
}, e);
|
|
2911
2871
|
}
|
|
2912
2872
|
resetSessionTimeout() {
|
|
2913
2873
|
this.setupSessionTimeout();
|
|
2914
2874
|
const e = this.get("sessionId");
|
|
2915
|
-
e && this.persistSession(e);
|
|
2875
|
+
e && this.persistSession(e, Date.now(), this.get("sessionReferrer"), this.get("sessionUtm"));
|
|
2916
2876
|
}
|
|
2917
2877
|
clearSessionTimeout() {
|
|
2918
2878
|
this.sessionTimeoutId && (clearTimeout(this.sessionTimeoutId), this.sessionTimeoutId = null);
|
|
2919
2879
|
}
|
|
2920
2880
|
setupActivityListeners() {
|
|
2921
2881
|
this.activityHandler = () => {
|
|
2922
|
-
this.resetSessionTimeout();
|
|
2882
|
+
this.needsRenewal ? this.renewSession() : this.resetSessionTimeout();
|
|
2923
2883
|
}, document.addEventListener("click", this.activityHandler, { passive: !0 }), document.addEventListener("keydown", this.activityHandler, { passive: !0 }), document.addEventListener("scroll", this.activityHandler, { passive: !0 });
|
|
2924
2884
|
}
|
|
2885
|
+
/**
|
|
2886
|
+
* Renews the session after timeout when user returns.
|
|
2887
|
+
* Creates a new session ID and emits SESSION_START.
|
|
2888
|
+
*/
|
|
2889
|
+
renewSession() {
|
|
2890
|
+
this.needsRenewal = !1;
|
|
2891
|
+
const e = this.generateSessionId(), t = te(), r = re();
|
|
2892
|
+
a("debug", "Renewing session after timeout", {
|
|
2893
|
+
data: { newSessionId: e }
|
|
2894
|
+
}), this.set("sessionId", e), this.set("sessionReferrer", t), this.set("sessionUtm", r), this.persistSession(e, Date.now(), t, r), this.cleanupCrossTabSync(), this.initCrossTabSync(), this.shareSession(e), this.eventManager.track({
|
|
2895
|
+
type: d.SESSION_START
|
|
2896
|
+
}), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
|
|
2897
|
+
}
|
|
2925
2898
|
cleanupActivityListeners() {
|
|
2926
2899
|
this.activityHandler && (document.removeEventListener("click", this.activityHandler), document.removeEventListener("keydown", this.activityHandler), document.removeEventListener("scroll", this.activityHandler), this.activityHandler = null);
|
|
2927
2900
|
}
|
|
2928
2901
|
setupLifecycleListeners() {
|
|
2929
2902
|
this.visibilityChangeHandler || (this.visibilityChangeHandler = () => {
|
|
2930
|
-
document.hidden
|
|
2903
|
+
if (document.hidden)
|
|
2904
|
+
this.clearSessionTimeout();
|
|
2905
|
+
else {
|
|
2906
|
+
if (this.isSessionStale()) {
|
|
2907
|
+
a("debug", "Session expired during suspend, entering renewal mode"), this.enterRenewalMode();
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2910
|
+
this.get("sessionId") && this.setupSessionTimeout();
|
|
2911
|
+
}
|
|
2931
2912
|
}, document.addEventListener("visibilitychange", this.visibilityChangeHandler));
|
|
2932
2913
|
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Checks if the current session has become stale (expired during browser suspend).
|
|
2916
|
+
* This handles the case where JavaScript timers are paused during suspend/hibernate.
|
|
2917
|
+
*/
|
|
2918
|
+
isSessionStale() {
|
|
2919
|
+
if (this.needsRenewal || !this.get("sessionId"))
|
|
2920
|
+
return !1;
|
|
2921
|
+
const t = this.loadStoredSession();
|
|
2922
|
+
if (!t)
|
|
2923
|
+
return !1;
|
|
2924
|
+
const r = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2925
|
+
return Date.now() - t.lastActivity > r;
|
|
2926
|
+
}
|
|
2933
2927
|
cleanupLifecycleListeners() {
|
|
2934
2928
|
this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null);
|
|
2935
2929
|
}
|
|
2930
|
+
/**
|
|
2931
|
+
* Enters renewal mode after session timeout.
|
|
2932
|
+
* Keeps activity listeners active to detect when user returns.
|
|
2933
|
+
* Called by session timeout timer.
|
|
2934
|
+
*/
|
|
2935
|
+
enterRenewalMode() {
|
|
2936
|
+
this.clearSessionTimeout(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.needsRenewal = !0, a("debug", "Session timed out, entering renewal mode");
|
|
2937
|
+
}
|
|
2938
|
+
/**
|
|
2939
|
+
* Fully resets session state and cleans up all resources.
|
|
2940
|
+
* Called by stopTracking() for explicit session termination.
|
|
2941
|
+
*/
|
|
2936
2942
|
resetSessionState() {
|
|
2937
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.isTracking = !1;
|
|
2943
|
+
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.needsRenewal = !1, this.isTracking = !1;
|
|
2938
2944
|
}
|
|
2939
2945
|
/**
|
|
2940
2946
|
* Stops session tracking and cleans up all resources.
|
|
@@ -3000,10 +3006,10 @@ class Zt extends _ {
|
|
|
3000
3006
|
* ```
|
|
3001
3007
|
*/
|
|
3002
3008
|
destroy() {
|
|
3003
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
3009
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3004
3010
|
}
|
|
3005
3011
|
}
|
|
3006
|
-
class
|
|
3012
|
+
class nr extends _ {
|
|
3007
3013
|
eventManager;
|
|
3008
3014
|
storageManager;
|
|
3009
3015
|
sessionManager = null;
|
|
@@ -3038,7 +3044,7 @@ class er extends _ {
|
|
|
3038
3044
|
}
|
|
3039
3045
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3040
3046
|
try {
|
|
3041
|
-
this.sessionManager = new
|
|
3047
|
+
this.sessionManager = new sr(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3042
3048
|
} catch (r) {
|
|
3043
3049
|
if (this.sessionManager) {
|
|
3044
3050
|
try {
|
|
@@ -3091,7 +3097,7 @@ class er extends _ {
|
|
|
3091
3097
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3092
3098
|
}
|
|
3093
3099
|
}
|
|
3094
|
-
class
|
|
3100
|
+
class ir extends _ {
|
|
3095
3101
|
eventManager;
|
|
3096
3102
|
onTrack;
|
|
3097
3103
|
originalPushState;
|
|
@@ -3131,11 +3137,11 @@ class tr extends _ {
|
|
|
3131
3137
|
};
|
|
3132
3138
|
}
|
|
3133
3139
|
trackCurrentPage = () => {
|
|
3134
|
-
const e = window.location.href, t =
|
|
3140
|
+
const e = window.location.href, t = ue(e, this.get("config").sensitiveQueryParams);
|
|
3135
3141
|
if (this.get("pageUrl") === t)
|
|
3136
3142
|
return;
|
|
3137
|
-
const r = Date.now(),
|
|
3138
|
-
if (r - this.lastPageViewTime <
|
|
3143
|
+
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
3144
|
+
if (r - this.lastPageViewTime < n)
|
|
3139
3145
|
return;
|
|
3140
3146
|
this.lastPageViewTime = r, this.onTrack();
|
|
3141
3147
|
const i = this.get("pageUrl");
|
|
@@ -3149,7 +3155,7 @@ class tr extends _ {
|
|
|
3149
3155
|
});
|
|
3150
3156
|
};
|
|
3151
3157
|
trackInitialPageView() {
|
|
3152
|
-
const e =
|
|
3158
|
+
const e = ue(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3153
3159
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3154
3160
|
type: d.PAGE_VIEW,
|
|
3155
3161
|
page_url: e,
|
|
@@ -3157,9 +3163,9 @@ class tr extends _ {
|
|
|
3157
3163
|
}), this.onTrack();
|
|
3158
3164
|
}
|
|
3159
3165
|
extractPageViewData() {
|
|
3160
|
-
const { pathname: e, search: t, hash: r } = window.location, { referrer:
|
|
3161
|
-
return !
|
|
3162
|
-
...
|
|
3166
|
+
const { pathname: e, search: t, hash: r } = window.location, { referrer: n } = document, { title: i } = document;
|
|
3167
|
+
return !n && !i && !e && !t && !r ? void 0 : {
|
|
3168
|
+
...n && { referrer: n },
|
|
3163
3169
|
...i && { title: i },
|
|
3164
3170
|
...e && { pathname: e },
|
|
3165
3171
|
...t && { search: t },
|
|
@@ -3167,7 +3173,7 @@ class tr extends _ {
|
|
|
3167
3173
|
};
|
|
3168
3174
|
}
|
|
3169
3175
|
}
|
|
3170
|
-
class
|
|
3176
|
+
class or extends _ {
|
|
3171
3177
|
eventManager;
|
|
3172
3178
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3173
3179
|
clickHandler;
|
|
@@ -3190,17 +3196,17 @@ class rr extends _ {
|
|
|
3190
3196
|
*/
|
|
3191
3197
|
startTracking() {
|
|
3192
3198
|
this.clickHandler || (this.clickHandler = (e) => {
|
|
3193
|
-
const t = e, r = t.target,
|
|
3194
|
-
if (!
|
|
3199
|
+
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;
|
|
3200
|
+
if (!n) {
|
|
3195
3201
|
a("debug", "Click target not found or not an element");
|
|
3196
3202
|
return;
|
|
3197
3203
|
}
|
|
3198
|
-
if (this.shouldIgnoreElement(
|
|
3204
|
+
if (this.shouldIgnoreElement(n))
|
|
3199
3205
|
return;
|
|
3200
3206
|
const i = this.get("config")?.clickThrottleMs ?? 300;
|
|
3201
|
-
if (i > 0 && !this.checkClickThrottle(
|
|
3207
|
+
if (i > 0 && !this.checkClickThrottle(n, i))
|
|
3202
3208
|
return;
|
|
3203
|
-
const o = this.findTrackingElement(
|
|
3209
|
+
const o = this.findTrackingElement(n), l = this.getRelevantClickElement(n), c = this.calculateClickCoordinates(t, n);
|
|
3204
3210
|
if (o) {
|
|
3205
3211
|
const S = this.extractTrackingData(o);
|
|
3206
3212
|
if (S) {
|
|
@@ -3214,7 +3220,7 @@ class rr extends _ {
|
|
|
3214
3220
|
});
|
|
3215
3221
|
}
|
|
3216
3222
|
}
|
|
3217
|
-
const u = this.generateClickData(
|
|
3223
|
+
const u = this.generateClickData(n, l, c);
|
|
3218
3224
|
this.eventManager.track({
|
|
3219
3225
|
type: d.CLICK,
|
|
3220
3226
|
click_data: u
|
|
@@ -3238,15 +3244,15 @@ class rr extends _ {
|
|
|
3238
3244
|
* Returns true if the click should be tracked, false if throttled
|
|
3239
3245
|
*/
|
|
3240
3246
|
checkClickThrottle(e, t) {
|
|
3241
|
-
const r = this.getElementSignature(e),
|
|
3242
|
-
this.pruneThrottleCache(
|
|
3247
|
+
const r = this.getElementSignature(e), n = Date.now();
|
|
3248
|
+
this.pruneThrottleCache(n);
|
|
3243
3249
|
const i = this.lastClickTimes.get(r);
|
|
3244
|
-
return i !== void 0 &&
|
|
3250
|
+
return i !== void 0 && n - i < t ? (a("debug", "ClickHandler: Click suppressed by throttle", {
|
|
3245
3251
|
data: {
|
|
3246
3252
|
signature: r,
|
|
3247
|
-
throttleRemaining: t - (
|
|
3253
|
+
throttleRemaining: t - (n - i)
|
|
3248
3254
|
}
|
|
3249
|
-
}), !1) : (this.lastClickTimes.set(r,
|
|
3255
|
+
}), !1) : (this.lastClickTimes.set(r, n), !0);
|
|
3250
3256
|
}
|
|
3251
3257
|
/**
|
|
3252
3258
|
* Prunes stale entries from the throttle cache to prevent memory leaks
|
|
@@ -3258,10 +3264,10 @@ class rr extends _ {
|
|
|
3258
3264
|
return;
|
|
3259
3265
|
this.lastPruneTime = e;
|
|
3260
3266
|
const t = e - 3e5;
|
|
3261
|
-
for (const [r,
|
|
3262
|
-
|
|
3267
|
+
for (const [r, n] of this.lastClickTimes.entries())
|
|
3268
|
+
n < t && this.lastClickTimes.delete(r);
|
|
3263
3269
|
if (this.lastClickTimes.size > 1e3) {
|
|
3264
|
-
const r = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]),
|
|
3270
|
+
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
3271
|
for (const [o] of i)
|
|
3266
3272
|
this.lastClickTimes.delete(o);
|
|
3267
3273
|
a("debug", "ClickHandler: Pruned throttle cache", {
|
|
@@ -3292,12 +3298,12 @@ class rr extends _ {
|
|
|
3292
3298
|
const t = [];
|
|
3293
3299
|
let r = e;
|
|
3294
3300
|
for (; r && r !== document.body; ) {
|
|
3295
|
-
let
|
|
3301
|
+
let n = r.tagName.toLowerCase();
|
|
3296
3302
|
if (r.className) {
|
|
3297
3303
|
const i = r.className.split(" ")[0];
|
|
3298
|
-
i && (
|
|
3304
|
+
i && (n += `.${i}`);
|
|
3299
3305
|
}
|
|
3300
|
-
t.unshift(
|
|
3306
|
+
t.unshift(n), r = r.parentElement;
|
|
3301
3307
|
}
|
|
3302
3308
|
return t.join(">") || "unknown";
|
|
3303
3309
|
}
|
|
@@ -3305,7 +3311,7 @@ class rr extends _ {
|
|
|
3305
3311
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3306
3312
|
}
|
|
3307
3313
|
getRelevantClickElement(e) {
|
|
3308
|
-
for (const t of
|
|
3314
|
+
for (const t of ot)
|
|
3309
3315
|
try {
|
|
3310
3316
|
if (e.matches(t))
|
|
3311
3317
|
return e;
|
|
@@ -3333,8 +3339,8 @@ class rr extends _ {
|
|
|
3333
3339
|
return Math.max(0, Math.min(1, Number(e.toFixed(3))));
|
|
3334
3340
|
}
|
|
3335
3341
|
calculateClickCoordinates(e, t) {
|
|
3336
|
-
const r = t.getBoundingClientRect(),
|
|
3337
|
-
return { x:
|
|
3342
|
+
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;
|
|
3343
|
+
return { x: n, y: i, relativeX: o, relativeY: l };
|
|
3338
3344
|
}
|
|
3339
3345
|
extractTrackingData(e) {
|
|
3340
3346
|
const t = e.getAttribute(`${w}-name`), r = e.getAttribute(`${w}-value`);
|
|
@@ -3346,9 +3352,9 @@ class rr extends _ {
|
|
|
3346
3352
|
};
|
|
3347
3353
|
}
|
|
3348
3354
|
generateClickData(e, t, r) {
|
|
3349
|
-
const { x:
|
|
3355
|
+
const { x: n, y: i, relativeX: o, relativeY: l } = r, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
3350
3356
|
return {
|
|
3351
|
-
x:
|
|
3357
|
+
x: n,
|
|
3352
3358
|
y: i,
|
|
3353
3359
|
relativeX: o,
|
|
3354
3360
|
relativeY: l,
|
|
@@ -3385,18 +3391,18 @@ class rr extends _ {
|
|
|
3385
3391
|
*/
|
|
3386
3392
|
sanitizeText(e) {
|
|
3387
3393
|
let t = e;
|
|
3388
|
-
for (const r of
|
|
3389
|
-
const
|
|
3390
|
-
t = t.replace(
|
|
3394
|
+
for (const r of Xe) {
|
|
3395
|
+
const n = new RegExp(r.source, r.flags);
|
|
3396
|
+
t = t.replace(n, "[REDACTED]");
|
|
3391
3397
|
}
|
|
3392
3398
|
return t;
|
|
3393
3399
|
}
|
|
3394
3400
|
getRelevantText(e, t) {
|
|
3395
|
-
const r = e.textContent?.trim() ?? "",
|
|
3396
|
-
if (!r && !
|
|
3401
|
+
const r = e.textContent?.trim() ?? "", n = t.textContent?.trim() ?? "";
|
|
3402
|
+
if (!r && !n)
|
|
3397
3403
|
return "";
|
|
3398
3404
|
let i = "";
|
|
3399
|
-
return r && r.length <= 255 ? i = r :
|
|
3405
|
+
return r && r.length <= 255 ? i = r : n.length <= 255 ? i = n : i = n.slice(0, 252) + "...", this.sanitizeText(i);
|
|
3400
3406
|
}
|
|
3401
3407
|
extractElementAttributes(e) {
|
|
3402
3408
|
const t = [
|
|
@@ -3411,9 +3417,9 @@ class rr extends _ {
|
|
|
3411
3417
|
"alt",
|
|
3412
3418
|
"role"
|
|
3413
3419
|
], r = {};
|
|
3414
|
-
for (const
|
|
3415
|
-
const i = e.getAttribute(
|
|
3416
|
-
i && (r[
|
|
3420
|
+
for (const n of t) {
|
|
3421
|
+
const i = e.getAttribute(n);
|
|
3422
|
+
i && (r[n] = i);
|
|
3417
3423
|
}
|
|
3418
3424
|
return r;
|
|
3419
3425
|
}
|
|
@@ -3424,7 +3430,7 @@ class rr extends _ {
|
|
|
3424
3430
|
};
|
|
3425
3431
|
}
|
|
3426
3432
|
}
|
|
3427
|
-
class
|
|
3433
|
+
class ar extends _ {
|
|
3428
3434
|
eventManager;
|
|
3429
3435
|
containers = [];
|
|
3430
3436
|
limitWarningLogged = !1;
|
|
@@ -3471,8 +3477,8 @@ class nr extends _ {
|
|
|
3471
3477
|
const t = this.findScrollableElements();
|
|
3472
3478
|
if (this.isWindowScrollable() && this.setupScrollContainer(window, "window"), t.length > 0) {
|
|
3473
3479
|
for (const r of t) {
|
|
3474
|
-
const
|
|
3475
|
-
this.setupScrollContainer(r,
|
|
3480
|
+
const n = this.getElementSelector(r);
|
|
3481
|
+
this.setupScrollContainer(r, n);
|
|
3476
3482
|
}
|
|
3477
3483
|
this.applyPrimaryScrollSelectorIfConfigured();
|
|
3478
3484
|
return;
|
|
@@ -3493,8 +3499,8 @@ class nr extends _ {
|
|
|
3493
3499
|
if (!document.body)
|
|
3494
3500
|
return [];
|
|
3495
3501
|
const e = [], t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
3496
|
-
acceptNode: (
|
|
3497
|
-
const i =
|
|
3502
|
+
acceptNode: (n) => {
|
|
3503
|
+
const i = n;
|
|
3498
3504
|
if (!i.isConnected || !i.offsetParent)
|
|
3499
3505
|
return NodeFilter.FILTER_SKIP;
|
|
3500
3506
|
const o = getComputedStyle(i);
|
|
@@ -3503,8 +3509,8 @@ class nr extends _ {
|
|
|
3503
3509
|
});
|
|
3504
3510
|
let r;
|
|
3505
3511
|
for (; (r = t.nextNode()) && e.length < 10; ) {
|
|
3506
|
-
const
|
|
3507
|
-
this.isElementScrollable(
|
|
3512
|
+
const n = r;
|
|
3513
|
+
this.isElementScrollable(n) && e.push(n);
|
|
3508
3514
|
}
|
|
3509
3515
|
return e;
|
|
3510
3516
|
}
|
|
@@ -3515,7 +3521,7 @@ class nr extends _ {
|
|
|
3515
3521
|
if (t.id)
|
|
3516
3522
|
return `#${t.id}`;
|
|
3517
3523
|
if (t.className && typeof t.className == "string") {
|
|
3518
|
-
const r = t.className.split(" ").filter((
|
|
3524
|
+
const r = t.className.split(" ").filter((n) => n.trim())[0];
|
|
3519
3525
|
if (r)
|
|
3520
3526
|
return `.${r}`;
|
|
3521
3527
|
}
|
|
@@ -3527,15 +3533,15 @@ class nr extends _ {
|
|
|
3527
3533
|
setupScrollContainer(e, t) {
|
|
3528
3534
|
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3529
3535
|
return;
|
|
3530
|
-
const
|
|
3531
|
-
|
|
3536
|
+
const n = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3537
|
+
n,
|
|
3532
3538
|
this.getScrollHeight(e),
|
|
3533
3539
|
this.getViewportHeight(e)
|
|
3534
3540
|
), o = this.determineIfPrimary(e), l = {
|
|
3535
3541
|
element: e,
|
|
3536
3542
|
selector: t,
|
|
3537
3543
|
isPrimary: o,
|
|
3538
|
-
lastScrollPos:
|
|
3544
|
+
lastScrollPos: n,
|
|
3539
3545
|
lastDepth: i,
|
|
3540
3546
|
lastDirection: X.DOWN,
|
|
3541
3547
|
lastEventTime: 0,
|
|
@@ -3559,8 +3565,8 @@ class nr extends _ {
|
|
|
3559
3565
|
if (!this.shouldEmitScrollEvent(e, t, r))
|
|
3560
3566
|
return;
|
|
3561
3567
|
e.lastEventTime = r, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3562
|
-
const
|
|
3563
|
-
this.set("scrollEventCount",
|
|
3568
|
+
const n = this.get("scrollEventCount") ?? 0;
|
|
3569
|
+
this.set("scrollEventCount", n + 1), this.eventManager.track({
|
|
3564
3570
|
type: d.SCROLL,
|
|
3565
3571
|
scroll_data: {
|
|
3566
3572
|
...t,
|
|
@@ -3601,21 +3607,21 @@ class nr extends _ {
|
|
|
3601
3607
|
calculateScrollDepth(e, t, r) {
|
|
3602
3608
|
if (t <= r)
|
|
3603
3609
|
return 0;
|
|
3604
|
-
const
|
|
3605
|
-
return Math.min(100, Math.max(0, Math.floor(e /
|
|
3610
|
+
const n = t - r;
|
|
3611
|
+
return Math.min(100, Math.max(0, Math.floor(e / n * 100)));
|
|
3606
3612
|
}
|
|
3607
3613
|
calculateScrollData(e) {
|
|
3608
|
-
const { element: t, lastScrollPos: r, lastEventTime:
|
|
3614
|
+
const { element: t, lastScrollPos: r, lastEventTime: n } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - r);
|
|
3609
3615
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3610
3616
|
return null;
|
|
3611
3617
|
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
|
|
3618
|
+
let p;
|
|
3619
|
+
n > 0 ? p = o - n : e.firstScrollEventTime !== null ? p = o - e.firstScrollEventTime : p = 250;
|
|
3620
|
+
const E = Math.round(l / p * 1e3);
|
|
3615
3621
|
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3616
3622
|
depth: g,
|
|
3617
3623
|
direction: S,
|
|
3618
|
-
velocity:
|
|
3624
|
+
velocity: E,
|
|
3619
3625
|
max_depth_reached: e.maxDepthReached
|
|
3620
3626
|
};
|
|
3621
3627
|
}
|
|
@@ -3629,30 +3635,30 @@ class nr extends _ {
|
|
|
3629
3635
|
return e === window ? document.documentElement.scrollHeight : e.scrollHeight;
|
|
3630
3636
|
}
|
|
3631
3637
|
isElementScrollable(e) {
|
|
3632
|
-
const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll",
|
|
3633
|
-
return r &&
|
|
3638
|
+
const t = getComputedStyle(e), r = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll", n = e.scrollHeight > e.clientHeight;
|
|
3639
|
+
return r && n;
|
|
3634
3640
|
}
|
|
3635
3641
|
applyPrimaryScrollSelector(e) {
|
|
3636
3642
|
let t;
|
|
3637
3643
|
if (e === "window")
|
|
3638
3644
|
t = window;
|
|
3639
3645
|
else {
|
|
3640
|
-
const
|
|
3641
|
-
if (!(
|
|
3646
|
+
const n = document.querySelector(e);
|
|
3647
|
+
if (!(n instanceof HTMLElement)) {
|
|
3642
3648
|
a("debug", `Selector "${e}" did not match an HTMLElement`);
|
|
3643
3649
|
return;
|
|
3644
3650
|
}
|
|
3645
|
-
t =
|
|
3651
|
+
t = n;
|
|
3646
3652
|
}
|
|
3647
|
-
this.containers.forEach((
|
|
3648
|
-
this.updateContainerPrimary(
|
|
3649
|
-
}), !this.containers.some((
|
|
3653
|
+
this.containers.forEach((n) => {
|
|
3654
|
+
this.updateContainerPrimary(n, n.element === t);
|
|
3655
|
+
}), !this.containers.some((n) => n.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
|
|
3650
3656
|
}
|
|
3651
3657
|
updateContainerPrimary(e, t) {
|
|
3652
3658
|
e.isPrimary = t;
|
|
3653
3659
|
}
|
|
3654
3660
|
}
|
|
3655
|
-
class
|
|
3661
|
+
class lr extends _ {
|
|
3656
3662
|
eventManager;
|
|
3657
3663
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3658
3664
|
observer = null;
|
|
@@ -3704,8 +3710,8 @@ class sr extends _ {
|
|
|
3704
3710
|
let t = this.trackedElements.size;
|
|
3705
3711
|
for (const r of this.config.elements)
|
|
3706
3712
|
try {
|
|
3707
|
-
const
|
|
3708
|
-
for (const i of Array.from(
|
|
3713
|
+
const n = document.querySelectorAll(r.selector);
|
|
3714
|
+
for (const i of Array.from(n)) {
|
|
3709
3715
|
if (t >= e) {
|
|
3710
3716
|
a("debug", "ViewportHandler: Maximum tracked elements reached", {
|
|
3711
3717
|
data: {
|
|
@@ -3726,8 +3732,8 @@ class sr extends _ {
|
|
|
3726
3732
|
lastFiredTime: null
|
|
3727
3733
|
}), this.observer?.observe(i), t++);
|
|
3728
3734
|
}
|
|
3729
|
-
} catch (
|
|
3730
|
-
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error:
|
|
3735
|
+
} catch (n) {
|
|
3736
|
+
a("debug", `ViewportHandler: Invalid selector "${r.selector}"`, { error: n });
|
|
3731
3737
|
}
|
|
3732
3738
|
a("debug", "ViewportHandler: Elements tracked", {
|
|
3733
3739
|
data: { count: t, limit: e }
|
|
@@ -3740,11 +3746,11 @@ class sr extends _ {
|
|
|
3740
3746
|
if (!this.config) return;
|
|
3741
3747
|
const t = this.config.minDwellTime ?? 1e3;
|
|
3742
3748
|
for (const r of e) {
|
|
3743
|
-
const
|
|
3744
|
-
|
|
3749
|
+
const n = this.trackedElements.get(r.target);
|
|
3750
|
+
n && (r.isIntersecting ? n.startTime === null && (n.startTime = performance.now(), n.timeoutId = window.setTimeout(() => {
|
|
3745
3751
|
const i = Math.round(r.intersectionRatio * 100) / 100;
|
|
3746
|
-
this.fireViewportEvent(
|
|
3747
|
-
}, t)) :
|
|
3752
|
+
this.fireViewportEvent(n, i);
|
|
3753
|
+
}, t)) : n.startTime !== null && (n.timeoutId !== null && (window.clearTimeout(n.timeoutId), n.timeoutId = null), n.startTime = null));
|
|
3748
3754
|
}
|
|
3749
3755
|
};
|
|
3750
3756
|
/**
|
|
@@ -3755,12 +3761,12 @@ class sr extends _ {
|
|
|
3755
3761
|
const r = Math.round(performance.now() - e.startTime);
|
|
3756
3762
|
if (e.element.hasAttribute(`${w}-ignore`))
|
|
3757
3763
|
return;
|
|
3758
|
-
const
|
|
3759
|
-
if (e.lastFiredTime !== null && i - e.lastFiredTime <
|
|
3764
|
+
const n = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3765
|
+
if (e.lastFiredTime !== null && i - e.lastFiredTime < n) {
|
|
3760
3766
|
a("debug", "ViewportHandler: Event suppressed by cooldown period", {
|
|
3761
3767
|
data: {
|
|
3762
3768
|
selector: e.selector,
|
|
3763
|
-
cooldownRemaining:
|
|
3769
|
+
cooldownRemaining: n - (i - e.lastFiredTime)
|
|
3764
3770
|
}
|
|
3765
3771
|
}), e.startTime = null, e.timeoutId = null;
|
|
3766
3772
|
return;
|
|
@@ -3805,15 +3811,15 @@ class sr extends _ {
|
|
|
3805
3811
|
cleanupRemovedNodes(e) {
|
|
3806
3812
|
e.forEach((t) => {
|
|
3807
3813
|
if (t.nodeType !== 1) return;
|
|
3808
|
-
const r = t,
|
|
3809
|
-
|
|
3814
|
+
const r = t, n = this.trackedElements.get(r);
|
|
3815
|
+
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
3816
|
const l = this.trackedElements.get(o);
|
|
3811
3817
|
l && l.timeoutId !== null && window.clearTimeout(l.timeoutId), this.observer?.unobserve(o), this.trackedElements.delete(o);
|
|
3812
3818
|
});
|
|
3813
3819
|
});
|
|
3814
3820
|
}
|
|
3815
3821
|
}
|
|
3816
|
-
class
|
|
3822
|
+
class cr {
|
|
3817
3823
|
storage;
|
|
3818
3824
|
sessionStorageRef;
|
|
3819
3825
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3993,8 +3999,8 @@ class ir {
|
|
|
3993
3999
|
} catch {
|
|
3994
4000
|
}
|
|
3995
4001
|
}), !0;
|
|
3996
|
-
const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"],
|
|
3997
|
-
return
|
|
4002
|
+
const r = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], n = e.filter((i) => !r.some((o) => i.startsWith(o)));
|
|
4003
|
+
return n.length > 0 ? (n.slice(0, 5).forEach((o) => {
|
|
3998
4004
|
try {
|
|
3999
4005
|
this.storage.removeItem(o);
|
|
4000
4006
|
} catch {
|
|
@@ -4096,7 +4102,7 @@ class ir {
|
|
|
4096
4102
|
this.fallbackSessionStorage.delete(e);
|
|
4097
4103
|
}
|
|
4098
4104
|
}
|
|
4099
|
-
class
|
|
4105
|
+
class ur extends _ {
|
|
4100
4106
|
eventManager;
|
|
4101
4107
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4102
4108
|
navigationHistory = [];
|
|
@@ -4107,7 +4113,7 @@ class or extends _ {
|
|
|
4107
4113
|
navigationCounter = 0;
|
|
4108
4114
|
// Counter for handling simultaneous navigations edge case
|
|
4109
4115
|
constructor(e) {
|
|
4110
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4116
|
+
super(), this.eventManager = e, this.vitalThresholds = De(ce);
|
|
4111
4117
|
}
|
|
4112
4118
|
/**
|
|
4113
4119
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4124,8 +4130,8 @@ class or extends _ {
|
|
|
4124
4130
|
* @returns Promise that resolves when tracking is initialized
|
|
4125
4131
|
*/
|
|
4126
4132
|
async startTracking() {
|
|
4127
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4128
|
-
this.vitalThresholds =
|
|
4133
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ce;
|
|
4134
|
+
this.vitalThresholds = De(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4129
4135
|
}
|
|
4130
4136
|
/**
|
|
4131
4137
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4149,7 +4155,7 @@ class or extends _ {
|
|
|
4149
4155
|
this.reportTTFB(), this.safeObserve(
|
|
4150
4156
|
"largest-contentful-paint",
|
|
4151
4157
|
(r) => {
|
|
4152
|
-
const
|
|
4158
|
+
const n = r.getEntries(), i = n[n.length - 1];
|
|
4153
4159
|
i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(2)) });
|
|
4154
4160
|
},
|
|
4155
4161
|
{ type: "largest-contentful-paint", buffered: !0 },
|
|
@@ -4159,8 +4165,8 @@ class or extends _ {
|
|
|
4159
4165
|
this.safeObserve(
|
|
4160
4166
|
"layout-shift",
|
|
4161
4167
|
(r) => {
|
|
4162
|
-
const
|
|
4163
|
-
|
|
4168
|
+
const n = this.getNavigationId();
|
|
4169
|
+
n !== t && (e = 0, t = n);
|
|
4164
4170
|
const i = r.getEntries();
|
|
4165
4171
|
for (const o of i) {
|
|
4166
4172
|
if (o.hadRecentInput === !0)
|
|
@@ -4174,32 +4180,32 @@ class or extends _ {
|
|
|
4174
4180
|
), this.safeObserve(
|
|
4175
4181
|
"paint",
|
|
4176
4182
|
(r) => {
|
|
4177
|
-
for (const
|
|
4178
|
-
|
|
4183
|
+
for (const n of r.getEntries())
|
|
4184
|
+
n.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(n.startTime.toFixed(2)) });
|
|
4179
4185
|
},
|
|
4180
4186
|
{ type: "paint", buffered: !0 },
|
|
4181
4187
|
!0
|
|
4182
4188
|
), this.safeObserve(
|
|
4183
4189
|
"event",
|
|
4184
4190
|
(r) => {
|
|
4185
|
-
let
|
|
4191
|
+
let n = 0;
|
|
4186
4192
|
const i = r.getEntries();
|
|
4187
4193
|
for (const o of i) {
|
|
4188
4194
|
const l = (o.processingEnd ?? 0) - (o.startTime ?? 0);
|
|
4189
|
-
|
|
4195
|
+
n = Math.max(n, l);
|
|
4190
4196
|
}
|
|
4191
|
-
|
|
4197
|
+
n > 0 && this.sendVital({ type: "INP", value: Number(n.toFixed(2)) });
|
|
4192
4198
|
},
|
|
4193
4199
|
{ type: "event", buffered: !0 }
|
|
4194
4200
|
);
|
|
4195
4201
|
}
|
|
4196
4202
|
async initWebVitals() {
|
|
4197
4203
|
try {
|
|
4198
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB:
|
|
4204
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => kr), o = (l) => (c) => {
|
|
4199
4205
|
const u = Number(c.value.toFixed(2));
|
|
4200
4206
|
this.sendVital({ type: l, value: u });
|
|
4201
4207
|
};
|
|
4202
|
-
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), r(o("FCP"), { reportAllChanges: !1 }),
|
|
4208
|
+
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
4209
|
} catch (e) {
|
|
4204
4210
|
a("debug", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
|
|
4205
4211
|
}
|
|
@@ -4221,8 +4227,8 @@ class or extends _ {
|
|
|
4221
4227
|
(e) => {
|
|
4222
4228
|
const t = e.getEntries();
|
|
4223
4229
|
for (const r of t) {
|
|
4224
|
-
const
|
|
4225
|
-
i - this.lastLongTaskSentAt >=
|
|
4230
|
+
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4231
|
+
i - this.lastLongTaskSentAt >= Ct && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4226
4232
|
}
|
|
4227
4233
|
},
|
|
4228
4234
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4238,7 +4244,7 @@ class or extends _ {
|
|
|
4238
4244
|
return;
|
|
4239
4245
|
if (r)
|
|
4240
4246
|
r.add(e.type);
|
|
4241
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4247
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Nt) {
|
|
4242
4248
|
const i = this.navigationHistory.shift();
|
|
4243
4249
|
i && this.reportedByNav.delete(i);
|
|
4244
4250
|
}
|
|
@@ -4284,8 +4290,8 @@ class or extends _ {
|
|
|
4284
4290
|
const e = performance.getEntriesByType("navigation")[0];
|
|
4285
4291
|
if (!e)
|
|
4286
4292
|
return null;
|
|
4287
|
-
const t = e.startTime || performance.now(), r = ++this.navigationCounter,
|
|
4288
|
-
return r > 1 ? `${
|
|
4293
|
+
const t = e.startTime || performance.now(), r = ++this.navigationCounter, n = `${t.toFixed(2)}_${window.location.pathname}`;
|
|
4294
|
+
return r > 1 ? `${n}_${r}` : n;
|
|
4289
4295
|
} catch (e) {
|
|
4290
4296
|
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
4291
4297
|
}
|
|
@@ -4295,7 +4301,7 @@ class or extends _ {
|
|
|
4295
4301
|
const t = PerformanceObserver.supportedEntryTypes;
|
|
4296
4302
|
return !t || t.includes(e);
|
|
4297
4303
|
}
|
|
4298
|
-
safeObserve(e, t, r,
|
|
4304
|
+
safeObserve(e, t, r, n = !1) {
|
|
4299
4305
|
try {
|
|
4300
4306
|
if (!this.isObserverSupported(e))
|
|
4301
4307
|
return !1;
|
|
@@ -4308,13 +4314,13 @@ class or extends _ {
|
|
|
4308
4314
|
data: { type: e }
|
|
4309
4315
|
});
|
|
4310
4316
|
}
|
|
4311
|
-
if (
|
|
4317
|
+
if (n)
|
|
4312
4318
|
try {
|
|
4313
4319
|
l.disconnect();
|
|
4314
4320
|
} catch {
|
|
4315
4321
|
}
|
|
4316
4322
|
});
|
|
4317
|
-
return i.observe(r ?? { type: e, buffered: !0 }),
|
|
4323
|
+
return i.observe(r ?? { type: e, buffered: !0 }), n || this.observers.push(i), !0;
|
|
4318
4324
|
} catch (i) {
|
|
4319
4325
|
return a("debug", "Failed to create performance observer", {
|
|
4320
4326
|
error: i,
|
|
@@ -4329,7 +4335,7 @@ class or extends _ {
|
|
|
4329
4335
|
return !(typeof r == "number" && t <= r);
|
|
4330
4336
|
}
|
|
4331
4337
|
}
|
|
4332
|
-
class
|
|
4338
|
+
class dr extends _ {
|
|
4333
4339
|
eventManager;
|
|
4334
4340
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4335
4341
|
errorBurstCounter = 0;
|
|
@@ -4365,14 +4371,14 @@ class ar extends _ {
|
|
|
4365
4371
|
const e = Date.now();
|
|
4366
4372
|
if (e < this.burstBackoffUntil)
|
|
4367
4373
|
return !1;
|
|
4368
|
-
if (e - this.burstWindowStart >
|
|
4369
|
-
return this.burstBackoffUntil = e +
|
|
4374
|
+
if (e - this.burstWindowStart > At && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Lt)
|
|
4375
|
+
return this.burstBackoffUntil = e + Oe, a("debug", "Error burst detected - entering cooldown", {
|
|
4370
4376
|
data: {
|
|
4371
4377
|
errorsInWindow: this.errorBurstCounter,
|
|
4372
|
-
cooldownMs:
|
|
4378
|
+
cooldownMs: Oe
|
|
4373
4379
|
}
|
|
4374
4380
|
}), !1;
|
|
4375
|
-
const r = this.get("config")?.errorSampling ??
|
|
4381
|
+
const r = this.get("config")?.errorSampling ?? Qe;
|
|
4376
4382
|
return Math.random() < r;
|
|
4377
4383
|
}
|
|
4378
4384
|
handleError = (e) => {
|
|
@@ -4416,34 +4422,34 @@ class ar extends _ {
|
|
|
4416
4422
|
}
|
|
4417
4423
|
}
|
|
4418
4424
|
sanitize(e) {
|
|
4419
|
-
let t = e.length >
|
|
4420
|
-
for (const r of
|
|
4421
|
-
const
|
|
4422
|
-
t = t.replace(
|
|
4425
|
+
let t = e.length > Ce ? e.slice(0, Ce) + "..." : e;
|
|
4426
|
+
for (const r of Xe) {
|
|
4427
|
+
const n = new RegExp(r.source, r.flags);
|
|
4428
|
+
t = t.replace(n, "[REDACTED]");
|
|
4423
4429
|
}
|
|
4424
4430
|
return t;
|
|
4425
4431
|
}
|
|
4426
4432
|
shouldSuppressError(e, t) {
|
|
4427
|
-
const r = Date.now(),
|
|
4428
|
-
return i && r - i <
|
|
4433
|
+
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4434
|
+
return i && r - i < Ne ? (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
4435
|
}
|
|
4430
4436
|
pruneOldErrors() {
|
|
4431
4437
|
const e = Date.now();
|
|
4432
|
-
for (const [
|
|
4433
|
-
e - i >
|
|
4438
|
+
for (const [n, i] of this.recentErrors.entries())
|
|
4439
|
+
e - i > Ne && this.recentErrors.delete(n);
|
|
4434
4440
|
if (this.recentErrors.size <= Q)
|
|
4435
4441
|
return;
|
|
4436
|
-
const t = Array.from(this.recentErrors.entries()).sort((
|
|
4437
|
-
for (let
|
|
4438
|
-
const i = t[
|
|
4442
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - Q;
|
|
4443
|
+
for (let n = 0; n < r; n += 1) {
|
|
4444
|
+
const i = t[n];
|
|
4439
4445
|
i && this.recentErrors.delete(i[0]);
|
|
4440
4446
|
}
|
|
4441
4447
|
}
|
|
4442
4448
|
}
|
|
4443
|
-
class
|
|
4449
|
+
class hr extends _ {
|
|
4444
4450
|
isInitialized = !1;
|
|
4445
4451
|
suppressNextScrollTimer = null;
|
|
4446
|
-
emitter = new
|
|
4452
|
+
emitter = new qt();
|
|
4447
4453
|
transformers = {};
|
|
4448
4454
|
managers = {};
|
|
4449
4455
|
handlers = {};
|
|
@@ -4459,9 +4465,9 @@ class lr extends _ {
|
|
|
4459
4465
|
*/
|
|
4460
4466
|
async init(e = {}) {
|
|
4461
4467
|
if (!this.isInitialized) {
|
|
4462
|
-
this.managers.storage = new
|
|
4468
|
+
this.managers.storage = new cr();
|
|
4463
4469
|
try {
|
|
4464
|
-
this.setupState(e), this.managers.event = new
|
|
4470
|
+
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
4471
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
4466
4472
|
}), this.isInitialized = !0;
|
|
4467
4473
|
} catch (t) {
|
|
@@ -4485,8 +4491,8 @@ class lr extends _ {
|
|
|
4485
4491
|
}
|
|
4486
4492
|
let r = t;
|
|
4487
4493
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4488
|
-
const { valid:
|
|
4489
|
-
if (!
|
|
4494
|
+
const { valid: n, error: i, sanitizedMetadata: o } = Yt(e, r);
|
|
4495
|
+
if (!n) {
|
|
4490
4496
|
if (this.get("mode") === z.QA)
|
|
4491
4497
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4492
4498
|
return;
|
|
@@ -4533,14 +4539,14 @@ class lr extends _ {
|
|
|
4533
4539
|
}
|
|
4534
4540
|
setupState(e = {}) {
|
|
4535
4541
|
this.set("config", e);
|
|
4536
|
-
const t =
|
|
4542
|
+
const t = tr.getId(this.managers.storage);
|
|
4537
4543
|
this.set("userId", t);
|
|
4538
|
-
const r =
|
|
4544
|
+
const r = Bt(e);
|
|
4539
4545
|
this.set("collectApiUrls", r);
|
|
4540
|
-
const
|
|
4541
|
-
this.set("device",
|
|
4542
|
-
const i =
|
|
4543
|
-
this.set("pageUrl", i),
|
|
4546
|
+
const n = yt();
|
|
4547
|
+
this.set("device", n);
|
|
4548
|
+
const i = ue(window.location.href, e.sensitiveQueryParams);
|
|
4549
|
+
this.set("pageUrl", i), kt() && this.set("mode", z.QA);
|
|
4544
4550
|
}
|
|
4545
4551
|
/**
|
|
4546
4552
|
* Returns the current configuration object.
|
|
@@ -4582,7 +4588,7 @@ class lr extends _ {
|
|
|
4582
4588
|
valid: !1,
|
|
4583
4589
|
error: "Global metadata must be a plain object"
|
|
4584
4590
|
};
|
|
4585
|
-
const t =
|
|
4591
|
+
const t = Ye("Global", e, "globalMetadata");
|
|
4586
4592
|
return t.valid ? { valid: !0 } : {
|
|
4587
4593
|
valid: !1,
|
|
4588
4594
|
error: t.error
|
|
@@ -4599,11 +4605,11 @@ class lr extends _ {
|
|
|
4599
4605
|
const t = this.validateGlobalMetadata(e);
|
|
4600
4606
|
if (!t.valid)
|
|
4601
4607
|
throw new Error(`[TraceLog] Invalid global metadata: ${t.error}`);
|
|
4602
|
-
const
|
|
4608
|
+
const n = {
|
|
4603
4609
|
...this.get("config"),
|
|
4604
4610
|
globalMetadata: e
|
|
4605
4611
|
};
|
|
4606
|
-
this.set("config",
|
|
4612
|
+
this.set("config", n), a("debug", "Global metadata updated (replaced)", { data: { keys: Object.keys(e) } });
|
|
4607
4613
|
}
|
|
4608
4614
|
/**
|
|
4609
4615
|
* Merges new metadata with existing global metadata.
|
|
@@ -4627,7 +4633,7 @@ class lr extends _ {
|
|
|
4627
4633
|
}
|
|
4628
4634
|
initializeHandlers() {
|
|
4629
4635
|
const e = this.get("config");
|
|
4630
|
-
this.handlers.session = new
|
|
4636
|
+
this.handlers.session = new nr(
|
|
4631
4637
|
this.managers.storage,
|
|
4632
4638
|
this.managers.event
|
|
4633
4639
|
), this.handlers.session.startTracking();
|
|
@@ -4636,96 +4642,96 @@ class lr extends _ {
|
|
|
4636
4642
|
this.set("suppressNextScroll", !1);
|
|
4637
4643
|
}, 500);
|
|
4638
4644
|
};
|
|
4639
|
-
this.handlers.pageView = new
|
|
4645
|
+
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
4646
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4641
|
-
}), this.handlers.error = new
|
|
4647
|
+
}), 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
4648
|
}
|
|
4643
4649
|
}
|
|
4644
|
-
const
|
|
4645
|
-
let f = null,
|
|
4646
|
-
const
|
|
4647
|
-
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !
|
|
4648
|
-
|
|
4650
|
+
const C = [], M = [];
|
|
4651
|
+
let f = null, R = !1, v = !1;
|
|
4652
|
+
const fr = async (s) => {
|
|
4653
|
+
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !R)) {
|
|
4654
|
+
R = !0;
|
|
4649
4655
|
try {
|
|
4650
|
-
const e =
|
|
4656
|
+
const e = jt(s ?? {}), t = new hr();
|
|
4651
4657
|
try {
|
|
4652
|
-
|
|
4658
|
+
C.forEach(({ event: i, callback: o }) => {
|
|
4653
4659
|
t.on(i, o);
|
|
4654
|
-
}),
|
|
4660
|
+
}), C.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4655
4661
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4656
4662
|
}), M.length = 0;
|
|
4657
|
-
const r = t.init(e),
|
|
4663
|
+
const r = t.init(e), n = new Promise((i, o) => {
|
|
4658
4664
|
setTimeout(() => {
|
|
4659
4665
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4660
4666
|
}, 1e4);
|
|
4661
4667
|
});
|
|
4662
|
-
await Promise.race([r,
|
|
4668
|
+
await Promise.race([r, n]), f = t;
|
|
4663
4669
|
} catch (r) {
|
|
4664
4670
|
try {
|
|
4665
4671
|
t.destroy(!0);
|
|
4666
|
-
} catch (
|
|
4667
|
-
a("error", "Failed to cleanup partially initialized app", { error:
|
|
4672
|
+
} catch (n) {
|
|
4673
|
+
a("error", "Failed to cleanup partially initialized app", { error: n });
|
|
4668
4674
|
}
|
|
4669
4675
|
throw r;
|
|
4670
4676
|
}
|
|
4671
4677
|
} catch (e) {
|
|
4672
4678
|
throw f = null, e;
|
|
4673
4679
|
} finally {
|
|
4674
|
-
|
|
4680
|
+
R = !1;
|
|
4675
4681
|
}
|
|
4676
4682
|
}
|
|
4677
|
-
},
|
|
4683
|
+
}, mr = (s, e) => {
|
|
4678
4684
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4679
4685
|
if (!f)
|
|
4680
4686
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4681
4687
|
if (v)
|
|
4682
4688
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4683
|
-
f.sendCustomEvent(
|
|
4689
|
+
f.sendCustomEvent(s, e);
|
|
4684
4690
|
}
|
|
4685
|
-
},
|
|
4691
|
+
}, gr = (s, e) => {
|
|
4686
4692
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4687
|
-
if (!f ||
|
|
4688
|
-
|
|
4693
|
+
if (!f || R) {
|
|
4694
|
+
C.push({ event: s, callback: e });
|
|
4689
4695
|
return;
|
|
4690
4696
|
}
|
|
4691
|
-
f.on(
|
|
4697
|
+
f.on(s, e);
|
|
4692
4698
|
}
|
|
4693
|
-
},
|
|
4699
|
+
}, Er = (s, e) => {
|
|
4694
4700
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4695
4701
|
if (!f) {
|
|
4696
|
-
const t =
|
|
4697
|
-
t !== -1 &&
|
|
4702
|
+
const t = C.findIndex((r) => r.event === s && r.callback === e);
|
|
4703
|
+
t !== -1 && C.splice(t, 1);
|
|
4698
4704
|
return;
|
|
4699
4705
|
}
|
|
4700
|
-
f.off(
|
|
4706
|
+
f.off(s, e);
|
|
4701
4707
|
}
|
|
4702
4708
|
};
|
|
4703
|
-
function
|
|
4709
|
+
function Sr(s, e) {
|
|
4704
4710
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4705
4711
|
if (typeof e != "function")
|
|
4706
4712
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4707
|
-
if (!f ||
|
|
4708
|
-
const t = M.findIndex((r) => r.hook ===
|
|
4709
|
-
t !== -1 && M.splice(t, 1), M.push({ hook:
|
|
4713
|
+
if (!f || R) {
|
|
4714
|
+
const t = M.findIndex((r) => r.hook === s);
|
|
4715
|
+
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4710
4716
|
return;
|
|
4711
4717
|
}
|
|
4712
4718
|
if (v)
|
|
4713
4719
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4714
|
-
|
|
4720
|
+
s === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4715
4721
|
}
|
|
4716
4722
|
}
|
|
4717
|
-
const
|
|
4723
|
+
const pr = (s) => {
|
|
4718
4724
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4719
4725
|
if (!f) {
|
|
4720
|
-
const e = M.findIndex((t) => t.hook ===
|
|
4726
|
+
const e = M.findIndex((t) => t.hook === s);
|
|
4721
4727
|
e !== -1 && M.splice(e, 1);
|
|
4722
4728
|
return;
|
|
4723
4729
|
}
|
|
4724
4730
|
if (v)
|
|
4725
4731
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4726
|
-
f.removeTransformer(
|
|
4732
|
+
f.removeTransformer(s);
|
|
4727
4733
|
}
|
|
4728
|
-
},
|
|
4734
|
+
}, Tr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, _r = () => {
|
|
4729
4735
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4730
4736
|
if (v)
|
|
4731
4737
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4735,273 +4741,273 @@ const mr = (n) => {
|
|
|
4735
4741
|
}
|
|
4736
4742
|
v = !0;
|
|
4737
4743
|
try {
|
|
4738
|
-
f.destroy(), f = null,
|
|
4739
|
-
} catch (
|
|
4740
|
-
f = null,
|
|
4744
|
+
f.destroy(), f = null, R = !1, C.length = 0, M.length = 0, v = !1;
|
|
4745
|
+
} catch (s) {
|
|
4746
|
+
f = null, R = !1, C.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4741
4747
|
}
|
|
4742
4748
|
}
|
|
4743
|
-
},
|
|
4744
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4745
|
-
},
|
|
4749
|
+
}, vr = (s) => {
|
|
4750
|
+
typeof window > "u" || typeof document > "u" || Vt(s);
|
|
4751
|
+
}, Ir = (s) => {
|
|
4746
4752
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4747
4753
|
if (!f)
|
|
4748
4754
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4749
4755
|
if (v)
|
|
4750
4756
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4751
|
-
f.updateGlobalMetadata(
|
|
4757
|
+
f.updateGlobalMetadata(s);
|
|
4752
4758
|
}
|
|
4753
|
-
},
|
|
4759
|
+
}, wr = (s) => {
|
|
4754
4760
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4755
4761
|
if (!f)
|
|
4756
4762
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4757
4763
|
if (v)
|
|
4758
4764
|
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:
|
|
4765
|
+
f.mergeGlobalMetadata(s);
|
|
4766
|
+
}
|
|
4767
|
+
}, Yr = {
|
|
4768
|
+
init: fr,
|
|
4769
|
+
event: mr,
|
|
4770
|
+
on: gr,
|
|
4771
|
+
off: Er,
|
|
4772
|
+
setTransformer: Sr,
|
|
4773
|
+
removeTransformer: pr,
|
|
4774
|
+
isInitialized: Tr,
|
|
4775
|
+
destroy: _r,
|
|
4776
|
+
setQaMode: vr,
|
|
4777
|
+
updateGlobalMetadata: Ir,
|
|
4778
|
+
mergeGlobalMetadata: wr
|
|
4773
4779
|
};
|
|
4774
|
-
var
|
|
4780
|
+
var he, Ze = -1, P = function(s) {
|
|
4775
4781
|
addEventListener("pageshow", (function(e) {
|
|
4776
|
-
e.persisted && (
|
|
4782
|
+
e.persisted && (Ze = e.timeStamp, s(e));
|
|
4777
4783
|
}), !0);
|
|
4778
|
-
},
|
|
4779
|
-
var
|
|
4780
|
-
if (
|
|
4784
|
+
}, pe = function() {
|
|
4785
|
+
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4786
|
+
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4781
4787
|
}, q = function() {
|
|
4782
|
-
var
|
|
4783
|
-
return
|
|
4784
|
-
}, b = function(
|
|
4785
|
-
var t =
|
|
4786
|
-
return
|
|
4787
|
-
}, F = function(
|
|
4788
|
+
var s = pe();
|
|
4789
|
+
return s && s.activationStart || 0;
|
|
4790
|
+
}, b = function(s, e) {
|
|
4791
|
+
var t = pe(), r = "navigate";
|
|
4792
|
+
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 };
|
|
4793
|
+
}, F = function(s, e, t) {
|
|
4788
4794
|
try {
|
|
4789
|
-
if (PerformanceObserver.supportedEntryTypes.includes(
|
|
4790
|
-
var r = new PerformanceObserver((function(
|
|
4795
|
+
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4796
|
+
var r = new PerformanceObserver((function(n) {
|
|
4791
4797
|
Promise.resolve().then((function() {
|
|
4792
|
-
e(
|
|
4798
|
+
e(n.getEntries());
|
|
4793
4799
|
}));
|
|
4794
4800
|
}));
|
|
4795
|
-
return r.observe(Object.assign({ type:
|
|
4801
|
+
return r.observe(Object.assign({ type: s, buffered: !0 }, t || {})), r;
|
|
4796
4802
|
}
|
|
4797
4803
|
} catch {
|
|
4798
4804
|
}
|
|
4799
|
-
}, A = function(
|
|
4800
|
-
var
|
|
4805
|
+
}, A = function(s, e, t, r) {
|
|
4806
|
+
var n, i;
|
|
4801
4807
|
return function(o) {
|
|
4802
|
-
e.value >= 0 && (o || r) && ((i = e.value - (
|
|
4808
|
+
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
4809
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4804
|
-
})(e.value, t),
|
|
4810
|
+
})(e.value, t), s(e));
|
|
4805
4811
|
};
|
|
4806
|
-
},
|
|
4812
|
+
}, Te = function(s) {
|
|
4807
4813
|
requestAnimationFrame((function() {
|
|
4808
4814
|
return requestAnimationFrame((function() {
|
|
4809
|
-
return
|
|
4815
|
+
return s();
|
|
4810
4816
|
}));
|
|
4811
4817
|
}));
|
|
4812
|
-
}, J = function(
|
|
4818
|
+
}, J = function(s) {
|
|
4813
4819
|
document.addEventListener("visibilitychange", (function() {
|
|
4814
|
-
document.visibilityState === "hidden" &&
|
|
4820
|
+
document.visibilityState === "hidden" && s();
|
|
4815
4821
|
}));
|
|
4816
|
-
},
|
|
4822
|
+
}, _e = function(s) {
|
|
4817
4823
|
var e = !1;
|
|
4818
4824
|
return function() {
|
|
4819
|
-
e || (
|
|
4825
|
+
e || (s(), e = !0);
|
|
4820
4826
|
};
|
|
4821
|
-
}, O = -1,
|
|
4827
|
+
}, O = -1, He = function() {
|
|
4822
4828
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4823
|
-
}, Y = function(
|
|
4824
|
-
document.visibilityState === "hidden" && O > -1 && (O =
|
|
4825
|
-
},
|
|
4829
|
+
}, Y = function(s) {
|
|
4830
|
+
document.visibilityState === "hidden" && O > -1 && (O = s.type === "visibilitychange" ? s.timeStamp : 0, yr());
|
|
4831
|
+
}, Fe = function() {
|
|
4826
4832
|
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4827
|
-
},
|
|
4833
|
+
}, yr = function() {
|
|
4828
4834
|
removeEventListener("visibilitychange", Y, !0), removeEventListener("prerenderingchange", Y, !0);
|
|
4829
|
-
},
|
|
4830
|
-
return O < 0 && (O =
|
|
4835
|
+
}, et = function() {
|
|
4836
|
+
return O < 0 && (O = He(), Fe(), P((function() {
|
|
4831
4837
|
setTimeout((function() {
|
|
4832
|
-
O =
|
|
4838
|
+
O = He(), Fe();
|
|
4833
4839
|
}), 0);
|
|
4834
4840
|
}))), { get firstHiddenTime() {
|
|
4835
4841
|
return O;
|
|
4836
4842
|
} };
|
|
4837
|
-
}, Z = function(
|
|
4843
|
+
}, Z = function(s) {
|
|
4838
4844
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4839
|
-
return
|
|
4840
|
-
}), !0) :
|
|
4841
|
-
},
|
|
4845
|
+
return s();
|
|
4846
|
+
}), !0) : s();
|
|
4847
|
+
}, fe = [1800, 3e3], tt = function(s, e) {
|
|
4842
4848
|
e = e || {}, Z((function() {
|
|
4843
|
-
var t, r =
|
|
4849
|
+
var t, r = et(), n = b("FCP"), i = F("paint", (function(o) {
|
|
4844
4850
|
o.forEach((function(l) {
|
|
4845
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (
|
|
4851
|
+
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
4852
|
}));
|
|
4847
4853
|
}));
|
|
4848
|
-
i && (t = A(
|
|
4849
|
-
|
|
4850
|
-
|
|
4854
|
+
i && (t = A(s, n, fe, e.reportAllChanges), P((function(o) {
|
|
4855
|
+
n = b("FCP"), t = A(s, n, fe, e.reportAllChanges), Te((function() {
|
|
4856
|
+
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4851
4857
|
}));
|
|
4852
4858
|
})));
|
|
4853
4859
|
}));
|
|
4854
|
-
},
|
|
4855
|
-
e = e || {},
|
|
4856
|
-
var t, r = b("CLS", 0),
|
|
4860
|
+
}, me = [0.1, 0.25], br = function(s, e) {
|
|
4861
|
+
e = e || {}, tt(_e((function() {
|
|
4862
|
+
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4857
4863
|
c.forEach((function(u) {
|
|
4858
4864
|
if (!u.hadRecentInput) {
|
|
4859
4865
|
var S = i[0], g = i[i.length - 1];
|
|
4860
|
-
|
|
4866
|
+
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
4861
4867
|
}
|
|
4862
|
-
})),
|
|
4868
|
+
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4863
4869
|
}, l = F("layout-shift", o);
|
|
4864
|
-
l && (t = A(
|
|
4870
|
+
l && (t = A(s, r, me, e.reportAllChanges), J((function() {
|
|
4865
4871
|
o(l.takeRecords()), t(!0);
|
|
4866
4872
|
})), P((function() {
|
|
4867
|
-
|
|
4873
|
+
n = 0, r = b("CLS", 0), t = A(s, r, me, e.reportAllChanges), Te((function() {
|
|
4868
4874
|
return t();
|
|
4869
4875
|
}));
|
|
4870
4876
|
})), setTimeout(t, 0));
|
|
4871
4877
|
})));
|
|
4872
|
-
},
|
|
4873
|
-
|
|
4874
|
-
e.interactionId && (
|
|
4878
|
+
}, rt = 0, ne = 1 / 0, G = 0, Ar = function(s) {
|
|
4879
|
+
s.forEach((function(e) {
|
|
4880
|
+
e.interactionId && (ne = Math.min(ne, e.interactionId), G = Math.max(G, e.interactionId), rt = G ? (G - ne) / 7 + 1 : 0);
|
|
4875
4881
|
}));
|
|
4876
|
-
},
|
|
4877
|
-
return
|
|
4878
|
-
},
|
|
4879
|
-
"interactionCount" in performance ||
|
|
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)
|
|
4882
|
+
}, st = function() {
|
|
4883
|
+
return he ? rt : performance.interactionCount || 0;
|
|
4884
|
+
}, Lr = function() {
|
|
4885
|
+
"interactionCount" in performance || he || (he = F("event", Ar, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4886
|
+
}, y = [], j = /* @__PURE__ */ new Map(), nt = 0, Mr = function() {
|
|
4887
|
+
var s = Math.min(y.length - 1, Math.floor((st() - nt) / 50));
|
|
4888
|
+
return y[s];
|
|
4889
|
+
}, Rr = [], Cr = function(s) {
|
|
4890
|
+
if (Rr.forEach((function(n) {
|
|
4891
|
+
return n(s);
|
|
4892
|
+
})), s.interactionId || s.entryType === "first-input") {
|
|
4893
|
+
var e = y[y.length - 1], t = j.get(s.interactionId);
|
|
4894
|
+
if (t || y.length < 10 || s.duration > e.latency) {
|
|
4895
|
+
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
4896
|
else {
|
|
4891
|
-
var r = { id:
|
|
4897
|
+
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
4892
4898
|
j.set(r.id, r), y.push(r);
|
|
4893
4899
|
}
|
|
4894
|
-
y.sort((function(
|
|
4895
|
-
return i.latency -
|
|
4896
|
-
})), y.length > 10 && y.splice(10).forEach((function(
|
|
4897
|
-
return j.delete(
|
|
4900
|
+
y.sort((function(n, i) {
|
|
4901
|
+
return i.latency - n.latency;
|
|
4902
|
+
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
4903
|
+
return j.delete(n.id);
|
|
4898
4904
|
}));
|
|
4899
4905
|
}
|
|
4900
4906
|
}
|
|
4901
|
-
},
|
|
4907
|
+
}, it = function(s) {
|
|
4902
4908
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4903
|
-
return
|
|
4904
|
-
},
|
|
4909
|
+
return s = _e(s), document.visibilityState === "hidden" ? s() : (t = e(s), J(s)), t;
|
|
4910
|
+
}, ge = [200, 500], Nr = function(s, e) {
|
|
4905
4911
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4906
4912
|
var t;
|
|
4907
|
-
|
|
4908
|
-
var r,
|
|
4909
|
-
|
|
4910
|
-
l.forEach(
|
|
4911
|
-
var c =
|
|
4912
|
-
c && c.latency !==
|
|
4913
|
+
Lr();
|
|
4914
|
+
var r, n = b("INP"), i = function(l) {
|
|
4915
|
+
it((function() {
|
|
4916
|
+
l.forEach(Cr);
|
|
4917
|
+
var c = Mr();
|
|
4918
|
+
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
4913
4919
|
}));
|
|
4914
4920
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4915
|
-
r = A(
|
|
4921
|
+
r = A(s, n, ge, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4916
4922
|
i(o.takeRecords()), r(!0);
|
|
4917
4923
|
})), P((function() {
|
|
4918
|
-
|
|
4924
|
+
nt = st(), y.length = 0, j.clear(), n = b("INP"), r = A(s, n, ge, e.reportAllChanges);
|
|
4919
4925
|
})));
|
|
4920
4926
|
})));
|
|
4921
|
-
},
|
|
4927
|
+
}, Ee = [2500, 4e3], ie = {}, Or = function(s, e) {
|
|
4922
4928
|
e = e || {}, Z((function() {
|
|
4923
|
-
var t, r =
|
|
4929
|
+
var t, r = et(), n = b("LCP"), i = function(c) {
|
|
4924
4930
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4925
|
-
u.startTime < r.firstHiddenTime && (
|
|
4931
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - q(), 0), n.entries = [u], t());
|
|
4926
4932
|
}));
|
|
4927
4933
|
}, o = F("largest-contentful-paint", i);
|
|
4928
4934
|
if (o) {
|
|
4929
|
-
t = A(
|
|
4930
|
-
var l =
|
|
4931
|
-
|
|
4935
|
+
t = A(s, n, Ee, e.reportAllChanges);
|
|
4936
|
+
var l = _e((function() {
|
|
4937
|
+
ie[n.id] || (i(o.takeRecords()), o.disconnect(), ie[n.id] = !0, t(!0));
|
|
4932
4938
|
}));
|
|
4933
4939
|
["keydown", "click"].forEach((function(c) {
|
|
4934
4940
|
addEventListener(c, (function() {
|
|
4935
|
-
return
|
|
4941
|
+
return it(l);
|
|
4936
4942
|
}), { once: !0, capture: !0 });
|
|
4937
4943
|
})), J(l), P((function(c) {
|
|
4938
|
-
|
|
4939
|
-
|
|
4944
|
+
n = b("LCP"), t = A(s, n, Ee, e.reportAllChanges), Te((function() {
|
|
4945
|
+
n.value = performance.now() - c.timeStamp, ie[n.id] = !0, t(!0);
|
|
4940
4946
|
}));
|
|
4941
4947
|
}));
|
|
4942
4948
|
}
|
|
4943
4949
|
}));
|
|
4944
|
-
},
|
|
4950
|
+
}, Se = [800, 1800], Pr = function s(e) {
|
|
4945
4951
|
document.prerendering ? Z((function() {
|
|
4946
|
-
return
|
|
4952
|
+
return s(e);
|
|
4947
4953
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4948
|
-
return
|
|
4954
|
+
return s(e);
|
|
4949
4955
|
}), !0) : setTimeout(e, 0);
|
|
4950
|
-
},
|
|
4956
|
+
}, Dr = function(s, e) {
|
|
4951
4957
|
e = e || {};
|
|
4952
|
-
var t = b("TTFB"), r = A(
|
|
4953
|
-
|
|
4954
|
-
var
|
|
4955
|
-
|
|
4956
|
-
t = b("TTFB", 0), (r = A(
|
|
4958
|
+
var t = b("TTFB"), r = A(s, t, Se, e.reportAllChanges);
|
|
4959
|
+
Pr((function() {
|
|
4960
|
+
var n = pe();
|
|
4961
|
+
n && (t.value = Math.max(n.responseStart - q(), 0), t.entries = [n], r(!0), P((function() {
|
|
4962
|
+
t = b("TTFB", 0), (r = A(s, t, Se, e.reportAllChanges))(!0);
|
|
4957
4963
|
})));
|
|
4958
4964
|
}));
|
|
4959
4965
|
};
|
|
4960
|
-
const
|
|
4966
|
+
const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4961
4967
|
__proto__: null,
|
|
4962
|
-
CLSThresholds:
|
|
4963
|
-
FCPThresholds:
|
|
4964
|
-
INPThresholds:
|
|
4965
|
-
LCPThresholds:
|
|
4966
|
-
TTFBThresholds:
|
|
4967
|
-
onCLS:
|
|
4968
|
-
onFCP:
|
|
4969
|
-
onINP:
|
|
4970
|
-
onLCP:
|
|
4971
|
-
onTTFB:
|
|
4968
|
+
CLSThresholds: me,
|
|
4969
|
+
FCPThresholds: fe,
|
|
4970
|
+
INPThresholds: ge,
|
|
4971
|
+
LCPThresholds: Ee,
|
|
4972
|
+
TTFBThresholds: Se,
|
|
4973
|
+
onCLS: br,
|
|
4974
|
+
onFCP: tt,
|
|
4975
|
+
onINP: Nr,
|
|
4976
|
+
onLCP: Or,
|
|
4977
|
+
onTTFB: Dr
|
|
4972
4978
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4973
4979
|
export {
|
|
4974
4980
|
h as AppConfigValidationError,
|
|
4975
|
-
|
|
4976
|
-
|
|
4981
|
+
Vr as DEFAULT_SESSION_TIMEOUT,
|
|
4982
|
+
ce as DEFAULT_WEB_VITALS_MODE,
|
|
4977
4983
|
L as DeviceType,
|
|
4978
|
-
|
|
4984
|
+
oe as EmitterEvent,
|
|
4979
4985
|
U as ErrorType,
|
|
4980
4986
|
d as EventType,
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4987
|
+
zr as InitializationTimeoutError,
|
|
4988
|
+
k as IntegrationValidationError,
|
|
4989
|
+
Xr as MAX_ARRAY_LENGTH,
|
|
4990
|
+
Fr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4991
|
+
Hr as MAX_CUSTOM_EVENT_KEYS,
|
|
4992
|
+
Ur as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4993
|
+
xr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4994
|
+
Br as MAX_METADATA_NESTING_DEPTH,
|
|
4995
|
+
$r as MAX_NESTED_OBJECT_KEYS,
|
|
4996
|
+
Wr as MAX_STRING_LENGTH,
|
|
4997
|
+
Gr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4992
4998
|
z as Mode,
|
|
4993
|
-
|
|
4999
|
+
Xe as PII_PATTERNS,
|
|
4994
5000
|
N as PermanentError,
|
|
4995
|
-
|
|
5001
|
+
Re as SamplingRateValidationError,
|
|
4996
5002
|
X as ScrollDirection,
|
|
4997
|
-
|
|
4998
|
-
|
|
5003
|
+
ft as SessionTimeoutValidationError,
|
|
5004
|
+
V as SpecialApiUrl,
|
|
4999
5005
|
H as TraceLogValidationError,
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5006
|
+
Kr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5007
|
+
Pe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5008
|
+
Rt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5009
|
+
De as getWebVitalsThresholds,
|
|
5010
|
+
Qr as isPrimaryScrollEvent,
|
|
5011
|
+
jr as isSecondaryScrollEvent,
|
|
5012
|
+
Yr as tracelog
|
|
5007
5013
|
};
|