@tracelog/lib 2.8.0 → 2.8.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.esm.js +528 -515
- 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/public-api.cjs +2 -2
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +9 -1
- package/dist/public-api.d.ts +9 -1
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const dr = 9e5;
|
|
2
|
+
const ur = 120, hr = 49152, fr = 100, mr = 500, gr = 200;
|
|
3
3
|
const Er = 1e3, Sr = 500, pr = 1e3;
|
|
4
|
-
const b = "data-tlog",
|
|
4
|
+
const b = "data-tlog", At = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const b = "data-tlog", bt = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], Lt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], Mt = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -49,7 +49,7 @@ const b = "data-tlog", bt = [
|
|
|
49
49
|
"code",
|
|
50
50
|
"otp"
|
|
51
51
|
];
|
|
52
|
-
const
|
|
52
|
+
const E = {
|
|
53
53
|
INVALID_SESSION_TIMEOUT: "Session timeout must be between 30000ms (30 seconds) and 86400000ms (24 hours)",
|
|
54
54
|
INVALID_SAMPLING_RATE: "Sampling rate must be between 0 and 1",
|
|
55
55
|
INVALID_ERROR_SAMPLING_RATE: "Error sampling must be between 0 and 1",
|
|
@@ -72,63 +72,67 @@ const m = {
|
|
|
72
72
|
INVALID_VIEWPORT_COOLDOWN_PERIOD: "Viewport cooldownPeriod must be a non-negative number",
|
|
73
73
|
INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS: "Viewport maxTrackedElements must be a positive number",
|
|
74
74
|
INVALID_SEND_INTERVAL: "Send interval must be between 1000ms (1 second) and 60000ms (60 seconds)"
|
|
75
|
-
},
|
|
75
|
+
}, Ct = [
|
|
76
76
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
77
77
|
/javascript:/gi,
|
|
78
78
|
/on\w+\s*=/gi,
|
|
79
79
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
80
80
|
/<embed\b[^>]*>/gi,
|
|
81
81
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
82
|
-
], I = "tlog",
|
|
83
|
-
var
|
|
82
|
+
], I = "tlog", X = `${I}:qa_mode`, Te = `${I}:uid`, nt = "tlog_mode", He = "qa", Fe = "qa_off", Rt = (r) => r ? `${I}:${r}:queue` : `${I}:queue`, Nt = (r) => r ? `${I}:${r}:session` : `${I}:session`, Ot = (r) => r ? `${I}:${r}:broadcast` : `${I}:broadcast`, xe = (r, e) => `${I}:${r}:session_counts:${e}`, $e = 10080 * 60 * 1e3, Be = `${I}:session_counts_last_cleanup`, We = 3600 * 1e3, fe = (r) => r ? `${I}:${r}:identity` : `${I}:identity`, U = `${I}:pending_identity`;
|
|
83
|
+
var $ = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))($ || {}), L = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(L || {}), se = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(se || {});
|
|
84
84
|
class O extends Error {
|
|
85
85
|
constructor(e, t) {
|
|
86
86
|
super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, O);
|
|
87
87
|
}
|
|
88
|
+
statusCode;
|
|
88
89
|
}
|
|
89
|
-
class
|
|
90
|
+
class re extends Error {
|
|
90
91
|
constructor(e) {
|
|
91
|
-
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
92
|
+
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, re);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
class
|
|
95
|
+
class ne extends Error {
|
|
95
96
|
constructor(e) {
|
|
96
|
-
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
97
|
+
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ne);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
var
|
|
100
|
-
const Tr = (r) => r.type ===
|
|
101
|
-
class
|
|
100
|
+
var u = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r.VIEWPORT_VISIBLE = "viewport_visible", r))(u || {}), Z = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(Z || {}), B = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(B || {}), ie = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(ie || {});
|
|
101
|
+
const Tr = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !0, Ir = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !1;
|
|
102
|
+
class j extends Error {
|
|
102
103
|
constructor(e, t, s) {
|
|
103
104
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
104
105
|
}
|
|
106
|
+
errorCode;
|
|
107
|
+
layer;
|
|
105
108
|
}
|
|
106
|
-
class
|
|
109
|
+
class m extends j {
|
|
107
110
|
constructor(e, t = "config") {
|
|
108
111
|
super(e, "APP_CONFIG_INVALID", t);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
class
|
|
114
|
+
class Pt extends j {
|
|
112
115
|
constructor(e, t = "config") {
|
|
113
116
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
class
|
|
119
|
+
class Xe extends j {
|
|
117
120
|
constructor(e, t = "config") {
|
|
118
121
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
|
-
class N extends
|
|
124
|
+
class N extends j {
|
|
122
125
|
constructor(e, t = "config") {
|
|
123
126
|
super(e, "INTEGRATION_INVALID", t);
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
class vr extends
|
|
129
|
+
class vr extends j {
|
|
127
130
|
constructor(e, t, s = "runtime") {
|
|
128
131
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
129
132
|
}
|
|
133
|
+
timeoutMs;
|
|
130
134
|
}
|
|
131
|
-
const
|
|
135
|
+
const it = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", ot = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Dt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", kt = (r, e) => {
|
|
132
136
|
if (e) {
|
|
133
137
|
if (e instanceof Error) {
|
|
134
138
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -147,21 +151,21 @@ const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
147
151
|
return `[TraceLog] ${r}: ${String(e)}`;
|
|
148
152
|
}
|
|
149
153
|
return `[TraceLog] ${r}`;
|
|
150
|
-
},
|
|
154
|
+
}, Vt = () => {
|
|
151
155
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
152
156
|
return !1;
|
|
153
157
|
try {
|
|
154
|
-
return sessionStorage.getItem(
|
|
158
|
+
return sessionStorage.getItem(X) === "true";
|
|
155
159
|
} catch {
|
|
156
160
|
return !1;
|
|
157
161
|
}
|
|
158
162
|
}, a = (r, e, t) => {
|
|
159
|
-
const { error: s, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = s ?
|
|
160
|
-
if (!
|
|
163
|
+
const { error: s, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = s ? kt(e, s) : `[TraceLog] ${e}`, d = r === "error" ? "error" : r === "warn" ? "warn" : "log";
|
|
164
|
+
if (!Ut(l, i))
|
|
161
165
|
return;
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
},
|
|
166
|
+
const g = Ht(l, o), T = n !== void 0 ? Ie(n) : void 0;
|
|
167
|
+
Ft(d, c, g, T);
|
|
168
|
+
}, Ut = (r, e) => r === "critical" ? !0 : r === "qa" || e ? Vt() : !1, Ht = (r, e) => e !== void 0 && e !== "" ? e : r === "critical" ? Dt : "", Ft = (r, e, t, s) => {
|
|
165
169
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
166
170
|
s !== void 0 ? n ? console[r](i, t, s) : console[r](i, s) : n ? console[r](i, t) : console[r](i);
|
|
167
171
|
}, Ie = (r) => {
|
|
@@ -178,10 +182,10 @@ const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
178
182
|
}
|
|
179
183
|
return e;
|
|
180
184
|
};
|
|
181
|
-
let ve,
|
|
182
|
-
const
|
|
183
|
-
typeof window < "u" && !ve && (ve = window.matchMedia("(pointer: coarse)"),
|
|
184
|
-
}, oe = "Unknown",
|
|
185
|
+
let ve, at;
|
|
186
|
+
const xt = () => {
|
|
187
|
+
typeof window < "u" && !ve && (ve = window.matchMedia("(pointer: coarse)"), at = window.matchMedia("(hover: none)"));
|
|
188
|
+
}, oe = "Unknown", $t = (r) => {
|
|
185
189
|
const e = r.userAgentData?.platform;
|
|
186
190
|
if (e != null && e !== "") {
|
|
187
191
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -193,7 +197,7 @@ const Ft = () => {
|
|
|
193
197
|
}
|
|
194
198
|
const t = navigator.userAgent;
|
|
195
199
|
return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : oe;
|
|
196
|
-
},
|
|
200
|
+
}, Bt = (r) => {
|
|
197
201
|
const e = r.userAgentData?.brands;
|
|
198
202
|
if (e != null && e.length > 0) {
|
|
199
203
|
const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -204,26 +208,26 @@ const Ft = () => {
|
|
|
204
208
|
}
|
|
205
209
|
const t = navigator.userAgent;
|
|
206
210
|
return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : oe;
|
|
207
|
-
},
|
|
211
|
+
}, Wt = () => {
|
|
208
212
|
try {
|
|
209
213
|
const r = navigator;
|
|
210
214
|
if (r.userAgentData != null && typeof r.userAgentData.mobile == "boolean") {
|
|
211
215
|
const c = r.userAgentData.platform;
|
|
212
216
|
return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : r.userAgentData.mobile ? L.Mobile : L.Desktop;
|
|
213
217
|
}
|
|
214
|
-
|
|
215
|
-
const e = window.innerWidth, t = ve?.matches ?? !1, s =
|
|
218
|
+
xt();
|
|
219
|
+
const e = window.innerWidth, t = ve?.matches ?? !1, s = at?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
216
220
|
return e <= 767 || o && n ? L.Mobile : e >= 768 && e <= 1024 || l || t && s && n ? L.Tablet : L.Desktop;
|
|
217
221
|
} catch (r) {
|
|
218
222
|
return a("debug", "Device detection failed, defaulting to desktop", { error: r }), L.Desktop;
|
|
219
223
|
}
|
|
220
|
-
},
|
|
224
|
+
}, Xt = () => {
|
|
221
225
|
try {
|
|
222
226
|
const r = navigator;
|
|
223
227
|
return {
|
|
224
|
-
type:
|
|
225
|
-
os:
|
|
226
|
-
browser:
|
|
228
|
+
type: Wt(),
|
|
229
|
+
os: $t(r),
|
|
230
|
+
browser: Bt(r)
|
|
227
231
|
};
|
|
228
232
|
} catch (r) {
|
|
229
233
|
return a("debug", "Device info detection failed, using defaults", { error: r }), {
|
|
@@ -232,7 +236,7 @@ const Ft = () => {
|
|
|
232
236
|
browser: oe
|
|
233
237
|
};
|
|
234
238
|
}
|
|
235
|
-
},
|
|
239
|
+
}, lt = [
|
|
236
240
|
// Email addresses
|
|
237
241
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
238
242
|
// US Phone numbers (various formats)
|
|
@@ -249,7 +253,7 @@ const Ft = () => {
|
|
|
249
253
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
250
254
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, etc.)
|
|
251
255
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
252
|
-
],
|
|
256
|
+
], Ge = 500, je = 2e3, ze = 5e3, ee = 50, Gt = ee * 2, ct = 1, jt = 1e3, zt = 10, Qe = 5e3, Qt = 6e4, _r = {
|
|
253
257
|
LCP: 2500,
|
|
254
258
|
// Good: ≤ 2.5s
|
|
255
259
|
FCP: 1800,
|
|
@@ -261,7 +265,7 @@ const Ft = () => {
|
|
|
261
265
|
TTFB: 800,
|
|
262
266
|
// Good: ≤ 800ms
|
|
263
267
|
LONG_TASK: 50
|
|
264
|
-
},
|
|
268
|
+
}, Ke = {
|
|
265
269
|
LCP: 2500,
|
|
266
270
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
267
271
|
FCP: 1800,
|
|
@@ -273,7 +277,7 @@ const Ft = () => {
|
|
|
273
277
|
TTFB: 800,
|
|
274
278
|
// Needs improvement: > 800ms
|
|
275
279
|
LONG_TASK: 50
|
|
276
|
-
},
|
|
280
|
+
}, Kt = {
|
|
277
281
|
LCP: 4e3,
|
|
278
282
|
// Poor: > 4s
|
|
279
283
|
FCP: 3e3,
|
|
@@ -285,53 +289,53 @@ const Ft = () => {
|
|
|
285
289
|
TTFB: 1800,
|
|
286
290
|
// Poor: > 1800ms
|
|
287
291
|
LONG_TASK: 50
|
|
288
|
-
}, _e = "needs-improvement",
|
|
292
|
+
}, _e = "needs-improvement", Ye = (r = _e) => {
|
|
289
293
|
switch (r) {
|
|
290
294
|
case "all":
|
|
291
295
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
292
296
|
// Track everything
|
|
293
297
|
case "needs-improvement":
|
|
294
|
-
return
|
|
298
|
+
return Ke;
|
|
295
299
|
case "poor":
|
|
296
|
-
return
|
|
300
|
+
return Kt;
|
|
297
301
|
default:
|
|
298
|
-
return
|
|
302
|
+
return Ke;
|
|
299
303
|
}
|
|
300
|
-
},
|
|
304
|
+
}, Yt = 1e3, qt = 50, Jt = "2.8.0", Zt = Jt, dt = () => typeof window < "u" && typeof sessionStorage < "u", es = () => {
|
|
301
305
|
try {
|
|
302
306
|
const r = new URLSearchParams(window.location.search);
|
|
303
|
-
r.delete(
|
|
307
|
+
r.delete(nt);
|
|
304
308
|
const e = r.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
305
309
|
window.history.replaceState({}, "", t);
|
|
306
310
|
} catch {
|
|
307
311
|
}
|
|
308
|
-
},
|
|
309
|
-
if (!
|
|
312
|
+
}, ts = () => {
|
|
313
|
+
if (!dt())
|
|
310
314
|
return !1;
|
|
311
315
|
try {
|
|
312
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
316
|
+
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(X);
|
|
313
317
|
let s = null;
|
|
314
|
-
return e ===
|
|
315
|
-
visibility: "qa",
|
|
316
|
-
style: nt
|
|
317
|
-
})) : e === He && (s = !1, sessionStorage.setItem(G, "false"), a("info", "QA Mode DISABLED", {
|
|
318
|
+
return e === He ? (s = !0, sessionStorage.setItem(X, "true"), a("info", "QA Mode ACTIVE", {
|
|
318
319
|
visibility: "qa",
|
|
319
320
|
style: it
|
|
320
|
-
}))
|
|
321
|
+
})) : e === Fe && (s = !1, sessionStorage.setItem(X, "false"), a("info", "QA Mode DISABLED", {
|
|
322
|
+
visibility: "qa",
|
|
323
|
+
style: ot
|
|
324
|
+
})), (e === He || e === Fe) && es(), s ?? t === "true";
|
|
321
325
|
} catch {
|
|
322
326
|
return !1;
|
|
323
327
|
}
|
|
324
|
-
},
|
|
325
|
-
if (
|
|
328
|
+
}, ss = (r) => {
|
|
329
|
+
if (dt())
|
|
326
330
|
try {
|
|
327
|
-
sessionStorage.setItem(
|
|
331
|
+
sessionStorage.setItem(X, r ? "true" : "false"), a("info", r ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
|
|
328
332
|
visibility: "qa",
|
|
329
|
-
style: r ?
|
|
333
|
+
style: r ? it : ot
|
|
330
334
|
});
|
|
331
335
|
} catch {
|
|
332
336
|
a("debug", "Cannot set QA mode: sessionStorage unavailable");
|
|
333
337
|
}
|
|
334
|
-
},
|
|
338
|
+
}, rs = [
|
|
335
339
|
"co.uk",
|
|
336
340
|
"org.uk",
|
|
337
341
|
"com.au",
|
|
@@ -343,25 +347,25 @@ const Ft = () => {
|
|
|
343
347
|
"co.in",
|
|
344
348
|
"com.cn",
|
|
345
349
|
"co.za"
|
|
346
|
-
],
|
|
350
|
+
], qe = (r) => {
|
|
347
351
|
const e = r.toLowerCase().split(".");
|
|
348
352
|
if (e.length <= 2)
|
|
349
353
|
return r.toLowerCase();
|
|
350
354
|
const t = e.slice(-2).join(".");
|
|
351
|
-
return
|
|
352
|
-
},
|
|
355
|
+
return rs.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
356
|
+
}, ns = (r, e) => r === e ? !0 : qe(r) === qe(e), me = () => {
|
|
353
357
|
const r = document.referrer;
|
|
354
358
|
if (!r)
|
|
355
359
|
return "Direct";
|
|
356
360
|
try {
|
|
357
361
|
const e = new URL(r).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
358
|
-
return
|
|
362
|
+
return ns(e, t) ? "Direct" : r;
|
|
359
363
|
} catch (e) {
|
|
360
364
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: r } }), r;
|
|
361
365
|
}
|
|
362
366
|
}, ge = () => {
|
|
363
367
|
const r = new URLSearchParams(window.location.search), e = {};
|
|
364
|
-
return
|
|
368
|
+
return Lt.forEach((s) => {
|
|
365
369
|
const n = r.get(s);
|
|
366
370
|
if (n) {
|
|
367
371
|
const i = s.split("utm_")[1];
|
|
@@ -372,11 +376,11 @@ const Ft = () => {
|
|
|
372
376
|
const e = Math.random() * 16 | 0;
|
|
373
377
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
374
378
|
});
|
|
375
|
-
let
|
|
376
|
-
const
|
|
379
|
+
let Y = 0, q = 0;
|
|
380
|
+
const ye = () => {
|
|
377
381
|
let r = Date.now();
|
|
378
|
-
r <
|
|
379
|
-
const e =
|
|
382
|
+
r < q && (r = q), r === q ? Y = (Y + 1) % 1e3 : Y = 0, q = r;
|
|
383
|
+
const e = Y.toString().padStart(3, "0");
|
|
380
384
|
let t = "";
|
|
381
385
|
try {
|
|
382
386
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -386,7 +390,7 @@ const ns = () => {
|
|
|
386
390
|
} catch {
|
|
387
391
|
}
|
|
388
392
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${r}-${e}-${t}`;
|
|
389
|
-
},
|
|
393
|
+
}, ht = (r, e = !1) => {
|
|
390
394
|
try {
|
|
391
395
|
const t = new URL(r), s = t.protocol === "https:", n = t.protocol === "http:";
|
|
392
396
|
return s || e && n;
|
|
@@ -411,7 +415,7 @@ const ns = () => {
|
|
|
411
415
|
if (s.length === 2 ? n = s.join(".") : n = s.slice(-2).join("."), !n || n.split(".").length < 2)
|
|
412
416
|
throw new Error("Invalid domain structure for SaaS");
|
|
413
417
|
const i = `https://${r}.${n}/collect`;
|
|
414
|
-
if (!
|
|
418
|
+
if (!ht(i))
|
|
415
419
|
throw new Error("Generated URL failed validation");
|
|
416
420
|
return i;
|
|
417
421
|
} catch (e) {
|
|
@@ -423,16 +427,16 @@ const ns = () => {
|
|
|
423
427
|
const t = r.integrations?.custom?.collectApiUrl;
|
|
424
428
|
if (t) {
|
|
425
429
|
const s = r.integrations?.custom?.allowHttp ?? !1;
|
|
426
|
-
if (!
|
|
430
|
+
if (!ht(t, s))
|
|
427
431
|
throw new Error("Invalid custom API URL");
|
|
428
432
|
e.custom = t;
|
|
429
433
|
}
|
|
430
434
|
return e;
|
|
431
|
-
},
|
|
435
|
+
}, we = (r, e = []) => {
|
|
432
436
|
if (!r || typeof r != "string")
|
|
433
437
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof r } }), r || "";
|
|
434
438
|
try {
|
|
435
|
-
const t = new URL(r), s = t.searchParams, n = [.../* @__PURE__ */ new Set([...
|
|
439
|
+
const t = new URL(r), s = t.searchParams, n = [.../* @__PURE__ */ new Set([...Mt, ...e])];
|
|
436
440
|
let i = !1;
|
|
437
441
|
const o = [];
|
|
438
442
|
return n.forEach((c) => {
|
|
@@ -441,13 +445,13 @@ const ns = () => {
|
|
|
441
445
|
} catch (t) {
|
|
442
446
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: r?.length } }), r;
|
|
443
447
|
}
|
|
444
|
-
},
|
|
448
|
+
}, Je = (r) => {
|
|
445
449
|
if (!r || typeof r != "string" || r.trim().length === 0)
|
|
446
450
|
return "";
|
|
447
451
|
let e = r;
|
|
448
452
|
r.length > 1e3 && (e = r.slice(0, Math.max(0, 1e3)));
|
|
449
453
|
let t = 0;
|
|
450
|
-
for (const n of
|
|
454
|
+
for (const n of Ct) {
|
|
451
455
|
const i = e;
|
|
452
456
|
e = e.replace(n, ""), i !== e && t++;
|
|
453
457
|
}
|
|
@@ -457,11 +461,11 @@ const ns = () => {
|
|
|
457
461
|
valueLength: r.length
|
|
458
462
|
}
|
|
459
463
|
}), e.trim();
|
|
460
|
-
},
|
|
464
|
+
}, be = (r, e = 0) => {
|
|
461
465
|
if (r == null)
|
|
462
466
|
return null;
|
|
463
467
|
if (typeof r == "string")
|
|
464
|
-
return
|
|
468
|
+
return Je(r);
|
|
465
469
|
if (typeof r == "number")
|
|
466
470
|
return !Number.isFinite(r) || r < -Number.MAX_SAFE_INTEGER || r > Number.MAX_SAFE_INTEGER ? 0 : r;
|
|
467
471
|
if (typeof r == "boolean")
|
|
@@ -469,13 +473,13 @@ const ns = () => {
|
|
|
469
473
|
if (e > 10)
|
|
470
474
|
return null;
|
|
471
475
|
if (Array.isArray(r))
|
|
472
|
-
return r.slice(0, 1e3).map((n) =>
|
|
476
|
+
return r.slice(0, 1e3).map((n) => be(n, e + 1)).filter((n) => n !== null);
|
|
473
477
|
if (typeof r == "object") {
|
|
474
478
|
const t = {}, n = Object.entries(r).slice(0, 200);
|
|
475
479
|
for (const [i, o] of n) {
|
|
476
|
-
const l =
|
|
480
|
+
const l = Je(i);
|
|
477
481
|
if (l) {
|
|
478
|
-
const c =
|
|
482
|
+
const c = be(o, e + 1);
|
|
479
483
|
c !== null && (t[l] = c);
|
|
480
484
|
}
|
|
481
485
|
}
|
|
@@ -486,7 +490,7 @@ const ns = () => {
|
|
|
486
490
|
if (typeof r != "object" || r === null)
|
|
487
491
|
return {};
|
|
488
492
|
try {
|
|
489
|
-
const e =
|
|
493
|
+
const e = be(r);
|
|
490
494
|
return typeof e == "object" && e !== null ? e : {};
|
|
491
495
|
} catch (e) {
|
|
492
496
|
const t = e instanceof Error ? e.message : String(e);
|
|
@@ -494,69 +498,69 @@ const ns = () => {
|
|
|
494
498
|
}
|
|
495
499
|
}, ls = (r) => {
|
|
496
500
|
if (r !== void 0 && (r === null || typeof r != "object"))
|
|
497
|
-
throw new
|
|
501
|
+
throw new m("Configuration must be an object", "config");
|
|
498
502
|
if (r) {
|
|
499
503
|
if (r.sessionTimeout !== void 0 && (typeof r.sessionTimeout != "number" || r.sessionTimeout < 3e4 || r.sessionTimeout > 864e5))
|
|
500
|
-
throw new
|
|
504
|
+
throw new Pt(E.INVALID_SESSION_TIMEOUT, "config");
|
|
501
505
|
if (r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null))
|
|
502
|
-
throw new
|
|
503
|
-
if (r.integrations &&
|
|
506
|
+
throw new m(E.INVALID_GLOBAL_METADATA, "config");
|
|
507
|
+
if (r.integrations && ds(r.integrations), r.sensitiveQueryParams !== void 0) {
|
|
504
508
|
if (!Array.isArray(r.sensitiveQueryParams))
|
|
505
|
-
throw new
|
|
509
|
+
throw new m(E.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
506
510
|
for (const e of r.sensitiveQueryParams)
|
|
507
511
|
if (typeof e != "string")
|
|
508
|
-
throw new
|
|
512
|
+
throw new m("All sensitive query params must be strings", "config");
|
|
509
513
|
}
|
|
510
514
|
if (r.errorSampling !== void 0 && (typeof r.errorSampling != "number" || r.errorSampling < 0 || r.errorSampling > 1))
|
|
511
|
-
throw new
|
|
515
|
+
throw new Xe(E.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
512
516
|
if (r.samplingRate !== void 0 && (typeof r.samplingRate != "number" || r.samplingRate < 0 || r.samplingRate > 1))
|
|
513
|
-
throw new
|
|
517
|
+
throw new Xe(E.INVALID_SAMPLING_RATE, "config");
|
|
514
518
|
if (r.primaryScrollSelector !== void 0) {
|
|
515
519
|
if (typeof r.primaryScrollSelector != "string" || !r.primaryScrollSelector.trim())
|
|
516
|
-
throw new
|
|
520
|
+
throw new m(E.INVALID_PRIMARY_SCROLL_SELECTOR, "config");
|
|
517
521
|
if (r.primaryScrollSelector !== "window")
|
|
518
522
|
try {
|
|
519
523
|
document.querySelector(r.primaryScrollSelector);
|
|
520
524
|
} catch {
|
|
521
|
-
throw new
|
|
522
|
-
`${
|
|
525
|
+
throw new m(
|
|
526
|
+
`${E.INVALID_PRIMARY_SCROLL_SELECTOR_SYNTAX}: "${r.primaryScrollSelector}"`,
|
|
523
527
|
"config"
|
|
524
528
|
);
|
|
525
529
|
}
|
|
526
530
|
}
|
|
527
531
|
if (r.pageViewThrottleMs !== void 0 && (typeof r.pageViewThrottleMs != "number" || r.pageViewThrottleMs < 0))
|
|
528
|
-
throw new
|
|
532
|
+
throw new m(E.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
529
533
|
if (r.clickThrottleMs !== void 0 && (typeof r.clickThrottleMs != "number" || r.clickThrottleMs < 0))
|
|
530
|
-
throw new
|
|
534
|
+
throw new m(E.INVALID_CLICK_THROTTLE, "config");
|
|
531
535
|
if (r.maxSameEventPerMinute !== void 0 && (typeof r.maxSameEventPerMinute != "number" || r.maxSameEventPerMinute <= 0))
|
|
532
|
-
throw new
|
|
536
|
+
throw new m(E.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
|
|
533
537
|
if (r.sendIntervalMs !== void 0 && (!Number.isFinite(r.sendIntervalMs) || r.sendIntervalMs < 1e3 || r.sendIntervalMs > 6e4))
|
|
534
|
-
throw new
|
|
538
|
+
throw new m(E.INVALID_SEND_INTERVAL, "config");
|
|
535
539
|
if (r.viewport !== void 0 && cs(r.viewport), r.webVitalsMode !== void 0) {
|
|
536
540
|
if (typeof r.webVitalsMode != "string")
|
|
537
|
-
throw new
|
|
541
|
+
throw new m(
|
|
538
542
|
`Invalid webVitalsMode type: ${typeof r.webVitalsMode}. Must be a string`,
|
|
539
543
|
"config"
|
|
540
544
|
);
|
|
541
545
|
const e = ["all", "needs-improvement", "poor"];
|
|
542
546
|
if (!e.includes(r.webVitalsMode))
|
|
543
|
-
throw new
|
|
547
|
+
throw new m(
|
|
544
548
|
`Invalid webVitalsMode: "${r.webVitalsMode}". Must be one of: ${e.join(", ")}`,
|
|
545
549
|
"config"
|
|
546
550
|
);
|
|
547
551
|
}
|
|
548
552
|
if (r.webVitalsThresholds !== void 0) {
|
|
549
553
|
if (typeof r.webVitalsThresholds != "object" || r.webVitalsThresholds === null || Array.isArray(r.webVitalsThresholds))
|
|
550
|
-
throw new
|
|
554
|
+
throw new m("webVitalsThresholds must be an object", "config");
|
|
551
555
|
const e = ["LCP", "FCP", "CLS", "INP", "TTFB", "LONG_TASK"];
|
|
552
556
|
for (const [t, s] of Object.entries(r.webVitalsThresholds)) {
|
|
553
557
|
if (!e.includes(t))
|
|
554
|
-
throw new
|
|
558
|
+
throw new m(
|
|
555
559
|
`Invalid Web Vitals threshold key: "${t}". Must be one of: ${e.join(", ")}`,
|
|
556
560
|
"config"
|
|
557
561
|
);
|
|
558
562
|
if (typeof s != "number" || !Number.isFinite(s) || s < 0)
|
|
559
|
-
throw new
|
|
563
|
+
throw new m(
|
|
560
564
|
`Invalid Web Vitals threshold value for ${t}: ${s}. Must be a non-negative finite number`,
|
|
561
565
|
"config"
|
|
562
566
|
);
|
|
@@ -565,41 +569,41 @@ const ns = () => {
|
|
|
565
569
|
}
|
|
566
570
|
}, cs = (r) => {
|
|
567
571
|
if (typeof r != "object" || r === null)
|
|
568
|
-
throw new
|
|
572
|
+
throw new m(E.INVALID_VIEWPORT_CONFIG, "config");
|
|
569
573
|
if (!r.elements || !Array.isArray(r.elements))
|
|
570
|
-
throw new
|
|
574
|
+
throw new m(E.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
571
575
|
if (r.elements.length === 0)
|
|
572
|
-
throw new
|
|
576
|
+
throw new m(E.INVALID_VIEWPORT_ELEMENTS, "config");
|
|
573
577
|
const e = /* @__PURE__ */ new Set();
|
|
574
578
|
for (const t of r.elements) {
|
|
575
579
|
if (!t.selector || typeof t.selector != "string" || !t.selector.trim())
|
|
576
|
-
throw new
|
|
580
|
+
throw new m(E.INVALID_VIEWPORT_ELEMENT, "config");
|
|
577
581
|
const s = t.selector.trim();
|
|
578
582
|
if (e.has(s))
|
|
579
|
-
throw new
|
|
583
|
+
throw new m(
|
|
580
584
|
`Duplicate viewport selector found: "${s}". Each selector should appear only once.`,
|
|
581
585
|
"config"
|
|
582
586
|
);
|
|
583
587
|
if (e.add(s), t.id !== void 0 && (typeof t.id != "string" || !t.id.trim()))
|
|
584
|
-
throw new
|
|
588
|
+
throw new m(E.INVALID_VIEWPORT_ELEMENT_ID, "config");
|
|
585
589
|
if (t.name !== void 0 && (typeof t.name != "string" || !t.name.trim()))
|
|
586
|
-
throw new
|
|
590
|
+
throw new m(E.INVALID_VIEWPORT_ELEMENT_NAME, "config");
|
|
587
591
|
}
|
|
588
592
|
if (r.threshold !== void 0 && (typeof r.threshold != "number" || r.threshold < 0 || r.threshold > 1))
|
|
589
|
-
throw new
|
|
593
|
+
throw new m(E.INVALID_VIEWPORT_THRESHOLD, "config");
|
|
590
594
|
if (r.minDwellTime !== void 0 && (typeof r.minDwellTime != "number" || r.minDwellTime < 0))
|
|
591
|
-
throw new
|
|
595
|
+
throw new m(E.INVALID_VIEWPORT_MIN_DWELL_TIME, "config");
|
|
592
596
|
if (r.cooldownPeriod !== void 0 && (typeof r.cooldownPeriod != "number" || r.cooldownPeriod < 0))
|
|
593
|
-
throw new
|
|
597
|
+
throw new m(E.INVALID_VIEWPORT_COOLDOWN_PERIOD, "config");
|
|
594
598
|
if (r.maxTrackedElements !== void 0 && (typeof r.maxTrackedElements != "number" || r.maxTrackedElements <= 0))
|
|
595
|
-
throw new
|
|
596
|
-
},
|
|
599
|
+
throw new m(E.INVALID_VIEWPORT_MAX_TRACKED_ELEMENTS, "config");
|
|
600
|
+
}, ds = (r) => {
|
|
597
601
|
if (r) {
|
|
598
602
|
if (r.tracelog && (!r.tracelog.projectId || typeof r.tracelog.projectId != "string" || r.tracelog.projectId.trim() === ""))
|
|
599
|
-
throw new N(
|
|
603
|
+
throw new N(E.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
600
604
|
if (r.custom) {
|
|
601
605
|
if (!r.custom.collectApiUrl || typeof r.custom.collectApiUrl != "string" || r.custom.collectApiUrl.trim() === "")
|
|
602
|
-
throw new N(
|
|
606
|
+
throw new N(E.INVALID_CUSTOM_API_URL, "config");
|
|
603
607
|
if (r.custom.allowHttp !== void 0 && typeof r.custom.allowHttp != "boolean")
|
|
604
608
|
throw new N("allowHttp must be a boolean", "config");
|
|
605
609
|
const e = r.custom.collectApiUrl.trim();
|
|
@@ -616,14 +620,14 @@ const ns = () => {
|
|
|
616
620
|
if (r.tracelog?.shopify !== void 0 && typeof r.tracelog.shopify != "boolean")
|
|
617
621
|
throw new N("tracelog.shopify must be a boolean", "config");
|
|
618
622
|
}
|
|
619
|
-
},
|
|
623
|
+
}, us = (r) => {
|
|
620
624
|
ls(r);
|
|
621
625
|
const e = {
|
|
622
626
|
...r ?? {},
|
|
623
627
|
sessionTimeout: r?.sessionTimeout ?? 9e5,
|
|
624
628
|
globalMetadata: r?.globalMetadata ?? {},
|
|
625
629
|
sensitiveQueryParams: r?.sensitiveQueryParams ?? [],
|
|
626
|
-
errorSampling: r?.errorSampling ??
|
|
630
|
+
errorSampling: r?.errorSampling ?? ct,
|
|
627
631
|
samplingRate: r?.samplingRate ?? 1,
|
|
628
632
|
pageViewThrottleMs: r?.pageViewThrottleMs ?? 1e3,
|
|
629
633
|
clickThrottleMs: r?.clickThrottleMs ?? 300,
|
|
@@ -640,12 +644,12 @@ const ns = () => {
|
|
|
640
644
|
cooldownPeriod: e.viewport.cooldownPeriod ?? 6e4,
|
|
641
645
|
maxTrackedElements: e.viewport.maxTrackedElements ?? 100
|
|
642
646
|
}), e;
|
|
643
|
-
},
|
|
647
|
+
}, Ae = (r, e = /* @__PURE__ */ new Set()) => {
|
|
644
648
|
if (r == null)
|
|
645
649
|
return !0;
|
|
646
650
|
const t = typeof r;
|
|
647
|
-
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(r) ? !1 : (e.add(r), Array.isArray(r) ? r.every((s) =>
|
|
648
|
-
}, hs = (r) => typeof r != "object" || r === null ? !1 :
|
|
651
|
+
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(r) ? !1 : (e.add(r), Array.isArray(r) ? r.every((s) => Ae(s, e)) : t === "object" ? Object.values(r).every((s) => Ae(s, e)) : !1);
|
|
652
|
+
}, hs = (r) => typeof r != "object" || r === null ? !1 : Ae(r), ft = (r) => {
|
|
649
653
|
if (typeof r != "object" || r === null || Array.isArray(r)) return;
|
|
650
654
|
const e = {};
|
|
651
655
|
for (const [t, s] of Object.entries(r))
|
|
@@ -666,7 +670,7 @@ const ns = () => {
|
|
|
666
670
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(r.toLowerCase()) ? {
|
|
667
671
|
valid: !1,
|
|
668
672
|
error: "Event name cannot be a reserved word"
|
|
669
|
-
} : { valid: !0 },
|
|
673
|
+
} : { valid: !0 }, Ze = (r, e, t) => {
|
|
670
674
|
const s = as(e), n = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
|
|
671
675
|
if (!hs(s))
|
|
672
676
|
return {
|
|
@@ -692,21 +696,21 @@ const ns = () => {
|
|
|
692
696
|
valid: !1,
|
|
693
697
|
error: `${n}: object has too many keys (max 100 keys).`
|
|
694
698
|
};
|
|
695
|
-
for (const [c,
|
|
696
|
-
if (Array.isArray(
|
|
697
|
-
if (
|
|
699
|
+
for (const [c, d] of Object.entries(s)) {
|
|
700
|
+
if (Array.isArray(d)) {
|
|
701
|
+
if (d.length > 500)
|
|
698
702
|
return {
|
|
699
703
|
valid: !1,
|
|
700
704
|
error: `${n}: array property "${c}" is too large (max 500 items).`
|
|
701
705
|
};
|
|
702
|
-
for (const
|
|
703
|
-
if (typeof
|
|
706
|
+
for (const f of d)
|
|
707
|
+
if (typeof f == "string" && f.length > 500)
|
|
704
708
|
return {
|
|
705
709
|
valid: !1,
|
|
706
710
|
error: `${n}: array property "${c}" contains strings that are too long (max 500 characters).`
|
|
707
711
|
};
|
|
708
712
|
}
|
|
709
|
-
if (typeof
|
|
713
|
+
if (typeof d == "string" && d.length > 1e3)
|
|
710
714
|
return {
|
|
711
715
|
valid: !1,
|
|
712
716
|
error: `${n}: property "${c}" is too long (max 1000 characters).`
|
|
@@ -716,7 +720,7 @@ const ns = () => {
|
|
|
716
720
|
valid: !0,
|
|
717
721
|
sanitizedMetadata: s
|
|
718
722
|
};
|
|
719
|
-
},
|
|
723
|
+
}, mt = (r, e, t) => {
|
|
720
724
|
if (Array.isArray(e)) {
|
|
721
725
|
const s = [], n = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
|
|
722
726
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -726,7 +730,7 @@ const ns = () => {
|
|
|
726
730
|
valid: !1,
|
|
727
731
|
error: `${n}: array item at index ${i} must be an object.`
|
|
728
732
|
};
|
|
729
|
-
const l =
|
|
733
|
+
const l = Ze(r, o, t);
|
|
730
734
|
if (!l.valid)
|
|
731
735
|
return {
|
|
732
736
|
valid: !1,
|
|
@@ -739,7 +743,7 @@ const ns = () => {
|
|
|
739
743
|
sanitizedMetadata: s
|
|
740
744
|
};
|
|
741
745
|
}
|
|
742
|
-
return
|
|
746
|
+
return Ze(r, e, t);
|
|
743
747
|
}, ms = (r, e) => {
|
|
744
748
|
const t = fs(r);
|
|
745
749
|
if (!t.valid)
|
|
@@ -748,7 +752,7 @@ const ns = () => {
|
|
|
748
752
|
}), t;
|
|
749
753
|
if (!e)
|
|
750
754
|
return { valid: !0 };
|
|
751
|
-
const s =
|
|
755
|
+
const s = mt(r, e, "customEvent");
|
|
752
756
|
return s.valid || a("error", "Event metadata validation failed", {
|
|
753
757
|
data: {
|
|
754
758
|
eventName: r,
|
|
@@ -873,7 +877,7 @@ class gs {
|
|
|
873
877
|
this.listeners.clear();
|
|
874
878
|
}
|
|
875
879
|
}
|
|
876
|
-
function
|
|
880
|
+
function gt(r, e, t) {
|
|
877
881
|
try {
|
|
878
882
|
const s = e(r);
|
|
879
883
|
return s === null ? null : typeof s == "object" && s !== null && "type" in s ? s : (a("warn", `beforeSend transformer returned invalid data, using original [${t}]`), r);
|
|
@@ -885,9 +889,9 @@ function mt(r, e, t) {
|
|
|
885
889
|
}
|
|
886
890
|
}
|
|
887
891
|
function Es(r, e, t) {
|
|
888
|
-
return r.map((s) =>
|
|
892
|
+
return r.map((s) => gt(s, e, t)).filter((s) => s !== null);
|
|
889
893
|
}
|
|
890
|
-
function
|
|
894
|
+
function Et(r, e, t) {
|
|
891
895
|
try {
|
|
892
896
|
const s = e(r);
|
|
893
897
|
return s === null ? (a("debug", `Batch filtered by beforeBatch transformer [${t}]`, {
|
|
@@ -962,7 +966,7 @@ class _ {
|
|
|
962
966
|
return { ...Ee };
|
|
963
967
|
}
|
|
964
968
|
}
|
|
965
|
-
class
|
|
969
|
+
class et extends _ {
|
|
966
970
|
storeManager;
|
|
967
971
|
integrationId;
|
|
968
972
|
apiUrl;
|
|
@@ -1047,7 +1051,7 @@ class Ze extends _ {
|
|
|
1047
1051
|
return { ...this.staticHeaders, ...e };
|
|
1048
1052
|
}
|
|
1049
1053
|
getQueueStorageKey() {
|
|
1050
|
-
const e = this.get("userId") || "anonymous", t =
|
|
1054
|
+
const e = this.get("userId") || "anonymous", t = Rt(e);
|
|
1051
1055
|
return this.integrationId ? `${t}:${this.integrationId}` : t;
|
|
1052
1056
|
}
|
|
1053
1057
|
/**
|
|
@@ -1064,13 +1068,14 @@ class Ze extends _ {
|
|
|
1064
1068
|
* - Uses `navigator.sendBeacon()` (browser-queued, synchronous API)
|
|
1065
1069
|
* - Payload size limited to 64KB (enforced by browser)
|
|
1066
1070
|
* - Browser guarantees delivery attempt (survives page close)
|
|
1067
|
-
* -
|
|
1071
|
+
* - Persists to localStorage on beacon failure/size overflow for later recovery
|
|
1068
1072
|
*
|
|
1069
1073
|
* **Return Values**:
|
|
1070
1074
|
* - `true`: Send succeeded OR skipped (standalone mode)
|
|
1071
1075
|
* - `false`: Send failed (network error, browser rejected beacon)
|
|
1072
1076
|
*
|
|
1073
|
-
* **Important**: No retry mechanism
|
|
1077
|
+
* **Important**: No retry mechanism. Failed events are persisted to localStorage for
|
|
1078
|
+
* recovery on next page load via `recoverPersistedEvents()`.
|
|
1074
1079
|
*
|
|
1075
1080
|
* **Custom Headers Limitation**: Custom headers set via `setCustomHeaders()` are NOT applied
|
|
1076
1081
|
* to sendBeacon requests due to browser API limitations. The sendBeacon API only supports
|
|
@@ -1089,13 +1094,13 @@ class Ze extends _ {
|
|
|
1089
1094
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1090
1095
|
*/
|
|
1091
1096
|
sendEventsQueueSync(e) {
|
|
1092
|
-
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes(
|
|
1097
|
+
return this.shouldSkipSend() ? !0 : this.apiUrl?.includes($.Fail) ? (a(
|
|
1093
1098
|
"warn",
|
|
1094
1099
|
`Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1095
1100
|
{
|
|
1096
1101
|
data: { events: e.events.length }
|
|
1097
1102
|
}
|
|
1098
|
-
), !1) : this.apiUrl?.includes(
|
|
1103
|
+
), !1) : this.apiUrl?.includes($.Localhost) ? (a(
|
|
1099
1104
|
"debug",
|
|
1100
1105
|
`Success mode: simulating successful send (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1101
1106
|
{
|
|
@@ -1120,7 +1125,7 @@ class Ze extends _ {
|
|
|
1120
1125
|
*
|
|
1121
1126
|
* **Error Handling**:
|
|
1122
1127
|
* - **Permanent errors** (4xx except 408, 429): Events discarded, not persisted
|
|
1123
|
-
* - **Timeout errors
|
|
1128
|
+
* - **Timeout errors**: Events persisted for retry with the same batch idempotency token
|
|
1124
1129
|
* - **Transient errors** (5xx, network, mixed): Events persisted for recovery
|
|
1125
1130
|
*
|
|
1126
1131
|
* **Important**: Events are NOT retried in-session. Persistence is for
|
|
@@ -1134,14 +1139,12 @@ class Ze extends _ {
|
|
|
1134
1139
|
* @see src/managers/README.md (lines 82-139) for send details
|
|
1135
1140
|
*/
|
|
1136
1141
|
async sendEventsQueue(e, t) {
|
|
1142
|
+
const s = this.ensureBatchMetadata(e);
|
|
1137
1143
|
try {
|
|
1138
|
-
const
|
|
1139
|
-
return
|
|
1140
|
-
} catch (
|
|
1141
|
-
return
|
|
1142
|
-
"debug",
|
|
1143
|
-
`All attempts timed out, skipping persistence (server likely received events)${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1144
|
-
), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(e), t?.onFailure?.(), !1);
|
|
1144
|
+
const n = await this.send(s);
|
|
1145
|
+
return n ? (this.clearPersistedEvents(), t?.onSuccess?.(s.events.length, s.events, s)) : (this.persistEvents(s), t?.onFailure?.()), n;
|
|
1146
|
+
} catch (n) {
|
|
1147
|
+
return n instanceof O ? (this.logPermanentError("Permanent error, not retrying", n), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(s), t?.onFailure?.(), !1);
|
|
1145
1148
|
}
|
|
1146
1149
|
}
|
|
1147
1150
|
/**
|
|
@@ -1199,35 +1202,28 @@ class Ze extends _ {
|
|
|
1199
1202
|
return;
|
|
1200
1203
|
}
|
|
1201
1204
|
this.recoveryInProgress = !0;
|
|
1205
|
+
let t = null, s = 0;
|
|
1202
1206
|
try {
|
|
1203
|
-
const
|
|
1204
|
-
if (!
|
|
1207
|
+
const n = this.getPersistedData();
|
|
1208
|
+
if (!n || !this.isDataRecent(n) || n.events.length === 0) {
|
|
1205
1209
|
this.clearPersistedEvents();
|
|
1206
1210
|
return;
|
|
1207
1211
|
}
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1212
|
+
const i = n.recoveryFailures;
|
|
1213
|
+
if (s = typeof i == "number" && Number.isFinite(i) && i >= 0 ? i : 0, s >= 3) {
|
|
1210
1214
|
a(
|
|
1211
1215
|
"debug",
|
|
1212
|
-
`Discarding persisted events after ${
|
|
1216
|
+
`Discarding persisted events after ${s} failed recovery attempts${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1213
1217
|
), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1214
1218
|
return;
|
|
1215
1219
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
this.logPermanentError("Permanent error during recovery, clearing persisted events", t), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1221
|
-
return;
|
|
1222
|
-
}
|
|
1223
|
-
if (t instanceof P) {
|
|
1224
|
-
a(
|
|
1225
|
-
"debug",
|
|
1226
|
-
`Recovery timed out, clearing persisted events (server likely received them)${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1227
|
-
), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1220
|
+
t = this.ensureBatchMetadata(this.createRecoveryBody(n)), await this.send(t) ? (this.clearPersistedEvents(), e?.onSuccess?.(n.events.length, n.events, t)) : (this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.());
|
|
1221
|
+
} catch (n) {
|
|
1222
|
+
if (n instanceof O) {
|
|
1223
|
+
this.logPermanentError("Permanent error during recovery, clearing persisted events", n), this.clearPersistedEvents(), e?.onFailure?.();
|
|
1228
1224
|
return;
|
|
1229
1225
|
}
|
|
1230
|
-
a("error", "Failed to recover persisted events", { error:
|
|
1226
|
+
a("error", "Failed to recover persisted events", { error: n }), t && this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.();
|
|
1231
1227
|
} finally {
|
|
1232
1228
|
this.recoveryInProgress = !1;
|
|
1233
1229
|
}
|
|
@@ -1322,7 +1318,7 @@ class Ze extends _ {
|
|
|
1322
1318
|
if (this.integrationId === "saas")
|
|
1323
1319
|
return e;
|
|
1324
1320
|
const t = this.transformers.beforeBatch;
|
|
1325
|
-
return t ?
|
|
1321
|
+
return t ? Et(e, t, this.integrationId || "SenderManager") : e;
|
|
1326
1322
|
}
|
|
1327
1323
|
/**
|
|
1328
1324
|
* Calculates exponential backoff delay with jitter for retry attempts.
|
|
@@ -1380,7 +1376,6 @@ class Ze extends _ {
|
|
|
1380
1376
|
* @param body - Event queue to send
|
|
1381
1377
|
* @returns Promise resolving to true if send succeeded, false if all retries exhausted
|
|
1382
1378
|
* @throws PermanentError for 4xx errors (caller should not retry)
|
|
1383
|
-
* @throws TimeoutError when all retry attempts timed out (caller should not persist)
|
|
1384
1379
|
*/
|
|
1385
1380
|
async send(e) {
|
|
1386
1381
|
if (this.shouldSkipSend())
|
|
@@ -1391,67 +1386,72 @@ class Ze extends _ {
|
|
|
1391
1386
|
const s = this.applyBeforeBatchTransformer(t);
|
|
1392
1387
|
if (!s)
|
|
1393
1388
|
return !0;
|
|
1394
|
-
|
|
1389
|
+
const n = this.ensureBatchMetadata(s, e._metadata?.idempotency_token);
|
|
1390
|
+
if (this.apiUrl?.includes($.Fail))
|
|
1395
1391
|
return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1396
|
-
data: { events:
|
|
1392
|
+
data: { events: n.events.length }
|
|
1397
1393
|
}), !1;
|
|
1398
|
-
if (this.apiUrl?.includes(
|
|
1394
|
+
if (this.apiUrl?.includes($.Localhost))
|
|
1399
1395
|
return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1400
|
-
data: { events:
|
|
1396
|
+
data: { events: n.events.length }
|
|
1401
1397
|
}), !0;
|
|
1402
1398
|
if (this.consecutiveNetworkFailures >= 3) {
|
|
1403
|
-
const
|
|
1404
|
-
if (
|
|
1399
|
+
const d = Date.now() - this.circuitOpenedAt;
|
|
1400
|
+
if (d < 12e4)
|
|
1405
1401
|
return a("debug", `Network circuit open, skipping send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1406
1402
|
data: {
|
|
1407
1403
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
1408
|
-
cooldownRemainingMs: 12e4 -
|
|
1404
|
+
cooldownRemainingMs: 12e4 - d
|
|
1409
1405
|
}
|
|
1410
1406
|
}), !1;
|
|
1411
1407
|
}
|
|
1412
|
-
const { url:
|
|
1413
|
-
let
|
|
1414
|
-
for (let
|
|
1408
|
+
const { url: i, payload: o } = this.prepareRequest(n);
|
|
1409
|
+
let l = !0, c = !1;
|
|
1410
|
+
for (let d = 1; d <= 3; d++)
|
|
1415
1411
|
try {
|
|
1416
|
-
return (await this.sendWithTimeout(
|
|
1412
|
+
return (await this.sendWithTimeout(i, o)).ok ? (d > 1 && a(
|
|
1417
1413
|
"info",
|
|
1418
|
-
`Send succeeded after ${
|
|
1414
|
+
`Send succeeded after ${d - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1419
1415
|
{
|
|
1420
|
-
data: { events:
|
|
1416
|
+
data: { events: n.events.length, attempt: d }
|
|
1421
1417
|
}
|
|
1422
1418
|
), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
|
|
1423
|
-
} catch (
|
|
1424
|
-
const g =
|
|
1425
|
-
if (
|
|
1426
|
-
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0,
|
|
1427
|
-
if (
|
|
1428
|
-
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0,
|
|
1429
|
-
data: { events: e.events.length, attempt:
|
|
1419
|
+
} catch (f) {
|
|
1420
|
+
const g = d === 3;
|
|
1421
|
+
if (f instanceof O)
|
|
1422
|
+
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, f;
|
|
1423
|
+
if (f instanceof re) {
|
|
1424
|
+
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l = !1, c = !0, a("warn", `Rate limited, skipping retries${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1425
|
+
data: { events: e.events.length, attempt: d }
|
|
1430
1426
|
});
|
|
1431
1427
|
break;
|
|
1432
1428
|
}
|
|
1433
|
-
if (
|
|
1429
|
+
if (f instanceof ne || (l = !1), f instanceof TypeError || (c = !0), a(
|
|
1434
1430
|
g ? "error" : "warn",
|
|
1435
|
-
`Send attempt ${
|
|
1431
|
+
`Send attempt ${d} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${g ? " (all retries exhausted)" : ", will retry"}`,
|
|
1436
1432
|
{
|
|
1437
|
-
error:
|
|
1433
|
+
error: f,
|
|
1438
1434
|
data: {
|
|
1439
1435
|
events: e.events.length,
|
|
1440
|
-
url:
|
|
1441
|
-
attempt:
|
|
1436
|
+
url: i.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1437
|
+
attempt: d,
|
|
1442
1438
|
maxAttempts: 3
|
|
1443
1439
|
}
|
|
1444
1440
|
}
|
|
1445
1441
|
), !g) {
|
|
1446
|
-
await this.backoffDelay(
|
|
1442
|
+
await this.backoffDelay(d);
|
|
1447
1443
|
continue;
|
|
1448
1444
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1445
|
+
return l ? (a(
|
|
1446
|
+
"debug",
|
|
1447
|
+
`All retry attempts timed out, preserving batch for retry${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1448
|
+
{
|
|
1449
|
+
data: { events: n.events.length }
|
|
1450
|
+
}
|
|
1451
|
+
), !1) : (c ? (this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0) : (this.consecutiveNetworkFailures = Math.min(
|
|
1452
1452
|
this.consecutiveNetworkFailures + 1,
|
|
1453
1453
|
3
|
|
1454
|
-
), this.consecutiveNetworkFailures >= 3 && (this.circuitOpenedAt = Date.now())), !1;
|
|
1454
|
+
), this.consecutiveNetworkFailures >= 3 && (this.circuitOpenedAt = Date.now())), !1);
|
|
1455
1455
|
}
|
|
1456
1456
|
return !1;
|
|
1457
1457
|
}
|
|
@@ -1463,18 +1463,18 @@ class Ze extends _ {
|
|
|
1463
1463
|
*
|
|
1464
1464
|
* **Timeout Behavior**:
|
|
1465
1465
|
* - 10-second timeout via AbortController (REQUEST_TIMEOUT_MS constant)
|
|
1466
|
-
* - Aborted requests throw TimeoutError
|
|
1466
|
+
* - Aborted requests throw TimeoutError
|
|
1467
1467
|
*
|
|
1468
1468
|
* **Error Classification**:
|
|
1469
1469
|
* - 4xx (except 408, 429): PermanentError thrown → no retries
|
|
1470
|
-
* - Timeout: TimeoutError thrown → caller
|
|
1470
|
+
* - Timeout: TimeoutError thrown → caller treats it as a retryable failure
|
|
1471
1471
|
* - 408, 429, 5xx, network: Standard Error thrown → triggers retry
|
|
1472
1472
|
*
|
|
1473
1473
|
* @param url - API endpoint URL
|
|
1474
1474
|
* @param payload - JSON-stringified EventsQueue body
|
|
1475
1475
|
* @returns Response object if successful
|
|
1476
1476
|
* @throws PermanentError for unrecoverable 4xx errors
|
|
1477
|
-
* @throws TimeoutError when request times out
|
|
1477
|
+
* @throws TimeoutError when request times out
|
|
1478
1478
|
* @throws Error for transient errors (5xx, network)
|
|
1479
1479
|
* @private
|
|
1480
1480
|
*/
|
|
@@ -1498,10 +1498,10 @@ class Ze extends _ {
|
|
|
1498
1498
|
}
|
|
1499
1499
|
});
|
|
1500
1500
|
if (!l.ok)
|
|
1501
|
-
throw l.status >= 400 && l.status < 500 && l.status !== 408 && l.status !== 429 ? new O(`HTTP ${l.status}: ${l.statusText}`, l.status) : l.status === 429 ? new
|
|
1501
|
+
throw l.status >= 400 && l.status < 500 && l.status !== 408 && l.status !== 429 ? new O(`HTTP ${l.status}: ${l.statusText}`, l.status) : l.status === 429 ? new re(`HTTP 429: ${l.statusText}`) : new Error(`HTTP ${l.status}: ${l.statusText}`);
|
|
1502
1502
|
return l;
|
|
1503
1503
|
} catch (o) {
|
|
1504
|
-
throw o instanceof O ? o : n ? new
|
|
1504
|
+
throw o instanceof O ? o : n ? new ne("Request timed out") : o;
|
|
1505
1505
|
} finally {
|
|
1506
1506
|
clearTimeout(i), this.pendingControllers.delete(s);
|
|
1507
1507
|
}
|
|
@@ -1523,40 +1523,40 @@ class Ze extends _ {
|
|
|
1523
1523
|
* - Oversized payloads persisted instead of silently failing
|
|
1524
1524
|
*
|
|
1525
1525
|
* @param body - EventsQueue to send
|
|
1526
|
-
* @returns `true` on success
|
|
1526
|
+
* @returns `true` on success, `false` on failure (events persisted for recovery)
|
|
1527
1527
|
* @private
|
|
1528
1528
|
*/
|
|
1529
1529
|
sendQueueSyncInternal(e) {
|
|
1530
|
-
const t = this.
|
|
1531
|
-
if (!t)
|
|
1532
|
-
return !0;
|
|
1533
|
-
const s = this.applyBeforeBatchTransformer(t);
|
|
1530
|
+
const t = this.ensureBatchMetadata(e), s = this.applyBeforeSendTransformer(t);
|
|
1534
1531
|
if (!s)
|
|
1535
1532
|
return !0;
|
|
1536
|
-
const
|
|
1537
|
-
if (
|
|
1533
|
+
const n = this.applyBeforeBatchTransformer(s);
|
|
1534
|
+
if (!n)
|
|
1535
|
+
return !0;
|
|
1536
|
+
const i = this.ensureBatchMetadata(n, t._metadata?.idempotency_token), { url: o, payload: l } = this.prepareRequest(i);
|
|
1537
|
+
if (l.length > 65536)
|
|
1538
1538
|
return a(
|
|
1539
1539
|
"warn",
|
|
1540
1540
|
`Payload exceeds sendBeacon limit, persisting for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`,
|
|
1541
1541
|
{
|
|
1542
1542
|
data: {
|
|
1543
|
-
size:
|
|
1543
|
+
size: l.length,
|
|
1544
1544
|
limit: 65536,
|
|
1545
|
-
events:
|
|
1545
|
+
events: i.events.length
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
1548
|
-
), this.persistEvents(
|
|
1549
|
-
const
|
|
1548
|
+
), this.persistEvents(t), !1;
|
|
1549
|
+
const c = new Blob([l], { type: "application/json" });
|
|
1550
1550
|
if (!this.isSendBeaconAvailable())
|
|
1551
1551
|
return a(
|
|
1552
1552
|
"warn",
|
|
1553
1553
|
`sendBeacon not available, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1554
|
-
), this.persistEvents(
|
|
1555
|
-
const
|
|
1556
|
-
return
|
|
1554
|
+
), this.persistEvents(t), !1;
|
|
1555
|
+
const d = navigator.sendBeacon(o, c);
|
|
1556
|
+
return d || (a(
|
|
1557
1557
|
"warn",
|
|
1558
1558
|
`sendBeacon rejected request, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
|
|
1559
|
-
), this.persistEvents(
|
|
1559
|
+
), this.persistEvents(t)), d;
|
|
1560
1560
|
}
|
|
1561
1561
|
/**
|
|
1562
1562
|
* Prepares request by enriching payload with metadata and serializing to JSON.
|
|
@@ -1568,9 +1568,10 @@ class Ze extends _ {
|
|
|
1568
1568
|
* - `timestamp`: Request generation time in milliseconds
|
|
1569
1569
|
*
|
|
1570
1570
|
* **Idempotency Token**:
|
|
1571
|
-
* -
|
|
1572
|
-
* -
|
|
1573
|
-
* -
|
|
1571
|
+
* - Set upstream by ensureBatchMetadata() before this method is called
|
|
1572
|
+
* - Fallback generateEventId() is defensive only (should not trigger in normal flow)
|
|
1573
|
+
* - Same token persists across all retry attempts of the same batch
|
|
1574
|
+
* - Backend uses this to deduplicate retries
|
|
1574
1575
|
*
|
|
1575
1576
|
* @param body - EventsQueue to send
|
|
1576
1577
|
* @returns Object with `url` (API endpoint) and `payload` (JSON string)
|
|
@@ -1582,9 +1583,11 @@ class Ze extends _ {
|
|
|
1582
1583
|
const s = {
|
|
1583
1584
|
...e,
|
|
1584
1585
|
_metadata: {
|
|
1586
|
+
...e._metadata,
|
|
1587
|
+
idempotency_token: e._metadata?.idempotency_token ?? ye(),
|
|
1585
1588
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1586
1589
|
timestamp: t,
|
|
1587
|
-
client_version:
|
|
1590
|
+
client_version: Zt
|
|
1588
1591
|
}
|
|
1589
1592
|
};
|
|
1590
1593
|
return {
|
|
@@ -1592,6 +1595,16 @@ class Ze extends _ {
|
|
|
1592
1595
|
payload: JSON.stringify(s)
|
|
1593
1596
|
};
|
|
1594
1597
|
}
|
|
1598
|
+
ensureBatchMetadata(e, t) {
|
|
1599
|
+
const s = e._metadata?.idempotency_token ?? t ?? ye();
|
|
1600
|
+
return e._metadata?.idempotency_token === s ? e : {
|
|
1601
|
+
...e,
|
|
1602
|
+
_metadata: {
|
|
1603
|
+
...e._metadata,
|
|
1604
|
+
idempotency_token: s
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1595
1608
|
/**
|
|
1596
1609
|
* Retrieves persisted events from localStorage with error recovery.
|
|
1597
1610
|
*
|
|
@@ -1723,7 +1736,7 @@ class Ze extends _ {
|
|
|
1723
1736
|
}
|
|
1724
1737
|
logPermanentError(e, t) {
|
|
1725
1738
|
const s = Date.now();
|
|
1726
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >=
|
|
1739
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= Qt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1727
1740
|
data: { status: t.statusCode, message: t.message }
|
|
1728
1741
|
}), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: s });
|
|
1729
1742
|
}
|
|
@@ -1877,7 +1890,7 @@ class Ss extends _ {
|
|
|
1877
1890
|
};
|
|
1878
1891
|
}
|
|
1879
1892
|
}
|
|
1880
|
-
const ps = new Set(Object.values(
|
|
1893
|
+
const ps = new Set(Object.values(u));
|
|
1881
1894
|
class Ts extends _ {
|
|
1882
1895
|
dataSenders;
|
|
1883
1896
|
emitter;
|
|
@@ -1895,11 +1908,11 @@ class Ts extends _ {
|
|
|
1895
1908
|
lastSessionId = null;
|
|
1896
1909
|
sessionEventCounts = {
|
|
1897
1910
|
total: 0,
|
|
1898
|
-
[
|
|
1899
|
-
[
|
|
1900
|
-
[
|
|
1901
|
-
[
|
|
1902
|
-
[
|
|
1911
|
+
[u.CLICK]: 0,
|
|
1912
|
+
[u.PAGE_VIEW]: 0,
|
|
1913
|
+
[u.CUSTOM]: 0,
|
|
1914
|
+
[u.VIEWPORT_VISIBLE]: 0,
|
|
1915
|
+
[u.SCROLL]: 0
|
|
1903
1916
|
};
|
|
1904
1917
|
saveSessionCountsDebounced = null;
|
|
1905
1918
|
/**
|
|
@@ -1919,8 +1932,8 @@ class Ts extends _ {
|
|
|
1919
1932
|
constructor(e, t = null, s = {}, n = {}, i, o = "include") {
|
|
1920
1933
|
super(), this.emitter = t, this.transformers = s, this.timeManager = new Ss(), this.dataSenders = [];
|
|
1921
1934
|
const l = this.get("collectApiUrls");
|
|
1922
|
-
l?.saas && this.dataSenders.push(new
|
|
1923
|
-
new
|
|
1935
|
+
l?.saas && this.dataSenders.push(new et(e, "saas", l.saas, s)), l?.custom && this.dataSenders.push(
|
|
1936
|
+
new et(
|
|
1924
1937
|
e,
|
|
1925
1938
|
"custom",
|
|
1926
1939
|
l.custom,
|
|
@@ -2041,8 +2054,8 @@ class Ts extends _ {
|
|
|
2041
2054
|
custom_event: o,
|
|
2042
2055
|
web_vitals: l,
|
|
2043
2056
|
error_data: c,
|
|
2044
|
-
viewport_data:
|
|
2045
|
-
page_view:
|
|
2057
|
+
viewport_data: d,
|
|
2058
|
+
page_view: f
|
|
2046
2059
|
}) {
|
|
2047
2060
|
if (!e) {
|
|
2048
2061
|
a("error", "Event type is required - event will be ignored");
|
|
@@ -2054,8 +2067,8 @@ class Ts extends _ {
|
|
|
2054
2067
|
});
|
|
2055
2068
|
return;
|
|
2056
2069
|
}
|
|
2057
|
-
const
|
|
2058
|
-
if (!
|
|
2070
|
+
const g = this.get("sessionId");
|
|
2071
|
+
if (!g) {
|
|
2059
2072
|
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("debug", "Pending events buffer full - dropping oldest event", {
|
|
2060
2073
|
data: { maxBufferSize: 100 }
|
|
2061
2074
|
})), this.pendingEventsBuffer.push({
|
|
@@ -2067,15 +2080,15 @@ class Ts extends _ {
|
|
|
2067
2080
|
custom_event: o,
|
|
2068
2081
|
web_vitals: l,
|
|
2069
2082
|
error_data: c,
|
|
2070
|
-
viewport_data:
|
|
2071
|
-
page_view:
|
|
2083
|
+
viewport_data: d,
|
|
2084
|
+
page_view: f
|
|
2072
2085
|
});
|
|
2073
2086
|
return;
|
|
2074
2087
|
}
|
|
2075
|
-
this.lastSessionId !==
|
|
2076
|
-
const T = e ===
|
|
2088
|
+
this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
|
|
2089
|
+
const T = e === u.SESSION_START;
|
|
2077
2090
|
if (T && a("debug", "Processing SESSION_START event", {
|
|
2078
|
-
data: { sessionId:
|
|
2091
|
+
data: { sessionId: g }
|
|
2079
2092
|
}), !T && !this.checkRateLimit())
|
|
2080
2093
|
return;
|
|
2081
2094
|
const S = e;
|
|
@@ -2105,25 +2118,25 @@ class Ts extends _ {
|
|
|
2105
2118
|
}
|
|
2106
2119
|
}
|
|
2107
2120
|
}
|
|
2108
|
-
if (S ===
|
|
2121
|
+
if (S === u.CUSTOM && o?.name) {
|
|
2109
2122
|
const v = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
2110
2123
|
if (!this.checkPerEventRateLimit(o.name, v))
|
|
2111
2124
|
return;
|
|
2112
2125
|
}
|
|
2113
|
-
const
|
|
2126
|
+
const Ue = S === u.SESSION_START, K = t || this.get("pageUrl"), x = this.buildEventPayload({
|
|
2114
2127
|
type: S,
|
|
2115
|
-
page_url:
|
|
2128
|
+
page_url: K,
|
|
2116
2129
|
from_page_url: s,
|
|
2117
2130
|
scroll_data: n,
|
|
2118
2131
|
click_data: i,
|
|
2119
2132
|
custom_event: o,
|
|
2120
2133
|
web_vitals: l,
|
|
2121
2134
|
error_data: c,
|
|
2122
|
-
viewport_data:
|
|
2123
|
-
page_view:
|
|
2135
|
+
viewport_data: d,
|
|
2136
|
+
page_view: f
|
|
2124
2137
|
});
|
|
2125
|
-
if (
|
|
2126
|
-
if (
|
|
2138
|
+
if (x && !(!T && !this.shouldSample())) {
|
|
2139
|
+
if (Ue) {
|
|
2127
2140
|
const v = this.get("sessionId");
|
|
2128
2141
|
if (!v) {
|
|
2129
2142
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -2137,34 +2150,34 @@ class Ts extends _ {
|
|
|
2137
2150
|
}
|
|
2138
2151
|
this.set("hasStartSession", !0);
|
|
2139
2152
|
}
|
|
2140
|
-
if (!this.isDuplicateEvent(
|
|
2153
|
+
if (!this.isDuplicateEvent(x)) {
|
|
2141
2154
|
if (this.get("mode") === ie.QA) {
|
|
2142
|
-
if (S ===
|
|
2155
|
+
if (S === u.CUSTOM && o) {
|
|
2143
2156
|
a("info", `Custom Event: ${o.name}`, {
|
|
2144
2157
|
visibility: "qa",
|
|
2145
2158
|
data: {
|
|
2146
2159
|
name: o.name,
|
|
2147
2160
|
...o.metadata && { metadata: o.metadata }
|
|
2148
2161
|
}
|
|
2149
|
-
}), this.emitEvent(
|
|
2162
|
+
}), this.emitEvent(x);
|
|
2150
2163
|
return;
|
|
2151
2164
|
}
|
|
2152
|
-
if (S ===
|
|
2153
|
-
const v =
|
|
2165
|
+
if (S === u.VIEWPORT_VISIBLE && d) {
|
|
2166
|
+
const v = d.name || d.id || d.selector;
|
|
2154
2167
|
a("info", `Viewport Visible: ${v}`, {
|
|
2155
2168
|
visibility: "qa",
|
|
2156
2169
|
data: {
|
|
2157
|
-
selector:
|
|
2158
|
-
...
|
|
2159
|
-
...
|
|
2160
|
-
visibilityRatio:
|
|
2161
|
-
dwellTime:
|
|
2170
|
+
selector: d.selector,
|
|
2171
|
+
...d.name && { name: d.name },
|
|
2172
|
+
...d.id && { id: d.id },
|
|
2173
|
+
visibilityRatio: d.visibilityRatio,
|
|
2174
|
+
dwellTime: d.dwellTime
|
|
2162
2175
|
}
|
|
2163
|
-
}), this.emitEvent(
|
|
2176
|
+
}), this.emitEvent(x);
|
|
2164
2177
|
return;
|
|
2165
2178
|
}
|
|
2166
2179
|
}
|
|
2167
|
-
if (this.addToQueue(
|
|
2180
|
+
if (this.addToQueue(x), !T) {
|
|
2168
2181
|
this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
|
|
2169
2182
|
const v = this.get("sessionId");
|
|
2170
2183
|
v && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(v);
|
|
@@ -2211,11 +2224,11 @@ class Ts extends _ {
|
|
|
2211
2224
|
const e = this.get("sessionId");
|
|
2212
2225
|
e && this.saveSessionCounts(e), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
|
|
2213
2226
|
total: 0,
|
|
2214
|
-
[
|
|
2215
|
-
[
|
|
2216
|
-
[
|
|
2217
|
-
[
|
|
2218
|
-
[
|
|
2227
|
+
[u.CLICK]: 0,
|
|
2228
|
+
[u.PAGE_VIEW]: 0,
|
|
2229
|
+
[u.CUSTOM]: 0,
|
|
2230
|
+
[u.VIEWPORT_VISIBLE]: 0,
|
|
2231
|
+
[u.SCROLL]: 0
|
|
2219
2232
|
}, this.lastSessionId = null, this.set("hasStartSession", !1), this.dataSenders.forEach((t) => {
|
|
2220
2233
|
t.stop();
|
|
2221
2234
|
});
|
|
@@ -2492,10 +2505,10 @@ class Ts extends _ {
|
|
|
2492
2505
|
buildEventsPayload() {
|
|
2493
2506
|
const e = /* @__PURE__ */ new Map(), t = [];
|
|
2494
2507
|
for (const c of this.eventsQueue) {
|
|
2495
|
-
const
|
|
2496
|
-
e.has(
|
|
2508
|
+
const d = this.createEventSignature(c);
|
|
2509
|
+
e.has(d) || t.push(d), e.set(d, c);
|
|
2497
2510
|
}
|
|
2498
|
-
const s = t.map((c) => e.get(c)).filter((c) => !!c).sort((c,
|
|
2511
|
+
const s = t.map((c) => e.get(c)).filter((c) => !!c).sort((c, d) => c.type === u.SESSION_START && d.type !== u.SESSION_START ? -1 : d.type === u.SESSION_START && c.type !== u.SESSION_START ? 1 : c.timestamp - d.timestamp);
|
|
2499
2512
|
let n = {
|
|
2500
2513
|
user_id: this.get("userId"),
|
|
2501
2514
|
session_id: this.get("sessionId"),
|
|
@@ -2506,7 +2519,7 @@ class Ts extends _ {
|
|
|
2506
2519
|
};
|
|
2507
2520
|
const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
|
|
2508
2521
|
if (!o && l) {
|
|
2509
|
-
const c =
|
|
2522
|
+
const c = Et(n, l, "EventManager");
|
|
2510
2523
|
c !== null && (n = c);
|
|
2511
2524
|
}
|
|
2512
2525
|
return n;
|
|
@@ -2518,7 +2531,7 @@ class Ts extends _ {
|
|
|
2518
2531
|
});
|
|
2519
2532
|
const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
|
|
2520
2533
|
let l = {
|
|
2521
|
-
id:
|
|
2534
|
+
id: ye(),
|
|
2522
2535
|
type: e.type,
|
|
2523
2536
|
page_url: t,
|
|
2524
2537
|
timestamp: s,
|
|
@@ -2533,12 +2546,12 @@ class Ts extends _ {
|
|
|
2533
2546
|
...e.page_view && { page_view: e.page_view },
|
|
2534
2547
|
...o && { utm: o }
|
|
2535
2548
|
};
|
|
2536
|
-
const c = this.get("collectApiUrls"),
|
|
2537
|
-
if (S && (!
|
|
2538
|
-
const
|
|
2539
|
-
if (
|
|
2549
|
+
const c = this.get("collectApiUrls"), d = !!c?.custom, f = !!c?.saas, g = d || f, T = d && f, S = this.transformers.beforeSend;
|
|
2550
|
+
if (S && (!g || d && !T)) {
|
|
2551
|
+
const K = gt(l, S, "EventManager");
|
|
2552
|
+
if (K === null)
|
|
2540
2553
|
return null;
|
|
2541
|
-
l =
|
|
2554
|
+
l = K;
|
|
2542
2555
|
}
|
|
2543
2556
|
return l;
|
|
2544
2557
|
}
|
|
@@ -2576,13 +2589,13 @@ class Ts extends _ {
|
|
|
2576
2589
|
}
|
|
2577
2590
|
addToQueue(e) {
|
|
2578
2591
|
if (this.emitEvent(e), this.eventsQueue.push(e), this.eventsQueue.length > 100) {
|
|
2579
|
-
const t = this.eventsQueue.findIndex((n) => n.type !==
|
|
2592
|
+
const t = this.eventsQueue.findIndex((n) => n.type !== u.SESSION_START), s = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
|
|
2580
2593
|
a("warn", "Event queue overflow, oldest non-critical event removed", {
|
|
2581
2594
|
data: {
|
|
2582
2595
|
maxLength: 100,
|
|
2583
2596
|
currentLength: this.eventsQueue.length,
|
|
2584
2597
|
removedEventType: s?.type,
|
|
2585
|
-
wasCritical: s?.type ===
|
|
2598
|
+
wasCritical: s?.type === u.SESSION_START
|
|
2586
2599
|
}
|
|
2587
2600
|
});
|
|
2588
2601
|
}
|
|
@@ -2621,11 +2634,11 @@ class Ts extends _ {
|
|
|
2621
2634
|
}
|
|
2622
2635
|
getTypeLimitForEvent(e) {
|
|
2623
2636
|
return {
|
|
2624
|
-
[
|
|
2625
|
-
[
|
|
2626
|
-
[
|
|
2627
|
-
[
|
|
2628
|
-
[
|
|
2637
|
+
[u.CLICK]: 500,
|
|
2638
|
+
[u.PAGE_VIEW]: 100,
|
|
2639
|
+
[u.CUSTOM]: 500,
|
|
2640
|
+
[u.VIEWPORT_VISIBLE]: 200,
|
|
2641
|
+
[u.SCROLL]: 120
|
|
2629
2642
|
}[e] ?? null;
|
|
2630
2643
|
}
|
|
2631
2644
|
removeProcessedEvents(e) {
|
|
@@ -2633,10 +2646,10 @@ class Ts extends _ {
|
|
|
2633
2646
|
this.eventsQueue = this.eventsQueue.filter((s) => !t.has(s.id));
|
|
2634
2647
|
}
|
|
2635
2648
|
emitEvent(e) {
|
|
2636
|
-
this.emitter && this.emitter.emit(
|
|
2649
|
+
this.emitter && this.emitter.emit(se.EVENT, e);
|
|
2637
2650
|
}
|
|
2638
2651
|
emitEventsQueue(e) {
|
|
2639
|
-
this.emitter && this.emitter.emit(
|
|
2652
|
+
this.emitter && this.emitter.emit(se.QUEUE, e);
|
|
2640
2653
|
}
|
|
2641
2654
|
/**
|
|
2642
2655
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2679,11 +2692,11 @@ class Ts extends _ {
|
|
|
2679
2692
|
getInitialCounts() {
|
|
2680
2693
|
return {
|
|
2681
2694
|
total: 0,
|
|
2682
|
-
[
|
|
2683
|
-
[
|
|
2684
|
-
[
|
|
2685
|
-
[
|
|
2686
|
-
[
|
|
2695
|
+
[u.CLICK]: 0,
|
|
2696
|
+
[u.PAGE_VIEW]: 0,
|
|
2697
|
+
[u.CUSTOM]: 0,
|
|
2698
|
+
[u.VIEWPORT_VISIBLE]: 0,
|
|
2699
|
+
[u.SCROLL]: 0
|
|
2687
2700
|
};
|
|
2688
2701
|
}
|
|
2689
2702
|
/**
|
|
@@ -2712,21 +2725,21 @@ class Ts extends _ {
|
|
|
2712
2725
|
loadSessionCounts(e) {
|
|
2713
2726
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2714
2727
|
return this.getInitialCounts();
|
|
2715
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2728
|
+
const t = this.get("userId") || "anonymous", s = xe(t, e);
|
|
2716
2729
|
try {
|
|
2717
2730
|
const n = localStorage.getItem(s);
|
|
2718
2731
|
if (!n)
|
|
2719
2732
|
return this.getInitialCounts();
|
|
2720
2733
|
const i = JSON.parse(n);
|
|
2721
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2734
|
+
return i._timestamp && Date.now() - i._timestamp > $e ? (a("debug", "Session counts expired, clearing", {
|
|
2722
2735
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2723
|
-
}), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[
|
|
2736
|
+
}), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[u.CLICK] == "number" && typeof i[u.PAGE_VIEW] == "number" && typeof i[u.CUSTOM] == "number" && typeof i[u.VIEWPORT_VISIBLE] == "number" && typeof i[u.SCROLL] == "number" ? {
|
|
2724
2737
|
total: i.total,
|
|
2725
|
-
[
|
|
2726
|
-
[
|
|
2727
|
-
[
|
|
2728
|
-
[
|
|
2729
|
-
[
|
|
2738
|
+
[u.CLICK]: i[u.CLICK],
|
|
2739
|
+
[u.PAGE_VIEW]: i[u.PAGE_VIEW],
|
|
2740
|
+
[u.CUSTOM]: i[u.CUSTOM],
|
|
2741
|
+
[u.VIEWPORT_VISIBLE]: i[u.VIEWPORT_VISIBLE],
|
|
2742
|
+
[u.SCROLL]: i[u.SCROLL]
|
|
2730
2743
|
} : (a("warn", "Invalid session counts structure in localStorage, resetting", {
|
|
2731
2744
|
data: { sessionId: e, parsed: i }
|
|
2732
2745
|
}), localStorage.removeItem(s), a("debug", "Session counts removed due to invalid/corrupted data", {
|
|
@@ -2763,12 +2776,12 @@ class Ts extends _ {
|
|
|
2763
2776
|
cleanupExpiredSessionCounts() {
|
|
2764
2777
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2765
2778
|
try {
|
|
2766
|
-
const e = localStorage.getItem(
|
|
2779
|
+
const e = localStorage.getItem(Be);
|
|
2767
2780
|
if (e) {
|
|
2768
2781
|
const i = Date.now() - parseInt(e, 10);
|
|
2769
|
-
if (i <
|
|
2782
|
+
if (i < We) {
|
|
2770
2783
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2771
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2784
|
+
data: { timeSinceLastCleanup: i, throttleMs: We }
|
|
2772
2785
|
});
|
|
2773
2786
|
return;
|
|
2774
2787
|
}
|
|
@@ -2781,14 +2794,14 @@ class Ts extends _ {
|
|
|
2781
2794
|
const l = localStorage.getItem(o);
|
|
2782
2795
|
if (l) {
|
|
2783
2796
|
const c = JSON.parse(l);
|
|
2784
|
-
c._timestamp && Date.now() - c._timestamp >
|
|
2797
|
+
c._timestamp && Date.now() - c._timestamp > $e && n.push(o);
|
|
2785
2798
|
}
|
|
2786
2799
|
} catch {
|
|
2787
2800
|
}
|
|
2788
2801
|
}
|
|
2789
2802
|
n.forEach((i) => {
|
|
2790
2803
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2791
|
-
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(
|
|
2804
|
+
}), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem(Be, Date.now().toString());
|
|
2792
2805
|
} catch (e) {
|
|
2793
2806
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2794
2807
|
}
|
|
@@ -2822,7 +2835,7 @@ class Ts extends _ {
|
|
|
2822
2835
|
* @internal
|
|
2823
2836
|
*/
|
|
2824
2837
|
saveSessionCounts(e) {
|
|
2825
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2838
|
+
const t = this.get("userId") || "anonymous", s = xe(t, e);
|
|
2826
2839
|
try {
|
|
2827
2840
|
const n = {
|
|
2828
2841
|
...this.sessionEventCounts,
|
|
@@ -2890,7 +2903,7 @@ class _s extends _ {
|
|
|
2890
2903
|
return;
|
|
2891
2904
|
}
|
|
2892
2905
|
const e = this.getProjectId();
|
|
2893
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2906
|
+
this.broadcastChannel = new BroadcastChannel(Ot(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2894
2907
|
const { action: s, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
|
|
2895
2908
|
o === e && (s === "session_start" && n && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", n), this.persistSession(n, i), this.isTracking && this.setupSessionTimeout()) : s && s !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: s } }));
|
|
2896
2909
|
};
|
|
@@ -2955,7 +2968,7 @@ class _s extends _ {
|
|
|
2955
2968
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2956
2969
|
}
|
|
2957
2970
|
getSessionStorageKey() {
|
|
2958
|
-
return
|
|
2971
|
+
return Nt(this.getProjectId());
|
|
2959
2972
|
}
|
|
2960
2973
|
getProjectId() {
|
|
2961
2974
|
return this.projectId;
|
|
@@ -3039,7 +3052,7 @@ class _s extends _ {
|
|
|
3039
3052
|
}) : (a("debug", "Emitting SESSION_START event", {
|
|
3040
3053
|
data: { sessionId: t }
|
|
3041
3054
|
}), this.eventManager.track({
|
|
3042
|
-
type:
|
|
3055
|
+
type: u.SESSION_START
|
|
3043
3056
|
})), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
3044
3057
|
} catch (i) {
|
|
3045
3058
|
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
|
|
@@ -3078,7 +3091,7 @@ class _s extends _ {
|
|
|
3078
3091
|
a("debug", "Renewing session after timeout", {
|
|
3079
3092
|
data: { newSessionId: e }
|
|
3080
3093
|
}), this.set("sessionId", e), this.set("sessionReferrer", t), this.set("sessionUtm", s), this.persistSession(e, Date.now(), t, s), this.cleanupCrossTabSync(), this.initCrossTabSync(), this.shareSession(e), this.eventManager.track({
|
|
3081
|
-
type:
|
|
3094
|
+
type: u.SESSION_START
|
|
3082
3095
|
}), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
|
|
3083
3096
|
}
|
|
3084
3097
|
cleanupActivityListeners() {
|
|
@@ -3323,7 +3336,7 @@ class ws extends _ {
|
|
|
3323
3336
|
};
|
|
3324
3337
|
}
|
|
3325
3338
|
trackCurrentPage = () => {
|
|
3326
|
-
const e = window.location.href, t =
|
|
3339
|
+
const e = window.location.href, t = we(e, this.get("config").sensitiveQueryParams);
|
|
3327
3340
|
if (this.get("pageUrl") === t)
|
|
3328
3341
|
return;
|
|
3329
3342
|
const s = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -3334,16 +3347,16 @@ class ws extends _ {
|
|
|
3334
3347
|
this.set("pageUrl", t);
|
|
3335
3348
|
const o = this.extractPageViewData();
|
|
3336
3349
|
this.eventManager.track({
|
|
3337
|
-
type:
|
|
3350
|
+
type: u.PAGE_VIEW,
|
|
3338
3351
|
page_url: this.get("pageUrl"),
|
|
3339
3352
|
from_page_url: i,
|
|
3340
3353
|
...o && { page_view: o }
|
|
3341
3354
|
});
|
|
3342
3355
|
};
|
|
3343
3356
|
trackInitialPageView() {
|
|
3344
|
-
const e =
|
|
3357
|
+
const e = we(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
3345
3358
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
3346
|
-
type:
|
|
3359
|
+
type: u.PAGE_VIEW,
|
|
3347
3360
|
page_url: e,
|
|
3348
3361
|
...t && { page_view: t }
|
|
3349
3362
|
}), this.onTrack();
|
|
@@ -3394,22 +3407,22 @@ class bs extends _ {
|
|
|
3394
3407
|
return;
|
|
3395
3408
|
const o = this.findTrackingElement(n), l = this.getRelevantClickElement(n), c = this.calculateClickCoordinates(t, n);
|
|
3396
3409
|
if (o) {
|
|
3397
|
-
const
|
|
3398
|
-
if (
|
|
3399
|
-
const
|
|
3410
|
+
const f = this.extractTrackingData(o);
|
|
3411
|
+
if (f) {
|
|
3412
|
+
const g = this.createCustomEventData(f);
|
|
3400
3413
|
this.eventManager.track({
|
|
3401
|
-
type:
|
|
3414
|
+
type: u.CUSTOM,
|
|
3402
3415
|
custom_event: {
|
|
3403
|
-
name:
|
|
3404
|
-
...
|
|
3416
|
+
name: g.name,
|
|
3417
|
+
...g.value && { metadata: { value: g.value } }
|
|
3405
3418
|
}
|
|
3406
3419
|
});
|
|
3407
3420
|
}
|
|
3408
3421
|
}
|
|
3409
|
-
const
|
|
3422
|
+
const d = this.generateClickData(n, l, c);
|
|
3410
3423
|
this.eventManager.track({
|
|
3411
|
-
type:
|
|
3412
|
-
click_data:
|
|
3424
|
+
type: u.CLICK,
|
|
3425
|
+
click_data: d
|
|
3413
3426
|
});
|
|
3414
3427
|
}, window.addEventListener("click", this.clickHandler, !0));
|
|
3415
3428
|
}
|
|
@@ -3497,7 +3510,7 @@ class bs extends _ {
|
|
|
3497
3510
|
return e.hasAttribute(`${b}-name`) ? e : e.closest(`[${b}-name]`);
|
|
3498
3511
|
}
|
|
3499
3512
|
getRelevantClickElement(e) {
|
|
3500
|
-
for (const t of
|
|
3513
|
+
for (const t of At)
|
|
3501
3514
|
try {
|
|
3502
3515
|
if (e.matches(t))
|
|
3503
3516
|
return e;
|
|
@@ -3538,7 +3551,7 @@ class bs extends _ {
|
|
|
3538
3551
|
};
|
|
3539
3552
|
}
|
|
3540
3553
|
generateClickData(e, t, s) {
|
|
3541
|
-
const { x: n, y: i, relativeX: o, relativeY: l } = s, c = this.getRelevantText(e, t),
|
|
3554
|
+
const { x: n, y: i, relativeX: o, relativeY: l } = s, c = this.getRelevantText(e, t), d = this.extractElementAttributes(t);
|
|
3542
3555
|
return {
|
|
3543
3556
|
x: n,
|
|
3544
3557
|
y: i,
|
|
@@ -3548,12 +3561,12 @@ class bs extends _ {
|
|
|
3548
3561
|
...t.id && { id: t.id },
|
|
3549
3562
|
...t.className && { class: t.className },
|
|
3550
3563
|
...c && { text: c },
|
|
3551
|
-
...
|
|
3552
|
-
...
|
|
3553
|
-
...
|
|
3554
|
-
...
|
|
3555
|
-
...
|
|
3556
|
-
...Object.keys(
|
|
3564
|
+
...d.href && { href: d.href },
|
|
3565
|
+
...d.title && { title: d.title },
|
|
3566
|
+
...d.alt && { alt: d.alt },
|
|
3567
|
+
...d.role && { role: d.role },
|
|
3568
|
+
...d["aria-label"] && { ariaLabel: d["aria-label"] },
|
|
3569
|
+
...Object.keys(d).length > 0 && { dataAttributes: d }
|
|
3557
3570
|
};
|
|
3558
3571
|
}
|
|
3559
3572
|
/**
|
|
@@ -3577,7 +3590,7 @@ class bs extends _ {
|
|
|
3577
3590
|
*/
|
|
3578
3591
|
sanitizeText(e) {
|
|
3579
3592
|
let t = e;
|
|
3580
|
-
for (const s of
|
|
3593
|
+
for (const s of lt) {
|
|
3581
3594
|
const n = new RegExp(s.source, s.flags);
|
|
3582
3595
|
t = t.replace(n, "[REDACTED]");
|
|
3583
3596
|
}
|
|
@@ -3717,7 +3730,7 @@ class As extends _ {
|
|
|
3717
3730
|
return this.isWindowScrollable() ? e === window : this.containers.length === 0;
|
|
3718
3731
|
}
|
|
3719
3732
|
setupScrollContainer(e, t) {
|
|
3720
|
-
if (this.containers.some((
|
|
3733
|
+
if (this.containers.some((d) => d.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3721
3734
|
return;
|
|
3722
3735
|
const n = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3723
3736
|
n,
|
|
@@ -3729,7 +3742,7 @@ class As extends _ {
|
|
|
3729
3742
|
isPrimary: o,
|
|
3730
3743
|
lastScrollPos: n,
|
|
3731
3744
|
lastDepth: i,
|
|
3732
|
-
lastDirection:
|
|
3745
|
+
lastDirection: Z.DOWN,
|
|
3733
3746
|
lastEventTime: 0,
|
|
3734
3747
|
firstScrollEventTime: null,
|
|
3735
3748
|
maxDepthReached: i,
|
|
@@ -3737,10 +3750,10 @@ class As extends _ {
|
|
|
3737
3750
|
listener: null
|
|
3738
3751
|
}, c = () => {
|
|
3739
3752
|
this.get("suppressNextScroll") || (l.firstScrollEventTime === null && (l.firstScrollEventTime = Date.now()), this.clearContainerTimer(l), l.debounceTimer = window.setTimeout(() => {
|
|
3740
|
-
const
|
|
3741
|
-
if (
|
|
3742
|
-
const
|
|
3743
|
-
this.processScrollEvent(l,
|
|
3753
|
+
const d = this.calculateScrollData(l);
|
|
3754
|
+
if (d) {
|
|
3755
|
+
const f = Date.now();
|
|
3756
|
+
this.processScrollEvent(l, d, f);
|
|
3744
3757
|
}
|
|
3745
3758
|
l.debounceTimer = null;
|
|
3746
3759
|
}, 250));
|
|
@@ -3753,7 +3766,7 @@ class As extends _ {
|
|
|
3753
3766
|
e.lastEventTime = s, e.lastDepth = t.depth, e.lastDirection = t.direction;
|
|
3754
3767
|
const n = this.get("scrollEventCount") ?? 0;
|
|
3755
3768
|
this.set("scrollEventCount", n + 1), this.eventManager.track({
|
|
3756
|
-
type:
|
|
3769
|
+
type: u.SCROLL,
|
|
3757
3770
|
scroll_data: {
|
|
3758
3771
|
...t,
|
|
3759
3772
|
container_selector: e.selector,
|
|
@@ -3788,7 +3801,7 @@ class As extends _ {
|
|
|
3788
3801
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3789
3802
|
}
|
|
3790
3803
|
getScrollDirection(e, t) {
|
|
3791
|
-
return e > t ?
|
|
3804
|
+
return e > t ? Z.DOWN : Z.UP;
|
|
3792
3805
|
}
|
|
3793
3806
|
calculateScrollDepth(e, t, s) {
|
|
3794
3807
|
if (t <= s)
|
|
@@ -3800,13 +3813,13 @@ class As extends _ {
|
|
|
3800
3813
|
const { element: t, lastScrollPos: s, lastEventTime: n } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - s);
|
|
3801
3814
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
3802
3815
|
return null;
|
|
3803
|
-
const c = this.getViewportHeight(t),
|
|
3816
|
+
const c = this.getViewportHeight(t), d = this.getScrollHeight(t), f = this.getScrollDirection(i, s), g = this.calculateScrollDepth(i, d, c);
|
|
3804
3817
|
let T;
|
|
3805
3818
|
n > 0 ? T = o - n : e.firstScrollEventTime !== null ? T = o - e.firstScrollEventTime : T = 250;
|
|
3806
3819
|
const S = Math.round(l / T * 1e3);
|
|
3807
|
-
return
|
|
3808
|
-
depth:
|
|
3809
|
-
direction:
|
|
3820
|
+
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
3821
|
+
depth: g,
|
|
3822
|
+
direction: f,
|
|
3810
3823
|
velocity: S,
|
|
3811
3824
|
max_depth_reached: e.maxDepthReached
|
|
3812
3825
|
};
|
|
@@ -3965,7 +3978,7 @@ class Ls extends _ {
|
|
|
3965
3978
|
...e.name !== void 0 && { name: e.name }
|
|
3966
3979
|
};
|
|
3967
3980
|
this.eventManager.track({
|
|
3968
|
-
type:
|
|
3981
|
+
type: u.VIEWPORT_VISIBLE,
|
|
3969
3982
|
viewport_data: o
|
|
3970
3983
|
}), e.startTime = null, e.timeoutId = null, e.lastFiredTime = i;
|
|
3971
3984
|
}
|
|
@@ -4342,7 +4355,7 @@ class Ns extends _ {
|
|
|
4342
4355
|
navigationCounter = 0;
|
|
4343
4356
|
// Counter for handling simultaneous navigations edge case
|
|
4344
4357
|
constructor(e) {
|
|
4345
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4358
|
+
super(), this.eventManager = e, this.vitalThresholds = Ye(_e);
|
|
4346
4359
|
}
|
|
4347
4360
|
/**
|
|
4348
4361
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4360,7 +4373,7 @@ class Ns extends _ {
|
|
|
4360
4373
|
*/
|
|
4361
4374
|
async startTracking() {
|
|
4362
4375
|
const e = this.get("config"), t = e?.webVitalsMode ?? _e;
|
|
4363
|
-
this.vitalThresholds =
|
|
4376
|
+
this.vitalThresholds = Ye(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4364
4377
|
}
|
|
4365
4378
|
/**
|
|
4366
4379
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4431,8 +4444,8 @@ class Ns extends _ {
|
|
|
4431
4444
|
async initWebVitals() {
|
|
4432
4445
|
try {
|
|
4433
4446
|
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() => cr), o = (l) => (c) => {
|
|
4434
|
-
const
|
|
4435
|
-
this.sendVital({ type: l, value:
|
|
4447
|
+
const d = Number(c.value.toFixed(2));
|
|
4448
|
+
this.sendVital({ type: l, value: d });
|
|
4436
4449
|
};
|
|
4437
4450
|
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), s(o("FCP"), { reportAllChanges: !1 }), n(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
4438
4451
|
} catch (e) {
|
|
@@ -4457,7 +4470,7 @@ class Ns extends _ {
|
|
|
4457
4470
|
const t = e.getEntries();
|
|
4458
4471
|
for (const s of t) {
|
|
4459
4472
|
const n = Number(s.duration.toFixed(2)), i = Date.now();
|
|
4460
|
-
i - this.lastLongTaskSentAt >=
|
|
4473
|
+
i - this.lastLongTaskSentAt >= Yt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
|
|
4461
4474
|
}
|
|
4462
4475
|
},
|
|
4463
4476
|
{ type: "longtask", buffered: !0 }
|
|
@@ -4473,7 +4486,7 @@ class Ns extends _ {
|
|
|
4473
4486
|
return;
|
|
4474
4487
|
if (s)
|
|
4475
4488
|
s.add(e.type);
|
|
4476
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
4489
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > qt) {
|
|
4477
4490
|
const i = this.navigationHistory.shift();
|
|
4478
4491
|
i && this.reportedByNav.delete(i);
|
|
4479
4492
|
}
|
|
@@ -4486,7 +4499,7 @@ class Ns extends _ {
|
|
|
4486
4499
|
return;
|
|
4487
4500
|
}
|
|
4488
4501
|
this.eventManager.track({
|
|
4489
|
-
type:
|
|
4502
|
+
type: u.WEB_VITALS,
|
|
4490
4503
|
web_vitals: {
|
|
4491
4504
|
type: e,
|
|
4492
4505
|
value: t
|
|
@@ -4600,27 +4613,27 @@ class ae extends _ {
|
|
|
4600
4613
|
const e = Date.now();
|
|
4601
4614
|
if (e < this.burstBackoffUntil)
|
|
4602
4615
|
return !1;
|
|
4603
|
-
if (e - this.burstWindowStart >
|
|
4604
|
-
return this.burstBackoffUntil = e +
|
|
4616
|
+
if (e - this.burstWindowStart > jt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > zt)
|
|
4617
|
+
return this.burstBackoffUntil = e + Qe, a("debug", "Error burst detected - entering cooldown", {
|
|
4605
4618
|
data: {
|
|
4606
4619
|
errorsInWindow: this.errorBurstCounter,
|
|
4607
|
-
cooldownMs:
|
|
4620
|
+
cooldownMs: Qe
|
|
4608
4621
|
}
|
|
4609
4622
|
}), !1;
|
|
4610
|
-
const s = this.get("config").errorSampling ??
|
|
4623
|
+
const s = this.get("config").errorSampling ?? ct;
|
|
4611
4624
|
return Math.random() < s;
|
|
4612
4625
|
}
|
|
4613
4626
|
handleError = (e) => {
|
|
4614
4627
|
if (!this.shouldSample())
|
|
4615
4628
|
return;
|
|
4616
4629
|
const t = this.sanitize(e.message || "Unknown error");
|
|
4617
|
-
if (this.shouldSuppressError(
|
|
4630
|
+
if (this.shouldSuppressError(B.JS_ERROR, t))
|
|
4618
4631
|
return;
|
|
4619
4632
|
const s = typeof e.error?.stack == "string" ? this.truncateStack(e.error.stack) : void 0;
|
|
4620
4633
|
this.eventManager.track({
|
|
4621
|
-
type:
|
|
4634
|
+
type: u.ERROR,
|
|
4622
4635
|
error_data: {
|
|
4623
|
-
type:
|
|
4636
|
+
type: B.JS_ERROR,
|
|
4624
4637
|
message: t,
|
|
4625
4638
|
...e.filename !== "" && { filename: e.filename },
|
|
4626
4639
|
...e.lineno !== 0 && { line: e.lineno },
|
|
@@ -4633,13 +4646,13 @@ class ae extends _ {
|
|
|
4633
4646
|
if (!this.shouldSample())
|
|
4634
4647
|
return;
|
|
4635
4648
|
const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
|
|
4636
|
-
if (this.shouldSuppressError(
|
|
4649
|
+
if (this.shouldSuppressError(B.PROMISE_REJECTION, s))
|
|
4637
4650
|
return;
|
|
4638
4651
|
const n = e.reason instanceof Error && typeof e.reason.stack == "string" ? this.truncateStack(e.reason.stack) : void 0;
|
|
4639
4652
|
this.eventManager.track({
|
|
4640
|
-
type:
|
|
4653
|
+
type: u.ERROR,
|
|
4641
4654
|
error_data: {
|
|
4642
|
-
type:
|
|
4655
|
+
type: B.PROMISE_REJECTION,
|
|
4643
4656
|
message: s,
|
|
4644
4657
|
...n !== void 0 && { stack: n }
|
|
4645
4658
|
}
|
|
@@ -4659,12 +4672,12 @@ class ae extends _ {
|
|
|
4659
4672
|
}
|
|
4660
4673
|
}
|
|
4661
4674
|
sanitize(e) {
|
|
4662
|
-
const t = e.length >
|
|
4675
|
+
const t = e.length > Ge ? e.slice(0, Ge) + "..." : e;
|
|
4663
4676
|
return this.sanitizePii(t);
|
|
4664
4677
|
}
|
|
4665
4678
|
sanitizePii(e) {
|
|
4666
4679
|
let t = e;
|
|
4667
|
-
for (const s of
|
|
4680
|
+
for (const s of lt) {
|
|
4668
4681
|
const n = new RegExp(s.source, s.flags);
|
|
4669
4682
|
t = t.replace(n, "[REDACTED]");
|
|
4670
4683
|
}
|
|
@@ -4672,22 +4685,22 @@ class ae extends _ {
|
|
|
4672
4685
|
}
|
|
4673
4686
|
shouldSuppressError(e, t) {
|
|
4674
4687
|
const s = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
|
|
4675
|
-
return i !== void 0 && s - i <
|
|
4688
|
+
return i !== void 0 && s - i < ze ? (this.recentErrors.set(n, s), !0) : (this.recentErrors.set(n, s), this.recentErrors.size > Gt ? (this.recentErrors.clear(), this.recentErrors.set(n, s), !1) : (this.recentErrors.size > ee && this.pruneOldErrors(), !1));
|
|
4676
4689
|
}
|
|
4677
4690
|
static TRUNCATION_SUFFIX = `
|
|
4678
4691
|
...truncated`;
|
|
4679
4692
|
truncateStack(e) {
|
|
4680
|
-
if (e.length <=
|
|
4681
|
-
const t =
|
|
4693
|
+
if (e.length <= je) return this.sanitizePii(e);
|
|
4694
|
+
const t = je - ae.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ae.TRUNCATION_SUFFIX;
|
|
4682
4695
|
return this.sanitizePii(s);
|
|
4683
4696
|
}
|
|
4684
4697
|
pruneOldErrors() {
|
|
4685
4698
|
const e = Date.now();
|
|
4686
4699
|
for (const [n, i] of this.recentErrors.entries())
|
|
4687
|
-
e - i >
|
|
4688
|
-
if (this.recentErrors.size <=
|
|
4700
|
+
e - i > ze && this.recentErrors.delete(n);
|
|
4701
|
+
if (this.recentErrors.size <= ee)
|
|
4689
4702
|
return;
|
|
4690
|
-
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size -
|
|
4703
|
+
const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size - ee;
|
|
4691
4704
|
for (let n = 0; n < s; n += 1) {
|
|
4692
4705
|
const i = t[n];
|
|
4693
4706
|
i && this.recentErrors.delete(i[0]);
|
|
@@ -4759,7 +4772,7 @@ class Os extends _ {
|
|
|
4759
4772
|
return;
|
|
4760
4773
|
}
|
|
4761
4774
|
this.managers.event.track({
|
|
4762
|
-
type:
|
|
4775
|
+
type: u.CUSTOM,
|
|
4763
4776
|
custom_event: {
|
|
4764
4777
|
name: e,
|
|
4765
4778
|
...o && { metadata: o }
|
|
@@ -4825,10 +4838,10 @@ class Os extends _ {
|
|
|
4825
4838
|
this.set("userId", t);
|
|
4826
4839
|
const s = os(e);
|
|
4827
4840
|
this.set("collectApiUrls", s);
|
|
4828
|
-
const n =
|
|
4841
|
+
const n = Xt();
|
|
4829
4842
|
this.set("device", n);
|
|
4830
|
-
const i =
|
|
4831
|
-
this.set("pageUrl", i),
|
|
4843
|
+
const i = we(window.location.href, e.sensitiveQueryParams);
|
|
4844
|
+
this.set("pageUrl", i), ts() && this.set("mode", ie.QA);
|
|
4832
4845
|
}
|
|
4833
4846
|
/**
|
|
4834
4847
|
* Returns the current configuration object.
|
|
@@ -4879,7 +4892,7 @@ class Os extends _ {
|
|
|
4879
4892
|
valid: !1,
|
|
4880
4893
|
error: "Global metadata must be a plain object"
|
|
4881
4894
|
};
|
|
4882
|
-
const t =
|
|
4895
|
+
const t = mt("Global", e, "globalMetadata");
|
|
4883
4896
|
return t.valid ? { valid: !0 } : {
|
|
4884
4897
|
valid: !1,
|
|
4885
4898
|
error: t.error
|
|
@@ -4946,7 +4959,7 @@ class Os extends _ {
|
|
|
4946
4959
|
a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
|
|
4947
4960
|
return;
|
|
4948
4961
|
}
|
|
4949
|
-
const s = e.trim(), n =
|
|
4962
|
+
const s = e.trim(), n = ft(t), i = {
|
|
4950
4963
|
userId: s,
|
|
4951
4964
|
...n ? { traits: n } : {}
|
|
4952
4965
|
};
|
|
@@ -4993,10 +5006,10 @@ class Os extends _ {
|
|
|
4993
5006
|
loadPersistedIdentity() {
|
|
4994
5007
|
const e = this.managers.storage, t = this.getProjectId(), s = fe(t);
|
|
4995
5008
|
try {
|
|
4996
|
-
const n = e.getItem(
|
|
5009
|
+
const n = e.getItem(U);
|
|
4997
5010
|
if (n) {
|
|
4998
5011
|
const i = JSON.parse(n);
|
|
4999
|
-
if (e.removeItem(
|
|
5012
|
+
if (e.removeItem(U), !this.isValidIdentityData(i)) {
|
|
5000
5013
|
a("debug", "Invalid pending identity in localStorage, discarded");
|
|
5001
5014
|
return;
|
|
5002
5015
|
}
|
|
@@ -5005,7 +5018,7 @@ class Os extends _ {
|
|
|
5005
5018
|
return;
|
|
5006
5019
|
}
|
|
5007
5020
|
} catch {
|
|
5008
|
-
e.removeItem(
|
|
5021
|
+
e.removeItem(U);
|
|
5009
5022
|
}
|
|
5010
5023
|
try {
|
|
5011
5024
|
const n = e.getItem(s);
|
|
@@ -5043,7 +5056,7 @@ class Os extends _ {
|
|
|
5043
5056
|
clearPersistedIdentity() {
|
|
5044
5057
|
try {
|
|
5045
5058
|
const e = this.managers.storage, t = this.getProjectId();
|
|
5046
|
-
e.removeItem(fe(t)), e.removeItem(
|
|
5059
|
+
e.removeItem(fe(t)), e.removeItem(U);
|
|
5047
5060
|
} catch {
|
|
5048
5061
|
a("debug", "Failed to clear persisted identity");
|
|
5049
5062
|
}
|
|
@@ -5068,23 +5081,23 @@ class Os extends _ {
|
|
|
5068
5081
|
a("warn", "Failed to start performance tracking", { error: s });
|
|
5069
5082
|
}), this.handlers.error = new ae(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new Ls(this.managers.event), this.handlers.viewport.startTracking()), e.integrations?.tracelog?.shopify) {
|
|
5070
5083
|
const s = new Cs();
|
|
5071
|
-
s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(
|
|
5072
|
-
n.type ===
|
|
5084
|
+
s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(se.EVENT, (n) => {
|
|
5085
|
+
n.type === u.SESSION_START && s.onSessionChange();
|
|
5073
5086
|
});
|
|
5074
5087
|
}
|
|
5075
5088
|
}
|
|
5076
5089
|
}
|
|
5077
|
-
const
|
|
5078
|
-
let
|
|
5079
|
-
const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (p = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R &&
|
|
5090
|
+
const k = [], M = [];
|
|
5091
|
+
let D = null, h = null, R = !1, p = !1, P = null;
|
|
5092
|
+
const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (p = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R && P || (R = !0, P = (async () => {
|
|
5080
5093
|
try {
|
|
5081
|
-
const e =
|
|
5094
|
+
const e = us(r ?? {}), t = new Os();
|
|
5082
5095
|
try {
|
|
5083
|
-
|
|
5096
|
+
k.forEach(({ event: o, callback: l }) => {
|
|
5084
5097
|
t.on(o, l);
|
|
5085
|
-
}),
|
|
5098
|
+
}), k.length = 0, M.forEach(({ hook: o, fn: l }) => {
|
|
5086
5099
|
o === "beforeSend" ? t.setTransformer("beforeSend", l) : t.setTransformer("beforeBatch", l);
|
|
5087
|
-
}), M.length = 0,
|
|
5100
|
+
}), M.length = 0, D && (t.setCustomHeaders(D), D = null);
|
|
5088
5101
|
const s = t.init(e), n = new Promise((o, l) => {
|
|
5089
5102
|
setTimeout(() => {
|
|
5090
5103
|
l(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
@@ -5102,9 +5115,9 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5102
5115
|
} catch (e) {
|
|
5103
5116
|
throw h = null, e;
|
|
5104
5117
|
} finally {
|
|
5105
|
-
R = !1,
|
|
5118
|
+
R = !1, P = null;
|
|
5106
5119
|
}
|
|
5107
|
-
})()),
|
|
5120
|
+
})()), P)), Ds = (r, e) => {
|
|
5108
5121
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5109
5122
|
if (!h)
|
|
5110
5123
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5115,7 +5128,7 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5115
5128
|
}, ks = (r, e) => {
|
|
5116
5129
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5117
5130
|
if (!h || R) {
|
|
5118
|
-
|
|
5131
|
+
k.push({ event: r, callback: e });
|
|
5119
5132
|
return;
|
|
5120
5133
|
}
|
|
5121
5134
|
h.on(r, e);
|
|
@@ -5123,8 +5136,8 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
5123
5136
|
}, Vs = (r, e) => {
|
|
5124
5137
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5125
5138
|
if (!h) {
|
|
5126
|
-
const t =
|
|
5127
|
-
t !== -1 &&
|
|
5139
|
+
const t = k.findIndex((s) => s.event === r && s.callback === e);
|
|
5140
|
+
t !== -1 && k.splice(t, 1);
|
|
5128
5141
|
return;
|
|
5129
5142
|
}
|
|
5130
5143
|
h.off(r, e);
|
|
@@ -5160,7 +5173,7 @@ const Hs = (r) => {
|
|
|
5160
5173
|
if (typeof r != "function")
|
|
5161
5174
|
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof r}`);
|
|
5162
5175
|
if (!h || R) {
|
|
5163
|
-
|
|
5176
|
+
D = r;
|
|
5164
5177
|
return;
|
|
5165
5178
|
}
|
|
5166
5179
|
if (p)
|
|
@@ -5170,7 +5183,7 @@ const Hs = (r) => {
|
|
|
5170
5183
|
}, xs = () => {
|
|
5171
5184
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5172
5185
|
if (!h) {
|
|
5173
|
-
|
|
5186
|
+
D = null;
|
|
5174
5187
|
return;
|
|
5175
5188
|
}
|
|
5176
5189
|
if (p)
|
|
@@ -5187,13 +5200,13 @@ const Hs = (r) => {
|
|
|
5187
5200
|
}
|
|
5188
5201
|
p = !0;
|
|
5189
5202
|
try {
|
|
5190
|
-
h.destroy(), h = null, R = !1,
|
|
5203
|
+
h.destroy(), h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, p = !1;
|
|
5191
5204
|
} catch (r) {
|
|
5192
|
-
h = null, R = !1,
|
|
5205
|
+
h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, p = !1, a("warn", "Error during destroy, forced cleanup completed", { error: r });
|
|
5193
5206
|
}
|
|
5194
5207
|
}
|
|
5195
5208
|
}, Xs = (r) => {
|
|
5196
|
-
typeof window > "u" || typeof document > "u" ||
|
|
5209
|
+
typeof window > "u" || typeof document > "u" || ss(r);
|
|
5197
5210
|
}, Gs = (r) => {
|
|
5198
5211
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5199
5212
|
if (!h)
|
|
@@ -5229,11 +5242,11 @@ const Hs = (r) => {
|
|
|
5229
5242
|
return;
|
|
5230
5243
|
}
|
|
5231
5244
|
try {
|
|
5232
|
-
const t =
|
|
5245
|
+
const t = ft(e), s = {
|
|
5233
5246
|
userId: r.trim(),
|
|
5234
5247
|
...t ? { traits: t } : {}
|
|
5235
5248
|
};
|
|
5236
|
-
localStorage.setItem(
|
|
5249
|
+
localStorage.setItem(U, JSON.stringify(s)), a("debug", "Identity persisted pre-init (will be applied on init)");
|
|
5237
5250
|
} catch {
|
|
5238
5251
|
a("debug", "Failed to persist pre-init identity");
|
|
5239
5252
|
}
|
|
@@ -5242,7 +5255,7 @@ const Hs = (r) => {
|
|
|
5242
5255
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5243
5256
|
if (!h) {
|
|
5244
5257
|
try {
|
|
5245
|
-
localStorage.removeItem(
|
|
5258
|
+
localStorage.removeItem(U);
|
|
5246
5259
|
} catch {
|
|
5247
5260
|
}
|
|
5248
5261
|
return;
|
|
@@ -5269,20 +5282,20 @@ const Hs = (r) => {
|
|
|
5269
5282
|
identify: zs,
|
|
5270
5283
|
resetIdentity: Qs
|
|
5271
5284
|
};
|
|
5272
|
-
var
|
|
5285
|
+
var Le, C, G, St, le, pt = -1, V = function(r) {
|
|
5273
5286
|
addEventListener("pageshow", (function(e) {
|
|
5274
|
-
e.persisted && (
|
|
5287
|
+
e.persisted && (pt = e.timeStamp, r(e));
|
|
5275
5288
|
}), !0);
|
|
5276
|
-
},
|
|
5289
|
+
}, De = function() {
|
|
5277
5290
|
var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
5278
5291
|
if (r && r.responseStart > 0 && r.responseStart < performance.now()) return r;
|
|
5279
|
-
},
|
|
5280
|
-
var r =
|
|
5292
|
+
}, de = function() {
|
|
5293
|
+
var r = De();
|
|
5281
5294
|
return r && r.activationStart || 0;
|
|
5282
5295
|
}, y = function(r, e) {
|
|
5283
|
-
var t =
|
|
5284
|
-
return
|
|
5285
|
-
},
|
|
5296
|
+
var t = De(), s = "navigate";
|
|
5297
|
+
return pt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || de() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: r, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
|
|
5298
|
+
}, F = function(r, e, t) {
|
|
5286
5299
|
try {
|
|
5287
5300
|
if (PerformanceObserver.supportedEntryTypes.includes(r)) {
|
|
5288
5301
|
var s = new PerformanceObserver((function(n) {
|
|
@@ -5301,164 +5314,164 @@ var Ae, C, j, Et, le, St = -1, U = function(r) {
|
|
|
5301
5314
|
return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
|
|
5302
5315
|
})(e.value, t), r(e));
|
|
5303
5316
|
};
|
|
5304
|
-
},
|
|
5317
|
+
}, ke = function(r) {
|
|
5305
5318
|
requestAnimationFrame((function() {
|
|
5306
5319
|
return requestAnimationFrame((function() {
|
|
5307
5320
|
return r();
|
|
5308
5321
|
}));
|
|
5309
5322
|
}));
|
|
5310
|
-
},
|
|
5323
|
+
}, z = function(r) {
|
|
5311
5324
|
document.addEventListener("visibilitychange", (function() {
|
|
5312
5325
|
document.visibilityState === "hidden" && r();
|
|
5313
5326
|
}));
|
|
5314
|
-
},
|
|
5327
|
+
}, ue = function(r) {
|
|
5315
5328
|
var e = !1;
|
|
5316
5329
|
return function() {
|
|
5317
5330
|
e || (r(), e = !0);
|
|
5318
5331
|
};
|
|
5319
|
-
},
|
|
5332
|
+
}, H = -1, tt = function() {
|
|
5320
5333
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
5321
5334
|
}, ce = function(r) {
|
|
5322
|
-
document.visibilityState === "hidden" &&
|
|
5323
|
-
},
|
|
5335
|
+
document.visibilityState === "hidden" && H > -1 && (H = r.type === "visibilitychange" ? r.timeStamp : 0, Ks());
|
|
5336
|
+
}, st = function() {
|
|
5324
5337
|
addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
|
|
5325
5338
|
}, Ks = function() {
|
|
5326
5339
|
removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
|
|
5327
|
-
},
|
|
5328
|
-
return
|
|
5340
|
+
}, Ve = function() {
|
|
5341
|
+
return H < 0 && (H = tt(), st(), V((function() {
|
|
5329
5342
|
setTimeout((function() {
|
|
5330
|
-
|
|
5343
|
+
H = tt(), st();
|
|
5331
5344
|
}), 0);
|
|
5332
5345
|
}))), { get firstHiddenTime() {
|
|
5333
|
-
return
|
|
5346
|
+
return H;
|
|
5334
5347
|
} };
|
|
5335
|
-
},
|
|
5348
|
+
}, Q = function(r) {
|
|
5336
5349
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
5337
5350
|
return r();
|
|
5338
5351
|
}), !0) : r();
|
|
5339
|
-
},
|
|
5340
|
-
e = e || {},
|
|
5341
|
-
var t, s =
|
|
5352
|
+
}, Me = [1800, 3e3], Tt = function(r, e) {
|
|
5353
|
+
e = e || {}, Q((function() {
|
|
5354
|
+
var t, s = Ve(), n = y("FCP"), i = F("paint", (function(o) {
|
|
5342
5355
|
o.forEach((function(l) {
|
|
5343
|
-
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime -
|
|
5356
|
+
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime - de(), 0), n.entries.push(l), t(!0)));
|
|
5344
5357
|
}));
|
|
5345
5358
|
}));
|
|
5346
|
-
i && (t = w(r, n,
|
|
5347
|
-
n = y("FCP"), t = w(r, n,
|
|
5359
|
+
i && (t = w(r, n, Me, e.reportAllChanges), V((function(o) {
|
|
5360
|
+
n = y("FCP"), t = w(r, n, Me, e.reportAllChanges), ke((function() {
|
|
5348
5361
|
n.value = performance.now() - o.timeStamp, t(!0);
|
|
5349
5362
|
}));
|
|
5350
5363
|
})));
|
|
5351
5364
|
}));
|
|
5352
|
-
},
|
|
5353
|
-
e = e || {},
|
|
5365
|
+
}, Ce = [0.1, 0.25], Ys = function(r, e) {
|
|
5366
|
+
e = e || {}, Tt(ue((function() {
|
|
5354
5367
|
var t, s = y("CLS", 0), n = 0, i = [], o = function(c) {
|
|
5355
|
-
c.forEach((function(
|
|
5356
|
-
if (!
|
|
5357
|
-
var
|
|
5358
|
-
n &&
|
|
5368
|
+
c.forEach((function(d) {
|
|
5369
|
+
if (!d.hadRecentInput) {
|
|
5370
|
+
var f = i[0], g = i[i.length - 1];
|
|
5371
|
+
n && d.startTime - g.startTime < 1e3 && d.startTime - f.startTime < 5e3 ? (n += d.value, i.push(d)) : (n = d.value, i = [d]);
|
|
5359
5372
|
}
|
|
5360
5373
|
})), n > s.value && (s.value = n, s.entries = i, t());
|
|
5361
|
-
}, l =
|
|
5362
|
-
l && (t = w(r, s,
|
|
5374
|
+
}, l = F("layout-shift", o);
|
|
5375
|
+
l && (t = w(r, s, Ce, e.reportAllChanges), z((function() {
|
|
5363
5376
|
o(l.takeRecords()), t(!0);
|
|
5364
|
-
})),
|
|
5365
|
-
n = 0, s = y("CLS", 0), t = w(r, s,
|
|
5377
|
+
})), V((function() {
|
|
5378
|
+
n = 0, s = y("CLS", 0), t = w(r, s, Ce, e.reportAllChanges), ke((function() {
|
|
5366
5379
|
return t();
|
|
5367
5380
|
}));
|
|
5368
5381
|
})), setTimeout(t, 0));
|
|
5369
5382
|
})));
|
|
5370
|
-
},
|
|
5383
|
+
}, It = 0, Se = 1 / 0, J = 0, qs = function(r) {
|
|
5371
5384
|
r.forEach((function(e) {
|
|
5372
|
-
e.interactionId && (Se = Math.min(Se, e.interactionId),
|
|
5385
|
+
e.interactionId && (Se = Math.min(Se, e.interactionId), J = Math.max(J, e.interactionId), It = J ? (J - Se) / 7 + 1 : 0);
|
|
5373
5386
|
}));
|
|
5374
|
-
},
|
|
5375
|
-
return
|
|
5387
|
+
}, vt = function() {
|
|
5388
|
+
return Le ? It : performance.interactionCount || 0;
|
|
5376
5389
|
}, Js = function() {
|
|
5377
|
-
"interactionCount" in performance ||
|
|
5378
|
-
}, A = [],
|
|
5379
|
-
var r = Math.min(A.length - 1, Math.floor((
|
|
5390
|
+
"interactionCount" in performance || Le || (Le = F("event", qs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5391
|
+
}, A = [], te = /* @__PURE__ */ new Map(), _t = 0, Zs = function() {
|
|
5392
|
+
var r = Math.min(A.length - 1, Math.floor((vt() - _t) / 50));
|
|
5380
5393
|
return A[r];
|
|
5381
5394
|
}, er = [], tr = function(r) {
|
|
5382
5395
|
if (er.forEach((function(n) {
|
|
5383
5396
|
return n(r);
|
|
5384
5397
|
})), r.interactionId || r.entryType === "first-input") {
|
|
5385
|
-
var e = A[A.length - 1], t =
|
|
5398
|
+
var e = A[A.length - 1], t = te.get(r.interactionId);
|
|
5386
5399
|
if (t || A.length < 10 || r.duration > e.latency) {
|
|
5387
5400
|
if (t) r.duration > t.latency ? (t.entries = [r], t.latency = r.duration) : r.duration === t.latency && r.startTime === t.entries[0].startTime && t.entries.push(r);
|
|
5388
5401
|
else {
|
|
5389
5402
|
var s = { id: r.interactionId, latency: r.duration, entries: [r] };
|
|
5390
|
-
|
|
5403
|
+
te.set(s.id, s), A.push(s);
|
|
5391
5404
|
}
|
|
5392
5405
|
A.sort((function(n, i) {
|
|
5393
5406
|
return i.latency - n.latency;
|
|
5394
5407
|
})), A.length > 10 && A.splice(10).forEach((function(n) {
|
|
5395
|
-
return
|
|
5408
|
+
return te.delete(n.id);
|
|
5396
5409
|
}));
|
|
5397
5410
|
}
|
|
5398
5411
|
}
|
|
5399
|
-
},
|
|
5412
|
+
}, yt = function(r) {
|
|
5400
5413
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5401
|
-
return r =
|
|
5402
|
-
},
|
|
5403
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
5414
|
+
return r = ue(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
|
|
5415
|
+
}, Re = [200, 500], sr = function(r, e) {
|
|
5416
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Q((function() {
|
|
5404
5417
|
var t;
|
|
5405
5418
|
Js();
|
|
5406
5419
|
var s, n = y("INP"), i = function(l) {
|
|
5407
|
-
|
|
5420
|
+
yt((function() {
|
|
5408
5421
|
l.forEach(tr);
|
|
5409
5422
|
var c = Zs();
|
|
5410
5423
|
c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, s());
|
|
5411
5424
|
}));
|
|
5412
|
-
}, o =
|
|
5413
|
-
s = w(r, n,
|
|
5425
|
+
}, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5426
|
+
s = w(r, n, Re, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), z((function() {
|
|
5414
5427
|
i(o.takeRecords()), s(!0);
|
|
5415
|
-
})),
|
|
5416
|
-
|
|
5428
|
+
})), V((function() {
|
|
5429
|
+
_t = vt(), A.length = 0, te.clear(), n = y("INP"), s = w(r, n, Re, e.reportAllChanges);
|
|
5417
5430
|
})));
|
|
5418
5431
|
})));
|
|
5419
|
-
},
|
|
5420
|
-
e = e || {},
|
|
5421
|
-
var t, s =
|
|
5422
|
-
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(
|
|
5423
|
-
|
|
5432
|
+
}, Ne = [2500, 4e3], pe = {}, rr = function(r, e) {
|
|
5433
|
+
e = e || {}, Q((function() {
|
|
5434
|
+
var t, s = Ve(), n = y("LCP"), i = function(c) {
|
|
5435
|
+
e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
|
|
5436
|
+
d.startTime < s.firstHiddenTime && (n.value = Math.max(d.startTime - de(), 0), n.entries = [d], t());
|
|
5424
5437
|
}));
|
|
5425
|
-
}, o =
|
|
5438
|
+
}, o = F("largest-contentful-paint", i);
|
|
5426
5439
|
if (o) {
|
|
5427
|
-
t = w(r, n,
|
|
5428
|
-
var l =
|
|
5440
|
+
t = w(r, n, Ne, e.reportAllChanges);
|
|
5441
|
+
var l = ue((function() {
|
|
5429
5442
|
pe[n.id] || (i(o.takeRecords()), o.disconnect(), pe[n.id] = !0, t(!0));
|
|
5430
5443
|
}));
|
|
5431
5444
|
["keydown", "click"].forEach((function(c) {
|
|
5432
5445
|
addEventListener(c, (function() {
|
|
5433
|
-
return
|
|
5446
|
+
return yt(l);
|
|
5434
5447
|
}), { once: !0, capture: !0 });
|
|
5435
|
-
})),
|
|
5436
|
-
n = y("LCP"), t = w(r, n,
|
|
5448
|
+
})), z(l), V((function(c) {
|
|
5449
|
+
n = y("LCP"), t = w(r, n, Ne, e.reportAllChanges), ke((function() {
|
|
5437
5450
|
n.value = performance.now() - c.timeStamp, pe[n.id] = !0, t(!0);
|
|
5438
5451
|
}));
|
|
5439
5452
|
}));
|
|
5440
5453
|
}
|
|
5441
5454
|
}));
|
|
5442
|
-
},
|
|
5443
|
-
document.prerendering ?
|
|
5455
|
+
}, Oe = [800, 1800], nr = function r(e) {
|
|
5456
|
+
document.prerendering ? Q((function() {
|
|
5444
5457
|
return r(e);
|
|
5445
5458
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5446
5459
|
return r(e);
|
|
5447
5460
|
}), !0) : setTimeout(e, 0);
|
|
5448
5461
|
}, ir = function(r, e) {
|
|
5449
5462
|
e = e || {};
|
|
5450
|
-
var t = y("TTFB"), s = w(r, t,
|
|
5463
|
+
var t = y("TTFB"), s = w(r, t, Oe, e.reportAllChanges);
|
|
5451
5464
|
nr((function() {
|
|
5452
|
-
var n =
|
|
5453
|
-
n && (t.value = Math.max(n.responseStart -
|
|
5454
|
-
t = y("TTFB", 0), (s = w(r, t,
|
|
5465
|
+
var n = De();
|
|
5466
|
+
n && (t.value = Math.max(n.responseStart - de(), 0), t.entries = [n], s(!0), V((function() {
|
|
5467
|
+
t = y("TTFB", 0), (s = w(r, t, Oe, e.reportAllChanges))(!0);
|
|
5455
5468
|
})));
|
|
5456
5469
|
}));
|
|
5457
|
-
},
|
|
5458
|
-
C || (C = e,
|
|
5459
|
-
},
|
|
5460
|
-
if (
|
|
5461
|
-
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp +
|
|
5470
|
+
}, W = { passive: !0, capture: !0 }, or = /* @__PURE__ */ new Date(), rt = function(r, e) {
|
|
5471
|
+
C || (C = e, G = r, St = /* @__PURE__ */ new Date(), bt(removeEventListener), wt());
|
|
5472
|
+
}, wt = function() {
|
|
5473
|
+
if (G >= 0 && G < St - or) {
|
|
5474
|
+
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + G };
|
|
5462
5475
|
le.forEach((function(e) {
|
|
5463
5476
|
e(r);
|
|
5464
5477
|
})), le = [];
|
|
@@ -5468,81 +5481,81 @@ var Ae, C, j, Et, le, St = -1, U = function(r) {
|
|
|
5468
5481
|
var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
|
|
5469
5482
|
r.type == "pointerdown" ? (function(t, s) {
|
|
5470
5483
|
var n = function() {
|
|
5471
|
-
|
|
5484
|
+
rt(t, s), o();
|
|
5472
5485
|
}, i = function() {
|
|
5473
5486
|
o();
|
|
5474
5487
|
}, o = function() {
|
|
5475
|
-
removeEventListener("pointerup", n,
|
|
5488
|
+
removeEventListener("pointerup", n, W), removeEventListener("pointercancel", i, W);
|
|
5476
5489
|
};
|
|
5477
|
-
addEventListener("pointerup", n,
|
|
5478
|
-
})(e, r) :
|
|
5490
|
+
addEventListener("pointerup", n, W), addEventListener("pointercancel", i, W);
|
|
5491
|
+
})(e, r) : rt(e, r);
|
|
5479
5492
|
}
|
|
5480
|
-
},
|
|
5493
|
+
}, bt = function(r) {
|
|
5481
5494
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5482
|
-
return r(e, ar,
|
|
5495
|
+
return r(e, ar, W);
|
|
5483
5496
|
}));
|
|
5484
|
-
},
|
|
5485
|
-
e = e || {},
|
|
5486
|
-
var t, s =
|
|
5497
|
+
}, Pe = [100, 300], lr = function(r, e) {
|
|
5498
|
+
e = e || {}, Q((function() {
|
|
5499
|
+
var t, s = Ve(), n = y("FID"), i = function(c) {
|
|
5487
5500
|
c.startTime < s.firstHiddenTime && (n.value = c.processingStart - c.startTime, n.entries.push(c), t(!0));
|
|
5488
5501
|
}, o = function(c) {
|
|
5489
5502
|
c.forEach(i);
|
|
5490
|
-
}, l =
|
|
5491
|
-
t = w(r, n,
|
|
5503
|
+
}, l = F("first-input", o);
|
|
5504
|
+
t = w(r, n, Pe, e.reportAllChanges), l && (z(ue((function() {
|
|
5492
5505
|
o(l.takeRecords()), l.disconnect();
|
|
5493
|
-
}))),
|
|
5506
|
+
}))), V((function() {
|
|
5494
5507
|
var c;
|
|
5495
|
-
n = y("FID"), t = w(r, n,
|
|
5508
|
+
n = y("FID"), t = w(r, n, Pe, e.reportAllChanges), le = [], G = -1, C = null, bt(addEventListener), c = i, le.push(c), wt();
|
|
5496
5509
|
})));
|
|
5497
5510
|
}));
|
|
5498
5511
|
};
|
|
5499
5512
|
const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5500
5513
|
__proto__: null,
|
|
5501
|
-
CLSThresholds:
|
|
5502
|
-
FCPThresholds:
|
|
5503
|
-
FIDThresholds:
|
|
5504
|
-
INPThresholds:
|
|
5505
|
-
LCPThresholds:
|
|
5506
|
-
TTFBThresholds:
|
|
5514
|
+
CLSThresholds: Ce,
|
|
5515
|
+
FCPThresholds: Me,
|
|
5516
|
+
FIDThresholds: Pe,
|
|
5517
|
+
INPThresholds: Re,
|
|
5518
|
+
LCPThresholds: Ne,
|
|
5519
|
+
TTFBThresholds: Oe,
|
|
5507
5520
|
onCLS: Ys,
|
|
5508
|
-
onFCP:
|
|
5521
|
+
onFCP: Tt,
|
|
5509
5522
|
onFID: lr,
|
|
5510
5523
|
onINP: sr,
|
|
5511
5524
|
onLCP: rr,
|
|
5512
5525
|
onTTFB: ir
|
|
5513
5526
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5514
5527
|
export {
|
|
5515
|
-
|
|
5516
|
-
|
|
5528
|
+
m as AppConfigValidationError,
|
|
5529
|
+
dr as DEFAULT_SESSION_TIMEOUT,
|
|
5517
5530
|
_e as DEFAULT_WEB_VITALS_MODE,
|
|
5518
5531
|
L as DeviceType,
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5532
|
+
se as EmitterEvent,
|
|
5533
|
+
B as ErrorType,
|
|
5534
|
+
u as EventType,
|
|
5522
5535
|
vr as InitializationTimeoutError,
|
|
5523
5536
|
N as IntegrationValidationError,
|
|
5524
5537
|
pr as MAX_ARRAY_LENGTH,
|
|
5525
5538
|
mr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5526
5539
|
fr as MAX_CUSTOM_EVENT_KEYS,
|
|
5527
|
-
|
|
5540
|
+
ur as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5528
5541
|
hr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5529
5542
|
gr as MAX_NESTED_OBJECT_KEYS,
|
|
5530
5543
|
Er as MAX_STRING_LENGTH,
|
|
5531
5544
|
Sr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5532
5545
|
ie as Mode,
|
|
5533
|
-
|
|
5546
|
+
lt as PII_PATTERNS,
|
|
5534
5547
|
O as PermanentError,
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5548
|
+
re as RateLimitError,
|
|
5549
|
+
Xe as SamplingRateValidationError,
|
|
5550
|
+
Z as ScrollDirection,
|
|
5551
|
+
Pt as SessionTimeoutValidationError,
|
|
5552
|
+
$ as SpecialApiUrl,
|
|
5553
|
+
ne as TimeoutError,
|
|
5554
|
+
j as TraceLogValidationError,
|
|
5542
5555
|
_r as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5556
|
+
Ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5557
|
+
Kt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5558
|
+
Ye as getWebVitalsThresholds,
|
|
5546
5559
|
Tr as isPrimaryScrollEvent,
|
|
5547
5560
|
Ir as isSecondaryScrollEvent,
|
|
5548
5561
|
yr as tracelog
|