@tracelog/lib 0.8.2 → 0.8.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/dist/browser/tracelog.esm.js +107 -112
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +2 -2
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/cjs/app.constants.d.ts +1 -1
- package/dist/cjs/app.constants.d.ts.map +1 -1
- package/dist/cjs/app.constants.js +1 -6
- package/dist/cjs/app.constants.js.map +1 -1
- package/dist/cjs/constants/config.constants.d.ts +0 -5
- package/dist/cjs/constants/config.constants.d.ts.map +1 -1
- package/dist/cjs/constants/config.constants.js +3 -9
- package/dist/cjs/constants/config.constants.js.map +1 -1
- package/dist/esm/app.constants.d.ts +1 -1
- package/dist/esm/app.constants.d.ts.map +1 -1
- package/dist/esm/app.constants.js +1 -1
- package/dist/esm/app.constants.js.map +1 -1
- package/dist/esm/constants/config.constants.d.ts +0 -5
- package/dist/esm/constants/config.constants.d.ts.map +1 -1
- package/dist/esm/constants/config.constants.js +1 -7
- package/dist/esm/constants/config.constants.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const Ft = 120, Gt = 8192, $t = 10, zt = 10,
|
|
2
|
-
const
|
|
1
|
+
const Ft = 120, Gt = 8192, $t = 10, zt = 10, Qt = 20, Bt = 1;
|
|
2
|
+
const jt = 1e3, Xt = 500, Wt = 100;
|
|
3
3
|
const P = "data-tlog", Oe = [
|
|
4
4
|
"button",
|
|
5
5
|
"a",
|
|
@@ -51,19 +51,19 @@ const m = {
|
|
|
51
51
|
/<embed\b[^>]*>/gi,
|
|
52
52
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
53
53
|
];
|
|
54
|
-
var
|
|
55
|
-
class
|
|
54
|
+
var X = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))(X || {}), _ = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(_ || {}), W = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(W || {});
|
|
55
|
+
class y extends Error {
|
|
56
56
|
constructor(e, t) {
|
|
57
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
57
|
+
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, y);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
var d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.SESSION_END = "session_end", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r))(d || {}), k = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(k || {}),
|
|
60
|
+
var d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.SESSION_END = "session_end", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r))(d || {}), k = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(k || {}), R = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(R || {}), C = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(C || {});
|
|
61
61
|
class b extends Error {
|
|
62
62
|
constructor(e, t, s) {
|
|
63
63
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
class
|
|
66
|
+
class A extends b {
|
|
67
67
|
constructor(e, t = "config") {
|
|
68
68
|
super(e, "APP_CONFIG_INVALID", t);
|
|
69
69
|
}
|
|
@@ -83,7 +83,7 @@ class v extends b {
|
|
|
83
83
|
super(e, "INTEGRATION_INVALID", t);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
class
|
|
86
|
+
class Yt extends b {
|
|
87
87
|
constructor(e, t, s = "runtime") {
|
|
88
88
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
89
89
|
}
|
|
@@ -133,7 +133,7 @@ const xe = () => {
|
|
|
133
133
|
INP: 200,
|
|
134
134
|
TTFB: 800,
|
|
135
135
|
LONG_TASK: 50
|
|
136
|
-
},
|
|
136
|
+
}, Qe = 1e3, ve = [
|
|
137
137
|
// Email addresses
|
|
138
138
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
139
139
|
// US Phone numbers (various formats)
|
|
@@ -148,10 +148,10 @@ const xe = () => {
|
|
|
148
148
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
149
149
|
// Passwords in connection strings (protocol://user:password@host)
|
|
150
150
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
151
|
-
], ue = 500, de = 5e3, U = 50,
|
|
151
|
+
], ue = 500, de = 5e3, U = 50, Be = U * 2, je = 6e4, he = "tlog_mode", Xe = "qa", We = () => {
|
|
152
152
|
if (sessionStorage.getItem(ce) === "true")
|
|
153
153
|
return !0;
|
|
154
|
-
const e = new URLSearchParams(window.location.search), s = e.get(he) ===
|
|
154
|
+
const e = new URLSearchParams(window.location.search), s = e.get(he) === Xe;
|
|
155
155
|
if (s) {
|
|
156
156
|
sessionStorage.setItem(ce, "true"), e.delete(he);
|
|
157
157
|
const n = e.toString(), i = `${window.location.pathname}${n ? "?" + n : ""}${window.location.hash}`;
|
|
@@ -264,7 +264,7 @@ const xe = () => {
|
|
|
264
264
|
return t;
|
|
265
265
|
}
|
|
266
266
|
return null;
|
|
267
|
-
},
|
|
267
|
+
}, Je = (r) => {
|
|
268
268
|
if (typeof r != "object" || r === null)
|
|
269
269
|
return {};
|
|
270
270
|
try {
|
|
@@ -274,20 +274,20 @@ const xe = () => {
|
|
|
274
274
|
const t = e instanceof Error ? e.message : String(e);
|
|
275
275
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
276
276
|
}
|
|
277
|
-
},
|
|
277
|
+
}, Ze = (r) => {
|
|
278
278
|
if (r !== void 0 && (r === null || typeof r != "object"))
|
|
279
|
-
throw new
|
|
279
|
+
throw new A("Configuration must be an object", "config");
|
|
280
280
|
if (r) {
|
|
281
281
|
if (r.sessionTimeout !== void 0 && (typeof r.sessionTimeout != "number" || r.sessionTimeout < 3e4 || r.sessionTimeout > 864e5))
|
|
282
282
|
throw new ke(m.INVALID_SESSION_TIMEOUT, "config");
|
|
283
283
|
if (r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null))
|
|
284
|
-
throw new
|
|
284
|
+
throw new A(m.INVALID_GLOBAL_METADATA, "config");
|
|
285
285
|
if (r.scrollContainerSelectors !== void 0 && tt(r.scrollContainerSelectors), r.integrations && rt(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
286
286
|
if (!Array.isArray(r.sensitiveQueryParams))
|
|
287
|
-
throw new
|
|
287
|
+
throw new A(m.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
288
288
|
for (const e of r.sensitiveQueryParams)
|
|
289
289
|
if (typeof e != "string")
|
|
290
|
-
throw new
|
|
290
|
+
throw new A("All sensitive query params must be strings", "config");
|
|
291
291
|
}
|
|
292
292
|
if (r.errorSampling !== void 0 && (typeof r.errorSampling != "number" || r.errorSampling < 0 || r.errorSampling > 1))
|
|
293
293
|
throw new le(m.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
@@ -316,7 +316,7 @@ const xe = () => {
|
|
|
316
316
|
type: typeof t,
|
|
317
317
|
isEmpty: t === "" || typeof t == "string" && t.trim() === ""
|
|
318
318
|
}
|
|
319
|
-
}), new
|
|
319
|
+
}), new A(m.INVALID_SCROLL_CONTAINER_SELECTORS, "config");
|
|
320
320
|
if (!et(t))
|
|
321
321
|
throw o("error", "Invalid or potentially unsafe CSS selector", {
|
|
322
322
|
showToClient: !0,
|
|
@@ -324,7 +324,7 @@ const xe = () => {
|
|
|
324
324
|
selector: t,
|
|
325
325
|
reason: "Failed security validation"
|
|
326
326
|
}
|
|
327
|
-
}), new
|
|
327
|
+
}), new A("Invalid or potentially unsafe CSS selector", "config");
|
|
328
328
|
}
|
|
329
329
|
}, rt = (r) => {
|
|
330
330
|
if (r) {
|
|
@@ -352,7 +352,7 @@ const xe = () => {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
}, st = (r) => {
|
|
355
|
-
|
|
355
|
+
Ze(r);
|
|
356
356
|
const e = {
|
|
357
357
|
...r ?? {},
|
|
358
358
|
sessionTimeout: r?.sessionTimeout ?? 9e5,
|
|
@@ -425,7 +425,7 @@ const xe = () => {
|
|
|
425
425
|
valid: !1,
|
|
426
426
|
error: "Event name cannot be a reserved word"
|
|
427
427
|
} : { valid: !0 }, Se = (r, e, t) => {
|
|
428
|
-
const s =
|
|
428
|
+
const s = Je(e), n = `${t} "${r}" metadata error`;
|
|
429
429
|
if (!Ie(s))
|
|
430
430
|
return {
|
|
431
431
|
valid: !1,
|
|
@@ -538,16 +538,16 @@ class lt {
|
|
|
538
538
|
this.listeners.clear();
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
|
-
const
|
|
541
|
+
const Q = {};
|
|
542
542
|
class f {
|
|
543
543
|
get(e) {
|
|
544
|
-
return
|
|
544
|
+
return Q[e];
|
|
545
545
|
}
|
|
546
546
|
set(e, t) {
|
|
547
|
-
|
|
547
|
+
Q[e] = t;
|
|
548
548
|
}
|
|
549
549
|
getState() {
|
|
550
|
-
return { ...
|
|
550
|
+
return { ...Q };
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
class ct extends f {
|
|
@@ -561,7 +561,7 @@ class ct extends f {
|
|
|
561
561
|
return Ge(e);
|
|
562
562
|
}
|
|
563
563
|
sendEventsQueueSync(e) {
|
|
564
|
-
return this.shouldSkipSend() ? !0 : this.get("config")?.integrations?.custom?.collectApiUrl ===
|
|
564
|
+
return this.shouldSkipSend() ? !0 : this.get("config")?.integrations?.custom?.collectApiUrl === X.Fail ? (o("warn", "Fail mode: simulating network failure (sync)", {
|
|
565
565
|
data: { events: e.events.length }
|
|
566
566
|
}), !1) : this.sendQueueSyncInternal(e);
|
|
567
567
|
}
|
|
@@ -570,7 +570,7 @@ class ct extends f {
|
|
|
570
570
|
const s = await this.send(e);
|
|
571
571
|
return s ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), s;
|
|
572
572
|
} catch (s) {
|
|
573
|
-
return s instanceof
|
|
573
|
+
return s instanceof y ? (this.logPermanentError("Permanent error, not retrying", s), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
async recoverPersistedEvents(e) {
|
|
@@ -583,7 +583,7 @@ class ct extends f {
|
|
|
583
583
|
const s = this.createRecoveryBody(t);
|
|
584
584
|
await this.send(s) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, s)) : e?.onFailure?.();
|
|
585
585
|
} catch (t) {
|
|
586
|
-
if (t instanceof
|
|
586
|
+
if (t instanceof y) {
|
|
587
587
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
588
588
|
return;
|
|
589
589
|
}
|
|
@@ -595,7 +595,7 @@ class ct extends f {
|
|
|
595
595
|
async send(e) {
|
|
596
596
|
if (this.shouldSkipSend())
|
|
597
597
|
return this.simulateSuccessfulSend();
|
|
598
|
-
if (this.get("config")?.integrations?.custom?.collectApiUrl ===
|
|
598
|
+
if (this.get("config")?.integrations?.custom?.collectApiUrl === X.Fail)
|
|
599
599
|
return o("warn", "Fail mode: simulating network failure", {
|
|
600
600
|
data: { events: e.events.length }
|
|
601
601
|
}), !1;
|
|
@@ -603,7 +603,7 @@ class ct extends f {
|
|
|
603
603
|
try {
|
|
604
604
|
return (await this.sendWithTimeout(s, n)).ok;
|
|
605
605
|
} catch (i) {
|
|
606
|
-
if (i instanceof
|
|
606
|
+
if (i instanceof y)
|
|
607
607
|
throw i;
|
|
608
608
|
return o("error", "Send request failed", {
|
|
609
609
|
error: i,
|
|
@@ -630,7 +630,7 @@ class ct extends f {
|
|
|
630
630
|
}
|
|
631
631
|
});
|
|
632
632
|
if (!i.ok)
|
|
633
|
-
throw i.status >= 400 && i.status < 500 ? new
|
|
633
|
+
throw i.status >= 400 && i.status < 500 ? new y(`HTTP ${i.status}: ${i.statusText}`, i.status) : new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
634
634
|
return i;
|
|
635
635
|
} finally {
|
|
636
636
|
clearTimeout(n);
|
|
@@ -713,7 +713,7 @@ class ct extends f {
|
|
|
713
713
|
}
|
|
714
714
|
logPermanentError(e, t) {
|
|
715
715
|
const s = Date.now();
|
|
716
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >=
|
|
716
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= je) && (o("error", e, {
|
|
717
717
|
data: { status: t.statusCode, message: t.message }
|
|
718
718
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: s });
|
|
719
719
|
}
|
|
@@ -779,7 +779,7 @@ class ut extends f {
|
|
|
779
779
|
const p = e === d.SESSION_START || e === d.SESSION_END;
|
|
780
780
|
if (!p && !this.checkRateLimit())
|
|
781
781
|
return;
|
|
782
|
-
const L = e,
|
|
782
|
+
const L = e, Ce = L === d.SESSION_START, be = t || this.get("pageUrl"), z = this.buildEventPayload({
|
|
783
783
|
type: L,
|
|
784
784
|
page_url: be,
|
|
785
785
|
from_page_url: s,
|
|
@@ -791,7 +791,7 @@ class ut extends f {
|
|
|
791
791
|
session_end_reason: u
|
|
792
792
|
});
|
|
793
793
|
if (!(!p && !this.shouldSample())) {
|
|
794
|
-
if (
|
|
794
|
+
if (Ce) {
|
|
795
795
|
const oe = this.get("sessionId");
|
|
796
796
|
if (!oe) {
|
|
797
797
|
o("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -806,7 +806,7 @@ class ut extends f {
|
|
|
806
806
|
this.set("hasStartSession", !0);
|
|
807
807
|
}
|
|
808
808
|
if (!this.isDuplicateEvent(z)) {
|
|
809
|
-
if (this.get("mode") ===
|
|
809
|
+
if (this.get("mode") === C.QA && L === d.CUSTOM && a) {
|
|
810
810
|
console.log("[TraceLog] Event", {
|
|
811
811
|
name: a.name,
|
|
812
812
|
...a.metadata && { metadata: a.metadata }
|
|
@@ -951,7 +951,7 @@ class ut extends f {
|
|
|
951
951
|
}
|
|
952
952
|
handleGoogleAnalyticsIntegration(e) {
|
|
953
953
|
if (this.googleAnalytics && e.type === d.CUSTOM && e.custom_event) {
|
|
954
|
-
if (this.get("mode") ===
|
|
954
|
+
if (this.get("mode") === C.QA)
|
|
955
955
|
return;
|
|
956
956
|
this.googleAnalytics.trackEvent(e.custom_event.name, e.custom_event.metadata ?? {});
|
|
957
957
|
}
|
|
@@ -1849,7 +1849,7 @@ class _t extends f {
|
|
|
1849
1849
|
const t = e.getEntries();
|
|
1850
1850
|
for (const s of t) {
|
|
1851
1851
|
const n = Number(s.duration.toFixed(2)), i = Date.now();
|
|
1852
|
-
i - this.lastLongTaskSentAt >=
|
|
1852
|
+
i - this.lastLongTaskSentAt >= Qe && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
1853
1853
|
}
|
|
1854
1854
|
},
|
|
1855
1855
|
{ type: "longtask", buffered: !0 }
|
|
@@ -1950,10 +1950,10 @@ class Tt extends f {
|
|
|
1950
1950
|
if (!this.shouldSample())
|
|
1951
1951
|
return;
|
|
1952
1952
|
const t = this.sanitize(e.message || "Unknown error");
|
|
1953
|
-
this.shouldSuppressError(
|
|
1953
|
+
this.shouldSuppressError(R.JS_ERROR, t) || this.eventManager.track({
|
|
1954
1954
|
type: d.ERROR,
|
|
1955
1955
|
error_data: {
|
|
1956
|
-
type:
|
|
1956
|
+
type: R.JS_ERROR,
|
|
1957
1957
|
message: t,
|
|
1958
1958
|
...e.filename && { filename: e.filename },
|
|
1959
1959
|
...e.lineno && { line: e.lineno },
|
|
@@ -1965,10 +1965,10 @@ class Tt extends f {
|
|
|
1965
1965
|
if (!this.shouldSample())
|
|
1966
1966
|
return;
|
|
1967
1967
|
const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
|
|
1968
|
-
this.shouldSuppressError(
|
|
1968
|
+
this.shouldSuppressError(R.PROMISE_REJECTION, s) || this.eventManager.track({
|
|
1969
1969
|
type: d.ERROR,
|
|
1970
1970
|
error_data: {
|
|
1971
|
-
type:
|
|
1971
|
+
type: R.PROMISE_REJECTION,
|
|
1972
1972
|
message: s
|
|
1973
1973
|
}
|
|
1974
1974
|
});
|
|
@@ -1996,7 +1996,7 @@ class Tt extends f {
|
|
|
1996
1996
|
}
|
|
1997
1997
|
shouldSuppressError(e, t) {
|
|
1998
1998
|
const s = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
1999
|
-
return i && s - i < de ? (this.recentErrors.set(n, s), !0) : (this.recentErrors.set(n, s), this.recentErrors.size >
|
|
1999
|
+
return i && s - i < de ? (this.recentErrors.set(n, s), !0) : (this.recentErrors.set(n, s), this.recentErrors.size > Be ? (this.recentErrors.clear(), this.recentErrors.set(n, s), !1) : (this.recentErrors.size > U && this.pruneOldErrors(), !1));
|
|
2000
2000
|
}
|
|
2001
2001
|
pruneOldErrors() {
|
|
2002
2002
|
const e = Date.now();
|
|
@@ -2040,7 +2040,7 @@ class vt extends f {
|
|
|
2040
2040
|
return;
|
|
2041
2041
|
const { valid: s, error: n, sanitizedMetadata: i } = ot(e, t);
|
|
2042
2042
|
if (!s) {
|
|
2043
|
-
if (this.get("mode") ===
|
|
2043
|
+
if (this.get("mode") === C.QA)
|
|
2044
2044
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${n}`);
|
|
2045
2045
|
return;
|
|
2046
2046
|
}
|
|
@@ -2077,7 +2077,7 @@ class vt extends f {
|
|
|
2077
2077
|
this.set("device", n);
|
|
2078
2078
|
const i = K(window.location.href, e.sensitiveQueryParams);
|
|
2079
2079
|
this.set("pageUrl", i);
|
|
2080
|
-
const a = We() ?
|
|
2080
|
+
const a = We() ? C.QA : void 0;
|
|
2081
2081
|
a && this.set("mode", a);
|
|
2082
2082
|
}
|
|
2083
2083
|
async setupIntegrations() {
|
|
@@ -2136,13 +2136,13 @@ const It = async (r) => {
|
|
|
2136
2136
|
M = !1;
|
|
2137
2137
|
}
|
|
2138
2138
|
}
|
|
2139
|
-
},
|
|
2139
|
+
}, yt = (r, e) => {
|
|
2140
2140
|
if (!h)
|
|
2141
2141
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
2142
2142
|
if (H)
|
|
2143
2143
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
2144
2144
|
h.sendCustomEvent(r, e);
|
|
2145
|
-
},
|
|
2145
|
+
}, At = (r, e) => {
|
|
2146
2146
|
if (!h || M) {
|
|
2147
2147
|
I.push({ event: r, callback: e });
|
|
2148
2148
|
return;
|
|
@@ -2168,13 +2168,13 @@ const It = async (r) => {
|
|
|
2168
2168
|
} finally {
|
|
2169
2169
|
H = !1;
|
|
2170
2170
|
}
|
|
2171
|
-
},
|
|
2171
|
+
}, Kt = {
|
|
2172
2172
|
WEB_VITALS_THRESHOLDS: Te
|
|
2173
2173
|
// Business thresholds for performance analysis
|
|
2174
|
-
},
|
|
2174
|
+
}, qt = {
|
|
2175
2175
|
PII_PATTERNS: ve
|
|
2176
2176
|
// Patterns for sensitive data protection
|
|
2177
|
-
},
|
|
2177
|
+
}, Jt = {
|
|
2178
2178
|
LOW_ACTIVITY_EVENT_COUNT: 50,
|
|
2179
2179
|
HIGH_ACTIVITY_EVENT_COUNT: 1e3,
|
|
2180
2180
|
MIN_EVENTS_FOR_DYNAMIC_CALCULATION: 100,
|
|
@@ -2184,7 +2184,7 @@ const It = async (r) => {
|
|
|
2184
2184
|
MIN_ENGAGED_SESSION_DURATION_MS: 30 * 1e3,
|
|
2185
2185
|
MIN_SCROLL_DEPTH_ENGAGEMENT: 25
|
|
2186
2186
|
// 25% scroll depth for engagement
|
|
2187
|
-
},
|
|
2187
|
+
}, Zt = {
|
|
2188
2188
|
INACTIVITY_TIMEOUT_MS: 30 * 60 * 1e3,
|
|
2189
2189
|
// 30min for analytics (vs 15min client)
|
|
2190
2190
|
SHORT_SESSION_THRESHOLD_MS: 30 * 1e3,
|
|
@@ -2192,20 +2192,20 @@ const It = async (r) => {
|
|
|
2192
2192
|
LONG_SESSION_THRESHOLD_MS: 30 * 60 * 1e3,
|
|
2193
2193
|
MAX_REALISTIC_SESSION_DURATION_MS: 8 * 60 * 60 * 1e3
|
|
2194
2194
|
// Filter outliers
|
|
2195
|
-
},
|
|
2195
|
+
}, er = {
|
|
2196
2196
|
MOBILE_MAX_WIDTH: 768,
|
|
2197
2197
|
TABLET_MAX_WIDTH: 1024,
|
|
2198
2198
|
MOBILE_PERFORMANCE_FACTOR: 1.5,
|
|
2199
2199
|
// Mobile typically 1.5x slower
|
|
2200
2200
|
TABLET_PERFORMANCE_FACTOR: 1.2
|
|
2201
|
-
},
|
|
2201
|
+
}, tr = {
|
|
2202
2202
|
MIN_TEXT_LENGTH_FOR_ANALYSIS: 10,
|
|
2203
2203
|
MIN_CLICKS_FOR_HOT_ELEMENT: 10,
|
|
2204
2204
|
// Popular element threshold
|
|
2205
2205
|
MIN_SCROLL_COMPLETION_PERCENT: 80,
|
|
2206
2206
|
// Page consumption threshold
|
|
2207
2207
|
MIN_TIME_ON_PAGE_FOR_READ_MS: 15 * 1e3
|
|
2208
|
-
},
|
|
2208
|
+
}, rr = {
|
|
2209
2209
|
SIGNIFICANT_CHANGE_PERCENT: 20,
|
|
2210
2210
|
MAJOR_CHANGE_PERCENT: 50,
|
|
2211
2211
|
MIN_EVENTS_FOR_INSIGHT: 100,
|
|
@@ -2215,19 +2215,19 @@ const It = async (r) => {
|
|
|
2215
2215
|
LOW_ERROR_RATE_PERCENT: 1,
|
|
2216
2216
|
HIGH_ERROR_RATE_PERCENT: 5,
|
|
2217
2217
|
CRITICAL_ERROR_RATE_PERCENT: 10
|
|
2218
|
-
},
|
|
2218
|
+
}, sr = {
|
|
2219
2219
|
SHORT_TERM_TREND_HOURS: 24,
|
|
2220
2220
|
MEDIUM_TERM_TREND_DAYS: 7,
|
|
2221
2221
|
LONG_TERM_TREND_DAYS: 30,
|
|
2222
2222
|
MIN_DATA_POINTS_FOR_TREND: 5,
|
|
2223
2223
|
WEEKLY_PATTERN_MIN_WEEKS: 4,
|
|
2224
2224
|
DAILY_PATTERN_MIN_DAYS: 14
|
|
2225
|
-
},
|
|
2225
|
+
}, nr = {
|
|
2226
2226
|
MIN_SEGMENT_SIZE: 10,
|
|
2227
2227
|
MIN_COHORT_SIZE: 5,
|
|
2228
2228
|
COHORT_ANALYSIS_DAYS: [1, 3, 7, 14, 30],
|
|
2229
2229
|
MIN_FUNNEL_EVENTS: 20
|
|
2230
|
-
},
|
|
2230
|
+
}, ir = {
|
|
2231
2231
|
DEFAULT_EVENTS_LIMIT: 5,
|
|
2232
2232
|
DEFAULT_SESSIONS_LIMIT: 5,
|
|
2233
2233
|
DEFAULT_PAGES_LIMIT: 5,
|
|
@@ -2235,27 +2235,27 @@ const It = async (r) => {
|
|
|
2235
2235
|
MAX_TIME_RANGE_DAYS: 365,
|
|
2236
2236
|
ANALYTICS_BATCH_SIZE: 1e3
|
|
2237
2237
|
// For historical analysis
|
|
2238
|
-
},
|
|
2238
|
+
}, ar = {
|
|
2239
2239
|
ANOMALY_THRESHOLD_SIGMA: 2.5,
|
|
2240
2240
|
STRONG_ANOMALY_THRESHOLD_SIGMA: 3,
|
|
2241
2241
|
TRAFFIC_DROP_ALERT_PERCENT: -30,
|
|
2242
2242
|
TRAFFIC_SPIKE_ALERT_PERCENT: 200,
|
|
2243
2243
|
MIN_BASELINE_DAYS: 7,
|
|
2244
2244
|
MIN_EVENTS_FOR_ANOMALY_DETECTION: 50
|
|
2245
|
-
},
|
|
2245
|
+
}, or = {
|
|
2246
2246
|
PAGE_URL_EXCLUDED: "excluded",
|
|
2247
2247
|
PAGE_URL_UNKNOWN: "unknown"
|
|
2248
|
-
},
|
|
2248
|
+
}, lr = {
|
|
2249
2249
|
init: It,
|
|
2250
|
-
event:
|
|
2251
|
-
on:
|
|
2250
|
+
event: yt,
|
|
2251
|
+
on: At,
|
|
2252
2252
|
off: wt,
|
|
2253
2253
|
isInitialized: Mt,
|
|
2254
2254
|
destroy: Nt
|
|
2255
2255
|
};
|
|
2256
|
-
var
|
|
2256
|
+
var J, ye = -1, N = function(r) {
|
|
2257
2257
|
addEventListener("pageshow", function(e) {
|
|
2258
|
-
e.persisted && (
|
|
2258
|
+
e.persisted && (ye = e.timeStamp, r(e));
|
|
2259
2259
|
}, !0);
|
|
2260
2260
|
}, ne = function() {
|
|
2261
2261
|
var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
@@ -2265,7 +2265,7 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2265
2265
|
return r && r.activationStart || 0;
|
|
2266
2266
|
}, E = function(r, e) {
|
|
2267
2267
|
var t = ne(), s = "navigate";
|
|
2268
|
-
return
|
|
2268
|
+
return ye >= 0 ? s = "back-forward-cache" : t && (document.prerendering || F() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: r, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
|
|
2269
2269
|
}, O = function(r, e, t) {
|
|
2270
2270
|
try {
|
|
2271
2271
|
if (PerformanceObserver.supportedEntryTypes.includes(r)) {
|
|
@@ -2308,7 +2308,7 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2308
2308
|
addEventListener("visibilitychange", V, !0), addEventListener("prerenderingchange", V, !0);
|
|
2309
2309
|
}, Lt = function() {
|
|
2310
2310
|
removeEventListener("visibilitychange", V, !0), removeEventListener("prerenderingchange", V, !0);
|
|
2311
|
-
},
|
|
2311
|
+
}, Ae = function() {
|
|
2312
2312
|
return w < 0 && (w = me(), pe(), N(function() {
|
|
2313
2313
|
setTimeout(function() {
|
|
2314
2314
|
w = me(), pe();
|
|
@@ -2320,20 +2320,20 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2320
2320
|
document.prerendering ? addEventListener("prerenderingchange", function() {
|
|
2321
2321
|
return r();
|
|
2322
2322
|
}, !0) : r();
|
|
2323
|
-
},
|
|
2323
|
+
}, Z = [1800, 3e3], we = function(r, e) {
|
|
2324
2324
|
e = e || {}, $(function() {
|
|
2325
|
-
var t, s =
|
|
2325
|
+
var t, s = Ae(), n = E("FCP"), i = O("paint", function(a) {
|
|
2326
2326
|
a.forEach(function(l) {
|
|
2327
2327
|
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime - F(), 0), n.entries.push(l), t(!0)));
|
|
2328
2328
|
});
|
|
2329
2329
|
});
|
|
2330
|
-
i && (t = S(r, n,
|
|
2331
|
-
n = E("FCP"), t = S(r, n,
|
|
2330
|
+
i && (t = S(r, n, Z, e.reportAllChanges), N(function(a) {
|
|
2331
|
+
n = E("FCP"), t = S(r, n, Z, e.reportAllChanges), ie(function() {
|
|
2332
2332
|
n.value = performance.now() - a.timeStamp, t(!0);
|
|
2333
2333
|
});
|
|
2334
2334
|
}));
|
|
2335
2335
|
});
|
|
2336
|
-
}, ee = [0.1, 0.25],
|
|
2336
|
+
}, ee = [0.1, 0.25], Rt = function(r, e) {
|
|
2337
2337
|
e = e || {}, we(ae(function() {
|
|
2338
2338
|
var t, s = E("CLS", 0), n = 0, i = [], a = function(c) {
|
|
2339
2339
|
c.forEach(function(u) {
|
|
@@ -2351,14 +2351,14 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2351
2351
|
});
|
|
2352
2352
|
}), setTimeout(t, 0));
|
|
2353
2353
|
}));
|
|
2354
|
-
}, Me = 0,
|
|
2354
|
+
}, Me = 0, B = 1 / 0, D = 0, Ct = function(r) {
|
|
2355
2355
|
r.forEach(function(e) {
|
|
2356
|
-
e.interactionId && (
|
|
2356
|
+
e.interactionId && (B = Math.min(B, e.interactionId), D = Math.max(D, e.interactionId), Me = D ? (D - B) / 7 + 1 : 0);
|
|
2357
2357
|
});
|
|
2358
2358
|
}, Ne = function() {
|
|
2359
|
-
return
|
|
2359
|
+
return J ? Me : performance.interactionCount || 0;
|
|
2360
2360
|
}, bt = function() {
|
|
2361
|
-
"interactionCount" in performance ||
|
|
2361
|
+
"interactionCount" in performance || J || (J = O("event", Ct, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
2362
2362
|
}, g = [], x = /* @__PURE__ */ new Map(), Le = 0, Ot = function() {
|
|
2363
2363
|
var r = Math.min(g.length - 1, Math.floor((Ne() - Le) / 50));
|
|
2364
2364
|
return g[r];
|
|
@@ -2380,7 +2380,7 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2380
2380
|
});
|
|
2381
2381
|
}
|
|
2382
2382
|
}
|
|
2383
|
-
},
|
|
2383
|
+
}, Re = function(r) {
|
|
2384
2384
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
2385
2385
|
return r = ae(r), document.visibilityState === "hidden" ? r() : (t = e(r), G(r)), t;
|
|
2386
2386
|
}, te = [200, 500], kt = function(r, e) {
|
|
@@ -2388,7 +2388,7 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2388
2388
|
var t;
|
|
2389
2389
|
bt();
|
|
2390
2390
|
var s, n = E("INP"), i = function(l) {
|
|
2391
|
-
|
|
2391
|
+
Re(function() {
|
|
2392
2392
|
l.forEach(Dt);
|
|
2393
2393
|
var c = Ot();
|
|
2394
2394
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, s());
|
|
@@ -2400,9 +2400,9 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2400
2400
|
Le = Ne(), g.length = 0, x.clear(), n = E("INP"), s = S(r, n, te, e.reportAllChanges);
|
|
2401
2401
|
}));
|
|
2402
2402
|
}));
|
|
2403
|
-
}, re = [2500, 4e3],
|
|
2403
|
+
}, re = [2500, 4e3], j = {}, Ut = function(r, e) {
|
|
2404
2404
|
e = e || {}, $(function() {
|
|
2405
|
-
var t, s =
|
|
2405
|
+
var t, s = Ae(), n = E("LCP"), i = function(c) {
|
|
2406
2406
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach(function(u) {
|
|
2407
2407
|
u.startTime < s.firstHiddenTime && (n.value = Math.max(u.startTime - F(), 0), n.entries = [u], t());
|
|
2408
2408
|
});
|
|
@@ -2410,15 +2410,15 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2410
2410
|
if (a) {
|
|
2411
2411
|
t = S(r, n, re, e.reportAllChanges);
|
|
2412
2412
|
var l = ae(function() {
|
|
2413
|
-
|
|
2413
|
+
j[n.id] || (i(a.takeRecords()), a.disconnect(), j[n.id] = !0, t(!0));
|
|
2414
2414
|
});
|
|
2415
2415
|
["keydown", "click"].forEach(function(c) {
|
|
2416
2416
|
addEventListener(c, function() {
|
|
2417
|
-
return
|
|
2417
|
+
return Re(l);
|
|
2418
2418
|
}, { once: !0, capture: !0 });
|
|
2419
2419
|
}), G(l), N(function(c) {
|
|
2420
2420
|
n = E("LCP"), t = S(r, n, re, e.reportAllChanges), ie(function() {
|
|
2421
|
-
n.value = performance.now() - c.timeStamp,
|
|
2421
|
+
n.value = performance.now() - c.timeStamp, j[n.id] = !0, t(!0);
|
|
2422
2422
|
});
|
|
2423
2423
|
});
|
|
2424
2424
|
}
|
|
@@ -2442,56 +2442,51 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2442
2442
|
const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2443
2443
|
__proto__: null,
|
|
2444
2444
|
CLSThresholds: ee,
|
|
2445
|
-
FCPThresholds:
|
|
2445
|
+
FCPThresholds: Z,
|
|
2446
2446
|
INPThresholds: te,
|
|
2447
2447
|
LCPThresholds: re,
|
|
2448
2448
|
TTFBThresholds: se,
|
|
2449
|
-
onCLS:
|
|
2449
|
+
onCLS: Rt,
|
|
2450
2450
|
onFCP: we,
|
|
2451
2451
|
onINP: kt,
|
|
2452
2452
|
onLCP: Ut,
|
|
2453
2453
|
onTTFB: xt
|
|
2454
2454
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2455
2455
|
export {
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2456
|
+
ir as ANALYTICS_QUERY_LIMITS,
|
|
2457
|
+
ar as ANOMALY_DETECTION,
|
|
2458
|
+
A as AppConfigValidationError,
|
|
2459
|
+
tr as CONTENT_ANALYTICS,
|
|
2460
|
+
qt as DATA_PROTECTION,
|
|
2461
|
+
er as DEVICE_ANALYTICS,
|
|
2462
2462
|
_ as DeviceType,
|
|
2463
|
-
|
|
2463
|
+
Jt as ENGAGEMENT_THRESHOLDS,
|
|
2464
2464
|
W as EmitterEvent,
|
|
2465
|
-
|
|
2465
|
+
R as ErrorType,
|
|
2466
2466
|
d as EventType,
|
|
2467
|
-
|
|
2468
|
-
|
|
2467
|
+
rr as INSIGHT_THRESHOLDS,
|
|
2468
|
+
Yt as InitializationTimeoutError,
|
|
2469
2469
|
v as IntegrationValidationError,
|
|
2470
|
-
|
|
2470
|
+
Wt as MAX_ARRAY_LENGTH,
|
|
2471
2471
|
zt as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
2472
|
-
jt as MAX_CUSTOM_EVENT_ARRAY_SIZE_BACKEND,
|
|
2473
|
-
Yt as MAX_CUSTOM_EVENT_JSON_SIZE_BACKEND,
|
|
2474
2472
|
$t as MAX_CUSTOM_EVENT_KEYS,
|
|
2475
|
-
Xt as MAX_CUSTOM_EVENT_KEYS_BACKEND,
|
|
2476
2473
|
Ft as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
2477
2474
|
Gt as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
nr as SESSION_ANALYTICS,
|
|
2489
|
-
hr as SPECIAL_PAGE_URLS,
|
|
2475
|
+
Bt as MAX_METADATA_NESTING_DEPTH,
|
|
2476
|
+
Qt as MAX_NESTED_OBJECT_KEYS,
|
|
2477
|
+
jt as MAX_STRING_LENGTH,
|
|
2478
|
+
Xt as MAX_STRING_LENGTH_IN_ARRAY,
|
|
2479
|
+
C as Mode,
|
|
2480
|
+
Kt as PERFORMANCE_CONFIG,
|
|
2481
|
+
y as PermanentError,
|
|
2482
|
+
nr as SEGMENTATION_ANALYTICS,
|
|
2483
|
+
Zt as SESSION_ANALYTICS,
|
|
2484
|
+
or as SPECIAL_PAGE_URLS,
|
|
2490
2485
|
le as SamplingRateValidationError,
|
|
2491
2486
|
k as ScrollDirection,
|
|
2492
2487
|
ke as SessionTimeoutValidationError,
|
|
2493
|
-
|
|
2494
|
-
|
|
2488
|
+
X as SpecialApiUrl,
|
|
2489
|
+
sr as TEMPORAL_ANALYSIS,
|
|
2495
2490
|
b as TraceLogValidationError,
|
|
2496
|
-
|
|
2491
|
+
lr as tracelog
|
|
2497
2492
|
};
|