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