@tracelog/lib 2.0.2 → 2.0.3
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 +70 -25
- package/dist/browser/tracelog.esm.js +263 -284
- 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 +10 -51
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +59 -78
- package/dist/public-api.d.ts +59 -78
- package/dist/public-api.js +10 -51
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Ir = 120,
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
const _r = 9e5;
|
|
2
|
+
const Ir = 120, vr = 8192, wr = 10, yr = 10, Ar = 20, br = 1;
|
|
3
|
+
const Mr = 1e3, Lr = 500, Cr = 100;
|
|
4
|
+
const v = "data-tlog", tt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const I = "data-tlog", rt = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], rt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], nt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -71,22 +71,22 @@ const m = {
|
|
|
71
71
|
INVALID_VIEWPORT_MIN_DWELL_TIME: "Viewport minDwellTime must be a non-negative number",
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number"
|
|
74
|
-
},
|
|
74
|
+
}, st = [
|
|
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
|
-
],
|
|
81
|
+
], I = "tlog", k = `${I}:qa_mode`, pe = `${I}:uid`, Te = "tlog_mode", _e = "qa", Ie = "qa_off", it = (n) => n ? `${I}:${n}:queue` : `${I}:queue`, ot = (n) => n ? `${I}:${n}:session` : `${I}:session`, at = (n) => n ? `${I}:${n}:broadcast` : `${I}:broadcast`, ve = (n, e) => `${I}:${n}:session_counts:${e}`, we = 10080 * 60 * 1e3, ye = `${I}:session_counts_last_cleanup`, Ae = 3600 * 1e3;
|
|
82
82
|
var D = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(D || {}), M = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(M || {}), ne = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(ne || {});
|
|
83
83
|
class R extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
85
|
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, R);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
var u = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n.VIEWPORT_VISIBLE = "viewport_visible", n))(u || {}), X = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(X || {}), V = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(V || {}),
|
|
89
|
-
const
|
|
88
|
+
var u = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n.VIEWPORT_VISIBLE = "viewport_visible", n))(u || {}), X = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(X || {}), V = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(V || {}), j = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(j || {});
|
|
89
|
+
const Rr = (n) => n.type === u.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !0, Nr = (n) => n.type === u.SCROLL && "scroll_data" in n && n.scroll_data.is_primary === !1;
|
|
90
90
|
class U extends Error {
|
|
91
91
|
constructor(e, t, r) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = r, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -97,12 +97,12 @@ class h extends U {
|
|
|
97
97
|
super(e, "APP_CONFIG_INVALID", t);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class lt extends U {
|
|
101
101
|
constructor(e, t = "config") {
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class be extends U {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
@@ -112,12 +112,12 @@ class P extends U {
|
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class Or extends U {
|
|
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 ct = (n, 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, "");
|
|
@@ -137,7 +137,7 @@ const ut = (n, e) => {
|
|
|
137
137
|
}
|
|
138
138
|
return `[TraceLog] ${n}`;
|
|
139
139
|
}, a = (n, e, t) => {
|
|
140
|
-
const { error: r, data: s, showToClient: i = !1, style: o } = t ?? {}, l = r ?
|
|
140
|
+
const { error: r, data: s, showToClient: i = !1, style: o } = t ?? {}, l = r ? ct(e, r) : `[TraceLog] ${e}`, c = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
141
141
|
if (n === "debug" || n === "info" && !i)
|
|
142
142
|
return;
|
|
143
143
|
const d = o !== void 0 && o !== "", g = d ? `%c${l}` : l;
|
|
@@ -160,21 +160,21 @@ const ut = (n, e) => {
|
|
|
160
160
|
}
|
|
161
161
|
return e;
|
|
162
162
|
};
|
|
163
|
-
let ie,
|
|
164
|
-
const
|
|
165
|
-
typeof window < "u" && !ie && (ie = window.matchMedia("(pointer: coarse)"),
|
|
166
|
-
},
|
|
163
|
+
let ie, xe;
|
|
164
|
+
const ut = () => {
|
|
165
|
+
typeof window < "u" && !ie && (ie = window.matchMedia("(pointer: coarse)"), xe = window.matchMedia("(hover: none)"));
|
|
166
|
+
}, dt = () => {
|
|
167
167
|
try {
|
|
168
168
|
const n = navigator;
|
|
169
169
|
if (n.userAgentData && typeof n.userAgentData.mobile == "boolean")
|
|
170
170
|
return n.userAgentData.platform && /ipad|tablet/i.test(n.userAgentData.platform) ? M.Tablet : n.userAgentData.mobile ? M.Mobile : M.Desktop;
|
|
171
|
-
|
|
172
|
-
const e = window.innerWidth, t = ie?.matches ?? !1, r =
|
|
171
|
+
ut();
|
|
172
|
+
const e = window.innerWidth, t = ie?.matches ?? !1, r = xe?.matches ?? !1, s = "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);
|
|
173
173
|
return e <= 767 || o && s ? M.Mobile : e >= 768 && e <= 1024 || l || t && r && s ? M.Tablet : M.Desktop;
|
|
174
174
|
} catch (n) {
|
|
175
175
|
return a("warn", "Device detection failed, defaulting to desktop", { error: n }), M.Desktop;
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, He = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Fe = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", $e = [
|
|
178
178
|
// Email addresses
|
|
179
179
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
180
180
|
// US Phone numbers (various formats)
|
|
@@ -189,7 +189,7 @@ const dt = () => {
|
|
|
189
189
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
190
190
|
// Passwords in connection strings (protocol://user:password@host)
|
|
191
191
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
192
|
-
],
|
|
192
|
+
], Me = 500, Le = 5e3, Q = 50, ht = Q * 2, Be = 1, ft = 1e3, mt = 10, Ce = 5e3, gt = 6e4, Pr = {
|
|
193
193
|
LCP: 2500,
|
|
194
194
|
// Good: ≤ 2.5s
|
|
195
195
|
FCP: 1800,
|
|
@@ -201,7 +201,7 @@ const dt = () => {
|
|
|
201
201
|
TTFB: 800,
|
|
202
202
|
// Good: ≤ 800ms
|
|
203
203
|
LONG_TASK: 50
|
|
204
|
-
},
|
|
204
|
+
}, Re = {
|
|
205
205
|
LCP: 2500,
|
|
206
206
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
207
207
|
FCP: 1800,
|
|
@@ -213,7 +213,7 @@ const dt = () => {
|
|
|
213
213
|
TTFB: 800,
|
|
214
214
|
// Needs improvement: > 800ms
|
|
215
215
|
LONG_TASK: 50
|
|
216
|
-
},
|
|
216
|
+
}, Et = {
|
|
217
217
|
LCP: 4e3,
|
|
218
218
|
// Poor: > 4s
|
|
219
219
|
FCP: 3e3,
|
|
@@ -225,19 +225,19 @@ const dt = () => {
|
|
|
225
225
|
TTFB: 1800,
|
|
226
226
|
// Poor: > 1800ms
|
|
227
227
|
LONG_TASK: 50
|
|
228
|
-
}, oe = "needs-improvement",
|
|
228
|
+
}, oe = "needs-improvement", Ne = (n = oe) => {
|
|
229
229
|
switch (n) {
|
|
230
230
|
case "all":
|
|
231
231
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
232
232
|
// Track everything
|
|
233
233
|
case "needs-improvement":
|
|
234
|
-
return
|
|
234
|
+
return Re;
|
|
235
235
|
case "poor":
|
|
236
|
-
return
|
|
236
|
+
return Et;
|
|
237
237
|
default:
|
|
238
|
-
return
|
|
238
|
+
return Re;
|
|
239
239
|
}
|
|
240
|
-
},
|
|
240
|
+
}, St = 1e3, pt = 50, Tt = "2.0.2", _t = Tt, It = () => {
|
|
241
241
|
if (typeof window > "u" || typeof document > "u")
|
|
242
242
|
return !1;
|
|
243
243
|
try {
|
|
@@ -245,11 +245,11 @@ const dt = () => {
|
|
|
245
245
|
let r = null;
|
|
246
246
|
if (e === _e ? (r = !0, sessionStorage.setItem(k, "true"), a("info", "QA Mode ACTIVE", {
|
|
247
247
|
showToClient: !0,
|
|
248
|
-
style:
|
|
249
|
-
})) : e ===
|
|
248
|
+
style: He
|
|
249
|
+
})) : e === Ie && (r = !1, sessionStorage.setItem(k, "false"), a("info", "QA Mode DISABLED", {
|
|
250
250
|
showToClient: !0,
|
|
251
251
|
style: Fe
|
|
252
|
-
})), e === _e || e ===
|
|
252
|
+
})), e === _e || e === Ie)
|
|
253
253
|
try {
|
|
254
254
|
n.delete(Te);
|
|
255
255
|
const s = n.toString(), i = window.location.pathname + (s ? "?" + s : "") + window.location.hash;
|
|
@@ -260,12 +260,12 @@ const dt = () => {
|
|
|
260
260
|
} catch {
|
|
261
261
|
return !1;
|
|
262
262
|
}
|
|
263
|
-
},
|
|
263
|
+
}, vt = (n) => {
|
|
264
264
|
if (!(typeof window > "u" || typeof document > "u"))
|
|
265
265
|
try {
|
|
266
266
|
n ? (sessionStorage.setItem(k, "true"), a("info", "QA Mode ENABLED", {
|
|
267
267
|
showToClient: !0,
|
|
268
|
-
style:
|
|
268
|
+
style: He
|
|
269
269
|
})) : (sessionStorage.setItem(k, "false"), a("info", "QA Mode DISABLED", {
|
|
270
270
|
showToClient: !0,
|
|
271
271
|
style: Fe
|
|
@@ -273,21 +273,21 @@ const dt = () => {
|
|
|
273
273
|
} catch {
|
|
274
274
|
a("warn", "Cannot set QA mode: sessionStorage unavailable");
|
|
275
275
|
}
|
|
276
|
-
},
|
|
276
|
+
}, Oe = () => {
|
|
277
277
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
278
|
-
return
|
|
278
|
+
return rt.forEach((r) => {
|
|
279
279
|
const s = n.get(r);
|
|
280
280
|
if (s) {
|
|
281
281
|
const i = r.split("utm_")[1];
|
|
282
282
|
e[i] = s;
|
|
283
283
|
}
|
|
284
284
|
}), Object.keys(e).length ? e : void 0;
|
|
285
|
-
},
|
|
285
|
+
}, wt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
286
286
|
const e = Math.random() * 16 | 0;
|
|
287
287
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
288
288
|
});
|
|
289
289
|
let B = 0, W = 0;
|
|
290
|
-
const
|
|
290
|
+
const yt = () => {
|
|
291
291
|
let n = Date.now();
|
|
292
292
|
n < W && (n = W), n === W ? B = (B + 1) % 1e3 : B = 0, W = n;
|
|
293
293
|
const e = B.toString().padStart(3, "0");
|
|
@@ -300,7 +300,7 @@ const bt = () => {
|
|
|
300
300
|
} catch {
|
|
301
301
|
}
|
|
302
302
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
303
|
-
},
|
|
303
|
+
}, We = (n, e = !1) => {
|
|
304
304
|
try {
|
|
305
305
|
const t = new URL(n), r = t.protocol === "https:", s = t.protocol === "http:";
|
|
306
306
|
return r || e && s;
|
|
@@ -325,19 +325,19 @@ const bt = () => {
|
|
|
325
325
|
if (r.length === 2 ? s = r.join(".") : s = r.slice(-2).join("."), !s || s.split(".").length < 2)
|
|
326
326
|
throw new Error("Invalid domain structure for SaaS");
|
|
327
327
|
const i = `https://${n}.${s}/collect`;
|
|
328
|
-
if (!
|
|
328
|
+
if (!We(i))
|
|
329
329
|
throw new Error("Generated URL failed validation");
|
|
330
330
|
return i;
|
|
331
331
|
} catch (e) {
|
|
332
332
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
333
333
|
}
|
|
334
|
-
},
|
|
334
|
+
}, bt = (n) => {
|
|
335
335
|
const e = {};
|
|
336
336
|
n.integrations?.tracelog?.projectId && (e.saas = At(n.integrations.tracelog.projectId));
|
|
337
337
|
const t = n.integrations?.custom?.collectApiUrl;
|
|
338
338
|
if (t) {
|
|
339
339
|
const r = n.integrations?.custom?.allowHttp ?? !1;
|
|
340
|
-
if (!
|
|
340
|
+
if (!We(t, r))
|
|
341
341
|
throw new Error("Invalid custom API URL");
|
|
342
342
|
e.custom = t;
|
|
343
343
|
}
|
|
@@ -346,7 +346,7 @@ const bt = () => {
|
|
|
346
346
|
if (!n || typeof n != "string")
|
|
347
347
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { url: String(n) } }), n || "";
|
|
348
348
|
try {
|
|
349
|
-
const t = new URL(n), r = t.searchParams, s = [.../* @__PURE__ */ new Set([...
|
|
349
|
+
const t = new URL(n), r = t.searchParams, s = [.../* @__PURE__ */ new Set([...nt, ...e])];
|
|
350
350
|
let i = !1;
|
|
351
351
|
const o = [];
|
|
352
352
|
return s.forEach((c) => {
|
|
@@ -356,13 +356,13 @@ const bt = () => {
|
|
|
356
356
|
const r = n && typeof n == "string" ? n.slice(0, 100) : String(n);
|
|
357
357
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { url: r } }), n;
|
|
358
358
|
}
|
|
359
|
-
},
|
|
359
|
+
}, Pe = (n) => {
|
|
360
360
|
if (!n || typeof n != "string" || n.trim().length === 0)
|
|
361
361
|
return "";
|
|
362
362
|
let e = n;
|
|
363
363
|
n.length > 1e3 && (e = n.slice(0, Math.max(0, 1e3)));
|
|
364
364
|
let t = 0;
|
|
365
|
-
for (const s of
|
|
365
|
+
for (const s of st) {
|
|
366
366
|
const i = e;
|
|
367
367
|
e = e.replace(s, ""), i !== e && t++;
|
|
368
368
|
}
|
|
@@ -376,7 +376,7 @@ const bt = () => {
|
|
|
376
376
|
if (e > 3 || n == null)
|
|
377
377
|
return null;
|
|
378
378
|
if (typeof n == "string")
|
|
379
|
-
return
|
|
379
|
+
return Pe(n);
|
|
380
380
|
if (typeof n == "number")
|
|
381
381
|
return !Number.isFinite(n) || n < -Number.MAX_SAFE_INTEGER || n > Number.MAX_SAFE_INTEGER ? 0 : n;
|
|
382
382
|
if (typeof n == "boolean")
|
|
@@ -386,7 +386,7 @@ const bt = () => {
|
|
|
386
386
|
if (typeof n == "object") {
|
|
387
387
|
const t = {}, s = Object.entries(n).slice(0, 20);
|
|
388
388
|
for (const [i, o] of s) {
|
|
389
|
-
const l =
|
|
389
|
+
const l = Pe(i);
|
|
390
390
|
if (l) {
|
|
391
391
|
const c = le(o, e + 1);
|
|
392
392
|
c !== null && (t[l] = c);
|
|
@@ -395,7 +395,7 @@ const bt = () => {
|
|
|
395
395
|
return t;
|
|
396
396
|
}
|
|
397
397
|
return null;
|
|
398
|
-
},
|
|
398
|
+
}, Mt = (n) => {
|
|
399
399
|
if (typeof n != "object" || n === null)
|
|
400
400
|
return {};
|
|
401
401
|
try {
|
|
@@ -405,15 +405,15 @@ const bt = () => {
|
|
|
405
405
|
const t = e instanceof Error ? e.message : String(e);
|
|
406
406
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
407
407
|
}
|
|
408
|
-
},
|
|
408
|
+
}, Lt = (n) => {
|
|
409
409
|
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
410
410
|
throw new h("Configuration must be an object", "config");
|
|
411
411
|
if (n) {
|
|
412
412
|
if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
|
|
413
|
-
throw new
|
|
413
|
+
throw new lt(m.INVALID_SESSION_TIMEOUT, "config");
|
|
414
414
|
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
415
415
|
throw new h(m.INVALID_GLOBAL_METADATA, "config");
|
|
416
|
-
if (n.integrations &&
|
|
416
|
+
if (n.integrations && Rt(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
417
417
|
if (!Array.isArray(n.sensitiveQueryParams))
|
|
418
418
|
throw new h(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
419
419
|
for (const e of n.sensitiveQueryParams)
|
|
@@ -421,9 +421,9 @@ const bt = () => {
|
|
|
421
421
|
throw new h("All sensitive query params must be strings", "config");
|
|
422
422
|
}
|
|
423
423
|
if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
|
|
424
|
-
throw new
|
|
424
|
+
throw new be(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
425
425
|
if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
|
|
426
|
-
throw new
|
|
426
|
+
throw new be(m.INVALID_SAMPLING_RATE, "config");
|
|
427
427
|
if (n.primaryScrollSelector !== void 0) {
|
|
428
428
|
if (typeof n.primaryScrollSelector != "string" || !n.primaryScrollSelector.trim())
|
|
429
429
|
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -443,27 +443,7 @@ const bt = () => {
|
|
|
443
443
|
throw new h(m.INVALID_CLICK_THROTTLE, "config");
|
|
444
444
|
if (n.maxSameEventPerMinute !== void 0 && (typeof n.maxSameEventPerMinute != "number" || n.maxSameEventPerMinute <= 0))
|
|
445
445
|
throw new h(m.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
446
|
-
if (n.viewport !== void 0 &&
|
|
447
|
-
if (!Array.isArray(n.disabledEvents))
|
|
448
|
-
throw new h("disabledEvents must be an array", "config");
|
|
449
|
-
const e = /* @__PURE__ */ new Set();
|
|
450
|
-
for (const t of n.disabledEvents) {
|
|
451
|
-
if (typeof t != "string")
|
|
452
|
-
throw new h("All disabled event types must be strings", "config");
|
|
453
|
-
if (!Me.includes(t))
|
|
454
|
-
throw new h(
|
|
455
|
-
`Invalid disabled event type: "${t}". Must be one of: ${Me.join(", ")}`,
|
|
456
|
-
"config"
|
|
457
|
-
);
|
|
458
|
-
if (e.has(t))
|
|
459
|
-
throw new h(
|
|
460
|
-
`Duplicate disabled event type found: "${t}". Each event type should appear only once.`,
|
|
461
|
-
"config"
|
|
462
|
-
);
|
|
463
|
-
e.add(t);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
if (n.webVitalsMode !== void 0) {
|
|
446
|
+
if (n.viewport !== void 0 && Ct(n.viewport), n.webVitalsMode !== void 0) {
|
|
467
447
|
if (typeof n.webVitalsMode != "string")
|
|
468
448
|
throw new h(
|
|
469
449
|
`Invalid webVitalsMode type: ${typeof n.webVitalsMode}. Must be a string`,
|
|
@@ -494,7 +474,7 @@ const bt = () => {
|
|
|
494
474
|
}
|
|
495
475
|
}
|
|
496
476
|
}
|
|
497
|
-
},
|
|
477
|
+
}, Ct = (n) => {
|
|
498
478
|
if (typeof n != "object" || n === null)
|
|
499
479
|
throw new h(m.INVALID_VIEWPORT_CONFIG, "config");
|
|
500
480
|
if (!n.elements || !Array.isArray(n.elements))
|
|
@@ -524,7 +504,7 @@ const bt = () => {
|
|
|
524
504
|
throw new h(m.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
525
505
|
if (n.maxTrackedElements !== void 0 && (typeof n.maxTrackedElements != "number" || n.maxTrackedElements <= 0))
|
|
526
506
|
throw new h(m.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
527
|
-
},
|
|
507
|
+
}, Rt = (n) => {
|
|
528
508
|
if (n) {
|
|
529
509
|
if (n.tracelog && (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === ""))
|
|
530
510
|
throw new P(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
@@ -543,19 +523,18 @@ const bt = () => {
|
|
|
543
523
|
);
|
|
544
524
|
}
|
|
545
525
|
}
|
|
546
|
-
},
|
|
547
|
-
|
|
526
|
+
}, Nt = (n) => {
|
|
527
|
+
Lt(n);
|
|
548
528
|
const e = {
|
|
549
529
|
...n ?? {},
|
|
550
530
|
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
551
531
|
globalMetadata: n?.globalMetadata ?? {},
|
|
552
532
|
sensitiveQueryParams: n?.sensitiveQueryParams ?? [],
|
|
553
|
-
errorSampling: n?.errorSampling ??
|
|
533
|
+
errorSampling: n?.errorSampling ?? Be,
|
|
554
534
|
samplingRate: n?.samplingRate ?? 1,
|
|
555
535
|
pageViewThrottleMs: n?.pageViewThrottleMs ?? 1e3,
|
|
556
536
|
clickThrottleMs: n?.clickThrottleMs ?? 300,
|
|
557
|
-
maxSameEventPerMinute: n?.maxSameEventPerMinute ?? 60
|
|
558
|
-
disabledEvents: n?.disabledEvents ?? []
|
|
537
|
+
maxSameEventPerMinute: n?.maxSameEventPerMinute ?? 60
|
|
559
538
|
};
|
|
560
539
|
return e.integrations?.custom && (e.integrations.custom = {
|
|
561
540
|
...e.integrations.custom,
|
|
@@ -567,7 +546,7 @@ const bt = () => {
|
|
|
567
546
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
568
547
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
569
548
|
}), e;
|
|
570
|
-
},
|
|
549
|
+
}, Ot = (n) => {
|
|
571
550
|
if (typeof n == "string")
|
|
572
551
|
return !0;
|
|
573
552
|
if (typeof n == "object" && n !== null && !Array.isArray(n)) {
|
|
@@ -584,7 +563,7 @@ const bt = () => {
|
|
|
584
563
|
return !0;
|
|
585
564
|
}
|
|
586
565
|
return !1;
|
|
587
|
-
},
|
|
566
|
+
}, Ge = (n, e = 0) => {
|
|
588
567
|
if (typeof n != "object" || n === null || e > 1)
|
|
589
568
|
return !1;
|
|
590
569
|
for (const t of Object.values(n)) {
|
|
@@ -598,12 +577,12 @@ const bt = () => {
|
|
|
598
577
|
if (typeof t[0] == "string") {
|
|
599
578
|
if (!t.every((o) => typeof o == "string"))
|
|
600
579
|
return !1;
|
|
601
|
-
} else if (!t.every((o) =>
|
|
580
|
+
} else if (!t.every((o) => Ot(o)))
|
|
602
581
|
return !1;
|
|
603
582
|
continue;
|
|
604
583
|
}
|
|
605
584
|
if (r === "object" && e === 0) {
|
|
606
|
-
if (!
|
|
585
|
+
if (!Ge(t, e + 1))
|
|
607
586
|
return !1;
|
|
608
587
|
continue;
|
|
609
588
|
}
|
|
@@ -611,7 +590,7 @@ const bt = () => {
|
|
|
611
590
|
}
|
|
612
591
|
}
|
|
613
592
|
return !0;
|
|
614
|
-
},
|
|
593
|
+
}, Pt = (n) => typeof n != "string" ? {
|
|
615
594
|
valid: !1,
|
|
616
595
|
error: "Event name must be a string"
|
|
617
596
|
} : n.length === 0 ? {
|
|
@@ -626,9 +605,9 @@ const bt = () => {
|
|
|
626
605
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(n.toLowerCase()) ? {
|
|
627
606
|
valid: !1,
|
|
628
607
|
error: "Event name cannot be a reserved word"
|
|
629
|
-
} : { valid: !0 },
|
|
630
|
-
const r =
|
|
631
|
-
if (!
|
|
608
|
+
} : { valid: !0 }, De = (n, e, t) => {
|
|
609
|
+
const r = Mt(e), s = t && t === "customEvent" ? `${t} "${n}" metadata error` : `${n} metadata error`;
|
|
610
|
+
if (!Ge(r))
|
|
632
611
|
return {
|
|
633
612
|
valid: !1,
|
|
634
613
|
error: `${s}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -676,7 +655,7 @@ const bt = () => {
|
|
|
676
655
|
valid: !0,
|
|
677
656
|
sanitizedMetadata: r
|
|
678
657
|
};
|
|
679
|
-
},
|
|
658
|
+
}, Xe = (n, e, t) => {
|
|
680
659
|
if (Array.isArray(e)) {
|
|
681
660
|
const r = [], s = t && t === "customEvent" ? `${t} "${n}" metadata error` : `${n} metadata error`;
|
|
682
661
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -686,7 +665,7 @@ const bt = () => {
|
|
|
686
665
|
valid: !1,
|
|
687
666
|
error: `${s}: array item at index ${i} must be an object.`
|
|
688
667
|
};
|
|
689
|
-
const l =
|
|
668
|
+
const l = De(n, o, t);
|
|
690
669
|
if (!l.valid)
|
|
691
670
|
return {
|
|
692
671
|
valid: !1,
|
|
@@ -699,9 +678,9 @@ const bt = () => {
|
|
|
699
678
|
sanitizedMetadata: r
|
|
700
679
|
};
|
|
701
680
|
}
|
|
702
|
-
return
|
|
703
|
-
},
|
|
704
|
-
const t =
|
|
681
|
+
return De(n, e, t);
|
|
682
|
+
}, Dt = (n, e) => {
|
|
683
|
+
const t = Pt(n);
|
|
705
684
|
if (!t.valid)
|
|
706
685
|
return a("error", "Event name validation failed", {
|
|
707
686
|
showToClient: !0,
|
|
@@ -709,7 +688,7 @@ const bt = () => {
|
|
|
709
688
|
}), t;
|
|
710
689
|
if (!e)
|
|
711
690
|
return { valid: !0 };
|
|
712
|
-
const r =
|
|
691
|
+
const r = Xe(n, e, "customEvent");
|
|
713
692
|
return r.valid || a("error", "Event metadata validation failed", {
|
|
714
693
|
showToClient: !0,
|
|
715
694
|
data: {
|
|
@@ -718,7 +697,7 @@ const bt = () => {
|
|
|
718
697
|
}
|
|
719
698
|
}), r;
|
|
720
699
|
};
|
|
721
|
-
class
|
|
700
|
+
class Vt {
|
|
722
701
|
listeners = /* @__PURE__ */ new Map();
|
|
723
702
|
/**
|
|
724
703
|
* Subscribes to an event channel
|
|
@@ -835,7 +814,7 @@ class kt {
|
|
|
835
814
|
this.listeners.clear();
|
|
836
815
|
}
|
|
837
816
|
}
|
|
838
|
-
function
|
|
817
|
+
function Qe(n, e, t) {
|
|
839
818
|
try {
|
|
840
819
|
const r = e(n);
|
|
841
820
|
return r === null ? null : typeof r == "object" && r !== null && "type" in r ? r : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), n);
|
|
@@ -843,8 +822,8 @@ function je(n, e, t) {
|
|
|
843
822
|
return a("error", `beforeSend transformer threw error, using original event [${t}]`, { error: r }), n;
|
|
844
823
|
}
|
|
845
824
|
}
|
|
846
|
-
function
|
|
847
|
-
return n.map((r) =>
|
|
825
|
+
function kt(n, e, t) {
|
|
826
|
+
return n.map((r) => Qe(r, e, t)).filter((r) => r !== null);
|
|
848
827
|
}
|
|
849
828
|
function ze(n, e, t) {
|
|
850
829
|
try {
|
|
@@ -920,7 +899,7 @@ class p {
|
|
|
920
899
|
return { ...ee };
|
|
921
900
|
}
|
|
922
901
|
}
|
|
923
|
-
class
|
|
902
|
+
class Ve extends p {
|
|
924
903
|
storeManager;
|
|
925
904
|
integrationId;
|
|
926
905
|
apiUrl;
|
|
@@ -954,7 +933,7 @@ class ke extends p {
|
|
|
954
933
|
return this.integrationId;
|
|
955
934
|
}
|
|
956
935
|
getQueueStorageKey() {
|
|
957
|
-
const e = this.get("userId") || "anonymous", t =
|
|
936
|
+
const e = this.get("userId") || "anonymous", t = it(e);
|
|
958
937
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
959
938
|
}
|
|
960
939
|
/**
|
|
@@ -1155,7 +1134,7 @@ class ke extends p {
|
|
|
1155
1134
|
const t = this.transformers.beforeSend;
|
|
1156
1135
|
if (!t)
|
|
1157
1136
|
return e;
|
|
1158
|
-
const r =
|
|
1137
|
+
const r = kt(
|
|
1159
1138
|
e.events,
|
|
1160
1139
|
t,
|
|
1161
1140
|
this.integrationId || "SenderManager"
|
|
@@ -1433,7 +1412,7 @@ class ke extends p {
|
|
|
1433
1412
|
_metadata: {
|
|
1434
1413
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1435
1414
|
timestamp: t,
|
|
1436
|
-
client_version:
|
|
1415
|
+
client_version: _t
|
|
1437
1416
|
}
|
|
1438
1417
|
};
|
|
1439
1418
|
return {
|
|
@@ -1552,12 +1531,12 @@ class ke extends p {
|
|
|
1552
1531
|
}
|
|
1553
1532
|
logPermanentError(e, t) {
|
|
1554
1533
|
const r = Date.now();
|
|
1555
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >=
|
|
1534
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || r - this.lastPermanentErrorLog.timestamp >= gt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1556
1535
|
data: { status: t.statusCode, message: t.message }
|
|
1557
1536
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: r });
|
|
1558
1537
|
}
|
|
1559
1538
|
}
|
|
1560
|
-
class
|
|
1539
|
+
class Ut extends p {
|
|
1561
1540
|
bootTime;
|
|
1562
1541
|
bootTimestamp;
|
|
1563
1542
|
hasPerformanceNow;
|
|
@@ -1706,7 +1685,7 @@ class xt extends p {
|
|
|
1706
1685
|
};
|
|
1707
1686
|
}
|
|
1708
1687
|
}
|
|
1709
|
-
class
|
|
1688
|
+
class xt extends p {
|
|
1710
1689
|
dataSenders;
|
|
1711
1690
|
emitter;
|
|
1712
1691
|
transformers;
|
|
@@ -1740,9 +1719,9 @@ class Ht extends p {
|
|
|
1740
1719
|
* @param transformers - Optional event transformation hooks
|
|
1741
1720
|
*/
|
|
1742
1721
|
constructor(e, t = null, r = {}) {
|
|
1743
|
-
super(), this.emitter = t, this.transformers = r, this.timeManager = new
|
|
1722
|
+
super(), this.emitter = t, this.transformers = r, this.timeManager = new Ut(), this.dataSenders = [];
|
|
1744
1723
|
const s = this.get("collectApiUrls");
|
|
1745
|
-
s?.saas && this.dataSenders.push(new
|
|
1724
|
+
s?.saas && this.dataSenders.push(new Ve(e, "saas", s.saas, r)), s?.custom && this.dataSenders.push(new Ve(e, "custom", s.custom, r)), this.saveSessionCountsDebounced = this.debounce((i) => {
|
|
1746
1725
|
this.saveSessionCounts(i);
|
|
1747
1726
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1748
1727
|
}
|
|
@@ -1915,9 +1894,9 @@ class Ht extends p {
|
|
|
1915
1894
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1916
1895
|
return;
|
|
1917
1896
|
}
|
|
1918
|
-
const H = S === u.SESSION_START,
|
|
1897
|
+
const H = S === u.SESSION_START, F = t || this.get("pageUrl"), $ = this.buildEventPayload({
|
|
1919
1898
|
type: S,
|
|
1920
|
-
page_url:
|
|
1899
|
+
page_url: F,
|
|
1921
1900
|
from_page_url: r,
|
|
1922
1901
|
scroll_data: s,
|
|
1923
1902
|
click_data: i,
|
|
@@ -1926,7 +1905,7 @@ class Ht extends p {
|
|
|
1926
1905
|
error_data: c,
|
|
1927
1906
|
viewport_data: d
|
|
1928
1907
|
});
|
|
1929
|
-
if (
|
|
1908
|
+
if ($ && !(!E && !this.shouldSample())) {
|
|
1930
1909
|
if (H) {
|
|
1931
1910
|
const T = this.get("sessionId");
|
|
1932
1911
|
if (!T) {
|
|
@@ -1941,18 +1920,18 @@ class Ht extends p {
|
|
|
1941
1920
|
}
|
|
1942
1921
|
this.set("hasStartSession", !0);
|
|
1943
1922
|
}
|
|
1944
|
-
if (!this.isDuplicateEvent(
|
|
1945
|
-
if (this.get("mode") ===
|
|
1923
|
+
if (!this.isDuplicateEvent($)) {
|
|
1924
|
+
if (this.get("mode") === j.QA && S === u.CUSTOM && o) {
|
|
1946
1925
|
a("info", `Custom Event: ${o.name}`, {
|
|
1947
1926
|
showToClient: !0,
|
|
1948
1927
|
data: {
|
|
1949
1928
|
name: o.name,
|
|
1950
1929
|
...o.metadata && { metadata: o.metadata }
|
|
1951
1930
|
}
|
|
1952
|
-
}), this.emitEvent(
|
|
1931
|
+
}), this.emitEvent($);
|
|
1953
1932
|
return;
|
|
1954
1933
|
}
|
|
1955
|
-
if (this.addToQueue(
|
|
1934
|
+
if (this.addToQueue($), !E) {
|
|
1956
1935
|
this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
|
|
1957
1936
|
const T = this.get("sessionId");
|
|
1958
1937
|
T && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(T);
|
|
@@ -2280,7 +2259,7 @@ class Ht extends p {
|
|
|
2280
2259
|
data: { type: e.type, error: i.error }
|
|
2281
2260
|
});
|
|
2282
2261
|
let o = {
|
|
2283
|
-
id:
|
|
2262
|
+
id: yt(),
|
|
2284
2263
|
type: e.type,
|
|
2285
2264
|
page_url: r,
|
|
2286
2265
|
timestamp: s,
|
|
@@ -2292,14 +2271,14 @@ class Ht extends p {
|
|
|
2292
2271
|
...e.web_vitals && { web_vitals: e.web_vitals },
|
|
2293
2272
|
...e.error_data && { error_data: e.error_data },
|
|
2294
2273
|
...e.viewport_data && { viewport_data: e.viewport_data },
|
|
2295
|
-
...t &&
|
|
2274
|
+
...t && Oe() && { utm: Oe() }
|
|
2296
2275
|
};
|
|
2297
2276
|
const l = this.get("collectApiUrls"), c = !!l?.custom, d = !!l?.saas, g = c || d, E = c && d, S = this.transformers.beforeSend;
|
|
2298
2277
|
if (S && (!g || c && !E)) {
|
|
2299
|
-
const
|
|
2300
|
-
if (
|
|
2278
|
+
const F = Qe(o, S, "EventManager");
|
|
2279
|
+
if (F === null)
|
|
2301
2280
|
return null;
|
|
2302
|
-
o =
|
|
2281
|
+
o = F;
|
|
2303
2282
|
}
|
|
2304
2283
|
return o;
|
|
2305
2284
|
}
|
|
@@ -2461,7 +2440,7 @@ class Ht extends p {
|
|
|
2461
2440
|
loadSessionCounts(e) {
|
|
2462
2441
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2463
2442
|
return this.getInitialCounts();
|
|
2464
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2443
|
+
const t = this.get("userId") || "anonymous", r = ve(t, e);
|
|
2465
2444
|
try {
|
|
2466
2445
|
const s = localStorage.getItem(r);
|
|
2467
2446
|
if (!s)
|
|
@@ -2515,14 +2494,14 @@ class Ht extends p {
|
|
|
2515
2494
|
const e = localStorage.getItem(ye);
|
|
2516
2495
|
if (e) {
|
|
2517
2496
|
const i = Date.now() - parseInt(e, 10);
|
|
2518
|
-
if (i <
|
|
2497
|
+
if (i < Ae) {
|
|
2519
2498
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2520
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2499
|
+
data: { timeSinceLastCleanup: i, throttleMs: Ae }
|
|
2521
2500
|
});
|
|
2522
2501
|
return;
|
|
2523
2502
|
}
|
|
2524
2503
|
}
|
|
2525
|
-
const t = this.get("userId") || "anonymous", r = `${
|
|
2504
|
+
const t = this.get("userId") || "anonymous", r = `${I}:${t}:session_counts:`, s = [];
|
|
2526
2505
|
for (let i = 0; i < localStorage.length; i++) {
|
|
2527
2506
|
const o = localStorage.key(i);
|
|
2528
2507
|
if (o?.startsWith(r))
|
|
@@ -2571,7 +2550,7 @@ class Ht extends p {
|
|
|
2571
2550
|
* @internal
|
|
2572
2551
|
*/
|
|
2573
2552
|
saveSessionCounts(e) {
|
|
2574
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2553
|
+
const t = this.get("userId") || "anonymous", r = ve(t, e);
|
|
2575
2554
|
try {
|
|
2576
2555
|
const s = {
|
|
2577
2556
|
...this.sessionEventCounts,
|
|
@@ -2587,7 +2566,7 @@ class Ht extends p {
|
|
|
2587
2566
|
}
|
|
2588
2567
|
}
|
|
2589
2568
|
}
|
|
2590
|
-
class
|
|
2569
|
+
class Ht {
|
|
2591
2570
|
/**
|
|
2592
2571
|
* Gets or creates a unique user ID.
|
|
2593
2572
|
*
|
|
@@ -2608,12 +2587,12 @@ class $t {
|
|
|
2608
2587
|
const t = e.getItem(pe);
|
|
2609
2588
|
if (t)
|
|
2610
2589
|
return t;
|
|
2611
|
-
const r =
|
|
2590
|
+
const r = wt();
|
|
2612
2591
|
return e.setItem(pe, r), r;
|
|
2613
2592
|
}
|
|
2614
2593
|
}
|
|
2615
2594
|
const Ft = /^\d{13}-[a-z0-9]{9}$/;
|
|
2616
|
-
class
|
|
2595
|
+
class $t extends p {
|
|
2617
2596
|
storageManager;
|
|
2618
2597
|
eventManager;
|
|
2619
2598
|
projectId;
|
|
@@ -2638,7 +2617,7 @@ class Bt extends p {
|
|
|
2638
2617
|
return;
|
|
2639
2618
|
}
|
|
2640
2619
|
const e = this.getProjectId();
|
|
2641
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2620
|
+
this.broadcastChannel = new BroadcastChannel(at(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2642
2621
|
const { action: r, sessionId: s, timestamp: i, projectId: o } = t.data ?? {};
|
|
2643
2622
|
o === e && (r === "session_start" && s && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", s), this.persistSession(s, i), this.isTracking && this.setupSessionTimeout()) : r && r !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: r } }));
|
|
2644
2623
|
};
|
|
@@ -2691,7 +2670,7 @@ class Bt extends p {
|
|
|
2691
2670
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
2692
2671
|
}
|
|
2693
2672
|
getSessionStorageKey() {
|
|
2694
|
-
return
|
|
2673
|
+
return ot(this.getProjectId());
|
|
2695
2674
|
}
|
|
2696
2675
|
getProjectId() {
|
|
2697
2676
|
return this.projectId;
|
|
@@ -2874,7 +2853,7 @@ class Bt extends p {
|
|
|
2874
2853
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
2875
2854
|
}
|
|
2876
2855
|
}
|
|
2877
|
-
class
|
|
2856
|
+
class Bt extends p {
|
|
2878
2857
|
eventManager;
|
|
2879
2858
|
storageManager;
|
|
2880
2859
|
sessionManager = null;
|
|
@@ -2909,7 +2888,7 @@ class Wt extends p {
|
|
|
2909
2888
|
}
|
|
2910
2889
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2911
2890
|
try {
|
|
2912
|
-
this.sessionManager = new
|
|
2891
|
+
this.sessionManager = new $t(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2913
2892
|
} catch (r) {
|
|
2914
2893
|
if (this.sessionManager) {
|
|
2915
2894
|
try {
|
|
@@ -2962,7 +2941,7 @@ class Wt extends p {
|
|
|
2962
2941
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2963
2942
|
}
|
|
2964
2943
|
}
|
|
2965
|
-
class
|
|
2944
|
+
class Wt extends p {
|
|
2966
2945
|
eventManager;
|
|
2967
2946
|
onTrack;
|
|
2968
2947
|
originalPushState;
|
|
@@ -3038,7 +3017,7 @@ class Gt extends p {
|
|
|
3038
3017
|
};
|
|
3039
3018
|
}
|
|
3040
3019
|
}
|
|
3041
|
-
class
|
|
3020
|
+
class Gt extends p {
|
|
3042
3021
|
eventManager;
|
|
3043
3022
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
3044
3023
|
clickHandler;
|
|
@@ -3102,7 +3081,7 @@ class Xt extends p {
|
|
|
3102
3081
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
3103
3082
|
}
|
|
3104
3083
|
shouldIgnoreElement(e) {
|
|
3105
|
-
return e.hasAttribute(`${
|
|
3084
|
+
return e.hasAttribute(`${v}-ignore`) ? !0 : e.closest(`[${v}-ignore]`) !== null;
|
|
3106
3085
|
}
|
|
3107
3086
|
/**
|
|
3108
3087
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -3153,8 +3132,8 @@ class Xt extends p {
|
|
|
3153
3132
|
const t = e.getAttribute("data-testid");
|
|
3154
3133
|
if (t)
|
|
3155
3134
|
return `[data-testid="${t}"]`;
|
|
3156
|
-
const r = e.getAttribute(`${
|
|
3157
|
-
return r ? `[${
|
|
3135
|
+
const r = e.getAttribute(`${v}-name`);
|
|
3136
|
+
return r ? `[${v}-name="${r}"]` : this.getElementPath(e);
|
|
3158
3137
|
}
|
|
3159
3138
|
/**
|
|
3160
3139
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -3173,10 +3152,10 @@ class Xt extends p {
|
|
|
3173
3152
|
return t.join(">") || "unknown";
|
|
3174
3153
|
}
|
|
3175
3154
|
findTrackingElement(e) {
|
|
3176
|
-
return e.hasAttribute(`${
|
|
3155
|
+
return e.hasAttribute(`${v}-name`) ? e : e.closest(`[${v}-name]`);
|
|
3177
3156
|
}
|
|
3178
3157
|
getRelevantClickElement(e) {
|
|
3179
|
-
for (const t of
|
|
3158
|
+
for (const t of tt)
|
|
3180
3159
|
try {
|
|
3181
3160
|
if (e.matches(t))
|
|
3182
3161
|
return e;
|
|
@@ -3208,7 +3187,7 @@ class Xt extends p {
|
|
|
3208
3187
|
return { x: s, y: i, relativeX: o, relativeY: l };
|
|
3209
3188
|
}
|
|
3210
3189
|
extractTrackingData(e) {
|
|
3211
|
-
const t = e.getAttribute(`${
|
|
3190
|
+
const t = e.getAttribute(`${v}-name`), r = e.getAttribute(`${v}-value`);
|
|
3212
3191
|
if (t)
|
|
3213
3192
|
return {
|
|
3214
3193
|
element: e,
|
|
@@ -3256,7 +3235,7 @@ class Xt extends p {
|
|
|
3256
3235
|
*/
|
|
3257
3236
|
sanitizeText(e) {
|
|
3258
3237
|
let t = e;
|
|
3259
|
-
for (const r of
|
|
3238
|
+
for (const r of $e) {
|
|
3260
3239
|
const s = new RegExp(r.source, r.flags);
|
|
3261
3240
|
t = t.replace(s, "[REDACTED]");
|
|
3262
3241
|
}
|
|
@@ -3295,7 +3274,7 @@ class Xt extends p {
|
|
|
3295
3274
|
};
|
|
3296
3275
|
}
|
|
3297
3276
|
}
|
|
3298
|
-
class
|
|
3277
|
+
class Xt extends p {
|
|
3299
3278
|
eventManager;
|
|
3300
3279
|
containers = [];
|
|
3301
3280
|
limitWarningLogged = !1;
|
|
@@ -3523,7 +3502,7 @@ class Qt extends p {
|
|
|
3523
3502
|
e.isPrimary = t;
|
|
3524
3503
|
}
|
|
3525
3504
|
}
|
|
3526
|
-
class
|
|
3505
|
+
class Qt extends p {
|
|
3527
3506
|
eventManager;
|
|
3528
3507
|
trackedElements = /* @__PURE__ */ new Map();
|
|
3529
3508
|
observer = null;
|
|
@@ -3587,7 +3566,7 @@ class jt extends p {
|
|
|
3587
3566
|
});
|
|
3588
3567
|
return;
|
|
3589
3568
|
}
|
|
3590
|
-
i.hasAttribute(`${
|
|
3569
|
+
i.hasAttribute(`${v}-ignore`) || this.trackedElements.has(i) || (this.trackedElements.set(i, {
|
|
3591
3570
|
element: i,
|
|
3592
3571
|
selector: r.selector,
|
|
3593
3572
|
id: r.id,
|
|
@@ -3624,7 +3603,7 @@ class jt extends p {
|
|
|
3624
3603
|
fireViewportEvent(e, t) {
|
|
3625
3604
|
if (e.startTime === null) return;
|
|
3626
3605
|
const r = Math.round(performance.now() - e.startTime);
|
|
3627
|
-
if (e.element.hasAttribute(`${
|
|
3606
|
+
if (e.element.hasAttribute(`${v}-ignore`))
|
|
3628
3607
|
return;
|
|
3629
3608
|
const s = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
|
|
3630
3609
|
if (e.lastFiredTime !== null && i - e.lastFiredTime < s) {
|
|
@@ -3967,7 +3946,7 @@ class zt {
|
|
|
3967
3946
|
this.fallbackSessionStorage.delete(e);
|
|
3968
3947
|
}
|
|
3969
3948
|
}
|
|
3970
|
-
class
|
|
3949
|
+
class jt extends p {
|
|
3971
3950
|
eventManager;
|
|
3972
3951
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3973
3952
|
navigationHistory = [];
|
|
@@ -3978,7 +3957,7 @@ class Kt extends p {
|
|
|
3978
3957
|
navigationCounter = 0;
|
|
3979
3958
|
// Counter for handling simultaneous navigations edge case
|
|
3980
3959
|
constructor(e) {
|
|
3981
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
3960
|
+
super(), this.eventManager = e, this.vitalThresholds = Ne(oe);
|
|
3982
3961
|
}
|
|
3983
3962
|
/**
|
|
3984
3963
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3996,7 +3975,7 @@ class Kt extends p {
|
|
|
3996
3975
|
*/
|
|
3997
3976
|
async startTracking() {
|
|
3998
3977
|
const e = this.get("config"), t = e?.webVitalsMode ?? oe;
|
|
3999
|
-
this.vitalThresholds =
|
|
3978
|
+
this.vitalThresholds = Ne(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4000
3979
|
}
|
|
4001
3980
|
/**
|
|
4002
3981
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4066,7 +4045,7 @@ class Kt extends p {
|
|
|
4066
4045
|
}
|
|
4067
4046
|
async initWebVitals() {
|
|
4068
4047
|
try {
|
|
4069
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() =>
|
|
4048
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: s, onINP: i } = await Promise.resolve().then(() => Tr), o = (l) => (c) => {
|
|
4070
4049
|
const d = Number(c.value.toFixed(2));
|
|
4071
4050
|
this.sendVital({ type: l, value: d });
|
|
4072
4051
|
};
|
|
@@ -4093,7 +4072,7 @@ class Kt extends p {
|
|
|
4093
4072
|
const t = e.getEntries();
|
|
4094
4073
|
for (const r of t) {
|
|
4095
4074
|
const s = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4096
|
-
i - this.lastLongTaskSentAt >=
|
|
4075
|
+
i - this.lastLongTaskSentAt >= St && (this.shouldSendVital("LONG_TASK", s) && this.trackWebVital("LONG_TASK", s), this.lastLongTaskSentAt = i);
|
|
4097
4076
|
}
|
|
4098
4077
|
},
|
|
4099
4078
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4109,7 +4088,7 @@ class Kt extends p {
|
|
|
4109
4088
|
return;
|
|
4110
4089
|
if (r)
|
|
4111
4090
|
r.add(e.type);
|
|
4112
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4091
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > pt) {
|
|
4113
4092
|
const i = this.navigationHistory.shift();
|
|
4114
4093
|
i && this.reportedByNav.delete(i);
|
|
4115
4094
|
}
|
|
@@ -4200,7 +4179,7 @@ class Kt extends p {
|
|
|
4200
4179
|
return !(typeof r == "number" && t <= r);
|
|
4201
4180
|
}
|
|
4202
4181
|
}
|
|
4203
|
-
class
|
|
4182
|
+
class Kt extends p {
|
|
4204
4183
|
eventManager;
|
|
4205
4184
|
recentErrors = /* @__PURE__ */ new Map();
|
|
4206
4185
|
errorBurstCounter = 0;
|
|
@@ -4236,14 +4215,14 @@ class Yt extends p {
|
|
|
4236
4215
|
const e = Date.now();
|
|
4237
4216
|
if (e < this.burstBackoffUntil)
|
|
4238
4217
|
return !1;
|
|
4239
|
-
if (e - this.burstWindowStart >
|
|
4240
|
-
return this.burstBackoffUntil = e +
|
|
4218
|
+
if (e - this.burstWindowStart > ft && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > mt)
|
|
4219
|
+
return this.burstBackoffUntil = e + Ce, a("warn", "Error burst detected - entering cooldown", {
|
|
4241
4220
|
data: {
|
|
4242
4221
|
errorsInWindow: this.errorBurstCounter,
|
|
4243
|
-
cooldownMs:
|
|
4222
|
+
cooldownMs: Ce
|
|
4244
4223
|
}
|
|
4245
4224
|
}), !1;
|
|
4246
|
-
const r = this.get("config")?.errorSampling ??
|
|
4225
|
+
const r = this.get("config")?.errorSampling ?? Be;
|
|
4247
4226
|
return Math.random() < r;
|
|
4248
4227
|
}
|
|
4249
4228
|
handleError = (e) => {
|
|
@@ -4287,8 +4266,8 @@ class Yt extends p {
|
|
|
4287
4266
|
}
|
|
4288
4267
|
}
|
|
4289
4268
|
sanitize(e) {
|
|
4290
|
-
let t = e.length >
|
|
4291
|
-
for (const r of
|
|
4269
|
+
let t = e.length > Me ? e.slice(0, Me) + "..." : e;
|
|
4270
|
+
for (const r of $e) {
|
|
4292
4271
|
const s = new RegExp(r.source, r.flags);
|
|
4293
4272
|
t = t.replace(s, "[REDACTED]");
|
|
4294
4273
|
}
|
|
@@ -4296,12 +4275,12 @@ class Yt extends p {
|
|
|
4296
4275
|
}
|
|
4297
4276
|
shouldSuppressError(e, t) {
|
|
4298
4277
|
const r = Date.now(), s = `${e}:${t}`, i = this.recentErrors.get(s);
|
|
4299
|
-
return i && r - i <
|
|
4278
|
+
return i && r - i < Le ? (this.recentErrors.set(s, r), !0) : (this.recentErrors.set(s, r), this.recentErrors.size > ht ? (this.recentErrors.clear(), this.recentErrors.set(s, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4300
4279
|
}
|
|
4301
4280
|
pruneOldErrors() {
|
|
4302
4281
|
const e = Date.now();
|
|
4303
4282
|
for (const [s, i] of this.recentErrors.entries())
|
|
4304
|
-
e - i >
|
|
4283
|
+
e - i > Le && this.recentErrors.delete(s);
|
|
4305
4284
|
if (this.recentErrors.size <= Q)
|
|
4306
4285
|
return;
|
|
4307
4286
|
const t = Array.from(this.recentErrors.entries()).sort((s, i) => s[1] - i[1]), r = this.recentErrors.size - Q;
|
|
@@ -4311,10 +4290,10 @@ class Yt extends p {
|
|
|
4311
4290
|
}
|
|
4312
4291
|
}
|
|
4313
4292
|
}
|
|
4314
|
-
class
|
|
4293
|
+
class Yt extends p {
|
|
4315
4294
|
isInitialized = !1;
|
|
4316
4295
|
suppressNextScrollTimer = null;
|
|
4317
|
-
emitter = new
|
|
4296
|
+
emitter = new Vt();
|
|
4318
4297
|
transformers = {};
|
|
4319
4298
|
managers = {};
|
|
4320
4299
|
handlers = {};
|
|
@@ -4332,7 +4311,7 @@ class qt extends p {
|
|
|
4332
4311
|
if (!this.isInitialized) {
|
|
4333
4312
|
this.managers.storage = new zt();
|
|
4334
4313
|
try {
|
|
4335
|
-
this.setupState(e), this.managers.event = new
|
|
4314
|
+
this.setupState(e), this.managers.event = new xt(this.managers.storage, this.emitter, this.transformers), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
4336
4315
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
4337
4316
|
}), this.isInitialized = !0;
|
|
4338
4317
|
} catch (t) {
|
|
@@ -4356,9 +4335,9 @@ class qt extends p {
|
|
|
4356
4335
|
}
|
|
4357
4336
|
let r = t;
|
|
4358
4337
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
4359
|
-
const { valid: s, error: i, sanitizedMetadata: o } =
|
|
4338
|
+
const { valid: s, error: i, sanitizedMetadata: o } = Dt(e, r);
|
|
4360
4339
|
if (!s) {
|
|
4361
|
-
if (this.get("mode") ===
|
|
4340
|
+
if (this.get("mode") === j.QA)
|
|
4362
4341
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
|
|
4363
4342
|
return;
|
|
4364
4343
|
}
|
|
@@ -4404,15 +4383,15 @@ class qt extends p {
|
|
|
4404
4383
|
}
|
|
4405
4384
|
setupState(e = {}) {
|
|
4406
4385
|
this.set("config", e);
|
|
4407
|
-
const t =
|
|
4386
|
+
const t = Ht.getId(this.managers.storage);
|
|
4408
4387
|
this.set("userId", t);
|
|
4409
|
-
const r =
|
|
4388
|
+
const r = bt(e);
|
|
4410
4389
|
this.set("collectApiUrls", r);
|
|
4411
|
-
const s =
|
|
4390
|
+
const s = dt();
|
|
4412
4391
|
this.set("device", s);
|
|
4413
4392
|
const i = ae(window.location.href, e.sensitiveQueryParams);
|
|
4414
4393
|
this.set("pageUrl", i);
|
|
4415
|
-
const o = It() ?
|
|
4394
|
+
const o = It() ? j.QA : void 0;
|
|
4416
4395
|
o && this.set("mode", o);
|
|
4417
4396
|
}
|
|
4418
4397
|
/**
|
|
@@ -4455,7 +4434,7 @@ class qt extends p {
|
|
|
4455
4434
|
valid: !1,
|
|
4456
4435
|
error: "Global metadata must be a plain object"
|
|
4457
4436
|
};
|
|
4458
|
-
const t =
|
|
4437
|
+
const t = Xe("Global", e, "globalMetadata");
|
|
4459
4438
|
return t.valid ? { valid: !0 } : {
|
|
4460
4439
|
valid: !1,
|
|
4461
4440
|
error: t.error
|
|
@@ -4499,34 +4478,34 @@ class qt extends p {
|
|
|
4499
4478
|
this.set("config", o), a("debug", "Global metadata updated (merged)", { data: { keys: Object.keys(e) } });
|
|
4500
4479
|
}
|
|
4501
4480
|
initializeHandlers() {
|
|
4502
|
-
const e = this.get("config")
|
|
4503
|
-
this.handlers.session = new
|
|
4481
|
+
const e = this.get("config");
|
|
4482
|
+
this.handlers.session = new Bt(
|
|
4504
4483
|
this.managers.storage,
|
|
4505
4484
|
this.managers.event
|
|
4506
4485
|
), this.handlers.session.startTracking();
|
|
4507
|
-
const
|
|
4486
|
+
const t = () => {
|
|
4508
4487
|
this.set("suppressNextScroll", !0), this.suppressNextScrollTimer && clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = window.setTimeout(() => {
|
|
4509
4488
|
this.set("suppressNextScroll", !1);
|
|
4510
4489
|
}, 500);
|
|
4511
4490
|
};
|
|
4512
|
-
this.handlers.pageView = new
|
|
4513
|
-
a("warn", "Failed to start performance tracking", { error:
|
|
4514
|
-
})
|
|
4491
|
+
this.handlers.pageView = new Wt(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new Gt(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new Xt(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new jt(this.managers.event), this.handlers.performance.startTracking().catch((r) => {
|
|
4492
|
+
a("warn", "Failed to start performance tracking", { error: r });
|
|
4493
|
+
}), this.handlers.error = new Kt(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new Qt(this.managers.event), this.handlers.viewport.startTracking());
|
|
4515
4494
|
}
|
|
4516
4495
|
}
|
|
4517
|
-
const C = [],
|
|
4496
|
+
const C = [], b = [];
|
|
4518
4497
|
let f = null, L = !1, _ = !1;
|
|
4519
|
-
const
|
|
4498
|
+
const qt = async (n) => {
|
|
4520
4499
|
if (!(typeof window > "u" || typeof document > "u") && (_ = !1, window.__traceLogDisabled !== !0 && !f && !L)) {
|
|
4521
4500
|
L = !0;
|
|
4522
4501
|
try {
|
|
4523
|
-
const e =
|
|
4502
|
+
const e = Nt(n ?? {}), t = new Yt();
|
|
4524
4503
|
try {
|
|
4525
4504
|
C.forEach(({ event: i, callback: o }) => {
|
|
4526
4505
|
t.on(i, o);
|
|
4527
|
-
}), C.length = 0,
|
|
4506
|
+
}), C.length = 0, b.forEach(({ hook: i, fn: o }) => {
|
|
4528
4507
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4529
|
-
}),
|
|
4508
|
+
}), b.length = 0;
|
|
4530
4509
|
const r = t.init(e), s = new Promise((i, o) => {
|
|
4531
4510
|
setTimeout(() => {
|
|
4532
4511
|
o(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -4547,7 +4526,7 @@ const Jt = async (n) => {
|
|
|
4547
4526
|
L = !1;
|
|
4548
4527
|
}
|
|
4549
4528
|
}
|
|
4550
|
-
},
|
|
4529
|
+
}, Jt = (n, e) => {
|
|
4551
4530
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4552
4531
|
if (!f)
|
|
4553
4532
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4555,7 +4534,7 @@ const Jt = async (n) => {
|
|
|
4555
4534
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4556
4535
|
f.sendCustomEvent(n, e);
|
|
4557
4536
|
}
|
|
4558
|
-
},
|
|
4537
|
+
}, Zt = (n, e) => {
|
|
4559
4538
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4560
4539
|
if (!f || L) {
|
|
4561
4540
|
C.push({ event: n, callback: e });
|
|
@@ -4563,7 +4542,7 @@ const Jt = async (n) => {
|
|
|
4563
4542
|
}
|
|
4564
4543
|
f.on(n, e);
|
|
4565
4544
|
}
|
|
4566
|
-
},
|
|
4545
|
+
}, er = (n, e) => {
|
|
4567
4546
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4568
4547
|
if (!f) {
|
|
4569
4548
|
const t = C.findIndex((r) => r.event === n && r.callback === e);
|
|
@@ -4573,13 +4552,13 @@ const Jt = async (n) => {
|
|
|
4573
4552
|
f.off(n, e);
|
|
4574
4553
|
}
|
|
4575
4554
|
};
|
|
4576
|
-
function
|
|
4555
|
+
function tr(n, e) {
|
|
4577
4556
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4578
4557
|
if (typeof e != "function")
|
|
4579
4558
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4580
4559
|
if (!f || L) {
|
|
4581
|
-
const t =
|
|
4582
|
-
t !== -1 &&
|
|
4560
|
+
const t = b.findIndex((r) => r.hook === n);
|
|
4561
|
+
t !== -1 && b.splice(t, 1), b.push({ hook: n, fn: e });
|
|
4583
4562
|
return;
|
|
4584
4563
|
}
|
|
4585
4564
|
if (_)
|
|
@@ -4587,18 +4566,18 @@ function rr(n, e) {
|
|
|
4587
4566
|
n === "beforeSend" ? f.setTransformer("beforeSend", e) : f.setTransformer("beforeBatch", e);
|
|
4588
4567
|
}
|
|
4589
4568
|
}
|
|
4590
|
-
const
|
|
4569
|
+
const rr = (n) => {
|
|
4591
4570
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4592
4571
|
if (!f) {
|
|
4593
|
-
const e =
|
|
4594
|
-
e !== -1 &&
|
|
4572
|
+
const e = b.findIndex((t) => t.hook === n);
|
|
4573
|
+
e !== -1 && b.splice(e, 1);
|
|
4595
4574
|
return;
|
|
4596
4575
|
}
|
|
4597
4576
|
if (_)
|
|
4598
4577
|
throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
|
|
4599
4578
|
f.removeTransformer(n);
|
|
4600
4579
|
}
|
|
4601
|
-
},
|
|
4580
|
+
}, nr = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, sr = () => {
|
|
4602
4581
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4603
4582
|
if (_)
|
|
4604
4583
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4608,14 +4587,14 @@ const nr = (n) => {
|
|
|
4608
4587
|
}
|
|
4609
4588
|
_ = !0;
|
|
4610
4589
|
try {
|
|
4611
|
-
f.destroy(), f = null, L = !1, C.length = 0,
|
|
4590
|
+
f.destroy(), f = null, L = !1, C.length = 0, b.length = 0, _ = !1;
|
|
4612
4591
|
} catch (n) {
|
|
4613
|
-
f = null, L = !1, C.length = 0,
|
|
4592
|
+
f = null, L = !1, C.length = 0, b.length = 0, _ = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4614
4593
|
}
|
|
4615
4594
|
}
|
|
4595
|
+
}, ir = (n) => {
|
|
4596
|
+
typeof window > "u" || typeof document > "u" || vt(n);
|
|
4616
4597
|
}, or = (n) => {
|
|
4617
|
-
typeof window > "u" || typeof document > "u" || wt(n);
|
|
4618
|
-
}, ar = (n) => {
|
|
4619
4598
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4620
4599
|
if (!f)
|
|
4621
4600
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4623,7 +4602,7 @@ const nr = (n) => {
|
|
|
4623
4602
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4624
4603
|
f.updateGlobalMetadata(n);
|
|
4625
4604
|
}
|
|
4626
|
-
},
|
|
4605
|
+
}, ar = (n) => {
|
|
4627
4606
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4628
4607
|
if (!f)
|
|
4629
4608
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4631,22 +4610,22 @@ const nr = (n) => {
|
|
|
4631
4610
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
4632
4611
|
f.mergeGlobalMetadata(n);
|
|
4633
4612
|
}
|
|
4634
|
-
},
|
|
4635
|
-
init:
|
|
4636
|
-
event:
|
|
4637
|
-
on:
|
|
4638
|
-
off:
|
|
4639
|
-
setTransformer:
|
|
4640
|
-
removeTransformer:
|
|
4641
|
-
isInitialized:
|
|
4642
|
-
destroy:
|
|
4643
|
-
setQaMode:
|
|
4644
|
-
updateGlobalMetadata:
|
|
4645
|
-
mergeGlobalMetadata:
|
|
4613
|
+
}, Dr = {
|
|
4614
|
+
init: qt,
|
|
4615
|
+
event: Jt,
|
|
4616
|
+
on: Zt,
|
|
4617
|
+
off: er,
|
|
4618
|
+
setTransformer: tr,
|
|
4619
|
+
removeTransformer: rr,
|
|
4620
|
+
isInitialized: nr,
|
|
4621
|
+
destroy: sr,
|
|
4622
|
+
setQaMode: ir,
|
|
4623
|
+
updateGlobalMetadata: or,
|
|
4624
|
+
mergeGlobalMetadata: ar
|
|
4646
4625
|
};
|
|
4647
|
-
var ce,
|
|
4626
|
+
var ce, je = -1, O = function(n) {
|
|
4648
4627
|
addEventListener("pageshow", (function(e) {
|
|
4649
|
-
e.persisted && (
|
|
4628
|
+
e.persisted && (je = e.timeStamp, n(e));
|
|
4650
4629
|
}), !0);
|
|
4651
4630
|
}, ge = function() {
|
|
4652
4631
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
@@ -4656,7 +4635,7 @@ var ce, Ke = -1, O = function(n) {
|
|
|
4656
4635
|
return n && n.activationStart || 0;
|
|
4657
4636
|
}, y = function(n, e) {
|
|
4658
4637
|
var t = ge(), r = "navigate";
|
|
4659
|
-
return
|
|
4638
|
+
return je >= 0 ? r = "back-forward-cache" : t && (document.prerendering || Y() > 0 ? r = "prerender" : document.wasDiscarded ? r = "restore" : t.type && (r = t.type.replace(/_/g, "-"))), { name: n, 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 };
|
|
4660
4639
|
}, x = function(n, e, t) {
|
|
4661
4640
|
try {
|
|
4662
4641
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
@@ -4669,7 +4648,7 @@ var ce, Ke = -1, O = function(n) {
|
|
|
4669
4648
|
}
|
|
4670
4649
|
} catch {
|
|
4671
4650
|
}
|
|
4672
|
-
},
|
|
4651
|
+
}, A = function(n, e, t, r) {
|
|
4673
4652
|
var s, i;
|
|
4674
4653
|
return function(o) {
|
|
4675
4654
|
e.value >= 0 && (o || r) && ((i = e.value - (s || 0)) || s === void 0) && (s = e.value, e.delta = i, e.rating = (function(l, c) {
|
|
@@ -4691,18 +4670,18 @@ var ce, Ke = -1, O = function(n) {
|
|
|
4691
4670
|
return function() {
|
|
4692
4671
|
e || (n(), e = !0);
|
|
4693
4672
|
};
|
|
4694
|
-
}, N = -1,
|
|
4673
|
+
}, N = -1, ke = function() {
|
|
4695
4674
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4696
4675
|
}, K = function(n) {
|
|
4697
|
-
document.visibilityState === "hidden" && N > -1 && (N = n.type === "visibilitychange" ? n.timeStamp : 0,
|
|
4698
|
-
},
|
|
4676
|
+
document.visibilityState === "hidden" && N > -1 && (N = n.type === "visibilitychange" ? n.timeStamp : 0, lr());
|
|
4677
|
+
}, Ue = function() {
|
|
4699
4678
|
addEventListener("visibilitychange", K, !0), addEventListener("prerenderingchange", K, !0);
|
|
4700
|
-
},
|
|
4679
|
+
}, lr = function() {
|
|
4701
4680
|
removeEventListener("visibilitychange", K, !0), removeEventListener("prerenderingchange", K, !0);
|
|
4702
|
-
},
|
|
4703
|
-
return N < 0 && (N =
|
|
4681
|
+
}, Ke = function() {
|
|
4682
|
+
return N < 0 && (N = ke(), Ue(), O((function() {
|
|
4704
4683
|
setTimeout((function() {
|
|
4705
|
-
N =
|
|
4684
|
+
N = ke(), Ue();
|
|
4706
4685
|
}), 0);
|
|
4707
4686
|
}))), { get firstHiddenTime() {
|
|
4708
4687
|
return N;
|
|
@@ -4711,21 +4690,21 @@ var ce, Ke = -1, O = function(n) {
|
|
|
4711
4690
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4712
4691
|
return n();
|
|
4713
4692
|
}), !0) : n();
|
|
4714
|
-
}, ue = [1800, 3e3],
|
|
4693
|
+
}, ue = [1800, 3e3], Ye = function(n, e) {
|
|
4715
4694
|
e = e || {}, J((function() {
|
|
4716
|
-
var t, r =
|
|
4695
|
+
var t, r = Ke(), s = y("FCP"), i = x("paint", (function(o) {
|
|
4717
4696
|
o.forEach((function(l) {
|
|
4718
4697
|
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (s.value = Math.max(l.startTime - Y(), 0), s.entries.push(l), t(!0)));
|
|
4719
4698
|
}));
|
|
4720
4699
|
}));
|
|
4721
|
-
i && (t =
|
|
4722
|
-
s = y("FCP"), t =
|
|
4700
|
+
i && (t = A(n, s, ue, e.reportAllChanges), O((function(o) {
|
|
4701
|
+
s = y("FCP"), t = A(n, s, ue, e.reportAllChanges), Ee((function() {
|
|
4723
4702
|
s.value = performance.now() - o.timeStamp, t(!0);
|
|
4724
4703
|
}));
|
|
4725
4704
|
})));
|
|
4726
4705
|
}));
|
|
4727
|
-
}, de = [0.1, 0.25],
|
|
4728
|
-
e = e || {},
|
|
4706
|
+
}, de = [0.1, 0.25], cr = function(n, e) {
|
|
4707
|
+
e = e || {}, Ye(Se((function() {
|
|
4729
4708
|
var t, r = y("CLS", 0), s = 0, i = [], o = function(c) {
|
|
4730
4709
|
c.forEach((function(d) {
|
|
4731
4710
|
if (!d.hadRecentInput) {
|
|
@@ -4734,147 +4713,147 @@ var ce, Ke = -1, O = function(n) {
|
|
|
4734
4713
|
}
|
|
4735
4714
|
})), s > r.value && (r.value = s, r.entries = i, t());
|
|
4736
4715
|
}, l = x("layout-shift", o);
|
|
4737
|
-
l && (t =
|
|
4716
|
+
l && (t = A(n, r, de, e.reportAllChanges), q((function() {
|
|
4738
4717
|
o(l.takeRecords()), t(!0);
|
|
4739
4718
|
})), O((function() {
|
|
4740
|
-
s = 0, r = y("CLS", 0), t =
|
|
4719
|
+
s = 0, r = y("CLS", 0), t = A(n, r, de, e.reportAllChanges), Ee((function() {
|
|
4741
4720
|
return t();
|
|
4742
4721
|
}));
|
|
4743
4722
|
})), setTimeout(t, 0));
|
|
4744
4723
|
})));
|
|
4745
|
-
},
|
|
4724
|
+
}, qe = 0, te = 1 / 0, G = 0, ur = function(n) {
|
|
4746
4725
|
n.forEach((function(e) {
|
|
4747
|
-
e.interactionId && (te = Math.min(te, e.interactionId), G = Math.max(G, e.interactionId),
|
|
4726
|
+
e.interactionId && (te = Math.min(te, e.interactionId), G = Math.max(G, e.interactionId), qe = G ? (G - te) / 7 + 1 : 0);
|
|
4748
4727
|
}));
|
|
4749
|
-
},
|
|
4750
|
-
return ce ?
|
|
4751
|
-
},
|
|
4752
|
-
"interactionCount" in performance || ce || (ce = x("event",
|
|
4753
|
-
}, w = [],
|
|
4754
|
-
var n = Math.min(w.length - 1, Math.floor((
|
|
4728
|
+
}, Je = function() {
|
|
4729
|
+
return ce ? qe : performance.interactionCount || 0;
|
|
4730
|
+
}, dr = function() {
|
|
4731
|
+
"interactionCount" in performance || ce || (ce = x("event", ur, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4732
|
+
}, w = [], z = /* @__PURE__ */ new Map(), Ze = 0, hr = function() {
|
|
4733
|
+
var n = Math.min(w.length - 1, Math.floor((Je() - Ze) / 50));
|
|
4755
4734
|
return w[n];
|
|
4756
|
-
},
|
|
4757
|
-
if (
|
|
4735
|
+
}, fr = [], mr = function(n) {
|
|
4736
|
+
if (fr.forEach((function(s) {
|
|
4758
4737
|
return s(n);
|
|
4759
4738
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4760
|
-
var e = w[w.length - 1], t =
|
|
4739
|
+
var e = w[w.length - 1], t = z.get(n.interactionId);
|
|
4761
4740
|
if (t || w.length < 10 || n.duration > e.latency) {
|
|
4762
4741
|
if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
|
|
4763
4742
|
else {
|
|
4764
4743
|
var r = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4765
|
-
|
|
4744
|
+
z.set(r.id, r), w.push(r);
|
|
4766
4745
|
}
|
|
4767
4746
|
w.sort((function(s, i) {
|
|
4768
4747
|
return i.latency - s.latency;
|
|
4769
4748
|
})), w.length > 10 && w.splice(10).forEach((function(s) {
|
|
4770
|
-
return
|
|
4749
|
+
return z.delete(s.id);
|
|
4771
4750
|
}));
|
|
4772
4751
|
}
|
|
4773
4752
|
}
|
|
4774
|
-
},
|
|
4753
|
+
}, et = function(n) {
|
|
4775
4754
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4776
4755
|
return n = Se(n), document.visibilityState === "hidden" ? n() : (t = e(n), q(n)), t;
|
|
4777
|
-
}, he = [200, 500],
|
|
4756
|
+
}, he = [200, 500], gr = function(n, e) {
|
|
4778
4757
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, J((function() {
|
|
4779
4758
|
var t;
|
|
4780
|
-
|
|
4759
|
+
dr();
|
|
4781
4760
|
var r, s = y("INP"), i = function(l) {
|
|
4782
|
-
|
|
4783
|
-
l.forEach(
|
|
4784
|
-
var c =
|
|
4761
|
+
et((function() {
|
|
4762
|
+
l.forEach(mr);
|
|
4763
|
+
var c = hr();
|
|
4785
4764
|
c && c.latency !== s.value && (s.value = c.latency, s.entries = c.entries, r());
|
|
4786
4765
|
}));
|
|
4787
4766
|
}, o = x("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4788
|
-
r =
|
|
4767
|
+
r = A(n, s, he, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), q((function() {
|
|
4789
4768
|
i(o.takeRecords()), r(!0);
|
|
4790
4769
|
})), O((function() {
|
|
4791
|
-
|
|
4770
|
+
Ze = Je(), w.length = 0, z.clear(), s = y("INP"), r = A(n, s, he, e.reportAllChanges);
|
|
4792
4771
|
})));
|
|
4793
4772
|
})));
|
|
4794
|
-
}, fe = [2500, 4e3], re = {},
|
|
4773
|
+
}, fe = [2500, 4e3], re = {}, Er = function(n, e) {
|
|
4795
4774
|
e = e || {}, J((function() {
|
|
4796
|
-
var t, r =
|
|
4775
|
+
var t, r = Ke(), s = y("LCP"), i = function(c) {
|
|
4797
4776
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
|
|
4798
4777
|
d.startTime < r.firstHiddenTime && (s.value = Math.max(d.startTime - Y(), 0), s.entries = [d], t());
|
|
4799
4778
|
}));
|
|
4800
4779
|
}, o = x("largest-contentful-paint", i);
|
|
4801
4780
|
if (o) {
|
|
4802
|
-
t =
|
|
4781
|
+
t = A(n, s, fe, e.reportAllChanges);
|
|
4803
4782
|
var l = Se((function() {
|
|
4804
4783
|
re[s.id] || (i(o.takeRecords()), o.disconnect(), re[s.id] = !0, t(!0));
|
|
4805
4784
|
}));
|
|
4806
4785
|
["keydown", "click"].forEach((function(c) {
|
|
4807
4786
|
addEventListener(c, (function() {
|
|
4808
|
-
return
|
|
4787
|
+
return et(l);
|
|
4809
4788
|
}), { once: !0, capture: !0 });
|
|
4810
4789
|
})), q(l), O((function(c) {
|
|
4811
|
-
s = y("LCP"), t =
|
|
4790
|
+
s = y("LCP"), t = A(n, s, fe, e.reportAllChanges), Ee((function() {
|
|
4812
4791
|
s.value = performance.now() - c.timeStamp, re[s.id] = !0, t(!0);
|
|
4813
4792
|
}));
|
|
4814
4793
|
}));
|
|
4815
4794
|
}
|
|
4816
4795
|
}));
|
|
4817
|
-
}, me = [800, 1800],
|
|
4796
|
+
}, me = [800, 1800], Sr = function n(e) {
|
|
4818
4797
|
document.prerendering ? J((function() {
|
|
4819
4798
|
return n(e);
|
|
4820
4799
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4821
4800
|
return n(e);
|
|
4822
4801
|
}), !0) : setTimeout(e, 0);
|
|
4823
|
-
},
|
|
4802
|
+
}, pr = function(n, e) {
|
|
4824
4803
|
e = e || {};
|
|
4825
|
-
var t = y("TTFB"), r =
|
|
4826
|
-
|
|
4804
|
+
var t = y("TTFB"), r = A(n, t, me, e.reportAllChanges);
|
|
4805
|
+
Sr((function() {
|
|
4827
4806
|
var s = ge();
|
|
4828
4807
|
s && (t.value = Math.max(s.responseStart - Y(), 0), t.entries = [s], r(!0), O((function() {
|
|
4829
|
-
t = y("TTFB", 0), (r =
|
|
4808
|
+
t = y("TTFB", 0), (r = A(n, t, me, e.reportAllChanges))(!0);
|
|
4830
4809
|
})));
|
|
4831
4810
|
}));
|
|
4832
4811
|
};
|
|
4833
|
-
const
|
|
4812
|
+
const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4834
4813
|
__proto__: null,
|
|
4835
4814
|
CLSThresholds: de,
|
|
4836
4815
|
FCPThresholds: ue,
|
|
4837
4816
|
INPThresholds: he,
|
|
4838
4817
|
LCPThresholds: fe,
|
|
4839
4818
|
TTFBThresholds: me,
|
|
4840
|
-
onCLS:
|
|
4841
|
-
onFCP:
|
|
4842
|
-
onINP:
|
|
4843
|
-
onLCP:
|
|
4844
|
-
onTTFB:
|
|
4819
|
+
onCLS: cr,
|
|
4820
|
+
onFCP: Ye,
|
|
4821
|
+
onINP: gr,
|
|
4822
|
+
onLCP: Er,
|
|
4823
|
+
onTTFB: pr
|
|
4845
4824
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4846
4825
|
export {
|
|
4847
4826
|
h as AppConfigValidationError,
|
|
4848
|
-
|
|
4827
|
+
_r as DEFAULT_SESSION_TIMEOUT,
|
|
4849
4828
|
oe as DEFAULT_WEB_VITALS_MODE,
|
|
4850
4829
|
M as DeviceType,
|
|
4851
4830
|
ne as EmitterEvent,
|
|
4852
4831
|
V as ErrorType,
|
|
4853
4832
|
u as EventType,
|
|
4854
|
-
|
|
4833
|
+
Or as InitializationTimeoutError,
|
|
4855
4834
|
P as IntegrationValidationError,
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4835
|
+
Cr as MAX_ARRAY_LENGTH,
|
|
4836
|
+
yr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4837
|
+
wr as MAX_CUSTOM_EVENT_KEYS,
|
|
4859
4838
|
Ir as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4860
|
-
|
|
4861
|
-
|
|
4839
|
+
vr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4840
|
+
br as MAX_METADATA_NESTING_DEPTH,
|
|
4862
4841
|
Ar as MAX_NESTED_OBJECT_KEYS,
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4842
|
+
Mr as MAX_STRING_LENGTH,
|
|
4843
|
+
Lr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4844
|
+
j as Mode,
|
|
4845
|
+
$e as PII_PATTERNS,
|
|
4867
4846
|
R as PermanentError,
|
|
4868
|
-
|
|
4847
|
+
be as SamplingRateValidationError,
|
|
4869
4848
|
X as ScrollDirection,
|
|
4870
|
-
|
|
4849
|
+
lt as SessionTimeoutValidationError,
|
|
4871
4850
|
D as SpecialApiUrl,
|
|
4872
4851
|
U as TraceLogValidationError,
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4852
|
+
Pr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4853
|
+
Re as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4854
|
+
Et as WEB_VITALS_POOR_THRESHOLDS,
|
|
4855
|
+
Ne as getWebVitalsThresholds,
|
|
4856
|
+
Rr as isPrimaryScrollEvent,
|
|
4857
|
+
Nr as isSecondaryScrollEvent,
|
|
4858
|
+
Dr as tracelog
|
|
4880
4859
|
};
|