@tracelog/lib 2.1.2-rc.78.4 → 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/README.md +4 -97
- package/dist/browser/tracelog.esm.js +441 -570
- 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 +6 -171
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +2 -45
- package/dist/public-api.d.ts +2 -45
- package/dist/public-api.js +6 -171
- 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", at = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], at = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], lt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,53 +71,53 @@ const m = {
|
|
|
71
71
|
INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
},
|
|
74
|
+
}, 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
|
|
83
|
-
class
|
|
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
|
+
class N extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
85
|
+
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
var 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 || {}),
|
|
89
|
-
const
|
|
90
|
-
class
|
|
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
|
+
class H extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
class
|
|
95
|
+
class h extends H {
|
|
96
96
|
constructor(e, t = "config") {
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class ft extends H {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class Re extends
|
|
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, "");
|
|
@@ -136,7 +136,7 @@ const We = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
136
136
|
return `[TraceLog] ${s}: ${String(e)}`;
|
|
137
137
|
}
|
|
138
138
|
return `[TraceLog] ${s}`;
|
|
139
|
-
},
|
|
139
|
+
}, Et = () => {
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
142
142
|
try {
|
|
@@ -145,15 +145,15 @@ const We = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
147
147
|
}, a = (s, e, t) => {
|
|
148
|
-
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ?
|
|
149
|
-
if (!
|
|
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
|
-
},
|
|
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
154
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
155
155
|
r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
|
|
156
|
-
},
|
|
156
|
+
}, ae = (s) => {
|
|
157
157
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
158
158
|
for (const [r, n] of Object.entries(s)) {
|
|
159
159
|
const i = r.toLowerCase();
|
|
@@ -161,16 +161,16 @@ const We = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
161
161
|
e[r] = "[REDACTED]";
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] =
|
|
165
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
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
166
|
) : e[r] = n;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let
|
|
170
|
+
let le, Ge;
|
|
171
171
|
const _t = () => {
|
|
172
|
-
typeof window < "u" && !
|
|
173
|
-
},
|
|
172
|
+
typeof window < "u" && !le && (le = window.matchMedia("(pointer: coarse)"), Ge = window.matchMedia("(hover: none)"));
|
|
173
|
+
}, K = "Unknown", vt = (s) => {
|
|
174
174
|
const e = s.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
176
176
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -181,8 +181,8 @@ const _t = () => {
|
|
|
181
181
|
if (/ios/i.test(e)) return "iOS";
|
|
182
182
|
}
|
|
183
183
|
const t = navigator.userAgent;
|
|
184
|
-
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" :
|
|
185
|
-
},
|
|
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
|
+
}, It = (s) => {
|
|
186
186
|
const e = s.userAgentData?.brands;
|
|
187
187
|
if (e != null && e.length > 0) {
|
|
188
188
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -192,8 +192,8 @@ const _t = () => {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
const t = navigator.userAgent;
|
|
195
|
-
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" :
|
|
196
|
-
},
|
|
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
|
+
}, wt = () => {
|
|
197
197
|
try {
|
|
198
198
|
const s = navigator;
|
|
199
199
|
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
@@ -201,27 +201,27 @@ const _t = () => {
|
|
|
201
201
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : s.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
202
202
|
}
|
|
203
203
|
_t();
|
|
204
|
-
const e = window.innerWidth, 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
205
|
return e <= 767 || o && n ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? L.Tablet : L.Desktop;
|
|
206
206
|
} catch (s) {
|
|
207
207
|
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), L.Desktop;
|
|
208
208
|
}
|
|
209
|
-
},
|
|
209
|
+
}, yt = () => {
|
|
210
210
|
try {
|
|
211
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
217
|
} catch (s) {
|
|
218
218
|
return a("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
219
219
|
type: L.Desktop,
|
|
220
|
-
os:
|
|
221
|
-
browser:
|
|
220
|
+
os: K,
|
|
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 _t = () => {
|
|
|
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 _t = () => {
|
|
|
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,
|
|
@@ -272,53 +272,53 @@ const _t = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
},
|
|
275
|
+
}, ce = "needs-improvement", De = (s = ce) => {
|
|
276
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
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
289
|
const s = new URLSearchParams(window.location.search);
|
|
290
|
-
s.delete(
|
|
290
|
+
s.delete($e);
|
|
291
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
314
|
sessionStorage.setItem(x, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
|
-
style: s ?
|
|
316
|
+
style: s ? Be : We
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
|
-
},
|
|
321
|
+
}, Ut = [
|
|
322
322
|
"co.uk",
|
|
323
323
|
"org.uk",
|
|
324
324
|
"com.au",
|
|
@@ -330,13 +330,13 @@ const _t = () => {
|
|
|
330
330
|
"co.in",
|
|
331
331
|
"com.cn",
|
|
332
332
|
"co.za"
|
|
333
|
-
],
|
|
333
|
+
], ke = (s) => {
|
|
334
334
|
const e = s.toLowerCase().split(".");
|
|
335
335
|
if (e.length <= 2)
|
|
336
336
|
return s.toLowerCase();
|
|
337
337
|
const t = e.slice(-2).join(".");
|
|
338
|
-
return
|
|
339
|
-
}, xt = (s, e) => s === e ? !0 :
|
|
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
340
|
const s = document.referrer;
|
|
341
341
|
if (!s)
|
|
342
342
|
return "Direct";
|
|
@@ -346,24 +346,24 @@ const _t = () => {
|
|
|
346
346
|
} catch (e) {
|
|
347
347
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
348
348
|
}
|
|
349
|
-
},
|
|
349
|
+
}, re = () => {
|
|
350
350
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
351
|
-
return
|
|
351
|
+
return at.forEach((r) => {
|
|
352
352
|
const n = s.get(r);
|
|
353
353
|
if (n) {
|
|
354
354
|
const i = r.split("utm_")[1];
|
|
355
355
|
e[i] = n;
|
|
356
356
|
}
|
|
357
357
|
}), Object.keys(e).length ? e : void 0;
|
|
358
|
-
},
|
|
358
|
+
}, Ht = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
359
359
|
const e = Math.random() * 16 | 0;
|
|
360
360
|
return (s === "x" ? e : e & 3 | 8).toString(16);
|
|
361
361
|
});
|
|
362
|
-
let
|
|
363
|
-
const
|
|
362
|
+
let B = 0, W = 0;
|
|
363
|
+
const Ft = () => {
|
|
364
364
|
let s = Date.now();
|
|
365
|
-
s <
|
|
366
|
-
const e =
|
|
365
|
+
s < W && (s = W), s === W ? B = (B + 1) % 1e3 : B = 0, W = s;
|
|
366
|
+
const e = B.toString().padStart(3, "0");
|
|
367
367
|
let t = "";
|
|
368
368
|
try {
|
|
369
369
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -373,14 +373,14 @@ const $t = () => {
|
|
|
373
373
|
} catch {
|
|
374
374
|
}
|
|
375
375
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${s}-${e}-${t}`;
|
|
376
|
-
},
|
|
376
|
+
}, ze = (s, e = !1) => {
|
|
377
377
|
try {
|
|
378
378
|
const t = new URL(s), r = t.protocol === "https:", n = t.protocol === "http:";
|
|
379
379
|
return r || e && n;
|
|
380
380
|
} catch {
|
|
381
381
|
return !1;
|
|
382
382
|
}
|
|
383
|
-
},
|
|
383
|
+
}, $t = (s) => {
|
|
384
384
|
try {
|
|
385
385
|
const t = new URL(window.location.href).hostname;
|
|
386
386
|
if (!t || typeof t != "string")
|
|
@@ -398,28 +398,28 @@ const $t = () => {
|
|
|
398
398
|
if (r.length === 2 ? n = r.join(".") : n = r.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
399
399
|
throw new Error("Invalid domain structure for SaaS");
|
|
400
400
|
const i = `https://${s}.${n}/collect`;
|
|
401
|
-
if (!
|
|
401
|
+
if (!ze(i))
|
|
402
402
|
throw new Error("Generated URL failed validation");
|
|
403
403
|
return i;
|
|
404
404
|
} catch (e) {
|
|
405
405
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
406
406
|
}
|
|
407
|
-
},
|
|
407
|
+
}, Bt = (s) => {
|
|
408
408
|
const e = {};
|
|
409
|
-
s.integrations?.tracelog?.projectId && (e.saas =
|
|
409
|
+
s.integrations?.tracelog?.projectId && (e.saas = $t(s.integrations.tracelog.projectId));
|
|
410
410
|
const t = s.integrations?.custom?.collectApiUrl;
|
|
411
411
|
if (t) {
|
|
412
412
|
const r = s.integrations?.custom?.allowHttp ?? !1;
|
|
413
|
-
if (!
|
|
413
|
+
if (!ze(t, r))
|
|
414
414
|
throw new Error("Invalid custom API URL");
|
|
415
415
|
e.custom = t;
|
|
416
416
|
}
|
|
417
417
|
return e;
|
|
418
|
-
},
|
|
418
|
+
}, ue = (s, e = []) => {
|
|
419
419
|
if (!s || typeof s != "string")
|
|
420
420
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof s } }), s || "";
|
|
421
421
|
try {
|
|
422
|
-
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
422
|
+
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...lt, ...e])];
|
|
423
423
|
let i = !1;
|
|
424
424
|
const o = [];
|
|
425
425
|
return n.forEach((c) => {
|
|
@@ -428,13 +428,13 @@ const $t = () => {
|
|
|
428
428
|
} catch (t) {
|
|
429
429
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
430
430
|
}
|
|
431
|
-
},
|
|
431
|
+
}, Ve = (s) => {
|
|
432
432
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
433
433
|
return "";
|
|
434
434
|
let e = s;
|
|
435
435
|
s.length > 1e3 && (e = s.slice(0, Math.max(0, 1e3)));
|
|
436
436
|
let t = 0;
|
|
437
|
-
for (const n of
|
|
437
|
+
for (const n of ct) {
|
|
438
438
|
const i = e;
|
|
439
439
|
e = e.replace(n, ""), i !== e && t++;
|
|
440
440
|
}
|
|
@@ -444,53 +444,53 @@ const $t = () => {
|
|
|
444
444
|
valueLength: s.length
|
|
445
445
|
}
|
|
446
446
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
447
|
-
},
|
|
447
|
+
}, de = (s, e = 0) => {
|
|
448
448
|
if (e > 3 || s == null)
|
|
449
449
|
return null;
|
|
450
450
|
if (typeof s == "string")
|
|
451
|
-
return
|
|
451
|
+
return Ve(s);
|
|
452
452
|
if (typeof s == "number")
|
|
453
453
|
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
454
454
|
if (typeof s == "boolean")
|
|
455
455
|
return s;
|
|
456
456
|
if (Array.isArray(s))
|
|
457
|
-
return s.slice(0, 100).map((n) =>
|
|
457
|
+
return s.slice(0, 100).map((n) => de(n, e + 1)).filter((n) => n !== null);
|
|
458
458
|
if (typeof s == "object") {
|
|
459
459
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
460
460
|
for (const [i, o] of n) {
|
|
461
|
-
const l =
|
|
461
|
+
const l = Ve(i);
|
|
462
462
|
if (l) {
|
|
463
|
-
const c =
|
|
463
|
+
const c = de(o, e + 1);
|
|
464
464
|
c !== null && (t[l] = c);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
467
|
return t;
|
|
468
468
|
}
|
|
469
469
|
return null;
|
|
470
|
-
},
|
|
470
|
+
}, Wt = (s) => {
|
|
471
471
|
if (typeof s != "object" || s === null)
|
|
472
472
|
return {};
|
|
473
473
|
try {
|
|
474
|
-
const e =
|
|
474
|
+
const e = de(s);
|
|
475
475
|
return typeof e == "object" && e !== null ? e : {};
|
|
476
476
|
} catch (e) {
|
|
477
477
|
const t = e instanceof Error ? e.message : String(e);
|
|
478
478
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
479
479
|
}
|
|
480
|
-
},
|
|
480
|
+
}, Gt = (s) => {
|
|
481
481
|
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
482
|
-
throw new
|
|
482
|
+
throw new h("Configuration must be an object", "config");
|
|
483
483
|
if (s) {
|
|
484
484
|
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
485
|
-
throw new
|
|
485
|
+
throw new ft(m.INVALID_SESSION_TIMEOUT, "config");
|
|
486
486
|
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
487
|
-
throw new
|
|
488
|
-
if (s.integrations &&
|
|
487
|
+
throw new h(m.INVALID_GLOBAL_METADATA, "config");
|
|
488
|
+
if (s.integrations && Qt(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
489
489
|
if (!Array.isArray(s.sensitiveQueryParams))
|
|
490
|
-
throw new
|
|
490
|
+
throw new h(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
491
491
|
for (const e of s.sensitiveQueryParams)
|
|
492
492
|
if (typeof e != "string")
|
|
493
|
-
throw new
|
|
493
|
+
throw new h("All sensitive query params must be strings", "config");
|
|
494
494
|
}
|
|
495
495
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
496
496
|
throw new Re(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
@@ -498,111 +498,111 @@ const $t = () => {
|
|
|
498
498
|
throw new Re(m.INVALID_SAMPLING_RATE, "config");
|
|
499
499
|
if (s.primaryScrollSelector !== void 0) {
|
|
500
500
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
501
|
-
throw new
|
|
501
|
+
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
502
502
|
if (s.primaryScrollSelector !== "window")
|
|
503
503
|
try {
|
|
504
504
|
document.querySelector(s.primaryScrollSelector);
|
|
505
505
|
} catch {
|
|
506
|
-
throw new
|
|
506
|
+
throw new h(
|
|
507
507
|
`${m.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${s.primaryScrollSelector}"`,
|
|
508
508
|
"config"
|
|
509
509
|
);
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
512
|
if (s.pageViewThrottleMs !== void 0 && (typeof s.pageViewThrottleMs != "number" || s.pageViewThrottleMs < 0))
|
|
513
|
-
throw new
|
|
513
|
+
throw new h(m.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
514
514
|
if (s.clickThrottleMs !== void 0 && (typeof s.clickThrottleMs != "number" || s.clickThrottleMs < 0))
|
|
515
|
-
throw new
|
|
515
|
+
throw new h(m.INVALID_CLICK_THROTTLE, "config");
|
|
516
516
|
if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
|
|
517
|
-
throw new
|
|
518
|
-
if (s.viewport !== void 0 &&
|
|
517
|
+
throw new h(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
518
|
+
if (s.viewport !== void 0 && Xt(s.viewport), s.webVitalsMode !== void 0) {
|
|
519
519
|
if (typeof s.webVitalsMode != "string")
|
|
520
|
-
throw new
|
|
520
|
+
throw new h(
|
|
521
521
|
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
522
522
|
"config"
|
|
523
523
|
);
|
|
524
524
|
const e = ["all", "needs-improvement", "poor"];
|
|
525
525
|
if (!e.includes(s.webVitalsMode))
|
|
526
|
-
throw new
|
|
526
|
+
throw new h(
|
|
527
527
|
`Invalid webVitalsMode: "${s.webVitalsMode}". Must be one of: ${e.join(", ")}`,
|
|
528
528
|
"config"
|
|
529
529
|
);
|
|
530
530
|
}
|
|
531
531
|
if (s.webVitalsThresholds !== void 0) {
|
|
532
532
|
if (typeof s.webVitalsThresholds != "object" || s.webVitalsThresholds === null || Array.isArray(s.webVitalsThresholds))
|
|
533
|
-
throw new
|
|
533
|
+
throw new h("webVitalsThresholds must be an object", "config");
|
|
534
534
|
const e = ["LCP", "FCP", "CLS", "INP", "TTFB", "LONG_TASK"];
|
|
535
535
|
for (const [t, r] of Object.entries(s.webVitalsThresholds)) {
|
|
536
536
|
if (!e.includes(t))
|
|
537
|
-
throw new
|
|
537
|
+
throw new h(
|
|
538
538
|
`Invalid Web Vitals threshold key: "${t}". Must be one of: ${e.join(", ")}`,
|
|
539
539
|
"config"
|
|
540
540
|
);
|
|
541
541
|
if (typeof r != "number" || !Number.isFinite(r) || r < 0)
|
|
542
|
-
throw new
|
|
542
|
+
throw new h(
|
|
543
543
|
`Invalid Web Vitals threshold value for ${t}: ${r}. Must be a non-negative finite number`,
|
|
544
544
|
"config"
|
|
545
545
|
);
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
|
-
},
|
|
549
|
+
}, Xt = (s) => {
|
|
550
550
|
if (typeof s != "object" || s === null)
|
|
551
|
-
throw new
|
|
551
|
+
throw new h(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
552
552
|
if (!s.elements || !Array.isArray(s.elements))
|
|
553
|
-
throw new
|
|
553
|
+
throw new h(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
554
554
|
if (s.elements.length === 0)
|
|
555
|
-
throw new
|
|
555
|
+
throw new h(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
556
556
|
const e = /* @__PURE__ */ new Set();
|
|
557
557
|
for (const t of s.elements) {
|
|
558
558
|
if (!t.selector || typeof t.selector != "string" || !t.selector.trim())
|
|
559
|
-
throw new
|
|
559
|
+
throw new h(m.INVALID_VIEWPORT_ELEMENT, "config");
|
|
560
560
|
const r = t.selector.trim();
|
|
561
561
|
if (e.has(r))
|
|
562
|
-
throw new
|
|
562
|
+
throw new h(
|
|
563
563
|
`Duplicate viewport selector found: "${r}". Each selector should appear only once.`,
|
|
564
564
|
"config"
|
|
565
565
|
);
|
|
566
566
|
if (e.add(r), t.id !== void 0 && (typeof t.id != "string" || !t.id.trim()))
|
|
567
|
-
throw new
|
|
567
|
+
throw new h(m.INVALID_VIEWPORT_ELEMENT_ID, "config");
|
|
568
568
|
if (t.name !== void 0 && (typeof t.name != "string" || !t.name.trim()))
|
|
569
|
-
throw new
|
|
569
|
+
throw new h(m.INVALID_VIEWPORT_ELEMENT_NAME, "config");
|
|
570
570
|
}
|
|
571
571
|
if (s.threshold !== void 0 && (typeof s.threshold != "number" || s.threshold < 0 || s.threshold > 1))
|
|
572
|
-
throw new
|
|
572
|
+
throw new h(m.INVALID_VIEWPORT_THRESHOLD, "config");
|
|
573
573
|
if (s.minDwellTime !== void 0 && (typeof s.minDwellTime != "number" || s.minDwellTime < 0))
|
|
574
|
-
throw new
|
|
574
|
+
throw new h(m.INVALID_VIEWPORT_MIN_DWELL_TIME, "config");
|
|
575
575
|
if (s.cooldownPeriod !== void 0 && (typeof s.cooldownPeriod != "number" || s.cooldownPeriod < 0))
|
|
576
|
-
throw new
|
|
576
|
+
throw new h(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
577
577
|
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
578
|
-
throw new
|
|
579
|
-
},
|
|
578
|
+
throw new h(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
579
|
+
}, Qt = (s) => {
|
|
580
580
|
if (s) {
|
|
581
581
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
582
|
-
throw new
|
|
582
|
+
throw new k(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
583
583
|
if (s.custom) {
|
|
584
584
|
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
585
|
-
throw new
|
|
585
|
+
throw new k(m.INVALID_CUSTOM_API_URL, "config");
|
|
586
586
|
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
587
|
-
throw new
|
|
587
|
+
throw new k("allowHttp must be a boolean", "config");
|
|
588
588
|
const e = s.custom.collectApiUrl.trim();
|
|
589
589
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
590
|
-
throw new
|
|
590
|
+
throw new k('Custom API URL must start with "http://" or "https://"', "config");
|
|
591
591
|
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
592
|
-
throw new
|
|
592
|
+
throw new k(
|
|
593
593
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
594
594
|
"config"
|
|
595
595
|
);
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
|
-
},
|
|
599
|
-
|
|
598
|
+
}, jt = (s) => {
|
|
599
|
+
Gt(s);
|
|
600
600
|
const e = {
|
|
601
601
|
...s ?? {},
|
|
602
602
|
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
603
603
|
globalMetadata: s?.globalMetadata ?? {},
|
|
604
604
|
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
605
|
-
errorSampling: s?.errorSampling ??
|
|
605
|
+
errorSampling: s?.errorSampling ?? Qe,
|
|
606
606
|
samplingRate: s?.samplingRate ?? 1,
|
|
607
607
|
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
608
608
|
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
@@ -618,7 +618,7 @@ const $t = () => {
|
|
|
618
618
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
619
619
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
620
620
|
}), e;
|
|
621
|
-
},
|
|
621
|
+
}, zt = (s) => {
|
|
622
622
|
if (typeof s == "string")
|
|
623
623
|
return !0;
|
|
624
624
|
if (typeof s == "object" && s !== null && !Array.isArray(s)) {
|
|
@@ -635,7 +635,7 @@ const $t = () => {
|
|
|
635
635
|
return !0;
|
|
636
636
|
}
|
|
637
637
|
return !1;
|
|
638
|
-
},
|
|
638
|
+
}, Ke = (s, e = 0) => {
|
|
639
639
|
if (typeof s != "object" || s === null || e > 1)
|
|
640
640
|
return !1;
|
|
641
641
|
for (const t of Object.values(s)) {
|
|
@@ -649,12 +649,12 @@ const $t = () => {
|
|
|
649
649
|
if (typeof t[0] == "string") {
|
|
650
650
|
if (!t.every((o) => typeof o == "string"))
|
|
651
651
|
return !1;
|
|
652
|
-
} else if (!t.every((o) =>
|
|
652
|
+
} else if (!t.every((o) => zt(o)))
|
|
653
653
|
return !1;
|
|
654
654
|
continue;
|
|
655
655
|
}
|
|
656
656
|
if (r === "object" && e === 0) {
|
|
657
|
-
if (!
|
|
657
|
+
if (!Ke(t, e + 1))
|
|
658
658
|
return !1;
|
|
659
659
|
continue;
|
|
660
660
|
}
|
|
@@ -662,7 +662,7 @@ const $t = () => {
|
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
664
|
return !0;
|
|
665
|
-
},
|
|
665
|
+
}, Kt = (s) => typeof s != "string" ? {
|
|
666
666
|
valid: !1,
|
|
667
667
|
error: "Event name must be a string"
|
|
668
668
|
} : s.length === 0 ? {
|
|
@@ -677,9 +677,9 @@ const $t = () => {
|
|
|
677
677
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
678
678
|
valid: !1,
|
|
679
679
|
error: "Event name cannot be a reserved word"
|
|
680
|
-
} : { valid: !0 },
|
|
681
|
-
const r =
|
|
682
|
-
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))
|
|
683
683
|
return {
|
|
684
684
|
valid: !1,
|
|
685
685
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -727,7 +727,7 @@ const $t = () => {
|
|
|
727
727
|
valid: !0,
|
|
728
728
|
sanitizedMetadata: r
|
|
729
729
|
};
|
|
730
|
-
},
|
|
730
|
+
}, Ye = (s, e, t) => {
|
|
731
731
|
if (Array.isArray(e)) {
|
|
732
732
|
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
733
733
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -737,7 +737,7 @@ const $t = () => {
|
|
|
737
737
|
valid: !1,
|
|
738
738
|
error: `${n}: array item at index ${i} must be an object.`
|
|
739
739
|
};
|
|
740
|
-
const l =
|
|
740
|
+
const l = Ue(s, o, t);
|
|
741
741
|
if (!l.valid)
|
|
742
742
|
return {
|
|
743
743
|
valid: !1,
|
|
@@ -750,16 +750,16 @@ const $t = () => {
|
|
|
750
750
|
sanitizedMetadata: r
|
|
751
751
|
};
|
|
752
752
|
}
|
|
753
|
-
return
|
|
754
|
-
},
|
|
755
|
-
const t =
|
|
753
|
+
return Ue(s, e, t);
|
|
754
|
+
}, Yt = (s, e) => {
|
|
755
|
+
const t = Kt(s);
|
|
756
756
|
if (!t.valid)
|
|
757
757
|
return a("error", "Event name validation failed", {
|
|
758
758
|
data: { eventName: s, error: t.error }
|
|
759
759
|
}), t;
|
|
760
760
|
if (!e)
|
|
761
761
|
return { valid: !0 };
|
|
762
|
-
const r =
|
|
762
|
+
const r = Ye(s, e, "customEvent");
|
|
763
763
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
764
764
|
data: {
|
|
765
765
|
eventName: s,
|
|
@@ -767,7 +767,7 @@ const $t = () => {
|
|
|
767
767
|
}
|
|
768
768
|
}), r;
|
|
769
769
|
};
|
|
770
|
-
class
|
|
770
|
+
class qt {
|
|
771
771
|
listeners = /* @__PURE__ */ new Map();
|
|
772
772
|
/**
|
|
773
773
|
* Subscribes to an event channel
|
|
@@ -884,7 +884,7 @@ class Jt {
|
|
|
884
884
|
this.listeners.clear();
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
|
-
function
|
|
887
|
+
function qe(s, e, t) {
|
|
888
888
|
try {
|
|
889
889
|
const r = e(s);
|
|
890
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);
|
|
@@ -895,10 +895,10 @@ function Je(s, e, t) {
|
|
|
895
895
|
}), s;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
function
|
|
899
|
-
return s.map((r) =>
|
|
898
|
+
function Jt(s, e, t) {
|
|
899
|
+
return s.map((r) => qe(r, e, t)).filter((r) => r !== null);
|
|
900
900
|
}
|
|
901
|
-
function
|
|
901
|
+
function Je(s, e, t) {
|
|
902
902
|
try {
|
|
903
903
|
const r = e(s);
|
|
904
904
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -914,7 +914,7 @@ function Ze(s, e, t) {
|
|
|
914
914
|
}), s;
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
|
-
const
|
|
917
|
+
const se = {};
|
|
918
918
|
class _ {
|
|
919
919
|
/**
|
|
920
920
|
* Retrieves a value from global state.
|
|
@@ -933,7 +933,7 @@ class _ {
|
|
|
933
933
|
* ```
|
|
934
934
|
*/
|
|
935
935
|
get(e) {
|
|
936
|
-
return
|
|
936
|
+
return se[e];
|
|
937
937
|
}
|
|
938
938
|
/**
|
|
939
939
|
* Sets a value in global state.
|
|
@@ -953,7 +953,7 @@ class _ {
|
|
|
953
953
|
* ```
|
|
954
954
|
*/
|
|
955
955
|
set(e, t) {
|
|
956
|
-
|
|
956
|
+
se[e] = t;
|
|
957
957
|
}
|
|
958
958
|
/**
|
|
959
959
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -970,7 +970,7 @@ class _ {
|
|
|
970
970
|
* ```
|
|
971
971
|
*/
|
|
972
972
|
getState() {
|
|
973
|
-
return { ...
|
|
973
|
+
return { ...se };
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
976
|
class xe extends _ {
|
|
@@ -978,8 +978,6 @@ class xe extends _ {
|
|
|
978
978
|
integrationId;
|
|
979
979
|
apiUrl;
|
|
980
980
|
transformers;
|
|
981
|
-
staticHeaders;
|
|
982
|
-
customHeadersProvider;
|
|
983
981
|
lastPermanentErrorLog = null;
|
|
984
982
|
recoveryInProgress = !1;
|
|
985
983
|
lastMetadataTimestamp = 0;
|
|
@@ -994,14 +992,12 @@ class xe extends _ {
|
|
|
994
992
|
* @param integrationId - Optional integration identifier ('saas' or 'custom')
|
|
995
993
|
* @param apiUrl - Optional API endpoint URL
|
|
996
994
|
* @param transformers - Optional event transformation hooks
|
|
997
|
-
* @param staticHeaders - Optional static HTTP headers (from config)
|
|
998
|
-
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
999
995
|
* @throws Error if integrationId and apiUrl are not both provided or both undefined
|
|
1000
996
|
*/
|
|
1001
|
-
constructor(e, t, r, n = {}
|
|
997
|
+
constructor(e, t, r, n = {}) {
|
|
1002
998
|
if (super(), t && !r || !t && r)
|
|
1003
999
|
throw new Error("SenderManager: integrationId and apiUrl must either both be provided or both be undefined");
|
|
1004
|
-
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers = n
|
|
1000
|
+
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers = n;
|
|
1005
1001
|
}
|
|
1006
1002
|
/**
|
|
1007
1003
|
* Get the integration ID for this sender
|
|
@@ -1010,45 +1006,8 @@ class xe extends _ {
|
|
|
1010
1006
|
getIntegrationId() {
|
|
1011
1007
|
return this.integrationId;
|
|
1012
1008
|
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Sets the custom headers provider callback.
|
|
1015
|
-
* Only applies to 'custom' integration (ignored for 'saas').
|
|
1016
|
-
*
|
|
1017
|
-
* @param provider - Callback function that returns custom headers
|
|
1018
|
-
*/
|
|
1019
|
-
setCustomHeadersProvider(e) {
|
|
1020
|
-
this.customHeadersProvider = e;
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* Removes the custom headers provider callback.
|
|
1024
|
-
*/
|
|
1025
|
-
removeCustomHeadersProvider() {
|
|
1026
|
-
this.customHeadersProvider = void 0;
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Builds custom headers by merging static headers with dynamic headers from provider.
|
|
1030
|
-
* Only applies to 'custom' integration (returns empty object for 'saas').
|
|
1031
|
-
*
|
|
1032
|
-
* @returns Merged custom headers object (dynamic headers override static)
|
|
1033
|
-
* @private
|
|
1034
|
-
*/
|
|
1035
|
-
getCustomHeaders() {
|
|
1036
|
-
if (this.integrationId !== "custom")
|
|
1037
|
-
return {};
|
|
1038
|
-
let e = {};
|
|
1039
|
-
if (this.customHeadersProvider)
|
|
1040
|
-
try {
|
|
1041
|
-
const t = this.customHeadersProvider();
|
|
1042
|
-
typeof t == "object" && t !== null && !Array.isArray(t) ? e = t : a("warn", "Custom headers provider returned invalid value, expected object", {
|
|
1043
|
-
data: { received: typeof t }
|
|
1044
|
-
});
|
|
1045
|
-
} catch (t) {
|
|
1046
|
-
a("warn", "Custom headers provider threw an error, using static headers only", { error: t });
|
|
1047
|
-
}
|
|
1048
|
-
return { ...this.staticHeaders, ...e };
|
|
1049
|
-
}
|
|
1050
1009
|
getQueueStorageKey() {
|
|
1051
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1010
|
+
const e = this.get("userId") || "anonymous", t = ut(e);
|
|
1052
1011
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1053
1012
|
}
|
|
1054
1013
|
/**
|
|
@@ -1073,11 +1032,6 @@ class xe extends _ {
|
|
|
1073
1032
|
*
|
|
1074
1033
|
* **Important**: No retry mechanism for failures. Events are NOT persisted.
|
|
1075
1034
|
*
|
|
1076
|
-
* **Custom Headers Limitation**: Custom headers set via `setCustomHeaders()` are NOT applied
|
|
1077
|
-
* to sendBeacon requests due to browser API limitations. The sendBeacon API only supports
|
|
1078
|
-
* Content-Type header via Blob. For scenarios requiring custom headers, ensure async
|
|
1079
|
-
* sends complete before page unload.
|
|
1080
|
-
*
|
|
1081
1035
|
* @param body - Event queue to send
|
|
1082
1036
|
* @returns `true` if send succeeded or was skipped, `false` if failed
|
|
1083
1037
|
*
|
|
@@ -1085,13 +1039,13 @@ class xe extends _ {
|
|
|
1085
1039
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1086
1040
|
*/
|
|
1087
1041
|
sendEventsQueueSync(e) {
|
|
1088
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1042
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(V.Fail) ? (a(
|
|
1089
1043
|
"warn",
|
|
1090
1044
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1091
1045
|
{
|
|
1092
1046
|
data: { events: e.events.length }
|
|
1093
1047
|
}
|
|
1094
|
-
), !1) : this.apiUrl?.includes(
|
|
1048
|
+
), !1) : this.apiUrl?.includes(V.Localhost) ? (a(
|
|
1095
1049
|
"debug",
|
|
1096
1050
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1097
1051
|
{
|
|
@@ -1133,7 +1087,7 @@ class xe extends _ {
|
|
|
1133
1087
|
const r = await this.send(e);
|
|
1134
1088
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
|
|
1135
1089
|
} catch (r) {
|
|
1136
|
-
return r instanceof
|
|
1090
|
+
return r instanceof N ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1137
1091
|
}
|
|
1138
1092
|
}
|
|
1139
1093
|
/**
|
|
@@ -1200,7 +1154,7 @@ class xe extends _ {
|
|
|
1200
1154
|
const r = this.createRecoveryBody(t);
|
|
1201
1155
|
await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
|
|
1202
1156
|
} catch (t) {
|
|
1203
|
-
if (t instanceof
|
|
1157
|
+
if (t instanceof N) {
|
|
1204
1158
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1205
1159
|
return;
|
|
1206
1160
|
}
|
|
@@ -1254,7 +1208,7 @@ class xe extends _ {
|
|
|
1254
1208
|
const t = this.transformers.beforeSend;
|
|
1255
1209
|
if (!t)
|
|
1256
1210
|
return e;
|
|
1257
|
-
const r =
|
|
1211
|
+
const r = Jt(
|
|
1258
1212
|
e.events,
|
|
1259
1213
|
t,
|
|
1260
1214
|
this.integrationId || "SenderManager"
|
|
@@ -1299,7 +1253,7 @@ class xe extends _ {
|
|
|
1299
1253
|
if (this.integrationId === "saas")
|
|
1300
1254
|
return e;
|
|
1301
1255
|
const t = this.transformers.beforeBatch;
|
|
1302
|
-
return t ?
|
|
1256
|
+
return t ? Je(e, t, this.integrationId || "SenderManager") : e;
|
|
1303
1257
|
}
|
|
1304
1258
|
/**
|
|
1305
1259
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1367,11 +1321,11 @@ class xe extends _ {
|
|
|
1367
1321
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1368
1322
|
if (!r)
|
|
1369
1323
|
return !0;
|
|
1370
|
-
if (this.apiUrl?.includes(
|
|
1324
|
+
if (this.apiUrl?.includes(V.Fail))
|
|
1371
1325
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1372
1326
|
data: { events: r.events.length }
|
|
1373
1327
|
}), !1;
|
|
1374
|
-
if (this.apiUrl?.includes(
|
|
1328
|
+
if (this.apiUrl?.includes(V.Localhost))
|
|
1375
1329
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1376
1330
|
data: { events: r.events.length }
|
|
1377
1331
|
}), !0;
|
|
@@ -1387,7 +1341,7 @@ class xe extends _ {
|
|
|
1387
1341
|
), !0) : !1;
|
|
1388
1342
|
} catch (l) {
|
|
1389
1343
|
const c = o === 3;
|
|
1390
|
-
if (l instanceof
|
|
1344
|
+
if (l instanceof N)
|
|
1391
1345
|
throw l;
|
|
1392
1346
|
if (a(
|
|
1393
1347
|
c ? "error" : "warn",
|
|
@@ -1437,20 +1391,19 @@ class xe extends _ {
|
|
|
1437
1391
|
r.abort();
|
|
1438
1392
|
}, 15e3);
|
|
1439
1393
|
try {
|
|
1440
|
-
const i =
|
|
1394
|
+
const i = await fetch(e, {
|
|
1441
1395
|
method: "POST",
|
|
1442
1396
|
body: t,
|
|
1443
1397
|
keepalive: !0,
|
|
1444
1398
|
credentials: "include",
|
|
1445
1399
|
signal: r.signal,
|
|
1446
1400
|
headers: {
|
|
1447
|
-
"Content-Type": "application/json"
|
|
1448
|
-
...i
|
|
1401
|
+
"Content-Type": "application/json"
|
|
1449
1402
|
}
|
|
1450
1403
|
});
|
|
1451
|
-
if (!
|
|
1452
|
-
throw
|
|
1453
|
-
return
|
|
1404
|
+
if (!i.ok)
|
|
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}`);
|
|
1406
|
+
return i;
|
|
1454
1407
|
} finally {
|
|
1455
1408
|
clearTimeout(n), this.pendingControllers.delete(r);
|
|
1456
1409
|
}
|
|
@@ -1533,7 +1486,7 @@ class xe extends _ {
|
|
|
1533
1486
|
_metadata: {
|
|
1534
1487
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1535
1488
|
timestamp: t,
|
|
1536
|
-
client_version:
|
|
1489
|
+
client_version: Pt
|
|
1537
1490
|
}
|
|
1538
1491
|
};
|
|
1539
1492
|
return {
|
|
@@ -1654,12 +1607,12 @@ class xe extends _ {
|
|
|
1654
1607
|
}
|
|
1655
1608
|
logPermanentError(e, t) {
|
|
1656
1609
|
const r = Date.now();
|
|
1657
|
-
(!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}]` : ""}`, {
|
|
1658
1611
|
data: { status: t.statusCode, message: t.message }
|
|
1659
1612
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1660
1613
|
}
|
|
1661
1614
|
}
|
|
1662
|
-
class
|
|
1615
|
+
class Zt extends _ {
|
|
1663
1616
|
bootTime;
|
|
1664
1617
|
bootTimestamp;
|
|
1665
1618
|
hasPerformanceNow;
|
|
@@ -1808,7 +1761,7 @@ class er extends _ {
|
|
|
1808
1761
|
};
|
|
1809
1762
|
}
|
|
1810
1763
|
}
|
|
1811
|
-
class
|
|
1764
|
+
class er extends _ {
|
|
1812
1765
|
dataSenders;
|
|
1813
1766
|
emitter;
|
|
1814
1767
|
transformers;
|
|
@@ -1840,23 +1793,12 @@ class tr extends _ {
|
|
|
1840
1793
|
* @param storeManager - Storage manager for persistence
|
|
1841
1794
|
* @param emitter - Optional event emitter for local event consumption
|
|
1842
1795
|
* @param transformers - Optional event transformation hooks
|
|
1843
|
-
* @param staticHeaders - Optional static HTTP headers for custom backend (from config)
|
|
1844
|
-
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1845
1796
|
*/
|
|
1846
|
-
constructor(e, t = null, r = {}
|
|
1847
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
e,
|
|
1852
|
-
"custom",
|
|
1853
|
-
o.custom,
|
|
1854
|
-
r,
|
|
1855
|
-
n,
|
|
1856
|
-
i
|
|
1857
|
-
)
|
|
1858
|
-
), this.saveSessionCountsDebounced = this.debounce((l) => {
|
|
1859
|
-
this.saveSessionCounts(l);
|
|
1797
|
+
constructor(e, t = null, r = {}) {
|
|
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) => {
|
|
1801
|
+
this.saveSessionCounts(i);
|
|
1860
1802
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1861
1803
|
}
|
|
1862
1804
|
/**
|
|
@@ -2012,12 +1954,12 @@ class tr extends _ {
|
|
|
2012
1954
|
}
|
|
2013
1955
|
const T = this.getTypeLimitForEvent(E);
|
|
2014
1956
|
if (T) {
|
|
2015
|
-
const
|
|
2016
|
-
if (
|
|
1957
|
+
const ee = this.sessionEventCounts[E];
|
|
1958
|
+
if (ee !== void 0 && ee >= T) {
|
|
2017
1959
|
a("warn", "Session event type limit reached", {
|
|
2018
1960
|
data: {
|
|
2019
1961
|
type: E,
|
|
2020
|
-
count:
|
|
1962
|
+
count: ee,
|
|
2021
1963
|
limit: T
|
|
2022
1964
|
}
|
|
2023
1965
|
});
|
|
@@ -2030,9 +1972,9 @@ class tr extends _ {
|
|
|
2030
1972
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
2031
1973
|
return;
|
|
2032
1974
|
}
|
|
2033
|
-
const
|
|
1975
|
+
const ve = E === d.SESSION_START, $ = t || this.get("pageUrl"), D = this.buildEventPayload({
|
|
2034
1976
|
type: E,
|
|
2035
|
-
page_url:
|
|
1977
|
+
page_url: $,
|
|
2036
1978
|
from_page_url: r,
|
|
2037
1979
|
scroll_data: n,
|
|
2038
1980
|
click_data: i,
|
|
@@ -2042,8 +1984,8 @@ class tr extends _ {
|
|
|
2042
1984
|
viewport_data: u,
|
|
2043
1985
|
page_view: S
|
|
2044
1986
|
});
|
|
2045
|
-
if (
|
|
2046
|
-
if (
|
|
1987
|
+
if (D && !(!p && !this.shouldSample())) {
|
|
1988
|
+
if (ve) {
|
|
2047
1989
|
const T = this.get("sessionId");
|
|
2048
1990
|
if (!T) {
|
|
2049
1991
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2057,8 +1999,8 @@ class tr extends _ {
|
|
|
2057
1999
|
}
|
|
2058
2000
|
this.set("hasStartSession", !0);
|
|
2059
2001
|
}
|
|
2060
|
-
if (!this.isDuplicateEvent(
|
|
2061
|
-
if (this.get("mode") ===
|
|
2002
|
+
if (!this.isDuplicateEvent(D)) {
|
|
2003
|
+
if (this.get("mode") === z.QA) {
|
|
2062
2004
|
if (E === d.CUSTOM && o) {
|
|
2063
2005
|
a("info", `Custom Event: ${o.name}`, {
|
|
2064
2006
|
visibility: "qa",
|
|
@@ -2066,7 +2008,7 @@ class tr extends _ {
|
|
|
2066
2008
|
name: o.name,
|
|
2067
2009
|
...o.metadata && { metadata: o.metadata }
|
|
2068
2010
|
}
|
|
2069
|
-
}), this.emitEvent(
|
|
2011
|
+
}), this.emitEvent(D);
|
|
2070
2012
|
return;
|
|
2071
2013
|
}
|
|
2072
2014
|
if (E === d.VIEWPORT_VISIBLE && u) {
|
|
@@ -2080,11 +2022,11 @@ class tr extends _ {
|
|
|
2080
2022
|
visibilityRatio: u.visibilityRatio,
|
|
2081
2023
|
dwellTime: u.dwellTime
|
|
2082
2024
|
}
|
|
2083
|
-
}), this.emitEvent(
|
|
2025
|
+
}), this.emitEvent(D);
|
|
2084
2026
|
return;
|
|
2085
2027
|
}
|
|
2086
2028
|
}
|
|
2087
|
-
if (this.addToQueue(
|
|
2029
|
+
if (this.addToQueue(D), !p) {
|
|
2088
2030
|
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2089
2031
|
const T = this.get("sessionId");
|
|
2090
2032
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
@@ -2214,23 +2156,6 @@ class tr extends _ {
|
|
|
2214
2156
|
flushImmediatelySync() {
|
|
2215
2157
|
return this.flushEvents(!0);
|
|
2216
2158
|
}
|
|
2217
|
-
/**
|
|
2218
|
-
* Sets the custom headers provider callback for the custom integration.
|
|
2219
|
-
* Only affects requests to custom backend (not TraceLog SaaS).
|
|
2220
|
-
*
|
|
2221
|
-
* @param provider - Callback function that returns custom headers
|
|
2222
|
-
*/
|
|
2223
|
-
setCustomHeadersProvider(e) {
|
|
2224
|
-
for (const t of this.dataSenders)
|
|
2225
|
-
t.getIntegrationId() === "custom" && t.setCustomHeadersProvider(e);
|
|
2226
|
-
}
|
|
2227
|
-
/**
|
|
2228
|
-
* Removes the custom headers provider callback from the custom integration.
|
|
2229
|
-
*/
|
|
2230
|
-
removeCustomHeadersProvider() {
|
|
2231
|
-
for (const e of this.dataSenders)
|
|
2232
|
-
e.getIntegrationId() === "custom" && e.removeCustomHeadersProvider();
|
|
2233
|
-
}
|
|
2234
2159
|
/**
|
|
2235
2160
|
* Returns the current number of events in the main queue.
|
|
2236
2161
|
*
|
|
@@ -2418,7 +2343,7 @@ class tr extends _ {
|
|
|
2418
2343
|
};
|
|
2419
2344
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2420
2345
|
if (!o && l) {
|
|
2421
|
-
const c =
|
|
2346
|
+
const c = Je(n, l, "EventManager");
|
|
2422
2347
|
c !== null && (n = c);
|
|
2423
2348
|
}
|
|
2424
2349
|
return n;
|
|
@@ -2430,7 +2355,7 @@ class tr extends _ {
|
|
|
2430
2355
|
});
|
|
2431
2356
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2432
2357
|
let l = {
|
|
2433
|
-
id:
|
|
2358
|
+
id: Ft(),
|
|
2434
2359
|
type: e.type,
|
|
2435
2360
|
page_url: t,
|
|
2436
2361
|
timestamp: r,
|
|
@@ -2447,10 +2372,10 @@ class tr extends _ {
|
|
|
2447
2372
|
};
|
|
2448
2373
|
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2449
2374
|
if (E && (!g || u && !p)) {
|
|
2450
|
-
const
|
|
2451
|
-
if (
|
|
2375
|
+
const $ = qe(l, E, "EventManager");
|
|
2376
|
+
if ($ === null)
|
|
2452
2377
|
return null;
|
|
2453
|
-
l =
|
|
2378
|
+
l = $;
|
|
2454
2379
|
}
|
|
2455
2380
|
return l;
|
|
2456
2381
|
}
|
|
@@ -2533,10 +2458,10 @@ class tr extends _ {
|
|
|
2533
2458
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2534
2459
|
}
|
|
2535
2460
|
emitEvent(e) {
|
|
2536
|
-
this.emitter && this.emitter.emit(
|
|
2461
|
+
this.emitter && this.emitter.emit(oe.EVENT, e);
|
|
2537
2462
|
}
|
|
2538
2463
|
emitEventsQueue(e) {
|
|
2539
|
-
this.emitter && this.emitter.emit(
|
|
2464
|
+
this.emitter && this.emitter.emit(oe.QUEUE, e);
|
|
2540
2465
|
}
|
|
2541
2466
|
/**
|
|
2542
2467
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2612,13 +2537,13 @@ class tr extends _ {
|
|
|
2612
2537
|
loadSessionCounts(e) {
|
|
2613
2538
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2614
2539
|
return this.getInitialCounts();
|
|
2615
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2540
|
+
const t = this.get("userId") || "anonymous", r = be(t, e);
|
|
2616
2541
|
try {
|
|
2617
2542
|
const n = localStorage.getItem(r);
|
|
2618
2543
|
if (!n)
|
|
2619
2544
|
return this.getInitialCounts();
|
|
2620
2545
|
const i = JSON.parse(n);
|
|
2621
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2546
|
+
return i._timestamp && Date.now() - i._timestamp > Ae ? (a("debug", "Session counts expired, clearing", {
|
|
2622
2547
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2623
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" ? {
|
|
2624
2549
|
total: i.total,
|
|
@@ -2663,12 +2588,12 @@ class tr extends _ {
|
|
|
2663
2588
|
cleanupExpiredSessionCounts() {
|
|
2664
2589
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2665
2590
|
try {
|
|
2666
|
-
const e = localStorage.getItem(
|
|
2591
|
+
const e = localStorage.getItem(Le);
|
|
2667
2592
|
if (e) {
|
|
2668
2593
|
const i = Date.now() - parseInt(e, 10);
|
|
2669
|
-
if (i <
|
|
2594
|
+
if (i < Me) {
|
|
2670
2595
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2671
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2596
|
+
data: { timeSinceLastCleanup: i, throttleMs: Me }
|
|
2672
2597
|
});
|
|
2673
2598
|
return;
|
|
2674
2599
|
}
|
|
@@ -2681,14 +2606,14 @@ class tr extends _ {
|
|
|
2681
2606
|
const l = localStorage.getItem(o);
|
|
2682
2607
|
if (l) {
|
|
2683
2608
|
const c = JSON.parse(l);
|
|
2684
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2609
|
+
c._timestamp && Date.now() - c._timestamp > Ae && n.push(o);
|
|
2685
2610
|
}
|
|
2686
2611
|
} catch {
|
|
2687
2612
|
}
|
|
2688
2613
|
}
|
|
2689
2614
|
n.forEach((i) => {
|
|
2690
2615
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2691
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2616
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Le, Date.now().toString());
|
|
2692
2617
|
} catch (e) {
|
|
2693
2618
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2694
2619
|
}
|
|
@@ -2722,7 +2647,7 @@ class tr extends _ {
|
|
|
2722
2647
|
* @internal
|
|
2723
2648
|
*/
|
|
2724
2649
|
saveSessionCounts(e) {
|
|
2725
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2650
|
+
const t = this.get("userId") || "anonymous", r = be(t, e);
|
|
2726
2651
|
try {
|
|
2727
2652
|
const n = {
|
|
2728
2653
|
...this.sessionEventCounts,
|
|
@@ -2738,7 +2663,7 @@ class tr extends _ {
|
|
|
2738
2663
|
}
|
|
2739
2664
|
}
|
|
2740
2665
|
}
|
|
2741
|
-
class
|
|
2666
|
+
class tr {
|
|
2742
2667
|
/**
|
|
2743
2668
|
* Gets or creates a unique user ID.
|
|
2744
2669
|
*
|
|
@@ -2756,15 +2681,15 @@ class rr {
|
|
|
2756
2681
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2757
2682
|
*/
|
|
2758
2683
|
static getId(e) {
|
|
2759
|
-
const t = e.getItem(
|
|
2684
|
+
const t = e.getItem(Ie);
|
|
2760
2685
|
if (t)
|
|
2761
2686
|
return t;
|
|
2762
|
-
const r =
|
|
2763
|
-
return e.setItem(
|
|
2687
|
+
const r = Ht();
|
|
2688
|
+
return e.setItem(Ie, r), r;
|
|
2764
2689
|
}
|
|
2765
2690
|
}
|
|
2766
|
-
const
|
|
2767
|
-
class
|
|
2691
|
+
const rr = /^\d{13}-[a-z0-9]{9}$/;
|
|
2692
|
+
class sr extends _ {
|
|
2768
2693
|
storageManager;
|
|
2769
2694
|
eventManager;
|
|
2770
2695
|
projectId;
|
|
@@ -2790,7 +2715,7 @@ class nr extends _ {
|
|
|
2790
2715
|
return;
|
|
2791
2716
|
}
|
|
2792
2717
|
const e = this.getProjectId();
|
|
2793
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2718
|
+
this.broadcastChannel = new BroadcastChannel(ht(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2794
2719
|
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2795
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 } }));
|
|
2796
2721
|
};
|
|
@@ -2810,7 +2735,7 @@ class nr extends _ {
|
|
|
2810
2735
|
const e = this.loadStoredSession();
|
|
2811
2736
|
if (!e)
|
|
2812
2737
|
return null;
|
|
2813
|
-
if (!
|
|
2738
|
+
if (!rr.test(e.id))
|
|
2814
2739
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2815
2740
|
data: { sessionId: e.id }
|
|
2816
2741
|
}), this.clearStoredSession(), null;
|
|
@@ -2845,7 +2770,7 @@ class nr extends _ {
|
|
|
2845
2770
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2846
2771
|
}
|
|
2847
2772
|
getSessionStorageKey() {
|
|
2848
|
-
return
|
|
2773
|
+
return dt(this.getProjectId());
|
|
2849
2774
|
}
|
|
2850
2775
|
getProjectId() {
|
|
2851
2776
|
return this.projectId;
|
|
@@ -2910,9 +2835,9 @@ class nr extends _ {
|
|
|
2910
2835
|
let r, n;
|
|
2911
2836
|
if (e) {
|
|
2912
2837
|
const i = this.loadStoredSession();
|
|
2913
|
-
r = i?.referrer ??
|
|
2838
|
+
r = i?.referrer ?? te(), n = i?.utm ?? re();
|
|
2914
2839
|
} else
|
|
2915
|
-
r =
|
|
2840
|
+
r = te(), n = re();
|
|
2916
2841
|
a("debug", "Session tracking initialized", {
|
|
2917
2842
|
data: {
|
|
2918
2843
|
sessionId: t,
|
|
@@ -2963,7 +2888,7 @@ class nr extends _ {
|
|
|
2963
2888
|
*/
|
|
2964
2889
|
renewSession() {
|
|
2965
2890
|
this.needsRenewal = !1;
|
|
2966
|
-
const e = this.generateSessionId(), t =
|
|
2891
|
+
const e = this.generateSessionId(), t = te(), r = re();
|
|
2967
2892
|
a("debug", "Renewing session after timeout", {
|
|
2968
2893
|
data: { newSessionId: e }
|
|
2969
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({
|
|
@@ -3084,7 +3009,7 @@ class nr extends _ {
|
|
|
3084
3009
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3085
3010
|
}
|
|
3086
3011
|
}
|
|
3087
|
-
class
|
|
3012
|
+
class nr extends _ {
|
|
3088
3013
|
eventManager;
|
|
3089
3014
|
storageManager;
|
|
3090
3015
|
sessionManager = null;
|
|
@@ -3119,7 +3044,7 @@ class ir extends _ {
|
|
|
3119
3044
|
}
|
|
3120
3045
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3121
3046
|
try {
|
|
3122
|
-
this.sessionManager = new
|
|
3047
|
+
this.sessionManager = new sr(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3123
3048
|
} catch (r) {
|
|
3124
3049
|
if (this.sessionManager) {
|
|
3125
3050
|
try {
|
|
@@ -3172,7 +3097,7 @@ class ir extends _ {
|
|
|
3172
3097
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3173
3098
|
}
|
|
3174
3099
|
}
|
|
3175
|
-
class
|
|
3100
|
+
class ir extends _ {
|
|
3176
3101
|
eventManager;
|
|
3177
3102
|
onTrack;
|
|
3178
3103
|
originalPushState;
|
|
@@ -3212,7 +3137,7 @@ class or extends _ {
|
|
|
3212
3137
|
};
|
|
3213
3138
|
}
|
|
3214
3139
|
trackCurrentPage = () => {
|
|
3215
|
-
const e = window.location.href, t =
|
|
3140
|
+
const e = window.location.href, t = ue(e, this.get("config").sensitiveQueryParams);
|
|
3216
3141
|
if (this.get("pageUrl") === t)
|
|
3217
3142
|
return;
|
|
3218
3143
|
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3230,7 +3155,7 @@ class or extends _ {
|
|
|
3230
3155
|
});
|
|
3231
3156
|
};
|
|
3232
3157
|
trackInitialPageView() {
|
|
3233
|
-
const e =
|
|
3158
|
+
const e = ue(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3234
3159
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3235
3160
|
type: d.PAGE_VIEW,
|
|
3236
3161
|
page_url: e,
|
|
@@ -3248,7 +3173,7 @@ class or extends _ {
|
|
|
3248
3173
|
};
|
|
3249
3174
|
}
|
|
3250
3175
|
}
|
|
3251
|
-
class
|
|
3176
|
+
class or extends _ {
|
|
3252
3177
|
eventManager;
|
|
3253
3178
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3254
3179
|
clickHandler;
|
|
@@ -3386,7 +3311,7 @@ class ar extends _ {
|
|
|
3386
3311
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3387
3312
|
}
|
|
3388
3313
|
getRelevantClickElement(e) {
|
|
3389
|
-
for (const t of
|
|
3314
|
+
for (const t of ot)
|
|
3390
3315
|
try {
|
|
3391
3316
|
if (e.matches(t))
|
|
3392
3317
|
return e;
|
|
@@ -3466,7 +3391,7 @@ class ar extends _ {
|
|
|
3466
3391
|
*/
|
|
3467
3392
|
sanitizeText(e) {
|
|
3468
3393
|
let t = e;
|
|
3469
|
-
for (const r of
|
|
3394
|
+
for (const r of Xe) {
|
|
3470
3395
|
const n = new RegExp(r.source, r.flags);
|
|
3471
3396
|
t = t.replace(n, "[REDACTED]");
|
|
3472
3397
|
}
|
|
@@ -3505,7 +3430,7 @@ class ar extends _ {
|
|
|
3505
3430
|
};
|
|
3506
3431
|
}
|
|
3507
3432
|
}
|
|
3508
|
-
class
|
|
3433
|
+
class ar extends _ {
|
|
3509
3434
|
eventManager;
|
|
3510
3435
|
containers = [];
|
|
3511
3436
|
limitWarningLogged = !1;
|
|
@@ -3618,7 +3543,7 @@ class lr extends _ {
|
|
|
3618
3543
|
isPrimary: o,
|
|
3619
3544
|
lastScrollPos: n,
|
|
3620
3545
|
lastDepth: i,
|
|
3621
|
-
lastDirection:
|
|
3546
|
+
lastDirection: X.DOWN,
|
|
3622
3547
|
lastEventTime: 0,
|
|
3623
3548
|
firstScrollEventTime: null,
|
|
3624
3549
|
maxDepthReached: i,
|
|
@@ -3677,7 +3602,7 @@ class lr extends _ {
|
|
|
3677
3602
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3678
3603
|
}
|
|
3679
3604
|
getScrollDirection(e, t) {
|
|
3680
|
-
return e > t ?
|
|
3605
|
+
return e > t ? X.DOWN : X.UP;
|
|
3681
3606
|
}
|
|
3682
3607
|
calculateScrollDepth(e, t, r) {
|
|
3683
3608
|
if (t <= r)
|
|
@@ -3733,7 +3658,7 @@ class lr extends _ {
|
|
|
3733
3658
|
e.isPrimary = t;
|
|
3734
3659
|
}
|
|
3735
3660
|
}
|
|
3736
|
-
class
|
|
3661
|
+
class lr extends _ {
|
|
3737
3662
|
eventManager;
|
|
3738
3663
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3739
3664
|
observer = null;
|
|
@@ -3894,7 +3819,7 @@ class cr extends _ {
|
|
|
3894
3819
|
});
|
|
3895
3820
|
}
|
|
3896
3821
|
}
|
|
3897
|
-
class
|
|
3822
|
+
class cr {
|
|
3898
3823
|
storage;
|
|
3899
3824
|
sessionStorageRef;
|
|
3900
3825
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4177,7 +4102,7 @@ class ur {
|
|
|
4177
4102
|
this.fallbackSessionStorage.delete(e);
|
|
4178
4103
|
}
|
|
4179
4104
|
}
|
|
4180
|
-
class
|
|
4105
|
+
class ur extends _ {
|
|
4181
4106
|
eventManager;
|
|
4182
4107
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4183
4108
|
navigationHistory = [];
|
|
@@ -4188,7 +4113,7 @@ class dr extends _ {
|
|
|
4188
4113
|
navigationCounter = 0;
|
|
4189
4114
|
// Counter for handling simultaneous navigations edge case
|
|
4190
4115
|
constructor(e) {
|
|
4191
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4116
|
+
super(), this.eventManager = e, this.vitalThresholds = De(ce);
|
|
4192
4117
|
}
|
|
4193
4118
|
/**
|
|
4194
4119
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4205,8 +4130,8 @@ class dr extends _ {
|
|
|
4205
4130
|
* @returns Promise that resolves when tracking is initialized
|
|
4206
4131
|
*/
|
|
4207
4132
|
async startTracking() {
|
|
4208
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4209
|
-
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();
|
|
4210
4135
|
}
|
|
4211
4136
|
/**
|
|
4212
4137
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4276,7 +4201,7 @@ class dr extends _ {
|
|
|
4276
4201
|
}
|
|
4277
4202
|
async initWebVitals() {
|
|
4278
4203
|
try {
|
|
4279
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4204
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => kr), o = (l) => (c) => {
|
|
4280
4205
|
const u = Number(c.value.toFixed(2));
|
|
4281
4206
|
this.sendVital({ type: l, value: u });
|
|
4282
4207
|
};
|
|
@@ -4303,7 +4228,7 @@ class dr extends _ {
|
|
|
4303
4228
|
const t = e.getEntries();
|
|
4304
4229
|
for (const r of t) {
|
|
4305
4230
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4306
|
-
i - this.lastLongTaskSentAt >=
|
|
4231
|
+
i - this.lastLongTaskSentAt >= Ct && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4307
4232
|
}
|
|
4308
4233
|
},
|
|
4309
4234
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4319,7 +4244,7 @@ class dr extends _ {
|
|
|
4319
4244
|
return;
|
|
4320
4245
|
if (r)
|
|
4321
4246
|
r.add(e.type);
|
|
4322
|
-
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) {
|
|
4323
4248
|
const i = this.navigationHistory.shift();
|
|
4324
4249
|
i && this.reportedByNav.delete(i);
|
|
4325
4250
|
}
|
|
@@ -4410,7 +4335,7 @@ class dr extends _ {
|
|
|
4410
4335
|
return !(typeof r == "number" && t <= r);
|
|
4411
4336
|
}
|
|
4412
4337
|
}
|
|
4413
|
-
class
|
|
4338
|
+
class dr extends _ {
|
|
4414
4339
|
eventManager;
|
|
4415
4340
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4416
4341
|
errorBurstCounter = 0;
|
|
@@ -4446,24 +4371,24 @@ class hr extends _ {
|
|
|
4446
4371
|
const e = Date.now();
|
|
4447
4372
|
if (e < this.burstBackoffUntil)
|
|
4448
4373
|
return !1;
|
|
4449
|
-
if (e - this.burstWindowStart >
|
|
4450
|
-
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", {
|
|
4451
4376
|
data: {
|
|
4452
4377
|
errorsInWindow: this.errorBurstCounter,
|
|
4453
|
-
cooldownMs:
|
|
4378
|
+
cooldownMs: Oe
|
|
4454
4379
|
}
|
|
4455
4380
|
}), !1;
|
|
4456
|
-
const r = this.get("config")?.errorSampling ??
|
|
4381
|
+
const r = this.get("config")?.errorSampling ?? Qe;
|
|
4457
4382
|
return Math.random() < r;
|
|
4458
4383
|
}
|
|
4459
4384
|
handleError = (e) => {
|
|
4460
4385
|
if (!this.shouldSample())
|
|
4461
4386
|
return;
|
|
4462
4387
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4463
|
-
this.shouldSuppressError(
|
|
4388
|
+
this.shouldSuppressError(U.JS_ERROR, t) || this.eventManager.track({
|
|
4464
4389
|
type: d.ERROR,
|
|
4465
4390
|
error_data: {
|
|
4466
|
-
type:
|
|
4391
|
+
type: U.JS_ERROR,
|
|
4467
4392
|
message: t,
|
|
4468
4393
|
...e.filename && { filename: e.filename },
|
|
4469
4394
|
...e.lineno && { line: e.lineno },
|
|
@@ -4475,10 +4400,10 @@ class hr extends _ {
|
|
|
4475
4400
|
if (!this.shouldSample())
|
|
4476
4401
|
return;
|
|
4477
4402
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4478
|
-
this.shouldSuppressError(
|
|
4403
|
+
this.shouldSuppressError(U.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4479
4404
|
type: d.ERROR,
|
|
4480
4405
|
error_data: {
|
|
4481
|
-
type:
|
|
4406
|
+
type: U.PROMISE_REJECTION,
|
|
4482
4407
|
message: r
|
|
4483
4408
|
}
|
|
4484
4409
|
});
|
|
@@ -4497,8 +4422,8 @@ class hr extends _ {
|
|
|
4497
4422
|
}
|
|
4498
4423
|
}
|
|
4499
4424
|
sanitize(e) {
|
|
4500
|
-
let t = e.length >
|
|
4501
|
-
for (const r of
|
|
4425
|
+
let t = e.length > Ce ? e.slice(0, Ce) + "..." : e;
|
|
4426
|
+
for (const r of Xe) {
|
|
4502
4427
|
const n = new RegExp(r.source, r.flags);
|
|
4503
4428
|
t = t.replace(n, "[REDACTED]");
|
|
4504
4429
|
}
|
|
@@ -4506,27 +4431,26 @@ class hr extends _ {
|
|
|
4506
4431
|
}
|
|
4507
4432
|
shouldSuppressError(e, t) {
|
|
4508
4433
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4509
|
-
return i && r - i <
|
|
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));
|
|
4510
4435
|
}
|
|
4511
4436
|
pruneOldErrors() {
|
|
4512
4437
|
const e = Date.now();
|
|
4513
4438
|
for (const [n, i] of this.recentErrors.entries())
|
|
4514
|
-
e - i >
|
|
4515
|
-
if (this.recentErrors.size <=
|
|
4439
|
+
e - i > Ne && this.recentErrors.delete(n);
|
|
4440
|
+
if (this.recentErrors.size <= Q)
|
|
4516
4441
|
return;
|
|
4517
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size -
|
|
4442
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - Q;
|
|
4518
4443
|
for (let n = 0; n < r; n += 1) {
|
|
4519
4444
|
const i = t[n];
|
|
4520
4445
|
i && this.recentErrors.delete(i[0]);
|
|
4521
4446
|
}
|
|
4522
4447
|
}
|
|
4523
4448
|
}
|
|
4524
|
-
class
|
|
4449
|
+
class hr extends _ {
|
|
4525
4450
|
isInitialized = !1;
|
|
4526
4451
|
suppressNextScrollTimer = null;
|
|
4527
|
-
emitter = new
|
|
4452
|
+
emitter = new qt();
|
|
4528
4453
|
transformers = {};
|
|
4529
|
-
customHeadersProvider;
|
|
4530
4454
|
managers = {};
|
|
4531
4455
|
handlers = {};
|
|
4532
4456
|
get initialized() {
|
|
@@ -4541,18 +4465,10 @@ class fr extends _ {
|
|
|
4541
4465
|
*/
|
|
4542
4466
|
async init(e = {}) {
|
|
4543
4467
|
if (!this.isInitialized) {
|
|
4544
|
-
this.managers.storage = new
|
|
4468
|
+
this.managers.storage = new cr();
|
|
4545
4469
|
try {
|
|
4546
|
-
this.setupState(e)
|
|
4547
|
-
|
|
4548
|
-
this.managers.event = new tr(
|
|
4549
|
-
this.managers.storage,
|
|
4550
|
-
this.emitter,
|
|
4551
|
-
this.transformers,
|
|
4552
|
-
t,
|
|
4553
|
-
this.customHeadersProvider
|
|
4554
|
-
), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4555
|
-
a("warn", "Failed to recover persisted events", { error: r });
|
|
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) => {
|
|
4471
|
+
a("warn", "Failed to recover persisted events", { error: t });
|
|
4556
4472
|
}), this.isInitialized = !0;
|
|
4557
4473
|
} catch (t) {
|
|
4558
4474
|
this.destroy(!0);
|
|
@@ -4575,9 +4491,9 @@ class fr extends _ {
|
|
|
4575
4491
|
}
|
|
4576
4492
|
let r = t;
|
|
4577
4493
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4578
|
-
const { valid: n, error: i, sanitizedMetadata: o } =
|
|
4494
|
+
const { valid: n, error: i, sanitizedMetadata: o } = Yt(e, r);
|
|
4579
4495
|
if (!n) {
|
|
4580
|
-
if (this.get("mode") ===
|
|
4496
|
+
if (this.get("mode") === z.QA)
|
|
4581
4497
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4582
4498
|
return;
|
|
4583
4499
|
}
|
|
@@ -4606,27 +4522,6 @@ class fr extends _ {
|
|
|
4606
4522
|
getTransformer(e) {
|
|
4607
4523
|
return this.transformers[e];
|
|
4608
4524
|
}
|
|
4609
|
-
/**
|
|
4610
|
-
* Sets a callback to provide custom HTTP headers for requests to custom backends.
|
|
4611
|
-
* Only applies to custom backend integration (not TraceLog SaaS).
|
|
4612
|
-
*
|
|
4613
|
-
* @param provider - Callback function that returns custom headers
|
|
4614
|
-
* @throws {Error} If provider is not a function
|
|
4615
|
-
* @internal Called from api.setCustomHeaders()
|
|
4616
|
-
*/
|
|
4617
|
-
setCustomHeaders(e) {
|
|
4618
|
-
if (typeof e != "function")
|
|
4619
|
-
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof e}`);
|
|
4620
|
-
this.customHeadersProvider = e, this.managers.event && this.managers.event.setCustomHeadersProvider(e);
|
|
4621
|
-
}
|
|
4622
|
-
/**
|
|
4623
|
-
* Removes the custom headers provider callback.
|
|
4624
|
-
*
|
|
4625
|
-
* @internal Called from api.removeCustomHeaders()
|
|
4626
|
-
*/
|
|
4627
|
-
removeCustomHeaders() {
|
|
4628
|
-
this.customHeadersProvider = void 0, this.managers.event && this.managers.event.removeCustomHeadersProvider();
|
|
4629
|
-
}
|
|
4630
4525
|
/**
|
|
4631
4526
|
* Destroys the TraceLog instance and cleans up all resources.
|
|
4632
4527
|
*
|
|
@@ -4640,18 +4535,18 @@ class fr extends _ {
|
|
|
4640
4535
|
} catch (r) {
|
|
4641
4536
|
a("warn", "Failed to stop tracking", { error: r });
|
|
4642
4537
|
}
|
|
4643
|
-
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.transformers.beforeSend = void 0, this.transformers.beforeBatch = void 0, this.
|
|
4538
|
+
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.transformers.beforeSend = void 0, this.transformers.beforeBatch = void 0, this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
4644
4539
|
}
|
|
4645
4540
|
setupState(e = {}) {
|
|
4646
4541
|
this.set("config", e);
|
|
4647
|
-
const t =
|
|
4542
|
+
const t = tr.getId(this.managers.storage);
|
|
4648
4543
|
this.set("userId", t);
|
|
4649
|
-
const r =
|
|
4544
|
+
const r = Bt(e);
|
|
4650
4545
|
this.set("collectApiUrls", r);
|
|
4651
|
-
const n =
|
|
4546
|
+
const n = yt();
|
|
4652
4547
|
this.set("device", n);
|
|
4653
|
-
const i =
|
|
4654
|
-
this.set("pageUrl", i),
|
|
4548
|
+
const i = ue(window.location.href, e.sensitiveQueryParams);
|
|
4549
|
+
this.set("pageUrl", i), kt() && this.set("mode", z.QA);
|
|
4655
4550
|
}
|
|
4656
4551
|
/**
|
|
4657
4552
|
* Returns the current configuration object.
|
|
@@ -4693,7 +4588,7 @@ class fr extends _ {
|
|
|
4693
4588
|
valid: !1,
|
|
4694
4589
|
error: "Global metadata must be a plain object"
|
|
4695
4590
|
};
|
|
4696
|
-
const t =
|
|
4591
|
+
const t = Ye("Global", e, "globalMetadata");
|
|
4697
4592
|
return t.valid ? { valid: !0 } : {
|
|
4698
4593
|
valid: !1,
|
|
4699
4594
|
error: t.error
|
|
@@ -4738,7 +4633,7 @@ class fr extends _ {
|
|
|
4738
4633
|
}
|
|
4739
4634
|
initializeHandlers() {
|
|
4740
4635
|
const e = this.get("config");
|
|
4741
|
-
this.handlers.session = new
|
|
4636
|
+
this.handlers.session = new nr(
|
|
4742
4637
|
this.managers.storage,
|
|
4743
4638
|
this.managers.event
|
|
4744
4639
|
), this.handlers.session.startTracking();
|
|
@@ -4747,30 +4642,30 @@ class fr extends _ {
|
|
|
4747
4642
|
this.set("suppressNextScroll", !1);
|
|
4748
4643
|
}, 500);
|
|
4749
4644
|
};
|
|
4750
|
-
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) => {
|
|
4751
4646
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4752
|
-
}), 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());
|
|
4753
4648
|
}
|
|
4754
4649
|
}
|
|
4755
|
-
const
|
|
4756
|
-
let
|
|
4757
|
-
const
|
|
4758
|
-
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !
|
|
4759
|
-
|
|
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;
|
|
4760
4655
|
try {
|
|
4761
|
-
const e =
|
|
4656
|
+
const e = jt(s ?? {}), t = new hr();
|
|
4762
4657
|
try {
|
|
4763
|
-
|
|
4658
|
+
C.forEach(({ event: i, callback: o }) => {
|
|
4764
4659
|
t.on(i, o);
|
|
4765
|
-
}),
|
|
4660
|
+
}), C.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4766
4661
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4767
|
-
}), M.length = 0
|
|
4662
|
+
}), M.length = 0;
|
|
4768
4663
|
const r = t.init(e), n = new Promise((i, o) => {
|
|
4769
4664
|
setTimeout(() => {
|
|
4770
4665
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4771
4666
|
}, 1e4);
|
|
4772
4667
|
});
|
|
4773
|
-
await Promise.race([r, n]),
|
|
4668
|
+
await Promise.race([r, n]), f = t;
|
|
4774
4669
|
} catch (r) {
|
|
4775
4670
|
try {
|
|
4776
4671
|
t.destroy(!0);
|
|
@@ -4780,146 +4675,122 @@ const mr = async (s) => {
|
|
|
4780
4675
|
throw r;
|
|
4781
4676
|
}
|
|
4782
4677
|
} catch (e) {
|
|
4783
|
-
throw
|
|
4678
|
+
throw f = null, e;
|
|
4784
4679
|
} finally {
|
|
4785
|
-
|
|
4680
|
+
R = !1;
|
|
4786
4681
|
}
|
|
4787
4682
|
}
|
|
4788
|
-
},
|
|
4683
|
+
}, mr = (s, e) => {
|
|
4789
4684
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4790
|
-
if (!
|
|
4685
|
+
if (!f)
|
|
4791
4686
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4792
4687
|
if (v)
|
|
4793
4688
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4794
|
-
|
|
4689
|
+
f.sendCustomEvent(s, e);
|
|
4795
4690
|
}
|
|
4796
|
-
},
|
|
4691
|
+
}, gr = (s, e) => {
|
|
4797
4692
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4798
|
-
if (!
|
|
4799
|
-
|
|
4693
|
+
if (!f || R) {
|
|
4694
|
+
C.push({ event: s, callback: e });
|
|
4800
4695
|
return;
|
|
4801
4696
|
}
|
|
4802
|
-
|
|
4697
|
+
f.on(s, e);
|
|
4803
4698
|
}
|
|
4804
|
-
},
|
|
4699
|
+
}, Er = (s, e) => {
|
|
4805
4700
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4806
|
-
if (!
|
|
4807
|
-
const t =
|
|
4808
|
-
t !== -1 &&
|
|
4701
|
+
if (!f) {
|
|
4702
|
+
const t = C.findIndex((r) => r.event === s && r.callback === e);
|
|
4703
|
+
t !== -1 && C.splice(t, 1);
|
|
4809
4704
|
return;
|
|
4810
4705
|
}
|
|
4811
|
-
|
|
4706
|
+
f.off(s, e);
|
|
4812
4707
|
}
|
|
4813
4708
|
};
|
|
4814
|
-
function
|
|
4709
|
+
function Sr(s, e) {
|
|
4815
4710
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4816
4711
|
if (typeof e != "function")
|
|
4817
4712
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4818
|
-
if (!
|
|
4713
|
+
if (!f || R) {
|
|
4819
4714
|
const t = M.findIndex((r) => r.hook === s);
|
|
4820
4715
|
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4821
4716
|
return;
|
|
4822
4717
|
}
|
|
4823
4718
|
if (v)
|
|
4824
4719
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4825
|
-
s === "beforeSend" ?
|
|
4720
|
+
s === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4826
4721
|
}
|
|
4827
4722
|
}
|
|
4828
|
-
const
|
|
4723
|
+
const pr = (s) => {
|
|
4829
4724
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4830
|
-
if (!
|
|
4725
|
+
if (!f) {
|
|
4831
4726
|
const e = M.findIndex((t) => t.hook === s);
|
|
4832
4727
|
e !== -1 && M.splice(e, 1);
|
|
4833
4728
|
return;
|
|
4834
4729
|
}
|
|
4835
4730
|
if (v)
|
|
4836
4731
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4837
|
-
|
|
4838
|
-
}
|
|
4839
|
-
}, vr = (s) => {
|
|
4840
|
-
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4841
|
-
if (typeof s != "function")
|
|
4842
|
-
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof s}`);
|
|
4843
|
-
if (!h || C) {
|
|
4844
|
-
R = s;
|
|
4845
|
-
return;
|
|
4846
|
-
}
|
|
4847
|
-
if (v)
|
|
4848
|
-
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
4849
|
-
h.setCustomHeaders(s);
|
|
4850
|
-
}
|
|
4851
|
-
}, _r = () => {
|
|
4852
|
-
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4853
|
-
if (!h) {
|
|
4854
|
-
R = null;
|
|
4855
|
-
return;
|
|
4856
|
-
}
|
|
4857
|
-
if (v)
|
|
4858
|
-
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
4859
|
-
h.removeCustomHeaders();
|
|
4732
|
+
f.removeTransformer(s);
|
|
4860
4733
|
}
|
|
4861
|
-
},
|
|
4734
|
+
}, Tr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, _r = () => {
|
|
4862
4735
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4863
4736
|
if (v)
|
|
4864
4737
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
4865
|
-
if (!
|
|
4738
|
+
if (!f) {
|
|
4866
4739
|
v = !1;
|
|
4867
4740
|
return;
|
|
4868
4741
|
}
|
|
4869
4742
|
v = !0;
|
|
4870
4743
|
try {
|
|
4871
|
-
|
|
4744
|
+
f.destroy(), f = null, R = !1, C.length = 0, M.length = 0, v = !1;
|
|
4872
4745
|
} catch (s) {
|
|
4873
|
-
|
|
4746
|
+
f = null, R = !1, C.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4874
4747
|
}
|
|
4875
4748
|
}
|
|
4876
|
-
},
|
|
4877
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4878
|
-
},
|
|
4749
|
+
}, vr = (s) => {
|
|
4750
|
+
typeof window > "u" || typeof document > "u" || Vt(s);
|
|
4751
|
+
}, Ir = (s) => {
|
|
4879
4752
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4880
|
-
if (!
|
|
4753
|
+
if (!f)
|
|
4881
4754
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4882
4755
|
if (v)
|
|
4883
4756
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4884
|
-
|
|
4757
|
+
f.updateGlobalMetadata(s);
|
|
4885
4758
|
}
|
|
4886
|
-
},
|
|
4759
|
+
}, wr = (s) => {
|
|
4887
4760
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4888
|
-
if (!
|
|
4761
|
+
if (!f)
|
|
4889
4762
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4890
4763
|
if (v)
|
|
4891
4764
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4892
|
-
|
|
4893
|
-
}
|
|
4894
|
-
},
|
|
4895
|
-
init:
|
|
4896
|
-
event:
|
|
4897
|
-
on:
|
|
4898
|
-
off:
|
|
4899
|
-
setTransformer:
|
|
4900
|
-
removeTransformer:
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
updateGlobalMetadata: br,
|
|
4907
|
-
mergeGlobalMetadata: Ar
|
|
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
|
|
4908
4779
|
};
|
|
4909
|
-
var
|
|
4780
|
+
var he, Ze = -1, P = function(s) {
|
|
4910
4781
|
addEventListener("pageshow", (function(e) {
|
|
4911
|
-
e.persisted && (
|
|
4782
|
+
e.persisted && (Ze = e.timeStamp, s(e));
|
|
4912
4783
|
}), !0);
|
|
4913
|
-
},
|
|
4784
|
+
}, pe = function() {
|
|
4914
4785
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4915
4786
|
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4916
|
-
},
|
|
4917
|
-
var s =
|
|
4787
|
+
}, q = function() {
|
|
4788
|
+
var s = pe();
|
|
4918
4789
|
return s && s.activationStart || 0;
|
|
4919
4790
|
}, b = function(s, e) {
|
|
4920
|
-
var t =
|
|
4921
|
-
return
|
|
4922
|
-
},
|
|
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) {
|
|
4923
4794
|
try {
|
|
4924
4795
|
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4925
4796
|
var r = new PerformanceObserver((function(n) {
|
|
@@ -4938,13 +4809,13 @@ var fe, et = -1, D = function(s) {
|
|
|
4938
4809
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4939
4810
|
})(e.value, t), s(e));
|
|
4940
4811
|
};
|
|
4941
|
-
},
|
|
4812
|
+
}, Te = function(s) {
|
|
4942
4813
|
requestAnimationFrame((function() {
|
|
4943
4814
|
return requestAnimationFrame((function() {
|
|
4944
4815
|
return s();
|
|
4945
4816
|
}));
|
|
4946
4817
|
}));
|
|
4947
|
-
},
|
|
4818
|
+
}, J = function(s) {
|
|
4948
4819
|
document.addEventListener("visibilitychange", (function() {
|
|
4949
4820
|
document.visibilityState === "hidden" && s();
|
|
4950
4821
|
}));
|
|
@@ -4953,41 +4824,41 @@ var fe, et = -1, D = function(s) {
|
|
|
4953
4824
|
return function() {
|
|
4954
4825
|
e || (s(), e = !0);
|
|
4955
4826
|
};
|
|
4956
|
-
},
|
|
4827
|
+
}, O = -1, He = function() {
|
|
4957
4828
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4958
|
-
},
|
|
4959
|
-
document.visibilityState === "hidden" &&
|
|
4960
|
-
},
|
|
4961
|
-
addEventListener("visibilitychange",
|
|
4962
|
-
},
|
|
4963
|
-
removeEventListener("visibilitychange",
|
|
4964
|
-
},
|
|
4965
|
-
return
|
|
4829
|
+
}, Y = function(s) {
|
|
4830
|
+
document.visibilityState === "hidden" && O > -1 && (O = s.type === "visibilitychange" ? s.timeStamp : 0, yr());
|
|
4831
|
+
}, Fe = function() {
|
|
4832
|
+
addEventListener("visibilitychange", Y, !0), addEventListener("prerenderingchange", Y, !0);
|
|
4833
|
+
}, yr = function() {
|
|
4834
|
+
removeEventListener("visibilitychange", Y, !0), removeEventListener("prerenderingchange", Y, !0);
|
|
4835
|
+
}, et = function() {
|
|
4836
|
+
return O < 0 && (O = He(), Fe(), P((function() {
|
|
4966
4837
|
setTimeout((function() {
|
|
4967
|
-
|
|
4838
|
+
O = He(), Fe();
|
|
4968
4839
|
}), 0);
|
|
4969
4840
|
}))), { get firstHiddenTime() {
|
|
4970
|
-
return
|
|
4841
|
+
return O;
|
|
4971
4842
|
} };
|
|
4972
|
-
},
|
|
4843
|
+
}, Z = function(s) {
|
|
4973
4844
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4974
4845
|
return s();
|
|
4975
4846
|
}), !0) : s();
|
|
4976
|
-
},
|
|
4977
|
-
e = e || {},
|
|
4978
|
-
var t, r =
|
|
4847
|
+
}, fe = [1800, 3e3], tt = function(s, e) {
|
|
4848
|
+
e = e || {}, Z((function() {
|
|
4849
|
+
var t, r = et(), n = b("FCP"), i = F("paint", (function(o) {
|
|
4979
4850
|
o.forEach((function(l) {
|
|
4980
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime -
|
|
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)));
|
|
4981
4852
|
}));
|
|
4982
4853
|
}));
|
|
4983
|
-
i && (t = A(s, n,
|
|
4984
|
-
n = b("FCP"), t = A(s, n,
|
|
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() {
|
|
4985
4856
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4986
4857
|
}));
|
|
4987
4858
|
})));
|
|
4988
4859
|
}));
|
|
4989
|
-
},
|
|
4990
|
-
e = e || {},
|
|
4860
|
+
}, me = [0.1, 0.25], br = function(s, e) {
|
|
4861
|
+
e = e || {}, tt(_e((function() {
|
|
4991
4862
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4992
4863
|
c.forEach((function(u) {
|
|
4993
4864
|
if (!u.hadRecentInput) {
|
|
@@ -4995,148 +4866,148 @@ var fe, et = -1, D = function(s) {
|
|
|
4995
4866
|
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
4996
4867
|
}
|
|
4997
4868
|
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4998
|
-
}, l =
|
|
4999
|
-
l && (t = A(s, r,
|
|
4869
|
+
}, l = F("layout-shift", o);
|
|
4870
|
+
l && (t = A(s, r, me, e.reportAllChanges), J((function() {
|
|
5000
4871
|
o(l.takeRecords()), t(!0);
|
|
5001
|
-
})),
|
|
5002
|
-
n = 0, r = b("CLS", 0), t = A(s, r,
|
|
4872
|
+
})), P((function() {
|
|
4873
|
+
n = 0, r = b("CLS", 0), t = A(s, r, me, e.reportAllChanges), Te((function() {
|
|
5003
4874
|
return t();
|
|
5004
4875
|
}));
|
|
5005
4876
|
})), setTimeout(t, 0));
|
|
5006
4877
|
})));
|
|
5007
|
-
},
|
|
4878
|
+
}, rt = 0, ne = 1 / 0, G = 0, Ar = function(s) {
|
|
5008
4879
|
s.forEach((function(e) {
|
|
5009
|
-
e.interactionId && (
|
|
4880
|
+
e.interactionId && (ne = Math.min(ne, e.interactionId), G = Math.max(G, e.interactionId), rt = G ? (G - ne) / 7 + 1 : 0);
|
|
5010
4881
|
}));
|
|
5011
|
-
},
|
|
5012
|
-
return
|
|
5013
|
-
},
|
|
5014
|
-
"interactionCount" in performance ||
|
|
5015
|
-
}, y = [],
|
|
5016
|
-
var s = Math.min(y.length - 1, Math.floor((
|
|
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));
|
|
5017
4888
|
return y[s];
|
|
5018
|
-
},
|
|
5019
|
-
if (
|
|
4889
|
+
}, Rr = [], Cr = function(s) {
|
|
4890
|
+
if (Rr.forEach((function(n) {
|
|
5020
4891
|
return n(s);
|
|
5021
4892
|
})), s.interactionId || s.entryType === "first-input") {
|
|
5022
|
-
var e = y[y.length - 1], t =
|
|
4893
|
+
var e = y[y.length - 1], t = j.get(s.interactionId);
|
|
5023
4894
|
if (t || y.length < 10 || s.duration > e.latency) {
|
|
5024
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);
|
|
5025
4896
|
else {
|
|
5026
4897
|
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
5027
|
-
|
|
4898
|
+
j.set(r.id, r), y.push(r);
|
|
5028
4899
|
}
|
|
5029
4900
|
y.sort((function(n, i) {
|
|
5030
4901
|
return i.latency - n.latency;
|
|
5031
4902
|
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
5032
|
-
return
|
|
4903
|
+
return j.delete(n.id);
|
|
5033
4904
|
}));
|
|
5034
4905
|
}
|
|
5035
4906
|
}
|
|
5036
|
-
},
|
|
4907
|
+
}, it = function(s) {
|
|
5037
4908
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5038
|
-
return s = _e(s), document.visibilityState === "hidden" ? s() : (t = e(s),
|
|
5039
|
-
},
|
|
5040
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
4909
|
+
return s = _e(s), document.visibilityState === "hidden" ? s() : (t = e(s), J(s)), t;
|
|
4910
|
+
}, ge = [200, 500], Nr = function(s, e) {
|
|
4911
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
5041
4912
|
var t;
|
|
5042
|
-
|
|
4913
|
+
Lr();
|
|
5043
4914
|
var r, n = b("INP"), i = function(l) {
|
|
5044
|
-
|
|
5045
|
-
l.forEach(
|
|
5046
|
-
var c =
|
|
4915
|
+
it((function() {
|
|
4916
|
+
l.forEach(Cr);
|
|
4917
|
+
var c = Mr();
|
|
5047
4918
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
5048
4919
|
}));
|
|
5049
|
-
}, o =
|
|
5050
|
-
r = A(s, n,
|
|
4920
|
+
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4921
|
+
r = A(s, n, ge, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
5051
4922
|
i(o.takeRecords()), r(!0);
|
|
5052
|
-
})),
|
|
5053
|
-
|
|
4923
|
+
})), P((function() {
|
|
4924
|
+
nt = st(), y.length = 0, j.clear(), n = b("INP"), r = A(s, n, ge, e.reportAllChanges);
|
|
5054
4925
|
})));
|
|
5055
4926
|
})));
|
|
5056
|
-
},
|
|
5057
|
-
e = e || {},
|
|
5058
|
-
var t, r =
|
|
4927
|
+
}, Ee = [2500, 4e3], ie = {}, Or = function(s, e) {
|
|
4928
|
+
e = e || {}, Z((function() {
|
|
4929
|
+
var t, r = et(), n = b("LCP"), i = function(c) {
|
|
5059
4930
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
5060
|
-
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime -
|
|
4931
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - q(), 0), n.entries = [u], t());
|
|
5061
4932
|
}));
|
|
5062
|
-
}, o =
|
|
4933
|
+
}, o = F("largest-contentful-paint", i);
|
|
5063
4934
|
if (o) {
|
|
5064
|
-
t = A(s, n,
|
|
4935
|
+
t = A(s, n, Ee, e.reportAllChanges);
|
|
5065
4936
|
var l = _e((function() {
|
|
5066
|
-
|
|
4937
|
+
ie[n.id] || (i(o.takeRecords()), o.disconnect(), ie[n.id] = !0, t(!0));
|
|
5067
4938
|
}));
|
|
5068
4939
|
["keydown", "click"].forEach((function(c) {
|
|
5069
4940
|
addEventListener(c, (function() {
|
|
5070
|
-
return
|
|
4941
|
+
return it(l);
|
|
5071
4942
|
}), { once: !0, capture: !0 });
|
|
5072
|
-
})),
|
|
5073
|
-
n = b("LCP"), t = A(s, n,
|
|
5074
|
-
n.value = performance.now() - c.timeStamp,
|
|
4943
|
+
})), J(l), P((function(c) {
|
|
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);
|
|
5075
4946
|
}));
|
|
5076
4947
|
}));
|
|
5077
4948
|
}
|
|
5078
4949
|
}));
|
|
5079
|
-
},
|
|
5080
|
-
document.prerendering ?
|
|
4950
|
+
}, Se = [800, 1800], Pr = function s(e) {
|
|
4951
|
+
document.prerendering ? Z((function() {
|
|
5081
4952
|
return s(e);
|
|
5082
4953
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5083
4954
|
return s(e);
|
|
5084
4955
|
}), !0) : setTimeout(e, 0);
|
|
5085
|
-
},
|
|
4956
|
+
}, Dr = function(s, e) {
|
|
5086
4957
|
e = e || {};
|
|
5087
|
-
var t = b("TTFB"), r = A(s, t,
|
|
5088
|
-
|
|
5089
|
-
var n =
|
|
5090
|
-
n && (t.value = Math.max(n.responseStart -
|
|
5091
|
-
t = b("TTFB", 0), (r = A(s, t,
|
|
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);
|
|
5092
4963
|
})));
|
|
5093
4964
|
}));
|
|
5094
4965
|
};
|
|
5095
|
-
const
|
|
4966
|
+
const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5096
4967
|
__proto__: null,
|
|
5097
|
-
CLSThresholds:
|
|
5098
|
-
FCPThresholds:
|
|
5099
|
-
INPThresholds:
|
|
5100
|
-
LCPThresholds:
|
|
5101
|
-
TTFBThresholds:
|
|
5102
|
-
onCLS:
|
|
5103
|
-
onFCP:
|
|
5104
|
-
onINP:
|
|
5105
|
-
onLCP:
|
|
5106
|
-
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
|
|
5107
4978
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5108
4979
|
export {
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
4980
|
+
h as AppConfigValidationError,
|
|
4981
|
+
Vr as DEFAULT_SESSION_TIMEOUT,
|
|
4982
|
+
ce as DEFAULT_WEB_VITALS_MODE,
|
|
5112
4983
|
L as DeviceType,
|
|
5113
|
-
|
|
5114
|
-
|
|
4984
|
+
oe as EmitterEvent,
|
|
4985
|
+
U as ErrorType,
|
|
5115
4986
|
d as EventType,
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
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,
|
|
4998
|
+
z as Mode,
|
|
4999
|
+
Xe as PII_PATTERNS,
|
|
5000
|
+
N as PermanentError,
|
|
5130
5001
|
Re as SamplingRateValidationError,
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5002
|
+
X as ScrollDirection,
|
|
5003
|
+
ft as SessionTimeoutValidationError,
|
|
5004
|
+
V as SpecialApiUrl,
|
|
5005
|
+
H as TraceLogValidationError,
|
|
5006
|
+
Kr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5007
|
+
Pe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5137
5008
|
Rt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5009
|
+
De as getWebVitalsThresholds,
|
|
5010
|
+
Qr as isPrimaryScrollEvent,
|
|
5011
|
+
jr as isSecondaryScrollEvent,
|
|
5012
|
+
Yr as tracelog
|
|
5142
5013
|
};
|