@tracelog/lib 2.3.0 → 2.3.1-rc.84.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.esm.js +444 -433
- 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 +2 -6711
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +4 -3
- package/dist/public-api.d.ts +4 -3
- package/dist/public-api.js +2 -6678
- 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 Br = 9e5;
|
|
2
|
+
const Wr = 120, Gr = 8192, Xr = 10, Qr = 10, jr = 20;
|
|
3
|
+
const zr = 1e3, Kr = 500, Yr = 100;
|
|
4
|
+
const w = "data-tlog", lt = [
|
|
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
|
+
], ct = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], ut = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,22 +71,22 @@ const m = {
|
|
|
71
71
|
INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
},
|
|
74
|
+
}, dt = [
|
|
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
|
-
], _ = "tlog",
|
|
82
|
-
var
|
|
83
|
-
class
|
|
81
|
+
], _ = "tlog", $ = `${_}:qa_mode`, be = `${_}:uid`, Ge = "tlog_mode", Le = "qa", Ae = "qa_off", ht = (s) => s ? `${_}:${s}:queue` : `${_}:queue`, ft = (s) => s ? `${_}:${s}:session` : `${_}:session`, mt = (s) => s ? `${_}:${s}:broadcast` : `${_}:broadcast`, Me = (s, e) => `${_}:${s}:session_counts:${e}`, Ce = 10080 * 60 * 1e3, Re = `${_}:session_counts_last_cleanup`, Ne = 3600 * 1e3;
|
|
82
|
+
var H = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(H || {}), A = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(A || {}), le = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(le || {});
|
|
83
|
+
class P 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, P);
|
|
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
|
|
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 || {}), j = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(j || {}), x = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(x || {}), Y = /* @__PURE__ */ ((s) => (s.QA = "qa", s))(Y || {});
|
|
89
|
+
const qr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !0, Jr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !1;
|
|
90
90
|
class F extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -97,27 +97,27 @@ class f extends F {
|
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class gt extends F {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class Oe extends F {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
class
|
|
110
|
+
class U extends F {
|
|
111
111
|
constructor(e, t = "config") {
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class Zr extends F {
|
|
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 Xe = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Qe = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Et = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", St = (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,24 +136,24 @@ const Ge = "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
|
+
}, pt = () => {
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
142
142
|
try {
|
|
143
|
-
return sessionStorage.getItem(
|
|
143
|
+
return sessionStorage.getItem($) === "true";
|
|
144
144
|
} catch {
|
|
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 ? St(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
|
|
149
|
+
if (!Tt(l, i))
|
|
150
150
|
return;
|
|
151
|
-
const g =
|
|
152
|
-
|
|
153
|
-
},
|
|
151
|
+
const g = vt(l, o), p = n !== void 0 ? ce(n) : void 0;
|
|
152
|
+
It(u, c, g, p);
|
|
153
|
+
}, Tt = (s, e) => s === "critical" ? !0 : s === "qa" || e ? pt() : !1, vt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? Et : "", It = (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
|
+
}, ce = (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 Ge = "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] = ce(n) : Array.isArray(n) ? e[r] = n.map(
|
|
165
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ce(o) : o
|
|
166
166
|
) : e[r] = n;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let
|
|
171
|
-
const
|
|
172
|
-
typeof window < "u" && !
|
|
173
|
-
},
|
|
170
|
+
let ue, je;
|
|
171
|
+
const _t = () => {
|
|
172
|
+
typeof window < "u" && !ue && (ue = window.matchMedia("(pointer: coarse)"), je = window.matchMedia("(hover: none)"));
|
|
173
|
+
}, q = "Unknown", wt = (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 It = () => {
|
|
|
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" : q;
|
|
185
|
+
}, yt = (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,36 +192,36 @@ const It = () => {
|
|
|
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" : q;
|
|
196
|
+
}, bt = () => {
|
|
197
197
|
try {
|
|
198
198
|
const s = navigator;
|
|
199
199
|
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
200
200
|
const c = s.userAgentData.platform;
|
|
201
201
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? A.Tablet : s.userAgentData.mobile ? A.Mobile : A.Desktop;
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
const e = window.innerWidth, t =
|
|
203
|
+
_t();
|
|
204
|
+
const e = window.innerWidth, t = ue?.matches ?? !1, r = je?.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 ? A.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? A.Tablet : A.Desktop;
|
|
206
206
|
} catch (s) {
|
|
207
207
|
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), A.Desktop;
|
|
208
208
|
}
|
|
209
|
-
},
|
|
209
|
+
}, Lt = () => {
|
|
210
210
|
try {
|
|
211
211
|
const s = navigator;
|
|
212
212
|
return {
|
|
213
|
-
type:
|
|
214
|
-
os:
|
|
215
|
-
browser:
|
|
213
|
+
type: bt(),
|
|
214
|
+
os: wt(s),
|
|
215
|
+
browser: yt(s)
|
|
216
216
|
};
|
|
217
217
|
} catch (s) {
|
|
218
218
|
return a("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
219
219
|
type: A.Desktop,
|
|
220
|
-
os:
|
|
221
|
-
browser:
|
|
220
|
+
os: q,
|
|
221
|
+
browser: q
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
},
|
|
224
|
+
}, ze = [
|
|
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 It = () => {
|
|
|
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
|
+
], Pe = 500, De = 5e3, z = 50, At = z * 2, Ke = 1, Mt = 1e3, Ct = 10, ke = 5e3, Rt = 6e4, es = {
|
|
240
240
|
LCP: 2500,
|
|
241
241
|
// Good: ≤ 2.5s
|
|
242
242
|
FCP: 1800,
|
|
@@ -248,7 +248,7 @@ const It = () => {
|
|
|
248
248
|
TTFB: 800,
|
|
249
249
|
// Good: ≤ 800ms
|
|
250
250
|
LONG_TASK: 50
|
|
251
|
-
},
|
|
251
|
+
}, Ve = {
|
|
252
252
|
LCP: 2500,
|
|
253
253
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
254
254
|
FCP: 1800,
|
|
@@ -260,7 +260,7 @@ const It = () => {
|
|
|
260
260
|
TTFB: 800,
|
|
261
261
|
// Needs improvement: > 800ms
|
|
262
262
|
LONG_TASK: 50
|
|
263
|
-
},
|
|
263
|
+
}, Nt = {
|
|
264
264
|
LCP: 4e3,
|
|
265
265
|
// Poor: > 4s
|
|
266
266
|
FCP: 3e3,
|
|
@@ -272,53 +272,53 @@ const It = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
},
|
|
275
|
+
}, de = "needs-improvement", Ue = (s = de) => {
|
|
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 Ve;
|
|
282
282
|
case "poor":
|
|
283
|
-
return
|
|
283
|
+
return Nt;
|
|
284
284
|
default:
|
|
285
|
-
return
|
|
285
|
+
return Ve;
|
|
286
286
|
}
|
|
287
|
-
},
|
|
287
|
+
}, Ot = 1e3, Pt = 50, Dt = "2.3.1", kt = Dt, Ye = () => typeof window < "u" && typeof sessionStorage < "u", Vt = () => {
|
|
288
288
|
try {
|
|
289
289
|
const s = new URLSearchParams(window.location.search);
|
|
290
|
-
s.delete(
|
|
290
|
+
s.delete(Ge);
|
|
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
|
+
}, Ut = () => {
|
|
296
|
+
if (!Ye())
|
|
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(Ge), t = sessionStorage.getItem($);
|
|
300
300
|
let r = null;
|
|
301
|
-
return e ===
|
|
302
|
-
visibility: "qa",
|
|
303
|
-
style: Ge
|
|
304
|
-
})) : e === Le && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
301
|
+
return e === Le ? (r = !0, sessionStorage.setItem($, "true"), a("info", "QA Mode ACTIVE", {
|
|
305
302
|
visibility: "qa",
|
|
306
303
|
style: Xe
|
|
307
|
-
}))
|
|
304
|
+
})) : e === Ae && (r = !1, sessionStorage.setItem($, "false"), a("info", "QA Mode DISABLED", {
|
|
305
|
+
visibility: "qa",
|
|
306
|
+
style: Qe
|
|
307
|
+
})), (e === Le || e === Ae) && Vt(), r ?? t === "true";
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
312
|
-
if (
|
|
311
|
+
}, Ht = (s) => {
|
|
312
|
+
if (Ye())
|
|
313
313
|
try {
|
|
314
|
-
sessionStorage.setItem(
|
|
314
|
+
sessionStorage.setItem($, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
|
-
style: s ?
|
|
316
|
+
style: s ? Xe : Qe
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
|
-
},
|
|
321
|
+
}, xt = [
|
|
322
322
|
"co.uk",
|
|
323
323
|
"org.uk",
|
|
324
324
|
"com.au",
|
|
@@ -330,25 +330,25 @@ const It = () => {
|
|
|
330
330
|
"co.in",
|
|
331
331
|
"com.cn",
|
|
332
332
|
"co.za"
|
|
333
|
-
],
|
|
333
|
+
], He = (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
|
-
},
|
|
338
|
+
return xt.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
339
|
+
}, $t = (s, e) => s === e ? !0 : He(s) === He(e), se = () => {
|
|
340
340
|
const s = document.referrer;
|
|
341
341
|
if (!s)
|
|
342
342
|
return "Direct";
|
|
343
343
|
try {
|
|
344
344
|
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
345
|
-
return
|
|
345
|
+
return $t(e, t) ? "Direct" : s;
|
|
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
|
+
}, ne = () => {
|
|
350
350
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
351
|
-
return
|
|
351
|
+
return ct.forEach((r) => {
|
|
352
352
|
const n = s.get(r);
|
|
353
353
|
if (n) {
|
|
354
354
|
const i = r.split("utm_")[1];
|
|
@@ -359,11 +359,11 @@ const It = () => {
|
|
|
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 G = 0, X = 0;
|
|
363
|
+
const Bt = () => {
|
|
364
364
|
let s = Date.now();
|
|
365
|
-
s <
|
|
366
|
-
const e =
|
|
365
|
+
s < X && (s = X), s === X ? G = (G + 1) % 1e3 : G = 0, X = s;
|
|
366
|
+
const e = G.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
|
+
}, qe = (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
|
+
}, Wt = (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 (!qe(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
|
+
}, Gt = (s) => {
|
|
408
408
|
const e = {};
|
|
409
|
-
s.integrations?.tracelog?.projectId && (e.saas =
|
|
409
|
+
s.integrations?.tracelog?.projectId && (e.saas = Wt(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 (!qe(t, r))
|
|
414
414
|
throw new Error("Invalid custom API URL");
|
|
415
415
|
e.custom = t;
|
|
416
416
|
}
|
|
417
417
|
return e;
|
|
418
|
-
},
|
|
418
|
+
}, he = (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([...ut, ...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
|
+
}, xe = (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 dt) {
|
|
438
438
|
const i = e;
|
|
439
439
|
e = e.replace(n, ""), i !== e && t++;
|
|
440
440
|
}
|
|
@@ -444,11 +444,11 @@ const $t = () => {
|
|
|
444
444
|
valueLength: s.length
|
|
445
445
|
}
|
|
446
446
|
}), e.trim();
|
|
447
|
-
},
|
|
447
|
+
}, fe = (s, e = 0) => {
|
|
448
448
|
if (s == null)
|
|
449
449
|
return null;
|
|
450
450
|
if (typeof s == "string")
|
|
451
|
-
return
|
|
451
|
+
return xe(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")
|
|
@@ -456,38 +456,38 @@ const $t = () => {
|
|
|
456
456
|
if (e > 10)
|
|
457
457
|
return null;
|
|
458
458
|
if (Array.isArray(s))
|
|
459
|
-
return s.slice(0, 100).map((n) =>
|
|
459
|
+
return s.slice(0, 100).map((n) => fe(n, e + 1)).filter((n) => n !== null);
|
|
460
460
|
if (typeof s == "object") {
|
|
461
461
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
462
462
|
for (const [i, o] of n) {
|
|
463
|
-
const l =
|
|
463
|
+
const l = xe(i);
|
|
464
464
|
if (l) {
|
|
465
|
-
const c =
|
|
465
|
+
const c = fe(o, e + 1);
|
|
466
466
|
c !== null && (t[l] = c);
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
return t;
|
|
470
470
|
}
|
|
471
471
|
return null;
|
|
472
|
-
},
|
|
472
|
+
}, Xt = (s) => {
|
|
473
473
|
if (typeof s != "object" || s === null)
|
|
474
474
|
return {};
|
|
475
475
|
try {
|
|
476
|
-
const e =
|
|
476
|
+
const e = fe(s);
|
|
477
477
|
return typeof e == "object" && e !== null ? e : {};
|
|
478
478
|
} catch (e) {
|
|
479
479
|
const t = e instanceof Error ? e.message : String(e);
|
|
480
480
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
481
481
|
}
|
|
482
|
-
},
|
|
482
|
+
}, Qt = (s) => {
|
|
483
483
|
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
484
484
|
throw new f("Configuration must be an object", "config");
|
|
485
485
|
if (s) {
|
|
486
486
|
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
487
|
-
throw new
|
|
487
|
+
throw new gt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
488
488
|
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
489
489
|
throw new f(m.INVALID_GLOBAL_METADATA, "config");
|
|
490
|
-
if (s.integrations &&
|
|
490
|
+
if (s.integrations && zt(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
491
491
|
if (!Array.isArray(s.sensitiveQueryParams))
|
|
492
492
|
throw new f(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
493
493
|
for (const e of s.sensitiveQueryParams)
|
|
@@ -495,9 +495,9 @@ const $t = () => {
|
|
|
495
495
|
throw new f("All sensitive query params must be strings", "config");
|
|
496
496
|
}
|
|
497
497
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
498
|
-
throw new
|
|
498
|
+
throw new Oe(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
499
499
|
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
500
|
-
throw new
|
|
500
|
+
throw new Oe(m.INVALID_SAMPLING_RATE, "config");
|
|
501
501
|
if (s.primaryScrollSelector !== void 0) {
|
|
502
502
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
503
503
|
throw new f(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -517,7 +517,7 @@ const $t = () => {
|
|
|
517
517
|
throw new f(m.INVALID_CLICK_THROTTLE, "config");
|
|
518
518
|
if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
|
|
519
519
|
throw new f(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
520
|
-
if (s.viewport !== void 0 &&
|
|
520
|
+
if (s.viewport !== void 0 && jt(s.viewport), s.webVitalsMode !== void 0) {
|
|
521
521
|
if (typeof s.webVitalsMode != "string")
|
|
522
522
|
throw new f(
|
|
523
523
|
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
@@ -548,7 +548,7 @@ const $t = () => {
|
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
},
|
|
551
|
+
}, jt = (s) => {
|
|
552
552
|
if (typeof s != "object" || s === null)
|
|
553
553
|
throw new f(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
554
554
|
if (!s.elements || !Array.isArray(s.elements))
|
|
@@ -578,33 +578,33 @@ const $t = () => {
|
|
|
578
578
|
throw new f(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
579
579
|
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
580
580
|
throw new f(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
581
|
-
},
|
|
581
|
+
}, zt = (s) => {
|
|
582
582
|
if (s) {
|
|
583
583
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
584
|
-
throw new
|
|
584
|
+
throw new U(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
585
585
|
if (s.custom) {
|
|
586
586
|
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
587
|
-
throw new
|
|
587
|
+
throw new U(m.INVALID_CUSTOM_API_URL, "config");
|
|
588
588
|
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
589
|
-
throw new
|
|
589
|
+
throw new U("allowHttp must be a boolean", "config");
|
|
590
590
|
const e = s.custom.collectApiUrl.trim();
|
|
591
591
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
592
|
-
throw new
|
|
592
|
+
throw new U('Custom API URL must start with "http://" or "https://"', "config");
|
|
593
593
|
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
594
|
-
throw new
|
|
594
|
+
throw new U(
|
|
595
595
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
596
596
|
"config"
|
|
597
597
|
);
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
},
|
|
601
|
-
|
|
600
|
+
}, Kt = (s) => {
|
|
601
|
+
Qt(s);
|
|
602
602
|
const e = {
|
|
603
603
|
...s ?? {},
|
|
604
604
|
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
605
605
|
globalMetadata: s?.globalMetadata ?? {},
|
|
606
606
|
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
607
|
-
errorSampling: s?.errorSampling ??
|
|
607
|
+
errorSampling: s?.errorSampling ?? Ke,
|
|
608
608
|
samplingRate: s?.samplingRate ?? 1,
|
|
609
609
|
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
610
610
|
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
@@ -620,12 +620,12 @@ const $t = () => {
|
|
|
620
620
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
621
621
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
622
622
|
}), e;
|
|
623
|
-
},
|
|
623
|
+
}, me = (s, e = /* @__PURE__ */ new Set()) => {
|
|
624
624
|
if (s == null)
|
|
625
625
|
return !0;
|
|
626
626
|
const t = typeof s;
|
|
627
|
-
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(s) ? !1 : (e.add(s), Array.isArray(s) ? s.every((r) =>
|
|
628
|
-
},
|
|
627
|
+
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(s) ? !1 : (e.add(s), Array.isArray(s) ? s.every((r) => me(r, e)) : t === "object" ? Object.values(s).every((r) => me(r, e)) : !1);
|
|
628
|
+
}, Yt = (s) => typeof s != "object" || s === null ? !1 : me(s), qt = (s) => typeof s != "string" ? {
|
|
629
629
|
valid: !1,
|
|
630
630
|
error: "Event name must be a string"
|
|
631
631
|
} : s.length === 0 ? {
|
|
@@ -640,9 +640,9 @@ const $t = () => {
|
|
|
640
640
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
641
641
|
valid: !1,
|
|
642
642
|
error: "Event name cannot be a reserved word"
|
|
643
|
-
} : { valid: !0 },
|
|
644
|
-
const r =
|
|
645
|
-
if (!
|
|
643
|
+
} : { valid: !0 }, $e = (s, e, t) => {
|
|
644
|
+
const r = Xt(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
645
|
+
if (!Yt(r))
|
|
646
646
|
return {
|
|
647
647
|
valid: !1,
|
|
648
648
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -690,7 +690,7 @@ const $t = () => {
|
|
|
690
690
|
valid: !0,
|
|
691
691
|
sanitizedMetadata: r
|
|
692
692
|
};
|
|
693
|
-
},
|
|
693
|
+
}, Je = (s, e, t) => {
|
|
694
694
|
if (Array.isArray(e)) {
|
|
695
695
|
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
696
696
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -700,7 +700,7 @@ const $t = () => {
|
|
|
700
700
|
valid: !1,
|
|
701
701
|
error: `${n}: array item at index ${i} must be an object.`
|
|
702
702
|
};
|
|
703
|
-
const l =
|
|
703
|
+
const l = $e(s, o, t);
|
|
704
704
|
if (!l.valid)
|
|
705
705
|
return {
|
|
706
706
|
valid: !1,
|
|
@@ -713,16 +713,16 @@ const $t = () => {
|
|
|
713
713
|
sanitizedMetadata: r
|
|
714
714
|
};
|
|
715
715
|
}
|
|
716
|
-
return
|
|
717
|
-
},
|
|
718
|
-
const t =
|
|
716
|
+
return $e(s, e, t);
|
|
717
|
+
}, Jt = (s, e) => {
|
|
718
|
+
const t = qt(s);
|
|
719
719
|
if (!t.valid)
|
|
720
720
|
return a("error", "Event name validation failed", {
|
|
721
721
|
data: { eventName: s, error: t.error }
|
|
722
722
|
}), t;
|
|
723
723
|
if (!e)
|
|
724
724
|
return { valid: !0 };
|
|
725
|
-
const r =
|
|
725
|
+
const r = Je(s, e, "customEvent");
|
|
726
726
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
727
727
|
data: {
|
|
728
728
|
eventName: s,
|
|
@@ -730,7 +730,7 @@ const $t = () => {
|
|
|
730
730
|
}
|
|
731
731
|
}), r;
|
|
732
732
|
};
|
|
733
|
-
class
|
|
733
|
+
class Zt {
|
|
734
734
|
listeners = /* @__PURE__ */ new Map();
|
|
735
735
|
/**
|
|
736
736
|
* Subscribes to an event channel
|
|
@@ -847,7 +847,7 @@ class Jt {
|
|
|
847
847
|
this.listeners.clear();
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function Ze(s, e, t) {
|
|
851
851
|
try {
|
|
852
852
|
const r = e(s);
|
|
853
853
|
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), s);
|
|
@@ -858,10 +858,10 @@ function Je(s, e, t) {
|
|
|
858
858
|
}), s;
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
|
-
function
|
|
862
|
-
return s.map((r) =>
|
|
861
|
+
function er(s, e, t) {
|
|
862
|
+
return s.map((r) => Ze(r, e, t)).filter((r) => r !== null);
|
|
863
863
|
}
|
|
864
|
-
function
|
|
864
|
+
function et(s, e, t) {
|
|
865
865
|
try {
|
|
866
866
|
const r = e(s);
|
|
867
867
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -877,7 +877,7 @@ function Ze(s, e, t) {
|
|
|
877
877
|
}), s;
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
|
-
const
|
|
880
|
+
const ie = {};
|
|
881
881
|
class I {
|
|
882
882
|
/**
|
|
883
883
|
* Retrieves a value from global state.
|
|
@@ -896,7 +896,7 @@ class I {
|
|
|
896
896
|
* ```
|
|
897
897
|
*/
|
|
898
898
|
get(e) {
|
|
899
|
-
return
|
|
899
|
+
return ie[e];
|
|
900
900
|
}
|
|
901
901
|
/**
|
|
902
902
|
* Sets a value in global state.
|
|
@@ -916,7 +916,7 @@ class I {
|
|
|
916
916
|
* ```
|
|
917
917
|
*/
|
|
918
918
|
set(e, t) {
|
|
919
|
-
|
|
919
|
+
ie[e] = t;
|
|
920
920
|
}
|
|
921
921
|
/**
|
|
922
922
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -933,7 +933,7 @@ class I {
|
|
|
933
933
|
* ```
|
|
934
934
|
*/
|
|
935
935
|
getState() {
|
|
936
|
-
return { ...
|
|
936
|
+
return { ...ie };
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
class Fe extends I {
|
|
@@ -1011,7 +1011,7 @@ class Fe extends I {
|
|
|
1011
1011
|
return { ...this.staticHeaders, ...e };
|
|
1012
1012
|
}
|
|
1013
1013
|
getQueueStorageKey() {
|
|
1014
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1014
|
+
const e = this.get("userId") || "anonymous", t = ht(e);
|
|
1015
1015
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1016
1016
|
}
|
|
1017
1017
|
/**
|
|
@@ -1048,13 +1048,13 @@ class Fe extends I {
|
|
|
1048
1048
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1049
1049
|
*/
|
|
1050
1050
|
sendEventsQueueSync(e) {
|
|
1051
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1051
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(H.Fail) ? (a(
|
|
1052
1052
|
"warn",
|
|
1053
1053
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1054
1054
|
{
|
|
1055
1055
|
data: { events: e.events.length }
|
|
1056
1056
|
}
|
|
1057
|
-
), !1) : this.apiUrl?.includes(
|
|
1057
|
+
), !1) : this.apiUrl?.includes(H.Localhost) ? (a(
|
|
1058
1058
|
"debug",
|
|
1059
1059
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1060
1060
|
{
|
|
@@ -1096,7 +1096,7 @@ class Fe extends I {
|
|
|
1096
1096
|
const r = await this.send(e);
|
|
1097
1097
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
|
|
1098
1098
|
} catch (r) {
|
|
1099
|
-
return r instanceof
|
|
1099
|
+
return r instanceof P ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1100
1100
|
}
|
|
1101
1101
|
}
|
|
1102
1102
|
/**
|
|
@@ -1163,7 +1163,7 @@ class Fe extends I {
|
|
|
1163
1163
|
const r = this.createRecoveryBody(t);
|
|
1164
1164
|
await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
|
|
1165
1165
|
} catch (t) {
|
|
1166
|
-
if (t instanceof
|
|
1166
|
+
if (t instanceof P) {
|
|
1167
1167
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1168
1168
|
return;
|
|
1169
1169
|
}
|
|
@@ -1217,7 +1217,7 @@ class Fe extends I {
|
|
|
1217
1217
|
const t = this.transformers.beforeSend;
|
|
1218
1218
|
if (!t)
|
|
1219
1219
|
return e;
|
|
1220
|
-
const r =
|
|
1220
|
+
const r = er(
|
|
1221
1221
|
e.events,
|
|
1222
1222
|
t,
|
|
1223
1223
|
this.integrationId || "SenderManager"
|
|
@@ -1262,7 +1262,7 @@ class Fe extends I {
|
|
|
1262
1262
|
if (this.integrationId === "saas")
|
|
1263
1263
|
return e;
|
|
1264
1264
|
const t = this.transformers.beforeBatch;
|
|
1265
|
-
return t ?
|
|
1265
|
+
return t ? et(e, t, this.integrationId || "SenderManager") : e;
|
|
1266
1266
|
}
|
|
1267
1267
|
/**
|
|
1268
1268
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1330,11 +1330,11 @@ class Fe extends I {
|
|
|
1330
1330
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1331
1331
|
if (!r)
|
|
1332
1332
|
return !0;
|
|
1333
|
-
if (this.apiUrl?.includes(
|
|
1333
|
+
if (this.apiUrl?.includes(H.Fail))
|
|
1334
1334
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1335
1335
|
data: { events: r.events.length }
|
|
1336
1336
|
}), !1;
|
|
1337
|
-
if (this.apiUrl?.includes(
|
|
1337
|
+
if (this.apiUrl?.includes(H.Localhost))
|
|
1338
1338
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1339
1339
|
data: { events: r.events.length }
|
|
1340
1340
|
}), !0;
|
|
@@ -1350,7 +1350,7 @@ class Fe extends I {
|
|
|
1350
1350
|
), !0) : !1;
|
|
1351
1351
|
} catch (l) {
|
|
1352
1352
|
const c = o === 3;
|
|
1353
|
-
if (l instanceof
|
|
1353
|
+
if (l instanceof P)
|
|
1354
1354
|
throw l;
|
|
1355
1355
|
if (a(
|
|
1356
1356
|
c ? "error" : "warn",
|
|
@@ -1412,7 +1412,7 @@ class Fe extends I {
|
|
|
1412
1412
|
}
|
|
1413
1413
|
});
|
|
1414
1414
|
if (!o.ok)
|
|
1415
|
-
throw o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429 ? new
|
|
1415
|
+
throw o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429 ? new P(`HTTP ${o.status}: ${o.statusText}`, o.status) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1416
1416
|
return o;
|
|
1417
1417
|
} finally {
|
|
1418
1418
|
clearTimeout(n), this.pendingControllers.delete(r);
|
|
@@ -1496,7 +1496,7 @@ class Fe extends I {
|
|
|
1496
1496
|
_metadata: {
|
|
1497
1497
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1498
1498
|
timestamp: t,
|
|
1499
|
-
client_version:
|
|
1499
|
+
client_version: kt
|
|
1500
1500
|
}
|
|
1501
1501
|
};
|
|
1502
1502
|
return {
|
|
@@ -1617,12 +1617,12 @@ class Fe extends I {
|
|
|
1617
1617
|
}
|
|
1618
1618
|
logPermanentError(e, t) {
|
|
1619
1619
|
const r = Date.now();
|
|
1620
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1620
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= Rt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1621
1621
|
data: { status: t.statusCode, message: t.message }
|
|
1622
1622
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1623
1623
|
}
|
|
1624
1624
|
}
|
|
1625
|
-
class
|
|
1625
|
+
class tr extends I {
|
|
1626
1626
|
bootTime;
|
|
1627
1627
|
bootTimestamp;
|
|
1628
1628
|
hasPerformanceNow;
|
|
@@ -1771,7 +1771,8 @@ class er extends I {
|
|
|
1771
1771
|
};
|
|
1772
1772
|
}
|
|
1773
1773
|
}
|
|
1774
|
-
|
|
1774
|
+
const rr = new Set(Object.values(d));
|
|
1775
|
+
class sr extends I {
|
|
1775
1776
|
dataSenders;
|
|
1776
1777
|
emitter;
|
|
1777
1778
|
transformers;
|
|
@@ -1781,6 +1782,7 @@ class tr extends I {
|
|
|
1781
1782
|
eventsQueue = [];
|
|
1782
1783
|
pendingEventsBuffer = [];
|
|
1783
1784
|
sendIntervalId = null;
|
|
1785
|
+
sendInProgress = !1;
|
|
1784
1786
|
rateLimitCounter = 0;
|
|
1785
1787
|
rateLimitWindowStart = 0;
|
|
1786
1788
|
lastSessionId = null;
|
|
@@ -1807,7 +1809,7 @@ class tr extends I {
|
|
|
1807
1809
|
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1808
1810
|
*/
|
|
1809
1811
|
constructor(e, t = null, r = {}, n = {}, i) {
|
|
1810
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1812
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new tr(), this.dataSenders = [];
|
|
1811
1813
|
const o = this.get("collectApiUrls");
|
|
1812
1814
|
o?.saas && this.dataSenders.push(new Fe(e, "saas", o.saas, r)), o?.custom && this.dataSenders.push(
|
|
1813
1815
|
new Fe(
|
|
@@ -1937,6 +1939,12 @@ class tr extends I {
|
|
|
1937
1939
|
a("error", "Event type is required - event will be ignored");
|
|
1938
1940
|
return;
|
|
1939
1941
|
}
|
|
1942
|
+
if (!rr.has(e)) {
|
|
1943
|
+
a("error", "Invalid event type - event will be ignored", {
|
|
1944
|
+
data: { type: e }
|
|
1945
|
+
});
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
1940
1948
|
const g = this.get("sessionId");
|
|
1941
1949
|
if (!g) {
|
|
1942
1950
|
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("debug", "Pending events buffer full - dropping oldest event", {
|
|
@@ -1975,12 +1983,12 @@ class tr extends I {
|
|
|
1975
1983
|
}
|
|
1976
1984
|
const T = this.getTypeLimitForEvent(E);
|
|
1977
1985
|
if (T) {
|
|
1978
|
-
const
|
|
1979
|
-
if (
|
|
1986
|
+
const re = this.sessionEventCounts[E];
|
|
1987
|
+
if (re !== void 0 && re >= T) {
|
|
1980
1988
|
a("warn", "Session event type limit reached", {
|
|
1981
1989
|
data: {
|
|
1982
1990
|
type: E,
|
|
1983
|
-
count:
|
|
1991
|
+
count: re,
|
|
1984
1992
|
limit: T
|
|
1985
1993
|
}
|
|
1986
1994
|
});
|
|
@@ -1993,9 +2001,9 @@ class tr extends I {
|
|
|
1993
2001
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1994
2002
|
return;
|
|
1995
2003
|
}
|
|
1996
|
-
const
|
|
2004
|
+
const ye = E === d.SESSION_START, W = t || this.get("pageUrl"), V = this.buildEventPayload({
|
|
1997
2005
|
type: E,
|
|
1998
|
-
page_url:
|
|
2006
|
+
page_url: W,
|
|
1999
2007
|
from_page_url: r,
|
|
2000
2008
|
scroll_data: n,
|
|
2001
2009
|
click_data: i,
|
|
@@ -2005,8 +2013,8 @@ class tr extends I {
|
|
|
2005
2013
|
viewport_data: u,
|
|
2006
2014
|
page_view: S
|
|
2007
2015
|
});
|
|
2008
|
-
if (
|
|
2009
|
-
if (
|
|
2016
|
+
if (V && !(!p && !this.shouldSample())) {
|
|
2017
|
+
if (ye) {
|
|
2010
2018
|
const T = this.get("sessionId");
|
|
2011
2019
|
if (!T) {
|
|
2012
2020
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2020,8 +2028,8 @@ class tr extends I {
|
|
|
2020
2028
|
}
|
|
2021
2029
|
this.set("hasStartSession", !0);
|
|
2022
2030
|
}
|
|
2023
|
-
if (!this.isDuplicateEvent(
|
|
2024
|
-
if (this.get("mode") ===
|
|
2031
|
+
if (!this.isDuplicateEvent(V)) {
|
|
2032
|
+
if (this.get("mode") === Y.QA) {
|
|
2025
2033
|
if (E === d.CUSTOM && o) {
|
|
2026
2034
|
a("info", `Custom Event: ${o.name}`, {
|
|
2027
2035
|
visibility: "qa",
|
|
@@ -2029,7 +2037,7 @@ class tr extends I {
|
|
|
2029
2037
|
name: o.name,
|
|
2030
2038
|
...o.metadata && { metadata: o.metadata }
|
|
2031
2039
|
}
|
|
2032
|
-
}), this.emitEvent(
|
|
2040
|
+
}), this.emitEvent(V);
|
|
2033
2041
|
return;
|
|
2034
2042
|
}
|
|
2035
2043
|
if (E === d.VIEWPORT_VISIBLE && u) {
|
|
@@ -2043,11 +2051,11 @@ class tr extends I {
|
|
|
2043
2051
|
visibilityRatio: u.visibilityRatio,
|
|
2044
2052
|
dwellTime: u.dwellTime
|
|
2045
2053
|
}
|
|
2046
|
-
}), this.emitEvent(
|
|
2054
|
+
}), this.emitEvent(V);
|
|
2047
2055
|
return;
|
|
2048
2056
|
}
|
|
2049
2057
|
}
|
|
2050
|
-
if (this.addToQueue(
|
|
2058
|
+
if (this.addToQueue(V), !p) {
|
|
2051
2059
|
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2052
2060
|
const T = this.get("sessionId");
|
|
2053
2061
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
@@ -2072,8 +2080,8 @@ class tr extends I {
|
|
|
2072
2080
|
* 6. **Stop SenderManagers**: Calls `stop()` on all SenderManager instances
|
|
2073
2081
|
*
|
|
2074
2082
|
* **Important Behavior**:
|
|
2075
|
-
* - **No final flush**:
|
|
2076
|
-
* -
|
|
2083
|
+
* - **No final flush**: `stop()` itself does NOT send queued events
|
|
2084
|
+
* - `App.destroy()` calls `flushImmediatelySync()` before `stop()` automatically
|
|
2077
2085
|
*
|
|
2078
2086
|
* **Multi-Integration**:
|
|
2079
2087
|
* - Stops all SenderManager instances (SaaS + Custom)
|
|
@@ -2338,32 +2346,37 @@ class tr extends I {
|
|
|
2338
2346
|
}
|
|
2339
2347
|
}
|
|
2340
2348
|
async sendEventsQueue() {
|
|
2341
|
-
if (!this.get("sessionId") || this.eventsQueue.length === 0)
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
const t = [...this.eventsQueue], r = t.map((l) => l.id), n = this.dataSenders.map(
|
|
2349
|
-
async (l) => l.sendEventsQueue(e, {
|
|
2350
|
-
onSuccess: () => {
|
|
2351
|
-
},
|
|
2352
|
-
onFailure: () => {
|
|
2349
|
+
if (!(!this.get("sessionId") || this.eventsQueue.length === 0 || this.sendInProgress)) {
|
|
2350
|
+
this.sendInProgress = !0;
|
|
2351
|
+
try {
|
|
2352
|
+
const e = this.buildEventsPayload();
|
|
2353
|
+
if (this.dataSenders.length === 0) {
|
|
2354
|
+
this.emitEventsQueue(e);
|
|
2355
|
+
return;
|
|
2353
2356
|
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2357
|
+
const t = [...this.eventsQueue], r = t.map((l) => l.id), n = this.dataSenders.map(
|
|
2358
|
+
async (l) => l.sendEventsQueue(e, {
|
|
2359
|
+
onSuccess: () => {
|
|
2360
|
+
},
|
|
2361
|
+
onFailure: () => {
|
|
2362
|
+
}
|
|
2363
|
+
})
|
|
2364
|
+
), i = await Promise.allSettled(n);
|
|
2365
|
+
if (i.some((l) => this.isSuccessfulResult(l))) {
|
|
2366
|
+
this.removeProcessedEvents(r), this.emitEventsQueue(e);
|
|
2367
|
+
const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
2368
|
+
l > 0 && a("debug", "Periodic send completed with some failures, removed from queue and persisted per-integration", {
|
|
2369
|
+
data: { eventCount: t.length, failedCount: l }
|
|
2370
|
+
});
|
|
2371
|
+
} else
|
|
2372
|
+
a("debug", "Periodic send complete failure, events kept in queue for retry", {
|
|
2373
|
+
data: { eventCount: t.length }
|
|
2374
|
+
});
|
|
2375
|
+
this.eventsQueue.length === 0 && this.clearSendInterval();
|
|
2376
|
+
} finally {
|
|
2377
|
+
this.sendInProgress = !1;
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2367
2380
|
}
|
|
2368
2381
|
buildEventsPayload() {
|
|
2369
2382
|
const e = /* @__PURE__ */ new Map(), t = [];
|
|
@@ -2381,7 +2394,7 @@ class tr extends I {
|
|
|
2381
2394
|
};
|
|
2382
2395
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2383
2396
|
if (!o && l) {
|
|
2384
|
-
const c =
|
|
2397
|
+
const c = et(n, l, "EventManager");
|
|
2385
2398
|
c !== null && (n = c);
|
|
2386
2399
|
}
|
|
2387
2400
|
return n;
|
|
@@ -2393,7 +2406,7 @@ class tr extends I {
|
|
|
2393
2406
|
});
|
|
2394
2407
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2395
2408
|
let l = {
|
|
2396
|
-
id:
|
|
2409
|
+
id: Bt(),
|
|
2397
2410
|
type: e.type,
|
|
2398
2411
|
page_url: t,
|
|
2399
2412
|
timestamp: r,
|
|
@@ -2410,10 +2423,10 @@ class tr extends I {
|
|
|
2410
2423
|
};
|
|
2411
2424
|
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2412
2425
|
if (E && (!g || u && !p)) {
|
|
2413
|
-
const
|
|
2414
|
-
if (
|
|
2426
|
+
const W = Ze(l, E, "EventManager");
|
|
2427
|
+
if (W === null)
|
|
2415
2428
|
return null;
|
|
2416
|
-
l =
|
|
2429
|
+
l = W;
|
|
2417
2430
|
}
|
|
2418
2431
|
return l;
|
|
2419
2432
|
}
|
|
@@ -2496,10 +2509,10 @@ class tr extends I {
|
|
|
2496
2509
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2497
2510
|
}
|
|
2498
2511
|
emitEvent(e) {
|
|
2499
|
-
this.emitter && this.emitter.emit(
|
|
2512
|
+
this.emitter && this.emitter.emit(le.EVENT, e);
|
|
2500
2513
|
}
|
|
2501
2514
|
emitEventsQueue(e) {
|
|
2502
|
-
this.emitter && this.emitter.emit(
|
|
2515
|
+
this.emitter && this.emitter.emit(le.QUEUE, e);
|
|
2503
2516
|
}
|
|
2504
2517
|
/**
|
|
2505
2518
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2575,13 +2588,13 @@ class tr extends I {
|
|
|
2575
2588
|
loadSessionCounts(e) {
|
|
2576
2589
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2577
2590
|
return this.getInitialCounts();
|
|
2578
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2591
|
+
const t = this.get("userId") || "anonymous", r = Me(t, e);
|
|
2579
2592
|
try {
|
|
2580
2593
|
const n = localStorage.getItem(r);
|
|
2581
2594
|
if (!n)
|
|
2582
2595
|
return this.getInitialCounts();
|
|
2583
2596
|
const i = JSON.parse(n);
|
|
2584
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2597
|
+
return i._timestamp && Date.now() - i._timestamp > Ce ? (a("debug", "Session counts expired, clearing", {
|
|
2585
2598
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2586
2599
|
}), 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" ? {
|
|
2587
2600
|
total: i.total,
|
|
@@ -2626,12 +2639,12 @@ class tr extends I {
|
|
|
2626
2639
|
cleanupExpiredSessionCounts() {
|
|
2627
2640
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2628
2641
|
try {
|
|
2629
|
-
const e = localStorage.getItem(
|
|
2642
|
+
const e = localStorage.getItem(Re);
|
|
2630
2643
|
if (e) {
|
|
2631
2644
|
const i = Date.now() - parseInt(e, 10);
|
|
2632
|
-
if (i <
|
|
2645
|
+
if (i < Ne) {
|
|
2633
2646
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2634
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2647
|
+
data: { timeSinceLastCleanup: i, throttleMs: Ne }
|
|
2635
2648
|
});
|
|
2636
2649
|
return;
|
|
2637
2650
|
}
|
|
@@ -2644,14 +2657,14 @@ class tr extends I {
|
|
|
2644
2657
|
const l = localStorage.getItem(o);
|
|
2645
2658
|
if (l) {
|
|
2646
2659
|
const c = JSON.parse(l);
|
|
2647
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2660
|
+
c._timestamp && Date.now() - c._timestamp > Ce && n.push(o);
|
|
2648
2661
|
}
|
|
2649
2662
|
} catch {
|
|
2650
2663
|
}
|
|
2651
2664
|
}
|
|
2652
2665
|
n.forEach((i) => {
|
|
2653
2666
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2654
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2667
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Re, Date.now().toString());
|
|
2655
2668
|
} catch (e) {
|
|
2656
2669
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2657
2670
|
}
|
|
@@ -2685,7 +2698,7 @@ class tr extends I {
|
|
|
2685
2698
|
* @internal
|
|
2686
2699
|
*/
|
|
2687
2700
|
saveSessionCounts(e) {
|
|
2688
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2701
|
+
const t = this.get("userId") || "anonymous", r = Me(t, e);
|
|
2689
2702
|
try {
|
|
2690
2703
|
const n = {
|
|
2691
2704
|
...this.sessionEventCounts,
|
|
@@ -2701,7 +2714,7 @@ class tr extends I {
|
|
|
2701
2714
|
}
|
|
2702
2715
|
}
|
|
2703
2716
|
}
|
|
2704
|
-
class
|
|
2717
|
+
class nr {
|
|
2705
2718
|
/**
|
|
2706
2719
|
* Gets or creates a unique user ID.
|
|
2707
2720
|
*
|
|
@@ -2719,15 +2732,15 @@ class rr {
|
|
|
2719
2732
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2720
2733
|
*/
|
|
2721
2734
|
static getId(e) {
|
|
2722
|
-
const t = e.getItem(
|
|
2735
|
+
const t = e.getItem(be);
|
|
2723
2736
|
if (t)
|
|
2724
2737
|
return t;
|
|
2725
2738
|
const r = Ft();
|
|
2726
|
-
return e.setItem(
|
|
2739
|
+
return e.setItem(be, r), r;
|
|
2727
2740
|
}
|
|
2728
2741
|
}
|
|
2729
|
-
const
|
|
2730
|
-
class
|
|
2742
|
+
const ir = /^\d{13}-[a-z0-9]{9}$/;
|
|
2743
|
+
class or extends I {
|
|
2731
2744
|
storageManager;
|
|
2732
2745
|
eventManager;
|
|
2733
2746
|
projectId;
|
|
@@ -2753,7 +2766,7 @@ class nr extends I {
|
|
|
2753
2766
|
return;
|
|
2754
2767
|
}
|
|
2755
2768
|
const e = this.getProjectId();
|
|
2756
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2769
|
+
this.broadcastChannel = new BroadcastChannel(mt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2757
2770
|
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2758
2771
|
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 } }));
|
|
2759
2772
|
};
|
|
@@ -2773,7 +2786,7 @@ class nr extends I {
|
|
|
2773
2786
|
const e = this.loadStoredSession();
|
|
2774
2787
|
if (!e)
|
|
2775
2788
|
return null;
|
|
2776
|
-
if (!
|
|
2789
|
+
if (!ir.test(e.id))
|
|
2777
2790
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2778
2791
|
data: { sessionId: e.id }
|
|
2779
2792
|
}), this.clearStoredSession(), null;
|
|
@@ -2808,7 +2821,7 @@ class nr extends I {
|
|
|
2808
2821
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2809
2822
|
}
|
|
2810
2823
|
getSessionStorageKey() {
|
|
2811
|
-
return
|
|
2824
|
+
return ft(this.getProjectId());
|
|
2812
2825
|
}
|
|
2813
2826
|
getProjectId() {
|
|
2814
2827
|
return this.projectId;
|
|
@@ -2873,9 +2886,9 @@ class nr extends I {
|
|
|
2873
2886
|
let r, n;
|
|
2874
2887
|
if (e) {
|
|
2875
2888
|
const i = this.loadStoredSession();
|
|
2876
|
-
r = i?.referrer ??
|
|
2889
|
+
r = i?.referrer ?? se(), n = i?.utm ?? ne();
|
|
2877
2890
|
} else
|
|
2878
|
-
r =
|
|
2891
|
+
r = se(), n = ne();
|
|
2879
2892
|
a("debug", "Session tracking initialized", {
|
|
2880
2893
|
data: {
|
|
2881
2894
|
sessionId: t,
|
|
@@ -2926,7 +2939,7 @@ class nr extends I {
|
|
|
2926
2939
|
*/
|
|
2927
2940
|
renewSession() {
|
|
2928
2941
|
this.needsRenewal = !1;
|
|
2929
|
-
const e = this.generateSessionId(), t =
|
|
2942
|
+
const e = this.generateSessionId(), t = se(), r = ne();
|
|
2930
2943
|
a("debug", "Renewing session after timeout", {
|
|
2931
2944
|
data: { newSessionId: e }
|
|
2932
2945
|
}), 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({
|
|
@@ -3047,7 +3060,7 @@ class nr extends I {
|
|
|
3047
3060
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3048
3061
|
}
|
|
3049
3062
|
}
|
|
3050
|
-
class
|
|
3063
|
+
class ar extends I {
|
|
3051
3064
|
eventManager;
|
|
3052
3065
|
storageManager;
|
|
3053
3066
|
sessionManager = null;
|
|
@@ -3082,7 +3095,7 @@ class ir extends I {
|
|
|
3082
3095
|
}
|
|
3083
3096
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3084
3097
|
try {
|
|
3085
|
-
this.sessionManager = new
|
|
3098
|
+
this.sessionManager = new or(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3086
3099
|
} catch (r) {
|
|
3087
3100
|
if (this.sessionManager) {
|
|
3088
3101
|
try {
|
|
@@ -3135,7 +3148,7 @@ class ir extends I {
|
|
|
3135
3148
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3136
3149
|
}
|
|
3137
3150
|
}
|
|
3138
|
-
class
|
|
3151
|
+
class lr extends I {
|
|
3139
3152
|
eventManager;
|
|
3140
3153
|
onTrack;
|
|
3141
3154
|
originalPushState;
|
|
@@ -3175,7 +3188,7 @@ class or extends I {
|
|
|
3175
3188
|
};
|
|
3176
3189
|
}
|
|
3177
3190
|
trackCurrentPage = () => {
|
|
3178
|
-
const e = window.location.href, t =
|
|
3191
|
+
const e = window.location.href, t = he(e, this.get("config").sensitiveQueryParams);
|
|
3179
3192
|
if (this.get("pageUrl") === t)
|
|
3180
3193
|
return;
|
|
3181
3194
|
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3193,7 +3206,7 @@ class or extends I {
|
|
|
3193
3206
|
});
|
|
3194
3207
|
};
|
|
3195
3208
|
trackInitialPageView() {
|
|
3196
|
-
const e =
|
|
3209
|
+
const e = he(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3197
3210
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3198
3211
|
type: d.PAGE_VIEW,
|
|
3199
3212
|
page_url: e,
|
|
@@ -3211,7 +3224,7 @@ class or extends I {
|
|
|
3211
3224
|
};
|
|
3212
3225
|
}
|
|
3213
3226
|
}
|
|
3214
|
-
class
|
|
3227
|
+
class cr extends I {
|
|
3215
3228
|
eventManager;
|
|
3216
3229
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3217
3230
|
clickHandler;
|
|
@@ -3349,7 +3362,7 @@ class ar extends I {
|
|
|
3349
3362
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3350
3363
|
}
|
|
3351
3364
|
getRelevantClickElement(e) {
|
|
3352
|
-
for (const t of
|
|
3365
|
+
for (const t of lt)
|
|
3353
3366
|
try {
|
|
3354
3367
|
if (e.matches(t))
|
|
3355
3368
|
return e;
|
|
@@ -3429,7 +3442,7 @@ class ar extends I {
|
|
|
3429
3442
|
*/
|
|
3430
3443
|
sanitizeText(e) {
|
|
3431
3444
|
let t = e;
|
|
3432
|
-
for (const r of
|
|
3445
|
+
for (const r of ze) {
|
|
3433
3446
|
const n = new RegExp(r.source, r.flags);
|
|
3434
3447
|
t = t.replace(n, "[REDACTED]");
|
|
3435
3448
|
}
|
|
@@ -3468,7 +3481,7 @@ class ar extends I {
|
|
|
3468
3481
|
};
|
|
3469
3482
|
}
|
|
3470
3483
|
}
|
|
3471
|
-
class
|
|
3484
|
+
class ur extends I {
|
|
3472
3485
|
eventManager;
|
|
3473
3486
|
containers = [];
|
|
3474
3487
|
limitWarningLogged = !1;
|
|
@@ -3581,7 +3594,7 @@ class lr extends I {
|
|
|
3581
3594
|
isPrimary: o,
|
|
3582
3595
|
lastScrollPos: n,
|
|
3583
3596
|
lastDepth: i,
|
|
3584
|
-
lastDirection:
|
|
3597
|
+
lastDirection: j.DOWN,
|
|
3585
3598
|
lastEventTime: 0,
|
|
3586
3599
|
firstScrollEventTime: null,
|
|
3587
3600
|
maxDepthReached: i,
|
|
@@ -3640,7 +3653,7 @@ class lr extends I {
|
|
|
3640
3653
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3641
3654
|
}
|
|
3642
3655
|
getScrollDirection(e, t) {
|
|
3643
|
-
return e > t ?
|
|
3656
|
+
return e > t ? j.DOWN : j.UP;
|
|
3644
3657
|
}
|
|
3645
3658
|
calculateScrollDepth(e, t, r) {
|
|
3646
3659
|
if (t <= r)
|
|
@@ -3696,7 +3709,7 @@ class lr extends I {
|
|
|
3696
3709
|
e.isPrimary = t;
|
|
3697
3710
|
}
|
|
3698
3711
|
}
|
|
3699
|
-
class
|
|
3712
|
+
class dr extends I {
|
|
3700
3713
|
eventManager;
|
|
3701
3714
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3702
3715
|
observer = null;
|
|
@@ -3857,7 +3870,7 @@ class cr extends I {
|
|
|
3857
3870
|
});
|
|
3858
3871
|
}
|
|
3859
3872
|
}
|
|
3860
|
-
class
|
|
3873
|
+
class hr {
|
|
3861
3874
|
storage;
|
|
3862
3875
|
sessionStorageRef;
|
|
3863
3876
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4140,7 +4153,7 @@ class ur {
|
|
|
4140
4153
|
this.fallbackSessionStorage.delete(e);
|
|
4141
4154
|
}
|
|
4142
4155
|
}
|
|
4143
|
-
class
|
|
4156
|
+
class fr extends I {
|
|
4144
4157
|
eventManager;
|
|
4145
4158
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4146
4159
|
navigationHistory = [];
|
|
@@ -4151,7 +4164,7 @@ class dr extends I {
|
|
|
4151
4164
|
navigationCounter = 0;
|
|
4152
4165
|
// Counter for handling simultaneous navigations edge case
|
|
4153
4166
|
constructor(e) {
|
|
4154
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4167
|
+
super(), this.eventManager = e, this.vitalThresholds = Ue(de);
|
|
4155
4168
|
}
|
|
4156
4169
|
/**
|
|
4157
4170
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4168,8 +4181,8 @@ class dr extends I {
|
|
|
4168
4181
|
* @returns Promise that resolves when tracking is initialized
|
|
4169
4182
|
*/
|
|
4170
4183
|
async startTracking() {
|
|
4171
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4172
|
-
this.vitalThresholds =
|
|
4184
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? de;
|
|
4185
|
+
this.vitalThresholds = Ue(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4173
4186
|
}
|
|
4174
4187
|
/**
|
|
4175
4188
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4239,7 +4252,7 @@ class dr extends I {
|
|
|
4239
4252
|
}
|
|
4240
4253
|
async initWebVitals() {
|
|
4241
4254
|
try {
|
|
4242
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4255
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => Fr), o = (l) => (c) => {
|
|
4243
4256
|
const u = Number(c.value.toFixed(2));
|
|
4244
4257
|
this.sendVital({ type: l, value: u });
|
|
4245
4258
|
};
|
|
@@ -4266,7 +4279,7 @@ class dr extends I {
|
|
|
4266
4279
|
const t = e.getEntries();
|
|
4267
4280
|
for (const r of t) {
|
|
4268
4281
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4269
|
-
i - this.lastLongTaskSentAt >=
|
|
4282
|
+
i - this.lastLongTaskSentAt >= Ot && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4270
4283
|
}
|
|
4271
4284
|
},
|
|
4272
4285
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4282,7 +4295,7 @@ class dr extends I {
|
|
|
4282
4295
|
return;
|
|
4283
4296
|
if (r)
|
|
4284
4297
|
r.add(e.type);
|
|
4285
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4298
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Pt) {
|
|
4286
4299
|
const i = this.navigationHistory.shift();
|
|
4287
4300
|
i && this.reportedByNav.delete(i);
|
|
4288
4301
|
}
|
|
@@ -4373,7 +4386,7 @@ class dr extends I {
|
|
|
4373
4386
|
return !(typeof r == "number" && t <= r);
|
|
4374
4387
|
}
|
|
4375
4388
|
}
|
|
4376
|
-
class
|
|
4389
|
+
class mr extends I {
|
|
4377
4390
|
eventManager;
|
|
4378
4391
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4379
4392
|
errorBurstCounter = 0;
|
|
@@ -4409,24 +4422,24 @@ class hr extends I {
|
|
|
4409
4422
|
const e = Date.now();
|
|
4410
4423
|
if (e < this.burstBackoffUntil)
|
|
4411
4424
|
return !1;
|
|
4412
|
-
if (e - this.burstWindowStart >
|
|
4413
|
-
return this.burstBackoffUntil = e +
|
|
4425
|
+
if (e - this.burstWindowStart > Mt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Ct)
|
|
4426
|
+
return this.burstBackoffUntil = e + ke, a("debug", "Error burst detected - entering cooldown", {
|
|
4414
4427
|
data: {
|
|
4415
4428
|
errorsInWindow: this.errorBurstCounter,
|
|
4416
|
-
cooldownMs:
|
|
4429
|
+
cooldownMs: ke
|
|
4417
4430
|
}
|
|
4418
4431
|
}), !1;
|
|
4419
|
-
const r = this.get("config")?.errorSampling ??
|
|
4432
|
+
const r = this.get("config")?.errorSampling ?? Ke;
|
|
4420
4433
|
return Math.random() < r;
|
|
4421
4434
|
}
|
|
4422
4435
|
handleError = (e) => {
|
|
4423
4436
|
if (!this.shouldSample())
|
|
4424
4437
|
return;
|
|
4425
4438
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4426
|
-
this.shouldSuppressError(
|
|
4439
|
+
this.shouldSuppressError(x.JS_ERROR, t) || this.eventManager.track({
|
|
4427
4440
|
type: d.ERROR,
|
|
4428
4441
|
error_data: {
|
|
4429
|
-
type:
|
|
4442
|
+
type: x.JS_ERROR,
|
|
4430
4443
|
message: t,
|
|
4431
4444
|
...e.filename && { filename: e.filename },
|
|
4432
4445
|
...e.lineno && { line: e.lineno },
|
|
@@ -4438,10 +4451,10 @@ class hr extends I {
|
|
|
4438
4451
|
if (!this.shouldSample())
|
|
4439
4452
|
return;
|
|
4440
4453
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4441
|
-
this.shouldSuppressError(
|
|
4454
|
+
this.shouldSuppressError(x.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4442
4455
|
type: d.ERROR,
|
|
4443
4456
|
error_data: {
|
|
4444
|
-
type:
|
|
4457
|
+
type: x.PROMISE_REJECTION,
|
|
4445
4458
|
message: r
|
|
4446
4459
|
}
|
|
4447
4460
|
});
|
|
@@ -4460,8 +4473,8 @@ class hr extends I {
|
|
|
4460
4473
|
}
|
|
4461
4474
|
}
|
|
4462
4475
|
sanitize(e) {
|
|
4463
|
-
let t = e.length >
|
|
4464
|
-
for (const r of
|
|
4476
|
+
let t = e.length > Pe ? e.slice(0, Pe) + "..." : e;
|
|
4477
|
+
for (const r of ze) {
|
|
4465
4478
|
const n = new RegExp(r.source, r.flags);
|
|
4466
4479
|
t = t.replace(n, "[REDACTED]");
|
|
4467
4480
|
}
|
|
@@ -4469,25 +4482,26 @@ class hr extends I {
|
|
|
4469
4482
|
}
|
|
4470
4483
|
shouldSuppressError(e, t) {
|
|
4471
4484
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4472
|
-
return i && r - i <
|
|
4485
|
+
return i && r - i < De ? (this.recentErrors.set(n, r), !0) : (this.recentErrors.set(n, r), this.recentErrors.size > At ? (this.recentErrors.clear(), this.recentErrors.set(n, r), !1) : (this.recentErrors.size > z && this.pruneOldErrors(), !1));
|
|
4473
4486
|
}
|
|
4474
4487
|
pruneOldErrors() {
|
|
4475
4488
|
const e = Date.now();
|
|
4476
4489
|
for (const [n, i] of this.recentErrors.entries())
|
|
4477
|
-
e - i >
|
|
4478
|
-
if (this.recentErrors.size <=
|
|
4490
|
+
e - i > De && this.recentErrors.delete(n);
|
|
4491
|
+
if (this.recentErrors.size <= z)
|
|
4479
4492
|
return;
|
|
4480
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size -
|
|
4493
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - z;
|
|
4481
4494
|
for (let n = 0; n < r; n += 1) {
|
|
4482
4495
|
const i = t[n];
|
|
4483
4496
|
i && this.recentErrors.delete(i[0]);
|
|
4484
4497
|
}
|
|
4485
4498
|
}
|
|
4486
4499
|
}
|
|
4487
|
-
class
|
|
4500
|
+
class gr extends I {
|
|
4488
4501
|
isInitialized = !1;
|
|
4489
4502
|
suppressNextScrollTimer = null;
|
|
4490
|
-
|
|
4503
|
+
pageUnloadHandler = null;
|
|
4504
|
+
emitter = new Zt();
|
|
4491
4505
|
transformers = {};
|
|
4492
4506
|
customHeadersProvider;
|
|
4493
4507
|
managers = {};
|
|
@@ -4505,17 +4519,17 @@ class fr extends I {
|
|
|
4505
4519
|
async init(e = {}) {
|
|
4506
4520
|
if (this.isInitialized)
|
|
4507
4521
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
4508
|
-
this.managers.storage = new
|
|
4522
|
+
this.managers.storage = new hr();
|
|
4509
4523
|
try {
|
|
4510
4524
|
this.setupState(e);
|
|
4511
4525
|
const t = e.integrations?.custom?.headers ?? {};
|
|
4512
|
-
return this.managers.event = new
|
|
4526
|
+
return this.managers.event = new sr(
|
|
4513
4527
|
this.managers.storage,
|
|
4514
4528
|
this.emitter,
|
|
4515
4529
|
this.transformers,
|
|
4516
4530
|
t,
|
|
4517
4531
|
this.customHeadersProvider
|
|
4518
|
-
), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4532
|
+
), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4519
4533
|
a("warn", "Failed to recover persisted events", { error: r });
|
|
4520
4534
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
4521
4535
|
} catch (t) {
|
|
@@ -4538,10 +4552,11 @@ class fr extends I {
|
|
|
4538
4552
|
}
|
|
4539
4553
|
let r = t;
|
|
4540
4554
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4541
|
-
const { valid: n, error: i, sanitizedMetadata: o } =
|
|
4555
|
+
const { valid: n, error: i, sanitizedMetadata: o } = Jt(e, r);
|
|
4542
4556
|
if (!n) {
|
|
4543
|
-
if (this.get("mode") ===
|
|
4557
|
+
if (this.get("mode") === Y.QA)
|
|
4544
4558
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4559
|
+
a("warn", `Custom event "${e}" dropped: ${i}`);
|
|
4545
4560
|
return;
|
|
4546
4561
|
}
|
|
4547
4562
|
this.managers.event.track({
|
|
@@ -4603,18 +4618,18 @@ class fr extends I {
|
|
|
4603
4618
|
} catch (r) {
|
|
4604
4619
|
a("warn", "Failed to stop tracking", { error: r });
|
|
4605
4620
|
}
|
|
4606
|
-
}), 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.customHeadersProvider = void 0, this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
4621
|
+
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.pageUnloadHandler && (window.removeEventListener("pagehide", this.pageUnloadHandler), window.removeEventListener("beforeunload", this.pageUnloadHandler), this.pageUnloadHandler = null), this.managers.event?.flushImmediatelySync(), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.transformers.beforeSend = void 0, this.transformers.beforeBatch = void 0, this.customHeadersProvider = void 0, this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
4607
4622
|
}
|
|
4608
4623
|
setupState(e = {}) {
|
|
4609
4624
|
this.set("config", e);
|
|
4610
|
-
const t =
|
|
4625
|
+
const t = nr.getId(this.managers.storage);
|
|
4611
4626
|
this.set("userId", t);
|
|
4612
|
-
const r =
|
|
4627
|
+
const r = Gt(e);
|
|
4613
4628
|
this.set("collectApiUrls", r);
|
|
4614
|
-
const n =
|
|
4629
|
+
const n = Lt();
|
|
4615
4630
|
this.set("device", n);
|
|
4616
|
-
const i =
|
|
4617
|
-
this.set("pageUrl", i),
|
|
4631
|
+
const i = he(window.location.href, e.sensitiveQueryParams);
|
|
4632
|
+
this.set("pageUrl", i), Ut() && this.set("mode", Y.QA);
|
|
4618
4633
|
}
|
|
4619
4634
|
/**
|
|
4620
4635
|
* Returns the current configuration object.
|
|
@@ -4665,7 +4680,7 @@ class fr extends I {
|
|
|
4665
4680
|
valid: !1,
|
|
4666
4681
|
error: "Global metadata must be a plain object"
|
|
4667
4682
|
};
|
|
4668
|
-
const t =
|
|
4683
|
+
const t = Je("Global", e, "globalMetadata");
|
|
4669
4684
|
return t.valid ? { valid: !0 } : {
|
|
4670
4685
|
valid: !1,
|
|
4671
4686
|
error: t.error
|
|
@@ -4708,9 +4723,14 @@ class fr extends I {
|
|
|
4708
4723
|
};
|
|
4709
4724
|
this.set("config", o), a("debug", "Global metadata updated (merged)", { data: { keys: Object.keys(e) } });
|
|
4710
4725
|
}
|
|
4726
|
+
setupPageLifecycleListeners() {
|
|
4727
|
+
this.pageUnloadHandler = () => {
|
|
4728
|
+
this.managers.event?.flushImmediatelySync();
|
|
4729
|
+
}, window.addEventListener("pagehide", this.pageUnloadHandler), window.addEventListener("beforeunload", this.pageUnloadHandler);
|
|
4730
|
+
}
|
|
4711
4731
|
initializeHandlers() {
|
|
4712
4732
|
const e = this.get("config");
|
|
4713
|
-
this.handlers.session = new
|
|
4733
|
+
this.handlers.session = new ar(
|
|
4714
4734
|
this.managers.storage,
|
|
4715
4735
|
this.managers.event
|
|
4716
4736
|
), this.handlers.session.startTracking();
|
|
@@ -4719,31 +4739,22 @@ class fr extends I {
|
|
|
4719
4739
|
this.set("suppressNextScroll", !1);
|
|
4720
4740
|
}, 500);
|
|
4721
4741
|
};
|
|
4722
|
-
this.handlers.pageView = new
|
|
4742
|
+
this.handlers.pageView = new lr(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new cr(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new ur(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new fr(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4723
4743
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4724
|
-
}), this.handlers.error = new
|
|
4744
|
+
}), this.handlers.error = new mr(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new dr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4725
4745
|
}
|
|
4726
4746
|
}
|
|
4727
|
-
const
|
|
4728
|
-
let
|
|
4729
|
-
const
|
|
4730
|
-
if (typeof window > "u" || typeof document > "u")
|
|
4731
|
-
return { sessionId: "" };
|
|
4732
|
-
if (v = !1, window.__traceLogDisabled === !0)
|
|
4733
|
-
return { sessionId: "" };
|
|
4734
|
-
if (h)
|
|
4735
|
-
return { sessionId: h.getSessionId() ?? "" };
|
|
4736
|
-
if (C)
|
|
4737
|
-
return { sessionId: "" };
|
|
4738
|
-
C = !0;
|
|
4747
|
+
const O = [], M = [];
|
|
4748
|
+
let N = null, h = null, C = !1, v = !1, R = null;
|
|
4749
|
+
const Er = async (s) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (v = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (C && R || (C = !0, R = (async () => {
|
|
4739
4750
|
try {
|
|
4740
|
-
const e =
|
|
4751
|
+
const e = Kt(s ?? {}), t = new gr();
|
|
4741
4752
|
try {
|
|
4742
|
-
|
|
4753
|
+
O.forEach(({ event: o, callback: l }) => {
|
|
4743
4754
|
t.on(o, l);
|
|
4744
|
-
}),
|
|
4755
|
+
}), O.length = 0, M.forEach(({ hook: o, fn: l }) => {
|
|
4745
4756
|
o === "beforeSend" ? t.setTransformer("beforeSend", l) : t.setTransformer("beforeBatch", l);
|
|
4746
|
-
}), M.length = 0,
|
|
4757
|
+
}), M.length = 0, N && (t.setCustomHeaders(N), N = null);
|
|
4747
4758
|
const r = t.init(e), n = new Promise((o, l) => {
|
|
4748
4759
|
setTimeout(() => {
|
|
4749
4760
|
l(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4761,9 +4772,9 @@ const mr = async (s) => {
|
|
|
4761
4772
|
} catch (e) {
|
|
4762
4773
|
throw h = null, e;
|
|
4763
4774
|
} finally {
|
|
4764
|
-
C = !1;
|
|
4775
|
+
C = !1, R = null;
|
|
4765
4776
|
}
|
|
4766
|
-
},
|
|
4777
|
+
})()), R)), Sr = (s, e) => {
|
|
4767
4778
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4768
4779
|
if (!h)
|
|
4769
4780
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4771,25 +4782,25 @@ const mr = async (s) => {
|
|
|
4771
4782
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4772
4783
|
h.sendCustomEvent(s, e);
|
|
4773
4784
|
}
|
|
4774
|
-
},
|
|
4785
|
+
}, pr = (s, e) => {
|
|
4775
4786
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4776
4787
|
if (!h || C) {
|
|
4777
|
-
|
|
4788
|
+
O.push({ event: s, callback: e });
|
|
4778
4789
|
return;
|
|
4779
4790
|
}
|
|
4780
4791
|
h.on(s, e);
|
|
4781
4792
|
}
|
|
4782
|
-
},
|
|
4793
|
+
}, Tr = (s, e) => {
|
|
4783
4794
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4784
4795
|
if (!h) {
|
|
4785
|
-
const t =
|
|
4786
|
-
t !== -1 &&
|
|
4796
|
+
const t = O.findIndex((r) => r.event === s && r.callback === e);
|
|
4797
|
+
t !== -1 && O.splice(t, 1);
|
|
4787
4798
|
return;
|
|
4788
4799
|
}
|
|
4789
4800
|
h.off(s, e);
|
|
4790
4801
|
}
|
|
4791
4802
|
};
|
|
4792
|
-
function
|
|
4803
|
+
function vr(s, e) {
|
|
4793
4804
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4794
4805
|
if (typeof e != "function")
|
|
4795
4806
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
@@ -4803,7 +4814,7 @@ function pr(s, e) {
|
|
|
4803
4814
|
s === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
4804
4815
|
}
|
|
4805
4816
|
}
|
|
4806
|
-
const
|
|
4817
|
+
const Ir = (s) => {
|
|
4807
4818
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4808
4819
|
if (!h) {
|
|
4809
4820
|
const e = M.findIndex((t) => t.hook === s);
|
|
@@ -4814,29 +4825,29 @@ const Tr = (s) => {
|
|
|
4814
4825
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4815
4826
|
h.removeTransformer(s);
|
|
4816
4827
|
}
|
|
4817
|
-
},
|
|
4828
|
+
}, _r = (s) => {
|
|
4818
4829
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4819
4830
|
if (typeof s != "function")
|
|
4820
4831
|
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof s}`);
|
|
4821
4832
|
if (!h || C) {
|
|
4822
|
-
|
|
4833
|
+
N = s;
|
|
4823
4834
|
return;
|
|
4824
4835
|
}
|
|
4825
4836
|
if (v)
|
|
4826
4837
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
4827
4838
|
h.setCustomHeaders(s);
|
|
4828
4839
|
}
|
|
4829
|
-
},
|
|
4840
|
+
}, wr = () => {
|
|
4830
4841
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4831
4842
|
if (!h) {
|
|
4832
|
-
|
|
4843
|
+
N = null;
|
|
4833
4844
|
return;
|
|
4834
4845
|
}
|
|
4835
4846
|
if (v)
|
|
4836
4847
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
4837
4848
|
h.removeCustomHeaders();
|
|
4838
4849
|
}
|
|
4839
|
-
},
|
|
4850
|
+
}, yr = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, br = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Lr = () => {
|
|
4840
4851
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4841
4852
|
if (v)
|
|
4842
4853
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4846,14 +4857,14 @@ const Tr = (s) => {
|
|
|
4846
4857
|
}
|
|
4847
4858
|
v = !0;
|
|
4848
4859
|
try {
|
|
4849
|
-
h.destroy(), h = null, C = !1,
|
|
4860
|
+
h.destroy(), h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, v = !1;
|
|
4850
4861
|
} catch (s) {
|
|
4851
|
-
h = null, C = !1,
|
|
4862
|
+
h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4852
4863
|
}
|
|
4853
4864
|
}
|
|
4854
|
-
},
|
|
4855
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4856
|
-
},
|
|
4865
|
+
}, Ar = (s) => {
|
|
4866
|
+
typeof window > "u" || typeof document > "u" || Ht(s);
|
|
4867
|
+
}, Mr = (s) => {
|
|
4857
4868
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4858
4869
|
if (!h)
|
|
4859
4870
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4861,7 +4872,7 @@ const Tr = (s) => {
|
|
|
4861
4872
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4862
4873
|
h.updateGlobalMetadata(s);
|
|
4863
4874
|
}
|
|
4864
|
-
},
|
|
4875
|
+
}, Cr = (s) => {
|
|
4865
4876
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4866
4877
|
if (!h)
|
|
4867
4878
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4869,36 +4880,36 @@ const Tr = (s) => {
|
|
|
4869
4880
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4870
4881
|
h.mergeGlobalMetadata(s);
|
|
4871
4882
|
}
|
|
4872
|
-
},
|
|
4873
|
-
init:
|
|
4874
|
-
event:
|
|
4875
|
-
on:
|
|
4876
|
-
off:
|
|
4877
|
-
setTransformer:
|
|
4878
|
-
removeTransformer:
|
|
4879
|
-
setCustomHeaders:
|
|
4880
|
-
removeCustomHeaders:
|
|
4881
|
-
isInitialized:
|
|
4882
|
-
getSessionId:
|
|
4883
|
-
destroy:
|
|
4884
|
-
setQaMode:
|
|
4885
|
-
updateGlobalMetadata:
|
|
4886
|
-
mergeGlobalMetadata:
|
|
4883
|
+
}, ts = {
|
|
4884
|
+
init: Er,
|
|
4885
|
+
event: Sr,
|
|
4886
|
+
on: pr,
|
|
4887
|
+
off: Tr,
|
|
4888
|
+
setTransformer: vr,
|
|
4889
|
+
removeTransformer: Ir,
|
|
4890
|
+
setCustomHeaders: _r,
|
|
4891
|
+
removeCustomHeaders: wr,
|
|
4892
|
+
isInitialized: yr,
|
|
4893
|
+
getSessionId: br,
|
|
4894
|
+
destroy: Lr,
|
|
4895
|
+
setQaMode: Ar,
|
|
4896
|
+
updateGlobalMetadata: Mr,
|
|
4897
|
+
mergeGlobalMetadata: Cr
|
|
4887
4898
|
};
|
|
4888
|
-
var
|
|
4899
|
+
var ge, tt = -1, k = function(s) {
|
|
4889
4900
|
addEventListener("pageshow", (function(e) {
|
|
4890
|
-
e.persisted && (
|
|
4901
|
+
e.persisted && (tt = e.timeStamp, s(e));
|
|
4891
4902
|
}), !0);
|
|
4892
|
-
},
|
|
4903
|
+
}, Ie = function() {
|
|
4893
4904
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4894
4905
|
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4895
|
-
},
|
|
4896
|
-
var s =
|
|
4906
|
+
}, Z = function() {
|
|
4907
|
+
var s = Ie();
|
|
4897
4908
|
return s && s.activationStart || 0;
|
|
4898
4909
|
}, b = function(s, e) {
|
|
4899
|
-
var t =
|
|
4900
|
-
return
|
|
4901
|
-
},
|
|
4910
|
+
var t = Ie(), r = "navigate";
|
|
4911
|
+
return tt >= 0 ? r = "back-forward-cache" : t && (document.prerendering || Z() > 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 };
|
|
4912
|
+
}, B = function(s, e, t) {
|
|
4902
4913
|
try {
|
|
4903
4914
|
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4904
4915
|
var r = new PerformanceObserver((function(n) {
|
|
@@ -4917,56 +4928,56 @@ var me, et = -1, D = function(s) {
|
|
|
4917
4928
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4918
4929
|
})(e.value, t), s(e));
|
|
4919
4930
|
};
|
|
4920
|
-
},
|
|
4931
|
+
}, _e = function(s) {
|
|
4921
4932
|
requestAnimationFrame((function() {
|
|
4922
4933
|
return requestAnimationFrame((function() {
|
|
4923
4934
|
return s();
|
|
4924
4935
|
}));
|
|
4925
4936
|
}));
|
|
4926
|
-
},
|
|
4937
|
+
}, ee = function(s) {
|
|
4927
4938
|
document.addEventListener("visibilitychange", (function() {
|
|
4928
4939
|
document.visibilityState === "hidden" && s();
|
|
4929
4940
|
}));
|
|
4930
|
-
},
|
|
4941
|
+
}, we = function(s) {
|
|
4931
4942
|
var e = !1;
|
|
4932
4943
|
return function() {
|
|
4933
4944
|
e || (s(), e = !0);
|
|
4934
4945
|
};
|
|
4935
|
-
},
|
|
4946
|
+
}, D = -1, Be = function() {
|
|
4936
4947
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4937
|
-
},
|
|
4938
|
-
document.visibilityState === "hidden" &&
|
|
4939
|
-
},
|
|
4940
|
-
addEventListener("visibilitychange",
|
|
4941
|
-
},
|
|
4942
|
-
removeEventListener("visibilitychange",
|
|
4943
|
-
},
|
|
4944
|
-
return
|
|
4948
|
+
}, J = function(s) {
|
|
4949
|
+
document.visibilityState === "hidden" && D > -1 && (D = s.type === "visibilitychange" ? s.timeStamp : 0, Rr());
|
|
4950
|
+
}, We = function() {
|
|
4951
|
+
addEventListener("visibilitychange", J, !0), addEventListener("prerenderingchange", J, !0);
|
|
4952
|
+
}, Rr = function() {
|
|
4953
|
+
removeEventListener("visibilitychange", J, !0), removeEventListener("prerenderingchange", J, !0);
|
|
4954
|
+
}, rt = function() {
|
|
4955
|
+
return D < 0 && (D = Be(), We(), k((function() {
|
|
4945
4956
|
setTimeout((function() {
|
|
4946
|
-
|
|
4957
|
+
D = Be(), We();
|
|
4947
4958
|
}), 0);
|
|
4948
4959
|
}))), { get firstHiddenTime() {
|
|
4949
|
-
return
|
|
4960
|
+
return D;
|
|
4950
4961
|
} };
|
|
4951
|
-
},
|
|
4962
|
+
}, te = function(s) {
|
|
4952
4963
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4953
4964
|
return s();
|
|
4954
4965
|
}), !0) : s();
|
|
4955
|
-
},
|
|
4956
|
-
e = e || {},
|
|
4957
|
-
var t, r =
|
|
4966
|
+
}, Ee = [1800, 3e3], st = function(s, e) {
|
|
4967
|
+
e = e || {}, te((function() {
|
|
4968
|
+
var t, r = rt(), n = b("FCP"), i = B("paint", (function(o) {
|
|
4958
4969
|
o.forEach((function(l) {
|
|
4959
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime -
|
|
4970
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime - Z(), 0), n.entries.push(l), t(!0)));
|
|
4960
4971
|
}));
|
|
4961
4972
|
}));
|
|
4962
|
-
i && (t = L(s, n,
|
|
4963
|
-
n = b("FCP"), t = L(s, n,
|
|
4973
|
+
i && (t = L(s, n, Ee, e.reportAllChanges), k((function(o) {
|
|
4974
|
+
n = b("FCP"), t = L(s, n, Ee, e.reportAllChanges), _e((function() {
|
|
4964
4975
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4965
4976
|
}));
|
|
4966
4977
|
})));
|
|
4967
4978
|
}));
|
|
4968
|
-
},
|
|
4969
|
-
e = e || {},
|
|
4979
|
+
}, Se = [0.1, 0.25], Nr = function(s, e) {
|
|
4980
|
+
e = e || {}, st(we((function() {
|
|
4970
4981
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4971
4982
|
c.forEach((function(u) {
|
|
4972
4983
|
if (!u.hadRecentInput) {
|
|
@@ -4974,147 +4985,147 @@ var me, et = -1, D = function(s) {
|
|
|
4974
4985
|
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
4975
4986
|
}
|
|
4976
4987
|
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4977
|
-
}, l =
|
|
4978
|
-
l && (t = L(s, r,
|
|
4988
|
+
}, l = B("layout-shift", o);
|
|
4989
|
+
l && (t = L(s, r, Se, e.reportAllChanges), ee((function() {
|
|
4979
4990
|
o(l.takeRecords()), t(!0);
|
|
4980
|
-
})),
|
|
4981
|
-
n = 0, r = b("CLS", 0), t = L(s, r,
|
|
4991
|
+
})), k((function() {
|
|
4992
|
+
n = 0, r = b("CLS", 0), t = L(s, r, Se, e.reportAllChanges), _e((function() {
|
|
4982
4993
|
return t();
|
|
4983
4994
|
}));
|
|
4984
4995
|
})), setTimeout(t, 0));
|
|
4985
4996
|
})));
|
|
4986
|
-
},
|
|
4997
|
+
}, nt = 0, oe = 1 / 0, Q = 0, Or = function(s) {
|
|
4987
4998
|
s.forEach((function(e) {
|
|
4988
|
-
e.interactionId && (
|
|
4999
|
+
e.interactionId && (oe = Math.min(oe, e.interactionId), Q = Math.max(Q, e.interactionId), nt = Q ? (Q - oe) / 7 + 1 : 0);
|
|
4989
5000
|
}));
|
|
4990
|
-
},
|
|
4991
|
-
return
|
|
4992
|
-
},
|
|
4993
|
-
"interactionCount" in performance ||
|
|
4994
|
-
}, y = [],
|
|
4995
|
-
var s = Math.min(y.length - 1, Math.floor((
|
|
5001
|
+
}, it = function() {
|
|
5002
|
+
return ge ? nt : performance.interactionCount || 0;
|
|
5003
|
+
}, Pr = function() {
|
|
5004
|
+
"interactionCount" in performance || ge || (ge = B("event", Or, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5005
|
+
}, y = [], K = /* @__PURE__ */ new Map(), ot = 0, Dr = function() {
|
|
5006
|
+
var s = Math.min(y.length - 1, Math.floor((it() - ot) / 50));
|
|
4996
5007
|
return y[s];
|
|
4997
|
-
},
|
|
4998
|
-
if (
|
|
5008
|
+
}, kr = [], Vr = function(s) {
|
|
5009
|
+
if (kr.forEach((function(n) {
|
|
4999
5010
|
return n(s);
|
|
5000
5011
|
})), s.interactionId || s.entryType === "first-input") {
|
|
5001
|
-
var e = y[y.length - 1], t =
|
|
5012
|
+
var e = y[y.length - 1], t = K.get(s.interactionId);
|
|
5002
5013
|
if (t || y.length < 10 || s.duration > e.latency) {
|
|
5003
5014
|
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);
|
|
5004
5015
|
else {
|
|
5005
5016
|
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
5006
|
-
|
|
5017
|
+
K.set(r.id, r), y.push(r);
|
|
5007
5018
|
}
|
|
5008
5019
|
y.sort((function(n, i) {
|
|
5009
5020
|
return i.latency - n.latency;
|
|
5010
5021
|
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
5011
|
-
return
|
|
5022
|
+
return K.delete(n.id);
|
|
5012
5023
|
}));
|
|
5013
5024
|
}
|
|
5014
5025
|
}
|
|
5015
|
-
},
|
|
5026
|
+
}, at = function(s) {
|
|
5016
5027
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5017
|
-
return s =
|
|
5018
|
-
},
|
|
5019
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
5028
|
+
return s = we(s), document.visibilityState === "hidden" ? s() : (t = e(s), ee(s)), t;
|
|
5029
|
+
}, pe = [200, 500], Ur = function(s, e) {
|
|
5030
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, te((function() {
|
|
5020
5031
|
var t;
|
|
5021
|
-
|
|
5032
|
+
Pr();
|
|
5022
5033
|
var r, n = b("INP"), i = function(l) {
|
|
5023
|
-
|
|
5024
|
-
l.forEach(
|
|
5025
|
-
var c =
|
|
5034
|
+
at((function() {
|
|
5035
|
+
l.forEach(Vr);
|
|
5036
|
+
var c = Dr();
|
|
5026
5037
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
5027
5038
|
}));
|
|
5028
|
-
}, o =
|
|
5029
|
-
r = L(s, n,
|
|
5039
|
+
}, o = B("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5040
|
+
r = L(s, n, pe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), ee((function() {
|
|
5030
5041
|
i(o.takeRecords()), r(!0);
|
|
5031
|
-
})),
|
|
5032
|
-
|
|
5042
|
+
})), k((function() {
|
|
5043
|
+
ot = it(), y.length = 0, K.clear(), n = b("INP"), r = L(s, n, pe, e.reportAllChanges);
|
|
5033
5044
|
})));
|
|
5034
5045
|
})));
|
|
5035
|
-
},
|
|
5036
|
-
e = e || {},
|
|
5037
|
-
var t, r =
|
|
5046
|
+
}, Te = [2500, 4e3], ae = {}, Hr = function(s, e) {
|
|
5047
|
+
e = e || {}, te((function() {
|
|
5048
|
+
var t, r = rt(), n = b("LCP"), i = function(c) {
|
|
5038
5049
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
5039
|
-
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime -
|
|
5050
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - Z(), 0), n.entries = [u], t());
|
|
5040
5051
|
}));
|
|
5041
|
-
}, o =
|
|
5052
|
+
}, o = B("largest-contentful-paint", i);
|
|
5042
5053
|
if (o) {
|
|
5043
|
-
t = L(s, n,
|
|
5044
|
-
var l =
|
|
5045
|
-
|
|
5054
|
+
t = L(s, n, Te, e.reportAllChanges);
|
|
5055
|
+
var l = we((function() {
|
|
5056
|
+
ae[n.id] || (i(o.takeRecords()), o.disconnect(), ae[n.id] = !0, t(!0));
|
|
5046
5057
|
}));
|
|
5047
5058
|
["keydown", "click"].forEach((function(c) {
|
|
5048
5059
|
addEventListener(c, (function() {
|
|
5049
|
-
return
|
|
5060
|
+
return at(l);
|
|
5050
5061
|
}), { once: !0, capture: !0 });
|
|
5051
|
-
})),
|
|
5052
|
-
n = b("LCP"), t = L(s, n,
|
|
5053
|
-
n.value = performance.now() - c.timeStamp,
|
|
5062
|
+
})), ee(l), k((function(c) {
|
|
5063
|
+
n = b("LCP"), t = L(s, n, Te, e.reportAllChanges), _e((function() {
|
|
5064
|
+
n.value = performance.now() - c.timeStamp, ae[n.id] = !0, t(!0);
|
|
5054
5065
|
}));
|
|
5055
5066
|
}));
|
|
5056
5067
|
}
|
|
5057
5068
|
}));
|
|
5058
|
-
},
|
|
5059
|
-
document.prerendering ?
|
|
5069
|
+
}, ve = [800, 1800], xr = function s(e) {
|
|
5070
|
+
document.prerendering ? te((function() {
|
|
5060
5071
|
return s(e);
|
|
5061
5072
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5062
5073
|
return s(e);
|
|
5063
5074
|
}), !0) : setTimeout(e, 0);
|
|
5064
|
-
},
|
|
5075
|
+
}, $r = function(s, e) {
|
|
5065
5076
|
e = e || {};
|
|
5066
|
-
var t = b("TTFB"), r = L(s, t,
|
|
5067
|
-
|
|
5068
|
-
var n =
|
|
5069
|
-
n && (t.value = Math.max(n.responseStart -
|
|
5070
|
-
t = b("TTFB", 0), (r = L(s, t,
|
|
5077
|
+
var t = b("TTFB"), r = L(s, t, ve, e.reportAllChanges);
|
|
5078
|
+
xr((function() {
|
|
5079
|
+
var n = Ie();
|
|
5080
|
+
n && (t.value = Math.max(n.responseStart - Z(), 0), t.entries = [n], r(!0), k((function() {
|
|
5081
|
+
t = b("TTFB", 0), (r = L(s, t, ve, e.reportAllChanges))(!0);
|
|
5071
5082
|
})));
|
|
5072
5083
|
}));
|
|
5073
5084
|
};
|
|
5074
|
-
const
|
|
5085
|
+
const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5075
5086
|
__proto__: null,
|
|
5076
|
-
CLSThresholds:
|
|
5077
|
-
FCPThresholds:
|
|
5078
|
-
INPThresholds:
|
|
5079
|
-
LCPThresholds:
|
|
5080
|
-
TTFBThresholds:
|
|
5081
|
-
onCLS:
|
|
5082
|
-
onFCP:
|
|
5083
|
-
onINP:
|
|
5084
|
-
onLCP:
|
|
5085
|
-
onTTFB:
|
|
5087
|
+
CLSThresholds: Se,
|
|
5088
|
+
FCPThresholds: Ee,
|
|
5089
|
+
INPThresholds: pe,
|
|
5090
|
+
LCPThresholds: Te,
|
|
5091
|
+
TTFBThresholds: ve,
|
|
5092
|
+
onCLS: Nr,
|
|
5093
|
+
onFCP: st,
|
|
5094
|
+
onINP: Ur,
|
|
5095
|
+
onLCP: Hr,
|
|
5096
|
+
onTTFB: $r
|
|
5086
5097
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5087
5098
|
export {
|
|
5088
5099
|
f as AppConfigValidationError,
|
|
5089
|
-
|
|
5090
|
-
|
|
5100
|
+
Br as DEFAULT_SESSION_TIMEOUT,
|
|
5101
|
+
de as DEFAULT_WEB_VITALS_MODE,
|
|
5091
5102
|
A as DeviceType,
|
|
5092
|
-
|
|
5093
|
-
|
|
5103
|
+
le as EmitterEvent,
|
|
5104
|
+
x as ErrorType,
|
|
5094
5105
|
d as EventType,
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5106
|
+
Zr as InitializationTimeoutError,
|
|
5107
|
+
U as IntegrationValidationError,
|
|
5108
|
+
Yr as MAX_ARRAY_LENGTH,
|
|
5109
|
+
Qr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5110
|
+
Xr as MAX_CUSTOM_EVENT_KEYS,
|
|
5111
|
+
Wr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5112
|
+
Gr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5113
|
+
jr as MAX_NESTED_OBJECT_KEYS,
|
|
5114
|
+
zr as MAX_STRING_LENGTH,
|
|
5115
|
+
Kr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5116
|
+
Y as Mode,
|
|
5117
|
+
ze as PII_PATTERNS,
|
|
5118
|
+
P as PermanentError,
|
|
5119
|
+
Oe as SamplingRateValidationError,
|
|
5120
|
+
j as ScrollDirection,
|
|
5121
|
+
gt as SessionTimeoutValidationError,
|
|
5122
|
+
H as SpecialApiUrl,
|
|
5112
5123
|
F as TraceLogValidationError,
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5124
|
+
es as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5125
|
+
Ve as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5126
|
+
Nt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5127
|
+
Ue as getWebVitalsThresholds,
|
|
5128
|
+
qr as isPrimaryScrollEvent,
|
|
5129
|
+
Jr as isSecondaryScrollEvent,
|
|
5130
|
+
ts as tracelog
|
|
5120
5131
|
};
|