@tracelog/lib 2.5.0 → 2.5.1
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 +532 -461
- 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 -2
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +9 -1
- package/dist/public-api.d.ts +9 -1
- package/dist/public-api.js +2 -2
- 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
|
|
1
|
+
const ts = 9e5;
|
|
2
|
+
const rs = 120, ss = 8192, ns = 10, is = 10, os = 20;
|
|
3
|
+
const as = 1e3, ls = 500, cs = 100;
|
|
4
|
+
const b = "data-tlog", pt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const w = "data-tlog", lt = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], Tt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], vt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -72,53 +72,58 @@ const m = {
|
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number",
|
|
74
74
|
INVALID_SEND_INTERVAL: "Send interval must be between 1000ms (1 second) and 60000ms (60 seconds)"
|
|
75
|
-
},
|
|
75
|
+
}, _t = [
|
|
76
76
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
77
77
|
/javascript:/gi,
|
|
78
78
|
/on\w+\s*=/gi,
|
|
79
79
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
80
80
|
/<embed\b[^>]*>/gi,
|
|
81
81
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
82
|
-
],
|
|
83
|
-
var
|
|
84
|
-
class
|
|
82
|
+
], y = "tlog", G = `${y}:qa_mode`, Oe = `${y}:uid`, Je = "tlog_mode", Pe = "qa", De = "qa_off", It = (s) => s ? `${y}:${s}:queue` : `${y}:queue`, wt = (s) => s ? `${y}:${s}:session` : `${y}:session`, yt = (s) => s ? `${y}:${s}:broadcast` : `${y}:broadcast`, Ve = (s, e) => `${y}:${s}:session_counts:${e}`, ke = 10080 * 60 * 1e3, Ue = `${y}:session_counts_last_cleanup`, He = 3600 * 1e3;
|
|
83
|
+
var $ = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))($ || {}), A = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(A || {}), me = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(me || {});
|
|
84
|
+
class N extends Error {
|
|
85
85
|
constructor(e, t) {
|
|
86
|
-
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, N);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
class O extends Error {
|
|
90
|
+
constructor(e) {
|
|
91
|
+
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, O);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
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 || {}), Z = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(Z || {}), B = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(B || {}), re = /* @__PURE__ */ ((s) => (s.QA = "qa", s))(re || {});
|
|
95
|
+
const us = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !0, ds = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !1;
|
|
96
|
+
class Q extends Error {
|
|
92
97
|
constructor(e, t, r) {
|
|
93
98
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
|
-
class f extends
|
|
101
|
+
class f extends Q {
|
|
97
102
|
constructor(e, t = "config") {
|
|
98
103
|
super(e, "APP_CONFIG_INVALID", t);
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
|
-
class
|
|
106
|
+
class bt extends Q {
|
|
102
107
|
constructor(e, t = "config") {
|
|
103
108
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
class
|
|
111
|
+
class xe extends Q {
|
|
107
112
|
constructor(e, t = "config") {
|
|
108
113
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
|
-
class
|
|
116
|
+
class U extends Q {
|
|
112
117
|
constructor(e, t = "config") {
|
|
113
118
|
super(e, "INTEGRATION_INVALID", t);
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
|
-
class
|
|
121
|
+
class hs extends Q {
|
|
117
122
|
constructor(e, t, r = "runtime") {
|
|
118
123
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
|
-
const
|
|
126
|
+
const Ze = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", et = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Lt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", At = (s, e) => {
|
|
122
127
|
if (e) {
|
|
123
128
|
if (e instanceof Error) {
|
|
124
129
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -137,24 +142,24 @@ const Xe = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
137
142
|
return `[TraceLog] ${s}: ${String(e)}`;
|
|
138
143
|
}
|
|
139
144
|
return `[TraceLog] ${s}`;
|
|
140
|
-
},
|
|
145
|
+
}, Mt = () => {
|
|
141
146
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
142
147
|
return !1;
|
|
143
148
|
try {
|
|
144
|
-
return sessionStorage.getItem(
|
|
149
|
+
return sessionStorage.getItem(G) === "true";
|
|
145
150
|
} catch {
|
|
146
151
|
return !1;
|
|
147
152
|
}
|
|
148
153
|
}, l = (s, e, t) => {
|
|
149
|
-
const { error: r, data: n, showToClient: i = !1, style: o, visibility: a } = t ?? {}, c = r ?
|
|
150
|
-
if (!
|
|
154
|
+
const { error: r, data: n, showToClient: i = !1, style: o, visibility: a } = t ?? {}, c = r ? At(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
|
|
155
|
+
if (!Ct(a, i))
|
|
151
156
|
return;
|
|
152
|
-
const g =
|
|
153
|
-
|
|
154
|
-
},
|
|
157
|
+
const g = Rt(a, o), p = n !== void 0 ? ge(n) : void 0;
|
|
158
|
+
Nt(u, c, g, p);
|
|
159
|
+
}, Ct = (s, e) => s === "critical" ? !0 : s === "qa" || e ? Mt() : !1, Rt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? Lt : "", Nt = (s, e, t, r) => {
|
|
155
160
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
156
161
|
r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
|
|
157
|
-
},
|
|
162
|
+
}, ge = (s) => {
|
|
158
163
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
159
164
|
for (const [r, n] of Object.entries(s)) {
|
|
160
165
|
const i = r.toLowerCase();
|
|
@@ -162,16 +167,16 @@ const Xe = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
162
167
|
e[r] = "[REDACTED]";
|
|
163
168
|
continue;
|
|
164
169
|
}
|
|
165
|
-
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] =
|
|
166
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
170
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] = ge(n) : Array.isArray(n) ? e[r] = n.map(
|
|
171
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ge(o) : o
|
|
167
172
|
) : e[r] = n;
|
|
168
173
|
}
|
|
169
174
|
return e;
|
|
170
175
|
};
|
|
171
|
-
let
|
|
172
|
-
const
|
|
173
|
-
typeof window < "u" && !
|
|
174
|
-
},
|
|
176
|
+
let Ee, tt;
|
|
177
|
+
const Ot = () => {
|
|
178
|
+
typeof window < "u" && !Ee && (Ee = window.matchMedia("(pointer: coarse)"), tt = window.matchMedia("(hover: none)"));
|
|
179
|
+
}, se = "Unknown", Pt = (s) => {
|
|
175
180
|
const e = s.userAgentData?.platform;
|
|
176
181
|
if (e != null && e !== "") {
|
|
177
182
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -182,8 +187,8 @@ const It = () => {
|
|
|
182
187
|
if (/ios/i.test(e)) return "iOS";
|
|
183
188
|
}
|
|
184
189
|
const t = navigator.userAgent;
|
|
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" :
|
|
186
|
-
},
|
|
190
|
+
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" : se;
|
|
191
|
+
}, Dt = (s) => {
|
|
187
192
|
const e = s.userAgentData?.brands;
|
|
188
193
|
if (e != null && e.length > 0) {
|
|
189
194
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -193,36 +198,36 @@ const It = () => {
|
|
|
193
198
|
}
|
|
194
199
|
}
|
|
195
200
|
const t = navigator.userAgent;
|
|
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" :
|
|
197
|
-
},
|
|
201
|
+
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" : se;
|
|
202
|
+
}, Vt = () => {
|
|
198
203
|
try {
|
|
199
204
|
const s = navigator;
|
|
200
205
|
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
201
206
|
const c = s.userAgentData.platform;
|
|
202
207
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? A.Tablet : s.userAgentData.mobile ? A.Mobile : A.Desktop;
|
|
203
208
|
}
|
|
204
|
-
|
|
205
|
-
const e = window.innerWidth, t =
|
|
209
|
+
Ot();
|
|
210
|
+
const e = window.innerWidth, t = Ee?.matches ?? !1, r = tt?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), a = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
206
211
|
return e <= 767 || o && n ? A.Mobile : e >= 768 && e <= 1024 || a || t && r && n ? A.Tablet : A.Desktop;
|
|
207
212
|
} catch (s) {
|
|
208
213
|
return l("debug", "Device detection failed, defaulting to desktop", { error: s }), A.Desktop;
|
|
209
214
|
}
|
|
210
|
-
},
|
|
215
|
+
}, kt = () => {
|
|
211
216
|
try {
|
|
212
217
|
const s = navigator;
|
|
213
218
|
return {
|
|
214
|
-
type:
|
|
215
|
-
os:
|
|
216
|
-
browser:
|
|
219
|
+
type: Vt(),
|
|
220
|
+
os: Pt(s),
|
|
221
|
+
browser: Dt(s)
|
|
217
222
|
};
|
|
218
223
|
} catch (s) {
|
|
219
224
|
return l("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
220
225
|
type: A.Desktop,
|
|
221
|
-
os:
|
|
222
|
-
browser:
|
|
226
|
+
os: se,
|
|
227
|
+
browser: se
|
|
223
228
|
};
|
|
224
229
|
}
|
|
225
|
-
},
|
|
230
|
+
}, rt = [
|
|
226
231
|
// Email addresses
|
|
227
232
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
228
233
|
// US Phone numbers (various formats)
|
|
@@ -237,7 +242,7 @@ const It = () => {
|
|
|
237
242
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
238
243
|
// Passwords in connection strings (protocol://user:password@host)
|
|
239
244
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
240
|
-
],
|
|
245
|
+
], Fe = 500, $e = 5e3, ee = 50, Ut = ee * 2, st = 1, Ht = 1e3, xt = 10, Be = 5e3, Ft = 6e4, fs = {
|
|
241
246
|
LCP: 2500,
|
|
242
247
|
// Good: ≤ 2.5s
|
|
243
248
|
FCP: 1800,
|
|
@@ -249,7 +254,7 @@ const It = () => {
|
|
|
249
254
|
TTFB: 800,
|
|
250
255
|
// Good: ≤ 800ms
|
|
251
256
|
LONG_TASK: 50
|
|
252
|
-
},
|
|
257
|
+
}, We = {
|
|
253
258
|
LCP: 2500,
|
|
254
259
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
255
260
|
FCP: 1800,
|
|
@@ -261,7 +266,7 @@ const It = () => {
|
|
|
261
266
|
TTFB: 800,
|
|
262
267
|
// Needs improvement: > 800ms
|
|
263
268
|
LONG_TASK: 50
|
|
264
|
-
},
|
|
269
|
+
}, $t = {
|
|
265
270
|
LCP: 4e3,
|
|
266
271
|
// Poor: > 4s
|
|
267
272
|
FCP: 3e3,
|
|
@@ -273,53 +278,53 @@ const It = () => {
|
|
|
273
278
|
TTFB: 1800,
|
|
274
279
|
// Poor: > 1800ms
|
|
275
280
|
LONG_TASK: 50
|
|
276
|
-
},
|
|
281
|
+
}, Se = "needs-improvement", Ge = (s = Se) => {
|
|
277
282
|
switch (s) {
|
|
278
283
|
case "all":
|
|
279
284
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
280
285
|
// Track everything
|
|
281
286
|
case "needs-improvement":
|
|
282
|
-
return
|
|
287
|
+
return We;
|
|
283
288
|
case "poor":
|
|
284
|
-
return
|
|
289
|
+
return $t;
|
|
285
290
|
default:
|
|
286
|
-
return
|
|
291
|
+
return We;
|
|
287
292
|
}
|
|
288
|
-
},
|
|
293
|
+
}, Bt = 1e3, Wt = 50, Gt = "2.5.0", Xt = Gt, nt = () => typeof window < "u" && typeof sessionStorage < "u", Qt = () => {
|
|
289
294
|
try {
|
|
290
295
|
const s = new URLSearchParams(window.location.search);
|
|
291
|
-
s.delete(
|
|
296
|
+
s.delete(Je);
|
|
292
297
|
const e = s.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
293
298
|
window.history.replaceState({}, "", t);
|
|
294
299
|
} catch {
|
|
295
300
|
}
|
|
296
|
-
},
|
|
297
|
-
if (!
|
|
301
|
+
}, jt = () => {
|
|
302
|
+
if (!nt())
|
|
298
303
|
return !1;
|
|
299
304
|
try {
|
|
300
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
305
|
+
const e = new URLSearchParams(window.location.search).get(Je), t = sessionStorage.getItem(G);
|
|
301
306
|
let r = null;
|
|
302
|
-
return e ===
|
|
307
|
+
return e === Pe ? (r = !0, sessionStorage.setItem(G, "true"), l("info", "QA Mode ACTIVE", {
|
|
303
308
|
visibility: "qa",
|
|
304
|
-
style:
|
|
305
|
-
})) : e ===
|
|
309
|
+
style: Ze
|
|
310
|
+
})) : e === De && (r = !1, sessionStorage.setItem(G, "false"), l("info", "QA Mode DISABLED", {
|
|
306
311
|
visibility: "qa",
|
|
307
|
-
style:
|
|
308
|
-
})), (e ===
|
|
312
|
+
style: et
|
|
313
|
+
})), (e === Pe || e === De) && Qt(), r ?? t === "true";
|
|
309
314
|
} catch {
|
|
310
315
|
return !1;
|
|
311
316
|
}
|
|
312
|
-
},
|
|
313
|
-
if (
|
|
317
|
+
}, zt = (s) => {
|
|
318
|
+
if (nt())
|
|
314
319
|
try {
|
|
315
|
-
sessionStorage.setItem(
|
|
320
|
+
sessionStorage.setItem(G, s ? "true" : "false"), l("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
316
321
|
visibility: "qa",
|
|
317
|
-
style: s ?
|
|
322
|
+
style: s ? Ze : et
|
|
318
323
|
});
|
|
319
324
|
} catch {
|
|
320
325
|
l("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
321
326
|
}
|
|
322
|
-
},
|
|
327
|
+
}, Kt = [
|
|
323
328
|
"co.uk",
|
|
324
329
|
"org.uk",
|
|
325
330
|
"com.au",
|
|
@@ -331,40 +336,40 @@ const It = () => {
|
|
|
331
336
|
"co.in",
|
|
332
337
|
"com.cn",
|
|
333
338
|
"co.za"
|
|
334
|
-
],
|
|
339
|
+
], Xe = (s) => {
|
|
335
340
|
const e = s.toLowerCase().split(".");
|
|
336
341
|
if (e.length <= 2)
|
|
337
342
|
return s.toLowerCase();
|
|
338
343
|
const t = e.slice(-2).join(".");
|
|
339
|
-
return
|
|
340
|
-
},
|
|
344
|
+
return Kt.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
345
|
+
}, Yt = (s, e) => s === e ? !0 : Xe(s) === Xe(e), ce = () => {
|
|
341
346
|
const s = document.referrer;
|
|
342
347
|
if (!s)
|
|
343
348
|
return "Direct";
|
|
344
349
|
try {
|
|
345
350
|
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
346
|
-
return
|
|
351
|
+
return Yt(e, t) ? "Direct" : s;
|
|
347
352
|
} catch (e) {
|
|
348
353
|
return l("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
349
354
|
}
|
|
350
|
-
},
|
|
355
|
+
}, ue = () => {
|
|
351
356
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
352
|
-
return
|
|
357
|
+
return Tt.forEach((r) => {
|
|
353
358
|
const n = s.get(r);
|
|
354
359
|
if (n) {
|
|
355
360
|
const i = r.split("utm_")[1];
|
|
356
361
|
e[i] = n;
|
|
357
362
|
}
|
|
358
363
|
}), Object.keys(e).length ? e : void 0;
|
|
359
|
-
},
|
|
364
|
+
}, qt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
360
365
|
const e = Math.random() * 16 | 0;
|
|
361
366
|
return (s === "x" ? e : e & 3 | 8).toString(16);
|
|
362
367
|
});
|
|
363
|
-
let
|
|
364
|
-
const
|
|
368
|
+
let Y = 0, q = 0;
|
|
369
|
+
const Jt = () => {
|
|
365
370
|
let s = Date.now();
|
|
366
|
-
s <
|
|
367
|
-
const e =
|
|
371
|
+
s < q && (s = q), s === q ? Y = (Y + 1) % 1e3 : Y = 0, q = s;
|
|
372
|
+
const e = Y.toString().padStart(3, "0");
|
|
368
373
|
let t = "";
|
|
369
374
|
try {
|
|
370
375
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -374,14 +379,14 @@ const Bt = () => {
|
|
|
374
379
|
} catch {
|
|
375
380
|
}
|
|
376
381
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${s}-${e}-${t}`;
|
|
377
|
-
},
|
|
382
|
+
}, it = (s, e = !1) => {
|
|
378
383
|
try {
|
|
379
384
|
const t = new URL(s), r = t.protocol === "https:", n = t.protocol === "http:";
|
|
380
385
|
return r || e && n;
|
|
381
386
|
} catch {
|
|
382
387
|
return !1;
|
|
383
388
|
}
|
|
384
|
-
},
|
|
389
|
+
}, Zt = (s) => {
|
|
385
390
|
try {
|
|
386
391
|
const t = new URL(window.location.href).hostname;
|
|
387
392
|
if (!t || typeof t != "string")
|
|
@@ -399,28 +404,28 @@ const Bt = () => {
|
|
|
399
404
|
if (r.length === 2 ? n = r.join(".") : n = r.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
400
405
|
throw new Error("Invalid domain structure for SaaS");
|
|
401
406
|
const i = `https://${s}.${n}/collect`;
|
|
402
|
-
if (!
|
|
407
|
+
if (!it(i))
|
|
403
408
|
throw new Error("Generated URL failed validation");
|
|
404
409
|
return i;
|
|
405
410
|
} catch (e) {
|
|
406
411
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
407
412
|
}
|
|
408
|
-
},
|
|
413
|
+
}, er = (s) => {
|
|
409
414
|
const e = {};
|
|
410
|
-
s.integrations?.tracelog?.projectId && (e.saas =
|
|
415
|
+
s.integrations?.tracelog?.projectId && (e.saas = Zt(s.integrations.tracelog.projectId));
|
|
411
416
|
const t = s.integrations?.custom?.collectApiUrl;
|
|
412
417
|
if (t) {
|
|
413
418
|
const r = s.integrations?.custom?.allowHttp ?? !1;
|
|
414
|
-
if (!
|
|
419
|
+
if (!it(t, r))
|
|
415
420
|
throw new Error("Invalid custom API URL");
|
|
416
421
|
e.custom = t;
|
|
417
422
|
}
|
|
418
423
|
return e;
|
|
419
|
-
},
|
|
424
|
+
}, pe = (s, e = []) => {
|
|
420
425
|
if (!s || typeof s != "string")
|
|
421
426
|
return l("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof s } }), s || "";
|
|
422
427
|
try {
|
|
423
|
-
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
428
|
+
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...vt, ...e])];
|
|
424
429
|
let i = !1;
|
|
425
430
|
const o = [];
|
|
426
431
|
return n.forEach((c) => {
|
|
@@ -429,13 +434,13 @@ const Bt = () => {
|
|
|
429
434
|
} catch (t) {
|
|
430
435
|
return l("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
431
436
|
}
|
|
432
|
-
},
|
|
437
|
+
}, Qe = (s) => {
|
|
433
438
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
434
439
|
return "";
|
|
435
440
|
let e = s;
|
|
436
441
|
s.length > 1e3 && (e = s.slice(0, Math.max(0, 1e3)));
|
|
437
442
|
let t = 0;
|
|
438
|
-
for (const n of
|
|
443
|
+
for (const n of _t) {
|
|
439
444
|
const i = e;
|
|
440
445
|
e = e.replace(n, ""), i !== e && t++;
|
|
441
446
|
}
|
|
@@ -445,11 +450,11 @@ const Bt = () => {
|
|
|
445
450
|
valueLength: s.length
|
|
446
451
|
}
|
|
447
452
|
}), e.trim();
|
|
448
|
-
},
|
|
453
|
+
}, Te = (s, e = 0) => {
|
|
449
454
|
if (s == null)
|
|
450
455
|
return null;
|
|
451
456
|
if (typeof s == "string")
|
|
452
|
-
return
|
|
457
|
+
return Qe(s);
|
|
453
458
|
if (typeof s == "number")
|
|
454
459
|
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
455
460
|
if (typeof s == "boolean")
|
|
@@ -457,38 +462,38 @@ const Bt = () => {
|
|
|
457
462
|
if (e > 10)
|
|
458
463
|
return null;
|
|
459
464
|
if (Array.isArray(s))
|
|
460
|
-
return s.slice(0, 100).map((n) =>
|
|
465
|
+
return s.slice(0, 100).map((n) => Te(n, e + 1)).filter((n) => n !== null);
|
|
461
466
|
if (typeof s == "object") {
|
|
462
467
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
463
468
|
for (const [i, o] of n) {
|
|
464
|
-
const a =
|
|
469
|
+
const a = Qe(i);
|
|
465
470
|
if (a) {
|
|
466
|
-
const c =
|
|
471
|
+
const c = Te(o, e + 1);
|
|
467
472
|
c !== null && (t[a] = c);
|
|
468
473
|
}
|
|
469
474
|
}
|
|
470
475
|
return t;
|
|
471
476
|
}
|
|
472
477
|
return null;
|
|
473
|
-
},
|
|
478
|
+
}, tr = (s) => {
|
|
474
479
|
if (typeof s != "object" || s === null)
|
|
475
480
|
return {};
|
|
476
481
|
try {
|
|
477
|
-
const e =
|
|
482
|
+
const e = Te(s);
|
|
478
483
|
return typeof e == "object" && e !== null ? e : {};
|
|
479
484
|
} catch (e) {
|
|
480
485
|
const t = e instanceof Error ? e.message : String(e);
|
|
481
486
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
482
487
|
}
|
|
483
|
-
},
|
|
488
|
+
}, rr = (s) => {
|
|
484
489
|
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
485
490
|
throw new f("Configuration must be an object", "config");
|
|
486
491
|
if (s) {
|
|
487
492
|
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
488
|
-
throw new
|
|
493
|
+
throw new bt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
489
494
|
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
490
495
|
throw new f(m.INVALID_GLOBAL_METADATA, "config");
|
|
491
|
-
if (s.integrations &&
|
|
496
|
+
if (s.integrations && nr(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
492
497
|
if (!Array.isArray(s.sensitiveQueryParams))
|
|
493
498
|
throw new f(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
494
499
|
for (const e of s.sensitiveQueryParams)
|
|
@@ -496,9 +501,9 @@ const Bt = () => {
|
|
|
496
501
|
throw new f("All sensitive query params must be strings", "config");
|
|
497
502
|
}
|
|
498
503
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
499
|
-
throw new
|
|
504
|
+
throw new xe(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
500
505
|
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
501
|
-
throw new
|
|
506
|
+
throw new xe(m.INVALID_SAMPLING_RATE, "config");
|
|
502
507
|
if (s.primaryScrollSelector !== void 0) {
|
|
503
508
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
504
509
|
throw new f(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -520,7 +525,7 @@ const Bt = () => {
|
|
|
520
525
|
throw new f(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
521
526
|
if (s.sendIntervalMs !== void 0 && (!Number.isFinite(s.sendIntervalMs) || s.sendIntervalMs < 1e3 || s.sendIntervalMs > 6e4))
|
|
522
527
|
throw new f(m.INVALID_SEND_INTERVAL, "config");
|
|
523
|
-
if (s.viewport !== void 0 &&
|
|
528
|
+
if (s.viewport !== void 0 && sr(s.viewport), s.webVitalsMode !== void 0) {
|
|
524
529
|
if (typeof s.webVitalsMode != "string")
|
|
525
530
|
throw new f(
|
|
526
531
|
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
@@ -551,7 +556,7 @@ const Bt = () => {
|
|
|
551
556
|
}
|
|
552
557
|
}
|
|
553
558
|
}
|
|
554
|
-
},
|
|
559
|
+
}, sr = (s) => {
|
|
555
560
|
if (typeof s != "object" || s === null)
|
|
556
561
|
throw new f(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
557
562
|
if (!s.elements || !Array.isArray(s.elements))
|
|
@@ -581,35 +586,35 @@ const Bt = () => {
|
|
|
581
586
|
throw new f(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
582
587
|
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
583
588
|
throw new f(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
584
|
-
},
|
|
589
|
+
}, nr = (s) => {
|
|
585
590
|
if (s) {
|
|
586
591
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
587
|
-
throw new
|
|
592
|
+
throw new U(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
588
593
|
if (s.custom) {
|
|
589
594
|
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
590
|
-
throw new
|
|
595
|
+
throw new U(m.INVALID_CUSTOM_API_URL, "config");
|
|
591
596
|
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
592
|
-
throw new
|
|
597
|
+
throw new U("allowHttp must be a boolean", "config");
|
|
593
598
|
const e = s.custom.collectApiUrl.trim();
|
|
594
599
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
595
|
-
throw new
|
|
600
|
+
throw new U('Custom API URL must start with "http://" or "https://"', "config");
|
|
596
601
|
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
597
|
-
throw new
|
|
602
|
+
throw new U(
|
|
598
603
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
599
604
|
"config"
|
|
600
605
|
);
|
|
601
606
|
if (s.custom.fetchCredentials !== void 0 && !["include", "same-origin", "omit"].includes(s.custom.fetchCredentials))
|
|
602
|
-
throw new
|
|
607
|
+
throw new U('fetchCredentials must be "include", "same-origin", or "omit"', "config");
|
|
603
608
|
}
|
|
604
609
|
}
|
|
605
|
-
},
|
|
606
|
-
|
|
610
|
+
}, ir = (s) => {
|
|
611
|
+
rr(s);
|
|
607
612
|
const e = {
|
|
608
613
|
...s ?? {},
|
|
609
614
|
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
610
615
|
globalMetadata: s?.globalMetadata ?? {},
|
|
611
616
|
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
612
|
-
errorSampling: s?.errorSampling ??
|
|
617
|
+
errorSampling: s?.errorSampling ?? st,
|
|
613
618
|
samplingRate: s?.samplingRate ?? 1,
|
|
614
619
|
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
615
620
|
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
@@ -626,12 +631,12 @@ const Bt = () => {
|
|
|
626
631
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
627
632
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
628
633
|
}), e;
|
|
629
|
-
},
|
|
634
|
+
}, ve = (s, e = /* @__PURE__ */ new Set()) => {
|
|
630
635
|
if (s == null)
|
|
631
636
|
return !0;
|
|
632
637
|
const t = typeof s;
|
|
633
|
-
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) =>
|
|
634
|
-
},
|
|
638
|
+
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) => ve(r, e)) : t === "object" ? Object.values(s).every((r) => ve(r, e)) : !1);
|
|
639
|
+
}, or = (s) => typeof s != "object" || s === null ? !1 : ve(s), ar = (s) => typeof s != "string" ? {
|
|
635
640
|
valid: !1,
|
|
636
641
|
error: "Event name must be a string"
|
|
637
642
|
} : s.length === 0 ? {
|
|
@@ -646,9 +651,9 @@ const Bt = () => {
|
|
|
646
651
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
647
652
|
valid: !1,
|
|
648
653
|
error: "Event name cannot be a reserved word"
|
|
649
|
-
} : { valid: !0 },
|
|
650
|
-
const r =
|
|
651
|
-
if (!
|
|
654
|
+
} : { valid: !0 }, je = (s, e, t) => {
|
|
655
|
+
const r = tr(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
656
|
+
if (!or(r))
|
|
652
657
|
return {
|
|
653
658
|
valid: !1,
|
|
654
659
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -696,7 +701,7 @@ const Bt = () => {
|
|
|
696
701
|
valid: !0,
|
|
697
702
|
sanitizedMetadata: r
|
|
698
703
|
};
|
|
699
|
-
},
|
|
704
|
+
}, ot = (s, e, t) => {
|
|
700
705
|
if (Array.isArray(e)) {
|
|
701
706
|
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
702
707
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -706,7 +711,7 @@ const Bt = () => {
|
|
|
706
711
|
valid: !1,
|
|
707
712
|
error: `${n}: array item at index ${i} must be an object.`
|
|
708
713
|
};
|
|
709
|
-
const a =
|
|
714
|
+
const a = je(s, o, t);
|
|
710
715
|
if (!a.valid)
|
|
711
716
|
return {
|
|
712
717
|
valid: !1,
|
|
@@ -719,16 +724,16 @@ const Bt = () => {
|
|
|
719
724
|
sanitizedMetadata: r
|
|
720
725
|
};
|
|
721
726
|
}
|
|
722
|
-
return
|
|
723
|
-
},
|
|
724
|
-
const t =
|
|
727
|
+
return je(s, e, t);
|
|
728
|
+
}, lr = (s, e) => {
|
|
729
|
+
const t = ar(s);
|
|
725
730
|
if (!t.valid)
|
|
726
731
|
return l("error", "Event name validation failed", {
|
|
727
732
|
data: { eventName: s, error: t.error }
|
|
728
733
|
}), t;
|
|
729
734
|
if (!e)
|
|
730
735
|
return { valid: !0 };
|
|
731
|
-
const r =
|
|
736
|
+
const r = ot(s, e, "customEvent");
|
|
732
737
|
return r.valid || l("error", "Event metadata validation failed", {
|
|
733
738
|
data: {
|
|
734
739
|
eventName: s,
|
|
@@ -736,7 +741,7 @@ const Bt = () => {
|
|
|
736
741
|
}
|
|
737
742
|
}), r;
|
|
738
743
|
};
|
|
739
|
-
class
|
|
744
|
+
class cr {
|
|
740
745
|
listeners = /* @__PURE__ */ new Map();
|
|
741
746
|
/**
|
|
742
747
|
* Subscribes to an event channel
|
|
@@ -853,7 +858,7 @@ class Zt {
|
|
|
853
858
|
this.listeners.clear();
|
|
854
859
|
}
|
|
855
860
|
}
|
|
856
|
-
function
|
|
861
|
+
function at(s, e, t) {
|
|
857
862
|
try {
|
|
858
863
|
const r = e(s);
|
|
859
864
|
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (l("warn", `beforeSend transformer returned invalid data, using original [${t}]`), s);
|
|
@@ -864,10 +869,10 @@ function Ze(s, e, t) {
|
|
|
864
869
|
}), s;
|
|
865
870
|
}
|
|
866
871
|
}
|
|
867
|
-
function
|
|
868
|
-
return s.map((r) =>
|
|
872
|
+
function ur(s, e, t) {
|
|
873
|
+
return s.map((r) => at(r, e, t)).filter((r) => r !== null);
|
|
869
874
|
}
|
|
870
|
-
function
|
|
875
|
+
function lt(s, e, t) {
|
|
871
876
|
try {
|
|
872
877
|
const r = e(s);
|
|
873
878
|
return r === null ? (l("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -883,8 +888,8 @@ function et(s, e, t) {
|
|
|
883
888
|
}), s;
|
|
884
889
|
}
|
|
885
890
|
}
|
|
886
|
-
const
|
|
887
|
-
class
|
|
891
|
+
const de = {};
|
|
892
|
+
class w {
|
|
888
893
|
/**
|
|
889
894
|
* Retrieves a value from global state.
|
|
890
895
|
*
|
|
@@ -902,7 +907,7 @@ class v {
|
|
|
902
907
|
* ```
|
|
903
908
|
*/
|
|
904
909
|
get(e) {
|
|
905
|
-
return
|
|
910
|
+
return de[e];
|
|
906
911
|
}
|
|
907
912
|
/**
|
|
908
913
|
* Sets a value in global state.
|
|
@@ -922,7 +927,7 @@ class v {
|
|
|
922
927
|
* ```
|
|
923
928
|
*/
|
|
924
929
|
set(e, t) {
|
|
925
|
-
|
|
930
|
+
de[e] = t;
|
|
926
931
|
}
|
|
927
932
|
/**
|
|
928
933
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -939,10 +944,10 @@ class v {
|
|
|
939
944
|
* ```
|
|
940
945
|
*/
|
|
941
946
|
getState() {
|
|
942
|
-
return { ...
|
|
947
|
+
return { ...de };
|
|
943
948
|
}
|
|
944
949
|
}
|
|
945
|
-
class
|
|
950
|
+
class ze extends w {
|
|
946
951
|
storeManager;
|
|
947
952
|
integrationId;
|
|
948
953
|
apiUrl;
|
|
@@ -1018,7 +1023,7 @@ class $e extends v {
|
|
|
1018
1023
|
return { ...this.staticHeaders, ...e };
|
|
1019
1024
|
}
|
|
1020
1025
|
getQueueStorageKey() {
|
|
1021
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1026
|
+
const e = this.get("userId") || "anonymous", t = It(e);
|
|
1022
1027
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1023
1028
|
}
|
|
1024
1029
|
/**
|
|
@@ -1060,13 +1065,13 @@ class $e extends v {
|
|
|
1060
1065
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1061
1066
|
*/
|
|
1062
1067
|
sendEventsQueueSync(e) {
|
|
1063
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1068
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes($.Fail) ? (l(
|
|
1064
1069
|
"warn",
|
|
1065
1070
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1066
1071
|
{
|
|
1067
1072
|
data: { events: e.events.length }
|
|
1068
1073
|
}
|
|
1069
|
-
), !1) : this.apiUrl?.includes(
|
|
1074
|
+
), !1) : this.apiUrl?.includes($.Localhost) ? (l(
|
|
1070
1075
|
"debug",
|
|
1071
1076
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1072
1077
|
{
|
|
@@ -1091,7 +1096,8 @@ class $e extends v {
|
|
|
1091
1096
|
*
|
|
1092
1097
|
* **Error Handling**:
|
|
1093
1098
|
* - **Permanent errors** (4xx except 408, 429): Events discarded, not persisted
|
|
1094
|
-
* - **
|
|
1099
|
+
* - **Timeout errors** (all attempts timed out): Events NOT persisted (server likely received them)
|
|
1100
|
+
* - **Transient errors** (5xx, network, mixed): Events persisted for recovery
|
|
1095
1101
|
*
|
|
1096
1102
|
* **Important**: Events are NOT retried in-session. Persistence is for
|
|
1097
1103
|
* recovery on next page load via `recoverPersistedEvents()`.
|
|
@@ -1108,7 +1114,10 @@ class $e extends v {
|
|
|
1108
1114
|
const r = await this.send(e);
|
|
1109
1115
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
|
|
1110
1116
|
} catch (r) {
|
|
1111
|
-
return r instanceof
|
|
1117
|
+
return r instanceof N ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : r instanceof O ? (l(
|
|
1118
|
+
"debug",
|
|
1119
|
+
`All attempts timed out, skipping persistence (server likely received events)${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1120
|
+
), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1112
1121
|
}
|
|
1113
1122
|
}
|
|
1114
1123
|
/**
|
|
@@ -1175,10 +1184,17 @@ class $e extends v {
|
|
|
1175
1184
|
const r = this.createRecoveryBody(t);
|
|
1176
1185
|
await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
|
|
1177
1186
|
} catch (t) {
|
|
1178
|
-
if (t instanceof
|
|
1187
|
+
if (t instanceof N) {
|
|
1179
1188
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1180
1189
|
return;
|
|
1181
1190
|
}
|
|
1191
|
+
if (t instanceof O) {
|
|
1192
|
+
l(
|
|
1193
|
+
"debug",
|
|
1194
|
+
`Recovery timed out, clearing persisted events (server likely received them)${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1195
|
+
), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1182
1198
|
l("error", "Failed to recover persisted events", { error: t });
|
|
1183
1199
|
} finally {
|
|
1184
1200
|
this.recoveryInProgress = !1;
|
|
@@ -1229,7 +1245,7 @@ class $e extends v {
|
|
|
1229
1245
|
const t = this.transformers.beforeSend;
|
|
1230
1246
|
if (!t)
|
|
1231
1247
|
return e;
|
|
1232
|
-
const r =
|
|
1248
|
+
const r = ur(
|
|
1233
1249
|
e.events,
|
|
1234
1250
|
t,
|
|
1235
1251
|
this.integrationId || "SenderManager"
|
|
@@ -1274,7 +1290,7 @@ class $e extends v {
|
|
|
1274
1290
|
if (this.integrationId === "saas")
|
|
1275
1291
|
return e;
|
|
1276
1292
|
const t = this.transformers.beforeBatch;
|
|
1277
|
-
return t ?
|
|
1293
|
+
return t ? lt(e, t, this.integrationId || "SenderManager") : e;
|
|
1278
1294
|
}
|
|
1279
1295
|
/**
|
|
1280
1296
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1332,6 +1348,7 @@ class $e extends v {
|
|
|
1332
1348
|
* @param body - Event queue to send
|
|
1333
1349
|
* @returns Promise resolving to true if send succeeded, false if all retries exhausted
|
|
1334
1350
|
* @throws PermanentError for 4xx errors (caller should not retry)
|
|
1351
|
+
* @throws TimeoutError when all retry attempts timed out (caller should not persist)
|
|
1335
1352
|
*/
|
|
1336
1353
|
async send(e) {
|
|
1337
1354
|
if (this.shouldSkipSend())
|
|
@@ -1342,44 +1359,47 @@ class $e extends v {
|
|
|
1342
1359
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1343
1360
|
if (!r)
|
|
1344
1361
|
return !0;
|
|
1345
|
-
if (this.apiUrl?.includes(
|
|
1362
|
+
if (this.apiUrl?.includes($.Fail))
|
|
1346
1363
|
return l("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1347
1364
|
data: { events: r.events.length }
|
|
1348
1365
|
}), !1;
|
|
1349
|
-
if (this.apiUrl?.includes(
|
|
1366
|
+
if (this.apiUrl?.includes($.Localhost))
|
|
1350
1367
|
return l("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1351
1368
|
data: { events: r.events.length }
|
|
1352
1369
|
}), !0;
|
|
1353
1370
|
const { url: n, payload: i } = this.prepareRequest(r);
|
|
1354
|
-
|
|
1371
|
+
let o = !0;
|
|
1372
|
+
for (let a = 1; a <= 3; a++)
|
|
1355
1373
|
try {
|
|
1356
|
-
return (await this.sendWithTimeout(n, i)).ok ? (
|
|
1374
|
+
return (await this.sendWithTimeout(n, i)).ok ? (a > 1 && l(
|
|
1357
1375
|
"info",
|
|
1358
|
-
`Send succeeded after ${
|
|
1376
|
+
`Send succeeded after ${a - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1359
1377
|
{
|
|
1360
|
-
data: { events: r.events.length, attempt:
|
|
1378
|
+
data: { events: r.events.length, attempt: a }
|
|
1361
1379
|
}
|
|
1362
1380
|
), !0) : !1;
|
|
1363
|
-
} catch (
|
|
1364
|
-
const
|
|
1365
|
-
if (
|
|
1366
|
-
throw
|
|
1367
|
-
if (l(
|
|
1368
|
-
|
|
1369
|
-
`Send attempt ${
|
|
1381
|
+
} catch (c) {
|
|
1382
|
+
const u = a === 3;
|
|
1383
|
+
if (c instanceof N)
|
|
1384
|
+
throw c;
|
|
1385
|
+
if (c instanceof O || (o = !1), l(
|
|
1386
|
+
u ? "error" : "warn",
|
|
1387
|
+
`Send attempt ${a} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${u ? " (all retries exhausted)" : ", will retry"}`,
|
|
1370
1388
|
{
|
|
1371
|
-
error:
|
|
1389
|
+
error: c,
|
|
1372
1390
|
data: {
|
|
1373
1391
|
events: e.events.length,
|
|
1374
1392
|
url: n.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1375
|
-
attempt:
|
|
1393
|
+
attempt: a,
|
|
1376
1394
|
maxAttempts: 3
|
|
1377
1395
|
}
|
|
1378
1396
|
}
|
|
1379
|
-
), !
|
|
1380
|
-
await this.backoffDelay(
|
|
1397
|
+
), !u) {
|
|
1398
|
+
await this.backoffDelay(a);
|
|
1381
1399
|
continue;
|
|
1382
1400
|
}
|
|
1401
|
+
if (o)
|
|
1402
|
+
throw new O("All retry attempts timed out (server likely received the request)");
|
|
1383
1403
|
return !1;
|
|
1384
1404
|
}
|
|
1385
1405
|
return !1;
|
|
@@ -1392,42 +1412,47 @@ class $e extends v {
|
|
|
1392
1412
|
*
|
|
1393
1413
|
* **Timeout Behavior**:
|
|
1394
1414
|
* - 10-second timeout via AbortController (REQUEST_TIMEOUT_MS constant)
|
|
1395
|
-
* - Aborted requests throw
|
|
1415
|
+
* - Aborted requests throw TimeoutError (caller decides persistence)
|
|
1396
1416
|
*
|
|
1397
1417
|
* **Error Classification**:
|
|
1398
1418
|
* - 4xx (except 408, 429): PermanentError thrown → no retries
|
|
1419
|
+
* - Timeout: TimeoutError thrown → caller tracks for persistence decision
|
|
1399
1420
|
* - 408, 429, 5xx, network: Standard Error thrown → triggers retry
|
|
1400
1421
|
*
|
|
1401
1422
|
* @param url - API endpoint URL
|
|
1402
1423
|
* @param payload - JSON-stringified EventsQueue body
|
|
1403
1424
|
* @returns Response object if successful
|
|
1404
1425
|
* @throws PermanentError for unrecoverable 4xx errors
|
|
1405
|
-
* @throws
|
|
1426
|
+
* @throws TimeoutError when request times out (server likely received it)
|
|
1427
|
+
* @throws Error for transient errors (5xx, network)
|
|
1406
1428
|
* @private
|
|
1407
1429
|
*/
|
|
1408
1430
|
async sendWithTimeout(e, t) {
|
|
1409
1431
|
const r = new AbortController();
|
|
1410
1432
|
this.pendingControllers.add(r);
|
|
1411
|
-
|
|
1412
|
-
|
|
1433
|
+
let n = !1;
|
|
1434
|
+
const i = setTimeout(() => {
|
|
1435
|
+
n = !0, r.abort();
|
|
1413
1436
|
}, 15e3);
|
|
1414
1437
|
try {
|
|
1415
|
-
const
|
|
1438
|
+
const o = this.getCustomHeaders(), a = await fetch(e, {
|
|
1416
1439
|
method: "POST",
|
|
1417
1440
|
body: t,
|
|
1418
1441
|
keepalive: !0,
|
|
1419
1442
|
credentials: this.fetchCredentials,
|
|
1420
1443
|
signal: r.signal,
|
|
1421
1444
|
headers: {
|
|
1422
|
-
...
|
|
1445
|
+
...o,
|
|
1423
1446
|
"Content-Type": "application/json"
|
|
1424
1447
|
}
|
|
1425
1448
|
});
|
|
1426
|
-
if (!
|
|
1427
|
-
throw
|
|
1428
|
-
return
|
|
1449
|
+
if (!a.ok)
|
|
1450
|
+
throw a.status >= 400 && a.status < 500 && a.status !== 408 && a.status !== 429 ? new N(`HTTP ${a.status}: ${a.statusText}`, a.status) : new Error(`HTTP ${a.status}: ${a.statusText}`);
|
|
1451
|
+
return a;
|
|
1452
|
+
} catch (o) {
|
|
1453
|
+
throw o instanceof N ? o : n ? new O("Request timed out (server likely received the request)") : o;
|
|
1429
1454
|
} finally {
|
|
1430
|
-
clearTimeout(
|
|
1455
|
+
clearTimeout(i), this.pendingControllers.delete(r);
|
|
1431
1456
|
}
|
|
1432
1457
|
}
|
|
1433
1458
|
/**
|
|
@@ -1508,7 +1533,7 @@ class $e extends v {
|
|
|
1508
1533
|
_metadata: {
|
|
1509
1534
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1510
1535
|
timestamp: t,
|
|
1511
|
-
client_version:
|
|
1536
|
+
client_version: Xt
|
|
1512
1537
|
}
|
|
1513
1538
|
};
|
|
1514
1539
|
return {
|
|
@@ -1629,12 +1654,12 @@ class $e extends v {
|
|
|
1629
1654
|
}
|
|
1630
1655
|
logPermanentError(e, t) {
|
|
1631
1656
|
const r = Date.now();
|
|
1632
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1657
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= Ft) && (l("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1633
1658
|
data: { status: t.statusCode, message: t.message }
|
|
1634
1659
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1635
1660
|
}
|
|
1636
1661
|
}
|
|
1637
|
-
class
|
|
1662
|
+
class dr extends w {
|
|
1638
1663
|
bootTime;
|
|
1639
1664
|
bootTimestamp;
|
|
1640
1665
|
hasPerformanceNow;
|
|
@@ -1783,8 +1808,8 @@ class tr extends v {
|
|
|
1783
1808
|
};
|
|
1784
1809
|
}
|
|
1785
1810
|
}
|
|
1786
|
-
const
|
|
1787
|
-
class
|
|
1811
|
+
const hr = new Set(Object.values(d));
|
|
1812
|
+
class fr extends w {
|
|
1788
1813
|
dataSenders;
|
|
1789
1814
|
emitter;
|
|
1790
1815
|
transformers;
|
|
@@ -1823,10 +1848,10 @@ class sr extends v {
|
|
|
1823
1848
|
* @param fetchCredentials - Fetch credentials mode for custom backend. @default 'include'
|
|
1824
1849
|
*/
|
|
1825
1850
|
constructor(e, t = null, r = {}, n = {}, i, o = "include") {
|
|
1826
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1851
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new dr(), this.dataSenders = [];
|
|
1827
1852
|
const a = this.get("collectApiUrls");
|
|
1828
|
-
a?.saas && this.dataSenders.push(new
|
|
1829
|
-
new
|
|
1853
|
+
a?.saas && this.dataSenders.push(new ze(e, "saas", a.saas, r)), a?.custom && this.dataSenders.push(
|
|
1854
|
+
new ze(
|
|
1830
1855
|
e,
|
|
1831
1856
|
"custom",
|
|
1832
1857
|
a.custom,
|
|
@@ -1954,7 +1979,7 @@ class sr extends v {
|
|
|
1954
1979
|
l("error", "Event type is required - event will be ignored");
|
|
1955
1980
|
return;
|
|
1956
1981
|
}
|
|
1957
|
-
if (!
|
|
1982
|
+
if (!hr.has(e)) {
|
|
1958
1983
|
l("error", "Invalid event type - event will be ignored", {
|
|
1959
1984
|
data: { type: e }
|
|
1960
1985
|
});
|
|
@@ -1998,12 +2023,12 @@ class sr extends v {
|
|
|
1998
2023
|
}
|
|
1999
2024
|
const T = this.getTypeLimitForEvent(E);
|
|
2000
2025
|
if (T) {
|
|
2001
|
-
const
|
|
2002
|
-
if (
|
|
2026
|
+
const le = this.sessionEventCounts[E];
|
|
2027
|
+
if (le !== void 0 && le >= T) {
|
|
2003
2028
|
l("warn", "Session event type limit reached", {
|
|
2004
2029
|
data: {
|
|
2005
2030
|
type: E,
|
|
2006
|
-
count:
|
|
2031
|
+
count: le,
|
|
2007
2032
|
limit: T
|
|
2008
2033
|
}
|
|
2009
2034
|
});
|
|
@@ -2016,9 +2041,9 @@ class sr extends v {
|
|
|
2016
2041
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
2017
2042
|
return;
|
|
2018
2043
|
}
|
|
2019
|
-
const
|
|
2044
|
+
const Ne = E === d.SESSION_START, K = t || this.get("pageUrl"), F = this.buildEventPayload({
|
|
2020
2045
|
type: E,
|
|
2021
|
-
page_url:
|
|
2046
|
+
page_url: K,
|
|
2022
2047
|
from_page_url: r,
|
|
2023
2048
|
scroll_data: n,
|
|
2024
2049
|
click_data: i,
|
|
@@ -2028,8 +2053,8 @@ class sr extends v {
|
|
|
2028
2053
|
viewport_data: u,
|
|
2029
2054
|
page_view: S
|
|
2030
2055
|
});
|
|
2031
|
-
if (
|
|
2032
|
-
if (
|
|
2056
|
+
if (F && !(!p && !this.shouldSample())) {
|
|
2057
|
+
if (Ne) {
|
|
2033
2058
|
const T = this.get("sessionId");
|
|
2034
2059
|
if (!T) {
|
|
2035
2060
|
l("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2043,8 +2068,8 @@ class sr extends v {
|
|
|
2043
2068
|
}
|
|
2044
2069
|
this.set("hasStartSession", !0);
|
|
2045
2070
|
}
|
|
2046
|
-
if (!this.isDuplicateEvent(
|
|
2047
|
-
if (this.get("mode") ===
|
|
2071
|
+
if (!this.isDuplicateEvent(F)) {
|
|
2072
|
+
if (this.get("mode") === re.QA) {
|
|
2048
2073
|
if (E === d.CUSTOM && o) {
|
|
2049
2074
|
l("info", `Custom Event: ${o.name}`, {
|
|
2050
2075
|
visibility: "qa",
|
|
@@ -2052,7 +2077,7 @@ class sr extends v {
|
|
|
2052
2077
|
name: o.name,
|
|
2053
2078
|
...o.metadata && { metadata: o.metadata }
|
|
2054
2079
|
}
|
|
2055
|
-
}), this.emitEvent(
|
|
2080
|
+
}), this.emitEvent(F);
|
|
2056
2081
|
return;
|
|
2057
2082
|
}
|
|
2058
2083
|
if (E === d.VIEWPORT_VISIBLE && u) {
|
|
@@ -2066,11 +2091,11 @@ class sr extends v {
|
|
|
2066
2091
|
visibilityRatio: u.visibilityRatio,
|
|
2067
2092
|
dwellTime: u.dwellTime
|
|
2068
2093
|
}
|
|
2069
|
-
}), this.emitEvent(
|
|
2094
|
+
}), this.emitEvent(F);
|
|
2070
2095
|
return;
|
|
2071
2096
|
}
|
|
2072
2097
|
}
|
|
2073
|
-
if (this.addToQueue(
|
|
2098
|
+
if (this.addToQueue(F), !p) {
|
|
2074
2099
|
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2075
2100
|
const T = this.get("sessionId");
|
|
2076
2101
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
@@ -2335,6 +2360,8 @@ class sr extends v {
|
|
|
2335
2360
|
flushEvents(e) {
|
|
2336
2361
|
if (this.eventsQueue.length === 0)
|
|
2337
2362
|
return e ? !0 : Promise.resolve(!0);
|
|
2363
|
+
if (!e && this.sendInProgress)
|
|
2364
|
+
return l("debug", "Async flush skipped: send already in progress"), Promise.resolve(!1);
|
|
2338
2365
|
const t = this.buildEventsPayload(), r = [...this.eventsQueue], n = r.map((i) => i.id);
|
|
2339
2366
|
if (this.dataSenders.length === 0)
|
|
2340
2367
|
return this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
|
|
@@ -2384,7 +2411,7 @@ class sr extends v {
|
|
|
2384
2411
|
data: { eventCount: t.length, failedCount: a }
|
|
2385
2412
|
});
|
|
2386
2413
|
} else
|
|
2387
|
-
this.consecutiveSendFailures
|
|
2414
|
+
this.consecutiveSendFailures = Math.min(this.consecutiveSendFailures + 1, 5), l("debug", "Periodic send complete failure, events kept in queue for retry", {
|
|
2388
2415
|
data: { eventCount: t.length }
|
|
2389
2416
|
});
|
|
2390
2417
|
this.eventsQueue.length === 0 ? this.clearSendTimeout() : this.scheduleSendTimeout();
|
|
@@ -2409,7 +2436,7 @@ class sr extends v {
|
|
|
2409
2436
|
};
|
|
2410
2437
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), a = this.transformers.beforeBatch;
|
|
2411
2438
|
if (!o && a) {
|
|
2412
|
-
const c =
|
|
2439
|
+
const c = lt(n, a, "EventManager");
|
|
2413
2440
|
c !== null && (n = c);
|
|
2414
2441
|
}
|
|
2415
2442
|
return n;
|
|
@@ -2421,7 +2448,7 @@ class sr extends v {
|
|
|
2421
2448
|
});
|
|
2422
2449
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2423
2450
|
let a = {
|
|
2424
|
-
id:
|
|
2451
|
+
id: Jt(),
|
|
2425
2452
|
type: e.type,
|
|
2426
2453
|
page_url: t,
|
|
2427
2454
|
timestamp: r,
|
|
@@ -2438,10 +2465,10 @@ class sr extends v {
|
|
|
2438
2465
|
};
|
|
2439
2466
|
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2440
2467
|
if (E && (!g || u && !p)) {
|
|
2441
|
-
const
|
|
2442
|
-
if (
|
|
2468
|
+
const K = at(a, E, "EventManager");
|
|
2469
|
+
if (K === null)
|
|
2443
2470
|
return null;
|
|
2444
|
-
a =
|
|
2471
|
+
a = K;
|
|
2445
2472
|
}
|
|
2446
2473
|
return a;
|
|
2447
2474
|
}
|
|
@@ -2485,10 +2512,10 @@ class sr extends v {
|
|
|
2485
2512
|
}
|
|
2486
2513
|
});
|
|
2487
2514
|
}
|
|
2488
|
-
this.
|
|
2515
|
+
this.scheduleSendTimeout(), this.eventsQueue.length >= 50 && this.consecutiveSendFailures < 5 && this.sendEventsQueue();
|
|
2489
2516
|
}
|
|
2490
2517
|
scheduleSendTimeout() {
|
|
2491
|
-
if (this.sendTimeoutId !== null
|
|
2518
|
+
if (this.sendTimeoutId !== null) return;
|
|
2492
2519
|
const e = this.calculateSendDelay();
|
|
2493
2520
|
this.sendTimeoutId = window.setTimeout(() => {
|
|
2494
2521
|
this.sendTimeoutId = null, this.eventsQueue.length > 0 && this.sendEventsQueue();
|
|
@@ -2532,10 +2559,10 @@ class sr extends v {
|
|
|
2532
2559
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2533
2560
|
}
|
|
2534
2561
|
emitEvent(e) {
|
|
2535
|
-
this.emitter && this.emitter.emit(
|
|
2562
|
+
this.emitter && this.emitter.emit(me.EVENT, e);
|
|
2536
2563
|
}
|
|
2537
2564
|
emitEventsQueue(e) {
|
|
2538
|
-
this.emitter && this.emitter.emit(
|
|
2565
|
+
this.emitter && this.emitter.emit(me.QUEUE, e);
|
|
2539
2566
|
}
|
|
2540
2567
|
/**
|
|
2541
2568
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2611,13 +2638,13 @@ class sr extends v {
|
|
|
2611
2638
|
loadSessionCounts(e) {
|
|
2612
2639
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2613
2640
|
return this.getInitialCounts();
|
|
2614
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2641
|
+
const t = this.get("userId") || "anonymous", r = Ve(t, e);
|
|
2615
2642
|
try {
|
|
2616
2643
|
const n = localStorage.getItem(r);
|
|
2617
2644
|
if (!n)
|
|
2618
2645
|
return this.getInitialCounts();
|
|
2619
2646
|
const i = JSON.parse(n);
|
|
2620
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2647
|
+
return i._timestamp && Date.now() - i._timestamp > ke ? (l("debug", "Session counts expired, clearing", {
|
|
2621
2648
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2622
2649
|
}), 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" ? {
|
|
2623
2650
|
total: i.total,
|
|
@@ -2662,17 +2689,17 @@ class sr extends v {
|
|
|
2662
2689
|
cleanupExpiredSessionCounts() {
|
|
2663
2690
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2664
2691
|
try {
|
|
2665
|
-
const e = localStorage.getItem(
|
|
2692
|
+
const e = localStorage.getItem(Ue);
|
|
2666
2693
|
if (e) {
|
|
2667
2694
|
const i = Date.now() - parseInt(e, 10);
|
|
2668
|
-
if (i <
|
|
2695
|
+
if (i < He) {
|
|
2669
2696
|
l("debug", "Skipping session counts cleanup (throttled)", {
|
|
2670
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2697
|
+
data: { timeSinceLastCleanup: i, throttleMs: He }
|
|
2671
2698
|
});
|
|
2672
2699
|
return;
|
|
2673
2700
|
}
|
|
2674
2701
|
}
|
|
2675
|
-
const t = this.get("userId") || "anonymous", r = `${
|
|
2702
|
+
const t = this.get("userId") || "anonymous", r = `${y}:${t}:session_counts:`, n = [];
|
|
2676
2703
|
for (let i = 0; i < localStorage.length; i++) {
|
|
2677
2704
|
const o = localStorage.key(i);
|
|
2678
2705
|
if (o?.startsWith(r))
|
|
@@ -2680,14 +2707,14 @@ class sr extends v {
|
|
|
2680
2707
|
const a = localStorage.getItem(o);
|
|
2681
2708
|
if (a) {
|
|
2682
2709
|
const c = JSON.parse(a);
|
|
2683
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2710
|
+
c._timestamp && Date.now() - c._timestamp > ke && n.push(o);
|
|
2684
2711
|
}
|
|
2685
2712
|
} catch {
|
|
2686
2713
|
}
|
|
2687
2714
|
}
|
|
2688
2715
|
n.forEach((i) => {
|
|
2689
2716
|
localStorage.removeItem(i), l("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2690
|
-
}), n.length > 0 && l("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2717
|
+
}), n.length > 0 && l("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Ue, Date.now().toString());
|
|
2691
2718
|
} catch (e) {
|
|
2692
2719
|
l("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2693
2720
|
}
|
|
@@ -2721,7 +2748,7 @@ class sr extends v {
|
|
|
2721
2748
|
* @internal
|
|
2722
2749
|
*/
|
|
2723
2750
|
saveSessionCounts(e) {
|
|
2724
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2751
|
+
const t = this.get("userId") || "anonymous", r = Ve(t, e);
|
|
2725
2752
|
try {
|
|
2726
2753
|
const n = {
|
|
2727
2754
|
...this.sessionEventCounts,
|
|
@@ -2737,7 +2764,7 @@ class sr extends v {
|
|
|
2737
2764
|
}
|
|
2738
2765
|
}
|
|
2739
2766
|
}
|
|
2740
|
-
class
|
|
2767
|
+
class mr {
|
|
2741
2768
|
/**
|
|
2742
2769
|
* Gets or creates a unique user ID.
|
|
2743
2770
|
*
|
|
@@ -2755,15 +2782,15 @@ class nr {
|
|
|
2755
2782
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2756
2783
|
*/
|
|
2757
2784
|
static getId(e) {
|
|
2758
|
-
const t = e.getItem(
|
|
2785
|
+
const t = e.getItem(Oe);
|
|
2759
2786
|
if (t)
|
|
2760
2787
|
return t;
|
|
2761
|
-
const r =
|
|
2762
|
-
return e.setItem(
|
|
2788
|
+
const r = qt();
|
|
2789
|
+
return e.setItem(Oe, r), r;
|
|
2763
2790
|
}
|
|
2764
2791
|
}
|
|
2765
|
-
const
|
|
2766
|
-
class
|
|
2792
|
+
const gr = /^\d{13}-[a-z0-9]{9}$/;
|
|
2793
|
+
class Er extends w {
|
|
2767
2794
|
storageManager;
|
|
2768
2795
|
eventManager;
|
|
2769
2796
|
projectId;
|
|
@@ -2789,7 +2816,7 @@ class or extends v {
|
|
|
2789
2816
|
return;
|
|
2790
2817
|
}
|
|
2791
2818
|
const e = this.getProjectId();
|
|
2792
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2819
|
+
this.broadcastChannel = new BroadcastChannel(yt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2793
2820
|
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2794
2821
|
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" && l("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2795
2822
|
};
|
|
@@ -2809,7 +2836,7 @@ class or extends v {
|
|
|
2809
2836
|
const e = this.loadStoredSession();
|
|
2810
2837
|
if (!e)
|
|
2811
2838
|
return null;
|
|
2812
|
-
if (!
|
|
2839
|
+
if (!gr.test(e.id))
|
|
2813
2840
|
return l("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2814
2841
|
data: { sessionId: e.id }
|
|
2815
2842
|
}), this.clearStoredSession(), null;
|
|
@@ -2844,7 +2871,7 @@ class or extends v {
|
|
|
2844
2871
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2845
2872
|
}
|
|
2846
2873
|
getSessionStorageKey() {
|
|
2847
|
-
return
|
|
2874
|
+
return wt(this.getProjectId());
|
|
2848
2875
|
}
|
|
2849
2876
|
getProjectId() {
|
|
2850
2877
|
return this.projectId;
|
|
@@ -2909,9 +2936,9 @@ class or extends v {
|
|
|
2909
2936
|
let r, n;
|
|
2910
2937
|
if (e) {
|
|
2911
2938
|
const i = this.loadStoredSession();
|
|
2912
|
-
r = i?.referrer ??
|
|
2939
|
+
r = i?.referrer ?? ce(), n = i?.utm ?? ue();
|
|
2913
2940
|
} else
|
|
2914
|
-
r =
|
|
2941
|
+
r = ce(), n = ue();
|
|
2915
2942
|
l("debug", "Session tracking initialized", {
|
|
2916
2943
|
data: {
|
|
2917
2944
|
sessionId: t,
|
|
@@ -2962,7 +2989,7 @@ class or extends v {
|
|
|
2962
2989
|
*/
|
|
2963
2990
|
renewSession() {
|
|
2964
2991
|
this.needsRenewal = !1;
|
|
2965
|
-
const e = this.generateSessionId(), t =
|
|
2992
|
+
const e = this.generateSessionId(), t = ce(), r = ue();
|
|
2966
2993
|
l("debug", "Renewing session after timeout", {
|
|
2967
2994
|
data: { newSessionId: e }
|
|
2968
2995
|
}), 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({
|
|
@@ -3083,7 +3110,7 @@ class or extends v {
|
|
|
3083
3110
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3084
3111
|
}
|
|
3085
3112
|
}
|
|
3086
|
-
class
|
|
3113
|
+
class Sr extends w {
|
|
3087
3114
|
eventManager;
|
|
3088
3115
|
storageManager;
|
|
3089
3116
|
sessionManager = null;
|
|
@@ -3118,7 +3145,7 @@ class ar extends v {
|
|
|
3118
3145
|
}
|
|
3119
3146
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3120
3147
|
try {
|
|
3121
|
-
this.sessionManager = new
|
|
3148
|
+
this.sessionManager = new Er(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3122
3149
|
} catch (r) {
|
|
3123
3150
|
if (this.sessionManager) {
|
|
3124
3151
|
try {
|
|
@@ -3171,7 +3198,7 @@ class ar extends v {
|
|
|
3171
3198
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3172
3199
|
}
|
|
3173
3200
|
}
|
|
3174
|
-
class
|
|
3201
|
+
class pr extends w {
|
|
3175
3202
|
eventManager;
|
|
3176
3203
|
onTrack;
|
|
3177
3204
|
originalPushState;
|
|
@@ -3211,7 +3238,7 @@ class lr extends v {
|
|
|
3211
3238
|
};
|
|
3212
3239
|
}
|
|
3213
3240
|
trackCurrentPage = () => {
|
|
3214
|
-
const e = window.location.href, t =
|
|
3241
|
+
const e = window.location.href, t = pe(e, this.get("config").sensitiveQueryParams);
|
|
3215
3242
|
if (this.get("pageUrl") === t)
|
|
3216
3243
|
return;
|
|
3217
3244
|
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3229,7 +3256,7 @@ class lr extends v {
|
|
|
3229
3256
|
});
|
|
3230
3257
|
};
|
|
3231
3258
|
trackInitialPageView() {
|
|
3232
|
-
const e =
|
|
3259
|
+
const e = pe(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3233
3260
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3234
3261
|
type: d.PAGE_VIEW,
|
|
3235
3262
|
page_url: e,
|
|
@@ -3247,7 +3274,7 @@ class lr extends v {
|
|
|
3247
3274
|
};
|
|
3248
3275
|
}
|
|
3249
3276
|
}
|
|
3250
|
-
class
|
|
3277
|
+
class Tr extends w {
|
|
3251
3278
|
eventManager;
|
|
3252
3279
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3253
3280
|
clickHandler;
|
|
@@ -3311,7 +3338,7 @@ class cr extends v {
|
|
|
3311
3338
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
3312
3339
|
}
|
|
3313
3340
|
shouldIgnoreElement(e) {
|
|
3314
|
-
return e.hasAttribute(`${
|
|
3341
|
+
return e.hasAttribute(`${b}-ignore`) ? !0 : e.closest(`[${b}-ignore]`) !== null;
|
|
3315
3342
|
}
|
|
3316
3343
|
/**
|
|
3317
3344
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -3362,8 +3389,8 @@ class cr extends v {
|
|
|
3362
3389
|
const t = e.getAttribute("data-testid");
|
|
3363
3390
|
if (t)
|
|
3364
3391
|
return `[data-testid="${t}"]`;
|
|
3365
|
-
const r = e.getAttribute(`${
|
|
3366
|
-
return r ? `[${
|
|
3392
|
+
const r = e.getAttribute(`${b}-name`);
|
|
3393
|
+
return r ? `[${b}-name="${r}"]` : this.getElementPath(e);
|
|
3367
3394
|
}
|
|
3368
3395
|
/**
|
|
3369
3396
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -3382,10 +3409,10 @@ class cr extends v {
|
|
|
3382
3409
|
return t.join(">") || "unknown";
|
|
3383
3410
|
}
|
|
3384
3411
|
findTrackingElement(e) {
|
|
3385
|
-
return e.hasAttribute(`${
|
|
3412
|
+
return e.hasAttribute(`${b}-name`) ? e : e.closest(`[${b}-name]`);
|
|
3386
3413
|
}
|
|
3387
3414
|
getRelevantClickElement(e) {
|
|
3388
|
-
for (const t of
|
|
3415
|
+
for (const t of pt)
|
|
3389
3416
|
try {
|
|
3390
3417
|
if (e.matches(t))
|
|
3391
3418
|
return e;
|
|
@@ -3417,7 +3444,7 @@ class cr extends v {
|
|
|
3417
3444
|
return { x: n, y: i, relativeX: o, relativeY: a };
|
|
3418
3445
|
}
|
|
3419
3446
|
extractTrackingData(e) {
|
|
3420
|
-
const t = e.getAttribute(`${
|
|
3447
|
+
const t = e.getAttribute(`${b}-name`), r = e.getAttribute(`${b}-value`);
|
|
3421
3448
|
if (t)
|
|
3422
3449
|
return {
|
|
3423
3450
|
element: e,
|
|
@@ -3465,7 +3492,7 @@ class cr extends v {
|
|
|
3465
3492
|
*/
|
|
3466
3493
|
sanitizeText(e) {
|
|
3467
3494
|
let t = e;
|
|
3468
|
-
for (const r of
|
|
3495
|
+
for (const r of rt) {
|
|
3469
3496
|
const n = new RegExp(r.source, r.flags);
|
|
3470
3497
|
t = t.replace(n, "[REDACTED]");
|
|
3471
3498
|
}
|
|
@@ -3504,7 +3531,7 @@ class cr extends v {
|
|
|
3504
3531
|
};
|
|
3505
3532
|
}
|
|
3506
3533
|
}
|
|
3507
|
-
class
|
|
3534
|
+
class vr extends w {
|
|
3508
3535
|
eventManager;
|
|
3509
3536
|
containers = [];
|
|
3510
3537
|
limitWarningLogged = !1;
|
|
@@ -3617,7 +3644,7 @@ class ur extends v {
|
|
|
3617
3644
|
isPrimary: o,
|
|
3618
3645
|
lastScrollPos: n,
|
|
3619
3646
|
lastDepth: i,
|
|
3620
|
-
lastDirection:
|
|
3647
|
+
lastDirection: Z.DOWN,
|
|
3621
3648
|
lastEventTime: 0,
|
|
3622
3649
|
firstScrollEventTime: null,
|
|
3623
3650
|
maxDepthReached: i,
|
|
@@ -3676,7 +3703,7 @@ class ur extends v {
|
|
|
3676
3703
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3677
3704
|
}
|
|
3678
3705
|
getScrollDirection(e, t) {
|
|
3679
|
-
return e > t ?
|
|
3706
|
+
return e > t ? Z.DOWN : Z.UP;
|
|
3680
3707
|
}
|
|
3681
3708
|
calculateScrollDepth(e, t, r) {
|
|
3682
3709
|
if (t <= r)
|
|
@@ -3732,7 +3759,7 @@ class ur extends v {
|
|
|
3732
3759
|
e.isPrimary = t;
|
|
3733
3760
|
}
|
|
3734
3761
|
}
|
|
3735
|
-
class
|
|
3762
|
+
class _r extends w {
|
|
3736
3763
|
eventManager;
|
|
3737
3764
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3738
3765
|
observer = null;
|
|
@@ -3796,7 +3823,7 @@ class dr extends v {
|
|
|
3796
3823
|
});
|
|
3797
3824
|
return;
|
|
3798
3825
|
}
|
|
3799
|
-
i.hasAttribute(`${
|
|
3826
|
+
i.hasAttribute(`${b}-ignore`) || this.trackedElements.has(i) || (this.trackedElements.set(i, {
|
|
3800
3827
|
element: i,
|
|
3801
3828
|
selector: r.selector,
|
|
3802
3829
|
id: r.id,
|
|
@@ -3833,7 +3860,7 @@ class dr extends v {
|
|
|
3833
3860
|
fireViewportEvent(e, t) {
|
|
3834
3861
|
if (e.startTime === null) return;
|
|
3835
3862
|
const r = Math.round(performance.now() - e.startTime);
|
|
3836
|
-
if (e.element.hasAttribute(`${
|
|
3863
|
+
if (e.element.hasAttribute(`${b}-ignore`))
|
|
3837
3864
|
return;
|
|
3838
3865
|
const n = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3839
3866
|
if (e.lastFiredTime !== null && i - e.lastFiredTime < n) {
|
|
@@ -3893,7 +3920,7 @@ class dr extends v {
|
|
|
3893
3920
|
});
|
|
3894
3921
|
}
|
|
3895
3922
|
}
|
|
3896
|
-
class
|
|
3923
|
+
class Ir {
|
|
3897
3924
|
storage;
|
|
3898
3925
|
sessionStorageRef;
|
|
3899
3926
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4176,7 +4203,7 @@ class hr {
|
|
|
4176
4203
|
this.fallbackSessionStorage.delete(e);
|
|
4177
4204
|
}
|
|
4178
4205
|
}
|
|
4179
|
-
class
|
|
4206
|
+
class wr extends w {
|
|
4180
4207
|
eventManager;
|
|
4181
4208
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4182
4209
|
navigationHistory = [];
|
|
@@ -4187,7 +4214,7 @@ class fr extends v {
|
|
|
4187
4214
|
navigationCounter = 0;
|
|
4188
4215
|
// Counter for handling simultaneous navigations edge case
|
|
4189
4216
|
constructor(e) {
|
|
4190
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4217
|
+
super(), this.eventManager = e, this.vitalThresholds = Ge(Se);
|
|
4191
4218
|
}
|
|
4192
4219
|
/**
|
|
4193
4220
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4204,8 +4231,8 @@ class fr extends v {
|
|
|
4204
4231
|
* @returns Promise that resolves when tracking is initialized
|
|
4205
4232
|
*/
|
|
4206
4233
|
async startTracking() {
|
|
4207
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4208
|
-
this.vitalThresholds =
|
|
4234
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? Se;
|
|
4235
|
+
this.vitalThresholds = Ge(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4209
4236
|
}
|
|
4210
4237
|
/**
|
|
4211
4238
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4275,7 +4302,7 @@ class fr extends v {
|
|
|
4275
4302
|
}
|
|
4276
4303
|
async initWebVitals() {
|
|
4277
4304
|
try {
|
|
4278
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4305
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => es), o = (a) => (c) => {
|
|
4279
4306
|
const u = Number(c.value.toFixed(2));
|
|
4280
4307
|
this.sendVital({ type: a, value: u });
|
|
4281
4308
|
};
|
|
@@ -4302,7 +4329,7 @@ class fr extends v {
|
|
|
4302
4329
|
const t = e.getEntries();
|
|
4303
4330
|
for (const r of t) {
|
|
4304
4331
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4305
|
-
i - this.lastLongTaskSentAt >=
|
|
4332
|
+
i - this.lastLongTaskSentAt >= Bt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4306
4333
|
}
|
|
4307
4334
|
},
|
|
4308
4335
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4318,7 +4345,7 @@ class fr extends v {
|
|
|
4318
4345
|
return;
|
|
4319
4346
|
if (r)
|
|
4320
4347
|
r.add(e.type);
|
|
4321
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4348
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Wt) {
|
|
4322
4349
|
const i = this.navigationHistory.shift();
|
|
4323
4350
|
i && this.reportedByNav.delete(i);
|
|
4324
4351
|
}
|
|
@@ -4409,7 +4436,7 @@ class fr extends v {
|
|
|
4409
4436
|
return !(typeof r == "number" && t <= r);
|
|
4410
4437
|
}
|
|
4411
4438
|
}
|
|
4412
|
-
class
|
|
4439
|
+
class yr extends w {
|
|
4413
4440
|
eventManager;
|
|
4414
4441
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4415
4442
|
errorBurstCounter = 0;
|
|
@@ -4445,24 +4472,24 @@ class mr extends v {
|
|
|
4445
4472
|
const e = Date.now();
|
|
4446
4473
|
if (e < this.burstBackoffUntil)
|
|
4447
4474
|
return !1;
|
|
4448
|
-
if (e - this.burstWindowStart >
|
|
4449
|
-
return this.burstBackoffUntil = e +
|
|
4475
|
+
if (e - this.burstWindowStart > Ht && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > xt)
|
|
4476
|
+
return this.burstBackoffUntil = e + Be, l("debug", "Error burst detected - entering cooldown", {
|
|
4450
4477
|
data: {
|
|
4451
4478
|
errorsInWindow: this.errorBurstCounter,
|
|
4452
|
-
cooldownMs:
|
|
4479
|
+
cooldownMs: Be
|
|
4453
4480
|
}
|
|
4454
4481
|
}), !1;
|
|
4455
|
-
const r = this.get("config")?.errorSampling ??
|
|
4482
|
+
const r = this.get("config")?.errorSampling ?? st;
|
|
4456
4483
|
return Math.random() < r;
|
|
4457
4484
|
}
|
|
4458
4485
|
handleError = (e) => {
|
|
4459
4486
|
if (!this.shouldSample())
|
|
4460
4487
|
return;
|
|
4461
4488
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4462
|
-
this.shouldSuppressError(
|
|
4489
|
+
this.shouldSuppressError(B.JS_ERROR, t) || this.eventManager.track({
|
|
4463
4490
|
type: d.ERROR,
|
|
4464
4491
|
error_data: {
|
|
4465
|
-
type:
|
|
4492
|
+
type: B.JS_ERROR,
|
|
4466
4493
|
message: t,
|
|
4467
4494
|
...e.filename && { filename: e.filename },
|
|
4468
4495
|
...e.lineno && { line: e.lineno },
|
|
@@ -4474,10 +4501,10 @@ class mr extends v {
|
|
|
4474
4501
|
if (!this.shouldSample())
|
|
4475
4502
|
return;
|
|
4476
4503
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4477
|
-
this.shouldSuppressError(
|
|
4504
|
+
this.shouldSuppressError(B.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4478
4505
|
type: d.ERROR,
|
|
4479
4506
|
error_data: {
|
|
4480
|
-
type:
|
|
4507
|
+
type: B.PROMISE_REJECTION,
|
|
4481
4508
|
message: r
|
|
4482
4509
|
}
|
|
4483
4510
|
});
|
|
@@ -4496,8 +4523,8 @@ class mr extends v {
|
|
|
4496
4523
|
}
|
|
4497
4524
|
}
|
|
4498
4525
|
sanitize(e) {
|
|
4499
|
-
let t = e.length >
|
|
4500
|
-
for (const r of
|
|
4526
|
+
let t = e.length > Fe ? e.slice(0, Fe) + "..." : e;
|
|
4527
|
+
for (const r of rt) {
|
|
4501
4528
|
const n = new RegExp(r.source, r.flags);
|
|
4502
4529
|
t = t.replace(n, "[REDACTED]");
|
|
4503
4530
|
}
|
|
@@ -4505,26 +4532,26 @@ class mr extends v {
|
|
|
4505
4532
|
}
|
|
4506
4533
|
shouldSuppressError(e, t) {
|
|
4507
4534
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4508
|
-
return i && r - i <
|
|
4535
|
+
return i && r - i < $e ? (this.recentErrors.set(n, r), !0) : (this.recentErrors.set(n, r), this.recentErrors.size > Ut ? (this.recentErrors.clear(), this.recentErrors.set(n, r), !1) : (this.recentErrors.size > ee && this.pruneOldErrors(), !1));
|
|
4509
4536
|
}
|
|
4510
4537
|
pruneOldErrors() {
|
|
4511
4538
|
const e = Date.now();
|
|
4512
4539
|
for (const [n, i] of this.recentErrors.entries())
|
|
4513
|
-
e - i >
|
|
4514
|
-
if (this.recentErrors.size <=
|
|
4540
|
+
e - i > $e && this.recentErrors.delete(n);
|
|
4541
|
+
if (this.recentErrors.size <= ee)
|
|
4515
4542
|
return;
|
|
4516
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size -
|
|
4543
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - ee;
|
|
4517
4544
|
for (let n = 0; n < r; n += 1) {
|
|
4518
4545
|
const i = t[n];
|
|
4519
4546
|
i && this.recentErrors.delete(i[0]);
|
|
4520
4547
|
}
|
|
4521
4548
|
}
|
|
4522
4549
|
}
|
|
4523
|
-
class
|
|
4550
|
+
class br extends w {
|
|
4524
4551
|
isInitialized = !1;
|
|
4525
4552
|
suppressNextScrollTimer = null;
|
|
4526
4553
|
pageUnloadHandler = null;
|
|
4527
|
-
emitter = new
|
|
4554
|
+
emitter = new cr();
|
|
4528
4555
|
transformers = {};
|
|
4529
4556
|
customHeadersProvider;
|
|
4530
4557
|
managers = {};
|
|
@@ -4542,11 +4569,11 @@ class gr extends v {
|
|
|
4542
4569
|
async init(e = {}) {
|
|
4543
4570
|
if (this.isInitialized)
|
|
4544
4571
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
4545
|
-
this.managers.storage = new
|
|
4572
|
+
this.managers.storage = new Ir();
|
|
4546
4573
|
try {
|
|
4547
4574
|
this.setupState(e);
|
|
4548
4575
|
const t = e.integrations?.custom?.headers ?? {}, r = e.integrations?.custom?.fetchCredentials ?? "include";
|
|
4549
|
-
return this.managers.event = new
|
|
4576
|
+
return this.managers.event = new fr(
|
|
4550
4577
|
this.managers.storage,
|
|
4551
4578
|
this.emitter,
|
|
4552
4579
|
this.transformers,
|
|
@@ -4576,9 +4603,9 @@ class gr extends v {
|
|
|
4576
4603
|
}
|
|
4577
4604
|
let r = t;
|
|
4578
4605
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4579
|
-
const { valid: n, error: i, sanitizedMetadata: o } =
|
|
4606
|
+
const { valid: n, error: i, sanitizedMetadata: o } = lr(e, r);
|
|
4580
4607
|
if (!n) {
|
|
4581
|
-
if (this.get("mode") ===
|
|
4608
|
+
if (this.get("mode") === re.QA)
|
|
4582
4609
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4583
4610
|
l("warn", `Custom event "${e}" dropped: ${i}`);
|
|
4584
4611
|
return;
|
|
@@ -4646,14 +4673,14 @@ class gr extends v {
|
|
|
4646
4673
|
}
|
|
4647
4674
|
setupState(e = {}) {
|
|
4648
4675
|
this.set("config", e);
|
|
4649
|
-
const t =
|
|
4676
|
+
const t = mr.getId(this.managers.storage);
|
|
4650
4677
|
this.set("userId", t);
|
|
4651
|
-
const r =
|
|
4678
|
+
const r = er(e);
|
|
4652
4679
|
this.set("collectApiUrls", r);
|
|
4653
|
-
const n =
|
|
4680
|
+
const n = kt();
|
|
4654
4681
|
this.set("device", n);
|
|
4655
|
-
const i =
|
|
4656
|
-
this.set("pageUrl", i),
|
|
4682
|
+
const i = pe(window.location.href, e.sensitiveQueryParams);
|
|
4683
|
+
this.set("pageUrl", i), jt() && this.set("mode", re.QA);
|
|
4657
4684
|
}
|
|
4658
4685
|
/**
|
|
4659
4686
|
* Returns the current configuration object.
|
|
@@ -4704,7 +4731,7 @@ class gr extends v {
|
|
|
4704
4731
|
valid: !1,
|
|
4705
4732
|
error: "Global metadata must be a plain object"
|
|
4706
4733
|
};
|
|
4707
|
-
const t =
|
|
4734
|
+
const t = ot("Global", e, "globalMetadata");
|
|
4708
4735
|
return t.valid ? { valid: !0 } : {
|
|
4709
4736
|
valid: !1,
|
|
4710
4737
|
error: t.error
|
|
@@ -4754,7 +4781,7 @@ class gr extends v {
|
|
|
4754
4781
|
}
|
|
4755
4782
|
initializeHandlers() {
|
|
4756
4783
|
const e = this.get("config");
|
|
4757
|
-
this.handlers.session = new
|
|
4784
|
+
this.handlers.session = new Sr(
|
|
4758
4785
|
this.managers.storage,
|
|
4759
4786
|
this.managers.event
|
|
4760
4787
|
), this.handlers.session.startTracking();
|
|
@@ -4763,22 +4790,22 @@ class gr extends v {
|
|
|
4763
4790
|
this.set("suppressNextScroll", !1);
|
|
4764
4791
|
}, 500);
|
|
4765
4792
|
};
|
|
4766
|
-
this.handlers.pageView = new
|
|
4793
|
+
this.handlers.pageView = new pr(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new Tr(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new vr(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new wr(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4767
4794
|
l("warn", "Failed to start performance tracking", { error: r });
|
|
4768
|
-
}), this.handlers.error = new
|
|
4795
|
+
}), this.handlers.error = new yr(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new _r(this.managers.event), this.handlers.viewport.startTracking());
|
|
4769
4796
|
}
|
|
4770
4797
|
}
|
|
4771
|
-
const
|
|
4772
|
-
let
|
|
4773
|
-
const
|
|
4798
|
+
const V = [], M = [];
|
|
4799
|
+
let D = null, h = null, R = !1, v = !1, P = null;
|
|
4800
|
+
const Lr = async (s) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (v = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R && P || (R = !0, P = (async () => {
|
|
4774
4801
|
try {
|
|
4775
|
-
const e =
|
|
4802
|
+
const e = ir(s ?? {}), t = new br();
|
|
4776
4803
|
try {
|
|
4777
|
-
|
|
4804
|
+
V.forEach(({ event: o, callback: a }) => {
|
|
4778
4805
|
t.on(o, a);
|
|
4779
|
-
}),
|
|
4806
|
+
}), V.length = 0, M.forEach(({ hook: o, fn: a }) => {
|
|
4780
4807
|
o === "beforeSend" ? t.setTransformer("beforeSend", a) : t.setTransformer("beforeBatch", a);
|
|
4781
|
-
}), M.length = 0,
|
|
4808
|
+
}), M.length = 0, D && (t.setCustomHeaders(D), D = null);
|
|
4782
4809
|
const r = t.init(e), n = new Promise((o, a) => {
|
|
4783
4810
|
setTimeout(() => {
|
|
4784
4811
|
a(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4796,144 +4823,144 @@ const Er = async (s) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4796
4823
|
} catch (e) {
|
|
4797
4824
|
throw h = null, e;
|
|
4798
4825
|
} finally {
|
|
4799
|
-
|
|
4826
|
+
R = !1, P = null;
|
|
4800
4827
|
}
|
|
4801
|
-
})()),
|
|
4828
|
+
})()), P)), Ar = (s, e) => {
|
|
4802
4829
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4803
4830
|
if (!h)
|
|
4804
4831
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4805
|
-
if (
|
|
4832
|
+
if (v)
|
|
4806
4833
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4807
4834
|
h.sendCustomEvent(s, e);
|
|
4808
4835
|
}
|
|
4809
|
-
},
|
|
4836
|
+
}, Mr = (s, e) => {
|
|
4810
4837
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4811
|
-
if (!h ||
|
|
4812
|
-
|
|
4838
|
+
if (!h || R) {
|
|
4839
|
+
V.push({ event: s, callback: e });
|
|
4813
4840
|
return;
|
|
4814
4841
|
}
|
|
4815
4842
|
h.on(s, e);
|
|
4816
4843
|
}
|
|
4817
|
-
},
|
|
4844
|
+
}, Cr = (s, e) => {
|
|
4818
4845
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4819
4846
|
if (!h) {
|
|
4820
|
-
const t =
|
|
4821
|
-
t !== -1 &&
|
|
4847
|
+
const t = V.findIndex((r) => r.event === s && r.callback === e);
|
|
4848
|
+
t !== -1 && V.splice(t, 1);
|
|
4822
4849
|
return;
|
|
4823
4850
|
}
|
|
4824
4851
|
h.off(s, e);
|
|
4825
4852
|
}
|
|
4826
4853
|
};
|
|
4827
|
-
function
|
|
4854
|
+
function Rr(s, e) {
|
|
4828
4855
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4829
4856
|
if (typeof e != "function")
|
|
4830
4857
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4831
|
-
if (!h ||
|
|
4858
|
+
if (!h || R) {
|
|
4832
4859
|
const t = M.findIndex((r) => r.hook === s);
|
|
4833
4860
|
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4834
4861
|
return;
|
|
4835
4862
|
}
|
|
4836
|
-
if (
|
|
4863
|
+
if (v)
|
|
4837
4864
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4838
4865
|
s === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
4839
4866
|
}
|
|
4840
4867
|
}
|
|
4841
|
-
const
|
|
4868
|
+
const Nr = (s) => {
|
|
4842
4869
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4843
4870
|
if (!h) {
|
|
4844
4871
|
const e = M.findIndex((t) => t.hook === s);
|
|
4845
4872
|
e !== -1 && M.splice(e, 1);
|
|
4846
4873
|
return;
|
|
4847
4874
|
}
|
|
4848
|
-
if (
|
|
4875
|
+
if (v)
|
|
4849
4876
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4850
4877
|
h.removeTransformer(s);
|
|
4851
4878
|
}
|
|
4852
|
-
},
|
|
4879
|
+
}, Or = (s) => {
|
|
4853
4880
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4854
4881
|
if (typeof s != "function")
|
|
4855
4882
|
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof s}`);
|
|
4856
|
-
if (!h ||
|
|
4857
|
-
|
|
4883
|
+
if (!h || R) {
|
|
4884
|
+
D = s;
|
|
4858
4885
|
return;
|
|
4859
4886
|
}
|
|
4860
|
-
if (
|
|
4887
|
+
if (v)
|
|
4861
4888
|
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
4862
4889
|
h.setCustomHeaders(s);
|
|
4863
4890
|
}
|
|
4864
|
-
},
|
|
4891
|
+
}, Pr = () => {
|
|
4865
4892
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4866
4893
|
if (!h) {
|
|
4867
|
-
|
|
4894
|
+
D = null;
|
|
4868
4895
|
return;
|
|
4869
4896
|
}
|
|
4870
|
-
if (
|
|
4897
|
+
if (v)
|
|
4871
4898
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
4872
4899
|
h.removeCustomHeaders();
|
|
4873
4900
|
}
|
|
4874
|
-
},
|
|
4901
|
+
}, Dr = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Vr = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), kr = () => {
|
|
4875
4902
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4876
|
-
if (
|
|
4903
|
+
if (v)
|
|
4877
4904
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
4878
4905
|
if (!h) {
|
|
4879
|
-
|
|
4906
|
+
v = !1;
|
|
4880
4907
|
return;
|
|
4881
4908
|
}
|
|
4882
|
-
|
|
4909
|
+
v = !0;
|
|
4883
4910
|
try {
|
|
4884
|
-
h.destroy(), h = null,
|
|
4911
|
+
h.destroy(), h = null, R = !1, P = null, V.length = 0, M.length = 0, D = null, v = !1;
|
|
4885
4912
|
} catch (s) {
|
|
4886
|
-
h = null,
|
|
4913
|
+
h = null, R = !1, P = null, V.length = 0, M.length = 0, D = null, v = !1, l("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4887
4914
|
}
|
|
4888
4915
|
}
|
|
4889
|
-
},
|
|
4890
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4891
|
-
},
|
|
4916
|
+
}, Ur = (s) => {
|
|
4917
|
+
typeof window > "u" || typeof document > "u" || zt(s);
|
|
4918
|
+
}, Hr = (s) => {
|
|
4892
4919
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4893
4920
|
if (!h)
|
|
4894
4921
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4895
|
-
if (
|
|
4922
|
+
if (v)
|
|
4896
4923
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4897
4924
|
h.updateGlobalMetadata(s);
|
|
4898
4925
|
}
|
|
4899
|
-
},
|
|
4926
|
+
}, xr = (s) => {
|
|
4900
4927
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4901
4928
|
if (!h)
|
|
4902
4929
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4903
|
-
if (
|
|
4930
|
+
if (v)
|
|
4904
4931
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4905
4932
|
h.mergeGlobalMetadata(s);
|
|
4906
4933
|
}
|
|
4907
|
-
},
|
|
4908
|
-
init:
|
|
4909
|
-
event:
|
|
4910
|
-
on:
|
|
4911
|
-
off:
|
|
4912
|
-
setTransformer:
|
|
4913
|
-
removeTransformer:
|
|
4914
|
-
setCustomHeaders:
|
|
4915
|
-
removeCustomHeaders:
|
|
4916
|
-
isInitialized:
|
|
4917
|
-
getSessionId:
|
|
4918
|
-
destroy:
|
|
4919
|
-
setQaMode:
|
|
4920
|
-
updateGlobalMetadata:
|
|
4921
|
-
mergeGlobalMetadata:
|
|
4934
|
+
}, ms = {
|
|
4935
|
+
init: Lr,
|
|
4936
|
+
event: Ar,
|
|
4937
|
+
on: Mr,
|
|
4938
|
+
off: Cr,
|
|
4939
|
+
setTransformer: Rr,
|
|
4940
|
+
removeTransformer: Nr,
|
|
4941
|
+
setCustomHeaders: Or,
|
|
4942
|
+
removeCustomHeaders: Pr,
|
|
4943
|
+
isInitialized: Dr,
|
|
4944
|
+
getSessionId: Vr,
|
|
4945
|
+
destroy: kr,
|
|
4946
|
+
setQaMode: Ur,
|
|
4947
|
+
updateGlobalMetadata: Hr,
|
|
4948
|
+
mergeGlobalMetadata: xr
|
|
4922
4949
|
};
|
|
4923
|
-
var
|
|
4950
|
+
var _e, C, X, ct, ne, ut = -1, k = function(s) {
|
|
4924
4951
|
addEventListener("pageshow", (function(e) {
|
|
4925
|
-
e.persisted && (
|
|
4952
|
+
e.persisted && (ut = e.timeStamp, s(e));
|
|
4926
4953
|
}), !0);
|
|
4927
|
-
},
|
|
4954
|
+
}, Me = function() {
|
|
4928
4955
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4929
4956
|
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4930
|
-
},
|
|
4931
|
-
var s =
|
|
4957
|
+
}, oe = function() {
|
|
4958
|
+
var s = Me();
|
|
4932
4959
|
return s && s.activationStart || 0;
|
|
4933
|
-
},
|
|
4934
|
-
var t =
|
|
4935
|
-
return
|
|
4936
|
-
},
|
|
4960
|
+
}, _ = function(s, e) {
|
|
4961
|
+
var t = Me(), r = "navigate";
|
|
4962
|
+
return ut >= 0 ? r = "back-forward-cache" : t && (document.prerendering || oe() > 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 };
|
|
4963
|
+
}, x = function(s, e, t) {
|
|
4937
4964
|
try {
|
|
4938
4965
|
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4939
4966
|
var r = new PerformanceObserver((function(n) {
|
|
@@ -4945,211 +4972,255 @@ var ge, tt = -1, k = function(s) {
|
|
|
4945
4972
|
}
|
|
4946
4973
|
} catch {
|
|
4947
4974
|
}
|
|
4948
|
-
},
|
|
4975
|
+
}, I = function(s, e, t, r) {
|
|
4949
4976
|
var n, i;
|
|
4950
4977
|
return function(o) {
|
|
4951
4978
|
e.value >= 0 && (o || r) && ((i = e.value - (n || 0)) || n === void 0) && (n = e.value, e.delta = i, e.rating = (function(a, c) {
|
|
4952
4979
|
return a > c[1] ? "poor" : a > c[0] ? "needs-improvement" : "good";
|
|
4953
4980
|
})(e.value, t), s(e));
|
|
4954
4981
|
};
|
|
4955
|
-
},
|
|
4982
|
+
}, Ce = function(s) {
|
|
4956
4983
|
requestAnimationFrame((function() {
|
|
4957
4984
|
return requestAnimationFrame((function() {
|
|
4958
4985
|
return s();
|
|
4959
4986
|
}));
|
|
4960
4987
|
}));
|
|
4961
|
-
},
|
|
4988
|
+
}, j = function(s) {
|
|
4962
4989
|
document.addEventListener("visibilitychange", (function() {
|
|
4963
4990
|
document.visibilityState === "hidden" && s();
|
|
4964
4991
|
}));
|
|
4965
|
-
},
|
|
4992
|
+
}, ae = function(s) {
|
|
4966
4993
|
var e = !1;
|
|
4967
4994
|
return function() {
|
|
4968
4995
|
e || (s(), e = !0);
|
|
4969
4996
|
};
|
|
4970
|
-
},
|
|
4997
|
+
}, H = -1, Ke = function() {
|
|
4971
4998
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4972
|
-
},
|
|
4973
|
-
document.visibilityState === "hidden" &&
|
|
4974
|
-
},
|
|
4975
|
-
addEventListener("visibilitychange",
|
|
4976
|
-
},
|
|
4977
|
-
removeEventListener("visibilitychange",
|
|
4978
|
-
},
|
|
4979
|
-
return
|
|
4999
|
+
}, ie = function(s) {
|
|
5000
|
+
document.visibilityState === "hidden" && H > -1 && (H = s.type === "visibilitychange" ? s.timeStamp : 0, Fr());
|
|
5001
|
+
}, Ye = function() {
|
|
5002
|
+
addEventListener("visibilitychange", ie, !0), addEventListener("prerenderingchange", ie, !0);
|
|
5003
|
+
}, Fr = function() {
|
|
5004
|
+
removeEventListener("visibilitychange", ie, !0), removeEventListener("prerenderingchange", ie, !0);
|
|
5005
|
+
}, Re = function() {
|
|
5006
|
+
return H < 0 && (H = Ke(), Ye(), k((function() {
|
|
4980
5007
|
setTimeout((function() {
|
|
4981
|
-
|
|
5008
|
+
H = Ke(), Ye();
|
|
4982
5009
|
}), 0);
|
|
4983
5010
|
}))), { get firstHiddenTime() {
|
|
4984
|
-
return
|
|
5011
|
+
return H;
|
|
4985
5012
|
} };
|
|
4986
|
-
},
|
|
5013
|
+
}, z = function(s) {
|
|
4987
5014
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4988
5015
|
return s();
|
|
4989
5016
|
}), !0) : s();
|
|
4990
|
-
},
|
|
4991
|
-
e = e || {},
|
|
4992
|
-
var t, r =
|
|
5017
|
+
}, Ie = [1800, 3e3], dt = function(s, e) {
|
|
5018
|
+
e = e || {}, z((function() {
|
|
5019
|
+
var t, r = Re(), n = _("FCP"), i = x("paint", (function(o) {
|
|
4993
5020
|
o.forEach((function(a) {
|
|
4994
|
-
a.name === "first-contentful-paint" && (i.disconnect(), a.startTime < r.firstHiddenTime && (n.value = Math.max(a.startTime -
|
|
5021
|
+
a.name === "first-contentful-paint" && (i.disconnect(), a.startTime < r.firstHiddenTime && (n.value = Math.max(a.startTime - oe(), 0), n.entries.push(a), t(!0)));
|
|
4995
5022
|
}));
|
|
4996
5023
|
}));
|
|
4997
|
-
i && (t =
|
|
4998
|
-
n =
|
|
5024
|
+
i && (t = I(s, n, Ie, e.reportAllChanges), k((function(o) {
|
|
5025
|
+
n = _("FCP"), t = I(s, n, Ie, e.reportAllChanges), Ce((function() {
|
|
4999
5026
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
5000
5027
|
}));
|
|
5001
5028
|
})));
|
|
5002
5029
|
}));
|
|
5003
|
-
},
|
|
5004
|
-
e = e || {},
|
|
5005
|
-
var t, r =
|
|
5030
|
+
}, we = [0.1, 0.25], $r = function(s, e) {
|
|
5031
|
+
e = e || {}, dt(ae((function() {
|
|
5032
|
+
var t, r = _("CLS", 0), n = 0, i = [], o = function(c) {
|
|
5006
5033
|
c.forEach((function(u) {
|
|
5007
5034
|
if (!u.hadRecentInput) {
|
|
5008
5035
|
var S = i[0], g = i[i.length - 1];
|
|
5009
5036
|
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
5010
5037
|
}
|
|
5011
5038
|
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
5012
|
-
}, a =
|
|
5013
|
-
a && (t =
|
|
5039
|
+
}, a = x("layout-shift", o);
|
|
5040
|
+
a && (t = I(s, r, we, e.reportAllChanges), j((function() {
|
|
5014
5041
|
o(a.takeRecords()), t(!0);
|
|
5015
5042
|
})), k((function() {
|
|
5016
|
-
n = 0, r =
|
|
5043
|
+
n = 0, r = _("CLS", 0), t = I(s, r, we, e.reportAllChanges), Ce((function() {
|
|
5017
5044
|
return t();
|
|
5018
5045
|
}));
|
|
5019
5046
|
})), setTimeout(t, 0));
|
|
5020
5047
|
})));
|
|
5021
|
-
},
|
|
5048
|
+
}, ht = 0, he = 1 / 0, J = 0, Br = function(s) {
|
|
5022
5049
|
s.forEach((function(e) {
|
|
5023
|
-
e.interactionId && (
|
|
5050
|
+
e.interactionId && (he = Math.min(he, e.interactionId), J = Math.max(J, e.interactionId), ht = J ? (J - he) / 7 + 1 : 0);
|
|
5024
5051
|
}));
|
|
5025
|
-
},
|
|
5026
|
-
return
|
|
5027
|
-
},
|
|
5028
|
-
"interactionCount" in performance ||
|
|
5029
|
-
},
|
|
5030
|
-
var s = Math.min(
|
|
5031
|
-
return
|
|
5032
|
-
},
|
|
5033
|
-
if (
|
|
5052
|
+
}, ft = function() {
|
|
5053
|
+
return _e ? ht : performance.interactionCount || 0;
|
|
5054
|
+
}, Wr = function() {
|
|
5055
|
+
"interactionCount" in performance || _e || (_e = x("event", Br, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5056
|
+
}, L = [], te = /* @__PURE__ */ new Map(), mt = 0, Gr = function() {
|
|
5057
|
+
var s = Math.min(L.length - 1, Math.floor((ft() - mt) / 50));
|
|
5058
|
+
return L[s];
|
|
5059
|
+
}, Xr = [], Qr = function(s) {
|
|
5060
|
+
if (Xr.forEach((function(n) {
|
|
5034
5061
|
return n(s);
|
|
5035
5062
|
})), s.interactionId || s.entryType === "first-input") {
|
|
5036
|
-
var e =
|
|
5037
|
-
if (t ||
|
|
5063
|
+
var e = L[L.length - 1], t = te.get(s.interactionId);
|
|
5064
|
+
if (t || L.length < 10 || s.duration > e.latency) {
|
|
5038
5065
|
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);
|
|
5039
5066
|
else {
|
|
5040
5067
|
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
5041
|
-
|
|
5068
|
+
te.set(r.id, r), L.push(r);
|
|
5042
5069
|
}
|
|
5043
|
-
|
|
5070
|
+
L.sort((function(n, i) {
|
|
5044
5071
|
return i.latency - n.latency;
|
|
5045
|
-
})),
|
|
5046
|
-
return
|
|
5072
|
+
})), L.length > 10 && L.splice(10).forEach((function(n) {
|
|
5073
|
+
return te.delete(n.id);
|
|
5047
5074
|
}));
|
|
5048
5075
|
}
|
|
5049
5076
|
}
|
|
5050
|
-
},
|
|
5077
|
+
}, gt = function(s) {
|
|
5051
5078
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5052
|
-
return s =
|
|
5053
|
-
},
|
|
5054
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
5079
|
+
return s = ae(s), document.visibilityState === "hidden" ? s() : (t = e(s), j(s)), t;
|
|
5080
|
+
}, ye = [200, 500], jr = function(s, e) {
|
|
5081
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, z((function() {
|
|
5055
5082
|
var t;
|
|
5056
|
-
|
|
5057
|
-
var r, n =
|
|
5058
|
-
|
|
5059
|
-
a.forEach(
|
|
5060
|
-
var c =
|
|
5083
|
+
Wr();
|
|
5084
|
+
var r, n = _("INP"), i = function(a) {
|
|
5085
|
+
gt((function() {
|
|
5086
|
+
a.forEach(Qr);
|
|
5087
|
+
var c = Gr();
|
|
5061
5088
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
5062
5089
|
}));
|
|
5063
|
-
}, o =
|
|
5064
|
-
r =
|
|
5090
|
+
}, o = x("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5091
|
+
r = I(s, n, ye, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), j((function() {
|
|
5065
5092
|
i(o.takeRecords()), r(!0);
|
|
5066
5093
|
})), k((function() {
|
|
5067
|
-
|
|
5094
|
+
mt = ft(), L.length = 0, te.clear(), n = _("INP"), r = I(s, n, ye, e.reportAllChanges);
|
|
5068
5095
|
})));
|
|
5069
5096
|
})));
|
|
5070
|
-
},
|
|
5071
|
-
e = e || {},
|
|
5072
|
-
var t, r =
|
|
5097
|
+
}, be = [2500, 4e3], fe = {}, zr = function(s, e) {
|
|
5098
|
+
e = e || {}, z((function() {
|
|
5099
|
+
var t, r = Re(), n = _("LCP"), i = function(c) {
|
|
5073
5100
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
5074
|
-
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime -
|
|
5101
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - oe(), 0), n.entries = [u], t());
|
|
5075
5102
|
}));
|
|
5076
|
-
}, o =
|
|
5103
|
+
}, o = x("largest-contentful-paint", i);
|
|
5077
5104
|
if (o) {
|
|
5078
|
-
t =
|
|
5079
|
-
var a =
|
|
5080
|
-
|
|
5105
|
+
t = I(s, n, be, e.reportAllChanges);
|
|
5106
|
+
var a = ae((function() {
|
|
5107
|
+
fe[n.id] || (i(o.takeRecords()), o.disconnect(), fe[n.id] = !0, t(!0));
|
|
5081
5108
|
}));
|
|
5082
5109
|
["keydown", "click"].forEach((function(c) {
|
|
5083
5110
|
addEventListener(c, (function() {
|
|
5084
|
-
return
|
|
5111
|
+
return gt(a);
|
|
5085
5112
|
}), { once: !0, capture: !0 });
|
|
5086
|
-
})),
|
|
5087
|
-
n =
|
|
5088
|
-
n.value = performance.now() - c.timeStamp,
|
|
5113
|
+
})), j(a), k((function(c) {
|
|
5114
|
+
n = _("LCP"), t = I(s, n, be, e.reportAllChanges), Ce((function() {
|
|
5115
|
+
n.value = performance.now() - c.timeStamp, fe[n.id] = !0, t(!0);
|
|
5089
5116
|
}));
|
|
5090
5117
|
}));
|
|
5091
5118
|
}
|
|
5092
5119
|
}));
|
|
5093
|
-
},
|
|
5094
|
-
document.prerendering ?
|
|
5120
|
+
}, Le = [800, 1800], Kr = function s(e) {
|
|
5121
|
+
document.prerendering ? z((function() {
|
|
5095
5122
|
return s(e);
|
|
5096
5123
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5097
5124
|
return s(e);
|
|
5098
5125
|
}), !0) : setTimeout(e, 0);
|
|
5099
|
-
},
|
|
5126
|
+
}, Yr = function(s, e) {
|
|
5100
5127
|
e = e || {};
|
|
5101
|
-
var t =
|
|
5102
|
-
|
|
5103
|
-
var n =
|
|
5104
|
-
n && (t.value = Math.max(n.responseStart -
|
|
5105
|
-
t =
|
|
5128
|
+
var t = _("TTFB"), r = I(s, t, Le, e.reportAllChanges);
|
|
5129
|
+
Kr((function() {
|
|
5130
|
+
var n = Me();
|
|
5131
|
+
n && (t.value = Math.max(n.responseStart - oe(), 0), t.entries = [n], r(!0), k((function() {
|
|
5132
|
+
t = _("TTFB", 0), (r = I(s, t, Le, e.reportAllChanges))(!0);
|
|
5133
|
+
})));
|
|
5134
|
+
}));
|
|
5135
|
+
}, W = { passive: !0, capture: !0 }, qr = /* @__PURE__ */ new Date(), qe = function(s, e) {
|
|
5136
|
+
C || (C = e, X = s, ct = /* @__PURE__ */ new Date(), St(removeEventListener), Et());
|
|
5137
|
+
}, Et = function() {
|
|
5138
|
+
if (X >= 0 && X < ct - qr) {
|
|
5139
|
+
var s = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + X };
|
|
5140
|
+
ne.forEach((function(e) {
|
|
5141
|
+
e(s);
|
|
5142
|
+
})), ne = [];
|
|
5143
|
+
}
|
|
5144
|
+
}, Jr = function(s) {
|
|
5145
|
+
if (s.cancelable) {
|
|
5146
|
+
var e = (s.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - s.timeStamp;
|
|
5147
|
+
s.type == "pointerdown" ? (function(t, r) {
|
|
5148
|
+
var n = function() {
|
|
5149
|
+
qe(t, r), o();
|
|
5150
|
+
}, i = function() {
|
|
5151
|
+
o();
|
|
5152
|
+
}, o = function() {
|
|
5153
|
+
removeEventListener("pointerup", n, W), removeEventListener("pointercancel", i, W);
|
|
5154
|
+
};
|
|
5155
|
+
addEventListener("pointerup", n, W), addEventListener("pointercancel", i, W);
|
|
5156
|
+
})(e, s) : qe(e, s);
|
|
5157
|
+
}
|
|
5158
|
+
}, St = function(s) {
|
|
5159
|
+
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5160
|
+
return s(e, Jr, W);
|
|
5161
|
+
}));
|
|
5162
|
+
}, Ae = [100, 300], Zr = function(s, e) {
|
|
5163
|
+
e = e || {}, z((function() {
|
|
5164
|
+
var t, r = Re(), n = _("FID"), i = function(c) {
|
|
5165
|
+
c.startTime < r.firstHiddenTime && (n.value = c.processingStart - c.startTime, n.entries.push(c), t(!0));
|
|
5166
|
+
}, o = function(c) {
|
|
5167
|
+
c.forEach(i);
|
|
5168
|
+
}, a = x("first-input", o);
|
|
5169
|
+
t = I(s, n, Ae, e.reportAllChanges), a && (j(ae((function() {
|
|
5170
|
+
o(a.takeRecords()), a.disconnect();
|
|
5171
|
+
}))), k((function() {
|
|
5172
|
+
var c;
|
|
5173
|
+
n = _("FID"), t = I(s, n, Ae, e.reportAllChanges), ne = [], X = -1, C = null, St(addEventListener), c = i, ne.push(c), Et();
|
|
5106
5174
|
})));
|
|
5107
5175
|
}));
|
|
5108
5176
|
};
|
|
5109
|
-
const
|
|
5177
|
+
const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5110
5178
|
__proto__: null,
|
|
5111
|
-
CLSThresholds:
|
|
5112
|
-
FCPThresholds:
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5179
|
+
CLSThresholds: we,
|
|
5180
|
+
FCPThresholds: Ie,
|
|
5181
|
+
FIDThresholds: Ae,
|
|
5182
|
+
INPThresholds: ye,
|
|
5183
|
+
LCPThresholds: be,
|
|
5184
|
+
TTFBThresholds: Le,
|
|
5185
|
+
onCLS: $r,
|
|
5186
|
+
onFCP: dt,
|
|
5187
|
+
onFID: Zr,
|
|
5188
|
+
onINP: jr,
|
|
5189
|
+
onLCP: zr,
|
|
5190
|
+
onTTFB: Yr
|
|
5121
5191
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5122
5192
|
export {
|
|
5123
5193
|
f as AppConfigValidationError,
|
|
5124
|
-
|
|
5125
|
-
|
|
5194
|
+
ts as DEFAULT_SESSION_TIMEOUT,
|
|
5195
|
+
Se as DEFAULT_WEB_VITALS_MODE,
|
|
5126
5196
|
A as DeviceType,
|
|
5127
|
-
|
|
5128
|
-
|
|
5197
|
+
me as EmitterEvent,
|
|
5198
|
+
B as ErrorType,
|
|
5129
5199
|
d as EventType,
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5200
|
+
hs as InitializationTimeoutError,
|
|
5201
|
+
U as IntegrationValidationError,
|
|
5202
|
+
cs as MAX_ARRAY_LENGTH,
|
|
5203
|
+
is as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5204
|
+
ns as MAX_CUSTOM_EVENT_KEYS,
|
|
5205
|
+
rs as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5206
|
+
ss as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5207
|
+
os as MAX_NESTED_OBJECT_KEYS,
|
|
5208
|
+
as as MAX_STRING_LENGTH,
|
|
5209
|
+
ls as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5210
|
+
re as Mode,
|
|
5211
|
+
rt as PII_PATTERNS,
|
|
5212
|
+
N as PermanentError,
|
|
5213
|
+
xe as SamplingRateValidationError,
|
|
5214
|
+
Z as ScrollDirection,
|
|
5215
|
+
bt as SessionTimeoutValidationError,
|
|
5216
|
+
$ as SpecialApiUrl,
|
|
5217
|
+
O as TimeoutError,
|
|
5218
|
+
Q as TraceLogValidationError,
|
|
5219
|
+
fs as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5220
|
+
We as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5221
|
+
$t as WEB_VITALS_POOR_THRESHOLDS,
|
|
5222
|
+
Ge as getWebVitalsThresholds,
|
|
5223
|
+
us as isPrimaryScrollEvent,
|
|
5224
|
+
ds as isSecondaryScrollEvent,
|
|
5225
|
+
ms as tracelog
|
|
5155
5226
|
};
|