@tracelog/lib 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -14
- package/dist/browser/tracelog.esm.js +563 -516
- 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/api.js +0 -2
- package/dist/cjs/api.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 +2 -5
- package/dist/cjs/constants/config.constants.d.ts.map +1 -1
- package/dist/cjs/constants/config.constants.js +5 -9
- package/dist/cjs/constants/config.constants.js.map +1 -1
- package/dist/cjs/constants/error.constants.d.ts +1 -1
- package/dist/cjs/constants/error.constants.d.ts.map +1 -1
- package/dist/cjs/constants/error.constants.js +1 -1
- package/dist/cjs/constants/error.constants.js.map +1 -1
- package/dist/cjs/handlers/error.handler.d.ts.map +1 -1
- package/dist/cjs/handlers/error.handler.js +1 -5
- package/dist/cjs/handlers/error.handler.js.map +1 -1
- package/dist/cjs/handlers/performance.handler.d.ts.map +1 -1
- package/dist/cjs/handlers/performance.handler.js +0 -6
- package/dist/cjs/handlers/performance.handler.js.map +1 -1
- package/dist/cjs/handlers/scroll.handler.d.ts +9 -2
- package/dist/cjs/handlers/scroll.handler.d.ts.map +1 -1
- package/dist/cjs/handlers/scroll.handler.js +133 -35
- package/dist/cjs/handlers/scroll.handler.js.map +1 -1
- package/dist/cjs/managers/event.manager.d.ts.map +1 -1
- package/dist/cjs/managers/event.manager.js +0 -14
- package/dist/cjs/managers/event.manager.js.map +1 -1
- package/dist/cjs/managers/sender.manager.d.ts.map +1 -1
- package/dist/cjs/managers/sender.manager.js +1 -15
- package/dist/cjs/managers/sender.manager.js.map +1 -1
- package/dist/cjs/types/config.types.d.ts +4 -4
- package/dist/cjs/types/config.types.d.ts.map +1 -1
- package/dist/cjs/types/event.types.d.ts +18 -0
- package/dist/cjs/types/event.types.d.ts.map +1 -1
- package/dist/cjs/types/event.types.js +9 -0
- package/dist/cjs/types/event.types.js.map +1 -1
- package/dist/cjs/utils/validations/config-validations.utils.d.ts.map +1 -1
- package/dist/cjs/utils/validations/config-validations.utils.js +15 -77
- package/dist/cjs/utils/validations/config-validations.utils.js.map +1 -1
- package/dist/esm/api.js +0 -2
- package/dist/esm/api.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 +2 -5
- package/dist/esm/constants/config.constants.d.ts.map +1 -1
- package/dist/esm/constants/config.constants.js +3 -7
- package/dist/esm/constants/config.constants.js.map +1 -1
- package/dist/esm/constants/error.constants.d.ts +1 -1
- package/dist/esm/constants/error.constants.d.ts.map +1 -1
- package/dist/esm/constants/error.constants.js +1 -1
- package/dist/esm/constants/error.constants.js.map +1 -1
- package/dist/esm/handlers/error.handler.d.ts.map +1 -1
- package/dist/esm/handlers/error.handler.js +2 -6
- package/dist/esm/handlers/error.handler.js.map +1 -1
- package/dist/esm/handlers/performance.handler.d.ts.map +1 -1
- package/dist/esm/handlers/performance.handler.js +0 -6
- package/dist/esm/handlers/performance.handler.js.map +1 -1
- package/dist/esm/handlers/scroll.handler.d.ts +9 -2
- package/dist/esm/handlers/scroll.handler.d.ts.map +1 -1
- package/dist/esm/handlers/scroll.handler.js +133 -35
- package/dist/esm/handlers/scroll.handler.js.map +1 -1
- package/dist/esm/managers/event.manager.d.ts.map +1 -1
- package/dist/esm/managers/event.manager.js +0 -14
- package/dist/esm/managers/event.manager.js.map +1 -1
- package/dist/esm/managers/sender.manager.d.ts.map +1 -1
- package/dist/esm/managers/sender.manager.js +1 -15
- package/dist/esm/managers/sender.manager.js.map +1 -1
- package/dist/esm/types/config.types.d.ts +4 -4
- package/dist/esm/types/config.types.d.ts.map +1 -1
- package/dist/esm/types/event.types.d.ts +18 -0
- package/dist/esm/types/event.types.d.ts.map +1 -1
- package/dist/esm/types/event.types.js +7 -0
- package/dist/esm/types/event.types.js.map +1 -1
- package/dist/esm/utils/validations/config-validations.utils.d.ts.map +1 -1
- package/dist/esm/utils/validations/config-validations.utils.js +15 -77
- package/dist/esm/utils/validations/config-validations.utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const Vt = 120, Ft = 8192, Gt = 10, $t = 10, zt = 20, Qt = 1;
|
|
2
|
+
const Bt = 1e3, jt = 500, Xt = 100;
|
|
3
|
+
const D = "data-tlog", Pe = [
|
|
4
4
|
"button",
|
|
5
5
|
"a",
|
|
6
6
|
'input[type="button"]',
|
|
@@ -32,18 +32,19 @@ const P = "data-tlog", Oe = [
|
|
|
32
32
|
".menu-item",
|
|
33
33
|
"[data-testid]",
|
|
34
34
|
'[tabindex="0"]'
|
|
35
|
-
],
|
|
36
|
-
const
|
|
35
|
+
], De = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
|
|
36
|
+
const S = {
|
|
37
37
|
INVALID_SESSION_TIMEOUT: "Session timeout must be between 30000ms (30 seconds) and 86400000ms (24 hours)",
|
|
38
38
|
INVALID_SAMPLING_RATE: "Sampling rate must be between 0 and 1",
|
|
39
39
|
INVALID_ERROR_SAMPLING_RATE: "Error sampling must be between 0 and 1",
|
|
40
40
|
INVALID_TRACELOG_PROJECT_ID: "TraceLog project ID is required when integration is enabled",
|
|
41
41
|
INVALID_CUSTOM_API_URL: "Custom API URL is required when integration is enabled",
|
|
42
42
|
INVALID_GOOGLE_ANALYTICS_ID: "Google Analytics measurement ID is required when integration is enabled",
|
|
43
|
-
INVALID_SCROLL_CONTAINER_SELECTORS: "Scroll container selectors must be valid CSS selectors",
|
|
44
43
|
INVALID_GLOBAL_METADATA: "Global metadata must be an object",
|
|
45
|
-
INVALID_SENSITIVE_QUERY_PARAMS: "Sensitive query params must be an array of strings"
|
|
46
|
-
|
|
44
|
+
INVALID_SENSITIVE_QUERY_PARAMS: "Sensitive query params must be an array of strings",
|
|
45
|
+
INVALID_PRIMARY_SCROLL_SELECTOR: "Primary scroll selector must be a non-empty string",
|
|
46
|
+
INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX: "Invalid CSS selector syntax for primaryScrollSelector"
|
|
47
|
+
}, ke = [
|
|
47
48
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
48
49
|
/javascript:/gi,
|
|
49
50
|
/on\w+\s*=/gi,
|
|
@@ -51,44 +52,51 @@ const m = {
|
|
|
51
52
|
/<embed\b[^>]*>/gi,
|
|
52
53
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
53
54
|
];
|
|
54
|
-
var
|
|
55
|
-
class
|
|
55
|
+
var Y = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))(Y || {}), T = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(T || {}), K = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(K || {});
|
|
56
|
+
class w extends Error {
|
|
56
57
|
constructor(e, t) {
|
|
57
|
-
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
58
|
+
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, w);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
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 || {}),
|
|
61
|
-
|
|
61
|
+
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 || {}), U = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(U || {}), R = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(R || {});
|
|
62
|
+
function Wt(r) {
|
|
63
|
+
return r.type === "scroll" && "scroll_data" in r && r.scroll_data.is_primary === !0;
|
|
64
|
+
}
|
|
65
|
+
function Yt(r) {
|
|
66
|
+
return r.type === "scroll" && "scroll_data" in r && r.scroll_data.is_primary === !1;
|
|
67
|
+
}
|
|
68
|
+
var b = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(b || {});
|
|
69
|
+
class C extends Error {
|
|
62
70
|
constructor(e, t, s) {
|
|
63
71
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
|
-
class
|
|
74
|
+
class A extends C {
|
|
67
75
|
constructor(e, t = "config") {
|
|
68
76
|
super(e, "APP_CONFIG_INVALID", t);
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
|
-
class
|
|
79
|
+
class Ue extends C {
|
|
72
80
|
constructor(e, t = "config") {
|
|
73
81
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
class
|
|
84
|
+
class ue extends C {
|
|
77
85
|
constructor(e, t = "config") {
|
|
78
86
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
79
87
|
}
|
|
80
88
|
}
|
|
81
|
-
class v extends
|
|
89
|
+
class v extends C {
|
|
82
90
|
constructor(e, t = "config") {
|
|
83
91
|
super(e, "INTEGRATION_INVALID", t);
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
|
-
class
|
|
94
|
+
class Kt extends C {
|
|
87
95
|
constructor(e, t, s = "runtime") {
|
|
88
96
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
const
|
|
99
|
+
const He = (r, e) => {
|
|
92
100
|
if (e) {
|
|
93
101
|
if (e instanceof Error) {
|
|
94
102
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\(.*?:\d+:\d+\)/g, "");
|
|
@@ -97,14 +105,14 @@ const Ue = (r, e) => {
|
|
|
97
105
|
return `[TraceLog] ${r}: ${e instanceof Error ? e.message : "Unknown error"}`;
|
|
98
106
|
}
|
|
99
107
|
return `[TraceLog] ${r}`;
|
|
100
|
-
},
|
|
101
|
-
const { error: s, data: n, showToClient: i = !1 } = t ?? {}, a = s ?
|
|
108
|
+
}, l = (r, e, t) => {
|
|
109
|
+
const { error: s, data: n, showToClient: i = !1 } = t ?? {}, a = s ? He(e, s) : `[TraceLog] ${e}`, o = r === "error" ? "error" : r === "warn" ? "warn" : "log";
|
|
102
110
|
if (!(r === "debug" || r === "info" && !i))
|
|
103
111
|
if (n !== void 0) {
|
|
104
|
-
const c =
|
|
105
|
-
console[
|
|
106
|
-
} else n !== void 0 ? console[
|
|
107
|
-
},
|
|
112
|
+
const c = xe(n);
|
|
113
|
+
console[o](a, c);
|
|
114
|
+
} else n !== void 0 ? console[o](a, n) : console[o](a);
|
|
115
|
+
}, xe = (r) => {
|
|
108
116
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
109
117
|
for (const [s, n] of Object.entries(r)) {
|
|
110
118
|
const i = s.toLowerCase();
|
|
@@ -112,28 +120,28 @@ const Ue = (r, e) => {
|
|
|
112
120
|
}
|
|
113
121
|
return e;
|
|
114
122
|
};
|
|
115
|
-
let
|
|
116
|
-
const
|
|
117
|
-
typeof window < "u" && !
|
|
118
|
-
},
|
|
123
|
+
let q, Ie;
|
|
124
|
+
const Ve = () => {
|
|
125
|
+
typeof window < "u" && !q && (q = window.matchMedia("(pointer: coarse)"), Ie = window.matchMedia("(hover: none)"));
|
|
126
|
+
}, Fe = () => {
|
|
119
127
|
try {
|
|
120
128
|
const r = navigator;
|
|
121
129
|
if (r.userAgentData && typeof r.userAgentData.mobile == "boolean")
|
|
122
|
-
return r.userAgentData.platform && /ipad|tablet/i.test(r.userAgentData.platform) ?
|
|
123
|
-
|
|
124
|
-
const e = window.innerWidth, t =
|
|
125
|
-
return e <= 767 || a && n ?
|
|
130
|
+
return r.userAgentData.platform && /ipad|tablet/i.test(r.userAgentData.platform) ? T.Tablet : r.userAgentData.mobile ? T.Mobile : T.Desktop;
|
|
131
|
+
Ve();
|
|
132
|
+
const e = window.innerWidth, t = q?.matches ?? !1, s = Ie?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), a = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), o = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
133
|
+
return e <= 767 || a && n ? T.Mobile : e >= 768 && e <= 1024 || o || t && s && n ? T.Tablet : T.Desktop;
|
|
126
134
|
} catch (r) {
|
|
127
|
-
return
|
|
135
|
+
return l("warn", "Device detection failed, defaulting to desktop", { error: r }), T.Desktop;
|
|
128
136
|
}
|
|
129
|
-
},
|
|
137
|
+
}, I = "tlog", de = `${I}:qa_mode`, Ge = `${I}:uid`, $e = (r) => r ? `${I}:${r}:queue` : `${I}:queue`, ze = (r) => r ? `${I}:${r}:session` : `${I}:session`, Qe = (r) => r ? `${I}:${r}:broadcast` : `${I}:broadcast`, ve = {
|
|
130
138
|
LCP: 4e3,
|
|
131
139
|
FCP: 1800,
|
|
132
140
|
CLS: 0.25,
|
|
133
141
|
INP: 200,
|
|
134
142
|
TTFB: 800,
|
|
135
143
|
LONG_TASK: 50
|
|
136
|
-
}, Be = 1e3,
|
|
144
|
+
}, Be = 1e3, ye = [
|
|
137
145
|
// Email addresses
|
|
138
146
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
139
147
|
// US Phone numbers (various formats)
|
|
@@ -148,17 +156,17 @@ const xe = () => {
|
|
|
148
156
|
/Bearer\s+[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?(?:\.[A-Za-z0-9_-]+)?/gi,
|
|
149
157
|
// Passwords in connection strings (protocol://user:password@host)
|
|
150
158
|
/:\/\/[^:/]+:([^@]+)@/gi
|
|
151
|
-
],
|
|
152
|
-
if (sessionStorage.getItem(
|
|
159
|
+
], he = 500, fe = 5e3, H = 50, je = H * 2, Ae = 1, Xe = 6e4, ge = "tlog_mode", We = "qa", Ye = () => {
|
|
160
|
+
if (sessionStorage.getItem(de) === "true")
|
|
153
161
|
return !0;
|
|
154
|
-
const e = new URLSearchParams(window.location.search), s = e.get(
|
|
162
|
+
const e = new URLSearchParams(window.location.search), s = e.get(ge) === We;
|
|
155
163
|
if (s) {
|
|
156
|
-
sessionStorage.setItem(
|
|
164
|
+
sessionStorage.setItem(de, "true"), e.delete(ge);
|
|
157
165
|
const n = e.toString(), i = `${window.location.pathname}${n ? "?" + n : ""}${window.location.hash}`;
|
|
158
166
|
try {
|
|
159
167
|
window.history.replaceState({}, "", i);
|
|
160
168
|
} catch (a) {
|
|
161
|
-
|
|
169
|
+
l("warn", "History API not available, cannot replace URL", { error: a });
|
|
162
170
|
}
|
|
163
171
|
console.log(
|
|
164
172
|
"%c[TraceLog] QA Mode ACTIVE",
|
|
@@ -166,19 +174,19 @@ const xe = () => {
|
|
|
166
174
|
);
|
|
167
175
|
}
|
|
168
176
|
return s;
|
|
169
|
-
},
|
|
177
|
+
}, Se = () => {
|
|
170
178
|
const r = new URLSearchParams(window.location.search), e = {};
|
|
171
|
-
return
|
|
179
|
+
return De.forEach((s) => {
|
|
172
180
|
const n = r.get(s);
|
|
173
181
|
if (n) {
|
|
174
182
|
const i = s.split("utm_")[1];
|
|
175
183
|
e[i] = n;
|
|
176
184
|
}
|
|
177
185
|
}), Object.keys(e).length ? e : void 0;
|
|
178
|
-
},
|
|
186
|
+
}, Ke = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
|
|
179
187
|
const e = Math.random() * 16 | 0;
|
|
180
188
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
181
|
-
}),
|
|
189
|
+
}), qe = () => {
|
|
182
190
|
const r = Date.now();
|
|
183
191
|
let e = "";
|
|
184
192
|
try {
|
|
@@ -189,76 +197,76 @@ const xe = () => {
|
|
|
189
197
|
} catch {
|
|
190
198
|
}
|
|
191
199
|
return e || (e = Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")), `${r}-${e}`;
|
|
192
|
-
},
|
|
200
|
+
}, Ee = (r, e = !1) => {
|
|
193
201
|
try {
|
|
194
202
|
const t = new URL(r), s = t.protocol === "https:", n = t.protocol === "http:";
|
|
195
203
|
return s || e && n;
|
|
196
204
|
} catch {
|
|
197
205
|
return !1;
|
|
198
206
|
}
|
|
199
|
-
},
|
|
207
|
+
}, Je = (r) => {
|
|
200
208
|
if (r.integrations?.tracelog?.projectId) {
|
|
201
209
|
const n = new URL(window.location.href).hostname.split(".");
|
|
202
210
|
if (n.length === 0)
|
|
203
211
|
throw new Error("Invalid URL");
|
|
204
|
-
const i = r.integrations.tracelog.projectId, a = n.slice(-2).join("."),
|
|
205
|
-
if (!
|
|
212
|
+
const i = r.integrations.tracelog.projectId, a = n.slice(-2).join("."), o = `https://${i}.${a}/collect`;
|
|
213
|
+
if (!Ee(o))
|
|
206
214
|
throw new Error("Invalid URL");
|
|
207
|
-
return
|
|
215
|
+
return o;
|
|
208
216
|
}
|
|
209
217
|
const e = r.integrations?.custom?.collectApiUrl;
|
|
210
218
|
if (e) {
|
|
211
219
|
const t = r.integrations?.custom?.allowHttp ?? !1;
|
|
212
|
-
if (!
|
|
220
|
+
if (!Ee(e, t))
|
|
213
221
|
throw new Error("Invalid URL");
|
|
214
222
|
return e;
|
|
215
223
|
}
|
|
216
224
|
return "";
|
|
217
|
-
},
|
|
225
|
+
}, J = (r, e = []) => {
|
|
218
226
|
try {
|
|
219
227
|
const t = new URL(r), s = t.searchParams;
|
|
220
228
|
let n = !1;
|
|
221
229
|
const i = [];
|
|
222
|
-
return e.forEach((
|
|
223
|
-
s.has(
|
|
230
|
+
return e.forEach((o) => {
|
|
231
|
+
s.has(o) && (s.delete(o), n = !0, i.push(o));
|
|
224
232
|
}), !n && r.includes("?") ? r : (t.search = s.toString(), t.toString());
|
|
225
233
|
} catch (t) {
|
|
226
|
-
return
|
|
234
|
+
return l("warn", "URL normalization failed, returning original", { error: t, data: { url: r.slice(0, 100) } }), r;
|
|
227
235
|
}
|
|
228
|
-
},
|
|
236
|
+
}, me = (r) => {
|
|
229
237
|
if (!r || typeof r != "string" || r.trim().length === 0)
|
|
230
238
|
return "";
|
|
231
239
|
let e = r;
|
|
232
240
|
r.length > 1e3 && (e = r.slice(0, Math.max(0, 1e3)));
|
|
233
241
|
let t = 0;
|
|
234
|
-
for (const n of
|
|
242
|
+
for (const n of ke) {
|
|
235
243
|
const i = e;
|
|
236
244
|
e = e.replace(n, ""), i !== e && t++;
|
|
237
245
|
}
|
|
238
|
-
return t > 0 &&
|
|
246
|
+
return t > 0 && l("warn", "XSS patterns detected and removed", {
|
|
239
247
|
data: {
|
|
240
248
|
patternMatches: t,
|
|
241
249
|
originalValue: r.slice(0, 100)
|
|
242
250
|
}
|
|
243
251
|
}), e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("/", "/"), e.trim();
|
|
244
|
-
},
|
|
252
|
+
}, Z = (r, e = 0) => {
|
|
245
253
|
if (e > 3 || r == null)
|
|
246
254
|
return null;
|
|
247
255
|
if (typeof r == "string")
|
|
248
|
-
return
|
|
256
|
+
return me(r);
|
|
249
257
|
if (typeof r == "number")
|
|
250
258
|
return !Number.isFinite(r) || r < -Number.MAX_SAFE_INTEGER || r > Number.MAX_SAFE_INTEGER ? 0 : r;
|
|
251
259
|
if (typeof r == "boolean")
|
|
252
260
|
return r;
|
|
253
261
|
if (Array.isArray(r))
|
|
254
|
-
return r.slice(0, 100).map((n) =>
|
|
262
|
+
return r.slice(0, 100).map((n) => Z(n, e + 1)).filter((n) => n !== null);
|
|
255
263
|
if (typeof r == "object") {
|
|
256
264
|
const t = {}, n = Object.entries(r).slice(0, 20);
|
|
257
265
|
for (const [i, a] of n) {
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const c =
|
|
261
|
-
c !== null && (t[
|
|
266
|
+
const o = me(i);
|
|
267
|
+
if (o) {
|
|
268
|
+
const c = Z(a, e + 1);
|
|
269
|
+
c !== null && (t[o] = c);
|
|
262
270
|
}
|
|
263
271
|
}
|
|
264
272
|
return t;
|
|
@@ -268,71 +276,52 @@ const xe = () => {
|
|
|
268
276
|
if (typeof r != "object" || r === null)
|
|
269
277
|
return {};
|
|
270
278
|
try {
|
|
271
|
-
const e =
|
|
279
|
+
const e = Z(r);
|
|
272
280
|
return typeof e == "object" && e !== null ? e : {};
|
|
273
281
|
} catch (e) {
|
|
274
282
|
const t = e instanceof Error ? e.message : String(e);
|
|
275
283
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
276
284
|
}
|
|
277
|
-
},
|
|
285
|
+
}, et = (r) => {
|
|
278
286
|
if (r !== void 0 && (r === null || typeof r != "object"))
|
|
279
|
-
throw new
|
|
287
|
+
throw new A("Configuration must be an object", "config");
|
|
280
288
|
if (r) {
|
|
281
289
|
if (r.sessionTimeout !== void 0 && (typeof r.sessionTimeout != "number" || r.sessionTimeout < 3e4 || r.sessionTimeout > 864e5))
|
|
282
|
-
throw new
|
|
290
|
+
throw new Ue(S.INVALID_SESSION_TIMEOUT, "config");
|
|
283
291
|
if (r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null))
|
|
284
|
-
throw new
|
|
285
|
-
if (r.
|
|
292
|
+
throw new A(S.INVALID_GLOBAL_METADATA, "config");
|
|
293
|
+
if (r.integrations && tt(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
286
294
|
if (!Array.isArray(r.sensitiveQueryParams))
|
|
287
|
-
throw new
|
|
295
|
+
throw new A(S.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
288
296
|
for (const e of r.sensitiveQueryParams)
|
|
289
297
|
if (typeof e != "string")
|
|
290
|
-
throw new
|
|
298
|
+
throw new A("All sensitive query params must be strings", "config");
|
|
291
299
|
}
|
|
292
300
|
if (r.errorSampling !== void 0 && (typeof r.errorSampling != "number" || r.errorSampling < 0 || r.errorSampling > 1))
|
|
293
|
-
throw new
|
|
301
|
+
throw new ue(S.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
294
302
|
if (r.samplingRate !== void 0 && (typeof r.samplingRate != "number" || r.samplingRate < 0 || r.samplingRate > 1))
|
|
295
|
-
throw new
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return s === 0;
|
|
308
|
-
}, tt = (r) => {
|
|
309
|
-
const e = Array.isArray(r) ? r : [r];
|
|
310
|
-
for (const t of e) {
|
|
311
|
-
if (typeof t != "string" || t.trim() === "")
|
|
312
|
-
throw o("error", "Invalid scroll container selector", {
|
|
313
|
-
showToClient: !0,
|
|
314
|
-
data: {
|
|
315
|
-
selector: t,
|
|
316
|
-
type: typeof t,
|
|
317
|
-
isEmpty: t === "" || typeof t == "string" && t.trim() === ""
|
|
318
|
-
}
|
|
319
|
-
}), new y(m.INVALID_SCROLL_CONTAINER_SELECTORS, "config");
|
|
320
|
-
if (!et(t))
|
|
321
|
-
throw o("error", "Invalid or potentially unsafe CSS selector", {
|
|
322
|
-
showToClient: !0,
|
|
323
|
-
data: {
|
|
324
|
-
selector: t,
|
|
325
|
-
reason: "Failed security validation"
|
|
303
|
+
throw new ue(S.INVALID_SAMPLING_RATE, "config");
|
|
304
|
+
if (r.primaryScrollSelector !== void 0) {
|
|
305
|
+
if (typeof r.primaryScrollSelector != "string" || !r.primaryScrollSelector.trim())
|
|
306
|
+
throw new A(S.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
307
|
+
if (r.primaryScrollSelector !== "window")
|
|
308
|
+
try {
|
|
309
|
+
document.querySelector(r.primaryScrollSelector);
|
|
310
|
+
} catch {
|
|
311
|
+
throw new A(
|
|
312
|
+
`${S.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${r.primaryScrollSelector}"`,
|
|
313
|
+
"config"
|
|
314
|
+
);
|
|
326
315
|
}
|
|
327
|
-
|
|
316
|
+
}
|
|
328
317
|
}
|
|
329
|
-
},
|
|
318
|
+
}, tt = (r) => {
|
|
330
319
|
if (r) {
|
|
331
320
|
if (r.tracelog && (!r.tracelog.projectId || typeof r.tracelog.projectId != "string" || r.tracelog.projectId.trim() === ""))
|
|
332
|
-
throw new v(
|
|
321
|
+
throw new v(S.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
333
322
|
if (r.custom) {
|
|
334
323
|
if (!r.custom.collectApiUrl || typeof r.custom.collectApiUrl != "string" || r.custom.collectApiUrl.trim() === "")
|
|
335
|
-
throw new v(
|
|
324
|
+
throw new v(S.INVALID_CUSTOM_API_URL, "config");
|
|
336
325
|
if (r.custom.allowHttp !== void 0 && typeof r.custom.allowHttp != "boolean")
|
|
337
326
|
throw new v("allowHttp must be a boolean", "config");
|
|
338
327
|
const e = r.custom.collectApiUrl.trim();
|
|
@@ -346,26 +335,26 @@ const xe = () => {
|
|
|
346
335
|
}
|
|
347
336
|
if (r.googleAnalytics) {
|
|
348
337
|
if (!r.googleAnalytics.measurementId || typeof r.googleAnalytics.measurementId != "string" || r.googleAnalytics.measurementId.trim() === "")
|
|
349
|
-
throw new v(
|
|
338
|
+
throw new v(S.INVALID_GOOGLE_ANALYTICS_ID, "config");
|
|
350
339
|
if (!r.googleAnalytics.measurementId.trim().match(/^(G-|UA-)/))
|
|
351
340
|
throw new v('Google Analytics measurement ID must start with "G-" or "UA-"', "config");
|
|
352
341
|
}
|
|
353
342
|
}
|
|
354
|
-
},
|
|
355
|
-
|
|
343
|
+
}, rt = (r) => {
|
|
344
|
+
et(r);
|
|
356
345
|
const e = {
|
|
357
346
|
...r ?? {},
|
|
358
347
|
sessionTimeout: r?.sessionTimeout ?? 9e5,
|
|
359
348
|
globalMetadata: r?.globalMetadata ?? {},
|
|
360
349
|
sensitiveQueryParams: r?.sensitiveQueryParams ?? [],
|
|
361
|
-
errorSampling: r?.errorSampling ??
|
|
350
|
+
errorSampling: r?.errorSampling ?? Ae,
|
|
362
351
|
samplingRate: r?.samplingRate ?? 1
|
|
363
352
|
};
|
|
364
353
|
return e.integrations?.custom && (e.integrations.custom = {
|
|
365
354
|
...e.integrations.custom,
|
|
366
355
|
allowHttp: e.integrations.custom.allowHttp ?? !1
|
|
367
356
|
}), e;
|
|
368
|
-
},
|
|
357
|
+
}, st = (r) => {
|
|
369
358
|
if (typeof r == "string")
|
|
370
359
|
return !0;
|
|
371
360
|
if (typeof r == "object" && r !== null && !Array.isArray(r)) {
|
|
@@ -382,7 +371,7 @@ const xe = () => {
|
|
|
382
371
|
return !0;
|
|
383
372
|
}
|
|
384
373
|
return !1;
|
|
385
|
-
},
|
|
374
|
+
}, we = (r, e = 0) => {
|
|
386
375
|
if (typeof r != "object" || r === null || e > 1)
|
|
387
376
|
return !1;
|
|
388
377
|
for (const t of Object.values(r)) {
|
|
@@ -396,12 +385,12 @@ const xe = () => {
|
|
|
396
385
|
if (typeof t[0] == "string") {
|
|
397
386
|
if (!t.every((a) => typeof a == "string"))
|
|
398
387
|
return !1;
|
|
399
|
-
} else if (!t.every((a) =>
|
|
388
|
+
} else if (!t.every((a) => st(a)))
|
|
400
389
|
return !1;
|
|
401
390
|
continue;
|
|
402
391
|
}
|
|
403
392
|
if (s === "object" && e === 0) {
|
|
404
|
-
if (!
|
|
393
|
+
if (!we(t, e + 1))
|
|
405
394
|
return !1;
|
|
406
395
|
continue;
|
|
407
396
|
}
|
|
@@ -409,7 +398,7 @@ const xe = () => {
|
|
|
409
398
|
}
|
|
410
399
|
}
|
|
411
400
|
return !0;
|
|
412
|
-
},
|
|
401
|
+
}, nt = (r) => typeof r != "string" ? {
|
|
413
402
|
valid: !1,
|
|
414
403
|
error: "Event name must be a string"
|
|
415
404
|
} : r.length === 0 ? {
|
|
@@ -424,9 +413,9 @@ const xe = () => {
|
|
|
424
413
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(r.toLowerCase()) ? {
|
|
425
414
|
valid: !1,
|
|
426
415
|
error: "Event name cannot be a reserved word"
|
|
427
|
-
} : { valid: !0 },
|
|
416
|
+
} : { valid: !0 }, pe = (r, e, t) => {
|
|
428
417
|
const s = Ze(e), n = `${t} "${r}" metadata error`;
|
|
429
|
-
if (!
|
|
418
|
+
if (!we(s))
|
|
430
419
|
return {
|
|
431
420
|
valid: !1,
|
|
432
421
|
error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -450,31 +439,31 @@ const xe = () => {
|
|
|
450
439
|
valid: !1,
|
|
451
440
|
error: `${n}: object has too many keys (max 10 keys).`
|
|
452
441
|
};
|
|
453
|
-
for (const [
|
|
442
|
+
for (const [o, c] of Object.entries(s)) {
|
|
454
443
|
if (Array.isArray(c)) {
|
|
455
444
|
if (c.length > 10)
|
|
456
445
|
return {
|
|
457
446
|
valid: !1,
|
|
458
|
-
error: `${n}: array property "${
|
|
447
|
+
error: `${n}: array property "${o}" is too large (max 10 items).`
|
|
459
448
|
};
|
|
460
449
|
for (const u of c)
|
|
461
450
|
if (typeof u == "string" && u.length > 500)
|
|
462
451
|
return {
|
|
463
452
|
valid: !1,
|
|
464
|
-
error: `${n}: array property "${
|
|
453
|
+
error: `${n}: array property "${o}" contains strings that are too long (max 500 characters).`
|
|
465
454
|
};
|
|
466
455
|
}
|
|
467
456
|
if (typeof c == "string" && c.length > 1e3)
|
|
468
457
|
return {
|
|
469
458
|
valid: !1,
|
|
470
|
-
error: `${n}: property "${
|
|
459
|
+
error: `${n}: property "${o}" is too long (max 1000 characters).`
|
|
471
460
|
};
|
|
472
461
|
}
|
|
473
462
|
return {
|
|
474
463
|
valid: !0,
|
|
475
464
|
sanitizedMetadata: s
|
|
476
465
|
};
|
|
477
|
-
},
|
|
466
|
+
}, it = (r, e, t) => {
|
|
478
467
|
if (Array.isArray(e)) {
|
|
479
468
|
const s = [], n = `${t} "${r}" metadata error`;
|
|
480
469
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -484,31 +473,31 @@ const xe = () => {
|
|
|
484
473
|
valid: !1,
|
|
485
474
|
error: `${n}: array item at index ${i} must be an object.`
|
|
486
475
|
};
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
476
|
+
const o = pe(r, a, t);
|
|
477
|
+
if (!o.valid)
|
|
489
478
|
return {
|
|
490
479
|
valid: !1,
|
|
491
|
-
error: `${n}: array item at index ${i} is invalid: ${
|
|
480
|
+
error: `${n}: array item at index ${i} is invalid: ${o.error}`
|
|
492
481
|
};
|
|
493
|
-
|
|
482
|
+
o.sanitizedMetadata && s.push(o.sanitizedMetadata);
|
|
494
483
|
}
|
|
495
484
|
return {
|
|
496
485
|
valid: !0,
|
|
497
486
|
sanitizedMetadata: s
|
|
498
487
|
};
|
|
499
488
|
}
|
|
500
|
-
return
|
|
501
|
-
},
|
|
502
|
-
const t =
|
|
489
|
+
return pe(r, e, t);
|
|
490
|
+
}, at = (r, e) => {
|
|
491
|
+
const t = nt(r);
|
|
503
492
|
if (!t.valid)
|
|
504
|
-
return
|
|
493
|
+
return l("error", "Event name validation failed", {
|
|
505
494
|
showToClient: !0,
|
|
506
495
|
data: { eventName: r, error: t.error }
|
|
507
496
|
}), t;
|
|
508
497
|
if (!e)
|
|
509
498
|
return { valid: !0 };
|
|
510
|
-
const s =
|
|
511
|
-
return s.valid ||
|
|
499
|
+
const s = it(r, e, "customEvent");
|
|
500
|
+
return s.valid || l("error", "Event metadata validation failed", {
|
|
512
501
|
showToClient: !0,
|
|
513
502
|
data: {
|
|
514
503
|
eventName: r,
|
|
@@ -516,7 +505,7 @@ const xe = () => {
|
|
|
516
505
|
}
|
|
517
506
|
}), s;
|
|
518
507
|
};
|
|
519
|
-
class
|
|
508
|
+
class ot {
|
|
520
509
|
listeners = /* @__PURE__ */ new Map();
|
|
521
510
|
on(e, t) {
|
|
522
511
|
this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
|
|
@@ -538,19 +527,19 @@ class lt {
|
|
|
538
527
|
this.listeners.clear();
|
|
539
528
|
}
|
|
540
529
|
}
|
|
541
|
-
const
|
|
542
|
-
class
|
|
530
|
+
const j = {};
|
|
531
|
+
class g {
|
|
543
532
|
get(e) {
|
|
544
|
-
return
|
|
533
|
+
return j[e];
|
|
545
534
|
}
|
|
546
535
|
set(e, t) {
|
|
547
|
-
|
|
536
|
+
j[e] = t;
|
|
548
537
|
}
|
|
549
538
|
getState() {
|
|
550
|
-
return { ...
|
|
539
|
+
return { ...j };
|
|
551
540
|
}
|
|
552
541
|
}
|
|
553
|
-
class
|
|
542
|
+
class lt extends g {
|
|
554
543
|
storeManager;
|
|
555
544
|
lastPermanentErrorLog = null;
|
|
556
545
|
constructor(e) {
|
|
@@ -558,10 +547,10 @@ class ct extends f {
|
|
|
558
547
|
}
|
|
559
548
|
getQueueStorageKey() {
|
|
560
549
|
const e = this.get("userId") || "anonymous";
|
|
561
|
-
return
|
|
550
|
+
return $e(e);
|
|
562
551
|
}
|
|
563
552
|
sendEventsQueueSync(e) {
|
|
564
|
-
return this.shouldSkipSend() ? !0 : this.get("config")?.integrations?.custom?.collectApiUrl ===
|
|
553
|
+
return this.shouldSkipSend() ? !0 : this.get("config")?.integrations?.custom?.collectApiUrl === Y.Fail ? (l("warn", "Fail mode: simulating network failure (sync)", {
|
|
565
554
|
data: { events: e.events.length }
|
|
566
555
|
}), !1) : this.sendQueueSyncInternal(e);
|
|
567
556
|
}
|
|
@@ -570,7 +559,7 @@ class ct extends f {
|
|
|
570
559
|
const s = await this.send(e);
|
|
571
560
|
return s ? (this.clearPersistedEvents(), t?.onSuccess?.(e.events.length, e.events, e)) : (this.persistEvents(e), t?.onFailure?.()), s;
|
|
572
561
|
} catch (s) {
|
|
573
|
-
return s instanceof
|
|
562
|
+
return s instanceof w ? (this.logPermanentError("Permanent error, not retrying", s), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
574
563
|
}
|
|
575
564
|
}
|
|
576
565
|
async recoverPersistedEvents(e) {
|
|
@@ -583,11 +572,11 @@ class ct extends f {
|
|
|
583
572
|
const s = this.createRecoveryBody(t);
|
|
584
573
|
await this.send(s) ? (this.clearPersistedEvents(), e?.onSuccess?.(t.events.length, t.events, s)) : e?.onFailure?.();
|
|
585
574
|
} catch (t) {
|
|
586
|
-
if (t instanceof
|
|
575
|
+
if (t instanceof w) {
|
|
587
576
|
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
588
577
|
return;
|
|
589
578
|
}
|
|
590
|
-
|
|
579
|
+
l("error", "Failed to recover persisted events", { error: t });
|
|
591
580
|
}
|
|
592
581
|
}
|
|
593
582
|
stop() {
|
|
@@ -595,17 +584,17 @@ class ct extends f {
|
|
|
595
584
|
async send(e) {
|
|
596
585
|
if (this.shouldSkipSend())
|
|
597
586
|
return this.simulateSuccessfulSend();
|
|
598
|
-
if (this.get("config")?.integrations?.custom?.collectApiUrl ===
|
|
599
|
-
return
|
|
587
|
+
if (this.get("config")?.integrations?.custom?.collectApiUrl === Y.Fail)
|
|
588
|
+
return l("warn", "Fail mode: simulating network failure", {
|
|
600
589
|
data: { events: e.events.length }
|
|
601
590
|
}), !1;
|
|
602
591
|
const { url: s, payload: n } = this.prepareRequest(e);
|
|
603
592
|
try {
|
|
604
593
|
return (await this.sendWithTimeout(s, n)).ok;
|
|
605
594
|
} catch (i) {
|
|
606
|
-
if (i instanceof
|
|
595
|
+
if (i instanceof w)
|
|
607
596
|
throw i;
|
|
608
|
-
return
|
|
597
|
+
return l("error", "Send request failed", {
|
|
609
598
|
error: i,
|
|
610
599
|
data: {
|
|
611
600
|
events: e.events.length,
|
|
@@ -630,7 +619,7 @@ class ct extends f {
|
|
|
630
619
|
}
|
|
631
620
|
});
|
|
632
621
|
if (!i.ok)
|
|
633
|
-
throw i.status >= 400 && i.status < 500 ? new
|
|
622
|
+
throw i.status >= 400 && i.status < 500 ? new w(`HTTP ${i.status}: ${i.statusText}`, i.status) : new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
634
623
|
return i;
|
|
635
624
|
} finally {
|
|
636
625
|
clearTimeout(n);
|
|
@@ -639,9 +628,9 @@ class ct extends f {
|
|
|
639
628
|
sendQueueSyncInternal(e) {
|
|
640
629
|
const { url: t, payload: s } = this.prepareRequest(e), n = new Blob([s], { type: "application/json" });
|
|
641
630
|
if (!this.isSendBeaconAvailable())
|
|
642
|
-
return
|
|
631
|
+
return l("warn", "sendBeacon not available, persisting events for recovery"), this.persistEvents(e), !1;
|
|
643
632
|
const i = navigator.sendBeacon(t, n);
|
|
644
|
-
return i || (
|
|
633
|
+
return i || (l("warn", "sendBeacon rejected request, persisting events for recovery"), this.persistEvents(e)), i;
|
|
645
634
|
}
|
|
646
635
|
prepareRequest(e) {
|
|
647
636
|
const t = {
|
|
@@ -662,7 +651,7 @@ class ct extends f {
|
|
|
662
651
|
if (t)
|
|
663
652
|
return JSON.parse(t);
|
|
664
653
|
} catch (e) {
|
|
665
|
-
|
|
654
|
+
l("warn", "Failed to parse persisted data", { error: e }), this.clearPersistedEvents();
|
|
666
655
|
}
|
|
667
656
|
return null;
|
|
668
657
|
}
|
|
@@ -690,7 +679,7 @@ class ct extends f {
|
|
|
690
679
|
}, s = this.getQueueStorageKey();
|
|
691
680
|
return this.storeManager.setItem(s, JSON.stringify(t)), !!this.storeManager.getItem(s);
|
|
692
681
|
} catch (t) {
|
|
693
|
-
return
|
|
682
|
+
return l("warn", "Failed to persist events", { error: t }), !1;
|
|
694
683
|
}
|
|
695
684
|
}
|
|
696
685
|
clearPersistedEvents() {
|
|
@@ -698,7 +687,7 @@ class ct extends f {
|
|
|
698
687
|
const e = this.getQueueStorageKey();
|
|
699
688
|
this.storeManager.removeItem(e);
|
|
700
689
|
} catch (e) {
|
|
701
|
-
|
|
690
|
+
l("warn", "Failed to clear persisted events", { error: e });
|
|
702
691
|
}
|
|
703
692
|
}
|
|
704
693
|
shouldSkipSend() {
|
|
@@ -713,12 +702,12 @@ class ct extends f {
|
|
|
713
702
|
}
|
|
714
703
|
logPermanentError(e, t) {
|
|
715
704
|
const s = Date.now();
|
|
716
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= Xe) && (
|
|
705
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= Xe) && (l("error", e, {
|
|
717
706
|
data: { status: t.statusCode, message: t.message }
|
|
718
707
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: s });
|
|
719
708
|
}
|
|
720
709
|
}
|
|
721
|
-
class
|
|
710
|
+
class ct extends g {
|
|
722
711
|
googleAnalytics;
|
|
723
712
|
dataSender;
|
|
724
713
|
emitter;
|
|
@@ -730,7 +719,7 @@ class ut extends f {
|
|
|
730
719
|
rateLimitCounter = 0;
|
|
731
720
|
rateLimitWindowStart = 0;
|
|
732
721
|
constructor(e, t = null, s = null) {
|
|
733
|
-
super(), this.googleAnalytics = t, this.dataSender = new
|
|
722
|
+
super(), this.googleAnalytics = t, this.dataSender = new lt(e), this.emitter = s;
|
|
734
723
|
}
|
|
735
724
|
async recoverPersistedEvents() {
|
|
736
725
|
await this.dataSender.recoverPersistedEvents({
|
|
@@ -741,7 +730,7 @@ class ut extends f {
|
|
|
741
730
|
}
|
|
742
731
|
},
|
|
743
732
|
onFailure: () => {
|
|
744
|
-
|
|
733
|
+
l("warn", "Failed to recover persisted events");
|
|
745
734
|
}
|
|
746
735
|
});
|
|
747
736
|
}
|
|
@@ -752,16 +741,16 @@ class ut extends f {
|
|
|
752
741
|
scroll_data: n,
|
|
753
742
|
click_data: i,
|
|
754
743
|
custom_event: a,
|
|
755
|
-
web_vitals:
|
|
744
|
+
web_vitals: o,
|
|
756
745
|
error_data: c,
|
|
757
746
|
session_end_reason: u
|
|
758
747
|
}) {
|
|
759
748
|
if (!e) {
|
|
760
|
-
|
|
749
|
+
l("error", "Event type is required - event will be ignored");
|
|
761
750
|
return;
|
|
762
751
|
}
|
|
763
752
|
if (!this.get("sessionId")) {
|
|
764
|
-
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(),
|
|
753
|
+
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), l("warn", "Pending events buffer full - dropping oldest event", {
|
|
765
754
|
data: { maxBufferSize: 100 }
|
|
766
755
|
})), this.pendingEventsBuffer.push({
|
|
767
756
|
type: e,
|
|
@@ -770,50 +759,50 @@ class ut extends f {
|
|
|
770
759
|
scroll_data: n,
|
|
771
760
|
click_data: i,
|
|
772
761
|
custom_event: a,
|
|
773
|
-
web_vitals:
|
|
762
|
+
web_vitals: o,
|
|
774
763
|
error_data: c,
|
|
775
764
|
session_end_reason: u
|
|
776
765
|
});
|
|
777
766
|
return;
|
|
778
767
|
}
|
|
779
|
-
const
|
|
780
|
-
if (!
|
|
768
|
+
const f = e === d.SESSION_START || e === d.SESSION_END;
|
|
769
|
+
if (!f && !this.checkRateLimit())
|
|
781
770
|
return;
|
|
782
|
-
const
|
|
783
|
-
type:
|
|
784
|
-
page_url:
|
|
771
|
+
const _ = e, P = _ === d.SESSION_START, Q = t || this.get("pageUrl"), B = this.buildEventPayload({
|
|
772
|
+
type: _,
|
|
773
|
+
page_url: Q,
|
|
785
774
|
from_page_url: s,
|
|
786
775
|
scroll_data: n,
|
|
787
776
|
click_data: i,
|
|
788
777
|
custom_event: a,
|
|
789
|
-
web_vitals:
|
|
778
|
+
web_vitals: o,
|
|
790
779
|
error_data: c,
|
|
791
780
|
session_end_reason: u
|
|
792
781
|
});
|
|
793
|
-
if (!(!
|
|
794
|
-
if (
|
|
795
|
-
const
|
|
796
|
-
if (!
|
|
797
|
-
|
|
782
|
+
if (!(!f && !this.shouldSample())) {
|
|
783
|
+
if (P) {
|
|
784
|
+
const ce = this.get("sessionId");
|
|
785
|
+
if (!ce) {
|
|
786
|
+
l("error", "Session start event requires sessionId - event will be ignored");
|
|
798
787
|
return;
|
|
799
788
|
}
|
|
800
789
|
if (this.get("hasStartSession")) {
|
|
801
|
-
|
|
802
|
-
data: { sessionId:
|
|
790
|
+
l("warn", "Duplicate session_start detected", {
|
|
791
|
+
data: { sessionId: ce }
|
|
803
792
|
});
|
|
804
793
|
return;
|
|
805
794
|
}
|
|
806
795
|
this.set("hasStartSession", !0);
|
|
807
796
|
}
|
|
808
|
-
if (!this.isDuplicateEvent(
|
|
809
|
-
if (this.get("mode") ===
|
|
797
|
+
if (!this.isDuplicateEvent(B)) {
|
|
798
|
+
if (this.get("mode") === b.QA && _ === d.CUSTOM && a) {
|
|
810
799
|
console.log("[TraceLog] Event", {
|
|
811
800
|
name: a.name,
|
|
812
801
|
...a.metadata && { metadata: a.metadata }
|
|
813
|
-
}), this.emitEvent(
|
|
802
|
+
}), this.emitEvent(B);
|
|
814
803
|
return;
|
|
815
804
|
}
|
|
816
|
-
this.addToQueue(
|
|
805
|
+
this.addToQueue(B);
|
|
817
806
|
}
|
|
818
807
|
}
|
|
819
808
|
}
|
|
@@ -833,7 +822,7 @@ class ut extends f {
|
|
|
833
822
|
if (this.pendingEventsBuffer.length === 0)
|
|
834
823
|
return;
|
|
835
824
|
if (!this.get("sessionId")) {
|
|
836
|
-
|
|
825
|
+
l("warn", "Cannot flush pending events: session not initialized - keeping in buffer", {
|
|
837
826
|
data: { bufferedEventCount: this.pendingEventsBuffer.length }
|
|
838
827
|
});
|
|
839
828
|
return;
|
|
@@ -859,7 +848,7 @@ class ut extends f {
|
|
|
859
848
|
this.removeProcessedEvents(n), this.clearSendInterval(), this.emitEventsQueue(t);
|
|
860
849
|
},
|
|
861
850
|
onFailure: () => {
|
|
862
|
-
|
|
851
|
+
l("warn", "Async flush failed", {
|
|
863
852
|
data: { eventCount: s.length }
|
|
864
853
|
});
|
|
865
854
|
}
|
|
@@ -874,7 +863,7 @@ class ut extends f {
|
|
|
874
863
|
this.removeProcessedEvents(s), this.emitEventsQueue(e);
|
|
875
864
|
},
|
|
876
865
|
onFailure: () => {
|
|
877
|
-
|
|
866
|
+
l("warn", "Events send failed, keeping in queue", {
|
|
878
867
|
data: { eventCount: t.length }
|
|
879
868
|
});
|
|
880
869
|
}
|
|
@@ -898,7 +887,7 @@ class ut extends f {
|
|
|
898
887
|
buildEventPayload(e) {
|
|
899
888
|
const t = e.type === d.SESSION_START, s = e.page_url ?? this.get("pageUrl");
|
|
900
889
|
return {
|
|
901
|
-
id:
|
|
890
|
+
id: qe(),
|
|
902
891
|
type: e.type,
|
|
903
892
|
page_url: s,
|
|
904
893
|
timestamp: Date.now(),
|
|
@@ -910,7 +899,7 @@ class ut extends f {
|
|
|
910
899
|
...e.web_vitals && { web_vitals: e.web_vitals },
|
|
911
900
|
...e.error_data && { error_data: e.error_data },
|
|
912
901
|
...e.session_end_reason && { session_end_reason: e.session_end_reason },
|
|
913
|
-
...t &&
|
|
902
|
+
...t && Se() && { utm: Se() }
|
|
914
903
|
};
|
|
915
904
|
}
|
|
916
905
|
isDuplicateEvent(e) {
|
|
@@ -933,7 +922,7 @@ class ut extends f {
|
|
|
933
922
|
const t = this.eventsQueue.findIndex(
|
|
934
923
|
(n) => n.type !== d.SESSION_START && n.type !== d.SESSION_END
|
|
935
924
|
), s = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
|
|
936
|
-
|
|
925
|
+
l("warn", "Event queue overflow, oldest non-critical event removed", {
|
|
937
926
|
data: {
|
|
938
927
|
maxLength: 100,
|
|
939
928
|
currentLength: this.eventsQueue.length,
|
|
@@ -951,7 +940,7 @@ class ut extends f {
|
|
|
951
940
|
}
|
|
952
941
|
handleGoogleAnalyticsIntegration(e) {
|
|
953
942
|
if (this.googleAnalytics && e.type === d.CUSTOM && e.custom_event) {
|
|
954
|
-
if (this.get("mode") ===
|
|
943
|
+
if (this.get("mode") === b.QA)
|
|
955
944
|
return;
|
|
956
945
|
this.googleAnalytics.trackEvent(e.custom_event.name, e.custom_event.metadata ?? {});
|
|
957
946
|
}
|
|
@@ -969,13 +958,13 @@ class ut extends f {
|
|
|
969
958
|
this.eventsQueue = this.eventsQueue.filter((s) => !t.has(s.id));
|
|
970
959
|
}
|
|
971
960
|
emitEvent(e) {
|
|
972
|
-
this.emitter && this.emitter.emit(
|
|
961
|
+
this.emitter && this.emitter.emit(K.EVENT, e);
|
|
973
962
|
}
|
|
974
963
|
emitEventsQueue(e) {
|
|
975
|
-
this.emitter && this.emitter.emit(
|
|
964
|
+
this.emitter && this.emitter.emit(K.QUEUE, e);
|
|
976
965
|
}
|
|
977
966
|
}
|
|
978
|
-
class
|
|
967
|
+
class ut {
|
|
979
968
|
/**
|
|
980
969
|
* Gets or creates a unique user ID for the given project.
|
|
981
970
|
* The user ID is persisted in localStorage and reused across sessions.
|
|
@@ -985,14 +974,14 @@ class dt {
|
|
|
985
974
|
* @returns Persistent unique user ID
|
|
986
975
|
*/
|
|
987
976
|
static getId(e) {
|
|
988
|
-
const t =
|
|
977
|
+
const t = Ge, s = e.getItem(t);
|
|
989
978
|
if (s)
|
|
990
979
|
return s;
|
|
991
|
-
const n =
|
|
980
|
+
const n = Ke();
|
|
992
981
|
return e.setItem(t, n), n;
|
|
993
982
|
}
|
|
994
983
|
}
|
|
995
|
-
class
|
|
984
|
+
class dt extends g {
|
|
996
985
|
storageManager;
|
|
997
986
|
eventManager;
|
|
998
987
|
projectId;
|
|
@@ -1007,11 +996,11 @@ class ht extends f {
|
|
|
1007
996
|
}
|
|
1008
997
|
initCrossTabSync() {
|
|
1009
998
|
if (typeof BroadcastChannel > "u") {
|
|
1010
|
-
|
|
999
|
+
l("warn", "BroadcastChannel not supported");
|
|
1011
1000
|
return;
|
|
1012
1001
|
}
|
|
1013
1002
|
const e = this.getProjectId();
|
|
1014
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
1003
|
+
this.broadcastChannel = new BroadcastChannel(Qe(e)), this.broadcastChannel.onmessage = (t) => {
|
|
1015
1004
|
const { action: s, sessionId: n, timestamp: i, projectId: a } = t.data ?? {};
|
|
1016
1005
|
if (a === e) {
|
|
1017
1006
|
if (s === "session_end") {
|
|
@@ -1041,7 +1030,7 @@ class ht extends f {
|
|
|
1041
1030
|
timestamp: Date.now()
|
|
1042
1031
|
});
|
|
1043
1032
|
} catch (s) {
|
|
1044
|
-
|
|
1033
|
+
l("warn", "Failed to broadcast session end", { error: s, data: { sessionId: e, reason: t } });
|
|
1045
1034
|
}
|
|
1046
1035
|
}
|
|
1047
1036
|
cleanupCrossTabSync() {
|
|
@@ -1080,14 +1069,14 @@ class ht extends f {
|
|
|
1080
1069
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
1081
1070
|
}
|
|
1082
1071
|
getSessionStorageKey() {
|
|
1083
|
-
return
|
|
1072
|
+
return ze(this.getProjectId());
|
|
1084
1073
|
}
|
|
1085
1074
|
getProjectId() {
|
|
1086
1075
|
return this.projectId;
|
|
1087
1076
|
}
|
|
1088
1077
|
startTracking() {
|
|
1089
1078
|
if (this.isTracking) {
|
|
1090
|
-
|
|
1079
|
+
l("warn", "Session tracking already active");
|
|
1091
1080
|
return;
|
|
1092
1081
|
}
|
|
1093
1082
|
const e = this.recoverSession(), t = e ?? this.generateSessionId(), s = !!e;
|
|
@@ -1139,13 +1128,13 @@ class ht extends f {
|
|
|
1139
1128
|
endSession(e) {
|
|
1140
1129
|
const t = this.get("sessionId");
|
|
1141
1130
|
if (!t) {
|
|
1142
|
-
|
|
1131
|
+
l("warn", "endSession called without active session", { data: { reason: e } }), this.resetSessionState(e);
|
|
1143
1132
|
return;
|
|
1144
1133
|
}
|
|
1145
1134
|
this.eventManager.track({
|
|
1146
1135
|
type: d.SESSION_END,
|
|
1147
1136
|
session_end_reason: e
|
|
1148
|
-
}), this.eventManager.flushImmediatelySync() ||
|
|
1137
|
+
}), this.eventManager.flushImmediatelySync() || l("warn", "Sync flush failed during session end, events persisted for recovery", {
|
|
1149
1138
|
data: { reason: e, sessionId: t }
|
|
1150
1139
|
}), this.broadcastSessionEnd(t, e), this.resetSessionState(e);
|
|
1151
1140
|
}
|
|
@@ -1159,7 +1148,7 @@ class ht extends f {
|
|
|
1159
1148
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
1160
1149
|
}
|
|
1161
1150
|
}
|
|
1162
|
-
class
|
|
1151
|
+
class ht extends g {
|
|
1163
1152
|
eventManager;
|
|
1164
1153
|
storageManager;
|
|
1165
1154
|
sessionManager = null;
|
|
@@ -1171,14 +1160,14 @@ class ft extends f {
|
|
|
1171
1160
|
if (this.isActive())
|
|
1172
1161
|
return;
|
|
1173
1162
|
if (this.destroyed) {
|
|
1174
|
-
|
|
1163
|
+
l("warn", "Cannot start tracking on destroyed handler");
|
|
1175
1164
|
return;
|
|
1176
1165
|
}
|
|
1177
1166
|
const e = this.get("config"), t = e?.integrations?.tracelog?.projectId ?? e?.integrations?.custom?.collectApiUrl ?? "default";
|
|
1178
1167
|
if (!t)
|
|
1179
1168
|
throw new Error("Cannot start session tracking: config not available");
|
|
1180
1169
|
try {
|
|
1181
|
-
this.sessionManager = new
|
|
1170
|
+
this.sessionManager = new dt(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
1182
1171
|
} catch (s) {
|
|
1183
1172
|
if (this.sessionManager) {
|
|
1184
1173
|
try {
|
|
@@ -1187,7 +1176,7 @@ class ft extends f {
|
|
|
1187
1176
|
}
|
|
1188
1177
|
this.sessionManager = null;
|
|
1189
1178
|
}
|
|
1190
|
-
throw
|
|
1179
|
+
throw l("error", "Failed to start session tracking", { error: s }), s;
|
|
1191
1180
|
}
|
|
1192
1181
|
}
|
|
1193
1182
|
isActive() {
|
|
@@ -1203,7 +1192,7 @@ class ft extends f {
|
|
|
1203
1192
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0, this.set("hasStartSession", !1));
|
|
1204
1193
|
}
|
|
1205
1194
|
}
|
|
1206
|
-
class
|
|
1195
|
+
class ft extends g {
|
|
1207
1196
|
eventManager;
|
|
1208
1197
|
onTrack;
|
|
1209
1198
|
originalPushState;
|
|
@@ -1224,7 +1213,7 @@ class gt extends f {
|
|
|
1224
1213
|
};
|
|
1225
1214
|
}
|
|
1226
1215
|
trackCurrentPage = () => {
|
|
1227
|
-
const e = window.location.href, t =
|
|
1216
|
+
const e = window.location.href, t = J(e, this.get("config").sensitiveQueryParams);
|
|
1228
1217
|
if (this.get("pageUrl") === t)
|
|
1229
1218
|
return;
|
|
1230
1219
|
this.onTrack();
|
|
@@ -1239,7 +1228,7 @@ class gt extends f {
|
|
|
1239
1228
|
});
|
|
1240
1229
|
};
|
|
1241
1230
|
trackInitialPageView() {
|
|
1242
|
-
const e =
|
|
1231
|
+
const e = J(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
1243
1232
|
this.eventManager.track({
|
|
1244
1233
|
type: d.PAGE_VIEW,
|
|
1245
1234
|
page_url: e,
|
|
@@ -1257,7 +1246,7 @@ class gt extends f {
|
|
|
1257
1246
|
};
|
|
1258
1247
|
}
|
|
1259
1248
|
}
|
|
1260
|
-
class
|
|
1249
|
+
class gt extends g {
|
|
1261
1250
|
eventManager;
|
|
1262
1251
|
clickHandler;
|
|
1263
1252
|
constructor(e) {
|
|
@@ -1267,24 +1256,24 @@ class Et extends f {
|
|
|
1267
1256
|
this.clickHandler || (this.clickHandler = (e) => {
|
|
1268
1257
|
const t = e, s = t.target, n = typeof HTMLElement < "u" && s instanceof HTMLElement ? s : typeof HTMLElement < "u" && s instanceof Node && s.parentElement instanceof HTMLElement ? s.parentElement : null;
|
|
1269
1258
|
if (!n) {
|
|
1270
|
-
|
|
1259
|
+
l("warn", "Click target not found or not an element");
|
|
1271
1260
|
return;
|
|
1272
1261
|
}
|
|
1273
|
-
const i = this.findTrackingElement(n), a = this.getRelevantClickElement(n),
|
|
1262
|
+
const i = this.findTrackingElement(n), a = this.getRelevantClickElement(n), o = this.calculateClickCoordinates(t, n);
|
|
1274
1263
|
if (i) {
|
|
1275
1264
|
const u = this.extractTrackingData(i);
|
|
1276
1265
|
if (u) {
|
|
1277
|
-
const
|
|
1266
|
+
const f = this.createCustomEventData(u);
|
|
1278
1267
|
this.eventManager.track({
|
|
1279
1268
|
type: d.CUSTOM,
|
|
1280
1269
|
custom_event: {
|
|
1281
|
-
name:
|
|
1282
|
-
...
|
|
1270
|
+
name: f.name,
|
|
1271
|
+
...f.value && { metadata: { value: f.value } }
|
|
1283
1272
|
}
|
|
1284
1273
|
});
|
|
1285
1274
|
}
|
|
1286
1275
|
}
|
|
1287
|
-
const c = this.generateClickData(n, a,
|
|
1276
|
+
const c = this.generateClickData(n, a, o);
|
|
1288
1277
|
this.eventManager.track({
|
|
1289
1278
|
type: d.CLICK,
|
|
1290
1279
|
click_data: c
|
|
@@ -1295,10 +1284,10 @@ class Et extends f {
|
|
|
1295
1284
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0);
|
|
1296
1285
|
}
|
|
1297
1286
|
findTrackingElement(e) {
|
|
1298
|
-
return e.hasAttribute(`${
|
|
1287
|
+
return e.hasAttribute(`${D}-name`) ? e : e.closest(`[${D}-name]`) || void 0;
|
|
1299
1288
|
}
|
|
1300
1289
|
getRelevantClickElement(e) {
|
|
1301
|
-
for (const t of
|
|
1290
|
+
for (const t of Pe)
|
|
1302
1291
|
try {
|
|
1303
1292
|
if (e.matches(t))
|
|
1304
1293
|
return e;
|
|
@@ -1306,7 +1295,7 @@ class Et extends f {
|
|
|
1306
1295
|
if (s)
|
|
1307
1296
|
return s;
|
|
1308
1297
|
} catch (s) {
|
|
1309
|
-
|
|
1298
|
+
l("warn", "Invalid selector in element search", { error: s, data: { selector: t } });
|
|
1310
1299
|
continue;
|
|
1311
1300
|
}
|
|
1312
1301
|
return e;
|
|
@@ -1315,11 +1304,11 @@ class Et extends f {
|
|
|
1315
1304
|
return Math.max(0, Math.min(1, Number(e.toFixed(3))));
|
|
1316
1305
|
}
|
|
1317
1306
|
calculateClickCoordinates(e, t) {
|
|
1318
|
-
const s = t.getBoundingClientRect(), n = e.clientX, i = e.clientY, a = s.width > 0 ? this.clamp((n - s.left) / s.width) : 0,
|
|
1319
|
-
return { x: n, y: i, relativeX: a, relativeY:
|
|
1307
|
+
const s = t.getBoundingClientRect(), n = e.clientX, i = e.clientY, a = s.width > 0 ? this.clamp((n - s.left) / s.width) : 0, o = s.height > 0 ? this.clamp((i - s.top) / s.height) : 0;
|
|
1308
|
+
return { x: n, y: i, relativeX: a, relativeY: o };
|
|
1320
1309
|
}
|
|
1321
1310
|
extractTrackingData(e) {
|
|
1322
|
-
const t = e.getAttribute(`${
|
|
1311
|
+
const t = e.getAttribute(`${D}-name`), s = e.getAttribute(`${D}-value`);
|
|
1323
1312
|
if (t)
|
|
1324
1313
|
return {
|
|
1325
1314
|
element: e,
|
|
@@ -1328,12 +1317,12 @@ class Et extends f {
|
|
|
1328
1317
|
};
|
|
1329
1318
|
}
|
|
1330
1319
|
generateClickData(e, t, s) {
|
|
1331
|
-
const { x: n, y: i, relativeX: a, relativeY:
|
|
1320
|
+
const { x: n, y: i, relativeX: a, relativeY: o } = s, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
|
|
1332
1321
|
return {
|
|
1333
1322
|
x: n,
|
|
1334
1323
|
y: i,
|
|
1335
1324
|
relativeX: a,
|
|
1336
|
-
relativeY:
|
|
1325
|
+
relativeY: o,
|
|
1337
1326
|
tag: t.tagName.toLowerCase(),
|
|
1338
1327
|
...t.id && { id: t.id },
|
|
1339
1328
|
...t.className && { class: t.className },
|
|
@@ -1376,69 +1365,113 @@ class Et extends f {
|
|
|
1376
1365
|
};
|
|
1377
1366
|
}
|
|
1378
1367
|
}
|
|
1379
|
-
class St extends
|
|
1368
|
+
class St extends g {
|
|
1380
1369
|
eventManager;
|
|
1381
1370
|
containers = [];
|
|
1382
1371
|
limitWarningLogged = !1;
|
|
1383
1372
|
minDepthChange = 5;
|
|
1384
1373
|
minIntervalMs = 500;
|
|
1385
1374
|
maxEventsPerSession = 120;
|
|
1375
|
+
windowScrollableCache = null;
|
|
1376
|
+
retryTimeoutId = null;
|
|
1386
1377
|
constructor(e) {
|
|
1387
1378
|
super(), this.eventManager = e;
|
|
1388
1379
|
}
|
|
1389
1380
|
startTracking() {
|
|
1390
|
-
this.limitWarningLogged = !1, this.applyConfigOverrides(), this.set("scrollEventCount", 0);
|
|
1391
|
-
const e = this.get("config").scrollContainerSelectors, t = Array.isArray(e) ? e : typeof e == "string" ? [e] : [];
|
|
1392
|
-
t.length === 0 ? this.setupScrollContainer(window) : this.trySetupContainers(t, 0);
|
|
1381
|
+
this.limitWarningLogged = !1, this.applyConfigOverrides(), this.set("scrollEventCount", 0), this.tryDetectScrollContainers(0);
|
|
1393
1382
|
}
|
|
1394
1383
|
stopTracking() {
|
|
1384
|
+
this.retryTimeoutId !== null && (clearTimeout(this.retryTimeoutId), this.retryTimeoutId = null);
|
|
1395
1385
|
for (const e of this.containers)
|
|
1396
1386
|
this.clearContainerTimer(e), e.element instanceof Window ? window.removeEventListener("scroll", e.listener) : e.element.removeEventListener("scroll", e.listener);
|
|
1397
|
-
this.containers.length = 0, this.set("scrollEventCount", 0), this.limitWarningLogged = !1;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1387
|
+
this.containers.length = 0, this.set("scrollEventCount", 0), this.limitWarningLogged = !1, this.windowScrollableCache = null;
|
|
1388
|
+
}
|
|
1389
|
+
tryDetectScrollContainers(e) {
|
|
1390
|
+
const t = this.findScrollableElements();
|
|
1391
|
+
if (t.length > 0) {
|
|
1392
|
+
for (const s of t) {
|
|
1393
|
+
const n = this.getElementSelector(s);
|
|
1394
|
+
this.setupScrollContainer(s, n);
|
|
1395
|
+
}
|
|
1396
|
+
this.applyPrimaryScrollSelectorIfConfigured();
|
|
1406
1397
|
return;
|
|
1407
1398
|
}
|
|
1408
|
-
if (
|
|
1409
|
-
setTimeout(() => {
|
|
1410
|
-
this.
|
|
1399
|
+
if (e < 5) {
|
|
1400
|
+
this.retryTimeoutId = window.setTimeout(() => {
|
|
1401
|
+
this.retryTimeoutId = null, this.tryDetectScrollContainers(e + 1);
|
|
1411
1402
|
}, 200);
|
|
1412
1403
|
return;
|
|
1413
1404
|
}
|
|
1414
|
-
this.containers.length === 0 && this.setupScrollContainer(window);
|
|
1405
|
+
this.containers.length === 0 && this.setupScrollContainer(window, "window"), this.applyPrimaryScrollSelectorIfConfigured();
|
|
1406
|
+
}
|
|
1407
|
+
applyPrimaryScrollSelectorIfConfigured() {
|
|
1408
|
+
const e = this.get("config");
|
|
1409
|
+
e?.primaryScrollSelector && this.applyPrimaryScrollSelector(e.primaryScrollSelector);
|
|
1410
|
+
}
|
|
1411
|
+
findScrollableElements() {
|
|
1412
|
+
if (!document.body)
|
|
1413
|
+
return [];
|
|
1414
|
+
const e = [], t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
|
|
1415
|
+
acceptNode: (n) => {
|
|
1416
|
+
const i = n;
|
|
1417
|
+
if (!i.isConnected || !i.offsetParent)
|
|
1418
|
+
return NodeFilter.FILTER_SKIP;
|
|
1419
|
+
const a = getComputedStyle(i);
|
|
1420
|
+
return a.overflowY === "auto" || a.overflowY === "scroll" || a.overflow === "auto" || a.overflow === "scroll" ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
let s;
|
|
1424
|
+
for (; (s = t.nextNode()) && e.length < 10; ) {
|
|
1425
|
+
const n = s;
|
|
1426
|
+
this.isElementScrollable(n) && e.push(n);
|
|
1427
|
+
}
|
|
1428
|
+
return e;
|
|
1415
1429
|
}
|
|
1416
|
-
|
|
1417
|
-
if (e
|
|
1430
|
+
getElementSelector(e) {
|
|
1431
|
+
if (e === window)
|
|
1432
|
+
return "window";
|
|
1433
|
+
const t = e;
|
|
1434
|
+
if (t.id)
|
|
1435
|
+
return `#${t.id}`;
|
|
1436
|
+
if (t.className && typeof t.className == "string") {
|
|
1437
|
+
const s = t.className.split(" ").filter((n) => n.trim())[0];
|
|
1438
|
+
if (s)
|
|
1439
|
+
return `.${s}`;
|
|
1440
|
+
}
|
|
1441
|
+
return t.tagName.toLowerCase();
|
|
1442
|
+
}
|
|
1443
|
+
determineIfPrimary(e) {
|
|
1444
|
+
return this.isWindowScrollable() ? e === window : this.containers.length === 0;
|
|
1445
|
+
}
|
|
1446
|
+
setupScrollContainer(e, t) {
|
|
1447
|
+
if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
|
|
1418
1448
|
return;
|
|
1419
|
-
const
|
|
1420
|
-
this.get("suppressNextScroll") || (this.clearContainerTimer(
|
|
1421
|
-
const
|
|
1422
|
-
if (
|
|
1423
|
-
const
|
|
1424
|
-
this.processScrollEvent(
|
|
1449
|
+
const n = () => {
|
|
1450
|
+
this.get("suppressNextScroll") || (this.clearContainerTimer(c), c.debounceTimer = window.setTimeout(() => {
|
|
1451
|
+
const u = this.calculateScrollData(c);
|
|
1452
|
+
if (u) {
|
|
1453
|
+
const f = Date.now();
|
|
1454
|
+
this.processScrollEvent(c, u, f);
|
|
1425
1455
|
}
|
|
1426
|
-
|
|
1456
|
+
c.debounceTimer = null;
|
|
1427
1457
|
}, 250));
|
|
1428
|
-
},
|
|
1458
|
+
}, i = this.getScrollTop(e), a = this.calculateScrollDepth(
|
|
1459
|
+
i,
|
|
1460
|
+
this.getScrollHeight(e),
|
|
1461
|
+
this.getViewportHeight(e)
|
|
1462
|
+
), o = this.determineIfPrimary(e), c = {
|
|
1429
1463
|
element: e,
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
),
|
|
1436
|
-
lastDirection: k.DOWN,
|
|
1464
|
+
selector: t,
|
|
1465
|
+
isPrimary: o,
|
|
1466
|
+
lastScrollPos: i,
|
|
1467
|
+
lastDepth: a,
|
|
1468
|
+
lastDirection: U.DOWN,
|
|
1437
1469
|
lastEventTime: 0,
|
|
1470
|
+
maxDepthReached: a,
|
|
1438
1471
|
debounceTimer: null,
|
|
1439
|
-
listener:
|
|
1472
|
+
listener: n
|
|
1440
1473
|
};
|
|
1441
|
-
this.containers.push(
|
|
1474
|
+
this.containers.push(c), e instanceof Window ? window.addEventListener("scroll", n, { passive: !0 }) : e.addEventListener("scroll", n, { passive: !0 });
|
|
1442
1475
|
}
|
|
1443
1476
|
processScrollEvent(e, t, s) {
|
|
1444
1477
|
if (!this.shouldEmitScrollEvent(e, t, s))
|
|
@@ -1447,7 +1480,11 @@ class St extends f {
|
|
|
1447
1480
|
const n = this.get("scrollEventCount") ?? 0;
|
|
1448
1481
|
this.set("scrollEventCount", n + 1), this.eventManager.track({
|
|
1449
1482
|
type: d.SCROLL,
|
|
1450
|
-
scroll_data:
|
|
1483
|
+
scroll_data: {
|
|
1484
|
+
...t,
|
|
1485
|
+
container_selector: e.selector,
|
|
1486
|
+
is_primary: e.isPrimary
|
|
1487
|
+
}
|
|
1451
1488
|
});
|
|
1452
1489
|
}
|
|
1453
1490
|
shouldEmitScrollEvent(e, t, s) {
|
|
@@ -1463,7 +1500,7 @@ class St extends f {
|
|
|
1463
1500
|
return Math.abs(t - e.lastDepth) >= this.minDepthChange;
|
|
1464
1501
|
}
|
|
1465
1502
|
logLimitOnce() {
|
|
1466
|
-
this.limitWarningLogged || (this.limitWarningLogged = !0,
|
|
1503
|
+
this.limitWarningLogged || (this.limitWarningLogged = !0, l("warn", "Max scroll events per session reached", {
|
|
1467
1504
|
data: { limit: this.maxEventsPerSession }
|
|
1468
1505
|
}));
|
|
1469
1506
|
}
|
|
@@ -1471,13 +1508,13 @@ class St extends f {
|
|
|
1471
1508
|
this.minDepthChange = 5, this.minIntervalMs = 500, this.maxEventsPerSession = 120;
|
|
1472
1509
|
}
|
|
1473
1510
|
isWindowScrollable() {
|
|
1474
|
-
return document.documentElement.scrollHeight > window.innerHeight;
|
|
1511
|
+
return this.windowScrollableCache !== null ? this.windowScrollableCache : (this.windowScrollableCache = document.documentElement.scrollHeight > window.innerHeight, this.windowScrollableCache);
|
|
1475
1512
|
}
|
|
1476
1513
|
clearContainerTimer(e) {
|
|
1477
1514
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
1478
1515
|
}
|
|
1479
1516
|
getScrollDirection(e, t) {
|
|
1480
|
-
return e > t ?
|
|
1517
|
+
return e > t ? U.DOWN : U.UP;
|
|
1481
1518
|
}
|
|
1482
1519
|
calculateScrollDepth(e, t, s) {
|
|
1483
1520
|
if (t <= s)
|
|
@@ -1486,11 +1523,16 @@ class St extends f {
|
|
|
1486
1523
|
return Math.min(100, Math.max(0, Math.floor(e / n * 100)));
|
|
1487
1524
|
}
|
|
1488
1525
|
calculateScrollData(e) {
|
|
1489
|
-
const { element: t, lastScrollPos: s } = e,
|
|
1490
|
-
if (
|
|
1526
|
+
const { element: t, lastScrollPos: s, lastEventTime: n } = e, i = this.getScrollTop(t), a = Date.now(), o = Math.abs(i - s);
|
|
1527
|
+
if (o < 10 || t === window && !this.isWindowScrollable())
|
|
1491
1528
|
return null;
|
|
1492
|
-
const
|
|
1493
|
-
return e.
|
|
1529
|
+
const c = this.getViewportHeight(t), u = this.getScrollHeight(t), f = this.getScrollDirection(i, s), _ = this.calculateScrollDepth(i, u, c), P = n > 0 ? a - n : 0, Q = P > 0 ? Math.round(o / P * 1e3) : 0;
|
|
1530
|
+
return _ > e.maxDepthReached && (e.maxDepthReached = _), e.lastScrollPos = i, {
|
|
1531
|
+
depth: _,
|
|
1532
|
+
direction: f,
|
|
1533
|
+
velocity: Q,
|
|
1534
|
+
max_depth_reached: e.maxDepthReached
|
|
1535
|
+
};
|
|
1494
1536
|
}
|
|
1495
1537
|
getScrollTop(e) {
|
|
1496
1538
|
return e instanceof Window ? window.scrollY : e.scrollTop;
|
|
@@ -1505,19 +1547,27 @@ class St extends f {
|
|
|
1505
1547
|
const t = getComputedStyle(e), s = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflowX === "auto" || t.overflowX === "scroll" || t.overflow === "auto" || t.overflow === "scroll", n = e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth;
|
|
1506
1548
|
return s && n;
|
|
1507
1549
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1550
|
+
applyPrimaryScrollSelector(e) {
|
|
1551
|
+
let t;
|
|
1552
|
+
if (e === "window")
|
|
1553
|
+
t = window;
|
|
1554
|
+
else {
|
|
1555
|
+
const n = document.querySelector(e);
|
|
1556
|
+
if (!(n instanceof HTMLElement)) {
|
|
1557
|
+
l("warn", `Selector "${e}" did not match an HTMLElement`);
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
t = n;
|
|
1517
1561
|
}
|
|
1562
|
+
this.containers.forEach((n) => {
|
|
1563
|
+
this.updateContainerPrimary(n, n.element === t);
|
|
1564
|
+
}), !this.containers.some((n) => n.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
|
|
1565
|
+
}
|
|
1566
|
+
updateContainerPrimary(e, t) {
|
|
1567
|
+
e.isPrimary = t;
|
|
1518
1568
|
}
|
|
1519
1569
|
}
|
|
1520
|
-
class
|
|
1570
|
+
class Et extends g {
|
|
1521
1571
|
isInitialized = !1;
|
|
1522
1572
|
async initialize() {
|
|
1523
1573
|
if (this.isInitialized)
|
|
@@ -1531,7 +1581,7 @@ class mt extends f {
|
|
|
1531
1581
|
}
|
|
1532
1582
|
await this.loadScript(e), this.configureGtag(e, t), this.isInitialized = !0;
|
|
1533
1583
|
} catch (s) {
|
|
1534
|
-
|
|
1584
|
+
l("error", "Google Analytics initialization failed", { error: s });
|
|
1535
1585
|
}
|
|
1536
1586
|
}
|
|
1537
1587
|
trackEvent(e, t) {
|
|
@@ -1540,7 +1590,7 @@ class mt extends f {
|
|
|
1540
1590
|
const s = Array.isArray(t) ? { items: t } : t;
|
|
1541
1591
|
window.gtag("event", e, s);
|
|
1542
1592
|
} catch (s) {
|
|
1543
|
-
|
|
1593
|
+
l("error", "Google Analytics event tracking failed", { error: s });
|
|
1544
1594
|
}
|
|
1545
1595
|
}
|
|
1546
1596
|
cleanup() {
|
|
@@ -1573,14 +1623,14 @@ class mt extends f {
|
|
|
1573
1623
|
`, document.head.appendChild(s);
|
|
1574
1624
|
}
|
|
1575
1625
|
}
|
|
1576
|
-
class
|
|
1626
|
+
class mt {
|
|
1577
1627
|
storage;
|
|
1578
1628
|
sessionStorageRef;
|
|
1579
1629
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
1580
1630
|
fallbackSessionStorage = /* @__PURE__ */ new Map();
|
|
1581
1631
|
hasQuotaExceededError = !1;
|
|
1582
1632
|
constructor() {
|
|
1583
|
-
this.storage = this.initializeStorage("localStorage"), this.sessionStorageRef = this.initializeStorage("sessionStorage"), this.storage ||
|
|
1633
|
+
this.storage = this.initializeStorage("localStorage"), this.sessionStorageRef = this.initializeStorage("sessionStorage"), this.storage || l("warn", "localStorage not available, using memory fallback"), this.sessionStorageRef || l("warn", "sessionStorage not available, using memory fallback");
|
|
1584
1634
|
}
|
|
1585
1635
|
/**
|
|
1586
1636
|
* Retrieves an item from storage
|
|
@@ -1604,7 +1654,7 @@ class pt {
|
|
|
1604
1654
|
}
|
|
1605
1655
|
} catch (s) {
|
|
1606
1656
|
if (s instanceof DOMException && s.name === "QuotaExceededError")
|
|
1607
|
-
if (this.hasQuotaExceededError = !0,
|
|
1657
|
+
if (this.hasQuotaExceededError = !0, l("warn", "localStorage quota exceeded, attempting cleanup", {
|
|
1608
1658
|
data: { key: e, valueSize: t.length }
|
|
1609
1659
|
}), this.cleanupOldData())
|
|
1610
1660
|
try {
|
|
@@ -1613,13 +1663,13 @@ class pt {
|
|
|
1613
1663
|
return;
|
|
1614
1664
|
}
|
|
1615
1665
|
} catch (i) {
|
|
1616
|
-
|
|
1666
|
+
l("error", "localStorage quota exceeded even after cleanup - data will not persist", {
|
|
1617
1667
|
error: i,
|
|
1618
1668
|
data: { key: e, valueSize: t.length }
|
|
1619
1669
|
});
|
|
1620
1670
|
}
|
|
1621
1671
|
else
|
|
1622
|
-
|
|
1672
|
+
l("error", "localStorage quota exceeded and no data to cleanup - data will not persist", {
|
|
1623
1673
|
error: s,
|
|
1624
1674
|
data: { key: e, valueSize: t.length }
|
|
1625
1675
|
});
|
|
@@ -1653,7 +1703,7 @@ class pt {
|
|
|
1653
1703
|
this.storage.removeItem(t);
|
|
1654
1704
|
}), this.fallbackStorage.clear();
|
|
1655
1705
|
} catch (e) {
|
|
1656
|
-
|
|
1706
|
+
l("error", "Failed to clear storage", { error: e }), this.fallbackStorage.clear();
|
|
1657
1707
|
}
|
|
1658
1708
|
}
|
|
1659
1709
|
/**
|
|
@@ -1697,7 +1747,7 @@ class pt {
|
|
|
1697
1747
|
}
|
|
1698
1748
|
}), !0) : !1;
|
|
1699
1749
|
} catch (e) {
|
|
1700
|
-
return
|
|
1750
|
+
return l("error", "Failed to cleanup old data", { error: e }), !1;
|
|
1701
1751
|
}
|
|
1702
1752
|
}
|
|
1703
1753
|
/**
|
|
@@ -1734,7 +1784,7 @@ class pt {
|
|
|
1734
1784
|
return;
|
|
1735
1785
|
}
|
|
1736
1786
|
} catch (s) {
|
|
1737
|
-
s instanceof DOMException && s.name === "QuotaExceededError" &&
|
|
1787
|
+
s instanceof DOMException && s.name === "QuotaExceededError" && l("error", "sessionStorage quota exceeded - data will not persist", {
|
|
1738
1788
|
error: s,
|
|
1739
1789
|
data: { key: e, valueSize: t.length }
|
|
1740
1790
|
});
|
|
@@ -1751,12 +1801,12 @@ class pt {
|
|
|
1751
1801
|
this.fallbackSessionStorage.delete(e);
|
|
1752
1802
|
}
|
|
1753
1803
|
}
|
|
1754
|
-
class
|
|
1804
|
+
class pt extends g {
|
|
1755
1805
|
eventManager;
|
|
1756
1806
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
1757
1807
|
observers = [];
|
|
1758
1808
|
lastLongTaskSentAt = 0;
|
|
1759
|
-
vitalThresholds =
|
|
1809
|
+
vitalThresholds = ve;
|
|
1760
1810
|
constructor(e) {
|
|
1761
1811
|
super(), this.eventManager = e;
|
|
1762
1812
|
}
|
|
@@ -1768,7 +1818,7 @@ class _t extends f {
|
|
|
1768
1818
|
try {
|
|
1769
1819
|
e.disconnect();
|
|
1770
1820
|
} catch (s) {
|
|
1771
|
-
|
|
1821
|
+
l("warn", "Failed to disconnect performance observer", { error: s, data: { observerIndex: t } });
|
|
1772
1822
|
}
|
|
1773
1823
|
}), this.observers.length = 0, this.reportedByNav.clear();
|
|
1774
1824
|
}
|
|
@@ -1792,8 +1842,8 @@ class _t extends f {
|
|
|
1792
1842
|
for (const a of i) {
|
|
1793
1843
|
if (a.hadRecentInput === !0)
|
|
1794
1844
|
continue;
|
|
1795
|
-
const
|
|
1796
|
-
e +=
|
|
1845
|
+
const o = typeof a.value == "number" ? a.value : 0;
|
|
1846
|
+
e += o;
|
|
1797
1847
|
}
|
|
1798
1848
|
this.sendVital({ type: "CLS", value: Number(e.toFixed(2)) });
|
|
1799
1849
|
},
|
|
@@ -1812,8 +1862,8 @@ class _t extends f {
|
|
|
1812
1862
|
let n = 0;
|
|
1813
1863
|
const i = s.getEntries();
|
|
1814
1864
|
for (const a of i) {
|
|
1815
|
-
const
|
|
1816
|
-
n = Math.max(n,
|
|
1865
|
+
const o = (a.processingEnd ?? 0) - (a.startTime ?? 0);
|
|
1866
|
+
n = Math.max(n, o);
|
|
1817
1867
|
}
|
|
1818
1868
|
n > 0 && this.sendVital({ type: "INP", value: Number(n.toFixed(2)) });
|
|
1819
1869
|
},
|
|
@@ -1822,13 +1872,13 @@ class _t extends f {
|
|
|
1822
1872
|
}
|
|
1823
1873
|
async initWebVitals() {
|
|
1824
1874
|
try {
|
|
1825
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
1875
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() => xt), a = (o) => (c) => {
|
|
1826
1876
|
const u = Number(c.value.toFixed(2));
|
|
1827
|
-
this.sendVital({ type:
|
|
1877
|
+
this.sendVital({ type: o, value: u });
|
|
1828
1878
|
};
|
|
1829
1879
|
e(a("LCP")), t(a("CLS")), s(a("FCP")), n(a("TTFB")), i(a("INP"));
|
|
1830
1880
|
} catch (e) {
|
|
1831
|
-
|
|
1881
|
+
l("warn", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
|
|
1832
1882
|
}
|
|
1833
1883
|
}
|
|
1834
1884
|
reportTTFB() {
|
|
@@ -1839,7 +1889,7 @@ class _t extends f {
|
|
|
1839
1889
|
const t = e.responseStart;
|
|
1840
1890
|
typeof t == "number" && Number.isFinite(t) && this.sendVital({ type: "TTFB", value: Number(t.toFixed(2)) });
|
|
1841
1891
|
} catch (e) {
|
|
1842
|
-
|
|
1892
|
+
l("warn", "Failed to report TTFB", { error: e });
|
|
1843
1893
|
}
|
|
1844
1894
|
}
|
|
1845
1895
|
observeLongTasks() {
|
|
@@ -1869,7 +1919,7 @@ class _t extends f {
|
|
|
1869
1919
|
}
|
|
1870
1920
|
trackWebVital(e, t) {
|
|
1871
1921
|
if (!Number.isFinite(t)) {
|
|
1872
|
-
|
|
1922
|
+
l("warn", "Invalid web vital value", { data: { type: e, value: t } });
|
|
1873
1923
|
return;
|
|
1874
1924
|
}
|
|
1875
1925
|
this.eventManager.track({
|
|
@@ -1888,7 +1938,7 @@ class _t extends f {
|
|
|
1888
1938
|
const t = e.startTime || performance.now(), s = Math.random().toString(36).substr(2, 5);
|
|
1889
1939
|
return `${t.toFixed(2)}_${window.location.pathname}_${s}`;
|
|
1890
1940
|
} catch (e) {
|
|
1891
|
-
return
|
|
1941
|
+
return l("warn", "Failed to get navigation ID", { error: e }), null;
|
|
1892
1942
|
}
|
|
1893
1943
|
}
|
|
1894
1944
|
isObserverSupported(e) {
|
|
@@ -1900,24 +1950,24 @@ class _t extends f {
|
|
|
1900
1950
|
try {
|
|
1901
1951
|
if (!this.isObserverSupported(e))
|
|
1902
1952
|
return !1;
|
|
1903
|
-
const i = new PerformanceObserver((a,
|
|
1953
|
+
const i = new PerformanceObserver((a, o) => {
|
|
1904
1954
|
try {
|
|
1905
|
-
t(a,
|
|
1955
|
+
t(a, o);
|
|
1906
1956
|
} catch (c) {
|
|
1907
|
-
|
|
1957
|
+
l("warn", "Observer callback failed", {
|
|
1908
1958
|
error: c,
|
|
1909
1959
|
data: { type: e }
|
|
1910
1960
|
});
|
|
1911
1961
|
}
|
|
1912
1962
|
if (n)
|
|
1913
1963
|
try {
|
|
1914
|
-
|
|
1964
|
+
o.disconnect();
|
|
1915
1965
|
} catch {
|
|
1916
1966
|
}
|
|
1917
1967
|
});
|
|
1918
1968
|
return i.observe(s ?? { type: e, buffered: !0 }), n || this.observers.push(i), !0;
|
|
1919
1969
|
} catch (i) {
|
|
1920
|
-
return
|
|
1970
|
+
return l("warn", "Failed to create performance observer", {
|
|
1921
1971
|
error: i,
|
|
1922
1972
|
data: { type: e }
|
|
1923
1973
|
}), !1;
|
|
@@ -1925,12 +1975,12 @@ class _t extends f {
|
|
|
1925
1975
|
}
|
|
1926
1976
|
shouldSendVital(e, t) {
|
|
1927
1977
|
if (typeof t != "number" || !Number.isFinite(t))
|
|
1928
|
-
return
|
|
1978
|
+
return l("warn", "Invalid web vital value", { data: { type: e, value: t } }), !1;
|
|
1929
1979
|
const s = this.vitalThresholds[e];
|
|
1930
1980
|
return !(typeof s == "number" && t <= s);
|
|
1931
1981
|
}
|
|
1932
1982
|
}
|
|
1933
|
-
class
|
|
1983
|
+
class _t extends g {
|
|
1934
1984
|
eventManager;
|
|
1935
1985
|
recentErrors = /* @__PURE__ */ new Map();
|
|
1936
1986
|
constructor(e) {
|
|
@@ -1943,17 +1993,17 @@ class Tt extends f {
|
|
|
1943
1993
|
window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.recentErrors.clear();
|
|
1944
1994
|
}
|
|
1945
1995
|
shouldSample() {
|
|
1946
|
-
const t = this.get("config")?.errorSampling ??
|
|
1996
|
+
const t = this.get("config")?.errorSampling ?? Ae;
|
|
1947
1997
|
return Math.random() < t;
|
|
1948
1998
|
}
|
|
1949
1999
|
handleError = (e) => {
|
|
1950
2000
|
if (!this.shouldSample())
|
|
1951
2001
|
return;
|
|
1952
2002
|
const t = this.sanitize(e.message || "Unknown error");
|
|
1953
|
-
this.shouldSuppressError(
|
|
2003
|
+
this.shouldSuppressError(R.JS_ERROR, t) || this.eventManager.track({
|
|
1954
2004
|
type: d.ERROR,
|
|
1955
2005
|
error_data: {
|
|
1956
|
-
type:
|
|
2006
|
+
type: R.JS_ERROR,
|
|
1957
2007
|
message: t,
|
|
1958
2008
|
...e.filename && { filename: e.filename },
|
|
1959
2009
|
...e.lineno && { line: e.lineno },
|
|
@@ -1965,10 +2015,10 @@ class Tt extends f {
|
|
|
1965
2015
|
if (!this.shouldSample())
|
|
1966
2016
|
return;
|
|
1967
2017
|
const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
|
|
1968
|
-
this.shouldSuppressError(
|
|
2018
|
+
this.shouldSuppressError(R.PROMISE_REJECTION, s) || this.eventManager.track({
|
|
1969
2019
|
type: d.ERROR,
|
|
1970
2020
|
error_data: {
|
|
1971
|
-
type:
|
|
2021
|
+
type: R.PROMISE_REJECTION,
|
|
1972
2022
|
message: s
|
|
1973
2023
|
}
|
|
1974
2024
|
});
|
|
@@ -1987,8 +2037,8 @@ class Tt extends f {
|
|
|
1987
2037
|
}
|
|
1988
2038
|
}
|
|
1989
2039
|
sanitize(e) {
|
|
1990
|
-
let t = e.length >
|
|
1991
|
-
for (const s of
|
|
2040
|
+
let t = e.length > he ? e.slice(0, he) + "..." : e;
|
|
2041
|
+
for (const s of ye) {
|
|
1992
2042
|
const n = new RegExp(s.source, s.flags);
|
|
1993
2043
|
t = t.replace(n, "[REDACTED]");
|
|
1994
2044
|
}
|
|
@@ -1996,25 +2046,25 @@ class Tt extends f {
|
|
|
1996
2046
|
}
|
|
1997
2047
|
shouldSuppressError(e, t) {
|
|
1998
2048
|
const s = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
1999
|
-
return i && s - i <
|
|
2049
|
+
return i && s - i < fe ? (this.recentErrors.set(n, s), !0) : (this.recentErrors.set(n, s), this.recentErrors.size > je ? (this.recentErrors.clear(), this.recentErrors.set(n, s), !1) : (this.recentErrors.size > H && this.pruneOldErrors(), !1));
|
|
2000
2050
|
}
|
|
2001
2051
|
pruneOldErrors() {
|
|
2002
2052
|
const e = Date.now();
|
|
2003
2053
|
for (const [n, i] of this.recentErrors.entries())
|
|
2004
|
-
e - i >
|
|
2005
|
-
if (this.recentErrors.size <=
|
|
2054
|
+
e - i > fe && this.recentErrors.delete(n);
|
|
2055
|
+
if (this.recentErrors.size <= H)
|
|
2006
2056
|
return;
|
|
2007
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size -
|
|
2057
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size - H;
|
|
2008
2058
|
for (let n = 0; n < s; n += 1) {
|
|
2009
2059
|
const i = t[n];
|
|
2010
2060
|
i && this.recentErrors.delete(i[0]);
|
|
2011
2061
|
}
|
|
2012
2062
|
}
|
|
2013
2063
|
}
|
|
2014
|
-
class
|
|
2064
|
+
class Tt extends g {
|
|
2015
2065
|
isInitialized = !1;
|
|
2016
2066
|
suppressNextScrollTimer = null;
|
|
2017
|
-
emitter = new
|
|
2067
|
+
emitter = new ot();
|
|
2018
2068
|
managers = {};
|
|
2019
2069
|
handlers = {};
|
|
2020
2070
|
integrations = {};
|
|
@@ -2023,10 +2073,10 @@ class vt extends f {
|
|
|
2023
2073
|
}
|
|
2024
2074
|
async init(e = {}) {
|
|
2025
2075
|
if (!this.isInitialized) {
|
|
2026
|
-
this.managers.storage = new
|
|
2076
|
+
this.managers.storage = new mt();
|
|
2027
2077
|
try {
|
|
2028
|
-
this.setupState(e), await this.setupIntegrations(), this.managers.event = new
|
|
2029
|
-
|
|
2078
|
+
this.setupState(e), await this.setupIntegrations(), this.managers.event = new ct(this.managers.storage, this.integrations.googleAnalytics, this.emitter), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
2079
|
+
l("warn", "Failed to recover persisted events", { error: t });
|
|
2030
2080
|
}), this.isInitialized = !0;
|
|
2031
2081
|
} catch (t) {
|
|
2032
2082
|
this.destroy(!0);
|
|
@@ -2038,9 +2088,9 @@ class vt extends f {
|
|
|
2038
2088
|
sendCustomEvent(e, t) {
|
|
2039
2089
|
if (!this.managers.event)
|
|
2040
2090
|
return;
|
|
2041
|
-
const { valid: s, error: n, sanitizedMetadata: i } =
|
|
2091
|
+
const { valid: s, error: n, sanitizedMetadata: i } = at(e, t);
|
|
2042
2092
|
if (!s) {
|
|
2043
|
-
if (this.get("mode") ===
|
|
2093
|
+
if (this.get("mode") === b.QA)
|
|
2044
2094
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${n}`);
|
|
2045
2095
|
return;
|
|
2046
2096
|
}
|
|
@@ -2063,33 +2113,33 @@ class vt extends f {
|
|
|
2063
2113
|
try {
|
|
2064
2114
|
t.stopTracking();
|
|
2065
2115
|
} catch (s) {
|
|
2066
|
-
|
|
2116
|
+
l("warn", "Failed to stop tracking", { error: s });
|
|
2067
2117
|
}
|
|
2068
2118
|
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.flushImmediatelySync(), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.set("hasStartSession", !1), this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {});
|
|
2069
2119
|
}
|
|
2070
2120
|
setupState(e = {}) {
|
|
2071
2121
|
this.set("config", e);
|
|
2072
|
-
const t =
|
|
2122
|
+
const t = ut.getId(this.managers.storage);
|
|
2073
2123
|
this.set("userId", t);
|
|
2074
|
-
const s =
|
|
2124
|
+
const s = Je(e);
|
|
2075
2125
|
this.set("collectApiUrl", s);
|
|
2076
|
-
const n =
|
|
2126
|
+
const n = Fe();
|
|
2077
2127
|
this.set("device", n);
|
|
2078
|
-
const i =
|
|
2128
|
+
const i = J(window.location.href, e.sensitiveQueryParams);
|
|
2079
2129
|
this.set("pageUrl", i);
|
|
2080
|
-
const a =
|
|
2130
|
+
const a = Ye() ? b.QA : void 0;
|
|
2081
2131
|
a && this.set("mode", a);
|
|
2082
2132
|
}
|
|
2083
2133
|
async setupIntegrations() {
|
|
2084
2134
|
if (this.get("config").integrations?.googleAnalytics?.measurementId?.trim())
|
|
2085
2135
|
try {
|
|
2086
|
-
this.integrations.googleAnalytics = new
|
|
2136
|
+
this.integrations.googleAnalytics = new Et(), await this.integrations.googleAnalytics.initialize();
|
|
2087
2137
|
} catch {
|
|
2088
2138
|
this.integrations.googleAnalytics = void 0;
|
|
2089
2139
|
}
|
|
2090
2140
|
}
|
|
2091
2141
|
initializeHandlers() {
|
|
2092
|
-
this.handlers.session = new
|
|
2142
|
+
this.handlers.session = new ht(
|
|
2093
2143
|
this.managers.storage,
|
|
2094
2144
|
this.managers.event
|
|
2095
2145
|
), this.handlers.session.startTracking();
|
|
@@ -2098,24 +2148,24 @@ class vt extends f {
|
|
|
2098
2148
|
this.set("suppressNextScroll", !1);
|
|
2099
2149
|
}, 250 * 2);
|
|
2100
2150
|
};
|
|
2101
|
-
this.handlers.pageView = new
|
|
2102
|
-
|
|
2103
|
-
}), this.handlers.error = new
|
|
2151
|
+
this.handlers.pageView = new ft(this.managers.event, e), this.handlers.pageView.startTracking(), this.handlers.click = new gt(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new St(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new pt(this.managers.event), this.handlers.performance.startTracking().catch((t) => {
|
|
2152
|
+
l("warn", "Failed to start performance tracking", { error: t });
|
|
2153
|
+
}), this.handlers.error = new _t(this.managers.event), this.handlers.error.startTracking();
|
|
2104
2154
|
}
|
|
2105
2155
|
}
|
|
2106
|
-
const
|
|
2107
|
-
let h = null,
|
|
2156
|
+
const y = [];
|
|
2157
|
+
let h = null, N = !1, x = !1;
|
|
2108
2158
|
const It = async (r) => {
|
|
2109
2159
|
if (typeof window > "u" || typeof document > "u")
|
|
2110
2160
|
throw new Error("[TraceLog] This library can only be used in a browser environment");
|
|
2111
|
-
if (!window.__traceLogDisabled && !h && !
|
|
2112
|
-
|
|
2161
|
+
if (!window.__traceLogDisabled && !h && !N) {
|
|
2162
|
+
N = !0;
|
|
2113
2163
|
try {
|
|
2114
|
-
const e =
|
|
2164
|
+
const e = rt(r ?? {}), t = new Tt();
|
|
2115
2165
|
try {
|
|
2116
|
-
|
|
2166
|
+
y.forEach(({ event: i, callback: a }) => {
|
|
2117
2167
|
t.on(i, a);
|
|
2118
|
-
}),
|
|
2168
|
+
}), y.length = 0;
|
|
2119
2169
|
const s = t.init(e), n = new Promise((i, a) => {
|
|
2120
2170
|
setTimeout(() => {
|
|
2121
2171
|
a(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -2126,55 +2176,55 @@ const It = async (r) => {
|
|
|
2126
2176
|
try {
|
|
2127
2177
|
t.destroy(!0);
|
|
2128
2178
|
} catch (n) {
|
|
2129
|
-
|
|
2179
|
+
l("error", "Failed to cleanup partially initialized app", { error: n });
|
|
2130
2180
|
}
|
|
2131
2181
|
throw s;
|
|
2132
2182
|
}
|
|
2133
2183
|
} catch (e) {
|
|
2134
2184
|
throw h = null, e;
|
|
2135
2185
|
} finally {
|
|
2136
|
-
|
|
2186
|
+
N = !1;
|
|
2137
2187
|
}
|
|
2138
2188
|
}
|
|
2139
|
-
},
|
|
2189
|
+
}, vt = (r, e) => {
|
|
2140
2190
|
if (!h)
|
|
2141
2191
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
2142
|
-
if (
|
|
2192
|
+
if (x)
|
|
2143
2193
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
2144
2194
|
h.sendCustomEvent(r, e);
|
|
2145
2195
|
}, yt = (r, e) => {
|
|
2146
|
-
if (!h ||
|
|
2147
|
-
|
|
2196
|
+
if (!h || N) {
|
|
2197
|
+
y.push({ event: r, callback: e });
|
|
2148
2198
|
return;
|
|
2149
2199
|
}
|
|
2150
2200
|
h.on(r, e);
|
|
2151
|
-
},
|
|
2201
|
+
}, At = (r, e) => {
|
|
2152
2202
|
if (!h) {
|
|
2153
|
-
const t =
|
|
2154
|
-
t !== -1 &&
|
|
2203
|
+
const t = y.findIndex((s) => s.event === r && s.callback === e);
|
|
2204
|
+
t !== -1 && y.splice(t, 1);
|
|
2155
2205
|
return;
|
|
2156
2206
|
}
|
|
2157
2207
|
h.off(r, e);
|
|
2158
|
-
},
|
|
2159
|
-
if (
|
|
2208
|
+
}, wt = () => h !== null, Mt = () => {
|
|
2209
|
+
if (x)
|
|
2160
2210
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
2161
2211
|
if (!h)
|
|
2162
2212
|
throw new Error("[TraceLog] App not initialized");
|
|
2163
|
-
|
|
2213
|
+
x = !0;
|
|
2164
2214
|
try {
|
|
2165
|
-
h.destroy(), h = null,
|
|
2215
|
+
h.destroy(), h = null, N = !1, y.length = 0;
|
|
2166
2216
|
} catch (r) {
|
|
2167
|
-
h = null,
|
|
2217
|
+
h = null, N = !1, y.length = 0, l("warn", "Error during destroy, forced cleanup completed", { error: r });
|
|
2168
2218
|
} finally {
|
|
2169
|
-
|
|
2219
|
+
x = !1;
|
|
2170
2220
|
}
|
|
2171
|
-
},
|
|
2172
|
-
WEB_VITALS_THRESHOLDS:
|
|
2221
|
+
}, qt = {
|
|
2222
|
+
WEB_VITALS_THRESHOLDS: ve
|
|
2173
2223
|
// Business thresholds for performance analysis
|
|
2174
|
-
},
|
|
2175
|
-
PII_PATTERNS:
|
|
2224
|
+
}, Jt = {
|
|
2225
|
+
PII_PATTERNS: ye
|
|
2176
2226
|
// Patterns for sensitive data protection
|
|
2177
|
-
},
|
|
2227
|
+
}, Zt = {
|
|
2178
2228
|
LOW_ACTIVITY_EVENT_COUNT: 50,
|
|
2179
2229
|
HIGH_ACTIVITY_EVENT_COUNT: 1e3,
|
|
2180
2230
|
MIN_EVENTS_FOR_DYNAMIC_CALCULATION: 100,
|
|
@@ -2184,7 +2234,7 @@ const It = async (r) => {
|
|
|
2184
2234
|
MIN_ENGAGED_SESSION_DURATION_MS: 30 * 1e3,
|
|
2185
2235
|
MIN_SCROLL_DEPTH_ENGAGEMENT: 25
|
|
2186
2236
|
// 25% scroll depth for engagement
|
|
2187
|
-
},
|
|
2237
|
+
}, er = {
|
|
2188
2238
|
INACTIVITY_TIMEOUT_MS: 30 * 60 * 1e3,
|
|
2189
2239
|
// 30min for analytics (vs 15min client)
|
|
2190
2240
|
SHORT_SESSION_THRESHOLD_MS: 30 * 1e3,
|
|
@@ -2192,20 +2242,20 @@ const It = async (r) => {
|
|
|
2192
2242
|
LONG_SESSION_THRESHOLD_MS: 30 * 60 * 1e3,
|
|
2193
2243
|
MAX_REALISTIC_SESSION_DURATION_MS: 8 * 60 * 60 * 1e3
|
|
2194
2244
|
// Filter outliers
|
|
2195
|
-
},
|
|
2245
|
+
}, tr = {
|
|
2196
2246
|
MOBILE_MAX_WIDTH: 768,
|
|
2197
2247
|
TABLET_MAX_WIDTH: 1024,
|
|
2198
2248
|
MOBILE_PERFORMANCE_FACTOR: 1.5,
|
|
2199
2249
|
// Mobile typically 1.5x slower
|
|
2200
2250
|
TABLET_PERFORMANCE_FACTOR: 1.2
|
|
2201
|
-
},
|
|
2251
|
+
}, rr = {
|
|
2202
2252
|
MIN_TEXT_LENGTH_FOR_ANALYSIS: 10,
|
|
2203
2253
|
MIN_CLICKS_FOR_HOT_ELEMENT: 10,
|
|
2204
2254
|
// Popular element threshold
|
|
2205
2255
|
MIN_SCROLL_COMPLETION_PERCENT: 80,
|
|
2206
2256
|
// Page consumption threshold
|
|
2207
2257
|
MIN_TIME_ON_PAGE_FOR_READ_MS: 15 * 1e3
|
|
2208
|
-
},
|
|
2258
|
+
}, sr = {
|
|
2209
2259
|
SIGNIFICANT_CHANGE_PERCENT: 20,
|
|
2210
2260
|
MAJOR_CHANGE_PERCENT: 50,
|
|
2211
2261
|
MIN_EVENTS_FOR_INSIGHT: 100,
|
|
@@ -2215,19 +2265,19 @@ const It = async (r) => {
|
|
|
2215
2265
|
LOW_ERROR_RATE_PERCENT: 1,
|
|
2216
2266
|
HIGH_ERROR_RATE_PERCENT: 5,
|
|
2217
2267
|
CRITICAL_ERROR_RATE_PERCENT: 10
|
|
2218
|
-
},
|
|
2268
|
+
}, nr = {
|
|
2219
2269
|
SHORT_TERM_TREND_HOURS: 24,
|
|
2220
2270
|
MEDIUM_TERM_TREND_DAYS: 7,
|
|
2221
2271
|
LONG_TERM_TREND_DAYS: 30,
|
|
2222
2272
|
MIN_DATA_POINTS_FOR_TREND: 5,
|
|
2223
2273
|
WEEKLY_PATTERN_MIN_WEEKS: 4,
|
|
2224
2274
|
DAILY_PATTERN_MIN_DAYS: 14
|
|
2225
|
-
},
|
|
2275
|
+
}, ir = {
|
|
2226
2276
|
MIN_SEGMENT_SIZE: 10,
|
|
2227
2277
|
MIN_COHORT_SIZE: 5,
|
|
2228
2278
|
COHORT_ANALYSIS_DAYS: [1, 3, 7, 14, 30],
|
|
2229
2279
|
MIN_FUNNEL_EVENTS: 20
|
|
2230
|
-
},
|
|
2280
|
+
}, ar = {
|
|
2231
2281
|
DEFAULT_EVENTS_LIMIT: 5,
|
|
2232
2282
|
DEFAULT_SESSIONS_LIMIT: 5,
|
|
2233
2283
|
DEFAULT_PAGES_LIMIT: 5,
|
|
@@ -2235,37 +2285,37 @@ const It = async (r) => {
|
|
|
2235
2285
|
MAX_TIME_RANGE_DAYS: 365,
|
|
2236
2286
|
ANALYTICS_BATCH_SIZE: 1e3
|
|
2237
2287
|
// For historical analysis
|
|
2238
|
-
},
|
|
2288
|
+
}, or = {
|
|
2239
2289
|
ANOMALY_THRESHOLD_SIGMA: 2.5,
|
|
2240
2290
|
STRONG_ANOMALY_THRESHOLD_SIGMA: 3,
|
|
2241
2291
|
TRAFFIC_DROP_ALERT_PERCENT: -30,
|
|
2242
2292
|
TRAFFIC_SPIKE_ALERT_PERCENT: 200,
|
|
2243
2293
|
MIN_BASELINE_DAYS: 7,
|
|
2244
2294
|
MIN_EVENTS_FOR_ANOMALY_DETECTION: 50
|
|
2245
|
-
},
|
|
2295
|
+
}, lr = {
|
|
2246
2296
|
PAGE_URL_EXCLUDED: "excluded",
|
|
2247
2297
|
PAGE_URL_UNKNOWN: "unknown"
|
|
2248
|
-
},
|
|
2298
|
+
}, cr = {
|
|
2249
2299
|
init: It,
|
|
2250
|
-
event:
|
|
2300
|
+
event: vt,
|
|
2251
2301
|
on: yt,
|
|
2252
|
-
off:
|
|
2253
|
-
isInitialized:
|
|
2254
|
-
destroy:
|
|
2302
|
+
off: At,
|
|
2303
|
+
isInitialized: wt,
|
|
2304
|
+
destroy: Mt
|
|
2255
2305
|
};
|
|
2256
|
-
var
|
|
2306
|
+
var ee, Me = -1, L = function(r) {
|
|
2257
2307
|
addEventListener("pageshow", function(e) {
|
|
2258
|
-
e.persisted && (
|
|
2308
|
+
e.persisted && (Me = e.timeStamp, r(e));
|
|
2259
2309
|
}, !0);
|
|
2260
|
-
},
|
|
2310
|
+
}, ae = function() {
|
|
2261
2311
|
var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
2262
2312
|
if (r && r.responseStart > 0 && r.responseStart < performance.now()) return r;
|
|
2263
|
-
},
|
|
2264
|
-
var r =
|
|
2313
|
+
}, G = function() {
|
|
2314
|
+
var r = ae();
|
|
2265
2315
|
return r && r.activationStart || 0;
|
|
2266
|
-
},
|
|
2267
|
-
var t =
|
|
2268
|
-
return
|
|
2316
|
+
}, m = function(r, e) {
|
|
2317
|
+
var t = ae(), s = "navigate";
|
|
2318
|
+
return Me >= 0 ? s = "back-forward-cache" : t && (document.prerendering || G() > 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
2319
|
}, O = function(r, e, t) {
|
|
2270
2320
|
try {
|
|
2271
2321
|
if (PerformanceObserver.supportedEntryTypes.includes(r)) {
|
|
@@ -2278,220 +2328,217 @@ var Z, Ae = -1, N = function(r) {
|
|
|
2278
2328
|
}
|
|
2279
2329
|
} catch {
|
|
2280
2330
|
}
|
|
2281
|
-
},
|
|
2331
|
+
}, p = function(r, e, t, s) {
|
|
2282
2332
|
var n, i;
|
|
2283
2333
|
return function(a) {
|
|
2284
|
-
e.value >= 0 && (a || s) && ((i = e.value - (n || 0)) || n === void 0) && (n = e.value, e.delta = i, e.rating = function(
|
|
2285
|
-
return
|
|
2334
|
+
e.value >= 0 && (a || s) && ((i = e.value - (n || 0)) || n === void 0) && (n = e.value, e.delta = i, e.rating = function(o, c) {
|
|
2335
|
+
return o > c[1] ? "poor" : o > c[0] ? "needs-improvement" : "good";
|
|
2286
2336
|
}(e.value, t), r(e));
|
|
2287
2337
|
};
|
|
2288
|
-
},
|
|
2338
|
+
}, oe = function(r) {
|
|
2289
2339
|
requestAnimationFrame(function() {
|
|
2290
2340
|
return requestAnimationFrame(function() {
|
|
2291
2341
|
return r();
|
|
2292
2342
|
});
|
|
2293
2343
|
});
|
|
2294
|
-
},
|
|
2344
|
+
}, $ = function(r) {
|
|
2295
2345
|
document.addEventListener("visibilitychange", function() {
|
|
2296
2346
|
document.visibilityState === "hidden" && r();
|
|
2297
2347
|
});
|
|
2298
|
-
},
|
|
2348
|
+
}, le = function(r) {
|
|
2299
2349
|
var e = !1;
|
|
2300
2350
|
return function() {
|
|
2301
2351
|
e || (r(), e = !0);
|
|
2302
2352
|
};
|
|
2303
|
-
},
|
|
2353
|
+
}, M = -1, _e = function() {
|
|
2304
2354
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
2305
|
-
},
|
|
2306
|
-
document.visibilityState === "hidden" &&
|
|
2307
|
-
},
|
|
2308
|
-
addEventListener("visibilitychange",
|
|
2309
|
-
},
|
|
2310
|
-
removeEventListener("visibilitychange",
|
|
2311
|
-
},
|
|
2312
|
-
return
|
|
2355
|
+
}, F = function(r) {
|
|
2356
|
+
document.visibilityState === "hidden" && M > -1 && (M = r.type === "visibilitychange" ? r.timeStamp : 0, Nt());
|
|
2357
|
+
}, Te = function() {
|
|
2358
|
+
addEventListener("visibilitychange", F, !0), addEventListener("prerenderingchange", F, !0);
|
|
2359
|
+
}, Nt = function() {
|
|
2360
|
+
removeEventListener("visibilitychange", F, !0), removeEventListener("prerenderingchange", F, !0);
|
|
2361
|
+
}, Ne = function() {
|
|
2362
|
+
return M < 0 && (M = _e(), Te(), L(function() {
|
|
2313
2363
|
setTimeout(function() {
|
|
2314
|
-
|
|
2364
|
+
M = _e(), Te();
|
|
2315
2365
|
}, 0);
|
|
2316
2366
|
})), { get firstHiddenTime() {
|
|
2317
|
-
return
|
|
2367
|
+
return M;
|
|
2318
2368
|
} };
|
|
2319
|
-
},
|
|
2369
|
+
}, z = function(r) {
|
|
2320
2370
|
document.prerendering ? addEventListener("prerenderingchange", function() {
|
|
2321
2371
|
return r();
|
|
2322
2372
|
}, !0) : r();
|
|
2323
|
-
},
|
|
2324
|
-
e = e || {},
|
|
2325
|
-
var t, s =
|
|
2326
|
-
a.forEach(function(
|
|
2327
|
-
|
|
2373
|
+
}, te = [1800, 3e3], Le = function(r, e) {
|
|
2374
|
+
e = e || {}, z(function() {
|
|
2375
|
+
var t, s = Ne(), n = m("FCP"), i = O("paint", function(a) {
|
|
2376
|
+
a.forEach(function(o) {
|
|
2377
|
+
o.name === "first-contentful-paint" && (i.disconnect(), o.startTime < s.firstHiddenTime && (n.value = Math.max(o.startTime - G(), 0), n.entries.push(o), t(!0)));
|
|
2328
2378
|
});
|
|
2329
2379
|
});
|
|
2330
|
-
i && (t =
|
|
2331
|
-
n =
|
|
2380
|
+
i && (t = p(r, n, te, e.reportAllChanges), L(function(a) {
|
|
2381
|
+
n = m("FCP"), t = p(r, n, te, e.reportAllChanges), oe(function() {
|
|
2332
2382
|
n.value = performance.now() - a.timeStamp, t(!0);
|
|
2333
2383
|
});
|
|
2334
2384
|
}));
|
|
2335
2385
|
});
|
|
2336
|
-
},
|
|
2337
|
-
e = e || {},
|
|
2338
|
-
var t, s =
|
|
2386
|
+
}, re = [0.1, 0.25], Lt = function(r, e) {
|
|
2387
|
+
e = e || {}, Le(le(function() {
|
|
2388
|
+
var t, s = m("CLS", 0), n = 0, i = [], a = function(c) {
|
|
2339
2389
|
c.forEach(function(u) {
|
|
2340
2390
|
if (!u.hadRecentInput) {
|
|
2341
|
-
var
|
|
2342
|
-
n && u.startTime -
|
|
2391
|
+
var f = i[0], _ = i[i.length - 1];
|
|
2392
|
+
n && u.startTime - _.startTime < 1e3 && u.startTime - f.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
|
|
2343
2393
|
}
|
|
2344
2394
|
}), n > s.value && (s.value = n, s.entries = i, t());
|
|
2345
|
-
},
|
|
2346
|
-
|
|
2347
|
-
a(
|
|
2348
|
-
}),
|
|
2349
|
-
n = 0, s =
|
|
2395
|
+
}, o = O("layout-shift", a);
|
|
2396
|
+
o && (t = p(r, s, re, e.reportAllChanges), $(function() {
|
|
2397
|
+
a(o.takeRecords()), t(!0);
|
|
2398
|
+
}), L(function() {
|
|
2399
|
+
n = 0, s = m("CLS", 0), t = p(r, s, re, e.reportAllChanges), oe(function() {
|
|
2350
2400
|
return t();
|
|
2351
2401
|
});
|
|
2352
2402
|
}), setTimeout(t, 0));
|
|
2353
2403
|
}));
|
|
2354
|
-
},
|
|
2404
|
+
}, Re = 0, X = 1 / 0, k = 0, Rt = function(r) {
|
|
2355
2405
|
r.forEach(function(e) {
|
|
2356
|
-
e.interactionId && (
|
|
2406
|
+
e.interactionId && (X = Math.min(X, e.interactionId), k = Math.max(k, e.interactionId), Re = k ? (k - X) / 7 + 1 : 0);
|
|
2357
2407
|
});
|
|
2358
|
-
},
|
|
2359
|
-
return
|
|
2408
|
+
}, be = function() {
|
|
2409
|
+
return ee ? Re : performance.interactionCount || 0;
|
|
2360
2410
|
}, bt = function() {
|
|
2361
|
-
"interactionCount" in performance ||
|
|
2362
|
-
},
|
|
2363
|
-
var r = Math.min(
|
|
2364
|
-
return
|
|
2365
|
-
},
|
|
2366
|
-
if (
|
|
2411
|
+
"interactionCount" in performance || ee || (ee = O("event", Rt, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
2412
|
+
}, E = [], V = /* @__PURE__ */ new Map(), Ce = 0, Ct = function() {
|
|
2413
|
+
var r = Math.min(E.length - 1, Math.floor((be() - Ce) / 50));
|
|
2414
|
+
return E[r];
|
|
2415
|
+
}, Ot = [], Pt = function(r) {
|
|
2416
|
+
if (Ot.forEach(function(n) {
|
|
2367
2417
|
return n(r);
|
|
2368
2418
|
}), r.interactionId || r.entryType === "first-input") {
|
|
2369
|
-
var e =
|
|
2370
|
-
if (t ||
|
|
2419
|
+
var e = E[E.length - 1], t = V.get(r.interactionId);
|
|
2420
|
+
if (t || E.length < 10 || r.duration > e.latency) {
|
|
2371
2421
|
if (t) r.duration > t.latency ? (t.entries = [r], t.latency = r.duration) : r.duration === t.latency && r.startTime === t.entries[0].startTime && t.entries.push(r);
|
|
2372
2422
|
else {
|
|
2373
2423
|
var s = { id: r.interactionId, latency: r.duration, entries: [r] };
|
|
2374
|
-
|
|
2424
|
+
V.set(s.id, s), E.push(s);
|
|
2375
2425
|
}
|
|
2376
|
-
|
|
2426
|
+
E.sort(function(n, i) {
|
|
2377
2427
|
return i.latency - n.latency;
|
|
2378
|
-
}),
|
|
2379
|
-
return
|
|
2428
|
+
}), E.length > 10 && E.splice(10).forEach(function(n) {
|
|
2429
|
+
return V.delete(n.id);
|
|
2380
2430
|
});
|
|
2381
2431
|
}
|
|
2382
2432
|
}
|
|
2383
|
-
},
|
|
2433
|
+
}, Oe = function(r) {
|
|
2384
2434
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
2385
|
-
return r =
|
|
2386
|
-
},
|
|
2387
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
2435
|
+
return r = le(r), document.visibilityState === "hidden" ? r() : (t = e(r), $(r)), t;
|
|
2436
|
+
}, se = [200, 500], Dt = function(r, e) {
|
|
2437
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, z(function() {
|
|
2388
2438
|
var t;
|
|
2389
2439
|
bt();
|
|
2390
|
-
var s, n =
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
var c =
|
|
2440
|
+
var s, n = m("INP"), i = function(o) {
|
|
2441
|
+
Oe(function() {
|
|
2442
|
+
o.forEach(Pt);
|
|
2443
|
+
var c = Ct();
|
|
2394
2444
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, s());
|
|
2395
2445
|
});
|
|
2396
2446
|
}, a = O("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
2397
|
-
s =
|
|
2447
|
+
s = p(r, n, se, e.reportAllChanges), a && (a.observe({ type: "first-input", buffered: !0 }), $(function() {
|
|
2398
2448
|
i(a.takeRecords()), s(!0);
|
|
2399
|
-
}),
|
|
2400
|
-
|
|
2449
|
+
}), L(function() {
|
|
2450
|
+
Ce = be(), E.length = 0, V.clear(), n = m("INP"), s = p(r, n, se, e.reportAllChanges);
|
|
2401
2451
|
}));
|
|
2402
2452
|
}));
|
|
2403
|
-
},
|
|
2404
|
-
e = e || {},
|
|
2405
|
-
var t, s =
|
|
2453
|
+
}, ne = [2500, 4e3], W = {}, kt = function(r, e) {
|
|
2454
|
+
e = e || {}, z(function() {
|
|
2455
|
+
var t, s = Ne(), n = m("LCP"), i = function(c) {
|
|
2406
2456
|
e.reportAllChanges || (c = c.slice(-1)), c.forEach(function(u) {
|
|
2407
|
-
u.startTime < s.firstHiddenTime && (n.value = Math.max(u.startTime -
|
|
2457
|
+
u.startTime < s.firstHiddenTime && (n.value = Math.max(u.startTime - G(), 0), n.entries = [u], t());
|
|
2408
2458
|
});
|
|
2409
2459
|
}, a = O("largest-contentful-paint", i);
|
|
2410
2460
|
if (a) {
|
|
2411
|
-
t =
|
|
2412
|
-
var
|
|
2413
|
-
|
|
2461
|
+
t = p(r, n, ne, e.reportAllChanges);
|
|
2462
|
+
var o = le(function() {
|
|
2463
|
+
W[n.id] || (i(a.takeRecords()), a.disconnect(), W[n.id] = !0, t(!0));
|
|
2414
2464
|
});
|
|
2415
2465
|
["keydown", "click"].forEach(function(c) {
|
|
2416
2466
|
addEventListener(c, function() {
|
|
2417
|
-
return
|
|
2467
|
+
return Oe(o);
|
|
2418
2468
|
}, { once: !0, capture: !0 });
|
|
2419
|
-
}),
|
|
2420
|
-
n =
|
|
2421
|
-
n.value = performance.now() - c.timeStamp,
|
|
2469
|
+
}), $(o), L(function(c) {
|
|
2470
|
+
n = m("LCP"), t = p(r, n, ne, e.reportAllChanges), oe(function() {
|
|
2471
|
+
n.value = performance.now() - c.timeStamp, W[n.id] = !0, t(!0);
|
|
2422
2472
|
});
|
|
2423
2473
|
});
|
|
2424
2474
|
}
|
|
2425
2475
|
});
|
|
2426
|
-
},
|
|
2427
|
-
document.prerendering ?
|
|
2476
|
+
}, ie = [800, 1800], Ut = function r(e) {
|
|
2477
|
+
document.prerendering ? z(function() {
|
|
2428
2478
|
return r(e);
|
|
2429
2479
|
}) : document.readyState !== "complete" ? addEventListener("load", function() {
|
|
2430
2480
|
return r(e);
|
|
2431
2481
|
}, !0) : setTimeout(e, 0);
|
|
2432
|
-
},
|
|
2482
|
+
}, Ht = function(r, e) {
|
|
2433
2483
|
e = e || {};
|
|
2434
|
-
var t =
|
|
2435
|
-
|
|
2436
|
-
var n =
|
|
2437
|
-
n && (t.value = Math.max(n.responseStart -
|
|
2438
|
-
t =
|
|
2484
|
+
var t = m("TTFB"), s = p(r, t, ie, e.reportAllChanges);
|
|
2485
|
+
Ut(function() {
|
|
2486
|
+
var n = ae();
|
|
2487
|
+
n && (t.value = Math.max(n.responseStart - G(), 0), t.entries = [n], s(!0), L(function() {
|
|
2488
|
+
t = m("TTFB", 0), (s = p(r, t, ie, e.reportAllChanges))(!0);
|
|
2439
2489
|
}));
|
|
2440
2490
|
});
|
|
2441
2491
|
};
|
|
2442
|
-
const
|
|
2492
|
+
const xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2443
2493
|
__proto__: null,
|
|
2444
|
-
CLSThresholds:
|
|
2445
|
-
FCPThresholds:
|
|
2446
|
-
INPThresholds:
|
|
2447
|
-
LCPThresholds:
|
|
2448
|
-
TTFBThresholds:
|
|
2449
|
-
onCLS:
|
|
2450
|
-
onFCP:
|
|
2451
|
-
onINP:
|
|
2452
|
-
onLCP:
|
|
2453
|
-
onTTFB:
|
|
2494
|
+
CLSThresholds: re,
|
|
2495
|
+
FCPThresholds: te,
|
|
2496
|
+
INPThresholds: se,
|
|
2497
|
+
LCPThresholds: ne,
|
|
2498
|
+
TTFBThresholds: ie,
|
|
2499
|
+
onCLS: Lt,
|
|
2500
|
+
onFCP: Le,
|
|
2501
|
+
onINP: Dt,
|
|
2502
|
+
onLCP: kt,
|
|
2503
|
+
onTTFB: Ht
|
|
2454
2504
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2455
2505
|
export {
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2506
|
+
ar as ANALYTICS_QUERY_LIMITS,
|
|
2507
|
+
or as ANOMALY_DETECTION,
|
|
2508
|
+
A as AppConfigValidationError,
|
|
2509
|
+
rr as CONTENT_ANALYTICS,
|
|
2510
|
+
Jt as DATA_PROTECTION,
|
|
2511
|
+
tr as DEVICE_ANALYTICS,
|
|
2512
|
+
T as DeviceType,
|
|
2513
|
+
Zt as ENGAGEMENT_THRESHOLDS,
|
|
2514
|
+
K as EmitterEvent,
|
|
2515
|
+
R as ErrorType,
|
|
2466
2516
|
d as EventType,
|
|
2467
|
-
|
|
2468
|
-
|
|
2517
|
+
sr as INSIGHT_THRESHOLDS,
|
|
2518
|
+
Kt as InitializationTimeoutError,
|
|
2469
2519
|
v as IntegrationValidationError,
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
Xt as MAX_CUSTOM_EVENT_KEYS_BACKEND,
|
|
2476
|
-
Ft as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
2477
|
-
Gt as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
2520
|
+
Xt as MAX_ARRAY_LENGTH,
|
|
2521
|
+
$t as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
2522
|
+
Gt as MAX_CUSTOM_EVENT_KEYS,
|
|
2523
|
+
Vt as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
2524
|
+
Ft as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
2478
2525
|
Qt as MAX_METADATA_NESTING_DEPTH,
|
|
2479
|
-
|
|
2480
|
-
Bt as
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2526
|
+
zt as MAX_NESTED_OBJECT_KEYS,
|
|
2527
|
+
Bt as MAX_STRING_LENGTH,
|
|
2528
|
+
jt as MAX_STRING_LENGTH_IN_ARRAY,
|
|
2529
|
+
b as Mode,
|
|
2530
|
+
qt as PERFORMANCE_CONFIG,
|
|
2531
|
+
w as PermanentError,
|
|
2532
|
+
ir as SEGMENTATION_ANALYTICS,
|
|
2533
|
+
er as SESSION_ANALYTICS,
|
|
2534
|
+
lr as SPECIAL_PAGE_URLS,
|
|
2535
|
+
ue as SamplingRateValidationError,
|
|
2536
|
+
U as ScrollDirection,
|
|
2537
|
+
Ue as SessionTimeoutValidationError,
|
|
2538
|
+
Y as SpecialApiUrl,
|
|
2539
|
+
nr as TEMPORAL_ANALYSIS,
|
|
2540
|
+
C as TraceLogValidationError,
|
|
2541
|
+
Wt as isPrimaryScrollEvent,
|
|
2542
|
+
Yt as isSecondaryScrollEvent,
|
|
2543
|
+
cr as tracelog
|
|
2497
2544
|
};
|