@tracelog/lib 2.3.1 → 2.4.0
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 +448 -430
- 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 -6717
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +13 -9
- package/dist/public-api.d.ts +13 -9
- package/dist/public-api.js +2 -6684
- 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",
|
|
@@ -70,54 +70,55 @@ const m = {
|
|
|
70
70
|
INVALID_VIEWPORT_THRESHOLD: "Viewport threshold must be a number between 0 and 1",
|
|
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
|
-
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
|
|
73
|
+
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number",
|
|
74
|
+
INVALID_SEND_INTERVAL: "Send interval must be between 1000ms (1 second) and 60000ms (60 seconds)"
|
|
75
|
+
}, dt = [
|
|
75
76
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
76
77
|
/javascript:/gi,
|
|
77
78
|
/on\w+\s*=/gi,
|
|
78
79
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
79
80
|
/<embed\b[^>]*>/gi,
|
|
80
81
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
81
|
-
],
|
|
82
|
-
var
|
|
83
|
-
class
|
|
82
|
+
], I = "tlog", F = `${I}:qa_mode`, be = `${I}:uid`, Ge = "tlog_mode", Le = "qa", Ae = "qa_off", ht = (s) => s ? `${I}:${s}:queue` : `${I}:queue`, ft = (s) => s ? `${I}:${s}:session` : `${I}:session`, mt = (s) => s ? `${I}:${s}:broadcast` : `${I}:broadcast`, Me = (s, e) => `${I}:${s}:session_counts:${e}`, Ce = 10080 * 60 * 1e3, Re = `${I}:session_counts_last_cleanup`, Ne = 3600 * 1e3;
|
|
83
|
+
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 || {});
|
|
84
|
+
class P extends Error {
|
|
84
85
|
constructor(e, t) {
|
|
85
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
86
|
+
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, P);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
var d = /* @__PURE__ */ ((s) => (s.PAGE_VIEW = "page_view", s.CLICK = "click", s.SCROLL = "scroll", s.SESSION_START = "session_start", s.CUSTOM = "custom", s.WEB_VITALS = "web_vitals", s.ERROR = "error", s.VIEWPORT_VISIBLE = "viewport_visible", s))(d || {}),
|
|
89
|
-
const
|
|
90
|
-
class
|
|
89
|
+
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 || {});
|
|
90
|
+
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;
|
|
91
|
+
class $ extends Error {
|
|
91
92
|
constructor(e, t, r) {
|
|
92
93
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
class f extends
|
|
96
|
+
class f extends $ {
|
|
96
97
|
constructor(e, t = "config") {
|
|
97
98
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
class
|
|
101
|
+
class gt extends $ {
|
|
101
102
|
constructor(e, t = "config") {
|
|
102
103
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
class
|
|
106
|
+
class Oe extends $ {
|
|
106
107
|
constructor(e, t = "config") {
|
|
107
108
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
class
|
|
111
|
+
class U extends $ {
|
|
111
112
|
constructor(e, t = "config") {
|
|
112
113
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
class
|
|
116
|
+
class Zr extends $ {
|
|
116
117
|
constructor(e, t, r = "runtime") {
|
|
117
118
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
const
|
|
121
|
+
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
122
|
if (e) {
|
|
122
123
|
if (e instanceof Error) {
|
|
123
124
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -136,24 +137,24 @@ const Ge = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
136
137
|
return `[TraceLog] ${s}: ${String(e)}`;
|
|
137
138
|
}
|
|
138
139
|
return `[TraceLog] ${s}`;
|
|
139
|
-
},
|
|
140
|
+
}, pt = () => {
|
|
140
141
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
142
|
return !1;
|
|
142
143
|
try {
|
|
143
|
-
return sessionStorage.getItem(
|
|
144
|
+
return sessionStorage.getItem(F) === "true";
|
|
144
145
|
} catch {
|
|
145
146
|
return !1;
|
|
146
147
|
}
|
|
147
148
|
}, a = (s, e, t) => {
|
|
148
|
-
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ?
|
|
149
|
-
if (!
|
|
149
|
+
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";
|
|
150
|
+
if (!Tt(l, i))
|
|
150
151
|
return;
|
|
151
|
-
const g =
|
|
152
|
+
const g = _t(l, o), p = n !== void 0 ? ce(n) : void 0;
|
|
152
153
|
vt(u, c, g, p);
|
|
153
|
-
},
|
|
154
|
+
}, Tt = (s, e) => s === "critical" ? !0 : s === "qa" || e ? pt() : !1, _t = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? Et : "", vt = (s, e, t, r) => {
|
|
154
155
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
155
156
|
r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
|
|
156
|
-
},
|
|
157
|
+
}, ce = (s) => {
|
|
157
158
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
158
159
|
for (const [r, n] of Object.entries(s)) {
|
|
159
160
|
const i = r.toLowerCase();
|
|
@@ -161,16 +162,16 @@ const Ge = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
161
162
|
e[r] = "[REDACTED]";
|
|
162
163
|
continue;
|
|
163
164
|
}
|
|
164
|
-
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] =
|
|
165
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
165
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] = ce(n) : Array.isArray(n) ? e[r] = n.map(
|
|
166
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ce(o) : o
|
|
166
167
|
) : e[r] = n;
|
|
167
168
|
}
|
|
168
169
|
return e;
|
|
169
170
|
};
|
|
170
|
-
let
|
|
171
|
+
let ue, je;
|
|
171
172
|
const It = () => {
|
|
172
|
-
typeof window < "u" && !
|
|
173
|
-
},
|
|
173
|
+
typeof window < "u" && !ue && (ue = window.matchMedia("(pointer: coarse)"), je = window.matchMedia("(hover: none)"));
|
|
174
|
+
}, q = "Unknown", wt = (s) => {
|
|
174
175
|
const e = s.userAgentData?.platform;
|
|
175
176
|
if (e != null && e !== "") {
|
|
176
177
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -181,8 +182,8 @@ const It = () => {
|
|
|
181
182
|
if (/ios/i.test(e)) return "iOS";
|
|
182
183
|
}
|
|
183
184
|
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
|
-
},
|
|
185
|
+
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;
|
|
186
|
+
}, yt = (s) => {
|
|
186
187
|
const e = s.userAgentData?.brands;
|
|
187
188
|
if (e != null && e.length > 0) {
|
|
188
189
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -192,8 +193,8 @@ const It = () => {
|
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
195
|
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
|
-
},
|
|
196
|
+
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;
|
|
197
|
+
}, bt = () => {
|
|
197
198
|
try {
|
|
198
199
|
const s = navigator;
|
|
199
200
|
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
@@ -201,27 +202,27 @@ const It = () => {
|
|
|
201
202
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? A.Tablet : s.userAgentData.mobile ? A.Mobile : A.Desktop;
|
|
202
203
|
}
|
|
203
204
|
It();
|
|
204
|
-
const e = window.innerWidth, t =
|
|
205
|
+
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
206
|
return e <= 767 || o && n ? A.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? A.Tablet : A.Desktop;
|
|
206
207
|
} catch (s) {
|
|
207
208
|
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), A.Desktop;
|
|
208
209
|
}
|
|
209
|
-
},
|
|
210
|
+
}, Lt = () => {
|
|
210
211
|
try {
|
|
211
212
|
const s = navigator;
|
|
212
213
|
return {
|
|
213
|
-
type:
|
|
214
|
-
os:
|
|
215
|
-
browser:
|
|
214
|
+
type: bt(),
|
|
215
|
+
os: wt(s),
|
|
216
|
+
browser: yt(s)
|
|
216
217
|
};
|
|
217
218
|
} catch (s) {
|
|
218
219
|
return a("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
219
220
|
type: A.Desktop,
|
|
220
|
-
os:
|
|
221
|
-
browser:
|
|
221
|
+
os: q,
|
|
222
|
+
browser: q
|
|
222
223
|
};
|
|
223
224
|
}
|
|
224
|
-
},
|
|
225
|
+
}, ze = [
|
|
225
226
|
// Email addresses
|
|
226
227
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
227
228
|
// US Phone numbers (various formats)
|
|
@@ -236,7 +237,7 @@ const It = () => {
|
|
|
236
237
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
237
238
|
// Passwords in connection strings (protocol://user:password@host)
|
|
238
239
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
239
|
-
],
|
|
240
|
+
], Pe = 500, De = 5e3, z = 50, At = z * 2, Ke = 1, Mt = 1e3, Ct = 10, Ve = 5e3, Rt = 6e4, es = {
|
|
240
241
|
LCP: 2500,
|
|
241
242
|
// Good: ≤ 2.5s
|
|
242
243
|
FCP: 1800,
|
|
@@ -260,7 +261,7 @@ const It = () => {
|
|
|
260
261
|
TTFB: 800,
|
|
261
262
|
// Needs improvement: > 800ms
|
|
262
263
|
LONG_TASK: 50
|
|
263
|
-
},
|
|
264
|
+
}, Nt = {
|
|
264
265
|
LCP: 4e3,
|
|
265
266
|
// Poor: > 4s
|
|
266
267
|
FCP: 3e3,
|
|
@@ -272,7 +273,7 @@ const It = () => {
|
|
|
272
273
|
TTFB: 1800,
|
|
273
274
|
// Poor: > 1800ms
|
|
274
275
|
LONG_TASK: 50
|
|
275
|
-
},
|
|
276
|
+
}, de = "needs-improvement", Ue = (s = de) => {
|
|
276
277
|
switch (s) {
|
|
277
278
|
case "all":
|
|
278
279
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
@@ -280,45 +281,45 @@ const It = () => {
|
|
|
280
281
|
case "needs-improvement":
|
|
281
282
|
return ke;
|
|
282
283
|
case "poor":
|
|
283
|
-
return
|
|
284
|
+
return Nt;
|
|
284
285
|
default:
|
|
285
286
|
return ke;
|
|
286
287
|
}
|
|
287
|
-
},
|
|
288
|
+
}, Ot = 1e3, Pt = 50, Dt = "2.3.1", Vt = Dt, Ye = () => typeof window < "u" && typeof sessionStorage < "u", kt = () => {
|
|
288
289
|
try {
|
|
289
290
|
const s = new URLSearchParams(window.location.search);
|
|
290
|
-
s.delete(
|
|
291
|
+
s.delete(Ge);
|
|
291
292
|
const e = s.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
292
293
|
window.history.replaceState({}, "", t);
|
|
293
294
|
} catch {
|
|
294
295
|
}
|
|
295
|
-
},
|
|
296
|
-
if (!
|
|
296
|
+
}, Ut = () => {
|
|
297
|
+
if (!Ye())
|
|
297
298
|
return !1;
|
|
298
299
|
try {
|
|
299
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
300
|
+
const e = new URLSearchParams(window.location.search).get(Ge), t = sessionStorage.getItem(F);
|
|
300
301
|
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", {
|
|
302
|
+
return e === Le ? (r = !0, sessionStorage.setItem(F, "true"), a("info", "QA Mode ACTIVE", {
|
|
305
303
|
visibility: "qa",
|
|
306
304
|
style: Xe
|
|
307
|
-
}))
|
|
305
|
+
})) : e === Ae && (r = !1, sessionStorage.setItem(F, "false"), a("info", "QA Mode DISABLED", {
|
|
306
|
+
visibility: "qa",
|
|
307
|
+
style: Qe
|
|
308
|
+
})), (e === Le || e === Ae) && kt(), r ?? t === "true";
|
|
308
309
|
} catch {
|
|
309
310
|
return !1;
|
|
310
311
|
}
|
|
311
|
-
},
|
|
312
|
-
if (
|
|
312
|
+
}, Ht = (s) => {
|
|
313
|
+
if (Ye())
|
|
313
314
|
try {
|
|
314
|
-
sessionStorage.setItem(
|
|
315
|
+
sessionStorage.setItem(F, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
316
|
visibility: "qa",
|
|
316
|
-
style: s ?
|
|
317
|
+
style: s ? Xe : Qe
|
|
317
318
|
});
|
|
318
319
|
} catch {
|
|
319
320
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
321
|
}
|
|
321
|
-
},
|
|
322
|
+
}, xt = [
|
|
322
323
|
"co.uk",
|
|
323
324
|
"org.uk",
|
|
324
325
|
"com.au",
|
|
@@ -330,40 +331,40 @@ const It = () => {
|
|
|
330
331
|
"co.in",
|
|
331
332
|
"com.cn",
|
|
332
333
|
"co.za"
|
|
333
|
-
],
|
|
334
|
+
], He = (s) => {
|
|
334
335
|
const e = s.toLowerCase().split(".");
|
|
335
336
|
if (e.length <= 2)
|
|
336
337
|
return s.toLowerCase();
|
|
337
338
|
const t = e.slice(-2).join(".");
|
|
338
|
-
return
|
|
339
|
-
},
|
|
339
|
+
return xt.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
340
|
+
}, Ft = (s, e) => s === e ? !0 : He(s) === He(e), se = () => {
|
|
340
341
|
const s = document.referrer;
|
|
341
342
|
if (!s)
|
|
342
343
|
return "Direct";
|
|
343
344
|
try {
|
|
344
345
|
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
345
|
-
return
|
|
346
|
+
return Ft(e, t) ? "Direct" : s;
|
|
346
347
|
} catch (e) {
|
|
347
348
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
348
349
|
}
|
|
349
|
-
},
|
|
350
|
+
}, ne = () => {
|
|
350
351
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
351
|
-
return
|
|
352
|
+
return ct.forEach((r) => {
|
|
352
353
|
const n = s.get(r);
|
|
353
354
|
if (n) {
|
|
354
355
|
const i = r.split("utm_")[1];
|
|
355
356
|
e[i] = n;
|
|
356
357
|
}
|
|
357
358
|
}), Object.keys(e).length ? e : void 0;
|
|
358
|
-
},
|
|
359
|
+
}, $t = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
359
360
|
const e = Math.random() * 16 | 0;
|
|
360
361
|
return (s === "x" ? e : e & 3 | 8).toString(16);
|
|
361
362
|
});
|
|
362
|
-
let
|
|
363
|
-
const
|
|
363
|
+
let G = 0, X = 0;
|
|
364
|
+
const Bt = () => {
|
|
364
365
|
let s = Date.now();
|
|
365
|
-
s <
|
|
366
|
-
const e =
|
|
366
|
+
s < X && (s = X), s === X ? G = (G + 1) % 1e3 : G = 0, X = s;
|
|
367
|
+
const e = G.toString().padStart(3, "0");
|
|
367
368
|
let t = "";
|
|
368
369
|
try {
|
|
369
370
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -373,14 +374,14 @@ const $t = () => {
|
|
|
373
374
|
} catch {
|
|
374
375
|
}
|
|
375
376
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${s}-${e}-${t}`;
|
|
376
|
-
},
|
|
377
|
+
}, qe = (s, e = !1) => {
|
|
377
378
|
try {
|
|
378
379
|
const t = new URL(s), r = t.protocol === "https:", n = t.protocol === "http:";
|
|
379
380
|
return r || e && n;
|
|
380
381
|
} catch {
|
|
381
382
|
return !1;
|
|
382
383
|
}
|
|
383
|
-
},
|
|
384
|
+
}, Wt = (s) => {
|
|
384
385
|
try {
|
|
385
386
|
const t = new URL(window.location.href).hostname;
|
|
386
387
|
if (!t || typeof t != "string")
|
|
@@ -398,28 +399,28 @@ const $t = () => {
|
|
|
398
399
|
if (r.length === 2 ? n = r.join(".") : n = r.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
399
400
|
throw new Error("Invalid domain structure for SaaS");
|
|
400
401
|
const i = `https://${s}.${n}/collect`;
|
|
401
|
-
if (!
|
|
402
|
+
if (!qe(i))
|
|
402
403
|
throw new Error("Generated URL failed validation");
|
|
403
404
|
return i;
|
|
404
405
|
} catch (e) {
|
|
405
406
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
406
407
|
}
|
|
407
|
-
},
|
|
408
|
+
}, Gt = (s) => {
|
|
408
409
|
const e = {};
|
|
409
|
-
s.integrations?.tracelog?.projectId && (e.saas =
|
|
410
|
+
s.integrations?.tracelog?.projectId && (e.saas = Wt(s.integrations.tracelog.projectId));
|
|
410
411
|
const t = s.integrations?.custom?.collectApiUrl;
|
|
411
412
|
if (t) {
|
|
412
413
|
const r = s.integrations?.custom?.allowHttp ?? !1;
|
|
413
|
-
if (!
|
|
414
|
+
if (!qe(t, r))
|
|
414
415
|
throw new Error("Invalid custom API URL");
|
|
415
416
|
e.custom = t;
|
|
416
417
|
}
|
|
417
418
|
return e;
|
|
418
|
-
},
|
|
419
|
+
}, he = (s, e = []) => {
|
|
419
420
|
if (!s || typeof s != "string")
|
|
420
421
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof s } }), s || "";
|
|
421
422
|
try {
|
|
422
|
-
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
423
|
+
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...ut, ...e])];
|
|
423
424
|
let i = !1;
|
|
424
425
|
const o = [];
|
|
425
426
|
return n.forEach((c) => {
|
|
@@ -428,13 +429,13 @@ const $t = () => {
|
|
|
428
429
|
} catch (t) {
|
|
429
430
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
430
431
|
}
|
|
431
|
-
},
|
|
432
|
+
}, xe = (s) => {
|
|
432
433
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
433
434
|
return "";
|
|
434
435
|
let e = s;
|
|
435
436
|
s.length > 1e3 && (e = s.slice(0, Math.max(0, 1e3)));
|
|
436
437
|
let t = 0;
|
|
437
|
-
for (const n of
|
|
438
|
+
for (const n of dt) {
|
|
438
439
|
const i = e;
|
|
439
440
|
e = e.replace(n, ""), i !== e && t++;
|
|
440
441
|
}
|
|
@@ -444,11 +445,11 @@ const $t = () => {
|
|
|
444
445
|
valueLength: s.length
|
|
445
446
|
}
|
|
446
447
|
}), e.trim();
|
|
447
|
-
},
|
|
448
|
+
}, fe = (s, e = 0) => {
|
|
448
449
|
if (s == null)
|
|
449
450
|
return null;
|
|
450
451
|
if (typeof s == "string")
|
|
451
|
-
return
|
|
452
|
+
return xe(s);
|
|
452
453
|
if (typeof s == "number")
|
|
453
454
|
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
454
455
|
if (typeof s == "boolean")
|
|
@@ -456,38 +457,38 @@ const $t = () => {
|
|
|
456
457
|
if (e > 10)
|
|
457
458
|
return null;
|
|
458
459
|
if (Array.isArray(s))
|
|
459
|
-
return s.slice(0, 100).map((n) =>
|
|
460
|
+
return s.slice(0, 100).map((n) => fe(n, e + 1)).filter((n) => n !== null);
|
|
460
461
|
if (typeof s == "object") {
|
|
461
462
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
462
463
|
for (const [i, o] of n) {
|
|
463
|
-
const l =
|
|
464
|
+
const l = xe(i);
|
|
464
465
|
if (l) {
|
|
465
|
-
const c =
|
|
466
|
+
const c = fe(o, e + 1);
|
|
466
467
|
c !== null && (t[l] = c);
|
|
467
468
|
}
|
|
468
469
|
}
|
|
469
470
|
return t;
|
|
470
471
|
}
|
|
471
472
|
return null;
|
|
472
|
-
},
|
|
473
|
+
}, Xt = (s) => {
|
|
473
474
|
if (typeof s != "object" || s === null)
|
|
474
475
|
return {};
|
|
475
476
|
try {
|
|
476
|
-
const e =
|
|
477
|
+
const e = fe(s);
|
|
477
478
|
return typeof e == "object" && e !== null ? e : {};
|
|
478
479
|
} catch (e) {
|
|
479
480
|
const t = e instanceof Error ? e.message : String(e);
|
|
480
481
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
481
482
|
}
|
|
482
|
-
},
|
|
483
|
+
}, Qt = (s) => {
|
|
483
484
|
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
484
485
|
throw new f("Configuration must be an object", "config");
|
|
485
486
|
if (s) {
|
|
486
487
|
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
487
|
-
throw new
|
|
488
|
+
throw new gt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
488
489
|
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
489
490
|
throw new f(m.INVALID_GLOBAL_METADATA, "config");
|
|
490
|
-
if (s.integrations &&
|
|
491
|
+
if (s.integrations && zt(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
491
492
|
if (!Array.isArray(s.sensitiveQueryParams))
|
|
492
493
|
throw new f(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
493
494
|
for (const e of s.sensitiveQueryParams)
|
|
@@ -495,9 +496,9 @@ const $t = () => {
|
|
|
495
496
|
throw new f("All sensitive query params must be strings", "config");
|
|
496
497
|
}
|
|
497
498
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
498
|
-
throw new
|
|
499
|
+
throw new Oe(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
499
500
|
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
500
|
-
throw new
|
|
501
|
+
throw new Oe(m.INVALID_SAMPLING_RATE, "config");
|
|
501
502
|
if (s.primaryScrollSelector !== void 0) {
|
|
502
503
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
503
504
|
throw new f(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -517,7 +518,9 @@ const $t = () => {
|
|
|
517
518
|
throw new f(m.INVALID_CLICK_THROTTLE, "config");
|
|
518
519
|
if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
|
|
519
520
|
throw new f(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
520
|
-
if (s.
|
|
521
|
+
if (s.sendIntervalMs !== void 0 && (!Number.isFinite(s.sendIntervalMs) || s.sendIntervalMs < 1e3 || s.sendIntervalMs > 6e4))
|
|
522
|
+
throw new f(m.INVALID_SEND_INTERVAL, "config");
|
|
523
|
+
if (s.viewport !== void 0 && jt(s.viewport), s.webVitalsMode !== void 0) {
|
|
521
524
|
if (typeof s.webVitalsMode != "string")
|
|
522
525
|
throw new f(
|
|
523
526
|
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
@@ -548,7 +551,7 @@ const $t = () => {
|
|
|
548
551
|
}
|
|
549
552
|
}
|
|
550
553
|
}
|
|
551
|
-
},
|
|
554
|
+
}, jt = (s) => {
|
|
552
555
|
if (typeof s != "object" || s === null)
|
|
553
556
|
throw new f(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
554
557
|
if (!s.elements || !Array.isArray(s.elements))
|
|
@@ -578,37 +581,38 @@ const $t = () => {
|
|
|
578
581
|
throw new f(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
579
582
|
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
580
583
|
throw new f(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
581
|
-
},
|
|
584
|
+
}, zt = (s) => {
|
|
582
585
|
if (s) {
|
|
583
586
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
584
|
-
throw new
|
|
587
|
+
throw new U(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
585
588
|
if (s.custom) {
|
|
586
589
|
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
587
|
-
throw new
|
|
590
|
+
throw new U(m.INVALID_CUSTOM_API_URL, "config");
|
|
588
591
|
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
589
|
-
throw new
|
|
592
|
+
throw new U("allowHttp must be a boolean", "config");
|
|
590
593
|
const e = s.custom.collectApiUrl.trim();
|
|
591
594
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
592
|
-
throw new
|
|
595
|
+
throw new U('Custom API URL must start with "http://" or "https://"', "config");
|
|
593
596
|
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
594
|
-
throw new
|
|
597
|
+
throw new U(
|
|
595
598
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
596
599
|
"config"
|
|
597
600
|
);
|
|
598
601
|
}
|
|
599
602
|
}
|
|
600
|
-
},
|
|
601
|
-
|
|
603
|
+
}, Kt = (s) => {
|
|
604
|
+
Qt(s);
|
|
602
605
|
const e = {
|
|
603
606
|
...s ?? {},
|
|
604
607
|
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
605
608
|
globalMetadata: s?.globalMetadata ?? {},
|
|
606
609
|
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
607
|
-
errorSampling: s?.errorSampling ??
|
|
610
|
+
errorSampling: s?.errorSampling ?? Ke,
|
|
608
611
|
samplingRate: s?.samplingRate ?? 1,
|
|
609
612
|
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
610
613
|
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
611
|
-
maxSameEventPerMinute: s?.maxSameEventPerMinute ?? 60
|
|
614
|
+
maxSameEventPerMinute: s?.maxSameEventPerMinute ?? 60,
|
|
615
|
+
sendIntervalMs: s?.sendIntervalMs ?? 1e4
|
|
612
616
|
};
|
|
613
617
|
return e.integrations?.custom && (e.integrations.custom = {
|
|
614
618
|
...e.integrations.custom,
|
|
@@ -620,12 +624,12 @@ const $t = () => {
|
|
|
620
624
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
621
625
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
622
626
|
}), e;
|
|
623
|
-
},
|
|
627
|
+
}, me = (s, e = /* @__PURE__ */ new Set()) => {
|
|
624
628
|
if (s == null)
|
|
625
629
|
return !0;
|
|
626
630
|
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
|
-
},
|
|
631
|
+
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);
|
|
632
|
+
}, Yt = (s) => typeof s != "object" || s === null ? !1 : me(s), qt = (s) => typeof s != "string" ? {
|
|
629
633
|
valid: !1,
|
|
630
634
|
error: "Event name must be a string"
|
|
631
635
|
} : s.length === 0 ? {
|
|
@@ -640,9 +644,9 @@ const $t = () => {
|
|
|
640
644
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
641
645
|
valid: !1,
|
|
642
646
|
error: "Event name cannot be a reserved word"
|
|
643
|
-
} : { valid: !0 },
|
|
644
|
-
const r =
|
|
645
|
-
if (!
|
|
647
|
+
} : { valid: !0 }, Fe = (s, e, t) => {
|
|
648
|
+
const r = Xt(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
649
|
+
if (!Yt(r))
|
|
646
650
|
return {
|
|
647
651
|
valid: !1,
|
|
648
652
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -690,7 +694,7 @@ const $t = () => {
|
|
|
690
694
|
valid: !0,
|
|
691
695
|
sanitizedMetadata: r
|
|
692
696
|
};
|
|
693
|
-
},
|
|
697
|
+
}, Je = (s, e, t) => {
|
|
694
698
|
if (Array.isArray(e)) {
|
|
695
699
|
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
696
700
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -700,7 +704,7 @@ const $t = () => {
|
|
|
700
704
|
valid: !1,
|
|
701
705
|
error: `${n}: array item at index ${i} must be an object.`
|
|
702
706
|
};
|
|
703
|
-
const l =
|
|
707
|
+
const l = Fe(s, o, t);
|
|
704
708
|
if (!l.valid)
|
|
705
709
|
return {
|
|
706
710
|
valid: !1,
|
|
@@ -713,16 +717,16 @@ const $t = () => {
|
|
|
713
717
|
sanitizedMetadata: r
|
|
714
718
|
};
|
|
715
719
|
}
|
|
716
|
-
return
|
|
717
|
-
},
|
|
718
|
-
const t =
|
|
720
|
+
return Fe(s, e, t);
|
|
721
|
+
}, Jt = (s, e) => {
|
|
722
|
+
const t = qt(s);
|
|
719
723
|
if (!t.valid)
|
|
720
724
|
return a("error", "Event name validation failed", {
|
|
721
725
|
data: { eventName: s, error: t.error }
|
|
722
726
|
}), t;
|
|
723
727
|
if (!e)
|
|
724
728
|
return { valid: !0 };
|
|
725
|
-
const r =
|
|
729
|
+
const r = Je(s, e, "customEvent");
|
|
726
730
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
727
731
|
data: {
|
|
728
732
|
eventName: s,
|
|
@@ -730,7 +734,7 @@ const $t = () => {
|
|
|
730
734
|
}
|
|
731
735
|
}), r;
|
|
732
736
|
};
|
|
733
|
-
class
|
|
737
|
+
class Zt {
|
|
734
738
|
listeners = /* @__PURE__ */ new Map();
|
|
735
739
|
/**
|
|
736
740
|
* Subscribes to an event channel
|
|
@@ -847,7 +851,7 @@ class Jt {
|
|
|
847
851
|
this.listeners.clear();
|
|
848
852
|
}
|
|
849
853
|
}
|
|
850
|
-
function
|
|
854
|
+
function Ze(s, e, t) {
|
|
851
855
|
try {
|
|
852
856
|
const r = e(s);
|
|
853
857
|
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 +862,10 @@ function Je(s, e, t) {
|
|
|
858
862
|
}), s;
|
|
859
863
|
}
|
|
860
864
|
}
|
|
861
|
-
function
|
|
862
|
-
return s.map((r) =>
|
|
865
|
+
function er(s, e, t) {
|
|
866
|
+
return s.map((r) => Ze(r, e, t)).filter((r) => r !== null);
|
|
863
867
|
}
|
|
864
|
-
function
|
|
868
|
+
function et(s, e, t) {
|
|
865
869
|
try {
|
|
866
870
|
const r = e(s);
|
|
867
871
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -877,8 +881,8 @@ function Ze(s, e, t) {
|
|
|
877
881
|
}), s;
|
|
878
882
|
}
|
|
879
883
|
}
|
|
880
|
-
const
|
|
881
|
-
class
|
|
884
|
+
const ie = {};
|
|
885
|
+
class v {
|
|
882
886
|
/**
|
|
883
887
|
* Retrieves a value from global state.
|
|
884
888
|
*
|
|
@@ -896,7 +900,7 @@ class I {
|
|
|
896
900
|
* ```
|
|
897
901
|
*/
|
|
898
902
|
get(e) {
|
|
899
|
-
return
|
|
903
|
+
return ie[e];
|
|
900
904
|
}
|
|
901
905
|
/**
|
|
902
906
|
* Sets a value in global state.
|
|
@@ -916,7 +920,7 @@ class I {
|
|
|
916
920
|
* ```
|
|
917
921
|
*/
|
|
918
922
|
set(e, t) {
|
|
919
|
-
|
|
923
|
+
ie[e] = t;
|
|
920
924
|
}
|
|
921
925
|
/**
|
|
922
926
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -933,10 +937,10 @@ class I {
|
|
|
933
937
|
* ```
|
|
934
938
|
*/
|
|
935
939
|
getState() {
|
|
936
|
-
return { ...
|
|
940
|
+
return { ...ie };
|
|
937
941
|
}
|
|
938
942
|
}
|
|
939
|
-
class
|
|
943
|
+
class $e extends v {
|
|
940
944
|
storeManager;
|
|
941
945
|
integrationId;
|
|
942
946
|
apiUrl;
|
|
@@ -1011,7 +1015,7 @@ class Fe extends I {
|
|
|
1011
1015
|
return { ...this.staticHeaders, ...e };
|
|
1012
1016
|
}
|
|
1013
1017
|
getQueueStorageKey() {
|
|
1014
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1018
|
+
const e = this.get("userId") || "anonymous", t = ht(e);
|
|
1015
1019
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1016
1020
|
}
|
|
1017
1021
|
/**
|
|
@@ -1048,13 +1052,13 @@ class Fe extends I {
|
|
|
1048
1052
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1049
1053
|
*/
|
|
1050
1054
|
sendEventsQueueSync(e) {
|
|
1051
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1055
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(H.Fail) ? (a(
|
|
1052
1056
|
"warn",
|
|
1053
1057
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1054
1058
|
{
|
|
1055
1059
|
data: { events: e.events.length }
|
|
1056
1060
|
}
|
|
1057
|
-
), !1) : this.apiUrl?.includes(
|
|
1061
|
+
), !1) : this.apiUrl?.includes(H.Localhost) ? (a(
|
|
1058
1062
|
"debug",
|
|
1059
1063
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1060
1064
|
{
|
|
@@ -1096,7 +1100,7 @@ class Fe extends I {
|
|
|
1096
1100
|
const r = await this.send(e);
|
|
1097
1101
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
|
|
1098
1102
|
} catch (r) {
|
|
1099
|
-
return r instanceof
|
|
1103
|
+
return r instanceof P ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1100
1104
|
}
|
|
1101
1105
|
}
|
|
1102
1106
|
/**
|
|
@@ -1163,7 +1167,7 @@ class Fe extends I {
|
|
|
1163
1167
|
const r = this.createRecoveryBody(t);
|
|
1164
1168
|
await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
|
|
1165
1169
|
} catch (t) {
|
|
1166
|
-
if (t instanceof
|
|
1170
|
+
if (t instanceof P) {
|
|
1167
1171
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1168
1172
|
return;
|
|
1169
1173
|
}
|
|
@@ -1217,7 +1221,7 @@ class Fe extends I {
|
|
|
1217
1221
|
const t = this.transformers.beforeSend;
|
|
1218
1222
|
if (!t)
|
|
1219
1223
|
return e;
|
|
1220
|
-
const r =
|
|
1224
|
+
const r = er(
|
|
1221
1225
|
e.events,
|
|
1222
1226
|
t,
|
|
1223
1227
|
this.integrationId || "SenderManager"
|
|
@@ -1262,7 +1266,7 @@ class Fe extends I {
|
|
|
1262
1266
|
if (this.integrationId === "saas")
|
|
1263
1267
|
return e;
|
|
1264
1268
|
const t = this.transformers.beforeBatch;
|
|
1265
|
-
return t ?
|
|
1269
|
+
return t ? et(e, t, this.integrationId || "SenderManager") : e;
|
|
1266
1270
|
}
|
|
1267
1271
|
/**
|
|
1268
1272
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1330,11 +1334,11 @@ class Fe extends I {
|
|
|
1330
1334
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1331
1335
|
if (!r)
|
|
1332
1336
|
return !0;
|
|
1333
|
-
if (this.apiUrl?.includes(
|
|
1337
|
+
if (this.apiUrl?.includes(H.Fail))
|
|
1334
1338
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1335
1339
|
data: { events: r.events.length }
|
|
1336
1340
|
}), !1;
|
|
1337
|
-
if (this.apiUrl?.includes(
|
|
1341
|
+
if (this.apiUrl?.includes(H.Localhost))
|
|
1338
1342
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1339
1343
|
data: { events: r.events.length }
|
|
1340
1344
|
}), !0;
|
|
@@ -1350,7 +1354,7 @@ class Fe extends I {
|
|
|
1350
1354
|
), !0) : !1;
|
|
1351
1355
|
} catch (l) {
|
|
1352
1356
|
const c = o === 3;
|
|
1353
|
-
if (l instanceof
|
|
1357
|
+
if (l instanceof P)
|
|
1354
1358
|
throw l;
|
|
1355
1359
|
if (a(
|
|
1356
1360
|
c ? "error" : "warn",
|
|
@@ -1412,7 +1416,7 @@ class Fe extends I {
|
|
|
1412
1416
|
}
|
|
1413
1417
|
});
|
|
1414
1418
|
if (!o.ok)
|
|
1415
|
-
throw o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429 ? new
|
|
1419
|
+
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
1420
|
return o;
|
|
1417
1421
|
} finally {
|
|
1418
1422
|
clearTimeout(n), this.pendingControllers.delete(r);
|
|
@@ -1496,7 +1500,7 @@ class Fe extends I {
|
|
|
1496
1500
|
_metadata: {
|
|
1497
1501
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1498
1502
|
timestamp: t,
|
|
1499
|
-
client_version:
|
|
1503
|
+
client_version: Vt
|
|
1500
1504
|
}
|
|
1501
1505
|
};
|
|
1502
1506
|
return {
|
|
@@ -1617,12 +1621,12 @@ class Fe extends I {
|
|
|
1617
1621
|
}
|
|
1618
1622
|
logPermanentError(e, t) {
|
|
1619
1623
|
const r = Date.now();
|
|
1620
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1624
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= Rt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1621
1625
|
data: { status: t.statusCode, message: t.message }
|
|
1622
1626
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1623
1627
|
}
|
|
1624
1628
|
}
|
|
1625
|
-
class
|
|
1629
|
+
class tr extends v {
|
|
1626
1630
|
bootTime;
|
|
1627
1631
|
bootTimestamp;
|
|
1628
1632
|
hasPerformanceNow;
|
|
@@ -1771,7 +1775,8 @@ class er extends I {
|
|
|
1771
1775
|
};
|
|
1772
1776
|
}
|
|
1773
1777
|
}
|
|
1774
|
-
|
|
1778
|
+
const rr = new Set(Object.values(d));
|
|
1779
|
+
class sr extends v {
|
|
1775
1780
|
dataSenders;
|
|
1776
1781
|
emitter;
|
|
1777
1782
|
transformers;
|
|
@@ -1780,8 +1785,9 @@ class tr extends I {
|
|
|
1780
1785
|
perEventRateLimits = /* @__PURE__ */ new Map();
|
|
1781
1786
|
eventsQueue = [];
|
|
1782
1787
|
pendingEventsBuffer = [];
|
|
1783
|
-
|
|
1788
|
+
sendTimeoutId = null;
|
|
1784
1789
|
sendInProgress = !1;
|
|
1790
|
+
consecutiveSendFailures = 0;
|
|
1785
1791
|
rateLimitCounter = 0;
|
|
1786
1792
|
rateLimitWindowStart = 0;
|
|
1787
1793
|
lastSessionId = null;
|
|
@@ -1808,10 +1814,10 @@ class tr extends I {
|
|
|
1808
1814
|
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1809
1815
|
*/
|
|
1810
1816
|
constructor(e, t = null, r = {}, n = {}, i) {
|
|
1811
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1817
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new tr(), this.dataSenders = [];
|
|
1812
1818
|
const o = this.get("collectApiUrls");
|
|
1813
|
-
o?.saas && this.dataSenders.push(new
|
|
1814
|
-
new
|
|
1819
|
+
o?.saas && this.dataSenders.push(new $e(e, "saas", o.saas, r)), o?.custom && this.dataSenders.push(
|
|
1820
|
+
new $e(
|
|
1815
1821
|
e,
|
|
1816
1822
|
"custom",
|
|
1817
1823
|
o.custom,
|
|
@@ -1938,6 +1944,12 @@ class tr extends I {
|
|
|
1938
1944
|
a("error", "Event type is required - event will be ignored");
|
|
1939
1945
|
return;
|
|
1940
1946
|
}
|
|
1947
|
+
if (!rr.has(e)) {
|
|
1948
|
+
a("error", "Invalid event type - event will be ignored", {
|
|
1949
|
+
data: { type: e }
|
|
1950
|
+
});
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1941
1953
|
const g = this.get("sessionId");
|
|
1942
1954
|
if (!g) {
|
|
1943
1955
|
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("debug", "Pending events buffer full - dropping oldest event", {
|
|
@@ -1976,12 +1988,12 @@ class tr extends I {
|
|
|
1976
1988
|
}
|
|
1977
1989
|
const T = this.getTypeLimitForEvent(E);
|
|
1978
1990
|
if (T) {
|
|
1979
|
-
const
|
|
1980
|
-
if (
|
|
1991
|
+
const re = this.sessionEventCounts[E];
|
|
1992
|
+
if (re !== void 0 && re >= T) {
|
|
1981
1993
|
a("warn", "Session event type limit reached", {
|
|
1982
1994
|
data: {
|
|
1983
1995
|
type: E,
|
|
1984
|
-
count:
|
|
1996
|
+
count: re,
|
|
1985
1997
|
limit: T
|
|
1986
1998
|
}
|
|
1987
1999
|
});
|
|
@@ -1994,9 +2006,9 @@ class tr extends I {
|
|
|
1994
2006
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1995
2007
|
return;
|
|
1996
2008
|
}
|
|
1997
|
-
const
|
|
2009
|
+
const ye = E === d.SESSION_START, W = t || this.get("pageUrl"), k = this.buildEventPayload({
|
|
1998
2010
|
type: E,
|
|
1999
|
-
page_url:
|
|
2011
|
+
page_url: W,
|
|
2000
2012
|
from_page_url: r,
|
|
2001
2013
|
scroll_data: n,
|
|
2002
2014
|
click_data: i,
|
|
@@ -2007,7 +2019,7 @@ class tr extends I {
|
|
|
2007
2019
|
page_view: S
|
|
2008
2020
|
});
|
|
2009
2021
|
if (k && !(!p && !this.shouldSample())) {
|
|
2010
|
-
if (
|
|
2022
|
+
if (ye) {
|
|
2011
2023
|
const T = this.get("sessionId");
|
|
2012
2024
|
if (!T) {
|
|
2013
2025
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2022,7 +2034,7 @@ class tr extends I {
|
|
|
2022
2034
|
this.set("hasStartSession", !0);
|
|
2023
2035
|
}
|
|
2024
2036
|
if (!this.isDuplicateEvent(k)) {
|
|
2025
|
-
if (this.get("mode") ===
|
|
2037
|
+
if (this.get("mode") === Y.QA) {
|
|
2026
2038
|
if (E === d.CUSTOM && o) {
|
|
2027
2039
|
a("info", `Custom Event: ${o.name}`, {
|
|
2028
2040
|
visibility: "qa",
|
|
@@ -2063,7 +2075,7 @@ class tr extends I {
|
|
|
2063
2075
|
* and allow subsequent init() → destroy() → init() cycles.
|
|
2064
2076
|
*
|
|
2065
2077
|
* **Cleanup Actions**:
|
|
2066
|
-
* 1. **Clear send
|
|
2078
|
+
* 1. **Clear send timeout**: Cancels pending queue flush timeout and resets backoff state
|
|
2067
2079
|
* 2. **Clear all queues and buffers**:
|
|
2068
2080
|
* - `eventsQueue`: Discarded (not sent)
|
|
2069
2081
|
* - `pendingEventsBuffer`: Discarded (events before session init)
|
|
@@ -2073,8 +2085,8 @@ class tr extends I {
|
|
|
2073
2085
|
* 6. **Stop SenderManagers**: Calls `stop()` on all SenderManager instances
|
|
2074
2086
|
*
|
|
2075
2087
|
* **Important Behavior**:
|
|
2076
|
-
* - **No final flush**:
|
|
2077
|
-
* -
|
|
2088
|
+
* - **No final flush**: `stop()` itself does NOT send queued events
|
|
2089
|
+
* - `App.destroy()` calls `flushImmediatelySync()` before `stop()` automatically
|
|
2078
2090
|
*
|
|
2079
2091
|
* **Multi-Integration**:
|
|
2080
2092
|
* - Stops all SenderManager instances (SaaS + Custom)
|
|
@@ -2091,7 +2103,7 @@ class tr extends I {
|
|
|
2091
2103
|
* @see src/managers/README.md (lines 5-75) for cleanup details
|
|
2092
2104
|
*/
|
|
2093
2105
|
stop() {
|
|
2094
|
-
this.
|
|
2106
|
+
this.clearSendTimeout(), this.sendInProgress = !1, this.consecutiveSendFailures = 0;
|
|
2095
2107
|
const e = this.get("sessionId");
|
|
2096
2108
|
e && this.saveSessionCounts(e), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
|
|
2097
2109
|
total: 0,
|
|
@@ -2108,7 +2120,7 @@ class tr extends I {
|
|
|
2108
2120
|
* Flushes all events in the queue asynchronously.
|
|
2109
2121
|
*
|
|
2110
2122
|
* **Purpose**: Force immediate sending of queued events without waiting for
|
|
2111
|
-
* the
|
|
2123
|
+
* the scheduled queue flush timeout.
|
|
2112
2124
|
*
|
|
2113
2125
|
* **Use Cases**:
|
|
2114
2126
|
* - Manual flush triggered by user action
|
|
@@ -2304,8 +2316,8 @@ class tr extends I {
|
|
|
2304
2316
|
this.track(r);
|
|
2305
2317
|
});
|
|
2306
2318
|
}
|
|
2307
|
-
|
|
2308
|
-
this.
|
|
2319
|
+
clearSendTimeout() {
|
|
2320
|
+
this.sendTimeoutId !== null && (clearTimeout(this.sendTimeoutId), this.sendTimeoutId = null);
|
|
2309
2321
|
}
|
|
2310
2322
|
isSuccessfulResult(e) {
|
|
2311
2323
|
return e.status === "fulfilled" && e.value === !0;
|
|
@@ -2315,10 +2327,10 @@ class tr extends I {
|
|
|
2315
2327
|
return e ? !0 : Promise.resolve(!0);
|
|
2316
2328
|
const t = this.buildEventsPayload(), r = [...this.eventsQueue], n = r.map((i) => i.id);
|
|
2317
2329
|
if (this.dataSenders.length === 0)
|
|
2318
|
-
return this.removeProcessedEvents(n), this.
|
|
2330
|
+
return this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
2319
2331
|
if (e) {
|
|
2320
2332
|
const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
|
|
2321
|
-
return o ? (this.removeProcessedEvents(n), this.
|
|
2333
|
+
return o ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : (this.clearSendTimeout(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
|
|
2322
2334
|
data: { eventCount: n.length }
|
|
2323
2335
|
})), o;
|
|
2324
2336
|
} else {
|
|
@@ -2332,7 +2344,7 @@ class tr extends I {
|
|
|
2332
2344
|
);
|
|
2333
2345
|
return Promise.allSettled(i).then((o) => {
|
|
2334
2346
|
const l = o.some((c) => this.isSuccessfulResult(c));
|
|
2335
|
-
return l ? (this.removeProcessedEvents(n), this.
|
|
2347
|
+
return l ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
|
|
2336
2348
|
data: { eventCount: r.length }
|
|
2337
2349
|
}), l;
|
|
2338
2350
|
});
|
|
@@ -2356,16 +2368,16 @@ class tr extends I {
|
|
|
2356
2368
|
})
|
|
2357
2369
|
), i = await Promise.allSettled(n);
|
|
2358
2370
|
if (i.some((l) => this.isSuccessfulResult(l))) {
|
|
2359
|
-
this.removeProcessedEvents(r), this.emitEventsQueue(e);
|
|
2371
|
+
this.consecutiveSendFailures = 0, this.removeProcessedEvents(r), this.emitEventsQueue(e);
|
|
2360
2372
|
const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
2361
2373
|
l > 0 && a("debug", "Periodic send completed with some failures, removed from queue and persisted per-integration", {
|
|
2362
2374
|
data: { eventCount: t.length, failedCount: l }
|
|
2363
2375
|
});
|
|
2364
2376
|
} else
|
|
2365
|
-
a("debug", "Periodic send complete failure, events kept in queue for retry", {
|
|
2377
|
+
this.consecutiveSendFailures++, a("debug", "Periodic send complete failure, events kept in queue for retry", {
|
|
2366
2378
|
data: { eventCount: t.length }
|
|
2367
2379
|
});
|
|
2368
|
-
this.eventsQueue.length === 0
|
|
2380
|
+
this.eventsQueue.length === 0 ? this.clearSendTimeout() : this.scheduleSendTimeout();
|
|
2369
2381
|
} finally {
|
|
2370
2382
|
this.sendInProgress = !1;
|
|
2371
2383
|
}
|
|
@@ -2387,7 +2399,7 @@ class tr extends I {
|
|
|
2387
2399
|
};
|
|
2388
2400
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2389
2401
|
if (!o && l) {
|
|
2390
|
-
const c =
|
|
2402
|
+
const c = et(n, l, "EventManager");
|
|
2391
2403
|
c !== null && (n = c);
|
|
2392
2404
|
}
|
|
2393
2405
|
return n;
|
|
@@ -2399,7 +2411,7 @@ class tr extends I {
|
|
|
2399
2411
|
});
|
|
2400
2412
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2401
2413
|
let l = {
|
|
2402
|
-
id:
|
|
2414
|
+
id: Bt(),
|
|
2403
2415
|
type: e.type,
|
|
2404
2416
|
page_url: t,
|
|
2405
2417
|
timestamp: r,
|
|
@@ -2416,10 +2428,10 @@ class tr extends I {
|
|
|
2416
2428
|
};
|
|
2417
2429
|
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2418
2430
|
if (E && (!g || u && !p)) {
|
|
2419
|
-
const
|
|
2420
|
-
if (
|
|
2431
|
+
const W = Ze(l, E, "EventManager");
|
|
2432
|
+
if (W === null)
|
|
2421
2433
|
return null;
|
|
2422
|
-
l =
|
|
2434
|
+
l = W;
|
|
2423
2435
|
}
|
|
2424
2436
|
return l;
|
|
2425
2437
|
}
|
|
@@ -2463,12 +2475,20 @@ class tr extends I {
|
|
|
2463
2475
|
}
|
|
2464
2476
|
});
|
|
2465
2477
|
}
|
|
2466
|
-
this.
|
|
2478
|
+
this.consecutiveSendFailures >= 5 && (this.consecutiveSendFailures = 0), this.scheduleSendTimeout(), this.eventsQueue.length >= 50 && this.sendEventsQueue();
|
|
2467
2479
|
}
|
|
2468
|
-
|
|
2469
|
-
this.
|
|
2470
|
-
|
|
2471
|
-
|
|
2480
|
+
scheduleSendTimeout() {
|
|
2481
|
+
if (this.sendTimeoutId !== null || this.consecutiveSendFailures >= 5) return;
|
|
2482
|
+
const e = this.calculateSendDelay();
|
|
2483
|
+
this.sendTimeoutId = window.setTimeout(() => {
|
|
2484
|
+
this.sendTimeoutId = null, this.eventsQueue.length > 0 && this.sendEventsQueue();
|
|
2485
|
+
}, e);
|
|
2486
|
+
}
|
|
2487
|
+
calculateSendDelay() {
|
|
2488
|
+
const e = this.get("config")?.sendIntervalMs ?? 1e4;
|
|
2489
|
+
if (this.consecutiveSendFailures === 0) return e;
|
|
2490
|
+
const t = e * Math.pow(2, this.consecutiveSendFailures);
|
|
2491
|
+
return Math.min(t, 12e4);
|
|
2472
2492
|
}
|
|
2473
2493
|
shouldSample() {
|
|
2474
2494
|
const e = this.get("config")?.samplingRate ?? 1;
|
|
@@ -2502,10 +2522,10 @@ class tr extends I {
|
|
|
2502
2522
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2503
2523
|
}
|
|
2504
2524
|
emitEvent(e) {
|
|
2505
|
-
this.emitter && this.emitter.emit(
|
|
2525
|
+
this.emitter && this.emitter.emit(le.EVENT, e);
|
|
2506
2526
|
}
|
|
2507
2527
|
emitEventsQueue(e) {
|
|
2508
|
-
this.emitter && this.emitter.emit(
|
|
2528
|
+
this.emitter && this.emitter.emit(le.QUEUE, e);
|
|
2509
2529
|
}
|
|
2510
2530
|
/**
|
|
2511
2531
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2581,13 +2601,13 @@ class tr extends I {
|
|
|
2581
2601
|
loadSessionCounts(e) {
|
|
2582
2602
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2583
2603
|
return this.getInitialCounts();
|
|
2584
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2604
|
+
const t = this.get("userId") || "anonymous", r = Me(t, e);
|
|
2585
2605
|
try {
|
|
2586
2606
|
const n = localStorage.getItem(r);
|
|
2587
2607
|
if (!n)
|
|
2588
2608
|
return this.getInitialCounts();
|
|
2589
2609
|
const i = JSON.parse(n);
|
|
2590
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2610
|
+
return i._timestamp && Date.now() - i._timestamp > Ce ? (a("debug", "Session counts expired, clearing", {
|
|
2591
2611
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2592
2612
|
}), 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" ? {
|
|
2593
2613
|
total: i.total,
|
|
@@ -2632,17 +2652,17 @@ class tr extends I {
|
|
|
2632
2652
|
cleanupExpiredSessionCounts() {
|
|
2633
2653
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2634
2654
|
try {
|
|
2635
|
-
const e = localStorage.getItem(
|
|
2655
|
+
const e = localStorage.getItem(Re);
|
|
2636
2656
|
if (e) {
|
|
2637
2657
|
const i = Date.now() - parseInt(e, 10);
|
|
2638
|
-
if (i <
|
|
2658
|
+
if (i < Ne) {
|
|
2639
2659
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2640
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2660
|
+
data: { timeSinceLastCleanup: i, throttleMs: Ne }
|
|
2641
2661
|
});
|
|
2642
2662
|
return;
|
|
2643
2663
|
}
|
|
2644
2664
|
}
|
|
2645
|
-
const t = this.get("userId") || "anonymous", r = `${
|
|
2665
|
+
const t = this.get("userId") || "anonymous", r = `${I}:${t}:session_counts:`, n = [];
|
|
2646
2666
|
for (let i = 0; i < localStorage.length; i++) {
|
|
2647
2667
|
const o = localStorage.key(i);
|
|
2648
2668
|
if (o?.startsWith(r))
|
|
@@ -2650,14 +2670,14 @@ class tr extends I {
|
|
|
2650
2670
|
const l = localStorage.getItem(o);
|
|
2651
2671
|
if (l) {
|
|
2652
2672
|
const c = JSON.parse(l);
|
|
2653
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2673
|
+
c._timestamp && Date.now() - c._timestamp > Ce && n.push(o);
|
|
2654
2674
|
}
|
|
2655
2675
|
} catch {
|
|
2656
2676
|
}
|
|
2657
2677
|
}
|
|
2658
2678
|
n.forEach((i) => {
|
|
2659
2679
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2660
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2680
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Re, Date.now().toString());
|
|
2661
2681
|
} catch (e) {
|
|
2662
2682
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2663
2683
|
}
|
|
@@ -2691,7 +2711,7 @@ class tr extends I {
|
|
|
2691
2711
|
* @internal
|
|
2692
2712
|
*/
|
|
2693
2713
|
saveSessionCounts(e) {
|
|
2694
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2714
|
+
const t = this.get("userId") || "anonymous", r = Me(t, e);
|
|
2695
2715
|
try {
|
|
2696
2716
|
const n = {
|
|
2697
2717
|
...this.sessionEventCounts,
|
|
@@ -2707,7 +2727,7 @@ class tr extends I {
|
|
|
2707
2727
|
}
|
|
2708
2728
|
}
|
|
2709
2729
|
}
|
|
2710
|
-
class
|
|
2730
|
+
class nr {
|
|
2711
2731
|
/**
|
|
2712
2732
|
* Gets or creates a unique user ID.
|
|
2713
2733
|
*
|
|
@@ -2725,15 +2745,15 @@ class rr {
|
|
|
2725
2745
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2726
2746
|
*/
|
|
2727
2747
|
static getId(e) {
|
|
2728
|
-
const t = e.getItem(
|
|
2748
|
+
const t = e.getItem(be);
|
|
2729
2749
|
if (t)
|
|
2730
2750
|
return t;
|
|
2731
|
-
const r =
|
|
2732
|
-
return e.setItem(
|
|
2751
|
+
const r = $t();
|
|
2752
|
+
return e.setItem(be, r), r;
|
|
2733
2753
|
}
|
|
2734
2754
|
}
|
|
2735
|
-
const
|
|
2736
|
-
class
|
|
2755
|
+
const ir = /^\d{13}-[a-z0-9]{9}$/;
|
|
2756
|
+
class or extends v {
|
|
2737
2757
|
storageManager;
|
|
2738
2758
|
eventManager;
|
|
2739
2759
|
projectId;
|
|
@@ -2759,7 +2779,7 @@ class nr extends I {
|
|
|
2759
2779
|
return;
|
|
2760
2780
|
}
|
|
2761
2781
|
const e = this.getProjectId();
|
|
2762
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2782
|
+
this.broadcastChannel = new BroadcastChannel(mt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2763
2783
|
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2764
2784
|
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 } }));
|
|
2765
2785
|
};
|
|
@@ -2779,7 +2799,7 @@ class nr extends I {
|
|
|
2779
2799
|
const e = this.loadStoredSession();
|
|
2780
2800
|
if (!e)
|
|
2781
2801
|
return null;
|
|
2782
|
-
if (!
|
|
2802
|
+
if (!ir.test(e.id))
|
|
2783
2803
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2784
2804
|
data: { sessionId: e.id }
|
|
2785
2805
|
}), this.clearStoredSession(), null;
|
|
@@ -2814,7 +2834,7 @@ class nr extends I {
|
|
|
2814
2834
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2815
2835
|
}
|
|
2816
2836
|
getSessionStorageKey() {
|
|
2817
|
-
return
|
|
2837
|
+
return ft(this.getProjectId());
|
|
2818
2838
|
}
|
|
2819
2839
|
getProjectId() {
|
|
2820
2840
|
return this.projectId;
|
|
@@ -2879,9 +2899,9 @@ class nr extends I {
|
|
|
2879
2899
|
let r, n;
|
|
2880
2900
|
if (e) {
|
|
2881
2901
|
const i = this.loadStoredSession();
|
|
2882
|
-
r = i?.referrer ??
|
|
2902
|
+
r = i?.referrer ?? se(), n = i?.utm ?? ne();
|
|
2883
2903
|
} else
|
|
2884
|
-
r =
|
|
2904
|
+
r = se(), n = ne();
|
|
2885
2905
|
a("debug", "Session tracking initialized", {
|
|
2886
2906
|
data: {
|
|
2887
2907
|
sessionId: t,
|
|
@@ -2932,7 +2952,7 @@ class nr extends I {
|
|
|
2932
2952
|
*/
|
|
2933
2953
|
renewSession() {
|
|
2934
2954
|
this.needsRenewal = !1;
|
|
2935
|
-
const e = this.generateSessionId(), t =
|
|
2955
|
+
const e = this.generateSessionId(), t = se(), r = ne();
|
|
2936
2956
|
a("debug", "Renewing session after timeout", {
|
|
2937
2957
|
data: { newSessionId: e }
|
|
2938
2958
|
}), 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({
|
|
@@ -3053,7 +3073,7 @@ class nr extends I {
|
|
|
3053
3073
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3054
3074
|
}
|
|
3055
3075
|
}
|
|
3056
|
-
class
|
|
3076
|
+
class ar extends v {
|
|
3057
3077
|
eventManager;
|
|
3058
3078
|
storageManager;
|
|
3059
3079
|
sessionManager = null;
|
|
@@ -3088,7 +3108,7 @@ class ir extends I {
|
|
|
3088
3108
|
}
|
|
3089
3109
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3090
3110
|
try {
|
|
3091
|
-
this.sessionManager = new
|
|
3111
|
+
this.sessionManager = new or(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3092
3112
|
} catch (r) {
|
|
3093
3113
|
if (this.sessionManager) {
|
|
3094
3114
|
try {
|
|
@@ -3141,7 +3161,7 @@ class ir extends I {
|
|
|
3141
3161
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3142
3162
|
}
|
|
3143
3163
|
}
|
|
3144
|
-
class
|
|
3164
|
+
class lr extends v {
|
|
3145
3165
|
eventManager;
|
|
3146
3166
|
onTrack;
|
|
3147
3167
|
originalPushState;
|
|
@@ -3181,7 +3201,7 @@ class or extends I {
|
|
|
3181
3201
|
};
|
|
3182
3202
|
}
|
|
3183
3203
|
trackCurrentPage = () => {
|
|
3184
|
-
const e = window.location.href, t =
|
|
3204
|
+
const e = window.location.href, t = he(e, this.get("config").sensitiveQueryParams);
|
|
3185
3205
|
if (this.get("pageUrl") === t)
|
|
3186
3206
|
return;
|
|
3187
3207
|
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3199,7 +3219,7 @@ class or extends I {
|
|
|
3199
3219
|
});
|
|
3200
3220
|
};
|
|
3201
3221
|
trackInitialPageView() {
|
|
3202
|
-
const e =
|
|
3222
|
+
const e = he(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3203
3223
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3204
3224
|
type: d.PAGE_VIEW,
|
|
3205
3225
|
page_url: e,
|
|
@@ -3217,7 +3237,7 @@ class or extends I {
|
|
|
3217
3237
|
};
|
|
3218
3238
|
}
|
|
3219
3239
|
}
|
|
3220
|
-
class
|
|
3240
|
+
class cr extends v {
|
|
3221
3241
|
eventManager;
|
|
3222
3242
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3223
3243
|
clickHandler;
|
|
@@ -3355,7 +3375,7 @@ class ar extends I {
|
|
|
3355
3375
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3356
3376
|
}
|
|
3357
3377
|
getRelevantClickElement(e) {
|
|
3358
|
-
for (const t of
|
|
3378
|
+
for (const t of lt)
|
|
3359
3379
|
try {
|
|
3360
3380
|
if (e.matches(t))
|
|
3361
3381
|
return e;
|
|
@@ -3435,7 +3455,7 @@ class ar extends I {
|
|
|
3435
3455
|
*/
|
|
3436
3456
|
sanitizeText(e) {
|
|
3437
3457
|
let t = e;
|
|
3438
|
-
for (const r of
|
|
3458
|
+
for (const r of ze) {
|
|
3439
3459
|
const n = new RegExp(r.source, r.flags);
|
|
3440
3460
|
t = t.replace(n, "[REDACTED]");
|
|
3441
3461
|
}
|
|
@@ -3474,7 +3494,7 @@ class ar extends I {
|
|
|
3474
3494
|
};
|
|
3475
3495
|
}
|
|
3476
3496
|
}
|
|
3477
|
-
class
|
|
3497
|
+
class ur extends v {
|
|
3478
3498
|
eventManager;
|
|
3479
3499
|
containers = [];
|
|
3480
3500
|
limitWarningLogged = !1;
|
|
@@ -3587,7 +3607,7 @@ class lr extends I {
|
|
|
3587
3607
|
isPrimary: o,
|
|
3588
3608
|
lastScrollPos: n,
|
|
3589
3609
|
lastDepth: i,
|
|
3590
|
-
lastDirection:
|
|
3610
|
+
lastDirection: j.DOWN,
|
|
3591
3611
|
lastEventTime: 0,
|
|
3592
3612
|
firstScrollEventTime: null,
|
|
3593
3613
|
maxDepthReached: i,
|
|
@@ -3646,7 +3666,7 @@ class lr extends I {
|
|
|
3646
3666
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3647
3667
|
}
|
|
3648
3668
|
getScrollDirection(e, t) {
|
|
3649
|
-
return e > t ?
|
|
3669
|
+
return e > t ? j.DOWN : j.UP;
|
|
3650
3670
|
}
|
|
3651
3671
|
calculateScrollDepth(e, t, r) {
|
|
3652
3672
|
if (t <= r)
|
|
@@ -3702,7 +3722,7 @@ class lr extends I {
|
|
|
3702
3722
|
e.isPrimary = t;
|
|
3703
3723
|
}
|
|
3704
3724
|
}
|
|
3705
|
-
class
|
|
3725
|
+
class dr extends v {
|
|
3706
3726
|
eventManager;
|
|
3707
3727
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3708
3728
|
observer = null;
|
|
@@ -3863,7 +3883,7 @@ class cr extends I {
|
|
|
3863
3883
|
});
|
|
3864
3884
|
}
|
|
3865
3885
|
}
|
|
3866
|
-
class
|
|
3886
|
+
class hr {
|
|
3867
3887
|
storage;
|
|
3868
3888
|
sessionStorageRef;
|
|
3869
3889
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4146,7 +4166,7 @@ class ur {
|
|
|
4146
4166
|
this.fallbackSessionStorage.delete(e);
|
|
4147
4167
|
}
|
|
4148
4168
|
}
|
|
4149
|
-
class
|
|
4169
|
+
class fr extends v {
|
|
4150
4170
|
eventManager;
|
|
4151
4171
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4152
4172
|
navigationHistory = [];
|
|
@@ -4157,7 +4177,7 @@ class dr extends I {
|
|
|
4157
4177
|
navigationCounter = 0;
|
|
4158
4178
|
// Counter for handling simultaneous navigations edge case
|
|
4159
4179
|
constructor(e) {
|
|
4160
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4180
|
+
super(), this.eventManager = e, this.vitalThresholds = Ue(de);
|
|
4161
4181
|
}
|
|
4162
4182
|
/**
|
|
4163
4183
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4174,8 +4194,8 @@ class dr extends I {
|
|
|
4174
4194
|
* @returns Promise that resolves when tracking is initialized
|
|
4175
4195
|
*/
|
|
4176
4196
|
async startTracking() {
|
|
4177
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4178
|
-
this.vitalThresholds =
|
|
4197
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? de;
|
|
4198
|
+
this.vitalThresholds = Ue(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4179
4199
|
}
|
|
4180
4200
|
/**
|
|
4181
4201
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4245,7 +4265,7 @@ class dr extends I {
|
|
|
4245
4265
|
}
|
|
4246
4266
|
async initWebVitals() {
|
|
4247
4267
|
try {
|
|
4248
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4268
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => $r), o = (l) => (c) => {
|
|
4249
4269
|
const u = Number(c.value.toFixed(2));
|
|
4250
4270
|
this.sendVital({ type: l, value: u });
|
|
4251
4271
|
};
|
|
@@ -4272,7 +4292,7 @@ class dr extends I {
|
|
|
4272
4292
|
const t = e.getEntries();
|
|
4273
4293
|
for (const r of t) {
|
|
4274
4294
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4275
|
-
i - this.lastLongTaskSentAt >=
|
|
4295
|
+
i - this.lastLongTaskSentAt >= Ot && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4276
4296
|
}
|
|
4277
4297
|
},
|
|
4278
4298
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4288,7 +4308,7 @@ class dr extends I {
|
|
|
4288
4308
|
return;
|
|
4289
4309
|
if (r)
|
|
4290
4310
|
r.add(e.type);
|
|
4291
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4311
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Pt) {
|
|
4292
4312
|
const i = this.navigationHistory.shift();
|
|
4293
4313
|
i && this.reportedByNav.delete(i);
|
|
4294
4314
|
}
|
|
@@ -4379,7 +4399,7 @@ class dr extends I {
|
|
|
4379
4399
|
return !(typeof r == "number" && t <= r);
|
|
4380
4400
|
}
|
|
4381
4401
|
}
|
|
4382
|
-
class
|
|
4402
|
+
class mr extends v {
|
|
4383
4403
|
eventManager;
|
|
4384
4404
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4385
4405
|
errorBurstCounter = 0;
|
|
@@ -4415,24 +4435,24 @@ class hr extends I {
|
|
|
4415
4435
|
const e = Date.now();
|
|
4416
4436
|
if (e < this.burstBackoffUntil)
|
|
4417
4437
|
return !1;
|
|
4418
|
-
if (e - this.burstWindowStart >
|
|
4419
|
-
return this.burstBackoffUntil = e +
|
|
4438
|
+
if (e - this.burstWindowStart > Mt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Ct)
|
|
4439
|
+
return this.burstBackoffUntil = e + Ve, a("debug", "Error burst detected - entering cooldown", {
|
|
4420
4440
|
data: {
|
|
4421
4441
|
errorsInWindow: this.errorBurstCounter,
|
|
4422
|
-
cooldownMs:
|
|
4442
|
+
cooldownMs: Ve
|
|
4423
4443
|
}
|
|
4424
4444
|
}), !1;
|
|
4425
|
-
const r = this.get("config")?.errorSampling ??
|
|
4445
|
+
const r = this.get("config")?.errorSampling ?? Ke;
|
|
4426
4446
|
return Math.random() < r;
|
|
4427
4447
|
}
|
|
4428
4448
|
handleError = (e) => {
|
|
4429
4449
|
if (!this.shouldSample())
|
|
4430
4450
|
return;
|
|
4431
4451
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4432
|
-
this.shouldSuppressError(
|
|
4452
|
+
this.shouldSuppressError(x.JS_ERROR, t) || this.eventManager.track({
|
|
4433
4453
|
type: d.ERROR,
|
|
4434
4454
|
error_data: {
|
|
4435
|
-
type:
|
|
4455
|
+
type: x.JS_ERROR,
|
|
4436
4456
|
message: t,
|
|
4437
4457
|
...e.filename && { filename: e.filename },
|
|
4438
4458
|
...e.lineno && { line: e.lineno },
|
|
@@ -4444,10 +4464,10 @@ class hr extends I {
|
|
|
4444
4464
|
if (!this.shouldSample())
|
|
4445
4465
|
return;
|
|
4446
4466
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4447
|
-
this.shouldSuppressError(
|
|
4467
|
+
this.shouldSuppressError(x.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4448
4468
|
type: d.ERROR,
|
|
4449
4469
|
error_data: {
|
|
4450
|
-
type:
|
|
4470
|
+
type: x.PROMISE_REJECTION,
|
|
4451
4471
|
message: r
|
|
4452
4472
|
}
|
|
4453
4473
|
});
|
|
@@ -4466,8 +4486,8 @@ class hr extends I {
|
|
|
4466
4486
|
}
|
|
4467
4487
|
}
|
|
4468
4488
|
sanitize(e) {
|
|
4469
|
-
let t = e.length >
|
|
4470
|
-
for (const r of
|
|
4489
|
+
let t = e.length > Pe ? e.slice(0, Pe) + "..." : e;
|
|
4490
|
+
for (const r of ze) {
|
|
4471
4491
|
const n = new RegExp(r.source, r.flags);
|
|
4472
4492
|
t = t.replace(n, "[REDACTED]");
|
|
4473
4493
|
}
|
|
@@ -4475,25 +4495,26 @@ class hr extends I {
|
|
|
4475
4495
|
}
|
|
4476
4496
|
shouldSuppressError(e, t) {
|
|
4477
4497
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4478
|
-
return i && r - i <
|
|
4498
|
+
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));
|
|
4479
4499
|
}
|
|
4480
4500
|
pruneOldErrors() {
|
|
4481
4501
|
const e = Date.now();
|
|
4482
4502
|
for (const [n, i] of this.recentErrors.entries())
|
|
4483
|
-
e - i >
|
|
4484
|
-
if (this.recentErrors.size <=
|
|
4503
|
+
e - i > De && this.recentErrors.delete(n);
|
|
4504
|
+
if (this.recentErrors.size <= z)
|
|
4485
4505
|
return;
|
|
4486
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size -
|
|
4506
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - z;
|
|
4487
4507
|
for (let n = 0; n < r; n += 1) {
|
|
4488
4508
|
const i = t[n];
|
|
4489
4509
|
i && this.recentErrors.delete(i[0]);
|
|
4490
4510
|
}
|
|
4491
4511
|
}
|
|
4492
4512
|
}
|
|
4493
|
-
class
|
|
4513
|
+
class gr extends v {
|
|
4494
4514
|
isInitialized = !1;
|
|
4495
4515
|
suppressNextScrollTimer = null;
|
|
4496
|
-
|
|
4516
|
+
pageUnloadHandler = null;
|
|
4517
|
+
emitter = new Zt();
|
|
4497
4518
|
transformers = {};
|
|
4498
4519
|
customHeadersProvider;
|
|
4499
4520
|
managers = {};
|
|
@@ -4511,17 +4532,17 @@ class fr extends I {
|
|
|
4511
4532
|
async init(e = {}) {
|
|
4512
4533
|
if (this.isInitialized)
|
|
4513
4534
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
4514
|
-
this.managers.storage = new
|
|
4535
|
+
this.managers.storage = new hr();
|
|
4515
4536
|
try {
|
|
4516
4537
|
this.setupState(e);
|
|
4517
4538
|
const t = e.integrations?.custom?.headers ?? {};
|
|
4518
|
-
return this.managers.event = new
|
|
4539
|
+
return this.managers.event = new sr(
|
|
4519
4540
|
this.managers.storage,
|
|
4520
4541
|
this.emitter,
|
|
4521
4542
|
this.transformers,
|
|
4522
4543
|
t,
|
|
4523
4544
|
this.customHeadersProvider
|
|
4524
|
-
), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4545
|
+
), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4525
4546
|
a("warn", "Failed to recover persisted events", { error: r });
|
|
4526
4547
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
4527
4548
|
} catch (t) {
|
|
@@ -4544,10 +4565,11 @@ class fr extends I {
|
|
|
4544
4565
|
}
|
|
4545
4566
|
let r = t;
|
|
4546
4567
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4547
|
-
const { valid: n, error: i, sanitizedMetadata: o } =
|
|
4568
|
+
const { valid: n, error: i, sanitizedMetadata: o } = Jt(e, r);
|
|
4548
4569
|
if (!n) {
|
|
4549
|
-
if (this.get("mode") ===
|
|
4570
|
+
if (this.get("mode") === Y.QA)
|
|
4550
4571
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4572
|
+
a("warn", `Custom event "${e}" dropped: ${i}`);
|
|
4551
4573
|
return;
|
|
4552
4574
|
}
|
|
4553
4575
|
this.managers.event.track({
|
|
@@ -4609,18 +4631,18 @@ class fr extends I {
|
|
|
4609
4631
|
} catch (r) {
|
|
4610
4632
|
a("warn", "Failed to stop tracking", { error: r });
|
|
4611
4633
|
}
|
|
4612
|
-
}), 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 = {});
|
|
4634
|
+
}), 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 = {});
|
|
4613
4635
|
}
|
|
4614
4636
|
setupState(e = {}) {
|
|
4615
4637
|
this.set("config", e);
|
|
4616
|
-
const t =
|
|
4638
|
+
const t = nr.getId(this.managers.storage);
|
|
4617
4639
|
this.set("userId", t);
|
|
4618
|
-
const r =
|
|
4640
|
+
const r = Gt(e);
|
|
4619
4641
|
this.set("collectApiUrls", r);
|
|
4620
|
-
const n =
|
|
4642
|
+
const n = Lt();
|
|
4621
4643
|
this.set("device", n);
|
|
4622
|
-
const i =
|
|
4623
|
-
this.set("pageUrl", i),
|
|
4644
|
+
const i = he(window.location.href, e.sensitiveQueryParams);
|
|
4645
|
+
this.set("pageUrl", i), Ut() && this.set("mode", Y.QA);
|
|
4624
4646
|
}
|
|
4625
4647
|
/**
|
|
4626
4648
|
* Returns the current configuration object.
|
|
@@ -4671,7 +4693,7 @@ class fr extends I {
|
|
|
4671
4693
|
valid: !1,
|
|
4672
4694
|
error: "Global metadata must be a plain object"
|
|
4673
4695
|
};
|
|
4674
|
-
const t =
|
|
4696
|
+
const t = Je("Global", e, "globalMetadata");
|
|
4675
4697
|
return t.valid ? { valid: !0 } : {
|
|
4676
4698
|
valid: !1,
|
|
4677
4699
|
error: t.error
|
|
@@ -4714,9 +4736,14 @@ class fr extends I {
|
|
|
4714
4736
|
};
|
|
4715
4737
|
this.set("config", o), a("debug", "Global metadata updated (merged)", { data: { keys: Object.keys(e) } });
|
|
4716
4738
|
}
|
|
4739
|
+
setupPageLifecycleListeners() {
|
|
4740
|
+
this.pageUnloadHandler = () => {
|
|
4741
|
+
this.managers.event?.flushImmediatelySync();
|
|
4742
|
+
}, window.addEventListener("pagehide", this.pageUnloadHandler), window.addEventListener("beforeunload", this.pageUnloadHandler);
|
|
4743
|
+
}
|
|
4717
4744
|
initializeHandlers() {
|
|
4718
4745
|
const e = this.get("config");
|
|
4719
|
-
this.handlers.session = new
|
|
4746
|
+
this.handlers.session = new ar(
|
|
4720
4747
|
this.managers.storage,
|
|
4721
4748
|
this.managers.event
|
|
4722
4749
|
), this.handlers.session.startTracking();
|
|
@@ -4725,31 +4752,22 @@ class fr extends I {
|
|
|
4725
4752
|
this.set("suppressNextScroll", !1);
|
|
4726
4753
|
}, 500);
|
|
4727
4754
|
};
|
|
4728
|
-
this.handlers.pageView = new
|
|
4755
|
+
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) => {
|
|
4729
4756
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4730
|
-
}), this.handlers.error = new
|
|
4757
|
+
}), 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());
|
|
4731
4758
|
}
|
|
4732
4759
|
}
|
|
4733
|
-
const
|
|
4734
|
-
let
|
|
4735
|
-
const
|
|
4736
|
-
if (typeof window > "u" || typeof document > "u")
|
|
4737
|
-
return { sessionId: "" };
|
|
4738
|
-
if (v = !1, window.__traceLogDisabled === !0)
|
|
4739
|
-
return { sessionId: "" };
|
|
4740
|
-
if (h)
|
|
4741
|
-
return { sessionId: h.getSessionId() ?? "" };
|
|
4742
|
-
if (C)
|
|
4743
|
-
return { sessionId: "" };
|
|
4744
|
-
C = !0;
|
|
4760
|
+
const O = [], M = [];
|
|
4761
|
+
let N = null, h = null, C = !1, _ = !1, R = null;
|
|
4762
|
+
const Er = async (s) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (_ = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (C && R || (C = !0, R = (async () => {
|
|
4745
4763
|
try {
|
|
4746
|
-
const e =
|
|
4764
|
+
const e = Kt(s ?? {}), t = new gr();
|
|
4747
4765
|
try {
|
|
4748
|
-
|
|
4766
|
+
O.forEach(({ event: o, callback: l }) => {
|
|
4749
4767
|
t.on(o, l);
|
|
4750
|
-
}),
|
|
4768
|
+
}), O.length = 0, M.forEach(({ hook: o, fn: l }) => {
|
|
4751
4769
|
o === "beforeSend" ? t.setTransformer("beforeSend", l) : t.setTransformer("beforeBatch", l);
|
|
4752
|
-
}), M.length = 0,
|
|
4770
|
+
}), M.length = 0, N && (t.setCustomHeaders(N), N = null);
|
|
4753
4771
|
const r = t.init(e), n = new Promise((o, l) => {
|
|
4754
4772
|
setTimeout(() => {
|
|
4755
4773
|
l(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4767,35 +4785,35 @@ const mr = async (s) => {
|
|
|
4767
4785
|
} catch (e) {
|
|
4768
4786
|
throw h = null, e;
|
|
4769
4787
|
} finally {
|
|
4770
|
-
C = !1;
|
|
4788
|
+
C = !1, R = null;
|
|
4771
4789
|
}
|
|
4772
|
-
},
|
|
4790
|
+
})()), R)), Sr = (s, e) => {
|
|
4773
4791
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4774
4792
|
if (!h)
|
|
4775
4793
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4776
|
-
if (
|
|
4794
|
+
if (_)
|
|
4777
4795
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4778
4796
|
h.sendCustomEvent(s, e);
|
|
4779
4797
|
}
|
|
4780
|
-
},
|
|
4798
|
+
}, pr = (s, e) => {
|
|
4781
4799
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4782
4800
|
if (!h || C) {
|
|
4783
|
-
|
|
4801
|
+
O.push({ event: s, callback: e });
|
|
4784
4802
|
return;
|
|
4785
4803
|
}
|
|
4786
4804
|
h.on(s, e);
|
|
4787
4805
|
}
|
|
4788
|
-
},
|
|
4806
|
+
}, Tr = (s, e) => {
|
|
4789
4807
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4790
4808
|
if (!h) {
|
|
4791
|
-
const t =
|
|
4792
|
-
t !== -1 &&
|
|
4809
|
+
const t = O.findIndex((r) => r.event === s && r.callback === e);
|
|
4810
|
+
t !== -1 && O.splice(t, 1);
|
|
4793
4811
|
return;
|
|
4794
4812
|
}
|
|
4795
4813
|
h.off(s, e);
|
|
4796
4814
|
}
|
|
4797
4815
|
};
|
|
4798
|
-
function
|
|
4816
|
+
function _r(s, e) {
|
|
4799
4817
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4800
4818
|
if (typeof e != "function")
|
|
4801
4819
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
@@ -4804,107 +4822,107 @@ function pr(s, e) {
|
|
|
4804
4822
|
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4805
4823
|
return;
|
|
4806
4824
|
}
|
|
4807
|
-
if (
|
|
4825
|
+
if (_)
|
|
4808
4826
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4809
4827
|
s === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
4810
4828
|
}
|
|
4811
4829
|
}
|
|
4812
|
-
const
|
|
4830
|
+
const vr = (s) => {
|
|
4813
4831
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4814
4832
|
if (!h) {
|
|
4815
4833
|
const e = M.findIndex((t) => t.hook === s);
|
|
4816
4834
|
e !== -1 && M.splice(e, 1);
|
|
4817
4835
|
return;
|
|
4818
4836
|
}
|
|
4819
|
-
if (
|
|
4837
|
+
if (_)
|
|
4820
4838
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4821
4839
|
h.removeTransformer(s);
|
|
4822
4840
|
}
|
|
4823
|
-
},
|
|
4841
|
+
}, Ir = (s) => {
|
|
4824
4842
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4825
4843
|
if (typeof s != "function")
|
|
4826
4844
|
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof s}`);
|
|
4827
4845
|
if (!h || C) {
|
|
4828
|
-
|
|
4846
|
+
N = s;
|
|
4829
4847
|
return;
|
|
4830
4848
|
}
|
|
4831
|
-
if (
|
|
4849
|
+
if (_)
|
|
4832
4850
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
4833
4851
|
h.setCustomHeaders(s);
|
|
4834
4852
|
}
|
|
4835
|
-
},
|
|
4853
|
+
}, wr = () => {
|
|
4836
4854
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4837
4855
|
if (!h) {
|
|
4838
|
-
|
|
4856
|
+
N = null;
|
|
4839
4857
|
return;
|
|
4840
4858
|
}
|
|
4841
|
-
if (
|
|
4859
|
+
if (_)
|
|
4842
4860
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
4843
4861
|
h.removeCustomHeaders();
|
|
4844
4862
|
}
|
|
4845
|
-
},
|
|
4863
|
+
}, yr = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, br = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Lr = () => {
|
|
4846
4864
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4847
|
-
if (
|
|
4865
|
+
if (_)
|
|
4848
4866
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
4849
4867
|
if (!h) {
|
|
4850
|
-
|
|
4868
|
+
_ = !1;
|
|
4851
4869
|
return;
|
|
4852
4870
|
}
|
|
4853
|
-
|
|
4871
|
+
_ = !0;
|
|
4854
4872
|
try {
|
|
4855
|
-
h.destroy(), h = null, C = !1,
|
|
4873
|
+
h.destroy(), h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, _ = !1;
|
|
4856
4874
|
} catch (s) {
|
|
4857
|
-
h = null, C = !1,
|
|
4875
|
+
h = null, C = !1, R = null, O.length = 0, M.length = 0, N = null, _ = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4858
4876
|
}
|
|
4859
4877
|
}
|
|
4860
|
-
},
|
|
4861
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4862
|
-
},
|
|
4878
|
+
}, Ar = (s) => {
|
|
4879
|
+
typeof window > "u" || typeof document > "u" || Ht(s);
|
|
4880
|
+
}, Mr = (s) => {
|
|
4863
4881
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4864
4882
|
if (!h)
|
|
4865
4883
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4866
|
-
if (
|
|
4884
|
+
if (_)
|
|
4867
4885
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4868
4886
|
h.updateGlobalMetadata(s);
|
|
4869
4887
|
}
|
|
4870
|
-
},
|
|
4888
|
+
}, Cr = (s) => {
|
|
4871
4889
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4872
4890
|
if (!h)
|
|
4873
4891
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4874
|
-
if (
|
|
4892
|
+
if (_)
|
|
4875
4893
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4876
4894
|
h.mergeGlobalMetadata(s);
|
|
4877
4895
|
}
|
|
4878
|
-
},
|
|
4879
|
-
init:
|
|
4880
|
-
event:
|
|
4881
|
-
on:
|
|
4882
|
-
off:
|
|
4883
|
-
setTransformer:
|
|
4884
|
-
removeTransformer:
|
|
4885
|
-
setCustomHeaders:
|
|
4886
|
-
removeCustomHeaders:
|
|
4887
|
-
isInitialized:
|
|
4888
|
-
getSessionId:
|
|
4889
|
-
destroy:
|
|
4890
|
-
setQaMode:
|
|
4891
|
-
updateGlobalMetadata:
|
|
4892
|
-
mergeGlobalMetadata:
|
|
4896
|
+
}, ts = {
|
|
4897
|
+
init: Er,
|
|
4898
|
+
event: Sr,
|
|
4899
|
+
on: pr,
|
|
4900
|
+
off: Tr,
|
|
4901
|
+
setTransformer: _r,
|
|
4902
|
+
removeTransformer: vr,
|
|
4903
|
+
setCustomHeaders: Ir,
|
|
4904
|
+
removeCustomHeaders: wr,
|
|
4905
|
+
isInitialized: yr,
|
|
4906
|
+
getSessionId: br,
|
|
4907
|
+
destroy: Lr,
|
|
4908
|
+
setQaMode: Ar,
|
|
4909
|
+
updateGlobalMetadata: Mr,
|
|
4910
|
+
mergeGlobalMetadata: Cr
|
|
4893
4911
|
};
|
|
4894
|
-
var
|
|
4912
|
+
var ge, tt = -1, V = function(s) {
|
|
4895
4913
|
addEventListener("pageshow", (function(e) {
|
|
4896
|
-
e.persisted && (
|
|
4914
|
+
e.persisted && (tt = e.timeStamp, s(e));
|
|
4897
4915
|
}), !0);
|
|
4898
4916
|
}, ve = function() {
|
|
4899
4917
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4900
4918
|
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4901
|
-
},
|
|
4919
|
+
}, Z = function() {
|
|
4902
4920
|
var s = ve();
|
|
4903
4921
|
return s && s.activationStart || 0;
|
|
4904
4922
|
}, b = function(s, e) {
|
|
4905
4923
|
var t = ve(), r = "navigate";
|
|
4906
|
-
return
|
|
4907
|
-
},
|
|
4924
|
+
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 };
|
|
4925
|
+
}, B = function(s, e, t) {
|
|
4908
4926
|
try {
|
|
4909
4927
|
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4910
4928
|
var r = new PerformanceObserver((function(n) {
|
|
@@ -4929,50 +4947,50 @@ var me, et = -1, D = function(s) {
|
|
|
4929
4947
|
return s();
|
|
4930
4948
|
}));
|
|
4931
4949
|
}));
|
|
4932
|
-
},
|
|
4950
|
+
}, ee = function(s) {
|
|
4933
4951
|
document.addEventListener("visibilitychange", (function() {
|
|
4934
4952
|
document.visibilityState === "hidden" && s();
|
|
4935
4953
|
}));
|
|
4936
|
-
},
|
|
4954
|
+
}, we = function(s) {
|
|
4937
4955
|
var e = !1;
|
|
4938
4956
|
return function() {
|
|
4939
4957
|
e || (s(), e = !0);
|
|
4940
4958
|
};
|
|
4941
|
-
},
|
|
4959
|
+
}, D = -1, Be = function() {
|
|
4942
4960
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4943
|
-
},
|
|
4944
|
-
document.visibilityState === "hidden" &&
|
|
4945
|
-
},
|
|
4946
|
-
addEventListener("visibilitychange",
|
|
4947
|
-
},
|
|
4948
|
-
removeEventListener("visibilitychange",
|
|
4949
|
-
},
|
|
4950
|
-
return
|
|
4961
|
+
}, J = function(s) {
|
|
4962
|
+
document.visibilityState === "hidden" && D > -1 && (D = s.type === "visibilitychange" ? s.timeStamp : 0, Rr());
|
|
4963
|
+
}, We = function() {
|
|
4964
|
+
addEventListener("visibilitychange", J, !0), addEventListener("prerenderingchange", J, !0);
|
|
4965
|
+
}, Rr = function() {
|
|
4966
|
+
removeEventListener("visibilitychange", J, !0), removeEventListener("prerenderingchange", J, !0);
|
|
4967
|
+
}, rt = function() {
|
|
4968
|
+
return D < 0 && (D = Be(), We(), V((function() {
|
|
4951
4969
|
setTimeout((function() {
|
|
4952
|
-
|
|
4970
|
+
D = Be(), We();
|
|
4953
4971
|
}), 0);
|
|
4954
4972
|
}))), { get firstHiddenTime() {
|
|
4955
|
-
return
|
|
4973
|
+
return D;
|
|
4956
4974
|
} };
|
|
4957
|
-
},
|
|
4975
|
+
}, te = function(s) {
|
|
4958
4976
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4959
4977
|
return s();
|
|
4960
4978
|
}), !0) : s();
|
|
4961
|
-
},
|
|
4962
|
-
e = e || {},
|
|
4963
|
-
var t, r =
|
|
4979
|
+
}, Ee = [1800, 3e3], st = function(s, e) {
|
|
4980
|
+
e = e || {}, te((function() {
|
|
4981
|
+
var t, r = rt(), n = b("FCP"), i = B("paint", (function(o) {
|
|
4964
4982
|
o.forEach((function(l) {
|
|
4965
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime -
|
|
4983
|
+
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)));
|
|
4966
4984
|
}));
|
|
4967
4985
|
}));
|
|
4968
|
-
i && (t = L(s, n,
|
|
4969
|
-
n = b("FCP"), t = L(s, n,
|
|
4986
|
+
i && (t = L(s, n, Ee, e.reportAllChanges), V((function(o) {
|
|
4987
|
+
n = b("FCP"), t = L(s, n, Ee, e.reportAllChanges), Ie((function() {
|
|
4970
4988
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4971
4989
|
}));
|
|
4972
4990
|
})));
|
|
4973
4991
|
}));
|
|
4974
|
-
},
|
|
4975
|
-
e = e || {},
|
|
4992
|
+
}, Se = [0.1, 0.25], Nr = function(s, e) {
|
|
4993
|
+
e = e || {}, st(we((function() {
|
|
4976
4994
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4977
4995
|
c.forEach((function(u) {
|
|
4978
4996
|
if (!u.hadRecentInput) {
|
|
@@ -4980,147 +4998,147 @@ var me, et = -1, D = function(s) {
|
|
|
4980
4998
|
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
4981
4999
|
}
|
|
4982
5000
|
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4983
|
-
}, l =
|
|
4984
|
-
l && (t = L(s, r,
|
|
5001
|
+
}, l = B("layout-shift", o);
|
|
5002
|
+
l && (t = L(s, r, Se, e.reportAllChanges), ee((function() {
|
|
4985
5003
|
o(l.takeRecords()), t(!0);
|
|
4986
|
-
})),
|
|
4987
|
-
n = 0, r = b("CLS", 0), t = L(s, r,
|
|
5004
|
+
})), V((function() {
|
|
5005
|
+
n = 0, r = b("CLS", 0), t = L(s, r, Se, e.reportAllChanges), Ie((function() {
|
|
4988
5006
|
return t();
|
|
4989
5007
|
}));
|
|
4990
5008
|
})), setTimeout(t, 0));
|
|
4991
5009
|
})));
|
|
4992
|
-
},
|
|
5010
|
+
}, nt = 0, oe = 1 / 0, Q = 0, Or = function(s) {
|
|
4993
5011
|
s.forEach((function(e) {
|
|
4994
|
-
e.interactionId && (
|
|
5012
|
+
e.interactionId && (oe = Math.min(oe, e.interactionId), Q = Math.max(Q, e.interactionId), nt = Q ? (Q - oe) / 7 + 1 : 0);
|
|
4995
5013
|
}));
|
|
4996
|
-
},
|
|
4997
|
-
return
|
|
4998
|
-
},
|
|
4999
|
-
"interactionCount" in performance ||
|
|
5000
|
-
}, y = [],
|
|
5001
|
-
var s = Math.min(y.length - 1, Math.floor((
|
|
5014
|
+
}, it = function() {
|
|
5015
|
+
return ge ? nt : performance.interactionCount || 0;
|
|
5016
|
+
}, Pr = function() {
|
|
5017
|
+
"interactionCount" in performance || ge || (ge = B("event", Or, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5018
|
+
}, y = [], K = /* @__PURE__ */ new Map(), ot = 0, Dr = function() {
|
|
5019
|
+
var s = Math.min(y.length - 1, Math.floor((it() - ot) / 50));
|
|
5002
5020
|
return y[s];
|
|
5003
|
-
},
|
|
5004
|
-
if (
|
|
5021
|
+
}, Vr = [], kr = function(s) {
|
|
5022
|
+
if (Vr.forEach((function(n) {
|
|
5005
5023
|
return n(s);
|
|
5006
5024
|
})), s.interactionId || s.entryType === "first-input") {
|
|
5007
|
-
var e = y[y.length - 1], t =
|
|
5025
|
+
var e = y[y.length - 1], t = K.get(s.interactionId);
|
|
5008
5026
|
if (t || y.length < 10 || s.duration > e.latency) {
|
|
5009
5027
|
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);
|
|
5010
5028
|
else {
|
|
5011
5029
|
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
5012
|
-
|
|
5030
|
+
K.set(r.id, r), y.push(r);
|
|
5013
5031
|
}
|
|
5014
5032
|
y.sort((function(n, i) {
|
|
5015
5033
|
return i.latency - n.latency;
|
|
5016
5034
|
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
5017
|
-
return
|
|
5035
|
+
return K.delete(n.id);
|
|
5018
5036
|
}));
|
|
5019
5037
|
}
|
|
5020
5038
|
}
|
|
5021
|
-
},
|
|
5039
|
+
}, at = function(s) {
|
|
5022
5040
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5023
|
-
return s =
|
|
5024
|
-
},
|
|
5025
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
5041
|
+
return s = we(s), document.visibilityState === "hidden" ? s() : (t = e(s), ee(s)), t;
|
|
5042
|
+
}, pe = [200, 500], Ur = function(s, e) {
|
|
5043
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, te((function() {
|
|
5026
5044
|
var t;
|
|
5027
|
-
|
|
5045
|
+
Pr();
|
|
5028
5046
|
var r, n = b("INP"), i = function(l) {
|
|
5029
|
-
|
|
5030
|
-
l.forEach(
|
|
5031
|
-
var c =
|
|
5047
|
+
at((function() {
|
|
5048
|
+
l.forEach(kr);
|
|
5049
|
+
var c = Dr();
|
|
5032
5050
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
5033
5051
|
}));
|
|
5034
|
-
}, o =
|
|
5035
|
-
r = L(s, n,
|
|
5052
|
+
}, o = B("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5053
|
+
r = L(s, n, pe, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), ee((function() {
|
|
5036
5054
|
i(o.takeRecords()), r(!0);
|
|
5037
|
-
})),
|
|
5038
|
-
|
|
5055
|
+
})), V((function() {
|
|
5056
|
+
ot = it(), y.length = 0, K.clear(), n = b("INP"), r = L(s, n, pe, e.reportAllChanges);
|
|
5039
5057
|
})));
|
|
5040
5058
|
})));
|
|
5041
|
-
},
|
|
5042
|
-
e = e || {},
|
|
5043
|
-
var t, r =
|
|
5059
|
+
}, Te = [2500, 4e3], ae = {}, Hr = function(s, e) {
|
|
5060
|
+
e = e || {}, te((function() {
|
|
5061
|
+
var t, r = rt(), n = b("LCP"), i = function(c) {
|
|
5044
5062
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
5045
|
-
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime -
|
|
5063
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - Z(), 0), n.entries = [u], t());
|
|
5046
5064
|
}));
|
|
5047
|
-
}, o =
|
|
5065
|
+
}, o = B("largest-contentful-paint", i);
|
|
5048
5066
|
if (o) {
|
|
5049
|
-
t = L(s, n,
|
|
5050
|
-
var l =
|
|
5051
|
-
|
|
5067
|
+
t = L(s, n, Te, e.reportAllChanges);
|
|
5068
|
+
var l = we((function() {
|
|
5069
|
+
ae[n.id] || (i(o.takeRecords()), o.disconnect(), ae[n.id] = !0, t(!0));
|
|
5052
5070
|
}));
|
|
5053
5071
|
["keydown", "click"].forEach((function(c) {
|
|
5054
5072
|
addEventListener(c, (function() {
|
|
5055
|
-
return
|
|
5073
|
+
return at(l);
|
|
5056
5074
|
}), { once: !0, capture: !0 });
|
|
5057
|
-
})),
|
|
5058
|
-
n = b("LCP"), t = L(s, n,
|
|
5059
|
-
n.value = performance.now() - c.timeStamp,
|
|
5075
|
+
})), ee(l), V((function(c) {
|
|
5076
|
+
n = b("LCP"), t = L(s, n, Te, e.reportAllChanges), Ie((function() {
|
|
5077
|
+
n.value = performance.now() - c.timeStamp, ae[n.id] = !0, t(!0);
|
|
5060
5078
|
}));
|
|
5061
5079
|
}));
|
|
5062
5080
|
}
|
|
5063
5081
|
}));
|
|
5064
|
-
},
|
|
5065
|
-
document.prerendering ?
|
|
5082
|
+
}, _e = [800, 1800], xr = function s(e) {
|
|
5083
|
+
document.prerendering ? te((function() {
|
|
5066
5084
|
return s(e);
|
|
5067
5085
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5068
5086
|
return s(e);
|
|
5069
5087
|
}), !0) : setTimeout(e, 0);
|
|
5070
|
-
},
|
|
5088
|
+
}, Fr = function(s, e) {
|
|
5071
5089
|
e = e || {};
|
|
5072
|
-
var t = b("TTFB"), r = L(s, t,
|
|
5073
|
-
|
|
5090
|
+
var t = b("TTFB"), r = L(s, t, _e, e.reportAllChanges);
|
|
5091
|
+
xr((function() {
|
|
5074
5092
|
var n = ve();
|
|
5075
|
-
n && (t.value = Math.max(n.responseStart -
|
|
5076
|
-
t = b("TTFB", 0), (r = L(s, t,
|
|
5093
|
+
n && (t.value = Math.max(n.responseStart - Z(), 0), t.entries = [n], r(!0), V((function() {
|
|
5094
|
+
t = b("TTFB", 0), (r = L(s, t, _e, e.reportAllChanges))(!0);
|
|
5077
5095
|
})));
|
|
5078
5096
|
}));
|
|
5079
5097
|
};
|
|
5080
|
-
const
|
|
5098
|
+
const $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5081
5099
|
__proto__: null,
|
|
5082
|
-
CLSThresholds:
|
|
5083
|
-
FCPThresholds:
|
|
5084
|
-
INPThresholds:
|
|
5085
|
-
LCPThresholds:
|
|
5086
|
-
TTFBThresholds:
|
|
5087
|
-
onCLS:
|
|
5088
|
-
onFCP:
|
|
5089
|
-
onINP:
|
|
5090
|
-
onLCP:
|
|
5091
|
-
onTTFB:
|
|
5100
|
+
CLSThresholds: Se,
|
|
5101
|
+
FCPThresholds: Ee,
|
|
5102
|
+
INPThresholds: pe,
|
|
5103
|
+
LCPThresholds: Te,
|
|
5104
|
+
TTFBThresholds: _e,
|
|
5105
|
+
onCLS: Nr,
|
|
5106
|
+
onFCP: st,
|
|
5107
|
+
onINP: Ur,
|
|
5108
|
+
onLCP: Hr,
|
|
5109
|
+
onTTFB: Fr
|
|
5092
5110
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5093
5111
|
export {
|
|
5094
5112
|
f as AppConfigValidationError,
|
|
5095
|
-
|
|
5096
|
-
|
|
5113
|
+
Br as DEFAULT_SESSION_TIMEOUT,
|
|
5114
|
+
de as DEFAULT_WEB_VITALS_MODE,
|
|
5097
5115
|
A as DeviceType,
|
|
5098
|
-
|
|
5099
|
-
|
|
5116
|
+
le as EmitterEvent,
|
|
5117
|
+
x as ErrorType,
|
|
5100
5118
|
d as EventType,
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5119
|
+
Zr as InitializationTimeoutError,
|
|
5120
|
+
U as IntegrationValidationError,
|
|
5121
|
+
Yr as MAX_ARRAY_LENGTH,
|
|
5122
|
+
Qr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5123
|
+
Xr as MAX_CUSTOM_EVENT_KEYS,
|
|
5124
|
+
Wr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5125
|
+
Gr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5126
|
+
jr as MAX_NESTED_OBJECT_KEYS,
|
|
5127
|
+
zr as MAX_STRING_LENGTH,
|
|
5128
|
+
Kr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5129
|
+
Y as Mode,
|
|
5130
|
+
ze as PII_PATTERNS,
|
|
5131
|
+
P as PermanentError,
|
|
5132
|
+
Oe as SamplingRateValidationError,
|
|
5133
|
+
j as ScrollDirection,
|
|
5134
|
+
gt as SessionTimeoutValidationError,
|
|
5135
|
+
H as SpecialApiUrl,
|
|
5136
|
+
$ as TraceLogValidationError,
|
|
5137
|
+
es as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5120
5138
|
ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5139
|
+
Nt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5140
|
+
Ue as getWebVitalsThresholds,
|
|
5141
|
+
qr as isPrimaryScrollEvent,
|
|
5142
|
+
Jr as isSecondaryScrollEvent,
|
|
5143
|
+
ts as tracelog
|
|
5126
5144
|
};
|