@tracelog/lib 2.1.2 → 2.2.0-rc.80.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -4
- package/dist/browser/tracelog.esm.js +586 -495
- 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 +192 -64
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +45 -3
- package/dist/public-api.d.ts +45 -3
- package/dist/public-api.js +193 -64
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const w = "data-tlog",
|
|
1
|
+
const Hr = 9e5;
|
|
2
|
+
const Fr = 120, $r = 8192, Br = 10, Wr = 10, Gr = 20;
|
|
3
|
+
const Xr = 1e3, Qr = 500, jr = 100;
|
|
4
|
+
const w = "data-tlog", at = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const w = "data-tlog", ot = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], lt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], ct = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,53 +71,53 @@ const m = {
|
|
|
71
71
|
INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
},
|
|
74
|
+
}, ut = [
|
|
75
75
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
76
76
|
/javascript:/gi,
|
|
77
77
|
/on\w+\s*=/gi,
|
|
78
78
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
79
79
|
/<embed\b[^>]*>/gi,
|
|
80
80
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
81
|
-
], I = "tlog",
|
|
82
|
-
var
|
|
83
|
-
class
|
|
81
|
+
], I = "tlog", H = `${I}:qa_mode`, ye = `${I}:uid`, We = "tlog_mode", be = "qa", Le = "qa_off", dt = (s) => s ? `${I}:${s}:queue` : `${I}:queue`, ht = (s) => s ? `${I}:${s}:session` : `${I}:session`, ft = (s) => s ? `${I}:${s}:broadcast` : `${I}:broadcast`, Ae = (s, e) => `${I}:${s}:session_counts:${e}`, Me = 10080 * 60 * 1e3, Ce = `${I}:session_counts_last_cleanup`, Re = 3600 * 1e3;
|
|
82
|
+
var U = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(U || {}), A = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(A || {}), ae = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(ae || {});
|
|
83
|
+
class O extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
85
|
+
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, O);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
var d = /* @__PURE__ */ ((s) => (s.PAGE_VIEW = "page_view", s.CLICK = "click", s.SCROLL = "scroll", s.SESSION_START = "session_start", s.CUSTOM = "custom", s.WEB_VITALS = "web_vitals", s.ERROR = "error", s.VIEWPORT_VISIBLE = "viewport_visible", s))(d || {}),
|
|
89
|
-
const
|
|
90
|
-
class
|
|
88
|
+
var d = /* @__PURE__ */ ((s) => (s.PAGE_VIEW = "page_view", s.CLICK = "click", s.SCROLL = "scroll", s.SESSION_START = "session_start", s.CUSTOM = "custom", s.WEB_VITALS = "web_vitals", s.ERROR = "error", s.VIEWPORT_VISIBLE = "viewport_visible", s))(d || {}), Q = /* @__PURE__ */ ((s) => (s.UP = "up", s.DOWN = "down", s))(Q || {}), x = /* @__PURE__ */ ((s) => (s.JS_ERROR = "js_error", s.PROMISE_REJECTION = "promise_rejection", s))(x || {}), K = /* @__PURE__ */ ((s) => (s.QA = "qa", s))(K || {});
|
|
89
|
+
const zr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !0, Kr = (s) => s.type === d.SCROLL && "scroll_data" in s && s.scroll_data.is_primary === !1;
|
|
90
|
+
class F extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
class
|
|
95
|
+
class f extends F {
|
|
96
96
|
constructor(e, t = "config") {
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class mt extends F {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class Ne extends F {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
class
|
|
110
|
+
class V extends F {
|
|
111
111
|
constructor(e, t = "config") {
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class Yr extends F {
|
|
116
116
|
constructor(e, t, r = "runtime") {
|
|
117
117
|
super(e, "INITIALIZATION_TIMEOUT", r), this.timeoutMs = t;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
const
|
|
120
|
+
const Ge = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Xe = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", gt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Et = (s, e) => {
|
|
121
121
|
if (e) {
|
|
122
122
|
if (e instanceof Error) {
|
|
123
123
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -136,24 +136,24 @@ const Be = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
136
136
|
return `[TraceLog] ${s}: ${String(e)}`;
|
|
137
137
|
}
|
|
138
138
|
return `[TraceLog] ${s}`;
|
|
139
|
-
},
|
|
139
|
+
}, St = () => {
|
|
140
140
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
141
141
|
return !1;
|
|
142
142
|
try {
|
|
143
|
-
return sessionStorage.getItem(
|
|
143
|
+
return sessionStorage.getItem(H) === "true";
|
|
144
144
|
} catch {
|
|
145
145
|
return !1;
|
|
146
146
|
}
|
|
147
147
|
}, a = (s, e, t) => {
|
|
148
|
-
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ?
|
|
149
|
-
if (!
|
|
148
|
+
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? Et(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
|
|
149
|
+
if (!pt(l, i))
|
|
150
150
|
return;
|
|
151
|
-
const g =
|
|
152
|
-
|
|
153
|
-
},
|
|
151
|
+
const g = Tt(l, o), p = n !== void 0 ? le(n) : void 0;
|
|
152
|
+
vt(u, c, g, p);
|
|
153
|
+
}, pt = (s, e) => s === "critical" ? !0 : s === "qa" || e ? St() : !1, Tt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? gt : "", vt = (s, e, t, r) => {
|
|
154
154
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
155
155
|
r !== void 0 ? n ? console[s](i, t, r) : console[s](i, r) : n ? console[s](i, t) : console[s](i);
|
|
156
|
-
},
|
|
156
|
+
}, le = (s) => {
|
|
157
157
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
158
158
|
for (const [r, n] of Object.entries(s)) {
|
|
159
159
|
const i = r.toLowerCase();
|
|
@@ -161,16 +161,16 @@ const Be = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
161
161
|
e[r] = "[REDACTED]";
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] =
|
|
165
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
164
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? e[r] = le(n) : Array.isArray(n) ? e[r] = n.map(
|
|
165
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? le(o) : o
|
|
166
166
|
) : e[r] = n;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let
|
|
170
|
+
let ce, Qe;
|
|
171
171
|
const _t = () => {
|
|
172
|
-
typeof window < "u" && !
|
|
173
|
-
},
|
|
172
|
+
typeof window < "u" && !ce && (ce = window.matchMedia("(pointer: coarse)"), Qe = window.matchMedia("(hover: none)"));
|
|
173
|
+
}, Y = "Unknown", It = (s) => {
|
|
174
174
|
const e = s.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
176
176
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -181,8 +181,8 @@ const _t = () => {
|
|
|
181
181
|
if (/ios/i.test(e)) return "iOS";
|
|
182
182
|
}
|
|
183
183
|
const t = navigator.userAgent;
|
|
184
|
-
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" :
|
|
185
|
-
},
|
|
184
|
+
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : Y;
|
|
185
|
+
}, wt = (s) => {
|
|
186
186
|
const e = s.userAgentData?.brands;
|
|
187
187
|
if (e != null && e.length > 0) {
|
|
188
188
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -192,36 +192,36 @@ const _t = () => {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
const t = navigator.userAgent;
|
|
195
|
-
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" :
|
|
196
|
-
},
|
|
195
|
+
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : Y;
|
|
196
|
+
}, yt = () => {
|
|
197
197
|
try {
|
|
198
198
|
const s = navigator;
|
|
199
199
|
if (s.userAgentData != null && typeof s.userAgentData.mobile == "boolean") {
|
|
200
200
|
const c = s.userAgentData.platform;
|
|
201
|
-
return c != null && c !== "" && /ipad|tablet/i.test(c) ?
|
|
201
|
+
return c != null && c !== "" && /ipad|tablet/i.test(c) ? A.Tablet : s.userAgentData.mobile ? A.Mobile : A.Desktop;
|
|
202
202
|
}
|
|
203
203
|
_t();
|
|
204
|
-
const e = window.innerWidth, t =
|
|
205
|
-
return e <= 767 || o && n ?
|
|
204
|
+
const e = window.innerWidth, t = ce?.matches ?? !1, r = Qe?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
205
|
+
return e <= 767 || o && n ? A.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? A.Tablet : A.Desktop;
|
|
206
206
|
} catch (s) {
|
|
207
|
-
return a("debug", "Device detection failed, defaulting to desktop", { error: s }),
|
|
207
|
+
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), A.Desktop;
|
|
208
208
|
}
|
|
209
|
-
},
|
|
209
|
+
}, bt = () => {
|
|
210
210
|
try {
|
|
211
211
|
const s = navigator;
|
|
212
212
|
return {
|
|
213
|
-
type:
|
|
214
|
-
os:
|
|
215
|
-
browser:
|
|
213
|
+
type: yt(),
|
|
214
|
+
os: It(s),
|
|
215
|
+
browser: wt(s)
|
|
216
216
|
};
|
|
217
217
|
} catch (s) {
|
|
218
218
|
return a("debug", "Device info detection failed, using defaults", { error: s }), {
|
|
219
|
-
type:
|
|
220
|
-
os:
|
|
221
|
-
browser:
|
|
219
|
+
type: A.Desktop,
|
|
220
|
+
os: Y,
|
|
221
|
+
browser: Y
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
},
|
|
224
|
+
}, je = [
|
|
225
225
|
// Email addresses
|
|
226
226
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
227
227
|
// US Phone numbers (various formats)
|
|
@@ -236,7 +236,7 @@ const _t = () => {
|
|
|
236
236
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
237
237
|
// Passwords in connection strings (protocol://user:password@host)
|
|
238
238
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
239
|
-
],
|
|
239
|
+
], Oe = 500, Pe = 5e3, j = 50, Lt = j * 2, ze = 1, At = 1e3, Mt = 10, De = 5e3, Ct = 6e4, qr = {
|
|
240
240
|
LCP: 2500,
|
|
241
241
|
// Good: ≤ 2.5s
|
|
242
242
|
FCP: 1800,
|
|
@@ -248,7 +248,7 @@ const _t = () => {
|
|
|
248
248
|
TTFB: 800,
|
|
249
249
|
// Good: ≤ 800ms
|
|
250
250
|
LONG_TASK: 50
|
|
251
|
-
},
|
|
251
|
+
}, ke = {
|
|
252
252
|
LCP: 2500,
|
|
253
253
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
254
254
|
FCP: 1800,
|
|
@@ -272,53 +272,53 @@ const _t = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
},
|
|
275
|
+
}, ue = "needs-improvement", Ve = (s = ue) => {
|
|
276
276
|
switch (s) {
|
|
277
277
|
case "all":
|
|
278
278
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
279
279
|
// Track everything
|
|
280
280
|
case "needs-improvement":
|
|
281
|
-
return
|
|
281
|
+
return ke;
|
|
282
282
|
case "poor":
|
|
283
283
|
return Rt;
|
|
284
284
|
default:
|
|
285
|
-
return
|
|
285
|
+
return ke;
|
|
286
286
|
}
|
|
287
|
-
},
|
|
287
|
+
}, Nt = 1e3, Ot = 50, Pt = "2.2.0", Dt = Pt, Ke = () => typeof window < "u" && typeof sessionStorage < "u", kt = () => {
|
|
288
288
|
try {
|
|
289
289
|
const s = new URLSearchParams(window.location.search);
|
|
290
|
-
s.delete(
|
|
290
|
+
s.delete(We);
|
|
291
291
|
const e = s.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
292
292
|
window.history.replaceState({}, "", t);
|
|
293
293
|
} catch {
|
|
294
294
|
}
|
|
295
|
-
},
|
|
296
|
-
if (!
|
|
295
|
+
}, Vt = () => {
|
|
296
|
+
if (!Ke())
|
|
297
297
|
return !1;
|
|
298
298
|
try {
|
|
299
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
299
|
+
const e = new URLSearchParams(window.location.search).get(We), t = sessionStorage.getItem(H);
|
|
300
300
|
let r = null;
|
|
301
|
-
return e ===
|
|
301
|
+
return e === be ? (r = !0, sessionStorage.setItem(H, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
302
|
visibility: "qa",
|
|
303
|
-
style:
|
|
304
|
-
})) : e ===
|
|
303
|
+
style: Ge
|
|
304
|
+
})) : e === Le && (r = !1, sessionStorage.setItem(H, "false"), a("info", "QA Mode DISABLED", {
|
|
305
305
|
visibility: "qa",
|
|
306
|
-
style:
|
|
307
|
-
})), (e ===
|
|
306
|
+
style: Xe
|
|
307
|
+
})), (e === be || e === Le) && kt(), r ?? t === "true";
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
312
|
-
if (
|
|
311
|
+
}, Ut = (s) => {
|
|
312
|
+
if (Ke())
|
|
313
313
|
try {
|
|
314
|
-
sessionStorage.setItem(
|
|
314
|
+
sessionStorage.setItem(H, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
315
315
|
visibility: "qa",
|
|
316
|
-
style: s ?
|
|
316
|
+
style: s ? Ge : Xe
|
|
317
317
|
});
|
|
318
318
|
} catch {
|
|
319
319
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
320
320
|
}
|
|
321
|
-
},
|
|
321
|
+
}, xt = [
|
|
322
322
|
"co.uk",
|
|
323
323
|
"org.uk",
|
|
324
324
|
"com.au",
|
|
@@ -330,40 +330,40 @@ const _t = () => {
|
|
|
330
330
|
"co.in",
|
|
331
331
|
"com.cn",
|
|
332
332
|
"co.za"
|
|
333
|
-
],
|
|
333
|
+
], Ue = (s) => {
|
|
334
334
|
const e = s.toLowerCase().split(".");
|
|
335
335
|
if (e.length <= 2)
|
|
336
336
|
return s.toLowerCase();
|
|
337
337
|
const t = e.slice(-2).join(".");
|
|
338
|
-
return
|
|
339
|
-
},
|
|
338
|
+
return xt.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
339
|
+
}, Ht = (s, e) => s === e ? !0 : Ue(s) === Ue(e), re = () => {
|
|
340
340
|
const s = document.referrer;
|
|
341
341
|
if (!s)
|
|
342
342
|
return "Direct";
|
|
343
343
|
try {
|
|
344
344
|
const e = new URL(s).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
345
|
-
return
|
|
345
|
+
return Ht(e, t) ? "Direct" : s;
|
|
346
346
|
} catch (e) {
|
|
347
347
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: s } }), s;
|
|
348
348
|
}
|
|
349
|
-
},
|
|
349
|
+
}, se = () => {
|
|
350
350
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
351
|
-
return
|
|
351
|
+
return lt.forEach((r) => {
|
|
352
352
|
const n = s.get(r);
|
|
353
353
|
if (n) {
|
|
354
354
|
const i = r.split("utm_")[1];
|
|
355
355
|
e[i] = n;
|
|
356
356
|
}
|
|
357
357
|
}), Object.keys(e).length ? e : void 0;
|
|
358
|
-
},
|
|
358
|
+
}, Ft = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (s) => {
|
|
359
359
|
const e = Math.random() * 16 | 0;
|
|
360
360
|
return (s === "x" ? e : e & 3 | 8).toString(16);
|
|
361
361
|
});
|
|
362
|
-
let
|
|
363
|
-
const
|
|
362
|
+
let W = 0, G = 0;
|
|
363
|
+
const $t = () => {
|
|
364
364
|
let s = Date.now();
|
|
365
|
-
s <
|
|
366
|
-
const e =
|
|
365
|
+
s < G && (s = G), s === G ? W = (W + 1) % 1e3 : W = 0, G = s;
|
|
366
|
+
const e = W.toString().padStart(3, "0");
|
|
367
367
|
let t = "";
|
|
368
368
|
try {
|
|
369
369
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -373,14 +373,14 @@ const Ft = () => {
|
|
|
373
373
|
} catch {
|
|
374
374
|
}
|
|
375
375
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${s}-${e}-${t}`;
|
|
376
|
-
},
|
|
376
|
+
}, Ye = (s, e = !1) => {
|
|
377
377
|
try {
|
|
378
378
|
const t = new URL(s), r = t.protocol === "https:", n = t.protocol === "http:";
|
|
379
379
|
return r || e && n;
|
|
380
380
|
} catch {
|
|
381
381
|
return !1;
|
|
382
382
|
}
|
|
383
|
-
},
|
|
383
|
+
}, Bt = (s) => {
|
|
384
384
|
try {
|
|
385
385
|
const t = new URL(window.location.href).hostname;
|
|
386
386
|
if (!t || typeof t != "string")
|
|
@@ -398,28 +398,28 @@ const Ft = () => {
|
|
|
398
398
|
if (r.length === 2 ? n = r.join(".") : n = r.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
399
399
|
throw new Error("Invalid domain structure for SaaS");
|
|
400
400
|
const i = `https://${s}.${n}/collect`;
|
|
401
|
-
if (!
|
|
401
|
+
if (!Ye(i))
|
|
402
402
|
throw new Error("Generated URL failed validation");
|
|
403
403
|
return i;
|
|
404
404
|
} catch (e) {
|
|
405
405
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
406
406
|
}
|
|
407
|
-
},
|
|
407
|
+
}, Wt = (s) => {
|
|
408
408
|
const e = {};
|
|
409
|
-
s.integrations?.tracelog?.projectId && (e.saas =
|
|
409
|
+
s.integrations?.tracelog?.projectId && (e.saas = Bt(s.integrations.tracelog.projectId));
|
|
410
410
|
const t = s.integrations?.custom?.collectApiUrl;
|
|
411
411
|
if (t) {
|
|
412
412
|
const r = s.integrations?.custom?.allowHttp ?? !1;
|
|
413
|
-
if (!
|
|
413
|
+
if (!Ye(t, r))
|
|
414
414
|
throw new Error("Invalid custom API URL");
|
|
415
415
|
e.custom = t;
|
|
416
416
|
}
|
|
417
417
|
return e;
|
|
418
|
-
},
|
|
418
|
+
}, de = (s, e = []) => {
|
|
419
419
|
if (!s || typeof s != "string")
|
|
420
420
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof s } }), s || "";
|
|
421
421
|
try {
|
|
422
|
-
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
422
|
+
const t = new URL(s), r = t.searchParams, n = [.../* @__PURE__ */ new Set([...ct, ...e])];
|
|
423
423
|
let i = !1;
|
|
424
424
|
const o = [];
|
|
425
425
|
return n.forEach((c) => {
|
|
@@ -428,13 +428,13 @@ const Ft = () => {
|
|
|
428
428
|
} catch (t) {
|
|
429
429
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: s?.length } }), s;
|
|
430
430
|
}
|
|
431
|
-
},
|
|
431
|
+
}, xe = (s) => {
|
|
432
432
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
433
433
|
return "";
|
|
434
434
|
let e = s;
|
|
435
435
|
s.length > 1e3 && (e = s.slice(0, Math.max(0, 1e3)));
|
|
436
436
|
let t = 0;
|
|
437
|
-
for (const n of
|
|
437
|
+
for (const n of ut) {
|
|
438
438
|
const i = e;
|
|
439
439
|
e = e.replace(n, ""), i !== e && t++;
|
|
440
440
|
}
|
|
@@ -444,165 +444,167 @@ const Ft = () => {
|
|
|
444
444
|
valueLength: s.length
|
|
445
445
|
}
|
|
446
446
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
447
|
-
},
|
|
448
|
-
if (
|
|
447
|
+
}, he = (s, e = 0) => {
|
|
448
|
+
if (s == null)
|
|
449
449
|
return null;
|
|
450
450
|
if (typeof s == "string")
|
|
451
|
-
return
|
|
451
|
+
return xe(s);
|
|
452
452
|
if (typeof s == "number")
|
|
453
453
|
return !Number.isFinite(s) || s < -Number.MAX_SAFE_INTEGER || s > Number.MAX_SAFE_INTEGER ? 0 : s;
|
|
454
454
|
if (typeof s == "boolean")
|
|
455
455
|
return s;
|
|
456
|
+
if (e > 10)
|
|
457
|
+
return null;
|
|
456
458
|
if (Array.isArray(s))
|
|
457
|
-
return s.slice(0, 100).map((n) =>
|
|
459
|
+
return s.slice(0, 100).map((n) => he(n, e + 1)).filter((n) => n !== null);
|
|
458
460
|
if (typeof s == "object") {
|
|
459
461
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
460
462
|
for (const [i, o] of n) {
|
|
461
|
-
const l =
|
|
463
|
+
const l = xe(i);
|
|
462
464
|
if (l) {
|
|
463
|
-
const c =
|
|
465
|
+
const c = he(o, e + 1);
|
|
464
466
|
c !== null && (t[l] = c);
|
|
465
467
|
}
|
|
466
468
|
}
|
|
467
469
|
return t;
|
|
468
470
|
}
|
|
469
471
|
return null;
|
|
470
|
-
},
|
|
472
|
+
}, Gt = (s) => {
|
|
471
473
|
if (typeof s != "object" || s === null)
|
|
472
474
|
return {};
|
|
473
475
|
try {
|
|
474
|
-
const e =
|
|
476
|
+
const e = he(s);
|
|
475
477
|
return typeof e == "object" && e !== null ? e : {};
|
|
476
478
|
} catch (e) {
|
|
477
479
|
const t = e instanceof Error ? e.message : String(e);
|
|
478
480
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
479
481
|
}
|
|
480
|
-
},
|
|
482
|
+
}, Xt = (s) => {
|
|
481
483
|
if (s !== void 0 && (s === null || typeof s != "object"))
|
|
482
|
-
throw new
|
|
484
|
+
throw new f("Configuration must be an object", "config");
|
|
483
485
|
if (s) {
|
|
484
486
|
if (s.sessionTimeout !== void 0 && (typeof s.sessionTimeout != "number" || s.sessionTimeout < 3e4 || s.sessionTimeout > 864e5))
|
|
485
|
-
throw new
|
|
487
|
+
throw new mt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
486
488
|
if (s.globalMetadata !== void 0 && (typeof s.globalMetadata != "object" || s.globalMetadata === null))
|
|
487
|
-
throw new
|
|
488
|
-
if (s.integrations &&
|
|
489
|
+
throw new f(m.INVALID_GLOBAL_METADATA, "config");
|
|
490
|
+
if (s.integrations && jt(s.integrations), s.sensitiveQueryParams !== void 0) {
|
|
489
491
|
if (!Array.isArray(s.sensitiveQueryParams))
|
|
490
|
-
throw new
|
|
492
|
+
throw new f(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
491
493
|
for (const e of s.sensitiveQueryParams)
|
|
492
494
|
if (typeof e != "string")
|
|
493
|
-
throw new
|
|
495
|
+
throw new f("All sensitive query params must be strings", "config");
|
|
494
496
|
}
|
|
495
497
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
496
|
-
throw new
|
|
498
|
+
throw new Ne(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
497
499
|
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
498
|
-
throw new
|
|
500
|
+
throw new Ne(m.INVALID_SAMPLING_RATE, "config");
|
|
499
501
|
if (s.primaryScrollSelector !== void 0) {
|
|
500
502
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
501
|
-
throw new
|
|
503
|
+
throw new f(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
502
504
|
if (s.primaryScrollSelector !== "window")
|
|
503
505
|
try {
|
|
504
506
|
document.querySelector(s.primaryScrollSelector);
|
|
505
507
|
} catch {
|
|
506
|
-
throw new
|
|
508
|
+
throw new f(
|
|
507
509
|
`${m.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${s.primaryScrollSelector}"`,
|
|
508
510
|
"config"
|
|
509
511
|
);
|
|
510
512
|
}
|
|
511
513
|
}
|
|
512
514
|
if (s.pageViewThrottleMs !== void 0 && (typeof s.pageViewThrottleMs != "number" || s.pageViewThrottleMs < 0))
|
|
513
|
-
throw new
|
|
515
|
+
throw new f(m.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
514
516
|
if (s.clickThrottleMs !== void 0 && (typeof s.clickThrottleMs != "number" || s.clickThrottleMs < 0))
|
|
515
|
-
throw new
|
|
517
|
+
throw new f(m.INVALID_CLICK_THROTTLE, "config");
|
|
516
518
|
if (s.maxSameEventPerMinute !== void 0 && (typeof s.maxSameEventPerMinute != "number" || s.maxSameEventPerMinute <= 0))
|
|
517
|
-
throw new
|
|
518
|
-
if (s.viewport !== void 0 &&
|
|
519
|
+
throw new f(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
520
|
+
if (s.viewport !== void 0 && Qt(s.viewport), s.webVitalsMode !== void 0) {
|
|
519
521
|
if (typeof s.webVitalsMode != "string")
|
|
520
|
-
throw new
|
|
522
|
+
throw new f(
|
|
521
523
|
`Invalid webVitalsMode type: ${typeof s.webVitalsMode}. Must be a string`,
|
|
522
524
|
"config"
|
|
523
525
|
);
|
|
524
526
|
const e = ["all", "needs-improvement", "poor"];
|
|
525
527
|
if (!e.includes(s.webVitalsMode))
|
|
526
|
-
throw new
|
|
528
|
+
throw new f(
|
|
527
529
|
`Invalid webVitalsMode: "${s.webVitalsMode}". Must be one of: ${e.join(", ")}`,
|
|
528
530
|
"config"
|
|
529
531
|
);
|
|
530
532
|
}
|
|
531
533
|
if (s.webVitalsThresholds !== void 0) {
|
|
532
534
|
if (typeof s.webVitalsThresholds != "object" || s.webVitalsThresholds === null || Array.isArray(s.webVitalsThresholds))
|
|
533
|
-
throw new
|
|
535
|
+
throw new f("webVitalsThresholds must be an object", "config");
|
|
534
536
|
const e = ["LCP", "FCP", "CLS", "INP", "TTFB", "LONG_TASK"];
|
|
535
537
|
for (const [t, r] of Object.entries(s.webVitalsThresholds)) {
|
|
536
538
|
if (!e.includes(t))
|
|
537
|
-
throw new
|
|
539
|
+
throw new f(
|
|
538
540
|
`Invalid Web Vitals threshold key: "${t}". Must be one of: ${e.join(", ")}`,
|
|
539
541
|
"config"
|
|
540
542
|
);
|
|
541
543
|
if (typeof r != "number" || !Number.isFinite(r) || r < 0)
|
|
542
|
-
throw new
|
|
544
|
+
throw new f(
|
|
543
545
|
`Invalid Web Vitals threshold value for ${t}: ${r}. Must be a non-negative finite number`,
|
|
544
546
|
"config"
|
|
545
547
|
);
|
|
546
548
|
}
|
|
547
549
|
}
|
|
548
550
|
}
|
|
549
|
-
},
|
|
551
|
+
}, Qt = (s) => {
|
|
550
552
|
if (typeof s != "object" || s === null)
|
|
551
|
-
throw new
|
|
553
|
+
throw new f(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
552
554
|
if (!s.elements || !Array.isArray(s.elements))
|
|
553
|
-
throw new
|
|
555
|
+
throw new f(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
554
556
|
if (s.elements.length === 0)
|
|
555
|
-
throw new
|
|
557
|
+
throw new f(m.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
556
558
|
const e = /* @__PURE__ */ new Set();
|
|
557
559
|
for (const t of s.elements) {
|
|
558
560
|
if (!t.selector || typeof t.selector != "string" || !t.selector.trim())
|
|
559
|
-
throw new
|
|
561
|
+
throw new f(m.INVALID_VIEWPORT_ELEMENT, "config");
|
|
560
562
|
const r = t.selector.trim();
|
|
561
563
|
if (e.has(r))
|
|
562
|
-
throw new
|
|
564
|
+
throw new f(
|
|
563
565
|
`Duplicate viewport selector found: "${r}". Each selector should appear only once.`,
|
|
564
566
|
"config"
|
|
565
567
|
);
|
|
566
568
|
if (e.add(r), t.id !== void 0 && (typeof t.id != "string" || !t.id.trim()))
|
|
567
|
-
throw new
|
|
569
|
+
throw new f(m.INVALID_VIEWPORT_ELEMENT_ID, "config");
|
|
568
570
|
if (t.name !== void 0 && (typeof t.name != "string" || !t.name.trim()))
|
|
569
|
-
throw new
|
|
571
|
+
throw new f(m.INVALID_VIEWPORT_ELEMENT_NAME, "config");
|
|
570
572
|
}
|
|
571
573
|
if (s.threshold !== void 0 && (typeof s.threshold != "number" || s.threshold < 0 || s.threshold > 1))
|
|
572
|
-
throw new
|
|
574
|
+
throw new f(m.INVALID_VIEWPORT_THRESHOLD, "config");
|
|
573
575
|
if (s.minDwellTime !== void 0 && (typeof s.minDwellTime != "number" || s.minDwellTime < 0))
|
|
574
|
-
throw new
|
|
576
|
+
throw new f(m.INVALID_VIEWPORT_MIN_DWELL_TIME, "config");
|
|
575
577
|
if (s.cooldownPeriod !== void 0 && (typeof s.cooldownPeriod != "number" || s.cooldownPeriod < 0))
|
|
576
|
-
throw new
|
|
578
|
+
throw new f(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
577
579
|
if (s.maxTrackedElements !== void 0 && (typeof s.maxTrackedElements != "number" || s.maxTrackedElements <= 0))
|
|
578
|
-
throw new
|
|
579
|
-
},
|
|
580
|
+
throw new f(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
581
|
+
}, jt = (s) => {
|
|
580
582
|
if (s) {
|
|
581
583
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
582
|
-
throw new
|
|
584
|
+
throw new V(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
583
585
|
if (s.custom) {
|
|
584
586
|
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
585
|
-
throw new
|
|
587
|
+
throw new V(m.INVALID_CUSTOM_API_URL, "config");
|
|
586
588
|
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
587
|
-
throw new
|
|
589
|
+
throw new V("allowHttp must be a boolean", "config");
|
|
588
590
|
const e = s.custom.collectApiUrl.trim();
|
|
589
591
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
590
|
-
throw new
|
|
592
|
+
throw new V('Custom API URL must start with "http://" or "https://"', "config");
|
|
591
593
|
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
592
|
-
throw new
|
|
594
|
+
throw new V(
|
|
593
595
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
594
596
|
"config"
|
|
595
597
|
);
|
|
596
598
|
}
|
|
597
599
|
}
|
|
598
|
-
},
|
|
599
|
-
|
|
600
|
+
}, zt = (s) => {
|
|
601
|
+
Xt(s);
|
|
600
602
|
const e = {
|
|
601
603
|
...s ?? {},
|
|
602
604
|
sessionTimeout: s?.sessionTimeout ?? 9e5,
|
|
603
605
|
globalMetadata: s?.globalMetadata ?? {},
|
|
604
606
|
sensitiveQueryParams: s?.sensitiveQueryParams ?? [],
|
|
605
|
-
errorSampling: s?.errorSampling ??
|
|
607
|
+
errorSampling: s?.errorSampling ?? ze,
|
|
606
608
|
samplingRate: s?.samplingRate ?? 1,
|
|
607
609
|
pageViewThrottleMs: s?.pageViewThrottleMs ?? 1e3,
|
|
608
610
|
clickThrottleMs: s?.clickThrottleMs ?? 300,
|
|
@@ -618,51 +620,12 @@ const Ft = () => {
|
|
|
618
620
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
619
621
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
620
622
|
}), e;
|
|
621
|
-
},
|
|
622
|
-
if (
|
|
623
|
+
}, fe = (s, e = /* @__PURE__ */ new Set()) => {
|
|
624
|
+
if (s == null)
|
|
623
625
|
return !0;
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
return !1;
|
|
628
|
-
for (const [, t] of e) {
|
|
629
|
-
if (t == null)
|
|
630
|
-
continue;
|
|
631
|
-
const r = typeof t;
|
|
632
|
-
if (r !== "string" && r !== "number" && r !== "boolean")
|
|
633
|
-
return !1;
|
|
634
|
-
}
|
|
635
|
-
return !0;
|
|
636
|
-
}
|
|
637
|
-
return !1;
|
|
638
|
-
}, Ke = (s, e = 0) => {
|
|
639
|
-
if (typeof s != "object" || s === null || e > 1)
|
|
640
|
-
return !1;
|
|
641
|
-
for (const t of Object.values(s)) {
|
|
642
|
-
if (t == null)
|
|
643
|
-
continue;
|
|
644
|
-
const r = typeof t;
|
|
645
|
-
if (!(r === "string" || r === "number" || r === "boolean")) {
|
|
646
|
-
if (Array.isArray(t)) {
|
|
647
|
-
if (t.length === 0)
|
|
648
|
-
continue;
|
|
649
|
-
if (typeof t[0] == "string") {
|
|
650
|
-
if (!t.every((o) => typeof o == "string"))
|
|
651
|
-
return !1;
|
|
652
|
-
} else if (!t.every((o) => zt(o)))
|
|
653
|
-
return !1;
|
|
654
|
-
continue;
|
|
655
|
-
}
|
|
656
|
-
if (r === "object" && e === 0) {
|
|
657
|
-
if (!Ke(t, e + 1))
|
|
658
|
-
return !1;
|
|
659
|
-
continue;
|
|
660
|
-
}
|
|
661
|
-
return !1;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
return !0;
|
|
665
|
-
}, Kt = (s) => typeof s != "string" ? {
|
|
626
|
+
const t = typeof s;
|
|
627
|
+
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(s) ? !1 : (e.add(s), Array.isArray(s) ? s.every((r) => fe(r, e)) : t === "object" ? Object.values(s).every((r) => fe(r, e)) : !1);
|
|
628
|
+
}, Kt = (s) => typeof s != "object" || s === null ? !1 : fe(s), Yt = (s) => typeof s != "string" ? {
|
|
666
629
|
valid: !1,
|
|
667
630
|
error: "Event name must be a string"
|
|
668
631
|
} : s.length === 0 ? {
|
|
@@ -677,9 +640,9 @@ const Ft = () => {
|
|
|
677
640
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(s.toLowerCase()) ? {
|
|
678
641
|
valid: !1,
|
|
679
642
|
error: "Event name cannot be a reserved word"
|
|
680
|
-
} : { valid: !0 },
|
|
681
|
-
const r =
|
|
682
|
-
if (!
|
|
643
|
+
} : { valid: !0 }, He = (s, e, t) => {
|
|
644
|
+
const r = Gt(e), n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
645
|
+
if (!Kt(r))
|
|
683
646
|
return {
|
|
684
647
|
valid: !1,
|
|
685
648
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -727,7 +690,7 @@ const Ft = () => {
|
|
|
727
690
|
valid: !0,
|
|
728
691
|
sanitizedMetadata: r
|
|
729
692
|
};
|
|
730
|
-
},
|
|
693
|
+
}, qe = (s, e, t) => {
|
|
731
694
|
if (Array.isArray(e)) {
|
|
732
695
|
const r = [], n = t && t === "customEvent" ? `${t} "${s}" metadata error` : `${s} metadata error`;
|
|
733
696
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -737,7 +700,7 @@ const Ft = () => {
|
|
|
737
700
|
valid: !1,
|
|
738
701
|
error: `${n}: array item at index ${i} must be an object.`
|
|
739
702
|
};
|
|
740
|
-
const l =
|
|
703
|
+
const l = He(s, o, t);
|
|
741
704
|
if (!l.valid)
|
|
742
705
|
return {
|
|
743
706
|
valid: !1,
|
|
@@ -750,16 +713,16 @@ const Ft = () => {
|
|
|
750
713
|
sanitizedMetadata: r
|
|
751
714
|
};
|
|
752
715
|
}
|
|
753
|
-
return
|
|
754
|
-
},
|
|
755
|
-
const t =
|
|
716
|
+
return He(s, e, t);
|
|
717
|
+
}, qt = (s, e) => {
|
|
718
|
+
const t = Yt(s);
|
|
756
719
|
if (!t.valid)
|
|
757
720
|
return a("error", "Event name validation failed", {
|
|
758
721
|
data: { eventName: s, error: t.error }
|
|
759
722
|
}), t;
|
|
760
723
|
if (!e)
|
|
761
724
|
return { valid: !0 };
|
|
762
|
-
const r =
|
|
725
|
+
const r = qe(s, e, "customEvent");
|
|
763
726
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
764
727
|
data: {
|
|
765
728
|
eventName: s,
|
|
@@ -767,7 +730,7 @@ const Ft = () => {
|
|
|
767
730
|
}
|
|
768
731
|
}), r;
|
|
769
732
|
};
|
|
770
|
-
class
|
|
733
|
+
class Jt {
|
|
771
734
|
listeners = /* @__PURE__ */ new Map();
|
|
772
735
|
/**
|
|
773
736
|
* Subscribes to an event channel
|
|
@@ -884,7 +847,7 @@ class qt {
|
|
|
884
847
|
this.listeners.clear();
|
|
885
848
|
}
|
|
886
849
|
}
|
|
887
|
-
function
|
|
850
|
+
function Je(s, e, t) {
|
|
888
851
|
try {
|
|
889
852
|
const r = e(s);
|
|
890
853
|
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), s);
|
|
@@ -895,10 +858,10 @@ function qe(s, e, t) {
|
|
|
895
858
|
}), s;
|
|
896
859
|
}
|
|
897
860
|
}
|
|
898
|
-
function
|
|
899
|
-
return s.map((r) =>
|
|
861
|
+
function Zt(s, e, t) {
|
|
862
|
+
return s.map((r) => Je(r, e, t)).filter((r) => r !== null);
|
|
900
863
|
}
|
|
901
|
-
function
|
|
864
|
+
function Ze(s, e, t) {
|
|
902
865
|
try {
|
|
903
866
|
const r = e(s);
|
|
904
867
|
return r === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -914,7 +877,7 @@ function Je(s, e, t) {
|
|
|
914
877
|
}), s;
|
|
915
878
|
}
|
|
916
879
|
}
|
|
917
|
-
const
|
|
880
|
+
const ne = {};
|
|
918
881
|
class _ {
|
|
919
882
|
/**
|
|
920
883
|
* Retrieves a value from global state.
|
|
@@ -933,7 +896,7 @@ class _ {
|
|
|
933
896
|
* ```
|
|
934
897
|
*/
|
|
935
898
|
get(e) {
|
|
936
|
-
return
|
|
899
|
+
return ne[e];
|
|
937
900
|
}
|
|
938
901
|
/**
|
|
939
902
|
* Sets a value in global state.
|
|
@@ -953,7 +916,7 @@ class _ {
|
|
|
953
916
|
* ```
|
|
954
917
|
*/
|
|
955
918
|
set(e, t) {
|
|
956
|
-
|
|
919
|
+
ne[e] = t;
|
|
957
920
|
}
|
|
958
921
|
/**
|
|
959
922
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -970,14 +933,16 @@ class _ {
|
|
|
970
933
|
* ```
|
|
971
934
|
*/
|
|
972
935
|
getState() {
|
|
973
|
-
return { ...
|
|
936
|
+
return { ...ne };
|
|
974
937
|
}
|
|
975
938
|
}
|
|
976
|
-
class
|
|
939
|
+
class Fe extends _ {
|
|
977
940
|
storeManager;
|
|
978
941
|
integrationId;
|
|
979
942
|
apiUrl;
|
|
980
943
|
transformers;
|
|
944
|
+
staticHeaders;
|
|
945
|
+
customHeadersProvider;
|
|
981
946
|
lastPermanentErrorLog = null;
|
|
982
947
|
recoveryInProgress = !1;
|
|
983
948
|
lastMetadataTimestamp = 0;
|
|
@@ -992,12 +957,14 @@ class xe extends _ {
|
|
|
992
957
|
* @param integrationId - Optional integration identifier ('saas' or 'custom')
|
|
993
958
|
* @param apiUrl - Optional API endpoint URL
|
|
994
959
|
* @param transformers - Optional event transformation hooks
|
|
960
|
+
* @param staticHeaders - Optional static HTTP headers (from config)
|
|
961
|
+
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
995
962
|
* @throws Error if integrationId and apiUrl are not both provided or both undefined
|
|
996
963
|
*/
|
|
997
|
-
constructor(e, t, r, n = {}) {
|
|
964
|
+
constructor(e, t, r, n = {}, i = {}, o) {
|
|
998
965
|
if (super(), t && !r || !t && r)
|
|
999
966
|
throw new Error("SenderManager: integrationId and apiUrl must either both be provided or both be undefined");
|
|
1000
|
-
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers = n;
|
|
967
|
+
this.storeManager = e, this.integrationId = t, this.apiUrl = r, this.transformers = n, this.staticHeaders = i, this.customHeadersProvider = o;
|
|
1001
968
|
}
|
|
1002
969
|
/**
|
|
1003
970
|
* Get the integration ID for this sender
|
|
@@ -1006,8 +973,45 @@ class xe extends _ {
|
|
|
1006
973
|
getIntegrationId() {
|
|
1007
974
|
return this.integrationId;
|
|
1008
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Sets the custom headers provider callback.
|
|
978
|
+
* Only applies to 'custom' integration (ignored for 'saas').
|
|
979
|
+
*
|
|
980
|
+
* @param provider - Callback function that returns custom headers
|
|
981
|
+
*/
|
|
982
|
+
setCustomHeadersProvider(e) {
|
|
983
|
+
this.customHeadersProvider = e;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Removes the custom headers provider callback.
|
|
987
|
+
*/
|
|
988
|
+
removeCustomHeadersProvider() {
|
|
989
|
+
this.customHeadersProvider = void 0;
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Builds custom headers by merging static headers with dynamic headers from provider.
|
|
993
|
+
* Only applies to 'custom' integration (returns empty object for 'saas').
|
|
994
|
+
*
|
|
995
|
+
* @returns Merged custom headers object (dynamic headers override static)
|
|
996
|
+
* @private
|
|
997
|
+
*/
|
|
998
|
+
getCustomHeaders() {
|
|
999
|
+
if (this.integrationId !== "custom")
|
|
1000
|
+
return {};
|
|
1001
|
+
let e = {};
|
|
1002
|
+
if (this.customHeadersProvider)
|
|
1003
|
+
try {
|
|
1004
|
+
const t = this.customHeadersProvider();
|
|
1005
|
+
typeof t == "object" && t !== null && !Array.isArray(t) ? e = t : a("warn", "Custom headers provider returned invalid value, expected object", {
|
|
1006
|
+
data: { received: typeof t }
|
|
1007
|
+
});
|
|
1008
|
+
} catch (t) {
|
|
1009
|
+
a("warn", "Custom headers provider threw an error, using static headers only", { error: t });
|
|
1010
|
+
}
|
|
1011
|
+
return { ...this.staticHeaders, ...e };
|
|
1012
|
+
}
|
|
1009
1013
|
getQueueStorageKey() {
|
|
1010
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1014
|
+
const e = this.get("userId") || "anonymous", t = dt(e);
|
|
1011
1015
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1012
1016
|
}
|
|
1013
1017
|
/**
|
|
@@ -1032,6 +1036,11 @@ class xe extends _ {
|
|
|
1032
1036
|
*
|
|
1033
1037
|
* **Important**: No retry mechanism for failures. Events are NOT persisted.
|
|
1034
1038
|
*
|
|
1039
|
+
* **Custom Headers Limitation**: Custom headers set via `setCustomHeaders()` are NOT applied
|
|
1040
|
+
* to sendBeacon requests due to browser API limitations. The sendBeacon API only supports
|
|
1041
|
+
* Content-Type header via Blob. For scenarios requiring custom headers, ensure async
|
|
1042
|
+
* sends complete before page unload.
|
|
1043
|
+
*
|
|
1035
1044
|
* @param body - Event queue to send
|
|
1036
1045
|
* @returns `true` if send succeeded or was skipped, `false` if failed
|
|
1037
1046
|
*
|
|
@@ -1039,13 +1048,13 @@ class xe extends _ {
|
|
|
1039
1048
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1040
1049
|
*/
|
|
1041
1050
|
sendEventsQueueSync(e) {
|
|
1042
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1051
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(U.Fail) ? (a(
|
|
1043
1052
|
"warn",
|
|
1044
1053
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1045
1054
|
{
|
|
1046
1055
|
data: { events: e.events.length }
|
|
1047
1056
|
}
|
|
1048
|
-
), !1) : this.apiUrl?.includes(
|
|
1057
|
+
), !1) : this.apiUrl?.includes(U.Localhost) ? (a(
|
|
1049
1058
|
"debug",
|
|
1050
1059
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1051
1060
|
{
|
|
@@ -1087,7 +1096,7 @@ class xe extends _ {
|
|
|
1087
1096
|
const r = await this.send(e);
|
|
1088
1097
|
return r ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), r;
|
|
1089
1098
|
} catch (r) {
|
|
1090
|
-
return r instanceof
|
|
1099
|
+
return r instanceof O ? (this.logPermanentError("Permanent error, not retrying", r), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1091
1100
|
}
|
|
1092
1101
|
}
|
|
1093
1102
|
/**
|
|
@@ -1154,7 +1163,7 @@ class xe extends _ {
|
|
|
1154
1163
|
const r = this.createRecoveryBody(t);
|
|
1155
1164
|
await this.send(r) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, r)) : e?.onFailure?.();
|
|
1156
1165
|
} catch (t) {
|
|
1157
|
-
if (t instanceof
|
|
1166
|
+
if (t instanceof O) {
|
|
1158
1167
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1159
1168
|
return;
|
|
1160
1169
|
}
|
|
@@ -1208,7 +1217,7 @@ class xe extends _ {
|
|
|
1208
1217
|
const t = this.transformers.beforeSend;
|
|
1209
1218
|
if (!t)
|
|
1210
1219
|
return e;
|
|
1211
|
-
const r =
|
|
1220
|
+
const r = Zt(
|
|
1212
1221
|
e.events,
|
|
1213
1222
|
t,
|
|
1214
1223
|
this.integrationId || "SenderManager"
|
|
@@ -1253,7 +1262,7 @@ class xe extends _ {
|
|
|
1253
1262
|
if (this.integrationId === "saas")
|
|
1254
1263
|
return e;
|
|
1255
1264
|
const t = this.transformers.beforeBatch;
|
|
1256
|
-
return t ?
|
|
1265
|
+
return t ? Ze(e, t, this.integrationId || "SenderManager") : e;
|
|
1257
1266
|
}
|
|
1258
1267
|
/**
|
|
1259
1268
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1321,11 +1330,11 @@ class xe extends _ {
|
|
|
1321
1330
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1322
1331
|
if (!r)
|
|
1323
1332
|
return !0;
|
|
1324
|
-
if (this.apiUrl?.includes(
|
|
1333
|
+
if (this.apiUrl?.includes(U.Fail))
|
|
1325
1334
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1326
1335
|
data: { events: r.events.length }
|
|
1327
1336
|
}), !1;
|
|
1328
|
-
if (this.apiUrl?.includes(
|
|
1337
|
+
if (this.apiUrl?.includes(U.Localhost))
|
|
1329
1338
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1330
1339
|
data: { events: r.events.length }
|
|
1331
1340
|
}), !0;
|
|
@@ -1341,7 +1350,7 @@ class xe extends _ {
|
|
|
1341
1350
|
), !0) : !1;
|
|
1342
1351
|
} catch (l) {
|
|
1343
1352
|
const c = o === 3;
|
|
1344
|
-
if (l instanceof
|
|
1353
|
+
if (l instanceof O)
|
|
1345
1354
|
throw l;
|
|
1346
1355
|
if (a(
|
|
1347
1356
|
c ? "error" : "warn",
|
|
@@ -1391,19 +1400,20 @@ class xe extends _ {
|
|
|
1391
1400
|
r.abort();
|
|
1392
1401
|
}, 15e3);
|
|
1393
1402
|
try {
|
|
1394
|
-
const i = await fetch(e, {
|
|
1403
|
+
const i = this.getCustomHeaders(), o = await fetch(e, {
|
|
1395
1404
|
method: "POST",
|
|
1396
1405
|
body: t,
|
|
1397
1406
|
keepalive: !0,
|
|
1398
1407
|
credentials: "include",
|
|
1399
1408
|
signal: r.signal,
|
|
1400
1409
|
headers: {
|
|
1410
|
+
...i,
|
|
1401
1411
|
"Content-Type": "application/json"
|
|
1402
1412
|
}
|
|
1403
1413
|
});
|
|
1404
|
-
if (!
|
|
1405
|
-
throw
|
|
1406
|
-
return
|
|
1414
|
+
if (!o.ok)
|
|
1415
|
+
throw o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429 ? new O(`HTTP ${o.status}: ${o.statusText}`, o.status) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1416
|
+
return o;
|
|
1407
1417
|
} finally {
|
|
1408
1418
|
clearTimeout(n), this.pendingControllers.delete(r);
|
|
1409
1419
|
}
|
|
@@ -1486,7 +1496,7 @@ class xe extends _ {
|
|
|
1486
1496
|
_metadata: {
|
|
1487
1497
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1488
1498
|
timestamp: t,
|
|
1489
|
-
client_version:
|
|
1499
|
+
client_version: Dt
|
|
1490
1500
|
}
|
|
1491
1501
|
};
|
|
1492
1502
|
return {
|
|
@@ -1607,12 +1617,12 @@ class xe extends _ {
|
|
|
1607
1617
|
}
|
|
1608
1618
|
logPermanentError(e, t) {
|
|
1609
1619
|
const r = Date.now();
|
|
1610
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1620
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= Ct) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1611
1621
|
data: { status: t.statusCode, message: t.message }
|
|
1612
1622
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1613
1623
|
}
|
|
1614
1624
|
}
|
|
1615
|
-
class
|
|
1625
|
+
class er extends _ {
|
|
1616
1626
|
bootTime;
|
|
1617
1627
|
bootTimestamp;
|
|
1618
1628
|
hasPerformanceNow;
|
|
@@ -1761,7 +1771,7 @@ class Zt extends _ {
|
|
|
1761
1771
|
};
|
|
1762
1772
|
}
|
|
1763
1773
|
}
|
|
1764
|
-
class
|
|
1774
|
+
class tr extends _ {
|
|
1765
1775
|
dataSenders;
|
|
1766
1776
|
emitter;
|
|
1767
1777
|
transformers;
|
|
@@ -1793,12 +1803,23 @@ class er extends _ {
|
|
|
1793
1803
|
* @param storeManager - Storage manager for persistence
|
|
1794
1804
|
* @param emitter - Optional event emitter for local event consumption
|
|
1795
1805
|
* @param transformers - Optional event transformation hooks
|
|
1806
|
+
* @param staticHeaders - Optional static HTTP headers for custom backend (from config)
|
|
1807
|
+
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1796
1808
|
*/
|
|
1797
|
-
constructor(e, t = null, r = {}) {
|
|
1798
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1799
|
-
const
|
|
1800
|
-
|
|
1801
|
-
|
|
1809
|
+
constructor(e, t = null, r = {}, n = {}, i) {
|
|
1810
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new er(), this.dataSenders = [];
|
|
1811
|
+
const o = this.get("collectApiUrls");
|
|
1812
|
+
o?.saas && this.dataSenders.push(new Fe(e, "saas", o.saas, r)), o?.custom && this.dataSenders.push(
|
|
1813
|
+
new Fe(
|
|
1814
|
+
e,
|
|
1815
|
+
"custom",
|
|
1816
|
+
o.custom,
|
|
1817
|
+
r,
|
|
1818
|
+
n,
|
|
1819
|
+
i
|
|
1820
|
+
)
|
|
1821
|
+
), this.saveSessionCountsDebounced = this.debounce((l) => {
|
|
1822
|
+
this.saveSessionCounts(l);
|
|
1802
1823
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1803
1824
|
}
|
|
1804
1825
|
/**
|
|
@@ -1954,12 +1975,12 @@ class er extends _ {
|
|
|
1954
1975
|
}
|
|
1955
1976
|
const T = this.getTypeLimitForEvent(E);
|
|
1956
1977
|
if (T) {
|
|
1957
|
-
const
|
|
1958
|
-
if (
|
|
1978
|
+
const te = this.sessionEventCounts[E];
|
|
1979
|
+
if (te !== void 0 && te >= T) {
|
|
1959
1980
|
a("warn", "Session event type limit reached", {
|
|
1960
1981
|
data: {
|
|
1961
1982
|
type: E,
|
|
1962
|
-
count:
|
|
1983
|
+
count: te,
|
|
1963
1984
|
limit: T
|
|
1964
1985
|
}
|
|
1965
1986
|
});
|
|
@@ -1972,9 +1993,9 @@ class er extends _ {
|
|
|
1972
1993
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1973
1994
|
return;
|
|
1974
1995
|
}
|
|
1975
|
-
const
|
|
1996
|
+
const we = E === d.SESSION_START, B = t || this.get("pageUrl"), k = this.buildEventPayload({
|
|
1976
1997
|
type: E,
|
|
1977
|
-
page_url:
|
|
1998
|
+
page_url: B,
|
|
1978
1999
|
from_page_url: r,
|
|
1979
2000
|
scroll_data: n,
|
|
1980
2001
|
click_data: i,
|
|
@@ -1984,8 +2005,8 @@ class er extends _ {
|
|
|
1984
2005
|
viewport_data: u,
|
|
1985
2006
|
page_view: S
|
|
1986
2007
|
});
|
|
1987
|
-
if (
|
|
1988
|
-
if (
|
|
2008
|
+
if (k && !(!p && !this.shouldSample())) {
|
|
2009
|
+
if (we) {
|
|
1989
2010
|
const T = this.get("sessionId");
|
|
1990
2011
|
if (!T) {
|
|
1991
2012
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -1999,8 +2020,8 @@ class er extends _ {
|
|
|
1999
2020
|
}
|
|
2000
2021
|
this.set("hasStartSession", !0);
|
|
2001
2022
|
}
|
|
2002
|
-
if (!this.isDuplicateEvent(
|
|
2003
|
-
if (this.get("mode") ===
|
|
2023
|
+
if (!this.isDuplicateEvent(k)) {
|
|
2024
|
+
if (this.get("mode") === K.QA) {
|
|
2004
2025
|
if (E === d.CUSTOM && o) {
|
|
2005
2026
|
a("info", `Custom Event: ${o.name}`, {
|
|
2006
2027
|
visibility: "qa",
|
|
@@ -2008,7 +2029,7 @@ class er extends _ {
|
|
|
2008
2029
|
name: o.name,
|
|
2009
2030
|
...o.metadata && { metadata: o.metadata }
|
|
2010
2031
|
}
|
|
2011
|
-
}), this.emitEvent(
|
|
2032
|
+
}), this.emitEvent(k);
|
|
2012
2033
|
return;
|
|
2013
2034
|
}
|
|
2014
2035
|
if (E === d.VIEWPORT_VISIBLE && u) {
|
|
@@ -2022,11 +2043,11 @@ class er extends _ {
|
|
|
2022
2043
|
visibilityRatio: u.visibilityRatio,
|
|
2023
2044
|
dwellTime: u.dwellTime
|
|
2024
2045
|
}
|
|
2025
|
-
}), this.emitEvent(
|
|
2046
|
+
}), this.emitEvent(k);
|
|
2026
2047
|
return;
|
|
2027
2048
|
}
|
|
2028
2049
|
}
|
|
2029
|
-
if (this.addToQueue(
|
|
2050
|
+
if (this.addToQueue(k), !p) {
|
|
2030
2051
|
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2031
2052
|
const T = this.get("sessionId");
|
|
2032
2053
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
@@ -2156,6 +2177,23 @@ class er extends _ {
|
|
|
2156
2177
|
flushImmediatelySync() {
|
|
2157
2178
|
return this.flushEvents(!0);
|
|
2158
2179
|
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Sets the custom headers provider callback for the custom integration.
|
|
2182
|
+
* Only affects requests to custom backend (not TraceLog SaaS).
|
|
2183
|
+
*
|
|
2184
|
+
* @param provider - Callback function that returns custom headers
|
|
2185
|
+
*/
|
|
2186
|
+
setCustomHeadersProvider(e) {
|
|
2187
|
+
for (const t of this.dataSenders)
|
|
2188
|
+
t.getIntegrationId() === "custom" && t.setCustomHeadersProvider(e);
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Removes the custom headers provider callback from the custom integration.
|
|
2192
|
+
*/
|
|
2193
|
+
removeCustomHeadersProvider() {
|
|
2194
|
+
for (const e of this.dataSenders)
|
|
2195
|
+
e.getIntegrationId() === "custom" && e.removeCustomHeadersProvider();
|
|
2196
|
+
}
|
|
2159
2197
|
/**
|
|
2160
2198
|
* Returns the current number of events in the main queue.
|
|
2161
2199
|
*
|
|
@@ -2343,7 +2381,7 @@ class er extends _ {
|
|
|
2343
2381
|
};
|
|
2344
2382
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2345
2383
|
if (!o && l) {
|
|
2346
|
-
const c =
|
|
2384
|
+
const c = Ze(n, l, "EventManager");
|
|
2347
2385
|
c !== null && (n = c);
|
|
2348
2386
|
}
|
|
2349
2387
|
return n;
|
|
@@ -2355,7 +2393,7 @@ class er extends _ {
|
|
|
2355
2393
|
});
|
|
2356
2394
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2357
2395
|
let l = {
|
|
2358
|
-
id:
|
|
2396
|
+
id: $t(),
|
|
2359
2397
|
type: e.type,
|
|
2360
2398
|
page_url: t,
|
|
2361
2399
|
timestamp: r,
|
|
@@ -2372,10 +2410,10 @@ class er extends _ {
|
|
|
2372
2410
|
};
|
|
2373
2411
|
const c = this.get("collectApiUrls"), u = !!c?.custom, S = !!c?.saas, g = u || S, p = u && S, E = this.transformers.beforeSend;
|
|
2374
2412
|
if (E && (!g || u && !p)) {
|
|
2375
|
-
const
|
|
2376
|
-
if (
|
|
2413
|
+
const B = Je(l, E, "EventManager");
|
|
2414
|
+
if (B === null)
|
|
2377
2415
|
return null;
|
|
2378
|
-
l =
|
|
2416
|
+
l = B;
|
|
2379
2417
|
}
|
|
2380
2418
|
return l;
|
|
2381
2419
|
}
|
|
@@ -2458,10 +2496,10 @@ class er extends _ {
|
|
|
2458
2496
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2459
2497
|
}
|
|
2460
2498
|
emitEvent(e) {
|
|
2461
|
-
this.emitter && this.emitter.emit(
|
|
2499
|
+
this.emitter && this.emitter.emit(ae.EVENT, e);
|
|
2462
2500
|
}
|
|
2463
2501
|
emitEventsQueue(e) {
|
|
2464
|
-
this.emitter && this.emitter.emit(
|
|
2502
|
+
this.emitter && this.emitter.emit(ae.QUEUE, e);
|
|
2465
2503
|
}
|
|
2466
2504
|
/**
|
|
2467
2505
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2537,13 +2575,13 @@ class er extends _ {
|
|
|
2537
2575
|
loadSessionCounts(e) {
|
|
2538
2576
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2539
2577
|
return this.getInitialCounts();
|
|
2540
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2578
|
+
const t = this.get("userId") || "anonymous", r = Ae(t, e);
|
|
2541
2579
|
try {
|
|
2542
2580
|
const n = localStorage.getItem(r);
|
|
2543
2581
|
if (!n)
|
|
2544
2582
|
return this.getInitialCounts();
|
|
2545
2583
|
const i = JSON.parse(n);
|
|
2546
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2584
|
+
return i._timestamp && Date.now() - i._timestamp > Me ? (a("debug", "Session counts expired, clearing", {
|
|
2547
2585
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2548
2586
|
}), 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" ? {
|
|
2549
2587
|
total: i.total,
|
|
@@ -2588,12 +2626,12 @@ class er extends _ {
|
|
|
2588
2626
|
cleanupExpiredSessionCounts() {
|
|
2589
2627
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2590
2628
|
try {
|
|
2591
|
-
const e = localStorage.getItem(
|
|
2629
|
+
const e = localStorage.getItem(Ce);
|
|
2592
2630
|
if (e) {
|
|
2593
2631
|
const i = Date.now() - parseInt(e, 10);
|
|
2594
|
-
if (i <
|
|
2632
|
+
if (i < Re) {
|
|
2595
2633
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2596
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2634
|
+
data: { timeSinceLastCleanup: i, throttleMs: Re }
|
|
2597
2635
|
});
|
|
2598
2636
|
return;
|
|
2599
2637
|
}
|
|
@@ -2606,14 +2644,14 @@ class er extends _ {
|
|
|
2606
2644
|
const l = localStorage.getItem(o);
|
|
2607
2645
|
if (l) {
|
|
2608
2646
|
const c = JSON.parse(l);
|
|
2609
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2647
|
+
c._timestamp && Date.now() - c._timestamp > Me && n.push(o);
|
|
2610
2648
|
}
|
|
2611
2649
|
} catch {
|
|
2612
2650
|
}
|
|
2613
2651
|
}
|
|
2614
2652
|
n.forEach((i) => {
|
|
2615
2653
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2616
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2654
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Ce, Date.now().toString());
|
|
2617
2655
|
} catch (e) {
|
|
2618
2656
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2619
2657
|
}
|
|
@@ -2647,7 +2685,7 @@ class er extends _ {
|
|
|
2647
2685
|
* @internal
|
|
2648
2686
|
*/
|
|
2649
2687
|
saveSessionCounts(e) {
|
|
2650
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2688
|
+
const t = this.get("userId") || "anonymous", r = Ae(t, e);
|
|
2651
2689
|
try {
|
|
2652
2690
|
const n = {
|
|
2653
2691
|
...this.sessionEventCounts,
|
|
@@ -2663,7 +2701,7 @@ class er extends _ {
|
|
|
2663
2701
|
}
|
|
2664
2702
|
}
|
|
2665
2703
|
}
|
|
2666
|
-
class
|
|
2704
|
+
class rr {
|
|
2667
2705
|
/**
|
|
2668
2706
|
* Gets or creates a unique user ID.
|
|
2669
2707
|
*
|
|
@@ -2681,15 +2719,15 @@ class tr {
|
|
|
2681
2719
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2682
2720
|
*/
|
|
2683
2721
|
static getId(e) {
|
|
2684
|
-
const t = e.getItem(
|
|
2722
|
+
const t = e.getItem(ye);
|
|
2685
2723
|
if (t)
|
|
2686
2724
|
return t;
|
|
2687
|
-
const r =
|
|
2688
|
-
return e.setItem(
|
|
2725
|
+
const r = Ft();
|
|
2726
|
+
return e.setItem(ye, r), r;
|
|
2689
2727
|
}
|
|
2690
2728
|
}
|
|
2691
|
-
const
|
|
2692
|
-
class
|
|
2729
|
+
const sr = /^\d{13}-[a-z0-9]{9}$/;
|
|
2730
|
+
class nr extends _ {
|
|
2693
2731
|
storageManager;
|
|
2694
2732
|
eventManager;
|
|
2695
2733
|
projectId;
|
|
@@ -2715,7 +2753,7 @@ class sr extends _ {
|
|
|
2715
2753
|
return;
|
|
2716
2754
|
}
|
|
2717
2755
|
const e = this.getProjectId();
|
|
2718
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2756
|
+
this.broadcastChannel = new BroadcastChannel(ft(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2719
2757
|
const { action: r, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2720
2758
|
o === e && (r === "session_start" && n && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", n), this.persistSession(n, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2721
2759
|
};
|
|
@@ -2735,7 +2773,7 @@ class sr extends _ {
|
|
|
2735
2773
|
const e = this.loadStoredSession();
|
|
2736
2774
|
if (!e)
|
|
2737
2775
|
return null;
|
|
2738
|
-
if (!
|
|
2776
|
+
if (!sr.test(e.id))
|
|
2739
2777
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2740
2778
|
data: { sessionId: e.id }
|
|
2741
2779
|
}), this.clearStoredSession(), null;
|
|
@@ -2770,7 +2808,7 @@ class sr extends _ {
|
|
|
2770
2808
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2771
2809
|
}
|
|
2772
2810
|
getSessionStorageKey() {
|
|
2773
|
-
return
|
|
2811
|
+
return ht(this.getProjectId());
|
|
2774
2812
|
}
|
|
2775
2813
|
getProjectId() {
|
|
2776
2814
|
return this.projectId;
|
|
@@ -2835,9 +2873,9 @@ class sr extends _ {
|
|
|
2835
2873
|
let r, n;
|
|
2836
2874
|
if (e) {
|
|
2837
2875
|
const i = this.loadStoredSession();
|
|
2838
|
-
r = i?.referrer ??
|
|
2876
|
+
r = i?.referrer ?? re(), n = i?.utm ?? se();
|
|
2839
2877
|
} else
|
|
2840
|
-
r =
|
|
2878
|
+
r = re(), n = se();
|
|
2841
2879
|
a("debug", "Session tracking initialized", {
|
|
2842
2880
|
data: {
|
|
2843
2881
|
sessionId: t,
|
|
@@ -2888,7 +2926,7 @@ class sr extends _ {
|
|
|
2888
2926
|
*/
|
|
2889
2927
|
renewSession() {
|
|
2890
2928
|
this.needsRenewal = !1;
|
|
2891
|
-
const e = this.generateSessionId(), t =
|
|
2929
|
+
const e = this.generateSessionId(), t = re(), r = se();
|
|
2892
2930
|
a("debug", "Renewing session after timeout", {
|
|
2893
2931
|
data: { newSessionId: e }
|
|
2894
2932
|
}), 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({
|
|
@@ -3009,7 +3047,7 @@ class sr extends _ {
|
|
|
3009
3047
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
3010
3048
|
}
|
|
3011
3049
|
}
|
|
3012
|
-
class
|
|
3050
|
+
class ir extends _ {
|
|
3013
3051
|
eventManager;
|
|
3014
3052
|
storageManager;
|
|
3015
3053
|
sessionManager = null;
|
|
@@ -3044,7 +3082,7 @@ class nr extends _ {
|
|
|
3044
3082
|
}
|
|
3045
3083
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
3046
3084
|
try {
|
|
3047
|
-
this.sessionManager = new
|
|
3085
|
+
this.sessionManager = new nr(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
3048
3086
|
} catch (r) {
|
|
3049
3087
|
if (this.sessionManager) {
|
|
3050
3088
|
try {
|
|
@@ -3097,7 +3135,7 @@ class nr extends _ {
|
|
|
3097
3135
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
3098
3136
|
}
|
|
3099
3137
|
}
|
|
3100
|
-
class
|
|
3138
|
+
class or extends _ {
|
|
3101
3139
|
eventManager;
|
|
3102
3140
|
onTrack;
|
|
3103
3141
|
originalPushState;
|
|
@@ -3137,7 +3175,7 @@ class ir extends _ {
|
|
|
3137
3175
|
};
|
|
3138
3176
|
}
|
|
3139
3177
|
trackCurrentPage = () => {
|
|
3140
|
-
const e = window.location.href, t =
|
|
3178
|
+
const e = window.location.href, t = de(e, this.get("config").sensitiveQueryParams);
|
|
3141
3179
|
if (this.get("pageUrl") === t)
|
|
3142
3180
|
return;
|
|
3143
3181
|
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3155,7 +3193,7 @@ class ir extends _ {
|
|
|
3155
3193
|
});
|
|
3156
3194
|
};
|
|
3157
3195
|
trackInitialPageView() {
|
|
3158
|
-
const e =
|
|
3196
|
+
const e = de(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3159
3197
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3160
3198
|
type: d.PAGE_VIEW,
|
|
3161
3199
|
page_url: e,
|
|
@@ -3173,7 +3211,7 @@ class ir extends _ {
|
|
|
3173
3211
|
};
|
|
3174
3212
|
}
|
|
3175
3213
|
}
|
|
3176
|
-
class
|
|
3214
|
+
class ar extends _ {
|
|
3177
3215
|
eventManager;
|
|
3178
3216
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3179
3217
|
clickHandler;
|
|
@@ -3311,7 +3349,7 @@ class or extends _ {
|
|
|
3311
3349
|
return e.hasAttribute(`${w}-name`) ? e : e.closest(`[${w}-name]`);
|
|
3312
3350
|
}
|
|
3313
3351
|
getRelevantClickElement(e) {
|
|
3314
|
-
for (const t of
|
|
3352
|
+
for (const t of at)
|
|
3315
3353
|
try {
|
|
3316
3354
|
if (e.matches(t))
|
|
3317
3355
|
return e;
|
|
@@ -3391,7 +3429,7 @@ class or extends _ {
|
|
|
3391
3429
|
*/
|
|
3392
3430
|
sanitizeText(e) {
|
|
3393
3431
|
let t = e;
|
|
3394
|
-
for (const r of
|
|
3432
|
+
for (const r of je) {
|
|
3395
3433
|
const n = new RegExp(r.source, r.flags);
|
|
3396
3434
|
t = t.replace(n, "[REDACTED]");
|
|
3397
3435
|
}
|
|
@@ -3430,7 +3468,7 @@ class or extends _ {
|
|
|
3430
3468
|
};
|
|
3431
3469
|
}
|
|
3432
3470
|
}
|
|
3433
|
-
class
|
|
3471
|
+
class lr extends _ {
|
|
3434
3472
|
eventManager;
|
|
3435
3473
|
containers = [];
|
|
3436
3474
|
limitWarningLogged = !1;
|
|
@@ -3543,7 +3581,7 @@ class ar extends _ {
|
|
|
3543
3581
|
isPrimary: o,
|
|
3544
3582
|
lastScrollPos: n,
|
|
3545
3583
|
lastDepth: i,
|
|
3546
|
-
lastDirection:
|
|
3584
|
+
lastDirection: Q.DOWN,
|
|
3547
3585
|
lastEventTime: 0,
|
|
3548
3586
|
firstScrollEventTime: null,
|
|
3549
3587
|
maxDepthReached: i,
|
|
@@ -3602,7 +3640,7 @@ class ar extends _ {
|
|
|
3602
3640
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3603
3641
|
}
|
|
3604
3642
|
getScrollDirection(e, t) {
|
|
3605
|
-
return e > t ?
|
|
3643
|
+
return e > t ? Q.DOWN : Q.UP;
|
|
3606
3644
|
}
|
|
3607
3645
|
calculateScrollDepth(e, t, r) {
|
|
3608
3646
|
if (t <= r)
|
|
@@ -3658,7 +3696,7 @@ class ar extends _ {
|
|
|
3658
3696
|
e.isPrimary = t;
|
|
3659
3697
|
}
|
|
3660
3698
|
}
|
|
3661
|
-
class
|
|
3699
|
+
class cr extends _ {
|
|
3662
3700
|
eventManager;
|
|
3663
3701
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3664
3702
|
observer = null;
|
|
@@ -3819,7 +3857,7 @@ class lr extends _ {
|
|
|
3819
3857
|
});
|
|
3820
3858
|
}
|
|
3821
3859
|
}
|
|
3822
|
-
class
|
|
3860
|
+
class ur {
|
|
3823
3861
|
storage;
|
|
3824
3862
|
sessionStorageRef;
|
|
3825
3863
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -4102,7 +4140,7 @@ class cr {
|
|
|
4102
4140
|
this.fallbackSessionStorage.delete(e);
|
|
4103
4141
|
}
|
|
4104
4142
|
}
|
|
4105
|
-
class
|
|
4143
|
+
class dr extends _ {
|
|
4106
4144
|
eventManager;
|
|
4107
4145
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
4108
4146
|
navigationHistory = [];
|
|
@@ -4113,7 +4151,7 @@ class ur extends _ {
|
|
|
4113
4151
|
navigationCounter = 0;
|
|
4114
4152
|
// Counter for handling simultaneous navigations edge case
|
|
4115
4153
|
constructor(e) {
|
|
4116
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4154
|
+
super(), this.eventManager = e, this.vitalThresholds = Ve(ue);
|
|
4117
4155
|
}
|
|
4118
4156
|
/**
|
|
4119
4157
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4130,8 +4168,8 @@ class ur extends _ {
|
|
|
4130
4168
|
* @returns Promise that resolves when tracking is initialized
|
|
4131
4169
|
*/
|
|
4132
4170
|
async startTracking() {
|
|
4133
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4134
|
-
this.vitalThresholds =
|
|
4171
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ue;
|
|
4172
|
+
this.vitalThresholds = Ve(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4135
4173
|
}
|
|
4136
4174
|
/**
|
|
4137
4175
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4201,7 +4239,7 @@ class ur extends _ {
|
|
|
4201
4239
|
}
|
|
4202
4240
|
async initWebVitals() {
|
|
4203
4241
|
try {
|
|
4204
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4242
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => xr), o = (l) => (c) => {
|
|
4205
4243
|
const u = Number(c.value.toFixed(2));
|
|
4206
4244
|
this.sendVital({ type: l, value: u });
|
|
4207
4245
|
};
|
|
@@ -4228,7 +4266,7 @@ class ur extends _ {
|
|
|
4228
4266
|
const t = e.getEntries();
|
|
4229
4267
|
for (const r of t) {
|
|
4230
4268
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4231
|
-
i - this.lastLongTaskSentAt >=
|
|
4269
|
+
i - this.lastLongTaskSentAt >= Nt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4232
4270
|
}
|
|
4233
4271
|
},
|
|
4234
4272
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4244,7 +4282,7 @@ class ur extends _ {
|
|
|
4244
4282
|
return;
|
|
4245
4283
|
if (r)
|
|
4246
4284
|
r.add(e.type);
|
|
4247
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4285
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Ot) {
|
|
4248
4286
|
const i = this.navigationHistory.shift();
|
|
4249
4287
|
i && this.reportedByNav.delete(i);
|
|
4250
4288
|
}
|
|
@@ -4335,7 +4373,7 @@ class ur extends _ {
|
|
|
4335
4373
|
return !(typeof r == "number" && t <= r);
|
|
4336
4374
|
}
|
|
4337
4375
|
}
|
|
4338
|
-
class
|
|
4376
|
+
class hr extends _ {
|
|
4339
4377
|
eventManager;
|
|
4340
4378
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4341
4379
|
errorBurstCounter = 0;
|
|
@@ -4371,24 +4409,24 @@ class dr extends _ {
|
|
|
4371
4409
|
const e = Date.now();
|
|
4372
4410
|
if (e < this.burstBackoffUntil)
|
|
4373
4411
|
return !1;
|
|
4374
|
-
if (e - this.burstWindowStart > At && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter >
|
|
4375
|
-
return this.burstBackoffUntil = e +
|
|
4412
|
+
if (e - this.burstWindowStart > At && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Mt)
|
|
4413
|
+
return this.burstBackoffUntil = e + De, a("debug", "Error burst detected - entering cooldown", {
|
|
4376
4414
|
data: {
|
|
4377
4415
|
errorsInWindow: this.errorBurstCounter,
|
|
4378
|
-
cooldownMs:
|
|
4416
|
+
cooldownMs: De
|
|
4379
4417
|
}
|
|
4380
4418
|
}), !1;
|
|
4381
|
-
const r = this.get("config")?.errorSampling ??
|
|
4419
|
+
const r = this.get("config")?.errorSampling ?? ze;
|
|
4382
4420
|
return Math.random() < r;
|
|
4383
4421
|
}
|
|
4384
4422
|
handleError = (e) => {
|
|
4385
4423
|
if (!this.shouldSample())
|
|
4386
4424
|
return;
|
|
4387
4425
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4388
|
-
this.shouldSuppressError(
|
|
4426
|
+
this.shouldSuppressError(x.JS_ERROR, t) || this.eventManager.track({
|
|
4389
4427
|
type: d.ERROR,
|
|
4390
4428
|
error_data: {
|
|
4391
|
-
type:
|
|
4429
|
+
type: x.JS_ERROR,
|
|
4392
4430
|
message: t,
|
|
4393
4431
|
...e.filename && { filename: e.filename },
|
|
4394
4432
|
...e.lineno && { line: e.lineno },
|
|
@@ -4400,10 +4438,10 @@ class dr extends _ {
|
|
|
4400
4438
|
if (!this.shouldSample())
|
|
4401
4439
|
return;
|
|
4402
4440
|
const t = this.extractRejectionMessage(e.reason), r = this.sanitize(t);
|
|
4403
|
-
this.shouldSuppressError(
|
|
4441
|
+
this.shouldSuppressError(x.PROMISE_REJECTION, r) || this.eventManager.track({
|
|
4404
4442
|
type: d.ERROR,
|
|
4405
4443
|
error_data: {
|
|
4406
|
-
type:
|
|
4444
|
+
type: x.PROMISE_REJECTION,
|
|
4407
4445
|
message: r
|
|
4408
4446
|
}
|
|
4409
4447
|
});
|
|
@@ -4422,8 +4460,8 @@ class dr extends _ {
|
|
|
4422
4460
|
}
|
|
4423
4461
|
}
|
|
4424
4462
|
sanitize(e) {
|
|
4425
|
-
let t = e.length >
|
|
4426
|
-
for (const r of
|
|
4463
|
+
let t = e.length > Oe ? e.slice(0, Oe) + "..." : e;
|
|
4464
|
+
for (const r of je) {
|
|
4427
4465
|
const n = new RegExp(r.source, r.flags);
|
|
4428
4466
|
t = t.replace(n, "[REDACTED]");
|
|
4429
4467
|
}
|
|
@@ -4431,26 +4469,27 @@ class dr extends _ {
|
|
|
4431
4469
|
}
|
|
4432
4470
|
shouldSuppressError(e, t) {
|
|
4433
4471
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4434
|
-
return i && r - i <
|
|
4472
|
+
return i && r - i < Pe ? (this.recentErrors.set(n, r), !0) : (this.recentErrors.set(n, r), this.recentErrors.size > Lt ? (this.recentErrors.clear(), this.recentErrors.set(n, r), !1) : (this.recentErrors.size > j && this.pruneOldErrors(), !1));
|
|
4435
4473
|
}
|
|
4436
4474
|
pruneOldErrors() {
|
|
4437
4475
|
const e = Date.now();
|
|
4438
4476
|
for (const [n, i] of this.recentErrors.entries())
|
|
4439
|
-
e - i >
|
|
4440
|
-
if (this.recentErrors.size <=
|
|
4477
|
+
e - i > Pe && this.recentErrors.delete(n);
|
|
4478
|
+
if (this.recentErrors.size <= j)
|
|
4441
4479
|
return;
|
|
4442
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size -
|
|
4480
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - j;
|
|
4443
4481
|
for (let n = 0; n < r; n += 1) {
|
|
4444
4482
|
const i = t[n];
|
|
4445
4483
|
i && this.recentErrors.delete(i[0]);
|
|
4446
4484
|
}
|
|
4447
4485
|
}
|
|
4448
4486
|
}
|
|
4449
|
-
class
|
|
4487
|
+
class fr extends _ {
|
|
4450
4488
|
isInitialized = !1;
|
|
4451
4489
|
suppressNextScrollTimer = null;
|
|
4452
|
-
emitter = new
|
|
4490
|
+
emitter = new Jt();
|
|
4453
4491
|
transformers = {};
|
|
4492
|
+
customHeadersProvider;
|
|
4454
4493
|
managers = {};
|
|
4455
4494
|
handlers = {};
|
|
4456
4495
|
get initialized() {
|
|
@@ -4465,10 +4504,18 @@ class hr extends _ {
|
|
|
4465
4504
|
*/
|
|
4466
4505
|
async init(e = {}) {
|
|
4467
4506
|
if (!this.isInitialized) {
|
|
4468
|
-
this.managers.storage = new
|
|
4507
|
+
this.managers.storage = new ur();
|
|
4469
4508
|
try {
|
|
4470
|
-
this.setupState(e)
|
|
4471
|
-
|
|
4509
|
+
this.setupState(e);
|
|
4510
|
+
const t = e.integrations?.custom?.headers ?? {};
|
|
4511
|
+
this.managers.event = new tr(
|
|
4512
|
+
this.managers.storage,
|
|
4513
|
+
this.emitter,
|
|
4514
|
+
this.transformers,
|
|
4515
|
+
t,
|
|
4516
|
+
this.customHeadersProvider
|
|
4517
|
+
), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((r) => {
|
|
4518
|
+
a("warn", "Failed to recover persisted events", { error: r });
|
|
4472
4519
|
}), this.isInitialized = !0;
|
|
4473
4520
|
} catch (t) {
|
|
4474
4521
|
this.destroy(!0);
|
|
@@ -4491,9 +4538,9 @@ class hr extends _ {
|
|
|
4491
4538
|
}
|
|
4492
4539
|
let r = t;
|
|
4493
4540
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4494
|
-
const { valid: n, error: i, sanitizedMetadata: o } =
|
|
4541
|
+
const { valid: n, error: i, sanitizedMetadata: o } = qt(e, r);
|
|
4495
4542
|
if (!n) {
|
|
4496
|
-
if (this.get("mode") ===
|
|
4543
|
+
if (this.get("mode") === K.QA)
|
|
4497
4544
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4498
4545
|
return;
|
|
4499
4546
|
}
|
|
@@ -4522,6 +4569,27 @@ class hr extends _ {
|
|
|
4522
4569
|
getTransformer(e) {
|
|
4523
4570
|
return this.transformers[e];
|
|
4524
4571
|
}
|
|
4572
|
+
/**
|
|
4573
|
+
* Sets a callback to provide custom HTTP headers for requests to custom backends.
|
|
4574
|
+
* Only applies to custom backend integration (not TraceLog SaaS).
|
|
4575
|
+
*
|
|
4576
|
+
* @param provider - Callback function that returns custom headers
|
|
4577
|
+
* @throws {Error} If provider is not a function
|
|
4578
|
+
* @internal Called from api.setCustomHeaders()
|
|
4579
|
+
*/
|
|
4580
|
+
setCustomHeaders(e) {
|
|
4581
|
+
if (typeof e != "function")
|
|
4582
|
+
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof e}`);
|
|
4583
|
+
this.customHeadersProvider = e, this.managers.event && this.managers.event.setCustomHeadersProvider(e);
|
|
4584
|
+
}
|
|
4585
|
+
/**
|
|
4586
|
+
* Removes the custom headers provider callback.
|
|
4587
|
+
*
|
|
4588
|
+
* @internal Called from api.removeCustomHeaders()
|
|
4589
|
+
*/
|
|
4590
|
+
removeCustomHeaders() {
|
|
4591
|
+
this.customHeadersProvider = void 0, this.managers.event && this.managers.event.removeCustomHeadersProvider();
|
|
4592
|
+
}
|
|
4525
4593
|
/**
|
|
4526
4594
|
* Destroys the TraceLog instance and cleans up all resources.
|
|
4527
4595
|
*
|
|
@@ -4535,18 +4603,18 @@ class hr extends _ {
|
|
|
4535
4603
|
} catch (r) {
|
|
4536
4604
|
a("warn", "Failed to stop tracking", { error: r });
|
|
4537
4605
|
}
|
|
4538
|
-
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.transformers.beforeSend = void 0, this.transformers.beforeBatch = void 0, this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
4606
|
+
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.transformers.beforeSend = void 0, this.transformers.beforeBatch = void 0, this.customHeadersProvider = void 0, this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
4539
4607
|
}
|
|
4540
4608
|
setupState(e = {}) {
|
|
4541
4609
|
this.set("config", e);
|
|
4542
|
-
const t =
|
|
4610
|
+
const t = rr.getId(this.managers.storage);
|
|
4543
4611
|
this.set("userId", t);
|
|
4544
|
-
const r =
|
|
4612
|
+
const r = Wt(e);
|
|
4545
4613
|
this.set("collectApiUrls", r);
|
|
4546
|
-
const n =
|
|
4614
|
+
const n = bt();
|
|
4547
4615
|
this.set("device", n);
|
|
4548
|
-
const i =
|
|
4549
|
-
this.set("pageUrl", i),
|
|
4616
|
+
const i = de(window.location.href, e.sensitiveQueryParams);
|
|
4617
|
+
this.set("pageUrl", i), Vt() && this.set("mode", K.QA);
|
|
4550
4618
|
}
|
|
4551
4619
|
/**
|
|
4552
4620
|
* Returns the current configuration object.
|
|
@@ -4588,7 +4656,7 @@ class hr extends _ {
|
|
|
4588
4656
|
valid: !1,
|
|
4589
4657
|
error: "Global metadata must be a plain object"
|
|
4590
4658
|
};
|
|
4591
|
-
const t =
|
|
4659
|
+
const t = qe("Global", e, "globalMetadata");
|
|
4592
4660
|
return t.valid ? { valid: !0 } : {
|
|
4593
4661
|
valid: !1,
|
|
4594
4662
|
error: t.error
|
|
@@ -4633,7 +4701,7 @@ class hr extends _ {
|
|
|
4633
4701
|
}
|
|
4634
4702
|
initializeHandlers() {
|
|
4635
4703
|
const e = this.get("config");
|
|
4636
|
-
this.handlers.session = new
|
|
4704
|
+
this.handlers.session = new ir(
|
|
4637
4705
|
this.managers.storage,
|
|
4638
4706
|
this.managers.event
|
|
4639
4707
|
), this.handlers.session.startTracking();
|
|
@@ -4642,30 +4710,30 @@ class hr extends _ {
|
|
|
4642
4710
|
this.set("suppressNextScroll", !1);
|
|
4643
4711
|
}, 500);
|
|
4644
4712
|
};
|
|
4645
|
-
this.handlers.pageView = new
|
|
4713
|
+
this.handlers.pageView = new or(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new ar(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new lr(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new dr(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4646
4714
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4647
|
-
}), this.handlers.error = new
|
|
4715
|
+
}), this.handlers.error = new hr(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new cr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4648
4716
|
}
|
|
4649
4717
|
}
|
|
4650
|
-
const
|
|
4651
|
-
let
|
|
4652
|
-
const
|
|
4653
|
-
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !
|
|
4654
|
-
|
|
4718
|
+
const N = [], M = [];
|
|
4719
|
+
let R = null, h = null, C = !1, v = !1;
|
|
4720
|
+
const mr = async (s) => {
|
|
4721
|
+
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !h && !C)) {
|
|
4722
|
+
C = !0;
|
|
4655
4723
|
try {
|
|
4656
|
-
const e =
|
|
4724
|
+
const e = zt(s ?? {}), t = new fr();
|
|
4657
4725
|
try {
|
|
4658
|
-
|
|
4726
|
+
N.forEach(({ event: i, callback: o }) => {
|
|
4659
4727
|
t.on(i, o);
|
|
4660
|
-
}),
|
|
4728
|
+
}), N.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4661
4729
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4662
|
-
}), M.length = 0;
|
|
4730
|
+
}), M.length = 0, R && (t.setCustomHeaders(R), R = null);
|
|
4663
4731
|
const r = t.init(e), n = new Promise((i, o) => {
|
|
4664
4732
|
setTimeout(() => {
|
|
4665
4733
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4666
4734
|
}, 1e4);
|
|
4667
4735
|
});
|
|
4668
|
-
await Promise.race([r, n]),
|
|
4736
|
+
await Promise.race([r, n]), h = t;
|
|
4669
4737
|
} catch (r) {
|
|
4670
4738
|
try {
|
|
4671
4739
|
t.destroy(!0);
|
|
@@ -4675,122 +4743,146 @@ const fr = async (s) => {
|
|
|
4675
4743
|
throw r;
|
|
4676
4744
|
}
|
|
4677
4745
|
} catch (e) {
|
|
4678
|
-
throw
|
|
4746
|
+
throw h = null, e;
|
|
4679
4747
|
} finally {
|
|
4680
|
-
|
|
4748
|
+
C = !1;
|
|
4681
4749
|
}
|
|
4682
4750
|
}
|
|
4683
|
-
},
|
|
4751
|
+
}, gr = (s, e) => {
|
|
4684
4752
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4685
|
-
if (!
|
|
4753
|
+
if (!h)
|
|
4686
4754
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4687
4755
|
if (v)
|
|
4688
4756
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4689
|
-
|
|
4757
|
+
h.sendCustomEvent(s, e);
|
|
4690
4758
|
}
|
|
4691
|
-
},
|
|
4759
|
+
}, Er = (s, e) => {
|
|
4692
4760
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4693
|
-
if (!
|
|
4694
|
-
|
|
4761
|
+
if (!h || C) {
|
|
4762
|
+
N.push({ event: s, callback: e });
|
|
4695
4763
|
return;
|
|
4696
4764
|
}
|
|
4697
|
-
|
|
4765
|
+
h.on(s, e);
|
|
4698
4766
|
}
|
|
4699
|
-
},
|
|
4767
|
+
}, Sr = (s, e) => {
|
|
4700
4768
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4701
|
-
if (!
|
|
4702
|
-
const t =
|
|
4703
|
-
t !== -1 &&
|
|
4769
|
+
if (!h) {
|
|
4770
|
+
const t = N.findIndex((r) => r.event === s && r.callback === e);
|
|
4771
|
+
t !== -1 && N.splice(t, 1);
|
|
4704
4772
|
return;
|
|
4705
4773
|
}
|
|
4706
|
-
|
|
4774
|
+
h.off(s, e);
|
|
4707
4775
|
}
|
|
4708
4776
|
};
|
|
4709
|
-
function
|
|
4777
|
+
function pr(s, e) {
|
|
4710
4778
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4711
4779
|
if (typeof e != "function")
|
|
4712
4780
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4713
|
-
if (!
|
|
4781
|
+
if (!h || C) {
|
|
4714
4782
|
const t = M.findIndex((r) => r.hook === s);
|
|
4715
4783
|
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4716
4784
|
return;
|
|
4717
4785
|
}
|
|
4718
4786
|
if (v)
|
|
4719
4787
|
throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
|
|
4720
|
-
s === "beforeSend" ?
|
|
4788
|
+
s === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
|
|
4721
4789
|
}
|
|
4722
4790
|
}
|
|
4723
|
-
const
|
|
4791
|
+
const Tr = (s) => {
|
|
4724
4792
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4725
|
-
if (!
|
|
4793
|
+
if (!h) {
|
|
4726
4794
|
const e = M.findIndex((t) => t.hook === s);
|
|
4727
4795
|
e !== -1 && M.splice(e, 1);
|
|
4728
4796
|
return;
|
|
4729
4797
|
}
|
|
4730
4798
|
if (v)
|
|
4731
4799
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4732
|
-
|
|
4800
|
+
h.removeTransformer(s);
|
|
4801
|
+
}
|
|
4802
|
+
}, vr = (s) => {
|
|
4803
|
+
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4804
|
+
if (typeof s != "function")
|
|
4805
|
+
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof s}`);
|
|
4806
|
+
if (!h || C) {
|
|
4807
|
+
R = s;
|
|
4808
|
+
return;
|
|
4809
|
+
}
|
|
4810
|
+
if (v)
|
|
4811
|
+
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
4812
|
+
h.setCustomHeaders(s);
|
|
4733
4813
|
}
|
|
4734
|
-
},
|
|
4814
|
+
}, _r = () => {
|
|
4815
|
+
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4816
|
+
if (!h) {
|
|
4817
|
+
R = null;
|
|
4818
|
+
return;
|
|
4819
|
+
}
|
|
4820
|
+
if (v)
|
|
4821
|
+
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
4822
|
+
h.removeCustomHeaders();
|
|
4823
|
+
}
|
|
4824
|
+
}, Ir = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, wr = () => {
|
|
4735
4825
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4736
4826
|
if (v)
|
|
4737
4827
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
4738
|
-
if (!
|
|
4828
|
+
if (!h) {
|
|
4739
4829
|
v = !1;
|
|
4740
4830
|
return;
|
|
4741
4831
|
}
|
|
4742
4832
|
v = !0;
|
|
4743
4833
|
try {
|
|
4744
|
-
|
|
4834
|
+
h.destroy(), h = null, C = !1, N.length = 0, M.length = 0, R = null, v = !1;
|
|
4745
4835
|
} catch (s) {
|
|
4746
|
-
|
|
4836
|
+
h = null, C = !1, N.length = 0, M.length = 0, R = null, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4747
4837
|
}
|
|
4748
4838
|
}
|
|
4749
|
-
},
|
|
4750
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4751
|
-
},
|
|
4839
|
+
}, yr = (s) => {
|
|
4840
|
+
typeof window > "u" || typeof document > "u" || Ut(s);
|
|
4841
|
+
}, br = (s) => {
|
|
4752
4842
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4753
|
-
if (!
|
|
4843
|
+
if (!h)
|
|
4754
4844
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4755
4845
|
if (v)
|
|
4756
4846
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4757
|
-
|
|
4847
|
+
h.updateGlobalMetadata(s);
|
|
4758
4848
|
}
|
|
4759
|
-
},
|
|
4849
|
+
}, Lr = (s) => {
|
|
4760
4850
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4761
|
-
if (!
|
|
4851
|
+
if (!h)
|
|
4762
4852
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
4763
4853
|
if (v)
|
|
4764
4854
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4765
|
-
|
|
4766
|
-
}
|
|
4767
|
-
},
|
|
4768
|
-
init:
|
|
4769
|
-
event:
|
|
4770
|
-
on:
|
|
4771
|
-
off:
|
|
4772
|
-
setTransformer:
|
|
4773
|
-
removeTransformer:
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4855
|
+
h.mergeGlobalMetadata(s);
|
|
4856
|
+
}
|
|
4857
|
+
}, Jr = {
|
|
4858
|
+
init: mr,
|
|
4859
|
+
event: gr,
|
|
4860
|
+
on: Er,
|
|
4861
|
+
off: Sr,
|
|
4862
|
+
setTransformer: pr,
|
|
4863
|
+
removeTransformer: Tr,
|
|
4864
|
+
setCustomHeaders: vr,
|
|
4865
|
+
removeCustomHeaders: _r,
|
|
4866
|
+
isInitialized: Ir,
|
|
4867
|
+
destroy: wr,
|
|
4868
|
+
setQaMode: yr,
|
|
4869
|
+
updateGlobalMetadata: br,
|
|
4870
|
+
mergeGlobalMetadata: Lr
|
|
4779
4871
|
};
|
|
4780
|
-
var
|
|
4872
|
+
var me, et = -1, D = function(s) {
|
|
4781
4873
|
addEventListener("pageshow", (function(e) {
|
|
4782
|
-
e.persisted && (
|
|
4874
|
+
e.persisted && (et = e.timeStamp, s(e));
|
|
4783
4875
|
}), !0);
|
|
4784
|
-
},
|
|
4876
|
+
}, ve = function() {
|
|
4785
4877
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4786
4878
|
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4787
|
-
},
|
|
4788
|
-
var s =
|
|
4879
|
+
}, J = function() {
|
|
4880
|
+
var s = ve();
|
|
4789
4881
|
return s && s.activationStart || 0;
|
|
4790
4882
|
}, b = function(s, e) {
|
|
4791
|
-
var t =
|
|
4792
|
-
return
|
|
4793
|
-
},
|
|
4883
|
+
var t = ve(), r = "navigate";
|
|
4884
|
+
return et >= 0 ? r = "back-forward-cache" : t && (document.prerendering || J() > 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 };
|
|
4885
|
+
}, $ = function(s, e, t) {
|
|
4794
4886
|
try {
|
|
4795
4887
|
if (PerformanceObserver.supportedEntryTypes.includes(s)) {
|
|
4796
4888
|
var r = new PerformanceObserver((function(n) {
|
|
@@ -4802,63 +4894,63 @@ var he, Ze = -1, P = function(s) {
|
|
|
4802
4894
|
}
|
|
4803
4895
|
} catch {
|
|
4804
4896
|
}
|
|
4805
|
-
},
|
|
4897
|
+
}, L = function(s, e, t, r) {
|
|
4806
4898
|
var n, i;
|
|
4807
4899
|
return function(o) {
|
|
4808
4900
|
e.value >= 0 && (o || r) && ((i = e.value - (n || 0)) || n === void 0) && (n = e.value, e.delta = i, e.rating = (function(l, c) {
|
|
4809
4901
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4810
4902
|
})(e.value, t), s(e));
|
|
4811
4903
|
};
|
|
4812
|
-
},
|
|
4904
|
+
}, _e = function(s) {
|
|
4813
4905
|
requestAnimationFrame((function() {
|
|
4814
4906
|
return requestAnimationFrame((function() {
|
|
4815
4907
|
return s();
|
|
4816
4908
|
}));
|
|
4817
4909
|
}));
|
|
4818
|
-
},
|
|
4910
|
+
}, Z = function(s) {
|
|
4819
4911
|
document.addEventListener("visibilitychange", (function() {
|
|
4820
4912
|
document.visibilityState === "hidden" && s();
|
|
4821
4913
|
}));
|
|
4822
|
-
},
|
|
4914
|
+
}, Ie = function(s) {
|
|
4823
4915
|
var e = !1;
|
|
4824
4916
|
return function() {
|
|
4825
4917
|
e || (s(), e = !0);
|
|
4826
4918
|
};
|
|
4827
|
-
},
|
|
4919
|
+
}, P = -1, $e = function() {
|
|
4828
4920
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4829
|
-
},
|
|
4830
|
-
document.visibilityState === "hidden" &&
|
|
4831
|
-
},
|
|
4832
|
-
addEventListener("visibilitychange",
|
|
4833
|
-
},
|
|
4834
|
-
removeEventListener("visibilitychange",
|
|
4835
|
-
},
|
|
4836
|
-
return
|
|
4921
|
+
}, q = function(s) {
|
|
4922
|
+
document.visibilityState === "hidden" && P > -1 && (P = s.type === "visibilitychange" ? s.timeStamp : 0, Ar());
|
|
4923
|
+
}, Be = function() {
|
|
4924
|
+
addEventListener("visibilitychange", q, !0), addEventListener("prerenderingchange", q, !0);
|
|
4925
|
+
}, Ar = function() {
|
|
4926
|
+
removeEventListener("visibilitychange", q, !0), removeEventListener("prerenderingchange", q, !0);
|
|
4927
|
+
}, tt = function() {
|
|
4928
|
+
return P < 0 && (P = $e(), Be(), D((function() {
|
|
4837
4929
|
setTimeout((function() {
|
|
4838
|
-
|
|
4930
|
+
P = $e(), Be();
|
|
4839
4931
|
}), 0);
|
|
4840
4932
|
}))), { get firstHiddenTime() {
|
|
4841
|
-
return
|
|
4933
|
+
return P;
|
|
4842
4934
|
} };
|
|
4843
|
-
},
|
|
4935
|
+
}, ee = function(s) {
|
|
4844
4936
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4845
4937
|
return s();
|
|
4846
4938
|
}), !0) : s();
|
|
4847
|
-
},
|
|
4848
|
-
e = e || {},
|
|
4849
|
-
var t, r =
|
|
4939
|
+
}, ge = [1800, 3e3], rt = function(s, e) {
|
|
4940
|
+
e = e || {}, ee((function() {
|
|
4941
|
+
var t, r = tt(), n = b("FCP"), i = $("paint", (function(o) {
|
|
4850
4942
|
o.forEach((function(l) {
|
|
4851
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime -
|
|
4943
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime - J(), 0), n.entries.push(l), t(!0)));
|
|
4852
4944
|
}));
|
|
4853
4945
|
}));
|
|
4854
|
-
i && (t =
|
|
4855
|
-
n = b("FCP"), t =
|
|
4946
|
+
i && (t = L(s, n, ge, e.reportAllChanges), D((function(o) {
|
|
4947
|
+
n = b("FCP"), t = L(s, n, ge, e.reportAllChanges), _e((function() {
|
|
4856
4948
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4857
4949
|
}));
|
|
4858
4950
|
})));
|
|
4859
4951
|
}));
|
|
4860
|
-
},
|
|
4861
|
-
e = e || {},
|
|
4952
|
+
}, Ee = [0.1, 0.25], Mr = function(s, e) {
|
|
4953
|
+
e = e || {}, rt(Ie((function() {
|
|
4862
4954
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4863
4955
|
c.forEach((function(u) {
|
|
4864
4956
|
if (!u.hadRecentInput) {
|
|
@@ -4866,148 +4958,147 @@ var he, Ze = -1, P = function(s) {
|
|
|
4866
4958
|
n && u.startTime - g.startTime < 1e3 && u.startTime - S.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
4867
4959
|
}
|
|
4868
4960
|
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4869
|
-
}, l =
|
|
4870
|
-
l && (t =
|
|
4961
|
+
}, l = $("layout-shift", o);
|
|
4962
|
+
l && (t = L(s, r, Ee, e.reportAllChanges), Z((function() {
|
|
4871
4963
|
o(l.takeRecords()), t(!0);
|
|
4872
|
-
})),
|
|
4873
|
-
n = 0, r = b("CLS", 0), t =
|
|
4964
|
+
})), D((function() {
|
|
4965
|
+
n = 0, r = b("CLS", 0), t = L(s, r, Ee, e.reportAllChanges), _e((function() {
|
|
4874
4966
|
return t();
|
|
4875
4967
|
}));
|
|
4876
4968
|
})), setTimeout(t, 0));
|
|
4877
4969
|
})));
|
|
4878
|
-
},
|
|
4970
|
+
}, st = 0, ie = 1 / 0, X = 0, Cr = function(s) {
|
|
4879
4971
|
s.forEach((function(e) {
|
|
4880
|
-
e.interactionId && (
|
|
4972
|
+
e.interactionId && (ie = Math.min(ie, e.interactionId), X = Math.max(X, e.interactionId), st = X ? (X - ie) / 7 + 1 : 0);
|
|
4881
4973
|
}));
|
|
4882
|
-
},
|
|
4883
|
-
return
|
|
4884
|
-
},
|
|
4885
|
-
"interactionCount" in performance ||
|
|
4886
|
-
}, y = [],
|
|
4887
|
-
var s = Math.min(y.length - 1, Math.floor((
|
|
4974
|
+
}, nt = function() {
|
|
4975
|
+
return me ? st : performance.interactionCount || 0;
|
|
4976
|
+
}, Rr = function() {
|
|
4977
|
+
"interactionCount" in performance || me || (me = $("event", Cr, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4978
|
+
}, y = [], z = /* @__PURE__ */ new Map(), it = 0, Nr = function() {
|
|
4979
|
+
var s = Math.min(y.length - 1, Math.floor((nt() - it) / 50));
|
|
4888
4980
|
return y[s];
|
|
4889
|
-
},
|
|
4890
|
-
if (
|
|
4981
|
+
}, Or = [], Pr = function(s) {
|
|
4982
|
+
if (Or.forEach((function(n) {
|
|
4891
4983
|
return n(s);
|
|
4892
4984
|
})), s.interactionId || s.entryType === "first-input") {
|
|
4893
|
-
var e = y[y.length - 1], t =
|
|
4985
|
+
var e = y[y.length - 1], t = z.get(s.interactionId);
|
|
4894
4986
|
if (t || y.length < 10 || s.duration > e.latency) {
|
|
4895
4987
|
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);
|
|
4896
4988
|
else {
|
|
4897
4989
|
var r = { id: s.interactionId, latency: s.duration, entries: [s] };
|
|
4898
|
-
|
|
4990
|
+
z.set(r.id, r), y.push(r);
|
|
4899
4991
|
}
|
|
4900
4992
|
y.sort((function(n, i) {
|
|
4901
4993
|
return i.latency - n.latency;
|
|
4902
4994
|
})), y.length > 10 && y.splice(10).forEach((function(n) {
|
|
4903
|
-
return
|
|
4995
|
+
return z.delete(n.id);
|
|
4904
4996
|
}));
|
|
4905
4997
|
}
|
|
4906
4998
|
}
|
|
4907
|
-
},
|
|
4999
|
+
}, ot = function(s) {
|
|
4908
5000
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4909
|
-
return s =
|
|
4910
|
-
},
|
|
4911
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
5001
|
+
return s = Ie(s), document.visibilityState === "hidden" ? s() : (t = e(s), Z(s)), t;
|
|
5002
|
+
}, Se = [200, 500], Dr = function(s, e) {
|
|
5003
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, ee((function() {
|
|
4912
5004
|
var t;
|
|
4913
|
-
|
|
5005
|
+
Rr();
|
|
4914
5006
|
var r, n = b("INP"), i = function(l) {
|
|
4915
|
-
|
|
4916
|
-
l.forEach(
|
|
4917
|
-
var c =
|
|
5007
|
+
ot((function() {
|
|
5008
|
+
l.forEach(Pr);
|
|
5009
|
+
var c = Nr();
|
|
4918
5010
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
4919
5011
|
}));
|
|
4920
|
-
}, o =
|
|
4921
|
-
r =
|
|
5012
|
+
}, o = $("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5013
|
+
r = L(s, n, Se, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), Z((function() {
|
|
4922
5014
|
i(o.takeRecords()), r(!0);
|
|
4923
|
-
})),
|
|
4924
|
-
|
|
5015
|
+
})), D((function() {
|
|
5016
|
+
it = nt(), y.length = 0, z.clear(), n = b("INP"), r = L(s, n, Se, e.reportAllChanges);
|
|
4925
5017
|
})));
|
|
4926
5018
|
})));
|
|
4927
|
-
},
|
|
4928
|
-
e = e || {},
|
|
4929
|
-
var t, r =
|
|
5019
|
+
}, pe = [2500, 4e3], oe = {}, kr = function(s, e) {
|
|
5020
|
+
e = e || {}, ee((function() {
|
|
5021
|
+
var t, r = tt(), n = b("LCP"), i = function(c) {
|
|
4930
5022
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
4931
|
-
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime -
|
|
5023
|
+
u.startTime < r.firstHiddenTime && (n.value = Math.max(u.startTime - J(), 0), n.entries = [u], t());
|
|
4932
5024
|
}));
|
|
4933
|
-
}, o =
|
|
5025
|
+
}, o = $("largest-contentful-paint", i);
|
|
4934
5026
|
if (o) {
|
|
4935
|
-
t =
|
|
4936
|
-
var l =
|
|
4937
|
-
|
|
5027
|
+
t = L(s, n, pe, e.reportAllChanges);
|
|
5028
|
+
var l = Ie((function() {
|
|
5029
|
+
oe[n.id] || (i(o.takeRecords()), o.disconnect(), oe[n.id] = !0, t(!0));
|
|
4938
5030
|
}));
|
|
4939
5031
|
["keydown", "click"].forEach((function(c) {
|
|
4940
5032
|
addEventListener(c, (function() {
|
|
4941
|
-
return
|
|
5033
|
+
return ot(l);
|
|
4942
5034
|
}), { once: !0, capture: !0 });
|
|
4943
|
-
})),
|
|
4944
|
-
n = b("LCP"), t =
|
|
4945
|
-
n.value = performance.now() - c.timeStamp,
|
|
5035
|
+
})), Z(l), D((function(c) {
|
|
5036
|
+
n = b("LCP"), t = L(s, n, pe, e.reportAllChanges), _e((function() {
|
|
5037
|
+
n.value = performance.now() - c.timeStamp, oe[n.id] = !0, t(!0);
|
|
4946
5038
|
}));
|
|
4947
5039
|
}));
|
|
4948
5040
|
}
|
|
4949
5041
|
}));
|
|
4950
|
-
},
|
|
4951
|
-
document.prerendering ?
|
|
5042
|
+
}, Te = [800, 1800], Vr = function s(e) {
|
|
5043
|
+
document.prerendering ? ee((function() {
|
|
4952
5044
|
return s(e);
|
|
4953
5045
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4954
5046
|
return s(e);
|
|
4955
5047
|
}), !0) : setTimeout(e, 0);
|
|
4956
|
-
},
|
|
5048
|
+
}, Ur = function(s, e) {
|
|
4957
5049
|
e = e || {};
|
|
4958
|
-
var t = b("TTFB"), r =
|
|
4959
|
-
|
|
4960
|
-
var n =
|
|
4961
|
-
n && (t.value = Math.max(n.responseStart -
|
|
4962
|
-
t = b("TTFB", 0), (r =
|
|
5050
|
+
var t = b("TTFB"), r = L(s, t, Te, e.reportAllChanges);
|
|
5051
|
+
Vr((function() {
|
|
5052
|
+
var n = ve();
|
|
5053
|
+
n && (t.value = Math.max(n.responseStart - J(), 0), t.entries = [n], r(!0), D((function() {
|
|
5054
|
+
t = b("TTFB", 0), (r = L(s, t, Te, e.reportAllChanges))(!0);
|
|
4963
5055
|
})));
|
|
4964
5056
|
}));
|
|
4965
5057
|
};
|
|
4966
|
-
const
|
|
5058
|
+
const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4967
5059
|
__proto__: null,
|
|
4968
|
-
CLSThresholds:
|
|
4969
|
-
FCPThresholds:
|
|
4970
|
-
INPThresholds:
|
|
4971
|
-
LCPThresholds:
|
|
4972
|
-
TTFBThresholds:
|
|
4973
|
-
onCLS:
|
|
4974
|
-
onFCP:
|
|
4975
|
-
onINP:
|
|
4976
|
-
onLCP:
|
|
4977
|
-
onTTFB:
|
|
5060
|
+
CLSThresholds: Ee,
|
|
5061
|
+
FCPThresholds: ge,
|
|
5062
|
+
INPThresholds: Se,
|
|
5063
|
+
LCPThresholds: pe,
|
|
5064
|
+
TTFBThresholds: Te,
|
|
5065
|
+
onCLS: Mr,
|
|
5066
|
+
onFCP: rt,
|
|
5067
|
+
onINP: Dr,
|
|
5068
|
+
onLCP: kr,
|
|
5069
|
+
onTTFB: Ur
|
|
4978
5070
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4979
5071
|
export {
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
5072
|
+
f as AppConfigValidationError,
|
|
5073
|
+
Hr as DEFAULT_SESSION_TIMEOUT,
|
|
5074
|
+
ue as DEFAULT_WEB_VITALS_MODE,
|
|
5075
|
+
A as DeviceType,
|
|
5076
|
+
ae as EmitterEvent,
|
|
5077
|
+
x as ErrorType,
|
|
4986
5078
|
d as EventType,
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
Pe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5079
|
+
Yr as InitializationTimeoutError,
|
|
5080
|
+
V as IntegrationValidationError,
|
|
5081
|
+
jr as MAX_ARRAY_LENGTH,
|
|
5082
|
+
Wr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5083
|
+
Br as MAX_CUSTOM_EVENT_KEYS,
|
|
5084
|
+
Fr as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5085
|
+
$r as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5086
|
+
Gr as MAX_NESTED_OBJECT_KEYS,
|
|
5087
|
+
Xr as MAX_STRING_LENGTH,
|
|
5088
|
+
Qr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5089
|
+
K as Mode,
|
|
5090
|
+
je as PII_PATTERNS,
|
|
5091
|
+
O as PermanentError,
|
|
5092
|
+
Ne as SamplingRateValidationError,
|
|
5093
|
+
Q as ScrollDirection,
|
|
5094
|
+
mt as SessionTimeoutValidationError,
|
|
5095
|
+
U as SpecialApiUrl,
|
|
5096
|
+
F as TraceLogValidationError,
|
|
5097
|
+
qr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5098
|
+
ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5008
5099
|
Rt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5100
|
+
Ve as getWebVitalsThresholds,
|
|
5101
|
+
zr as isPrimaryScrollEvent,
|
|
5102
|
+
Kr as isSecondaryScrollEvent,
|
|
5103
|
+
Jr as tracelog
|
|
5013
5104
|
};
|