@tracelog/lib 2.1.1-rc.75.2 → 2.1.1-rc.76.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.
Potentially problematic release.
This version of @tracelog/lib might be problematic. Click here for more details.
- package/dist/browser/tracelog.esm.js +202 -153
- 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 +6127 -6782
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.js +6095 -6782
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Vr = 9e5;
|
|
2
2
|
const Ur = 120, xr = 8192, Hr = 10, Fr = 10, $r = 20, Br = 1;
|
|
3
3
|
const Wr = 1e3, Gr = 500, Xr = 100;
|
|
4
4
|
const w = "data-tlog", ot = [
|
|
@@ -78,8 +78,8 @@ const m = {
|
|
|
78
78
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
79
79
|
/<embed\b[^>]*>/gi,
|
|
80
80
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
81
|
-
], I = "tlog", x = `${I}:qa_mode`,
|
|
82
|
-
var
|
|
81
|
+
], I = "tlog", x = `${I}:qa_mode`, Ie = `${I}:uid`, $e = "tlog_mode", we = "qa", ye = "qa_off", ut = (s) => s ? `${I}:${s}:queue` : `${I}:queue`, dt = (s) => s ? `${I}:${s}:session` : `${I}:session`, ht = (s) => s ? `${I}:${s}:broadcast` : `${I}:broadcast`, be = (s, e) => `${I}:${s}:session_counts:${e}`, Ae = 10080 * 60 * 1e3, Le = `${I}:session_counts_last_cleanup`, Me = 3600 * 1e3;
|
|
82
|
+
var V = /* @__PURE__ */ ((s) => (s.Localhost = "localhost:8080", s.Fail = "localhost:9999", s))(V || {}), L = /* @__PURE__ */ ((s) => (s.Mobile = "mobile", s.Tablet = "tablet", s.Desktop = "desktop", s.Unknown = "unknown", s))(L || {}), oe = /* @__PURE__ */ ((s) => (s.EVENT = "event", s.QUEUE = "queue", s))(oe || {});
|
|
83
83
|
class N extends Error {
|
|
84
84
|
constructor(e, t) {
|
|
85
85
|
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
@@ -102,12 +102,12 @@ class ft extends H {
|
|
|
102
102
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
class
|
|
105
|
+
class Re extends H {
|
|
106
106
|
constructor(e, t = "config") {
|
|
107
107
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
class
|
|
110
|
+
class k extends H {
|
|
111
111
|
constructor(e, t = "config") {
|
|
112
112
|
super(e, "INTEGRATION_INVALID", t);
|
|
113
113
|
}
|
|
@@ -148,12 +148,12 @@ const Be = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
148
148
|
const { error: r, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = r ? gt(e, r) : `[TraceLog] ${e}`, u = s === "error" ? "error" : s === "warn" ? "warn" : "log";
|
|
149
149
|
if (!St(l, i))
|
|
150
150
|
return;
|
|
151
|
-
const g = pt(l, o), p = n !== void 0 ?
|
|
151
|
+
const g = pt(l, o), p = n !== void 0 ? ae(n) : void 0;
|
|
152
152
|
Tt(u, c, g, p);
|
|
153
153
|
}, St = (s, e) => s === "critical" ? !0 : s === "qa" || e ? Et() : !1, pt = (s, e) => e !== void 0 && e !== "" ? e : s === "critical" ? mt : "", Tt = (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
|
+
}, ae = (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,15 +161,15 @@ 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] = ae(n) : Array.isArray(n) ? e[r] = n.map(
|
|
165
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ae(o) : o
|
|
166
166
|
) : e[r] = n;
|
|
167
167
|
}
|
|
168
168
|
return e;
|
|
169
169
|
};
|
|
170
|
-
let
|
|
170
|
+
let le, Ge;
|
|
171
171
|
const _t = () => {
|
|
172
|
-
typeof window < "u" && !
|
|
172
|
+
typeof window < "u" && !le && (le = window.matchMedia("(pointer: coarse)"), Ge = window.matchMedia("(hover: none)"));
|
|
173
173
|
}, K = "Unknown", vt = (s) => {
|
|
174
174
|
const e = s.userAgentData?.platform;
|
|
175
175
|
if (e != null && e !== "") {
|
|
@@ -201,7 +201,7 @@ const _t = () => {
|
|
|
201
201
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : s.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
202
202
|
}
|
|
203
203
|
_t();
|
|
204
|
-
const e = window.innerWidth, t =
|
|
204
|
+
const e = window.innerWidth, t = le?.matches ?? !1, r = Ge?.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
205
|
return e <= 767 || o && n ? L.Mobile : e >= 768 && e <= 1024 || l || t && r && n ? L.Tablet : L.Desktop;
|
|
206
206
|
} catch (s) {
|
|
207
207
|
return a("debug", "Device detection failed, defaulting to desktop", { error: s }), L.Desktop;
|
|
@@ -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
|
+
], Ce = 500, Ne = 5e3, Q = 50, bt = Q * 2, Qe = 1, At = 1e3, Lt = 10, Oe = 5e3, Mt = 6e4, Kr = {
|
|
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
|
+
}, Pe = {
|
|
252
252
|
LCP: 2500,
|
|
253
253
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
254
254
|
FCP: 1800,
|
|
@@ -260,7 +260,7 @@ const _t = () => {
|
|
|
260
260
|
TTFB: 800,
|
|
261
261
|
// Needs improvement: > 800ms
|
|
262
262
|
LONG_TASK: 50
|
|
263
|
-
},
|
|
263
|
+
}, Rt = {
|
|
264
264
|
LCP: 4e3,
|
|
265
265
|
// Poor: > 4s
|
|
266
266
|
FCP: 3e3,
|
|
@@ -272,19 +272,19 @@ const _t = () => {
|
|
|
272
272
|
TTFB: 1800,
|
|
273
273
|
// Poor: > 1800ms
|
|
274
274
|
LONG_TASK: 50
|
|
275
|
-
},
|
|
275
|
+
}, ce = "needs-improvement", De = (s = ce) => {
|
|
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 Pe;
|
|
282
282
|
case "poor":
|
|
283
|
-
return
|
|
283
|
+
return Rt;
|
|
284
284
|
default:
|
|
285
|
-
return
|
|
285
|
+
return Pe;
|
|
286
286
|
}
|
|
287
|
-
},
|
|
287
|
+
}, Ct = 1e3, Nt = 50, Ot = "2.1.1", Pt = Ot, je = () => typeof window < "u" && typeof sessionStorage < "u", Dt = () => {
|
|
288
288
|
try {
|
|
289
289
|
const s = new URLSearchParams(window.location.search);
|
|
290
290
|
s.delete($e);
|
|
@@ -292,23 +292,23 @@ const _t = () => {
|
|
|
292
292
|
window.history.replaceState({}, "", t);
|
|
293
293
|
} catch {
|
|
294
294
|
}
|
|
295
|
-
},
|
|
295
|
+
}, kt = () => {
|
|
296
296
|
if (!je())
|
|
297
297
|
return !1;
|
|
298
298
|
try {
|
|
299
299
|
const e = new URLSearchParams(window.location.search).get($e), t = sessionStorage.getItem(x);
|
|
300
300
|
let r = null;
|
|
301
|
-
return e ===
|
|
301
|
+
return e === we ? (r = !0, sessionStorage.setItem(x, "true"), a("info", "QA Mode ACTIVE", {
|
|
302
302
|
visibility: "qa",
|
|
303
303
|
style: Be
|
|
304
|
-
})) : e ===
|
|
304
|
+
})) : e === ye && (r = !1, sessionStorage.setItem(x, "false"), a("info", "QA Mode DISABLED", {
|
|
305
305
|
visibility: "qa",
|
|
306
306
|
style: We
|
|
307
|
-
})), (e ===
|
|
307
|
+
})), (e === we || e === ye) && Dt(), r ?? t === "true";
|
|
308
308
|
} catch {
|
|
309
309
|
return !1;
|
|
310
310
|
}
|
|
311
|
-
},
|
|
311
|
+
}, Vt = (s) => {
|
|
312
312
|
if (je())
|
|
313
313
|
try {
|
|
314
314
|
sessionStorage.setItem(x, s ? "true" : "false"), a("info", s ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
@@ -330,13 +330,13 @@ const _t = () => {
|
|
|
330
330
|
"co.in",
|
|
331
331
|
"com.cn",
|
|
332
332
|
"co.za"
|
|
333
|
-
],
|
|
333
|
+
], ke = (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
338
|
return Ut.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
339
|
-
}, xt = (s, e) => s === e ? !0 :
|
|
339
|
+
}, xt = (s, e) => s === e ? !0 : ke(s) === ke(e), te = () => {
|
|
340
340
|
const s = document.referrer;
|
|
341
341
|
if (!s)
|
|
342
342
|
return "Direct";
|
|
@@ -346,7 +346,7 @@ const _t = () => {
|
|
|
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
|
+
}, re = () => {
|
|
350
350
|
const s = new URLSearchParams(window.location.search), e = {};
|
|
351
351
|
return at.forEach((r) => {
|
|
352
352
|
const n = s.get(r);
|
|
@@ -415,7 +415,7 @@ const Ft = () => {
|
|
|
415
415
|
e.custom = t;
|
|
416
416
|
}
|
|
417
417
|
return e;
|
|
418
|
-
},
|
|
418
|
+
}, ue = (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 {
|
|
@@ -428,7 +428,7 @@ 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
|
+
}, Ve = (s) => {
|
|
432
432
|
if (!s || typeof s != "string" || s.trim().length === 0)
|
|
433
433
|
return "";
|
|
434
434
|
let e = s;
|
|
@@ -444,23 +444,23 @@ const Ft = () => {
|
|
|
444
444
|
valueLength: s.length
|
|
445
445
|
}
|
|
446
446
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
447
|
-
},
|
|
447
|
+
}, de = (s, e = 0) => {
|
|
448
448
|
if (e > 3 || s == null)
|
|
449
449
|
return null;
|
|
450
450
|
if (typeof s == "string")
|
|
451
|
-
return
|
|
451
|
+
return Ve(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
456
|
if (Array.isArray(s))
|
|
457
|
-
return s.slice(0, 100).map((n) =>
|
|
457
|
+
return s.slice(0, 100).map((n) => de(n, e + 1)).filter((n) => n !== null);
|
|
458
458
|
if (typeof s == "object") {
|
|
459
459
|
const t = {}, n = Object.entries(s).slice(0, 20);
|
|
460
460
|
for (const [i, o] of n) {
|
|
461
|
-
const l =
|
|
461
|
+
const l = Ve(i);
|
|
462
462
|
if (l) {
|
|
463
|
-
const c =
|
|
463
|
+
const c = de(o, e + 1);
|
|
464
464
|
c !== null && (t[l] = c);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
@@ -471,7 +471,7 @@ const Ft = () => {
|
|
|
471
471
|
if (typeof s != "object" || s === null)
|
|
472
472
|
return {};
|
|
473
473
|
try {
|
|
474
|
-
const e =
|
|
474
|
+
const e = de(s);
|
|
475
475
|
return typeof e == "object" && e !== null ? e : {};
|
|
476
476
|
} catch (e) {
|
|
477
477
|
const t = e instanceof Error ? e.message : String(e);
|
|
@@ -493,9 +493,9 @@ const Ft = () => {
|
|
|
493
493
|
throw new h("All sensitive query params must be strings", "config");
|
|
494
494
|
}
|
|
495
495
|
if (s.errorSampling !== void 0 && (typeof s.errorSampling != "number" || s.errorSampling < 0 || s.errorSampling > 1))
|
|
496
|
-
throw new
|
|
496
|
+
throw new Re(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
497
497
|
if (s.samplingRate !== void 0 && (typeof s.samplingRate != "number" || s.samplingRate < 0 || s.samplingRate > 1))
|
|
498
|
-
throw new
|
|
498
|
+
throw new Re(m.INVALID_SAMPLING_RATE, "config");
|
|
499
499
|
if (s.primaryScrollSelector !== void 0) {
|
|
500
500
|
if (typeof s.primaryScrollSelector != "string" || !s.primaryScrollSelector.trim())
|
|
501
501
|
throw new h(m.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
@@ -579,17 +579,17 @@ const Ft = () => {
|
|
|
579
579
|
}, Qt = (s) => {
|
|
580
580
|
if (s) {
|
|
581
581
|
if (s.tracelog && (!s.tracelog.projectId || typeof s.tracelog.projectId != "string" || s.tracelog.projectId.trim() === ""))
|
|
582
|
-
throw new
|
|
582
|
+
throw new k(m.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
583
583
|
if (s.custom) {
|
|
584
584
|
if (!s.custom.collectApiUrl || typeof s.custom.collectApiUrl != "string" || s.custom.collectApiUrl.trim() === "")
|
|
585
|
-
throw new
|
|
585
|
+
throw new k(m.INVALID_CUSTOM_API_URL, "config");
|
|
586
586
|
if (s.custom.allowHttp !== void 0 && typeof s.custom.allowHttp != "boolean")
|
|
587
|
-
throw new
|
|
587
|
+
throw new k("allowHttp must be a boolean", "config");
|
|
588
588
|
const e = s.custom.collectApiUrl.trim();
|
|
589
589
|
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
590
|
-
throw new
|
|
590
|
+
throw new k('Custom API URL must start with "http://" or "https://"', "config");
|
|
591
591
|
if (!(s.custom.allowHttp ?? !1) && e.startsWith("http://"))
|
|
592
|
-
throw new
|
|
592
|
+
throw new k(
|
|
593
593
|
"Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)",
|
|
594
594
|
"config"
|
|
595
595
|
);
|
|
@@ -914,7 +914,7 @@ function Je(s, e, t) {
|
|
|
914
914
|
}), s;
|
|
915
915
|
}
|
|
916
916
|
}
|
|
917
|
-
const
|
|
917
|
+
const se = {};
|
|
918
918
|
class _ {
|
|
919
919
|
/**
|
|
920
920
|
* Retrieves a value from global state.
|
|
@@ -933,7 +933,7 @@ class _ {
|
|
|
933
933
|
* ```
|
|
934
934
|
*/
|
|
935
935
|
get(e) {
|
|
936
|
-
return
|
|
936
|
+
return se[e];
|
|
937
937
|
}
|
|
938
938
|
/**
|
|
939
939
|
* Sets a value in global state.
|
|
@@ -953,7 +953,7 @@ class _ {
|
|
|
953
953
|
* ```
|
|
954
954
|
*/
|
|
955
955
|
set(e, t) {
|
|
956
|
-
|
|
956
|
+
se[e] = t;
|
|
957
957
|
}
|
|
958
958
|
/**
|
|
959
959
|
* Returns an immutable snapshot of the entire global state.
|
|
@@ -970,7 +970,7 @@ class _ {
|
|
|
970
970
|
* ```
|
|
971
971
|
*/
|
|
972
972
|
getState() {
|
|
973
|
-
return { ...
|
|
973
|
+
return { ...se };
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
976
|
class xe extends _ {
|
|
@@ -1039,13 +1039,13 @@ class xe extends _ {
|
|
|
1039
1039
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1040
1040
|
*/
|
|
1041
1041
|
sendEventsQueueSync(e) {
|
|
1042
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1042
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(V.Fail) ? (a(
|
|
1043
1043
|
"warn",
|
|
1044
1044
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1045
1045
|
{
|
|
1046
1046
|
data: { events: e.events.length }
|
|
1047
1047
|
}
|
|
1048
|
-
), !1) : this.apiUrl?.includes(
|
|
1048
|
+
), !1) : this.apiUrl?.includes(V.Localhost) ? (a(
|
|
1049
1049
|
"debug",
|
|
1050
1050
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1051
1051
|
{
|
|
@@ -1321,11 +1321,11 @@ class xe extends _ {
|
|
|
1321
1321
|
const r = this.applyBeforeBatchTransformer(t);
|
|
1322
1322
|
if (!r)
|
|
1323
1323
|
return !0;
|
|
1324
|
-
if (this.apiUrl?.includes(
|
|
1324
|
+
if (this.apiUrl?.includes(V.Fail))
|
|
1325
1325
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1326
1326
|
data: { events: r.events.length }
|
|
1327
1327
|
}), !1;
|
|
1328
|
-
if (this.apiUrl?.includes(
|
|
1328
|
+
if (this.apiUrl?.includes(V.Localhost))
|
|
1329
1329
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1330
1330
|
data: { events: r.events.length }
|
|
1331
1331
|
}), !0;
|
|
@@ -1972,7 +1972,7 @@ class er extends _ {
|
|
|
1972
1972
|
if (!this.checkPerEventRateLimit(o.name, T))
|
|
1973
1973
|
return;
|
|
1974
1974
|
}
|
|
1975
|
-
const
|
|
1975
|
+
const ve = E === d.SESSION_START, $ = t || this.get("pageUrl"), D = this.buildEventPayload({
|
|
1976
1976
|
type: E,
|
|
1977
1977
|
page_url: $,
|
|
1978
1978
|
from_page_url: r,
|
|
@@ -1985,7 +1985,7 @@ class er extends _ {
|
|
|
1985
1985
|
page_view: S
|
|
1986
1986
|
});
|
|
1987
1987
|
if (D && !(!p && !this.shouldSample())) {
|
|
1988
|
-
if (
|
|
1988
|
+
if (ve) {
|
|
1989
1989
|
const T = this.get("sessionId");
|
|
1990
1990
|
if (!T) {
|
|
1991
1991
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2458,10 +2458,10 @@ class er extends _ {
|
|
|
2458
2458
|
this.eventsQueue = this.eventsQueue.filter((r) => !t.has(r.id));
|
|
2459
2459
|
}
|
|
2460
2460
|
emitEvent(e) {
|
|
2461
|
-
this.emitter && this.emitter.emit(
|
|
2461
|
+
this.emitter && this.emitter.emit(oe.EVENT, e);
|
|
2462
2462
|
}
|
|
2463
2463
|
emitEventsQueue(e) {
|
|
2464
|
-
this.emitter && this.emitter.emit(
|
|
2464
|
+
this.emitter && this.emitter.emit(oe.QUEUE, e);
|
|
2465
2465
|
}
|
|
2466
2466
|
/**
|
|
2467
2467
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2537,13 +2537,13 @@ class er extends _ {
|
|
|
2537
2537
|
loadSessionCounts(e) {
|
|
2538
2538
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2539
2539
|
return this.getInitialCounts();
|
|
2540
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2540
|
+
const t = this.get("userId") || "anonymous", r = be(t, e);
|
|
2541
2541
|
try {
|
|
2542
2542
|
const n = localStorage.getItem(r);
|
|
2543
2543
|
if (!n)
|
|
2544
2544
|
return this.getInitialCounts();
|
|
2545
2545
|
const i = JSON.parse(n);
|
|
2546
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2546
|
+
return i._timestamp && Date.now() - i._timestamp > Ae ? (a("debug", "Session counts expired, clearing", {
|
|
2547
2547
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2548
2548
|
}), 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
2549
|
total: i.total,
|
|
@@ -2588,12 +2588,12 @@ class er extends _ {
|
|
|
2588
2588
|
cleanupExpiredSessionCounts() {
|
|
2589
2589
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2590
2590
|
try {
|
|
2591
|
-
const e = localStorage.getItem(
|
|
2591
|
+
const e = localStorage.getItem(Le);
|
|
2592
2592
|
if (e) {
|
|
2593
2593
|
const i = Date.now() - parseInt(e, 10);
|
|
2594
|
-
if (i <
|
|
2594
|
+
if (i < Me) {
|
|
2595
2595
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2596
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2596
|
+
data: { timeSinceLastCleanup: i, throttleMs: Me }
|
|
2597
2597
|
});
|
|
2598
2598
|
return;
|
|
2599
2599
|
}
|
|
@@ -2606,14 +2606,14 @@ class er extends _ {
|
|
|
2606
2606
|
const l = localStorage.getItem(o);
|
|
2607
2607
|
if (l) {
|
|
2608
2608
|
const c = JSON.parse(l);
|
|
2609
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2609
|
+
c._timestamp && Date.now() - c._timestamp > Ae && n.push(o);
|
|
2610
2610
|
}
|
|
2611
2611
|
} catch {
|
|
2612
2612
|
}
|
|
2613
2613
|
}
|
|
2614
2614
|
n.forEach((i) => {
|
|
2615
2615
|
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(
|
|
2616
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Le, Date.now().toString());
|
|
2617
2617
|
} catch (e) {
|
|
2618
2618
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2619
2619
|
}
|
|
@@ -2647,7 +2647,7 @@ class er extends _ {
|
|
|
2647
2647
|
* @internal
|
|
2648
2648
|
*/
|
|
2649
2649
|
saveSessionCounts(e) {
|
|
2650
|
-
const t = this.get("userId") || "anonymous", r =
|
|
2650
|
+
const t = this.get("userId") || "anonymous", r = be(t, e);
|
|
2651
2651
|
try {
|
|
2652
2652
|
const n = {
|
|
2653
2653
|
...this.sessionEventCounts,
|
|
@@ -2681,11 +2681,11 @@ class tr {
|
|
|
2681
2681
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2682
2682
|
*/
|
|
2683
2683
|
static getId(e) {
|
|
2684
|
-
const t = e.getItem(
|
|
2684
|
+
const t = e.getItem(Ie);
|
|
2685
2685
|
if (t)
|
|
2686
2686
|
return t;
|
|
2687
2687
|
const r = Ht();
|
|
2688
|
-
return e.setItem(
|
|
2688
|
+
return e.setItem(Ie, r), r;
|
|
2689
2689
|
}
|
|
2690
2690
|
}
|
|
2691
2691
|
const rr = /^\d{13}-[a-z0-9]{9}$/;
|
|
@@ -2698,6 +2698,7 @@ class sr extends _ {
|
|
|
2698
2698
|
sessionTimeoutId = null;
|
|
2699
2699
|
broadcastChannel = null;
|
|
2700
2700
|
isTracking = !1;
|
|
2701
|
+
needsRenewal = !1;
|
|
2701
2702
|
/**
|
|
2702
2703
|
* Creates a SessionManager instance.
|
|
2703
2704
|
*
|
|
@@ -2834,24 +2835,26 @@ class sr extends _ {
|
|
|
2834
2835
|
let r, n;
|
|
2835
2836
|
if (e) {
|
|
2836
2837
|
const i = this.loadStoredSession();
|
|
2837
|
-
r = i?.referrer ??
|
|
2838
|
+
r = i?.referrer ?? te(), n = i?.utm ?? re();
|
|
2838
2839
|
} else
|
|
2839
|
-
r =
|
|
2840
|
+
r = te(), n = re();
|
|
2840
2841
|
a("debug", "Session tracking initialized", {
|
|
2841
2842
|
data: {
|
|
2842
2843
|
sessionId: t,
|
|
2843
2844
|
wasRecovered: !!e,
|
|
2844
|
-
willEmitSessionStart: !
|
|
2845
|
+
willEmitSessionStart: !e,
|
|
2845
2846
|
sessionReferrer: r,
|
|
2846
2847
|
hasUtm: !!n
|
|
2847
2848
|
}
|
|
2848
2849
|
}), this.isTracking = !0;
|
|
2849
2850
|
try {
|
|
2850
|
-
this.set("sessionId", t), this.set("sessionReferrer", r), this.set("sessionUtm", n), this.persistSession(t, Date.now(), r, n), this.initCrossTabSync(), this.shareSession(t), a("debug", "
|
|
2851
|
+
this.set("sessionId", t), this.set("sessionReferrer", r), this.set("sessionUtm", n), this.persistSession(t, Date.now(), r, n), this.initCrossTabSync(), this.shareSession(t), e ? a("debug", "Session recovered, skipping SESSION_START", {
|
|
2852
|
+
data: { sessionId: t }
|
|
2853
|
+
}) : (a("debug", "Emitting SESSION_START event", {
|
|
2851
2854
|
data: { sessionId: t }
|
|
2852
2855
|
}), this.eventManager.track({
|
|
2853
2856
|
type: d.SESSION_START
|
|
2854
|
-
}), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2857
|
+
})), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2855
2858
|
} catch (i) {
|
|
2856
2859
|
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
|
|
2857
2860
|
}
|
|
@@ -2863,7 +2866,7 @@ class sr extends _ {
|
|
|
2863
2866
|
this.clearSessionTimeout();
|
|
2864
2867
|
const e = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2865
2868
|
this.sessionTimeoutId = setTimeout(() => {
|
|
2866
|
-
this.
|
|
2869
|
+
this.enterRenewalMode();
|
|
2867
2870
|
}, e);
|
|
2868
2871
|
}
|
|
2869
2872
|
resetSessionTimeout() {
|
|
@@ -2876,22 +2879,68 @@ class sr extends _ {
|
|
|
2876
2879
|
}
|
|
2877
2880
|
setupActivityListeners() {
|
|
2878
2881
|
this.activityHandler = () => {
|
|
2879
|
-
this.resetSessionTimeout();
|
|
2882
|
+
this.needsRenewal ? this.renewSession() : this.resetSessionTimeout();
|
|
2880
2883
|
}, document.addEventListener("click", this.activityHandler, { passive: !0 }), document.addEventListener("keydown", this.activityHandler, { passive: !0 }), document.addEventListener("scroll", this.activityHandler, { passive: !0 });
|
|
2881
2884
|
}
|
|
2885
|
+
/**
|
|
2886
|
+
* Renews the session after timeout when user returns.
|
|
2887
|
+
* Creates a new session ID and emits SESSION_START.
|
|
2888
|
+
*/
|
|
2889
|
+
renewSession() {
|
|
2890
|
+
this.needsRenewal = !1;
|
|
2891
|
+
const e = this.generateSessionId(), t = te(), r = re();
|
|
2892
|
+
a("debug", "Renewing session after timeout", {
|
|
2893
|
+
data: { newSessionId: e }
|
|
2894
|
+
}), 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({
|
|
2895
|
+
type: d.SESSION_START
|
|
2896
|
+
}), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
|
|
2897
|
+
}
|
|
2882
2898
|
cleanupActivityListeners() {
|
|
2883
2899
|
this.activityHandler && (document.removeEventListener("click", this.activityHandler), document.removeEventListener("keydown", this.activityHandler), document.removeEventListener("scroll", this.activityHandler), this.activityHandler = null);
|
|
2884
2900
|
}
|
|
2885
2901
|
setupLifecycleListeners() {
|
|
2886
2902
|
this.visibilityChangeHandler || (this.visibilityChangeHandler = () => {
|
|
2887
|
-
document.hidden
|
|
2903
|
+
if (document.hidden)
|
|
2904
|
+
this.clearSessionTimeout();
|
|
2905
|
+
else {
|
|
2906
|
+
if (this.isSessionStale()) {
|
|
2907
|
+
a("debug", "Session expired during suspend, entering renewal mode"), this.enterRenewalMode();
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2910
|
+
this.get("sessionId") && this.setupSessionTimeout();
|
|
2911
|
+
}
|
|
2888
2912
|
}, document.addEventListener("visibilitychange", this.visibilityChangeHandler));
|
|
2889
2913
|
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Checks if the current session has become stale (expired during browser suspend).
|
|
2916
|
+
* This handles the case where JavaScript timers are paused during suspend/hibernate.
|
|
2917
|
+
*/
|
|
2918
|
+
isSessionStale() {
|
|
2919
|
+
if (this.needsRenewal || !this.get("sessionId"))
|
|
2920
|
+
return !1;
|
|
2921
|
+
const t = this.loadStoredSession();
|
|
2922
|
+
if (!t)
|
|
2923
|
+
return !1;
|
|
2924
|
+
const r = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2925
|
+
return Date.now() - t.lastActivity > r;
|
|
2926
|
+
}
|
|
2890
2927
|
cleanupLifecycleListeners() {
|
|
2891
2928
|
this.visibilityChangeHandler && (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null);
|
|
2892
2929
|
}
|
|
2930
|
+
/**
|
|
2931
|
+
* Enters renewal mode after session timeout.
|
|
2932
|
+
* Keeps activity listeners active to detect when user returns.
|
|
2933
|
+
* Called by session timeout timer.
|
|
2934
|
+
*/
|
|
2935
|
+
enterRenewalMode() {
|
|
2936
|
+
this.clearSessionTimeout(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.needsRenewal = !0, a("debug", "Session timed out, entering renewal mode");
|
|
2937
|
+
}
|
|
2938
|
+
/**
|
|
2939
|
+
* Fully resets session state and cleans up all resources.
|
|
2940
|
+
* Called by stopTracking() for explicit session termination.
|
|
2941
|
+
*/
|
|
2893
2942
|
resetSessionState() {
|
|
2894
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.isTracking = !1;
|
|
2943
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.needsRenewal = !1, this.isTracking = !1;
|
|
2895
2944
|
}
|
|
2896
2945
|
/**
|
|
2897
2946
|
* Stops session tracking and cleans up all resources.
|
|
@@ -2957,7 +3006,7 @@ class sr extends _ {
|
|
|
2957
3006
|
* ```
|
|
2958
3007
|
*/
|
|
2959
3008
|
destroy() {
|
|
2960
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
3009
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
2961
3010
|
}
|
|
2962
3011
|
}
|
|
2963
3012
|
class nr extends _ {
|
|
@@ -3088,7 +3137,7 @@ class ir extends _ {
|
|
|
3088
3137
|
};
|
|
3089
3138
|
}
|
|
3090
3139
|
trackCurrentPage = () => {
|
|
3091
|
-
const e = window.location.href, t =
|
|
3140
|
+
const e = window.location.href, t = ue(e, this.get("config").sensitiveQueryParams);
|
|
3092
3141
|
if (this.get("pageUrl") === t)
|
|
3093
3142
|
return;
|
|
3094
3143
|
const r = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3106,7 +3155,7 @@ class ir extends _ {
|
|
|
3106
3155
|
});
|
|
3107
3156
|
};
|
|
3108
3157
|
trackInitialPageView() {
|
|
3109
|
-
const e =
|
|
3158
|
+
const e = ue(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3110
3159
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3111
3160
|
type: d.PAGE_VIEW,
|
|
3112
3161
|
page_url: e,
|
|
@@ -4064,7 +4113,7 @@ class ur extends _ {
|
|
|
4064
4113
|
navigationCounter = 0;
|
|
4065
4114
|
// Counter for handling simultaneous navigations edge case
|
|
4066
4115
|
constructor(e) {
|
|
4067
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4116
|
+
super(), this.eventManager = e, this.vitalThresholds = De(ce);
|
|
4068
4117
|
}
|
|
4069
4118
|
/**
|
|
4070
4119
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4081,8 +4130,8 @@ class ur extends _ {
|
|
|
4081
4130
|
* @returns Promise that resolves when tracking is initialized
|
|
4082
4131
|
*/
|
|
4083
4132
|
async startTracking() {
|
|
4084
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
4085
|
-
this.vitalThresholds =
|
|
4133
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ce;
|
|
4134
|
+
this.vitalThresholds = De(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4086
4135
|
}
|
|
4087
4136
|
/**
|
|
4088
4137
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4152,7 +4201,7 @@ class ur extends _ {
|
|
|
4152
4201
|
}
|
|
4153
4202
|
async initWebVitals() {
|
|
4154
4203
|
try {
|
|
4155
|
-
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4204
|
+
const { onLCP: e, onCLS: t, onFCP: r, onTTFB: n, onINP: i } = await Promise.resolve().then(() => kr), o = (l) => (c) => {
|
|
4156
4205
|
const u = Number(c.value.toFixed(2));
|
|
4157
4206
|
this.sendVital({ type: l, value: u });
|
|
4158
4207
|
};
|
|
@@ -4179,7 +4228,7 @@ class ur extends _ {
|
|
|
4179
4228
|
const t = e.getEntries();
|
|
4180
4229
|
for (const r of t) {
|
|
4181
4230
|
const n = Number(r.duration.toFixed(2)), i = Date.now();
|
|
4182
|
-
i - this.lastLongTaskSentAt >=
|
|
4231
|
+
i - this.lastLongTaskSentAt >= Ct && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4183
4232
|
}
|
|
4184
4233
|
},
|
|
4185
4234
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4323,10 +4372,10 @@ class dr extends _ {
|
|
|
4323
4372
|
if (e < this.burstBackoffUntil)
|
|
4324
4373
|
return !1;
|
|
4325
4374
|
if (e - this.burstWindowStart > At && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Lt)
|
|
4326
|
-
return this.burstBackoffUntil = e +
|
|
4375
|
+
return this.burstBackoffUntil = e + Oe, a("debug", "Error burst detected - entering cooldown", {
|
|
4327
4376
|
data: {
|
|
4328
4377
|
errorsInWindow: this.errorBurstCounter,
|
|
4329
|
-
cooldownMs:
|
|
4378
|
+
cooldownMs: Oe
|
|
4330
4379
|
}
|
|
4331
4380
|
}), !1;
|
|
4332
4381
|
const r = this.get("config")?.errorSampling ?? Qe;
|
|
@@ -4373,7 +4422,7 @@ class dr extends _ {
|
|
|
4373
4422
|
}
|
|
4374
4423
|
}
|
|
4375
4424
|
sanitize(e) {
|
|
4376
|
-
let t = e.length >
|
|
4425
|
+
let t = e.length > Ce ? e.slice(0, Ce) + "..." : e;
|
|
4377
4426
|
for (const r of Xe) {
|
|
4378
4427
|
const n = new RegExp(r.source, r.flags);
|
|
4379
4428
|
t = t.replace(n, "[REDACTED]");
|
|
@@ -4382,12 +4431,12 @@ class dr extends _ {
|
|
|
4382
4431
|
}
|
|
4383
4432
|
shouldSuppressError(e, t) {
|
|
4384
4433
|
const r = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4385
|
-
return i && r - i <
|
|
4434
|
+
return i && r - i < Ne ? (this.recentErrors.set(n, r), !0) : (this.recentErrors.set(n, r), this.recentErrors.size > bt ? (this.recentErrors.clear(), this.recentErrors.set(n, r), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
4386
4435
|
}
|
|
4387
4436
|
pruneOldErrors() {
|
|
4388
4437
|
const e = Date.now();
|
|
4389
4438
|
for (const [n, i] of this.recentErrors.entries())
|
|
4390
|
-
e - i >
|
|
4439
|
+
e - i > Ne && this.recentErrors.delete(n);
|
|
4391
4440
|
if (this.recentErrors.size <= Q)
|
|
4392
4441
|
return;
|
|
4393
4442
|
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), r = this.recentErrors.size - Q;
|
|
@@ -4496,8 +4545,8 @@ class hr extends _ {
|
|
|
4496
4545
|
this.set("collectApiUrls", r);
|
|
4497
4546
|
const n = yt();
|
|
4498
4547
|
this.set("device", n);
|
|
4499
|
-
const i =
|
|
4500
|
-
this.set("pageUrl", i),
|
|
4548
|
+
const i = ue(window.location.href, e.sensitiveQueryParams);
|
|
4549
|
+
this.set("pageUrl", i), kt() && this.set("mode", z.QA);
|
|
4501
4550
|
}
|
|
4502
4551
|
/**
|
|
4503
4552
|
* Returns the current configuration object.
|
|
@@ -4598,17 +4647,17 @@ class hr extends _ {
|
|
|
4598
4647
|
}), this.handlers.error = new dr(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new lr(this.managers.event), this.handlers.viewport.startTracking());
|
|
4599
4648
|
}
|
|
4600
4649
|
}
|
|
4601
|
-
const
|
|
4602
|
-
let f = null,
|
|
4650
|
+
const C = [], M = [];
|
|
4651
|
+
let f = null, R = !1, v = !1;
|
|
4603
4652
|
const fr = async (s) => {
|
|
4604
|
-
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !
|
|
4605
|
-
|
|
4653
|
+
if (!(typeof window > "u" || typeof document > "u") && (v = !1, window.__traceLogDisabled !== !0 && !f && !R)) {
|
|
4654
|
+
R = !0;
|
|
4606
4655
|
try {
|
|
4607
4656
|
const e = jt(s ?? {}), t = new hr();
|
|
4608
4657
|
try {
|
|
4609
|
-
|
|
4658
|
+
C.forEach(({ event: i, callback: o }) => {
|
|
4610
4659
|
t.on(i, o);
|
|
4611
|
-
}),
|
|
4660
|
+
}), C.length = 0, M.forEach(({ hook: i, fn: o }) => {
|
|
4612
4661
|
i === "beforeSend" ? t.setTransformer("beforeSend", o) : t.setTransformer("beforeBatch", o);
|
|
4613
4662
|
}), M.length = 0;
|
|
4614
4663
|
const r = t.init(e), n = new Promise((i, o) => {
|
|
@@ -4628,7 +4677,7 @@ const fr = async (s) => {
|
|
|
4628
4677
|
} catch (e) {
|
|
4629
4678
|
throw f = null, e;
|
|
4630
4679
|
} finally {
|
|
4631
|
-
|
|
4680
|
+
R = !1;
|
|
4632
4681
|
}
|
|
4633
4682
|
}
|
|
4634
4683
|
}, mr = (s, e) => {
|
|
@@ -4641,8 +4690,8 @@ const fr = async (s) => {
|
|
|
4641
4690
|
}
|
|
4642
4691
|
}, gr = (s, e) => {
|
|
4643
4692
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4644
|
-
if (!f ||
|
|
4645
|
-
|
|
4693
|
+
if (!f || R) {
|
|
4694
|
+
C.push({ event: s, callback: e });
|
|
4646
4695
|
return;
|
|
4647
4696
|
}
|
|
4648
4697
|
f.on(s, e);
|
|
@@ -4650,8 +4699,8 @@ const fr = async (s) => {
|
|
|
4650
4699
|
}, Er = (s, e) => {
|
|
4651
4700
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4652
4701
|
if (!f) {
|
|
4653
|
-
const t =
|
|
4654
|
-
t !== -1 &&
|
|
4702
|
+
const t = C.findIndex((r) => r.event === s && r.callback === e);
|
|
4703
|
+
t !== -1 && C.splice(t, 1);
|
|
4655
4704
|
return;
|
|
4656
4705
|
}
|
|
4657
4706
|
f.off(s, e);
|
|
@@ -4661,7 +4710,7 @@ function Sr(s, e) {
|
|
|
4661
4710
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4662
4711
|
if (typeof e != "function")
|
|
4663
4712
|
throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
|
|
4664
|
-
if (!f ||
|
|
4713
|
+
if (!f || R) {
|
|
4665
4714
|
const t = M.findIndex((r) => r.hook === s);
|
|
4666
4715
|
t !== -1 && M.splice(t, 1), M.push({ hook: s, fn: e });
|
|
4667
4716
|
return;
|
|
@@ -4692,13 +4741,13 @@ const pr = (s) => {
|
|
|
4692
4741
|
}
|
|
4693
4742
|
v = !0;
|
|
4694
4743
|
try {
|
|
4695
|
-
f.destroy(), f = null,
|
|
4744
|
+
f.destroy(), f = null, R = !1, C.length = 0, M.length = 0, v = !1;
|
|
4696
4745
|
} catch (s) {
|
|
4697
|
-
f = null,
|
|
4746
|
+
f = null, R = !1, C.length = 0, M.length = 0, v = !1, a("warn", "Error during destroy, forced cleanup completed", { error: s });
|
|
4698
4747
|
}
|
|
4699
4748
|
}
|
|
4700
4749
|
}, vr = (s) => {
|
|
4701
|
-
typeof window > "u" || typeof document > "u" ||
|
|
4750
|
+
typeof window > "u" || typeof document > "u" || Vt(s);
|
|
4702
4751
|
}, Ir = (s) => {
|
|
4703
4752
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4704
4753
|
if (!f)
|
|
@@ -4728,18 +4777,18 @@ const pr = (s) => {
|
|
|
4728
4777
|
updateGlobalMetadata: Ir,
|
|
4729
4778
|
mergeGlobalMetadata: wr
|
|
4730
4779
|
};
|
|
4731
|
-
var
|
|
4780
|
+
var he, Ze = -1, P = function(s) {
|
|
4732
4781
|
addEventListener("pageshow", (function(e) {
|
|
4733
4782
|
e.persisted && (Ze = e.timeStamp, s(e));
|
|
4734
4783
|
}), !0);
|
|
4735
|
-
},
|
|
4784
|
+
}, pe = function() {
|
|
4736
4785
|
var s = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4737
4786
|
if (s && s.responseStart > 0 && s.responseStart < performance.now()) return s;
|
|
4738
4787
|
}, q = function() {
|
|
4739
|
-
var s =
|
|
4788
|
+
var s = pe();
|
|
4740
4789
|
return s && s.activationStart || 0;
|
|
4741
4790
|
}, b = function(s, e) {
|
|
4742
|
-
var t =
|
|
4791
|
+
var t = pe(), r = "navigate";
|
|
4743
4792
|
return Ze >= 0 ? r = "back-forward-cache" : t && (document.prerendering || q() > 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 };
|
|
4744
4793
|
}, F = function(s, e, t) {
|
|
4745
4794
|
try {
|
|
@@ -4760,7 +4809,7 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4760
4809
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
4761
4810
|
})(e.value, t), s(e));
|
|
4762
4811
|
};
|
|
4763
|
-
},
|
|
4812
|
+
}, Te = function(s) {
|
|
4764
4813
|
requestAnimationFrame((function() {
|
|
4765
4814
|
return requestAnimationFrame((function() {
|
|
4766
4815
|
return s();
|
|
@@ -4770,7 +4819,7 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4770
4819
|
document.addEventListener("visibilitychange", (function() {
|
|
4771
4820
|
document.visibilityState === "hidden" && s();
|
|
4772
4821
|
}));
|
|
4773
|
-
},
|
|
4822
|
+
}, _e = function(s) {
|
|
4774
4823
|
var e = !1;
|
|
4775
4824
|
return function() {
|
|
4776
4825
|
e || (s(), e = !0);
|
|
@@ -4795,21 +4844,21 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4795
4844
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4796
4845
|
return s();
|
|
4797
4846
|
}), !0) : s();
|
|
4798
|
-
},
|
|
4847
|
+
}, fe = [1800, 3e3], tt = function(s, e) {
|
|
4799
4848
|
e = e || {}, Z((function() {
|
|
4800
4849
|
var t, r = et(), n = b("FCP"), i = F("paint", (function(o) {
|
|
4801
4850
|
o.forEach((function(l) {
|
|
4802
4851
|
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < r.firstHiddenTime && (n.value = Math.max(l.startTime - q(), 0), n.entries.push(l), t(!0)));
|
|
4803
4852
|
}));
|
|
4804
4853
|
}));
|
|
4805
|
-
i && (t = A(s, n,
|
|
4806
|
-
n = b("FCP"), t = A(s, n,
|
|
4854
|
+
i && (t = A(s, n, fe, e.reportAllChanges), P((function(o) {
|
|
4855
|
+
n = b("FCP"), t = A(s, n, fe, e.reportAllChanges), Te((function() {
|
|
4807
4856
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
4808
4857
|
}));
|
|
4809
4858
|
})));
|
|
4810
4859
|
}));
|
|
4811
|
-
},
|
|
4812
|
-
e = e || {}, tt(
|
|
4860
|
+
}, me = [0.1, 0.25], br = function(s, e) {
|
|
4861
|
+
e = e || {}, tt(_e((function() {
|
|
4813
4862
|
var t, r = b("CLS", 0), n = 0, i = [], o = function(c) {
|
|
4814
4863
|
c.forEach((function(u) {
|
|
4815
4864
|
if (!u.hadRecentInput) {
|
|
@@ -4818,27 +4867,27 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4818
4867
|
}
|
|
4819
4868
|
})), n > r.value && (r.value = n, r.entries = i, t());
|
|
4820
4869
|
}, l = F("layout-shift", o);
|
|
4821
|
-
l && (t = A(s, r,
|
|
4870
|
+
l && (t = A(s, r, me, e.reportAllChanges), J((function() {
|
|
4822
4871
|
o(l.takeRecords()), t(!0);
|
|
4823
4872
|
})), P((function() {
|
|
4824
|
-
n = 0, r = b("CLS", 0), t = A(s, r,
|
|
4873
|
+
n = 0, r = b("CLS", 0), t = A(s, r, me, e.reportAllChanges), Te((function() {
|
|
4825
4874
|
return t();
|
|
4826
4875
|
}));
|
|
4827
4876
|
})), setTimeout(t, 0));
|
|
4828
4877
|
})));
|
|
4829
|
-
}, rt = 0,
|
|
4878
|
+
}, rt = 0, ne = 1 / 0, G = 0, Ar = function(s) {
|
|
4830
4879
|
s.forEach((function(e) {
|
|
4831
|
-
e.interactionId && (
|
|
4880
|
+
e.interactionId && (ne = Math.min(ne, e.interactionId), G = Math.max(G, e.interactionId), rt = G ? (G - ne) / 7 + 1 : 0);
|
|
4832
4881
|
}));
|
|
4833
4882
|
}, st = function() {
|
|
4834
|
-
return
|
|
4883
|
+
return he ? rt : performance.interactionCount || 0;
|
|
4835
4884
|
}, Lr = function() {
|
|
4836
|
-
"interactionCount" in performance ||
|
|
4885
|
+
"interactionCount" in performance || he || (he = F("event", Ar, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4837
4886
|
}, y = [], j = /* @__PURE__ */ new Map(), nt = 0, Mr = function() {
|
|
4838
4887
|
var s = Math.min(y.length - 1, Math.floor((st() - nt) / 50));
|
|
4839
4888
|
return y[s];
|
|
4840
|
-
},
|
|
4841
|
-
if (
|
|
4889
|
+
}, Rr = [], Cr = function(s) {
|
|
4890
|
+
if (Rr.forEach((function(n) {
|
|
4842
4891
|
return n(s);
|
|
4843
4892
|
})), s.interactionId || s.entryType === "first-input") {
|
|
4844
4893
|
var e = y[y.length - 1], t = j.get(s.interactionId);
|
|
@@ -4857,25 +4906,25 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4857
4906
|
}
|
|
4858
4907
|
}, it = function(s) {
|
|
4859
4908
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4860
|
-
return s =
|
|
4861
|
-
},
|
|
4909
|
+
return s = _e(s), document.visibilityState === "hidden" ? s() : (t = e(s), J(s)), t;
|
|
4910
|
+
}, ge = [200, 500], Nr = function(s, e) {
|
|
4862
4911
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Z((function() {
|
|
4863
4912
|
var t;
|
|
4864
4913
|
Lr();
|
|
4865
4914
|
var r, n = b("INP"), i = function(l) {
|
|
4866
4915
|
it((function() {
|
|
4867
|
-
l.forEach(
|
|
4916
|
+
l.forEach(Cr);
|
|
4868
4917
|
var c = Mr();
|
|
4869
4918
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, r());
|
|
4870
4919
|
}));
|
|
4871
4920
|
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4872
|
-
r = A(s, n,
|
|
4921
|
+
r = A(s, n, ge, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), J((function() {
|
|
4873
4922
|
i(o.takeRecords()), r(!0);
|
|
4874
4923
|
})), P((function() {
|
|
4875
|
-
nt = st(), y.length = 0, j.clear(), n = b("INP"), r = A(s, n,
|
|
4924
|
+
nt = st(), y.length = 0, j.clear(), n = b("INP"), r = A(s, n, ge, e.reportAllChanges);
|
|
4876
4925
|
})));
|
|
4877
4926
|
})));
|
|
4878
|
-
},
|
|
4927
|
+
}, Ee = [2500, 4e3], ie = {}, Or = function(s, e) {
|
|
4879
4928
|
e = e || {}, Z((function() {
|
|
4880
4929
|
var t, r = et(), n = b("LCP"), i = function(c) {
|
|
4881
4930
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
|
|
@@ -4883,22 +4932,22 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4883
4932
|
}));
|
|
4884
4933
|
}, o = F("largest-contentful-paint", i);
|
|
4885
4934
|
if (o) {
|
|
4886
|
-
t = A(s, n,
|
|
4887
|
-
var l =
|
|
4888
|
-
|
|
4935
|
+
t = A(s, n, Ee, e.reportAllChanges);
|
|
4936
|
+
var l = _e((function() {
|
|
4937
|
+
ie[n.id] || (i(o.takeRecords()), o.disconnect(), ie[n.id] = !0, t(!0));
|
|
4889
4938
|
}));
|
|
4890
4939
|
["keydown", "click"].forEach((function(c) {
|
|
4891
4940
|
addEventListener(c, (function() {
|
|
4892
4941
|
return it(l);
|
|
4893
4942
|
}), { once: !0, capture: !0 });
|
|
4894
4943
|
})), J(l), P((function(c) {
|
|
4895
|
-
n = b("LCP"), t = A(s, n,
|
|
4896
|
-
n.value = performance.now() - c.timeStamp,
|
|
4944
|
+
n = b("LCP"), t = A(s, n, Ee, e.reportAllChanges), Te((function() {
|
|
4945
|
+
n.value = performance.now() - c.timeStamp, ie[n.id] = !0, t(!0);
|
|
4897
4946
|
}));
|
|
4898
4947
|
}));
|
|
4899
4948
|
}
|
|
4900
4949
|
}));
|
|
4901
|
-
},
|
|
4950
|
+
}, Se = [800, 1800], Pr = function s(e) {
|
|
4902
4951
|
document.prerendering ? Z((function() {
|
|
4903
4952
|
return s(e);
|
|
4904
4953
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
@@ -4906,21 +4955,21 @@ var ue, Ze = -1, P = function(s) {
|
|
|
4906
4955
|
}), !0) : setTimeout(e, 0);
|
|
4907
4956
|
}, Dr = function(s, e) {
|
|
4908
4957
|
e = e || {};
|
|
4909
|
-
var t = b("TTFB"), r = A(s, t,
|
|
4958
|
+
var t = b("TTFB"), r = A(s, t, Se, e.reportAllChanges);
|
|
4910
4959
|
Pr((function() {
|
|
4911
|
-
var n =
|
|
4960
|
+
var n = pe();
|
|
4912
4961
|
n && (t.value = Math.max(n.responseStart - q(), 0), t.entries = [n], r(!0), P((function() {
|
|
4913
|
-
t = b("TTFB", 0), (r = A(s, t,
|
|
4962
|
+
t = b("TTFB", 0), (r = A(s, t, Se, e.reportAllChanges))(!0);
|
|
4914
4963
|
})));
|
|
4915
4964
|
}));
|
|
4916
4965
|
};
|
|
4917
|
-
const
|
|
4966
|
+
const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4918
4967
|
__proto__: null,
|
|
4919
|
-
CLSThresholds:
|
|
4920
|
-
FCPThresholds:
|
|
4921
|
-
INPThresholds:
|
|
4922
|
-
LCPThresholds:
|
|
4923
|
-
TTFBThresholds:
|
|
4968
|
+
CLSThresholds: me,
|
|
4969
|
+
FCPThresholds: fe,
|
|
4970
|
+
INPThresholds: ge,
|
|
4971
|
+
LCPThresholds: Ee,
|
|
4972
|
+
TTFBThresholds: Se,
|
|
4924
4973
|
onCLS: br,
|
|
4925
4974
|
onFCP: tt,
|
|
4926
4975
|
onINP: Nr,
|
|
@@ -4929,14 +4978,14 @@ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4929
4978
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4930
4979
|
export {
|
|
4931
4980
|
h as AppConfigValidationError,
|
|
4932
|
-
|
|
4933
|
-
|
|
4981
|
+
Vr as DEFAULT_SESSION_TIMEOUT,
|
|
4982
|
+
ce as DEFAULT_WEB_VITALS_MODE,
|
|
4934
4983
|
L as DeviceType,
|
|
4935
|
-
|
|
4984
|
+
oe as EmitterEvent,
|
|
4936
4985
|
U as ErrorType,
|
|
4937
4986
|
d as EventType,
|
|
4938
4987
|
zr as InitializationTimeoutError,
|
|
4939
|
-
|
|
4988
|
+
k as IntegrationValidationError,
|
|
4940
4989
|
Xr as MAX_ARRAY_LENGTH,
|
|
4941
4990
|
Fr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4942
4991
|
Hr as MAX_CUSTOM_EVENT_KEYS,
|
|
@@ -4949,15 +4998,15 @@ export {
|
|
|
4949
4998
|
z as Mode,
|
|
4950
4999
|
Xe as PII_PATTERNS,
|
|
4951
5000
|
N as PermanentError,
|
|
4952
|
-
|
|
5001
|
+
Re as SamplingRateValidationError,
|
|
4953
5002
|
X as ScrollDirection,
|
|
4954
5003
|
ft as SessionTimeoutValidationError,
|
|
4955
|
-
|
|
5004
|
+
V as SpecialApiUrl,
|
|
4956
5005
|
H as TraceLogValidationError,
|
|
4957
5006
|
Kr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5007
|
+
Pe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5008
|
+
Rt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5009
|
+
De as getWebVitalsThresholds,
|
|
4961
5010
|
Qr as isPrimaryScrollEvent,
|
|
4962
5011
|
jr as isSecondaryScrollEvent,
|
|
4963
5012
|
Yr as tracelog
|