@tracelog/lib 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.js +253 -257
- package/dist/cjs/managers/event.manager.d.ts +1 -1
- package/dist/cjs/managers/event.manager.js +1 -3
- package/dist/cjs/managers/session.manager.js +6 -5
- package/dist/cjs/types/event.types.d.ts +0 -1
- package/dist/esm/managers/event.manager.d.ts +1 -1
- package/dist/esm/managers/event.manager.js +1 -3
- package/dist/esm/managers/session.manager.js +6 -5
- package/dist/esm/types/event.types.d.ts +0 -1
- package/package.json +1 -1
package/dist/browser/tracelog.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var y = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(y || {});
|
|
2
|
-
const ee = 15 * 60 * 1e3,
|
|
2
|
+
const ee = 15 * 60 * 1e3, Je = 1e3, Ze = 1e4, ke = 250, et = 24, Se = 500, Ee = 3, tt = 5e3, Ue = 1e4, rt = 10, ve = 5, ye = 500, Te = 120, A = 1, nt = 0, st = 1, z = 3e4, G = 864e5, Ie = 120, _e = 8 * 1024, we = 10, Ae = 10, Y = 255, T = 1e3, K = 100, be = 3, _ = 2, it = 2e3, k = "data-tl", at = [
|
|
3
3
|
"button",
|
|
4
4
|
"a",
|
|
5
5
|
'input[type="button"]',
|
|
@@ -31,7 +31,7 @@ const ee = 15 * 60 * 1e3, Ze = 1e3, et = 1e4, Ue = 250, tt = 24, Ee = 500, ve =
|
|
|
31
31
|
".menu-item",
|
|
32
32
|
"[data-testid]",
|
|
33
33
|
'[tabindex="0"]'
|
|
34
|
-
],
|
|
34
|
+
], ot = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], lt = 2, ct = /* @__PURE__ */ new Set([
|
|
35
35
|
"mode",
|
|
36
36
|
"tags",
|
|
37
37
|
"samplingRate",
|
|
@@ -54,35 +54,35 @@ const ee = 15 * 60 * 1e3, Ze = 1e3, et = 1e4, Ue = 250, tt = 24, Ee = 500, ve =
|
|
|
54
54
|
INVALID_GLOBAL_METADATA: "Global metadata must be an object",
|
|
55
55
|
// Array validation
|
|
56
56
|
INVALID_SENSITIVE_QUERY_PARAMS: "Sensitive query params must be an array of strings"
|
|
57
|
-
},
|
|
57
|
+
}, xe = [
|
|
58
58
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
59
59
|
/javascript:/gi,
|
|
60
60
|
/on\w+\s*=/gi,
|
|
61
61
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
62
62
|
/<embed\b[^>]*>/gi,
|
|
63
63
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
64
|
-
],
|
|
64
|
+
], He = {
|
|
65
65
|
samplingRate: A,
|
|
66
66
|
excludedUrlPaths: [],
|
|
67
67
|
tags: [],
|
|
68
68
|
ipExcluded: !1
|
|
69
|
-
},
|
|
70
|
-
...
|
|
69
|
+
}, Me = (r) => ({
|
|
70
|
+
...He,
|
|
71
71
|
...r,
|
|
72
72
|
allowHttp: !1,
|
|
73
73
|
sessionTimeout: ee,
|
|
74
|
-
samplingRate: r.samplingRate && r.samplingRate >
|
|
74
|
+
samplingRate: r.samplingRate && r.samplingRate > nt && r.samplingRate <= st ? r.samplingRate : A,
|
|
75
75
|
excludedUrlPaths: r.excludedUrlPaths ?? [],
|
|
76
76
|
tags: r.tags ?? [],
|
|
77
77
|
ipExcluded: r.ipExcluded ?? !1
|
|
78
|
-
}),
|
|
78
|
+
}), I = "tl", ut = (r) => r ? `${I}:${r}:uid` : `${I}:uid`, dt = (r) => r ? `${I}:${r}:queue` : `${I}:queue`, ht = (r) => r ? `${I}:${r}:session` : `${I}:session`, gt = (r) => r ? `${I}:${r}:broadcast` : `${I}:broadcast`, Ve = {
|
|
79
79
|
LCP: 4e3,
|
|
80
80
|
FCP: 1800,
|
|
81
81
|
CLS: 0.25,
|
|
82
82
|
INP: 200,
|
|
83
83
|
TTFB: 600,
|
|
84
84
|
LONG_TASK: 50
|
|
85
|
-
},
|
|
85
|
+
}, ft = 1e3, Fe = [
|
|
86
86
|
// Email addresses
|
|
87
87
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
88
88
|
// US Phone numbers (various formats)
|
|
@@ -91,7 +91,7 @@ const ee = 15 * 60 * 1e3, Ze = 1e3, et = 1e4, Ue = 250, tt = 24, Ee = 500, ve =
|
|
|
91
91
|
/\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g,
|
|
92
92
|
// IBAN (International Bank Account Number)
|
|
93
93
|
/\b[A-Z]{2}\d{2}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/gi
|
|
94
|
-
],
|
|
94
|
+
], Re = 500, Le = 6e4, X = 50, v = {};
|
|
95
95
|
class f {
|
|
96
96
|
/**
|
|
97
97
|
* Gets a value from the global state
|
|
@@ -148,7 +148,7 @@ class f {
|
|
|
148
148
|
return e === "config" ? t ? "(configured)" : "(not configured)" : t;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
class
|
|
151
|
+
class mt extends f {
|
|
152
152
|
clientError = (e, t, n) => this.log("CLIENT_ERROR", e, t, n);
|
|
153
153
|
clientWarn = (e, t, n) => this.log("CLIENT_WARN", e, t, n);
|
|
154
154
|
info = (e, t, n) => this.log("INFO", e, t, n);
|
|
@@ -169,11 +169,11 @@ class pt extends f {
|
|
|
169
169
|
return ["CLIENT_ERROR", "ERROR"].includes(e) ? "error" : ["CLIENT_WARN", "WARN"].includes(e) ? "warn" : "log";
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
const a = new
|
|
173
|
-
let te,
|
|
174
|
-
const
|
|
175
|
-
typeof window < "u" && !te && (te = window.matchMedia("(pointer: coarse)"),
|
|
176
|
-
},
|
|
172
|
+
const a = new mt();
|
|
173
|
+
let te, ze;
|
|
174
|
+
const pt = () => {
|
|
175
|
+
typeof window < "u" && !te && (te = window.matchMedia("(pointer: coarse)"), ze = window.matchMedia("(hover: none)"));
|
|
176
|
+
}, St = () => {
|
|
177
177
|
try {
|
|
178
178
|
a.debug("DeviceDetector", "Starting device detection");
|
|
179
179
|
const r = navigator;
|
|
@@ -186,8 +186,8 @@ const St = () => {
|
|
|
186
186
|
const u = r.userAgentData.mobile ? y.Mobile : y.Desktop;
|
|
187
187
|
return a.debug("DeviceDetector", "Device detected via User-Agent hints", { result: u }), u;
|
|
188
188
|
}
|
|
189
|
-
a.debug("DeviceDetector", "Using fallback detection methods"),
|
|
190
|
-
const e = window.innerWidth, t = te?.matches ?? !1, n =
|
|
189
|
+
a.debug("DeviceDetector", "Using fallback detection methods"), pt();
|
|
190
|
+
const e = window.innerWidth, t = te?.matches ?? !1, n = ze?.matches ?? !1, s = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), c = /tablet|ipad|android(?!.*mobile)/.test(i), l = {
|
|
191
191
|
width: e,
|
|
192
192
|
hasCoarsePointer: t,
|
|
193
193
|
hasNoHover: n,
|
|
@@ -202,13 +202,13 @@ const St = () => {
|
|
|
202
202
|
error: r instanceof Error ? r.message : r
|
|
203
203
|
}), y.Desktop;
|
|
204
204
|
}
|
|
205
|
-
},
|
|
205
|
+
}, Ne = () => {
|
|
206
206
|
a.debug("UTMParams", "Extracting UTM parameters from URL", {
|
|
207
207
|
url: window.location.href,
|
|
208
208
|
search: window.location.search
|
|
209
209
|
});
|
|
210
210
|
const r = new URLSearchParams(window.location.search), e = {};
|
|
211
|
-
|
|
211
|
+
ot.forEach((n) => {
|
|
212
212
|
const s = r.get(n);
|
|
213
213
|
if (s) {
|
|
214
214
|
const i = n.split("utm_")[1];
|
|
@@ -220,11 +220,11 @@ const St = () => {
|
|
|
220
220
|
parameterCount: Object.keys(t).length,
|
|
221
221
|
parameters: Object.keys(t)
|
|
222
222
|
}) : a.debug("UTMParams", "No UTM parameters found in URL"), t;
|
|
223
|
-
},
|
|
223
|
+
}, Et = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
|
|
224
224
|
const e = Math.random() * 16 | 0;
|
|
225
225
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
226
226
|
});
|
|
227
|
-
var w = /* @__PURE__ */ ((r) => (r.Skip = "skip", r.Localhost = "localhost:", r))(w || {}), re = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(re || {}), d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.SESSION_END = "session_end", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r))(d || {}), x = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(x || {}), N = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r.NETWORK_ERROR = "network_error", r))(N || {}), H = /* @__PURE__ */ ((r) => (r.QA = "qa", r.DEBUG = "debug", r))(H || {}),
|
|
227
|
+
var w = /* @__PURE__ */ ((r) => (r.Skip = "skip", r.Localhost = "localhost:", r))(w || {}), re = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(re || {}), d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.SESSION_END = "session_end", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r))(d || {}), x = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(x || {}), N = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r.NETWORK_ERROR = "network_error", r))(N || {}), H = /* @__PURE__ */ ((r) => (r.QA = "qa", r.DEBUG = "debug", r))(H || {}), vt = /* @__PURE__ */ ((r) => (r.AND = "AND", r.OR = "OR", r))(vt || {}), yt = /* @__PURE__ */ ((r) => (r.URL_MATCHES = "url_matches", r.ELEMENT_MATCHES = "element_matches", r.DEVICE_TYPE = "device_type", r.ELEMENT_TEXT = "element_text", r.ELEMENT_ATTRIBUTE = "element_attribute", r.UTM_SOURCE = "utm_source", r.UTM_MEDIUM = "utm_medium", r.UTM_CAMPAIGN = "utm_campaign", r))(yt || {}), Tt = /* @__PURE__ */ ((r) => (r.EQUALS = "equals", r.CONTAINS = "contains", r.STARTS_WITH = "starts_with", r.ENDS_WITH = "ends_with", r.REGEX = "regex", r.GREATER_THAN = "greater_than", r.LESS_THAN = "less_than", r.EXISTS = "exists", r.NOT_EXISTS = "not_exists", r))(Tt || {});
|
|
228
228
|
class O extends Error {
|
|
229
229
|
constructor(e, t, n) {
|
|
230
230
|
super(e), this.errorCode = t, this.layer = n, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -235,7 +235,7 @@ class ne extends O {
|
|
|
235
235
|
super(e, "PROJECT_ID_INVALID", t);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
class
|
|
238
|
+
class b extends O {
|
|
239
239
|
constructor(e, t = "config") {
|
|
240
240
|
super(e, "APP_CONFIG_INVALID", t);
|
|
241
241
|
}
|
|
@@ -245,19 +245,19 @@ class It extends O {
|
|
|
245
245
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
class
|
|
248
|
+
class _t extends O {
|
|
249
249
|
constructor(e, t = "config") {
|
|
250
250
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
class
|
|
253
|
+
class Ce extends O {
|
|
254
254
|
constructor(e, t = "config") {
|
|
255
255
|
super(e, "INTEGRATION_INVALID", t);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
const
|
|
258
|
+
const wt = (r) => {
|
|
259
259
|
if (!r || typeof r != "object")
|
|
260
|
-
throw a.clientError("ConfigValidation", "Configuration must be an object", { config: r }), new
|
|
260
|
+
throw a.clientError("ConfigValidation", "Configuration must be an object", { config: r }), new b("Configuration must be an object", "config");
|
|
261
261
|
if (!("id" in r))
|
|
262
262
|
throw a.clientError("ConfigValidation", "Project ID is missing from configuration"), new ne(p.MISSING_PROJECT_ID, "config");
|
|
263
263
|
if (r.id === null || r.id === void 0 || typeof r.id != "string")
|
|
@@ -275,26 +275,26 @@ const At = (r) => {
|
|
|
275
275
|
throw a.clientError("ConfigValidation", "Global metadata must be an object", {
|
|
276
276
|
provided: r.globalMetadata,
|
|
277
277
|
type: typeof r.globalMetadata
|
|
278
|
-
}), new
|
|
279
|
-
if (r.scrollContainerSelectors !== void 0 &&
|
|
278
|
+
}), new b(p.INVALID_GLOBAL_METADATA, "config");
|
|
279
|
+
if (r.scrollContainerSelectors !== void 0 && bt(r.scrollContainerSelectors), r.integrations && Mt(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
280
280
|
if (!Array.isArray(r.sensitiveQueryParams))
|
|
281
281
|
throw a.clientError("ConfigValidation", "Sensitive query params must be an array", {
|
|
282
282
|
provided: r.sensitiveQueryParams,
|
|
283
283
|
type: typeof r.sensitiveQueryParams
|
|
284
|
-
}), new
|
|
284
|
+
}), new b(p.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
285
285
|
for (const e of r.sensitiveQueryParams)
|
|
286
286
|
if (typeof e != "string")
|
|
287
287
|
throw a.clientError("ConfigValidation", "All sensitive query params must be strings", {
|
|
288
288
|
param: e,
|
|
289
289
|
type: typeof e
|
|
290
|
-
}), new
|
|
290
|
+
}), new b("All sensitive query params must be strings", "config");
|
|
291
291
|
}
|
|
292
292
|
if (r.errorSampling !== void 0 && (typeof r.errorSampling != "number" || r.errorSampling < 0 || r.errorSampling > 1))
|
|
293
293
|
throw a.clientError("ConfigValidation", "Invalid error sampling rate", {
|
|
294
294
|
provided: r.errorSampling,
|
|
295
295
|
expected: "0-1"
|
|
296
|
-
}), new
|
|
297
|
-
},
|
|
296
|
+
}), new _t(p.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
297
|
+
}, At = (r) => {
|
|
298
298
|
if (r.includes("<") || r.includes(">") || /on\w+\s*=/i.test(r) || !/^[a-zA-Z0-9\-_#.[\]="':, >+~*()]+$/.test(r))
|
|
299
299
|
return !1;
|
|
300
300
|
let t = 0;
|
|
@@ -305,7 +305,7 @@ const At = (r) => {
|
|
|
305
305
|
for (const s of r)
|
|
306
306
|
if (s === "[" && n++, s === "]" && n--, n < 0) return !1;
|
|
307
307
|
return n === 0;
|
|
308
|
-
},
|
|
308
|
+
}, bt = (r) => {
|
|
309
309
|
const e = Array.isArray(r) ? r : [r];
|
|
310
310
|
for (const t of e) {
|
|
311
311
|
if (typeof t != "string" || t.trim() === "")
|
|
@@ -313,28 +313,28 @@ const At = (r) => {
|
|
|
313
313
|
selector: t,
|
|
314
314
|
type: typeof t,
|
|
315
315
|
isEmpty: t === "" || typeof t == "string" && t.trim() === ""
|
|
316
|
-
}), new
|
|
317
|
-
if (!
|
|
316
|
+
}), new b(p.INVALID_SCROLL_CONTAINER_SELECTORS, "config");
|
|
317
|
+
if (!At(t))
|
|
318
318
|
throw a.clientError("ConfigValidation", "Invalid or potentially unsafe CSS selector", {
|
|
319
319
|
selector: t,
|
|
320
320
|
reason: "Failed security validation"
|
|
321
|
-
}), new
|
|
321
|
+
}), new b("Invalid or potentially unsafe CSS selector", "config");
|
|
322
322
|
}
|
|
323
|
-
},
|
|
323
|
+
}, Mt = (r) => {
|
|
324
324
|
if (r && r.googleAnalytics) {
|
|
325
325
|
if (!r.googleAnalytics.measurementId || typeof r.googleAnalytics.measurementId != "string" || r.googleAnalytics.measurementId.trim() === "")
|
|
326
326
|
throw a.clientError("ConfigValidation", "Invalid Google Analytics measurement ID", {
|
|
327
327
|
provided: r.googleAnalytics.measurementId,
|
|
328
328
|
type: typeof r.googleAnalytics.measurementId
|
|
329
|
-
}), new
|
|
329
|
+
}), new Ce(p.INVALID_GOOGLE_ANALYTICS_ID, "config");
|
|
330
330
|
const e = r.googleAnalytics.measurementId.trim();
|
|
331
331
|
if (!e.match(/^(G-|UA-)/))
|
|
332
332
|
throw a.clientError("ConfigValidation", 'Google Analytics measurement ID must start with "G-" or "UA-"', {
|
|
333
333
|
provided: e
|
|
334
|
-
}), new
|
|
334
|
+
}), new Ce('Google Analytics measurement ID must start with "G-" or "UA-"', "config");
|
|
335
335
|
}
|
|
336
|
-
},
|
|
337
|
-
|
|
336
|
+
}, Rt = (r) => {
|
|
337
|
+
wt(r);
|
|
338
338
|
const e = {
|
|
339
339
|
...r,
|
|
340
340
|
id: r.id.trim(),
|
|
@@ -347,10 +347,10 @@ const At = (r) => {
|
|
|
347
347
|
normalizedId: e.id
|
|
348
348
|
}), new ne(p.PROJECT_ID_EMPTY_AFTER_TRIM, "config");
|
|
349
349
|
return e;
|
|
350
|
-
},
|
|
350
|
+
}, Lt = (r, e) => {
|
|
351
351
|
if (r !== void 0)
|
|
352
352
|
return typeof r != "number" ? (e.push("samplingRate must be a number"), A) : Number.isNaN(r) || r <= 0 || r > 1 ? (e.push(p.INVALID_SAMPLING_RATE), A) : r;
|
|
353
|
-
},
|
|
353
|
+
}, Nt = (r, e, t = "") => {
|
|
354
354
|
if (r !== void 0)
|
|
355
355
|
if (Array.isArray(r))
|
|
356
356
|
for (const [n, s] of r.entries())
|
|
@@ -364,13 +364,13 @@ const At = (r) => {
|
|
|
364
364
|
e.push(`${t}excludedUrlPaths[${n}] must be a string`);
|
|
365
365
|
else
|
|
366
366
|
e.push(`${t}excludedUrlPaths must be an array`);
|
|
367
|
-
},
|
|
367
|
+
}, Ct = (r) => {
|
|
368
368
|
const e = [], t = [];
|
|
369
369
|
r.sessionTimeout !== void 0 && (typeof r.sessionTimeout != "number" ? e.push("sessionTimeout must be a number") : r.sessionTimeout < z ? e.push("sessionTimeout must be at least 30 seconds (30000ms)") : r.sessionTimeout > G && t.push("sessionTimeout is very long (>24 hours), consider reducing it")), r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null ? e.push("globalMetadata must be an object") : (JSON.stringify(r.globalMetadata).length > 10240 && e.push("globalMetadata is too large (max 10KB)"), Object.keys(r.globalMetadata).length > 12 && e.push("globalMetadata has too many keys (max 12)")));
|
|
370
|
-
const n =
|
|
371
|
-
return r.tags !== void 0 && !Array.isArray(r.tags) && e.push("tags must be an array"),
|
|
370
|
+
const n = Lt(r.samplingRate, e) ?? A;
|
|
371
|
+
return r.tags !== void 0 && !Array.isArray(r.tags) && e.push("tags must be an array"), Nt(r.excludedUrlPaths, e), { errors: e, warnings: t, samplingRate: n };
|
|
372
372
|
}, V = (r) => {
|
|
373
|
-
const { errors: e, warnings: t, samplingRate: n } =
|
|
373
|
+
const { errors: e, warnings: t, samplingRate: n } = Ct(r);
|
|
374
374
|
return {
|
|
375
375
|
config: {
|
|
376
376
|
...r,
|
|
@@ -379,7 +379,7 @@ const At = (r) => {
|
|
|
379
379
|
errors: e,
|
|
380
380
|
warnings: t
|
|
381
381
|
};
|
|
382
|
-
},
|
|
382
|
+
}, Pe = (r) => {
|
|
383
383
|
if (!r || typeof r != "string" || r.trim().length === 0)
|
|
384
384
|
return a.debug("Sanitize", "String sanitization skipped - empty or invalid input", { value: r, type: typeof r }), "";
|
|
385
385
|
const e = r.length;
|
|
@@ -390,7 +390,7 @@ const At = (r) => {
|
|
|
390
390
|
truncatedLength: t.length
|
|
391
391
|
}));
|
|
392
392
|
let n = 0;
|
|
393
|
-
for (const i of
|
|
393
|
+
for (const i of xe) {
|
|
394
394
|
const o = t;
|
|
395
395
|
t = t.replace(i, ""), o !== t && n++;
|
|
396
396
|
}
|
|
@@ -406,24 +406,24 @@ const At = (r) => {
|
|
|
406
406
|
xssPatternMatches: n,
|
|
407
407
|
wasTruncated: e > T
|
|
408
408
|
}), s;
|
|
409
|
-
},
|
|
409
|
+
}, Pt = (r) => {
|
|
410
410
|
if (typeof r != "string")
|
|
411
411
|
return "";
|
|
412
412
|
r.length > T && (r = r.slice(0, Math.max(0, T)));
|
|
413
413
|
let e = r;
|
|
414
|
-
for (const t of
|
|
414
|
+
for (const t of xe)
|
|
415
415
|
e = e.replace(t, "");
|
|
416
416
|
return e = e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'"), e.trim();
|
|
417
417
|
}, P = (r, e = 0) => {
|
|
418
|
-
if (e >
|
|
418
|
+
if (e > be)
|
|
419
419
|
return a.warn("Sanitize", "Maximum object depth exceeded during sanitization", {
|
|
420
420
|
depth: e,
|
|
421
|
-
maxDepth:
|
|
421
|
+
maxDepth: be
|
|
422
422
|
}), null;
|
|
423
423
|
if (r == null)
|
|
424
424
|
return null;
|
|
425
425
|
if (typeof r == "string")
|
|
426
|
-
return
|
|
426
|
+
return Pe(r);
|
|
427
427
|
if (typeof r == "number")
|
|
428
428
|
return !Number.isFinite(r) || r < -Number.MAX_SAFE_INTEGER || r > Number.MAX_SAFE_INTEGER ? (a.warn("Sanitize", "Invalid number sanitized to 0", { value: r, isFinite: Number.isFinite(r) }), 0) : r;
|
|
429
429
|
if (typeof r == "boolean")
|
|
@@ -447,7 +447,7 @@ const At = (r) => {
|
|
|
447
447
|
});
|
|
448
448
|
let o = 0;
|
|
449
449
|
for (const [c, l] of i) {
|
|
450
|
-
const u =
|
|
450
|
+
const u = Pe(c);
|
|
451
451
|
if (u) {
|
|
452
452
|
const h = P(l, e + 1);
|
|
453
453
|
h !== null ? t[u] = h : o++;
|
|
@@ -461,7 +461,7 @@ const At = (r) => {
|
|
|
461
461
|
}), t;
|
|
462
462
|
}
|
|
463
463
|
return a.debug("Sanitize", "Unknown value type sanitized to null", { type: typeof r, depth: e }), null;
|
|
464
|
-
},
|
|
464
|
+
}, Ot = (r) => {
|
|
465
465
|
a.debug("Sanitize", "Starting API config sanitization");
|
|
466
466
|
const e = {};
|
|
467
467
|
if (typeof r != "object" || r === null)
|
|
@@ -470,11 +470,11 @@ const At = (r) => {
|
|
|
470
470
|
const t = Object.keys(r);
|
|
471
471
|
let n = 0, s = 0;
|
|
472
472
|
for (const i of t)
|
|
473
|
-
if (
|
|
473
|
+
if (ct.has(i)) {
|
|
474
474
|
const o = r[i];
|
|
475
475
|
if (i === "excludedUrlPaths") {
|
|
476
476
|
const c = Array.isArray(o) ? o : typeof o == "string" ? [o] : [], l = c.length;
|
|
477
|
-
e.excludedUrlPaths = c.map((h) =>
|
|
477
|
+
e.excludedUrlPaths = c.map((h) => Pt(String(h))).filter(Boolean);
|
|
478
478
|
const u = l - e.excludedUrlPaths.length;
|
|
479
479
|
u > 0 && a.warn("Sanitize", "Some excluded URL paths were filtered during sanitization", {
|
|
480
480
|
originalCount: l,
|
|
@@ -504,7 +504,7 @@ const At = (r) => {
|
|
|
504
504
|
}), new Error(`API config sanitization failed: ${t instanceof Error ? t.message : "Unknown error"}`);
|
|
505
505
|
}
|
|
506
506
|
return e;
|
|
507
|
-
},
|
|
507
|
+
}, Dt = (r) => {
|
|
508
508
|
if (a.debug("Sanitize", "Starting metadata sanitization", { hasMetadata: r != null }), typeof r != "object" || r === null)
|
|
509
509
|
return a.debug("Sanitize", "Metadata is not an object, returning empty object", {
|
|
510
510
|
metadata: r,
|
|
@@ -522,7 +522,7 @@ const At = (r) => {
|
|
|
522
522
|
error: e instanceof Error ? e.message : e
|
|
523
523
|
}), new Error(`Metadata sanitization failed: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
524
524
|
}
|
|
525
|
-
},
|
|
525
|
+
}, kt = (r) => {
|
|
526
526
|
if (typeof r != "object" || r === null)
|
|
527
527
|
return !1;
|
|
528
528
|
for (const e of Object.values(r)) {
|
|
@@ -539,7 +539,7 @@ const At = (r) => {
|
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
return !0;
|
|
542
|
-
},
|
|
542
|
+
}, Ut = (r) => typeof r != "string" ? {
|
|
543
543
|
valid: !1,
|
|
544
544
|
error: "Event name must be a string"
|
|
545
545
|
} : r.length === 0 ? {
|
|
@@ -554,9 +554,9 @@ const At = (r) => {
|
|
|
554
554
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(r.toLowerCase()) ? {
|
|
555
555
|
valid: !1,
|
|
556
556
|
error: "Event name cannot be a reserved word"
|
|
557
|
-
} : { valid: !0 },
|
|
558
|
-
const n =
|
|
559
|
-
if (!
|
|
557
|
+
} : { valid: !0 }, xt = (r, e, t) => {
|
|
558
|
+
const n = Dt(e), s = `${t} "${r}" metadata error`;
|
|
559
|
+
if (!kt(n))
|
|
560
560
|
return {
|
|
561
561
|
valid: !1,
|
|
562
562
|
error: `${s}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -570,22 +570,22 @@ const At = (r) => {
|
|
|
570
570
|
error: `${s}: object contains circular references or cannot be serialized.`
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
|
-
if (i.length >
|
|
573
|
+
if (i.length > _e)
|
|
574
574
|
return {
|
|
575
575
|
valid: !1,
|
|
576
|
-
error: `${s}: object is too large (max ${
|
|
576
|
+
error: `${s}: object is too large (max ${_e / 1024} KB).`
|
|
577
577
|
};
|
|
578
|
-
if (Object.keys(n).length >
|
|
578
|
+
if (Object.keys(n).length > we)
|
|
579
579
|
return {
|
|
580
580
|
valid: !1,
|
|
581
|
-
error: `${s}: object has too many keys (max ${
|
|
581
|
+
error: `${s}: object has too many keys (max ${we} keys).`
|
|
582
582
|
};
|
|
583
583
|
for (const [c, l] of Object.entries(n)) {
|
|
584
584
|
if (Array.isArray(l)) {
|
|
585
|
-
if (l.length >
|
|
585
|
+
if (l.length > Ae)
|
|
586
586
|
return {
|
|
587
587
|
valid: !1,
|
|
588
|
-
error: `${s}: array property "${c}" is too large (max ${
|
|
588
|
+
error: `${s}: array property "${c}" is too large (max ${Ae} items).`
|
|
589
589
|
};
|
|
590
590
|
for (const u of l)
|
|
591
591
|
if (typeof u == "string" && u.length > 500)
|
|
@@ -604,13 +604,13 @@ const At = (r) => {
|
|
|
604
604
|
valid: !0,
|
|
605
605
|
sanitizedMetadata: n
|
|
606
606
|
};
|
|
607
|
-
},
|
|
608
|
-
const t =
|
|
607
|
+
}, Ht = (r, e) => {
|
|
608
|
+
const t = Ut(r);
|
|
609
609
|
if (!t.valid)
|
|
610
610
|
return a.clientError("EventValidation", "Event name validation failed", { eventName: r, error: t.error }), t;
|
|
611
611
|
if (!e)
|
|
612
612
|
return { valid: !0 };
|
|
613
|
-
const n =
|
|
613
|
+
const n = xt(r, e, "customEvent");
|
|
614
614
|
return n.valid || a.clientError("EventValidation", "Event metadata validation failed", {
|
|
615
615
|
eventName: r,
|
|
616
616
|
error: n.error
|
|
@@ -622,7 +622,7 @@ const At = (r) => {
|
|
|
622
622
|
} catch {
|
|
623
623
|
return !1;
|
|
624
624
|
}
|
|
625
|
-
},
|
|
625
|
+
}, Vt = (r, e = !1) => {
|
|
626
626
|
const t = new URL(window.location.href), n = t.hostname, s = n.split(".");
|
|
627
627
|
if (s.length === 0)
|
|
628
628
|
throw a.clientError("URLUtils", "Invalid hostname - no domain parts found", { hostname: n }), new Error("Invalid URL");
|
|
@@ -651,7 +651,7 @@ const At = (r) => {
|
|
|
651
651
|
error: t instanceof Error ? t.message : t
|
|
652
652
|
}), r;
|
|
653
653
|
}
|
|
654
|
-
},
|
|
654
|
+
}, Ft = (r, e = []) => {
|
|
655
655
|
if (e.length === 0)
|
|
656
656
|
return !1;
|
|
657
657
|
let t;
|
|
@@ -679,7 +679,7 @@ const At = (r) => {
|
|
|
679
679
|
}
|
|
680
680
|
});
|
|
681
681
|
};
|
|
682
|
-
async function
|
|
682
|
+
async function zt(r, e = {}) {
|
|
683
683
|
const { timeout: t = 1e4, ...n } = e, s = new AbortController(), i = setTimeout(() => {
|
|
684
684
|
s.abort();
|
|
685
685
|
}, t);
|
|
@@ -693,7 +693,7 @@ async function Gt(r, e = {}) {
|
|
|
693
693
|
throw clearTimeout(i), o instanceof Error && o.name === "AbortError" ? new Error(`Request timeout after ${t}ms`) : o;
|
|
694
694
|
}
|
|
695
695
|
}
|
|
696
|
-
class
|
|
696
|
+
class Gt {
|
|
697
697
|
listeners = /* @__PURE__ */ new Map();
|
|
698
698
|
on(e, t) {
|
|
699
699
|
this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
|
|
@@ -713,7 +713,7 @@ class jt {
|
|
|
713
713
|
this.listeners.clear();
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function jt(r, e = !1) {
|
|
717
717
|
try {
|
|
718
718
|
if (r.startsWith(w.Localhost)) {
|
|
719
719
|
const n = `http://${r}`;
|
|
@@ -721,7 +721,7 @@ function $t(r, e = !1) {
|
|
|
721
721
|
throw new Error(`Invalid localhost URL format: ${r}`);
|
|
722
722
|
return n;
|
|
723
723
|
}
|
|
724
|
-
const t =
|
|
724
|
+
const t = Vt(r, e);
|
|
725
725
|
if (!se(t, e))
|
|
726
726
|
throw new Error(`Generated API URL failed validation: ${t}`);
|
|
727
727
|
return t;
|
|
@@ -759,10 +759,10 @@ class he {
|
|
|
759
759
|
*/
|
|
760
760
|
async loadFromApi(e, t) {
|
|
761
761
|
try {
|
|
762
|
-
const n = this.buildConfigUrl(e, t), s = this.buildHeaders(t), i = await
|
|
762
|
+
const n = this.buildConfigUrl(e, t), s = this.buildHeaders(t), i = await zt(n, {
|
|
763
763
|
method: "GET",
|
|
764
764
|
headers: s,
|
|
765
|
-
timeout:
|
|
765
|
+
timeout: Ue
|
|
766
766
|
});
|
|
767
767
|
if (!i.ok)
|
|
768
768
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
@@ -826,7 +826,7 @@ class he {
|
|
|
826
826
|
* Merges API configuration with app configuration and applies mode-specific settings.
|
|
827
827
|
*/
|
|
828
828
|
mergeConfigurations(e, t) {
|
|
829
|
-
const n =
|
|
829
|
+
const n = Ot(e), s = { ...He, ...n }, i = Me({ ...t, ...s }), { config: o } = V(i);
|
|
830
830
|
this.isQaModeEnabled() && !o.mode && (o.mode = H.QA, a.info("ConfigManager", "QA mode enabled via URL parameter"));
|
|
831
831
|
const c = Object.values(H).includes(o.mode) ? 1 : o.errorSampling ?? 0.1;
|
|
832
832
|
return { ...o, errorSampling: c };
|
|
@@ -835,7 +835,7 @@ class he {
|
|
|
835
835
|
* Creates default configuration for skip mode and fallback scenarios.
|
|
836
836
|
*/
|
|
837
837
|
createDefaultConfig(e) {
|
|
838
|
-
const t =
|
|
838
|
+
const t = Me({
|
|
839
839
|
...e,
|
|
840
840
|
errorSampling: 1,
|
|
841
841
|
...e.id === w.Skip && { mode: H.DEBUG }
|
|
@@ -843,7 +843,7 @@ class he {
|
|
|
843
843
|
return n;
|
|
844
844
|
}
|
|
845
845
|
}
|
|
846
|
-
class
|
|
846
|
+
class $t extends f {
|
|
847
847
|
storeManager;
|
|
848
848
|
retryTimeoutId = null;
|
|
849
849
|
retryCount = 0;
|
|
@@ -853,7 +853,7 @@ class Qt extends f {
|
|
|
853
853
|
}
|
|
854
854
|
getQueueStorageKey() {
|
|
855
855
|
const e = this.get("config")?.id || "default", t = this.get("userId") || "anonymous";
|
|
856
|
-
return `${
|
|
856
|
+
return `${dt(e)}:${t}`;
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
859
859
|
* Send events synchronously using sendBeacon or XHR fallback
|
|
@@ -927,7 +927,7 @@ class Qt extends f {
|
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
929
|
async sendWithTimeout(e, t) {
|
|
930
|
-
const n = new AbortController(), s = setTimeout(() => n.abort(),
|
|
930
|
+
const n = new AbortController(), s = setTimeout(() => n.abort(), Ue);
|
|
931
931
|
try {
|
|
932
932
|
const i = await fetch(e, {
|
|
933
933
|
method: "POST",
|
|
@@ -953,7 +953,7 @@ class Qt extends f {
|
|
|
953
953
|
sendSyncXHR(e, t) {
|
|
954
954
|
const n = new XMLHttpRequest();
|
|
955
955
|
try {
|
|
956
|
-
n.open("POST", e, !1), n.setRequestHeader("Content-Type", "application/json"), n.withCredentials = !0, n.timeout =
|
|
956
|
+
n.open("POST", e, !1), n.setRequestHeader("Content-Type", "application/json"), n.withCredentials = !0, n.timeout = it, n.send(t);
|
|
957
957
|
const s = n.status >= 200 && n.status < 300;
|
|
958
958
|
return s || a.warn("SenderManager", "Sync XHR failed", {
|
|
959
959
|
status: n.status,
|
|
@@ -984,7 +984,7 @@ class Qt extends f {
|
|
|
984
984
|
return null;
|
|
985
985
|
}
|
|
986
986
|
isDataRecent(e) {
|
|
987
|
-
return !e.timestamp || typeof e.timestamp != "number" ? !1 : (Date.now() - e.timestamp) / (1e3 * 60 * 60) <
|
|
987
|
+
return !e.timestamp || typeof e.timestamp != "number" ? !1 : (Date.now() - e.timestamp) / (1e3 * 60 * 60) < et;
|
|
988
988
|
}
|
|
989
989
|
createRecoveryBody(e) {
|
|
990
990
|
return {
|
|
@@ -1023,16 +1023,16 @@ class Qt extends f {
|
|
|
1023
1023
|
scheduleRetry(e, t) {
|
|
1024
1024
|
if (this.retryTimeoutId !== null || this.isRetrying)
|
|
1025
1025
|
return;
|
|
1026
|
-
if (this.retryCount >=
|
|
1026
|
+
if (this.retryCount >= Ee) {
|
|
1027
1027
|
a.warn("SenderManager", "Max retries reached, giving up", { retryCount: this.retryCount }), this.clearPersistedEvents(), this.resetRetryState(), t?.onFailure?.();
|
|
1028
1028
|
return;
|
|
1029
1029
|
}
|
|
1030
|
-
const n =
|
|
1030
|
+
const n = tt * Math.pow(2, this.retryCount);
|
|
1031
1031
|
this.retryTimeoutId = window.setTimeout(async () => {
|
|
1032
1032
|
if (this.retryTimeoutId = null, !this.isRetrying) {
|
|
1033
1033
|
this.retryCount++, this.isRetrying = !0;
|
|
1034
1034
|
try {
|
|
1035
|
-
await this.send(e) ? (this.clearPersistedEvents(), this.resetRetryState(), t?.onSuccess?.(e.events.length)) : this.retryCount >=
|
|
1035
|
+
await this.send(e) ? (this.clearPersistedEvents(), this.resetRetryState(), t?.onSuccess?.(e.events.length)) : this.retryCount >= Ee ? (this.clearPersistedEvents(), this.resetRetryState(), t?.onFailure?.()) : this.scheduleRetry(e, t);
|
|
1036
1036
|
} finally {
|
|
1037
1037
|
this.isRetrying = !1;
|
|
1038
1038
|
}
|
|
@@ -1062,7 +1062,7 @@ class Qt extends f {
|
|
|
1062
1062
|
this.retryTimeoutId !== null && (clearTimeout(this.retryTimeoutId), this.retryTimeoutId = null);
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
class
|
|
1065
|
+
class Qt extends f {
|
|
1066
1066
|
googleAnalytics;
|
|
1067
1067
|
dataSender;
|
|
1068
1068
|
emitter;
|
|
@@ -1071,7 +1071,7 @@ class Wt extends f {
|
|
|
1071
1071
|
lastEventTime = 0;
|
|
1072
1072
|
sendIntervalId = null;
|
|
1073
1073
|
constructor(e, t = null, n = null) {
|
|
1074
|
-
super(), this.googleAnalytics = t, this.dataSender = new
|
|
1074
|
+
super(), this.googleAnalytics = t, this.dataSender = new $t(e), this.emitter = n;
|
|
1075
1075
|
}
|
|
1076
1076
|
/**
|
|
1077
1077
|
* Recovers persisted events from localStorage
|
|
@@ -1102,35 +1102,33 @@ class Wt extends f {
|
|
|
1102
1102
|
custom_event: o,
|
|
1103
1103
|
web_vitals: c,
|
|
1104
1104
|
error_data: l,
|
|
1105
|
-
session_end_reason: u
|
|
1106
|
-
session_start_recovered: h
|
|
1105
|
+
session_end_reason: u
|
|
1107
1106
|
}) {
|
|
1108
1107
|
if (!e) {
|
|
1109
1108
|
a.warn("EventManager", "Event type is required");
|
|
1110
1109
|
return;
|
|
1111
1110
|
}
|
|
1112
|
-
const
|
|
1113
|
-
type:
|
|
1114
|
-
page_url:
|
|
1111
|
+
const h = e, L = h === d.SESSION_START, Ke = h === d.SESSION_END, Xe = L || Ke, qe = t || this.get("pageUrl"), B = this.buildEventPayload({
|
|
1112
|
+
type: h,
|
|
1113
|
+
page_url: qe,
|
|
1115
1114
|
from_page_url: n,
|
|
1116
1115
|
scroll_data: s,
|
|
1117
1116
|
click_data: i,
|
|
1118
1117
|
custom_event: o,
|
|
1119
1118
|
web_vitals: c,
|
|
1120
1119
|
error_data: l,
|
|
1121
|
-
session_end_reason: u
|
|
1122
|
-
session_start_recovered: h
|
|
1120
|
+
session_end_reason: u
|
|
1123
1121
|
});
|
|
1124
|
-
if (!this.isEventExcluded(B) && !(!
|
|
1125
|
-
if (
|
|
1126
|
-
const
|
|
1127
|
-
if (!
|
|
1122
|
+
if (!this.isEventExcluded(B) && !(!Xe && !this.shouldSample())) {
|
|
1123
|
+
if (L) {
|
|
1124
|
+
const pe = this.get("sessionId");
|
|
1125
|
+
if (!pe) {
|
|
1128
1126
|
a.warn("EventManager", "Session start event ignored: missing sessionId");
|
|
1129
1127
|
return;
|
|
1130
1128
|
}
|
|
1131
1129
|
if (this.get("hasStartSession")) {
|
|
1132
1130
|
a.warn("EventManager", "Duplicate session_start detected", {
|
|
1133
|
-
sessionId:
|
|
1131
|
+
sessionId: pe
|
|
1134
1132
|
});
|
|
1135
1133
|
return;
|
|
1136
1134
|
}
|
|
@@ -1238,18 +1236,17 @@ class Wt extends f {
|
|
|
1238
1236
|
...e.web_vitals && { web_vitals: e.web_vitals },
|
|
1239
1237
|
...e.error_data && { error_data: e.error_data },
|
|
1240
1238
|
...e.session_end_reason && { session_end_reason: e.session_end_reason },
|
|
1241
|
-
...
|
|
1242
|
-
...t && Ce() && { utm: Ce() }
|
|
1239
|
+
...t && Ne() && { utm: Ne() }
|
|
1243
1240
|
}, i = this.get("config")?.tags;
|
|
1244
1241
|
return i?.length && (s.tags = i), s;
|
|
1245
1242
|
}
|
|
1246
1243
|
isEventExcluded(e) {
|
|
1247
|
-
const t = this.get("config"), n =
|
|
1244
|
+
const t = this.get("config"), n = Ft(e.page_url, t?.excludedUrlPaths ?? []), s = this.get("hasStartSession"), i = e.type === d.SESSION_END, o = e.type === d.SESSION_START;
|
|
1248
1245
|
return n && !o && !(i && s) ? !0 : t?.ipExcluded === !0;
|
|
1249
1246
|
}
|
|
1250
1247
|
isDuplicateEvent(e) {
|
|
1251
1248
|
const t = Date.now(), n = this.createEventFingerprint(e);
|
|
1252
|
-
return this.lastEventFingerprint === n && t - this.lastEventTime <
|
|
1249
|
+
return this.lastEventFingerprint === n && t - this.lastEventTime < Je ? !0 : (this.lastEventFingerprint = n, this.lastEventTime = t, !1);
|
|
1253
1250
|
}
|
|
1254
1251
|
createEventFingerprint(e) {
|
|
1255
1252
|
let t = `${e.type}_${e.page_url}`;
|
|
@@ -1263,10 +1260,10 @@ class Wt extends f {
|
|
|
1263
1260
|
return this.createEventFingerprint(e);
|
|
1264
1261
|
}
|
|
1265
1262
|
addToQueue(e) {
|
|
1266
|
-
if (this.eventsQueue.push(e), a.info("EventManager", "Event added to queue", e), this.emitEvent(e), this.eventsQueue.length >
|
|
1263
|
+
if (this.eventsQueue.push(e), a.info("EventManager", "Event added to queue", e), this.emitEvent(e), this.eventsQueue.length > Se) {
|
|
1267
1264
|
const t = this.eventsQueue.shift();
|
|
1268
1265
|
a.warn("EventManager", "Event queue overflow, oldest event removed", {
|
|
1269
|
-
maxLength:
|
|
1266
|
+
maxLength: Se,
|
|
1270
1267
|
currentLength: this.eventsQueue.length,
|
|
1271
1268
|
removedEventType: t?.type
|
|
1272
1269
|
});
|
|
@@ -1276,7 +1273,7 @@ class Wt extends f {
|
|
|
1276
1273
|
startSendInterval() {
|
|
1277
1274
|
this.sendIntervalId = window.setInterval(() => {
|
|
1278
1275
|
this.eventsQueue.length > 0 && this.sendEventsQueue();
|
|
1279
|
-
},
|
|
1276
|
+
}, Ze);
|
|
1280
1277
|
}
|
|
1281
1278
|
handleGoogleAnalyticsIntegration(e) {
|
|
1282
1279
|
this.googleAnalytics && e.type === d.CUSTOM && e.custom_event && (this.get("config")?.mode === "qa" || this.get("config")?.mode === "debug" || this.googleAnalytics.trackEvent(e.custom_event.name, e.custom_event.metadata ?? {}));
|
|
@@ -1305,7 +1302,7 @@ class Wt extends f {
|
|
|
1305
1302
|
this.emitter && this.emitter.emit(re.QUEUE, e);
|
|
1306
1303
|
}
|
|
1307
1304
|
}
|
|
1308
|
-
class
|
|
1305
|
+
class Wt {
|
|
1309
1306
|
/**
|
|
1310
1307
|
* Gets or creates a unique user ID for the given project.
|
|
1311
1308
|
* The user ID is persisted in localStorage and reused across sessions.
|
|
@@ -1315,14 +1312,14 @@ class Bt {
|
|
|
1315
1312
|
* @returns Persistent unique user ID
|
|
1316
1313
|
*/
|
|
1317
1314
|
static getId(e, t) {
|
|
1318
|
-
const n =
|
|
1315
|
+
const n = ut(t ?? ""), s = e.getItem(n);
|
|
1319
1316
|
if (s)
|
|
1320
1317
|
return s;
|
|
1321
|
-
const i =
|
|
1318
|
+
const i = Et();
|
|
1322
1319
|
return e.setItem(n, i), i;
|
|
1323
1320
|
}
|
|
1324
1321
|
}
|
|
1325
|
-
class
|
|
1322
|
+
class Bt extends f {
|
|
1326
1323
|
storageManager;
|
|
1327
1324
|
eventManager;
|
|
1328
1325
|
sessionTimeoutId = null;
|
|
@@ -1343,7 +1340,7 @@ class Yt extends f {
|
|
|
1343
1340
|
return;
|
|
1344
1341
|
}
|
|
1345
1342
|
const e = this.getProjectId();
|
|
1346
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
1343
|
+
this.broadcastChannel = new BroadcastChannel(gt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
1347
1344
|
const { action: n, sessionId: s, timestamp: i, projectId: o } = t.data ?? {};
|
|
1348
1345
|
if (o === e) {
|
|
1349
1346
|
if (n === "session_end") {
|
|
@@ -1419,7 +1416,7 @@ class Yt extends f {
|
|
|
1419
1416
|
this.storageManager.setItem(t, JSON.stringify(e));
|
|
1420
1417
|
}
|
|
1421
1418
|
getSessionStorageKey() {
|
|
1422
|
-
return
|
|
1419
|
+
return ht(this.getProjectId());
|
|
1423
1420
|
}
|
|
1424
1421
|
getProjectId() {
|
|
1425
1422
|
return this.get("config")?.id ?? "";
|
|
@@ -1435,9 +1432,8 @@ class Yt extends f {
|
|
|
1435
1432
|
const e = this.recoverSession(), t = e ?? this.generateSessionId(), n = !!e;
|
|
1436
1433
|
this.isTracking = !0;
|
|
1437
1434
|
try {
|
|
1438
|
-
this.set("sessionId", t), this.persistSession(t), this.eventManager.track({
|
|
1439
|
-
type: d.SESSION_START
|
|
1440
|
-
...n && { session_start_recovered: !0 }
|
|
1435
|
+
this.set("sessionId", t), this.persistSession(t), n || this.eventManager.track({
|
|
1436
|
+
type: d.SESSION_START
|
|
1441
1437
|
}), this.initCrossTabSync(), this.shareSession(t), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners(), a.info("SessionManager", "Session tracking started", { sessionId: t, recovered: n });
|
|
1442
1438
|
} catch (s) {
|
|
1443
1439
|
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), s;
|
|
@@ -1540,7 +1536,7 @@ class Yt extends f {
|
|
|
1540
1536
|
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.set("hasStartSession", !1);
|
|
1541
1537
|
}
|
|
1542
1538
|
}
|
|
1543
|
-
class
|
|
1539
|
+
class Yt extends f {
|
|
1544
1540
|
eventManager;
|
|
1545
1541
|
storageManager;
|
|
1546
1542
|
sessionManager = null;
|
|
@@ -1555,7 +1551,7 @@ class Kt extends f {
|
|
|
1555
1551
|
return;
|
|
1556
1552
|
}
|
|
1557
1553
|
try {
|
|
1558
|
-
this.sessionManager = new
|
|
1554
|
+
this.sessionManager = new Bt(this.storageManager, this.eventManager), await this.sessionManager.startTracking();
|
|
1559
1555
|
} catch (e) {
|
|
1560
1556
|
if (this.sessionManager) {
|
|
1561
1557
|
try {
|
|
@@ -1583,7 +1579,7 @@ class Kt extends f {
|
|
|
1583
1579
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0, this.set("hasStartSession", !1));
|
|
1584
1580
|
}
|
|
1585
1581
|
}
|
|
1586
|
-
class
|
|
1582
|
+
class Kt extends f {
|
|
1587
1583
|
eventManager;
|
|
1588
1584
|
onTrack;
|
|
1589
1585
|
originalPushState;
|
|
@@ -1637,7 +1633,7 @@ class Xt extends f {
|
|
|
1637
1633
|
};
|
|
1638
1634
|
}
|
|
1639
1635
|
}
|
|
1640
|
-
class
|
|
1636
|
+
class Xt extends f {
|
|
1641
1637
|
eventManager;
|
|
1642
1638
|
clickHandler;
|
|
1643
1639
|
constructor(e) {
|
|
@@ -1678,7 +1674,7 @@ class qt extends f {
|
|
|
1678
1674
|
return e.hasAttribute(`${k}-name`) ? e : e.closest(`[${k}-name]`) || void 0;
|
|
1679
1675
|
}
|
|
1680
1676
|
getRelevantClickElement(e) {
|
|
1681
|
-
for (const t of
|
|
1677
|
+
for (const t of at)
|
|
1682
1678
|
try {
|
|
1683
1679
|
if (e.matches(t))
|
|
1684
1680
|
return e;
|
|
@@ -1759,13 +1755,13 @@ class qt extends f {
|
|
|
1759
1755
|
};
|
|
1760
1756
|
}
|
|
1761
1757
|
}
|
|
1762
|
-
class
|
|
1758
|
+
class qt extends f {
|
|
1763
1759
|
eventManager;
|
|
1764
1760
|
containers = [];
|
|
1765
1761
|
limitWarningLogged = !1;
|
|
1766
|
-
minDepthChange =
|
|
1767
|
-
minIntervalMs =
|
|
1768
|
-
maxEventsPerSession =
|
|
1762
|
+
minDepthChange = ve;
|
|
1763
|
+
minIntervalMs = ye;
|
|
1764
|
+
maxEventsPerSession = Te;
|
|
1769
1765
|
constructor(e) {
|
|
1770
1766
|
super(), this.eventManager = e;
|
|
1771
1767
|
}
|
|
@@ -1803,7 +1799,7 @@ class Jt extends f {
|
|
|
1803
1799
|
this.processScrollEvent(s, i, o);
|
|
1804
1800
|
}
|
|
1805
1801
|
s.debounceTimer = null;
|
|
1806
|
-
},
|
|
1802
|
+
}, ke));
|
|
1807
1803
|
}, n = this.getScrollTop(e), s = {
|
|
1808
1804
|
element: e,
|
|
1809
1805
|
lastScrollPos: n,
|
|
@@ -1847,7 +1843,7 @@ class Jt extends f {
|
|
|
1847
1843
|
}));
|
|
1848
1844
|
}
|
|
1849
1845
|
applyConfigOverrides() {
|
|
1850
|
-
this.minDepthChange =
|
|
1846
|
+
this.minDepthChange = ve, this.minIntervalMs = ye, this.maxEventsPerSession = Te;
|
|
1851
1847
|
}
|
|
1852
1848
|
isWindowScrollable() {
|
|
1853
1849
|
return document.documentElement.scrollHeight > window.innerHeight;
|
|
@@ -1866,7 +1862,7 @@ class Jt extends f {
|
|
|
1866
1862
|
}
|
|
1867
1863
|
calculateScrollData(e) {
|
|
1868
1864
|
const { element: t, lastScrollPos: n } = e, s = this.getScrollTop(t);
|
|
1869
|
-
if (Math.abs(s - n) <
|
|
1865
|
+
if (Math.abs(s - n) < rt || t === window && !this.isWindowScrollable())
|
|
1870
1866
|
return null;
|
|
1871
1867
|
const o = this.getViewportHeight(t), c = this.getScrollHeight(t), l = this.getScrollDirection(s, n), u = this.calculateScrollDepth(s, c, o);
|
|
1872
1868
|
return e.lastScrollPos = s, { depth: u, direction: l };
|
|
@@ -1895,7 +1891,7 @@ class Jt extends f {
|
|
|
1895
1891
|
}
|
|
1896
1892
|
}
|
|
1897
1893
|
}
|
|
1898
|
-
class
|
|
1894
|
+
class Jt extends f {
|
|
1899
1895
|
isInitialized = !1;
|
|
1900
1896
|
async initialize() {
|
|
1901
1897
|
if (this.isInitialized)
|
|
@@ -1950,7 +1946,7 @@ class Zt extends f {
|
|
|
1950
1946
|
`, document.head.appendChild(n);
|
|
1951
1947
|
}
|
|
1952
1948
|
}
|
|
1953
|
-
class
|
|
1949
|
+
class Zt {
|
|
1954
1950
|
storage;
|
|
1955
1951
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
1956
1952
|
constructor() {
|
|
@@ -2030,12 +2026,12 @@ class er {
|
|
|
2030
2026
|
}
|
|
2031
2027
|
}
|
|
2032
2028
|
}
|
|
2033
|
-
class
|
|
2029
|
+
class er extends f {
|
|
2034
2030
|
eventManager;
|
|
2035
2031
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
2036
2032
|
observers = [];
|
|
2037
2033
|
lastLongTaskSentAt = 0;
|
|
2038
|
-
vitalThresholds =
|
|
2034
|
+
vitalThresholds = Ve;
|
|
2039
2035
|
constructor(e) {
|
|
2040
2036
|
super(), this.eventManager = e;
|
|
2041
2037
|
}
|
|
@@ -2059,7 +2055,7 @@ class tr extends f {
|
|
|
2059
2055
|
"largest-contentful-paint",
|
|
2060
2056
|
(n) => {
|
|
2061
2057
|
const s = n.getEntries(), i = s[s.length - 1];
|
|
2062
|
-
i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(
|
|
2058
|
+
i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(_)) });
|
|
2063
2059
|
},
|
|
2064
2060
|
{ type: "largest-contentful-paint", buffered: !0 },
|
|
2065
2061
|
!0
|
|
@@ -2077,14 +2073,14 @@ class tr extends f {
|
|
|
2077
2073
|
const c = typeof o.value == "number" ? o.value : 0;
|
|
2078
2074
|
e += c;
|
|
2079
2075
|
}
|
|
2080
|
-
this.sendVital({ type: "CLS", value: Number(e.toFixed(
|
|
2076
|
+
this.sendVital({ type: "CLS", value: Number(e.toFixed(_)) });
|
|
2081
2077
|
},
|
|
2082
2078
|
{ type: "layout-shift", buffered: !0 }
|
|
2083
2079
|
), this.safeObserve(
|
|
2084
2080
|
"paint",
|
|
2085
2081
|
(n) => {
|
|
2086
2082
|
for (const s of n.getEntries())
|
|
2087
|
-
s.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(s.startTime.toFixed(
|
|
2083
|
+
s.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(s.startTime.toFixed(_)) });
|
|
2088
2084
|
},
|
|
2089
2085
|
{ type: "paint", buffered: !0 },
|
|
2090
2086
|
!0
|
|
@@ -2097,15 +2093,15 @@ class tr extends f {
|
|
|
2097
2093
|
const c = (o.processingEnd ?? 0) - (o.startTime ?? 0);
|
|
2098
2094
|
s = Math.max(s, c);
|
|
2099
2095
|
}
|
|
2100
|
-
s > 0 && this.sendVital({ type: "INP", value: Number(s.toFixed(
|
|
2096
|
+
s > 0 && this.sendVital({ type: "INP", value: Number(s.toFixed(_)) });
|
|
2101
2097
|
},
|
|
2102
2098
|
{ type: "event", buffered: !0 }
|
|
2103
2099
|
);
|
|
2104
2100
|
}
|
|
2105
2101
|
async initWebVitals() {
|
|
2106
2102
|
try {
|
|
2107
|
-
const { onLCP: e, onCLS: t, onFCP: n, onTTFB: s, onINP: i } = await Promise.resolve().then(() =>
|
|
2108
|
-
const u = Number(l.value.toFixed(
|
|
2103
|
+
const { onLCP: e, onCLS: t, onFCP: n, onTTFB: s, onINP: i } = await Promise.resolve().then(() => yr), o = (c) => (l) => {
|
|
2104
|
+
const u = Number(l.value.toFixed(_));
|
|
2109
2105
|
this.sendVital({ type: c, value: u });
|
|
2110
2106
|
};
|
|
2111
2107
|
e(o("LCP")), t(o("CLS")), n(o("FCP")), s(o("TTFB")), i(o("INP"));
|
|
@@ -2121,7 +2117,7 @@ class tr extends f {
|
|
|
2121
2117
|
if (!e)
|
|
2122
2118
|
return;
|
|
2123
2119
|
const t = e.responseStart;
|
|
2124
|
-
typeof t == "number" && Number.isFinite(t) && this.sendVital({ type: "TTFB", value: Number(t.toFixed(
|
|
2120
|
+
typeof t == "number" && Number.isFinite(t) && this.sendVital({ type: "TTFB", value: Number(t.toFixed(_)) });
|
|
2125
2121
|
} catch (e) {
|
|
2126
2122
|
a.warn("PerformanceHandler", "Failed to report TTFB", {
|
|
2127
2123
|
error: e instanceof Error ? e.message : "Unknown error"
|
|
@@ -2134,8 +2130,8 @@ class tr extends f {
|
|
|
2134
2130
|
(e) => {
|
|
2135
2131
|
const t = e.getEntries();
|
|
2136
2132
|
for (const n of t) {
|
|
2137
|
-
const s = Number(n.duration.toFixed(
|
|
2138
|
-
i - this.lastLongTaskSentAt >=
|
|
2133
|
+
const s = Number(n.duration.toFixed(_)), i = Date.now();
|
|
2134
|
+
i - this.lastLongTaskSentAt >= ft && (this.shouldSendVital("LONG_TASK", s) && this.trackWebVital("LONG_TASK", s), this.lastLongTaskSentAt = i);
|
|
2139
2135
|
}
|
|
2140
2136
|
},
|
|
2141
2137
|
{ type: "longtask", buffered: !0 }
|
|
@@ -2222,7 +2218,7 @@ class tr extends f {
|
|
|
2222
2218
|
}), !1) : !0;
|
|
2223
2219
|
}
|
|
2224
2220
|
}
|
|
2225
|
-
class
|
|
2221
|
+
class tr extends f {
|
|
2226
2222
|
eventManager;
|
|
2227
2223
|
recentErrors = /* @__PURE__ */ new Map();
|
|
2228
2224
|
constructor(e) {
|
|
@@ -2283,8 +2279,8 @@ class rr extends f {
|
|
|
2283
2279
|
}
|
|
2284
2280
|
}
|
|
2285
2281
|
sanitize(e) {
|
|
2286
|
-
let t = e.length >
|
|
2287
|
-
for (const n of
|
|
2282
|
+
let t = e.length > Re ? e.slice(0, Re) + "..." : e;
|
|
2283
|
+
for (const n of Fe) {
|
|
2288
2284
|
const s = new RegExp(n.source, n.flags);
|
|
2289
2285
|
t = t.replace(s, "[REDACTED]");
|
|
2290
2286
|
}
|
|
@@ -2292,12 +2288,12 @@ class rr extends f {
|
|
|
2292
2288
|
}
|
|
2293
2289
|
shouldSuppressError(e, t) {
|
|
2294
2290
|
const n = Date.now(), s = `${e}:${t}`, i = this.recentErrors.get(s);
|
|
2295
|
-
return i && n - i <
|
|
2291
|
+
return i && n - i < Le ? (this.recentErrors.set(s, n), !0) : (this.recentErrors.set(s, n), this.recentErrors.size > X && this.pruneOldErrors(), !1);
|
|
2296
2292
|
}
|
|
2297
2293
|
pruneOldErrors() {
|
|
2298
2294
|
const e = Date.now();
|
|
2299
2295
|
for (const [s, i] of this.recentErrors.entries())
|
|
2300
|
-
e - i >
|
|
2296
|
+
e - i > Le && this.recentErrors.delete(s);
|
|
2301
2297
|
if (this.recentErrors.size <= X)
|
|
2302
2298
|
return;
|
|
2303
2299
|
const t = Array.from(this.recentErrors.entries()).sort((s, i) => s[1] - i[1]), n = this.recentErrors.size - X;
|
|
@@ -2307,10 +2303,10 @@ class rr extends f {
|
|
|
2307
2303
|
}
|
|
2308
2304
|
}
|
|
2309
2305
|
}
|
|
2310
|
-
class
|
|
2306
|
+
class rr extends f {
|
|
2311
2307
|
isInitialized = !1;
|
|
2312
2308
|
suppressNextScrollTimer = null;
|
|
2313
|
-
emitter = new
|
|
2309
|
+
emitter = new Gt();
|
|
2314
2310
|
managers = {};
|
|
2315
2311
|
handlers = {};
|
|
2316
2312
|
integrations = {};
|
|
@@ -2321,9 +2317,9 @@ class nr extends f {
|
|
|
2321
2317
|
if (!this.isInitialized) {
|
|
2322
2318
|
if (!e.id?.trim())
|
|
2323
2319
|
throw new Error("Project ID is required");
|
|
2324
|
-
this.managers.storage = new
|
|
2320
|
+
this.managers.storage = new Zt();
|
|
2325
2321
|
try {
|
|
2326
|
-
await this.setupState(e), await this.setupIntegrations(), this.managers.event = new
|
|
2322
|
+
await this.setupState(e), await this.setupIntegrations(), this.managers.event = new Qt(this.managers.storage, this.integrations.googleAnalytics, this.emitter), this.initializeHandlers(), await this.managers.event.recoverPersistedEvents().catch(() => {
|
|
2327
2323
|
a.warn("App", "Failed to recover persisted events");
|
|
2328
2324
|
}), this.isInitialized = !0;
|
|
2329
2325
|
} catch (t) {
|
|
@@ -2334,7 +2330,7 @@ class nr extends f {
|
|
|
2334
2330
|
sendCustomEvent(e, t) {
|
|
2335
2331
|
if (!this.managers.event)
|
|
2336
2332
|
return;
|
|
2337
|
-
const { valid: n, error: s, sanitizedMetadata: i } =
|
|
2333
|
+
const { valid: n, error: s, sanitizedMetadata: i } = Ht(e, t);
|
|
2338
2334
|
if (!n) {
|
|
2339
2335
|
const o = this.get("config");
|
|
2340
2336
|
if (o?.mode === "qa" || o?.mode === "debug")
|
|
@@ -2369,12 +2365,12 @@ class nr extends f {
|
|
|
2369
2365
|
await Promise.allSettled(t), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.set("hasStartSession", !1), this.set("suppressNextScroll", !1), this.set("sessionId", null), this.isInitialized = !1, this.handlers = {};
|
|
2370
2366
|
}
|
|
2371
2367
|
async setupState(e) {
|
|
2372
|
-
const t =
|
|
2368
|
+
const t = jt(e.id, e.allowHttp);
|
|
2373
2369
|
this.set("apiUrl", t);
|
|
2374
2370
|
const s = await new he().get(t, e), { config: i } = V(s);
|
|
2375
2371
|
this.set("config", i);
|
|
2376
|
-
const o =
|
|
2377
|
-
this.set("userId", o), this.set("device",
|
|
2372
|
+
const o = Wt.getId(this.managers.storage, i.id);
|
|
2373
|
+
this.set("userId", o), this.set("device", St());
|
|
2378
2374
|
const c = ie(window.location.href, i.sensitiveQueryParams);
|
|
2379
2375
|
this.set("pageUrl", c);
|
|
2380
2376
|
}
|
|
@@ -2382,13 +2378,13 @@ class nr extends f {
|
|
|
2382
2378
|
const e = this.get("config"), t = e.integrations?.googleAnalytics?.measurementId;
|
|
2383
2379
|
if (!e.ipExcluded && t?.trim())
|
|
2384
2380
|
try {
|
|
2385
|
-
this.integrations.googleAnalytics = new
|
|
2381
|
+
this.integrations.googleAnalytics = new Jt(), await this.integrations.googleAnalytics.initialize();
|
|
2386
2382
|
} catch {
|
|
2387
2383
|
this.integrations.googleAnalytics = void 0;
|
|
2388
2384
|
}
|
|
2389
2385
|
}
|
|
2390
2386
|
initializeHandlers() {
|
|
2391
|
-
this.handlers.session = new
|
|
2387
|
+
this.handlers.session = new Yt(
|
|
2392
2388
|
this.managers.storage,
|
|
2393
2389
|
this.managers.event
|
|
2394
2390
|
), this.handlers.session.startTracking().catch((t) => {
|
|
@@ -2399,15 +2395,15 @@ class nr extends f {
|
|
|
2399
2395
|
const e = () => {
|
|
2400
2396
|
this.set("suppressNextScroll", !0), this.suppressNextScrollTimer && clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = window.setTimeout(() => {
|
|
2401
2397
|
this.set("suppressNextScroll", !1);
|
|
2402
|
-
},
|
|
2398
|
+
}, ke * lt);
|
|
2403
2399
|
};
|
|
2404
|
-
this.handlers.pageView = new
|
|
2400
|
+
this.handlers.pageView = new Kt(this.managers.event, e), this.handlers.pageView.startTracking(), this.handlers.click = new Xt(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new qt(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new er(this.managers.event), this.handlers.performance.startTracking().catch(() => {
|
|
2405
2401
|
a.warn("App", "Failed to start performance tracking");
|
|
2406
|
-
}), this.handlers.error = new
|
|
2402
|
+
}), this.handlers.error = new tr(this.managers.event), this.handlers.error.startTracking();
|
|
2407
2403
|
}
|
|
2408
2404
|
}
|
|
2409
2405
|
let g = null, C = !1, q = !1;
|
|
2410
|
-
const
|
|
2406
|
+
const nr = async (r) => {
|
|
2411
2407
|
if (typeof window > "u" || typeof document > "u")
|
|
2412
2408
|
throw new Error("This library can only be used in a browser environment");
|
|
2413
2409
|
if (!window.__traceLogDisabled) {
|
|
@@ -2420,7 +2416,7 @@ const sr = async (r) => {
|
|
|
2420
2416
|
C = !0;
|
|
2421
2417
|
try {
|
|
2422
2418
|
a.info("API", "Initializing TraceLog", { projectId: r.id });
|
|
2423
|
-
const e =
|
|
2419
|
+
const e = Rt(r), t = new rr();
|
|
2424
2420
|
try {
|
|
2425
2421
|
await t.init(e), g = t, a.info("API", "TraceLog initialized successfully", { projectId: e.id });
|
|
2426
2422
|
} catch (n) {
|
|
@@ -2437,7 +2433,7 @@ const sr = async (r) => {
|
|
|
2437
2433
|
C = !1;
|
|
2438
2434
|
}
|
|
2439
2435
|
}
|
|
2440
|
-
},
|
|
2436
|
+
}, sr = (r, e) => {
|
|
2441
2437
|
if (!g)
|
|
2442
2438
|
throw new Error("TraceLog not initialized. Please call init() first.");
|
|
2443
2439
|
try {
|
|
@@ -2445,15 +2441,15 @@ const sr = async (r) => {
|
|
|
2445
2441
|
} catch (t) {
|
|
2446
2442
|
throw a.error("API", "Failed to send custom event", { eventName: r, error: t }), t;
|
|
2447
2443
|
}
|
|
2448
|
-
},
|
|
2444
|
+
}, ir = (r, e) => {
|
|
2449
2445
|
if (!g)
|
|
2450
2446
|
throw new Error("TraceLog not initialized. Please call init() first.");
|
|
2451
2447
|
g.on(r, e);
|
|
2452
|
-
},
|
|
2448
|
+
}, ar = (r, e) => {
|
|
2453
2449
|
if (!g)
|
|
2454
2450
|
throw new Error("TraceLog not initialized. Please call init() first.");
|
|
2455
2451
|
g.off(r, e);
|
|
2456
|
-
},
|
|
2452
|
+
}, or = () => g !== null, lr = async () => {
|
|
2457
2453
|
if (!g)
|
|
2458
2454
|
throw new Error("App not initialized");
|
|
2459
2455
|
if (q)
|
|
@@ -2466,13 +2462,13 @@ const sr = async (r) => {
|
|
|
2466
2462
|
} finally {
|
|
2467
2463
|
q = !1;
|
|
2468
2464
|
}
|
|
2469
|
-
},
|
|
2470
|
-
WEB_VITALS_THRESHOLDS:
|
|
2465
|
+
}, Tr = {
|
|
2466
|
+
WEB_VITALS_THRESHOLDS: Ve
|
|
2471
2467
|
// Business thresholds for performance analysis
|
|
2472
2468
|
}, Ir = {
|
|
2473
|
-
PII_PATTERNS:
|
|
2469
|
+
PII_PATTERNS: Fe
|
|
2474
2470
|
// Patterns for sensitive data protection
|
|
2475
|
-
},
|
|
2471
|
+
}, _r = {
|
|
2476
2472
|
LOW_ACTIVITY_EVENT_COUNT: 50,
|
|
2477
2473
|
HIGH_ACTIVITY_EVENT_COUNT: 1e3,
|
|
2478
2474
|
MIN_EVENTS_FOR_DYNAMIC_CALCULATION: 100,
|
|
@@ -2482,7 +2478,7 @@ const sr = async (r) => {
|
|
|
2482
2478
|
MIN_ENGAGED_SESSION_DURATION_MS: 30 * 1e3,
|
|
2483
2479
|
MIN_SCROLL_DEPTH_ENGAGEMENT: 25
|
|
2484
2480
|
// 25% scroll depth for engagement
|
|
2485
|
-
},
|
|
2481
|
+
}, wr = {
|
|
2486
2482
|
INACTIVITY_TIMEOUT_MS: 30 * 60 * 1e3,
|
|
2487
2483
|
// 30min for analytics (vs 15min client)
|
|
2488
2484
|
SHORT_SESSION_THRESHOLD_MS: 30 * 1e3,
|
|
@@ -2490,20 +2486,20 @@ const sr = async (r) => {
|
|
|
2490
2486
|
LONG_SESSION_THRESHOLD_MS: 30 * 60 * 1e3,
|
|
2491
2487
|
MAX_REALISTIC_SESSION_DURATION_MS: 8 * 60 * 60 * 1e3
|
|
2492
2488
|
// Filter outliers
|
|
2493
|
-
},
|
|
2489
|
+
}, Ar = {
|
|
2494
2490
|
MOBILE_MAX_WIDTH: 768,
|
|
2495
2491
|
TABLET_MAX_WIDTH: 1024,
|
|
2496
2492
|
MOBILE_PERFORMANCE_FACTOR: 1.5,
|
|
2497
2493
|
// Mobile typically 1.5x slower
|
|
2498
2494
|
TABLET_PERFORMANCE_FACTOR: 1.2
|
|
2499
|
-
},
|
|
2495
|
+
}, br = {
|
|
2500
2496
|
MIN_TEXT_LENGTH_FOR_ANALYSIS: 10,
|
|
2501
2497
|
MIN_CLICKS_FOR_HOT_ELEMENT: 10,
|
|
2502
2498
|
// Popular element threshold
|
|
2503
2499
|
MIN_SCROLL_COMPLETION_PERCENT: 80,
|
|
2504
2500
|
// Page consumption threshold
|
|
2505
2501
|
MIN_TIME_ON_PAGE_FOR_READ_MS: 15 * 1e3
|
|
2506
|
-
},
|
|
2502
|
+
}, Mr = {
|
|
2507
2503
|
SIGNIFICANT_CHANGE_PERCENT: 20,
|
|
2508
2504
|
MAJOR_CHANGE_PERCENT: 50,
|
|
2509
2505
|
MIN_EVENTS_FOR_INSIGHT: 100,
|
|
@@ -2513,19 +2509,19 @@ const sr = async (r) => {
|
|
|
2513
2509
|
LOW_ERROR_RATE_PERCENT: 1,
|
|
2514
2510
|
HIGH_ERROR_RATE_PERCENT: 5,
|
|
2515
2511
|
CRITICAL_ERROR_RATE_PERCENT: 10
|
|
2516
|
-
},
|
|
2512
|
+
}, Rr = {
|
|
2517
2513
|
SHORT_TERM_TREND_HOURS: 24,
|
|
2518
2514
|
MEDIUM_TERM_TREND_DAYS: 7,
|
|
2519
2515
|
LONG_TERM_TREND_DAYS: 30,
|
|
2520
2516
|
MIN_DATA_POINTS_FOR_TREND: 5,
|
|
2521
2517
|
WEEKLY_PATTERN_MIN_WEEKS: 4,
|
|
2522
2518
|
DAILY_PATTERN_MIN_DAYS: 14
|
|
2523
|
-
},
|
|
2519
|
+
}, Lr = {
|
|
2524
2520
|
MIN_SEGMENT_SIZE: 10,
|
|
2525
2521
|
MIN_COHORT_SIZE: 5,
|
|
2526
2522
|
COHORT_ANALYSIS_DAYS: [1, 3, 7, 14, 30],
|
|
2527
2523
|
MIN_FUNNEL_EVENTS: 20
|
|
2528
|
-
},
|
|
2524
|
+
}, Nr = {
|
|
2529
2525
|
DEFAULT_EVENTS_LIMIT: 5,
|
|
2530
2526
|
DEFAULT_SESSIONS_LIMIT: 5,
|
|
2531
2527
|
DEFAULT_PAGES_LIMIT: 5,
|
|
@@ -2533,27 +2529,27 @@ const sr = async (r) => {
|
|
|
2533
2529
|
MAX_TIME_RANGE_DAYS: 365,
|
|
2534
2530
|
ANALYTICS_BATCH_SIZE: 1e3
|
|
2535
2531
|
// For historical analysis
|
|
2536
|
-
},
|
|
2532
|
+
}, Cr = {
|
|
2537
2533
|
ANOMALY_THRESHOLD_SIGMA: 2.5,
|
|
2538
2534
|
STRONG_ANOMALY_THRESHOLD_SIGMA: 3,
|
|
2539
2535
|
TRAFFIC_DROP_ALERT_PERCENT: -30,
|
|
2540
2536
|
TRAFFIC_SPIKE_ALERT_PERCENT: 200,
|
|
2541
2537
|
MIN_BASELINE_DAYS: 7,
|
|
2542
2538
|
MIN_EVENTS_FOR_ANOMALY_DETECTION: 50
|
|
2543
|
-
},
|
|
2539
|
+
}, Pr = {
|
|
2544
2540
|
PAGE_URL_EXCLUDED: "excluded",
|
|
2545
2541
|
PAGE_URL_UNKNOWN: "unknown"
|
|
2546
|
-
},
|
|
2547
|
-
init:
|
|
2548
|
-
event:
|
|
2549
|
-
on:
|
|
2550
|
-
off:
|
|
2551
|
-
isInitialized:
|
|
2552
|
-
destroy:
|
|
2542
|
+
}, Or = {
|
|
2543
|
+
init: nr,
|
|
2544
|
+
event: sr,
|
|
2545
|
+
on: ir,
|
|
2546
|
+
off: ar,
|
|
2547
|
+
isInitialized: or,
|
|
2548
|
+
destroy: lr
|
|
2553
2549
|
};
|
|
2554
|
-
var ae,
|
|
2550
|
+
var ae, Ge = -1, R = function(r) {
|
|
2555
2551
|
addEventListener("pageshow", function(e) {
|
|
2556
|
-
e.persisted && (
|
|
2552
|
+
e.persisted && (Ge = e.timeStamp, r(e));
|
|
2557
2553
|
}, !0);
|
|
2558
2554
|
}, ge = function() {
|
|
2559
2555
|
var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
@@ -2563,7 +2559,7 @@ var ae, je = -1, L = function(r) {
|
|
|
2563
2559
|
return r && r.activationStart || 0;
|
|
2564
2560
|
}, S = function(r, e) {
|
|
2565
2561
|
var t = ge(), n = "navigate";
|
|
2566
|
-
return
|
|
2562
|
+
return Ge >= 0 ? n = "back-forward-cache" : t && (document.prerendering || $() > 0 ? n = "prerender" : document.wasDiscarded ? n = "restore" : t.type && (n = t.type.replace(/_/g, "-"))), { name: r, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: n };
|
|
2567
2563
|
}, D = function(r, e, t) {
|
|
2568
2564
|
try {
|
|
2569
2565
|
if (PerformanceObserver.supportedEntryTypes.includes(r)) {
|
|
@@ -2598,70 +2594,70 @@ var ae, je = -1, L = function(r) {
|
|
|
2598
2594
|
return function() {
|
|
2599
2595
|
e || (r(), e = !0);
|
|
2600
2596
|
};
|
|
2601
|
-
},
|
|
2597
|
+
}, M = -1, Oe = function() {
|
|
2602
2598
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
2603
2599
|
}, j = function(r) {
|
|
2604
|
-
document.visibilityState === "hidden" &&
|
|
2605
|
-
},
|
|
2600
|
+
document.visibilityState === "hidden" && M > -1 && (M = r.type === "visibilitychange" ? r.timeStamp : 0, cr());
|
|
2601
|
+
}, De = function() {
|
|
2606
2602
|
addEventListener("visibilitychange", j, !0), addEventListener("prerenderingchange", j, !0);
|
|
2607
|
-
},
|
|
2603
|
+
}, cr = function() {
|
|
2608
2604
|
removeEventListener("visibilitychange", j, !0), removeEventListener("prerenderingchange", j, !0);
|
|
2609
|
-
},
|
|
2610
|
-
return
|
|
2605
|
+
}, je = function() {
|
|
2606
|
+
return M < 0 && (M = Oe(), De(), R(function() {
|
|
2611
2607
|
setTimeout(function() {
|
|
2612
|
-
|
|
2608
|
+
M = Oe(), De();
|
|
2613
2609
|
}, 0);
|
|
2614
2610
|
})), { get firstHiddenTime() {
|
|
2615
|
-
return
|
|
2611
|
+
return M;
|
|
2616
2612
|
} };
|
|
2617
2613
|
}, W = function(r) {
|
|
2618
2614
|
document.prerendering ? addEventListener("prerenderingchange", function() {
|
|
2619
2615
|
return r();
|
|
2620
2616
|
}, !0) : r();
|
|
2621
|
-
}, oe = [1800, 3e3],
|
|
2617
|
+
}, oe = [1800, 3e3], $e = function(r, e) {
|
|
2622
2618
|
e = e || {}, W(function() {
|
|
2623
|
-
var t, n =
|
|
2619
|
+
var t, n = je(), s = S("FCP"), i = D("paint", function(o) {
|
|
2624
2620
|
o.forEach(function(c) {
|
|
2625
2621
|
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < n.firstHiddenTime && (s.value = Math.max(c.startTime - $(), 0), s.entries.push(c), t(!0)));
|
|
2626
2622
|
});
|
|
2627
2623
|
});
|
|
2628
|
-
i && (t = E(r, s, oe, e.reportAllChanges),
|
|
2624
|
+
i && (t = E(r, s, oe, e.reportAllChanges), R(function(o) {
|
|
2629
2625
|
s = S("FCP"), t = E(r, s, oe, e.reportAllChanges), fe(function() {
|
|
2630
2626
|
s.value = performance.now() - o.timeStamp, t(!0);
|
|
2631
2627
|
});
|
|
2632
2628
|
}));
|
|
2633
2629
|
});
|
|
2634
|
-
}, le = [0.1, 0.25],
|
|
2635
|
-
e = e || {},
|
|
2630
|
+
}, le = [0.1, 0.25], ur = function(r, e) {
|
|
2631
|
+
e = e || {}, $e(me(function() {
|
|
2636
2632
|
var t, n = S("CLS", 0), s = 0, i = [], o = function(l) {
|
|
2637
2633
|
l.forEach(function(u) {
|
|
2638
2634
|
if (!u.hadRecentInput) {
|
|
2639
|
-
var h = i[0],
|
|
2640
|
-
s && u.startTime -
|
|
2635
|
+
var h = i[0], L = i[i.length - 1];
|
|
2636
|
+
s && u.startTime - L.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (s += u.value, i.push(u)) : (s = u.value, i = [u]);
|
|
2641
2637
|
}
|
|
2642
2638
|
}), s > n.value && (n.value = s, n.entries = i, t());
|
|
2643
2639
|
}, c = D("layout-shift", o);
|
|
2644
2640
|
c && (t = E(r, n, le, e.reportAllChanges), Q(function() {
|
|
2645
2641
|
o(c.takeRecords()), t(!0);
|
|
2646
|
-
}),
|
|
2642
|
+
}), R(function() {
|
|
2647
2643
|
s = 0, n = S("CLS", 0), t = E(r, n, le, e.reportAllChanges), fe(function() {
|
|
2648
2644
|
return t();
|
|
2649
2645
|
});
|
|
2650
2646
|
}), setTimeout(t, 0));
|
|
2651
2647
|
}));
|
|
2652
|
-
},
|
|
2648
|
+
}, Qe = 0, J = 1 / 0, U = 0, dr = function(r) {
|
|
2653
2649
|
r.forEach(function(e) {
|
|
2654
|
-
e.interactionId && (J = Math.min(J, e.interactionId), U = Math.max(U, e.interactionId),
|
|
2650
|
+
e.interactionId && (J = Math.min(J, e.interactionId), U = Math.max(U, e.interactionId), Qe = U ? (U - J) / 7 + 1 : 0);
|
|
2655
2651
|
});
|
|
2656
|
-
},
|
|
2657
|
-
return ae ?
|
|
2658
|
-
},
|
|
2659
|
-
"interactionCount" in performance || ae || (ae = D("event",
|
|
2660
|
-
}, m = [], F = /* @__PURE__ */ new Map(),
|
|
2661
|
-
var r = Math.min(m.length - 1, Math.floor((
|
|
2652
|
+
}, We = function() {
|
|
2653
|
+
return ae ? Qe : performance.interactionCount || 0;
|
|
2654
|
+
}, hr = function() {
|
|
2655
|
+
"interactionCount" in performance || ae || (ae = D("event", dr, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
2656
|
+
}, m = [], F = /* @__PURE__ */ new Map(), Be = 0, gr = function() {
|
|
2657
|
+
var r = Math.min(m.length - 1, Math.floor((We() - Be) / 50));
|
|
2662
2658
|
return m[r];
|
|
2663
|
-
},
|
|
2664
|
-
if (
|
|
2659
|
+
}, fr = [], mr = function(r) {
|
|
2660
|
+
if (fr.forEach(function(s) {
|
|
2665
2661
|
return s(r);
|
|
2666
2662
|
}), r.interactionId || r.entryType === "first-input") {
|
|
2667
2663
|
var e = m[m.length - 1], t = F.get(r.interactionId);
|
|
@@ -2678,29 +2674,29 @@ var ae, je = -1, L = function(r) {
|
|
|
2678
2674
|
});
|
|
2679
2675
|
}
|
|
2680
2676
|
}
|
|
2681
|
-
},
|
|
2677
|
+
}, Ye = function(r) {
|
|
2682
2678
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
2683
2679
|
return r = me(r), document.visibilityState === "hidden" ? r() : (t = e(r), Q(r)), t;
|
|
2684
|
-
}, ce = [200, 500],
|
|
2680
|
+
}, ce = [200, 500], pr = function(r, e) {
|
|
2685
2681
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, W(function() {
|
|
2686
2682
|
var t;
|
|
2687
|
-
|
|
2683
|
+
hr();
|
|
2688
2684
|
var n, s = S("INP"), i = function(c) {
|
|
2689
|
-
|
|
2690
|
-
c.forEach(
|
|
2691
|
-
var l =
|
|
2685
|
+
Ye(function() {
|
|
2686
|
+
c.forEach(mr);
|
|
2687
|
+
var l = gr();
|
|
2692
2688
|
l && l.latency !== s.value && (s.value = l.latency, s.entries = l.entries, n());
|
|
2693
2689
|
});
|
|
2694
2690
|
}, o = D("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
2695
2691
|
n = E(r, s, ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), Q(function() {
|
|
2696
2692
|
i(o.takeRecords()), n(!0);
|
|
2697
|
-
}),
|
|
2698
|
-
|
|
2693
|
+
}), R(function() {
|
|
2694
|
+
Be = We(), m.length = 0, F.clear(), s = S("INP"), n = E(r, s, ce, e.reportAllChanges);
|
|
2699
2695
|
}));
|
|
2700
2696
|
}));
|
|
2701
|
-
}, ue = [2500, 4e3], Z = {},
|
|
2697
|
+
}, ue = [2500, 4e3], Z = {}, Sr = function(r, e) {
|
|
2702
2698
|
e = e || {}, W(function() {
|
|
2703
|
-
var t, n =
|
|
2699
|
+
var t, n = je(), s = S("LCP"), i = function(l) {
|
|
2704
2700
|
e.reportAllChanges || (l = l.slice(-1)), l.forEach(function(u) {
|
|
2705
2701
|
u.startTime < n.firstHiddenTime && (s.value = Math.max(u.startTime - $(), 0), s.entries = [u], t());
|
|
2706
2702
|
});
|
|
@@ -2712,64 +2708,64 @@ var ae, je = -1, L = function(r) {
|
|
|
2712
2708
|
});
|
|
2713
2709
|
["keydown", "click"].forEach(function(l) {
|
|
2714
2710
|
addEventListener(l, function() {
|
|
2715
|
-
return
|
|
2711
|
+
return Ye(c);
|
|
2716
2712
|
}, { once: !0, capture: !0 });
|
|
2717
|
-
}), Q(c),
|
|
2713
|
+
}), Q(c), R(function(l) {
|
|
2718
2714
|
s = S("LCP"), t = E(r, s, ue, e.reportAllChanges), fe(function() {
|
|
2719
2715
|
s.value = performance.now() - l.timeStamp, Z[s.id] = !0, t(!0);
|
|
2720
2716
|
});
|
|
2721
2717
|
});
|
|
2722
2718
|
}
|
|
2723
2719
|
});
|
|
2724
|
-
}, de = [800, 1800],
|
|
2720
|
+
}, de = [800, 1800], Er = function r(e) {
|
|
2725
2721
|
document.prerendering ? W(function() {
|
|
2726
2722
|
return r(e);
|
|
2727
2723
|
}) : document.readyState !== "complete" ? addEventListener("load", function() {
|
|
2728
2724
|
return r(e);
|
|
2729
2725
|
}, !0) : setTimeout(e, 0);
|
|
2730
|
-
},
|
|
2726
|
+
}, vr = function(r, e) {
|
|
2731
2727
|
e = e || {};
|
|
2732
2728
|
var t = S("TTFB"), n = E(r, t, de, e.reportAllChanges);
|
|
2733
|
-
|
|
2729
|
+
Er(function() {
|
|
2734
2730
|
var s = ge();
|
|
2735
|
-
s && (t.value = Math.max(s.responseStart - $(), 0), t.entries = [s], n(!0),
|
|
2731
|
+
s && (t.value = Math.max(s.responseStart - $(), 0), t.entries = [s], n(!0), R(function() {
|
|
2736
2732
|
t = S("TTFB", 0), (n = E(r, t, de, e.reportAllChanges))(!0);
|
|
2737
2733
|
}));
|
|
2738
2734
|
});
|
|
2739
2735
|
};
|
|
2740
|
-
const
|
|
2736
|
+
const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2741
2737
|
__proto__: null,
|
|
2742
2738
|
CLSThresholds: le,
|
|
2743
2739
|
FCPThresholds: oe,
|
|
2744
2740
|
INPThresholds: ce,
|
|
2745
2741
|
LCPThresholds: ue,
|
|
2746
2742
|
TTFBThresholds: de,
|
|
2747
|
-
onCLS:
|
|
2748
|
-
onFCP:
|
|
2749
|
-
onINP:
|
|
2750
|
-
onLCP:
|
|
2751
|
-
onTTFB:
|
|
2743
|
+
onCLS: ur,
|
|
2744
|
+
onFCP: $e,
|
|
2745
|
+
onINP: pr,
|
|
2746
|
+
onLCP: Sr,
|
|
2747
|
+
onTTFB: vr
|
|
2752
2748
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2753
2749
|
export {
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2750
|
+
Nr as ANALYTICS_QUERY_LIMITS,
|
|
2751
|
+
Cr as ANOMALY_DETECTION,
|
|
2752
|
+
br as CONTENT_ANALYTICS,
|
|
2757
2753
|
Ir as DATA_PROTECTION,
|
|
2758
|
-
|
|
2754
|
+
Ar as DEVICE_ANALYTICS,
|
|
2759
2755
|
y as DeviceType,
|
|
2760
|
-
|
|
2756
|
+
_r as ENGAGEMENT_THRESHOLDS,
|
|
2761
2757
|
N as ErrorType,
|
|
2762
2758
|
d as EventType,
|
|
2763
|
-
|
|
2759
|
+
Mr as INSIGHT_THRESHOLDS,
|
|
2764
2760
|
H as Mode,
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2761
|
+
Tr as PERFORMANCE_CONFIG,
|
|
2762
|
+
Lr as SEGMENTATION_ANALYTICS,
|
|
2763
|
+
wr as SESSION_ANALYTICS,
|
|
2764
|
+
Pr as SPECIAL_PAGE_URLS,
|
|
2769
2765
|
x as ScrollDirection,
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2766
|
+
Rr as TEMPORAL_ANALYSIS,
|
|
2767
|
+
Tt as TagConditionOperator,
|
|
2768
|
+
yt as TagConditionType,
|
|
2769
|
+
vt as TagLogicalOperator,
|
|
2770
|
+
Or as tracelog
|
|
2775
2771
|
};
|