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