@tracelog/lib 3.0.0 → 3.1.0-rc.116.2
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 +559 -484
- 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 +21 -1
- package/dist/public-api.d.ts +21 -1
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
const fn = 9e5;
|
|
2
|
+
const gn = 120, mn = 49152, pn = 100, Sn = 500, En = 200;
|
|
3
|
+
const vn = 1e3, Tn = 500, _n = 1e3;
|
|
4
|
+
const L = "data-tlog", vt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
7
7
|
'input[type="button"]',
|
|
@@ -33,7 +33,7 @@ const b = "data-tlog", pt = [
|
|
|
33
33
|
".menu-item",
|
|
34
34
|
"[data-testid]",
|
|
35
35
|
'[tabindex="0"]'
|
|
36
|
-
],
|
|
36
|
+
], Tt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], _t = [
|
|
37
37
|
"token",
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
@@ -60,15 +60,15 @@ const y = {
|
|
|
60
60
|
INVALID_CLICK_THROTTLE: "Click throttle must be a non-negative number",
|
|
61
61
|
INVALID_MAX_SAME_EVENT_PER_MINUTE: "Max same event per minute must be a positive number",
|
|
62
62
|
INVALID_SEND_INTERVAL: "Send interval must be between 1000ms (1 second) and 60000ms (60 seconds)"
|
|
63
|
-
},
|
|
63
|
+
}, yt = [
|
|
64
64
|
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
65
65
|
/javascript:/gi,
|
|
66
66
|
/on\w+\s*=/gi,
|
|
67
67
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
68
68
|
/<embed\b[^>]*>/gi,
|
|
69
69
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
70
|
-
], g = "tlog", z = `${g}:qa_mode`,
|
|
71
|
-
var F = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(F || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}),
|
|
70
|
+
], g = "tlog", z = `${g}:qa_mode`, Se = `${g}:uid`, nt = "tlog_mode", Ue = "qa", Fe = "qa_off", ce = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, le = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n) => n ? `${g}:${n}:session` : `${g}:session`, wt = (n) => n ? `${g}:${n}:broadcast` : `${g}:broadcast`, Ve = (n, e) => `${g}:${n}:session_counts:${e}`, He = 10080 * 60 * 1e3, xe = `${g}:session_counts_last_cleanup`, $e = 3600 * 1e3, ue = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, O = `${g}:pending_identity`;
|
|
71
|
+
var F = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(F || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), D = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(D || {});
|
|
72
72
|
class M extends Error {
|
|
73
73
|
constructor(e, t, s) {
|
|
74
74
|
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, M);
|
|
@@ -86,7 +86,7 @@ class Z extends Error {
|
|
|
86
86
|
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, Z);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}),
|
|
89
|
+
var d = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(d || {}), Ee = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(Ee || {}), V = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(V || {}), ee = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(ee || {});
|
|
90
90
|
class $ extends Error {
|
|
91
91
|
constructor(e, t, s) {
|
|
92
92
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -99,28 +99,34 @@ class m extends $ {
|
|
|
99
99
|
super(e, "APP_CONFIG_INVALID", t);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
class
|
|
102
|
+
class At extends $ {
|
|
103
103
|
constructor(e, t = "config") {
|
|
104
104
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
class
|
|
107
|
+
class Be extends $ {
|
|
108
108
|
constructor(e, t = "config") {
|
|
109
109
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
class
|
|
112
|
+
class Xe extends $ {
|
|
113
113
|
constructor(e, t = "config") {
|
|
114
114
|
super(e, "INTEGRATION_INVALID", t);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
class
|
|
117
|
+
class yn extends $ {
|
|
118
118
|
constructor(e, t, s = "runtime") {
|
|
119
119
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
120
120
|
}
|
|
121
121
|
timeoutMs;
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
124
|
+
const n = new URLSearchParams(window.location.search), e = {};
|
|
125
|
+
return Lt.forEach((s) => {
|
|
126
|
+
const r = n.get(s);
|
|
127
|
+
r && (e[s] = r);
|
|
128
|
+
}), Object.keys(e).length ? e : void 0;
|
|
129
|
+
}, bt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Mt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ct = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = (n, e) => {
|
|
124
130
|
if (e) {
|
|
125
131
|
if (e instanceof Error) {
|
|
126
132
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -139,7 +145,7 @@ const It = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
139
145
|
return `[TraceLog] ${n}: ${String(e)}`;
|
|
140
146
|
}
|
|
141
147
|
return `[TraceLog] ${n}`;
|
|
142
|
-
},
|
|
148
|
+
}, Nt = () => {
|
|
143
149
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
144
150
|
return !1;
|
|
145
151
|
try {
|
|
@@ -148,15 +154,15 @@ const It = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
148
154
|
return !1;
|
|
149
155
|
}
|
|
150
156
|
}, a = (n, e, t) => {
|
|
151
|
-
const { error: s, data: r, showToClient: i = !1, style: o, visibility:
|
|
152
|
-
if (!
|
|
157
|
+
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Rt(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
158
|
+
if (!Ot(c, i))
|
|
153
159
|
return;
|
|
154
|
-
const p =
|
|
155
|
-
|
|
156
|
-
},
|
|
160
|
+
const p = Pt(c, o), S = r !== void 0 ? ve(r) : void 0;
|
|
161
|
+
kt(u, l, p, S);
|
|
162
|
+
}, Ot = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Nt() : !1, Pt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Ct : "", kt = (n, e, t, s) => {
|
|
157
163
|
const r = t !== void 0 && t !== "", i = r ? `%c${e}` : e;
|
|
158
164
|
s !== void 0 ? r ? console[n](i, t, s) : console[n](i, s) : r ? console[n](i, t) : console[n](i);
|
|
159
|
-
},
|
|
165
|
+
}, ve = (n) => {
|
|
160
166
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
161
167
|
for (const [s, r] of Object.entries(n)) {
|
|
162
168
|
const i = s.toLowerCase();
|
|
@@ -164,16 +170,16 @@ const It = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
164
170
|
e[s] = "[REDACTED]";
|
|
165
171
|
continue;
|
|
166
172
|
}
|
|
167
|
-
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] =
|
|
168
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
173
|
+
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] = ve(r) : Array.isArray(r) ? e[s] = r.map(
|
|
174
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ve(o) : o
|
|
169
175
|
) : e[s] = r;
|
|
170
176
|
}
|
|
171
177
|
return e;
|
|
172
178
|
};
|
|
173
|
-
let
|
|
174
|
-
const
|
|
175
|
-
typeof window < "u" && !
|
|
176
|
-
}, te = "Unknown",
|
|
179
|
+
let Te, rt;
|
|
180
|
+
const Dt = () => {
|
|
181
|
+
typeof window < "u" && !Te && (Te = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
|
|
182
|
+
}, te = "Unknown", Ut = (n) => {
|
|
177
183
|
const e = n.userAgentData?.platform;
|
|
178
184
|
if (e != null && e !== "") {
|
|
179
185
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -185,7 +191,7 @@ const Nt = () => {
|
|
|
185
191
|
}
|
|
186
192
|
const t = navigator.userAgent;
|
|
187
193
|
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" : te;
|
|
188
|
-
},
|
|
194
|
+
}, Ft = (n) => {
|
|
189
195
|
const e = n.userAgentData?.brands;
|
|
190
196
|
if (e != null && e.length > 0) {
|
|
191
197
|
const r = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -196,26 +202,26 @@ const Nt = () => {
|
|
|
196
202
|
}
|
|
197
203
|
const t = navigator.userAgent;
|
|
198
204
|
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" : te;
|
|
199
|
-
},
|
|
205
|
+
}, Vt = () => {
|
|
200
206
|
try {
|
|
201
207
|
const n = navigator;
|
|
202
208
|
if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
|
|
203
|
-
const
|
|
204
|
-
return
|
|
209
|
+
const l = n.userAgentData.platform;
|
|
210
|
+
return l != null && l !== "" && /ipad|tablet/i.test(l) ? w.Tablet : n.userAgentData.mobile ? w.Mobile : w.Desktop;
|
|
205
211
|
}
|
|
206
|
-
|
|
207
|
-
const e = window.innerWidth, t =
|
|
208
|
-
return e <= 767 || o && r ? w.Mobile : e >= 768 && e <= 1024 ||
|
|
212
|
+
Dt();
|
|
213
|
+
const e = window.innerWidth, t = Te?.matches ?? !1, s = rt?.matches ?? !1, r = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), c = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
214
|
+
return e <= 767 || o && r ? w.Mobile : e >= 768 && e <= 1024 || c || t && s && r ? w.Tablet : w.Desktop;
|
|
209
215
|
} catch (n) {
|
|
210
216
|
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), w.Desktop;
|
|
211
217
|
}
|
|
212
|
-
},
|
|
218
|
+
}, Ht = () => {
|
|
213
219
|
try {
|
|
214
220
|
const n = navigator;
|
|
215
221
|
return {
|
|
216
|
-
type:
|
|
217
|
-
os:
|
|
218
|
-
browser:
|
|
222
|
+
type: Vt(),
|
|
223
|
+
os: Ut(n),
|
|
224
|
+
browser: Ft(n)
|
|
219
225
|
};
|
|
220
226
|
} catch (n) {
|
|
221
227
|
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
@@ -224,60 +230,60 @@ const Nt = () => {
|
|
|
224
230
|
browser: te
|
|
225
231
|
};
|
|
226
232
|
}
|
|
227
|
-
},
|
|
233
|
+
}, Ge = 500, We = 2e3, je = 5e3, Q = 50, xt = Q * 2, it = 1, $t = 1e3, Bt = 10, Ke = 5e3, Xt = 3, Gt = 200, Wt = 6e4, jt = 64, In = {
|
|
228
234
|
LCP: 2500,
|
|
229
235
|
FCP: 1800,
|
|
230
236
|
CLS: 0.1,
|
|
231
237
|
INP: 200,
|
|
232
238
|
TTFB: 800
|
|
233
|
-
},
|
|
239
|
+
}, ze = {
|
|
234
240
|
LCP: 2500,
|
|
235
241
|
FCP: 1800,
|
|
236
242
|
CLS: 0.1,
|
|
237
243
|
INP: 200,
|
|
238
244
|
TTFB: 800
|
|
239
|
-
},
|
|
245
|
+
}, Kt = {
|
|
240
246
|
LCP: 4e3,
|
|
241
247
|
FCP: 3e3,
|
|
242
248
|
CLS: 0.25,
|
|
243
249
|
INP: 500,
|
|
244
250
|
TTFB: 1800
|
|
245
|
-
},
|
|
251
|
+
}, _e = "needs-improvement", Qe = (n = _e) => {
|
|
246
252
|
switch (n) {
|
|
247
253
|
case "all":
|
|
248
254
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0 };
|
|
249
255
|
case "needs-improvement":
|
|
250
|
-
return
|
|
256
|
+
return ze;
|
|
251
257
|
case "poor":
|
|
252
|
-
return
|
|
258
|
+
return Kt;
|
|
253
259
|
default:
|
|
254
|
-
return
|
|
260
|
+
return ze;
|
|
255
261
|
}
|
|
256
|
-
},
|
|
262
|
+
}, zt = 50, Qt = "3.1.0", Yt = Qt, qt = () => typeof window < "u" && typeof sessionStorage < "u", Jt = () => {
|
|
257
263
|
try {
|
|
258
264
|
const n = new URLSearchParams(window.location.search);
|
|
259
|
-
n.delete(
|
|
265
|
+
n.delete(nt);
|
|
260
266
|
const e = n.toString(), t = window.location.pathname + (e ? "?" + e : "") + window.location.hash;
|
|
261
267
|
window.history.replaceState({}, "", t);
|
|
262
268
|
} catch {
|
|
263
269
|
}
|
|
264
|
-
},
|
|
265
|
-
if (!
|
|
270
|
+
}, Zt = () => {
|
|
271
|
+
if (!qt())
|
|
266
272
|
return !1;
|
|
267
273
|
try {
|
|
268
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
274
|
+
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(z);
|
|
269
275
|
let s = null;
|
|
270
|
-
return e ===
|
|
276
|
+
return e === Ue ? (s = !0, sessionStorage.setItem(z, "true"), a("info", "QA Mode ACTIVE", {
|
|
271
277
|
visibility: "qa",
|
|
272
|
-
style:
|
|
273
|
-
})) : e ===
|
|
278
|
+
style: bt
|
|
279
|
+
})) : e === Fe && (s = !1, sessionStorage.setItem(z, "false"), a("info", "QA Mode DISABLED", {
|
|
274
280
|
visibility: "qa",
|
|
275
|
-
style:
|
|
276
|
-
})), (e ===
|
|
281
|
+
style: Mt
|
|
282
|
+
})), (e === Ue || e === Fe) && Jt(), s ?? t === "true";
|
|
277
283
|
} catch {
|
|
278
284
|
return !1;
|
|
279
285
|
}
|
|
280
|
-
},
|
|
286
|
+
}, ot = () => typeof document < "u" && document.prerendering === !0, es = [
|
|
281
287
|
"co.uk",
|
|
282
288
|
"org.uk",
|
|
283
289
|
"com.au",
|
|
@@ -289,37 +295,37 @@ const Nt = () => {
|
|
|
289
295
|
"co.in",
|
|
290
296
|
"com.cn",
|
|
291
297
|
"co.za"
|
|
292
|
-
],
|
|
298
|
+
], Ye = (n) => {
|
|
293
299
|
const e = n.toLowerCase().split(".");
|
|
294
300
|
if (e.length <= 2)
|
|
295
301
|
return n.toLowerCase();
|
|
296
302
|
const t = e.slice(-2).join(".");
|
|
297
|
-
return
|
|
298
|
-
},
|
|
303
|
+
return es.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
304
|
+
}, ts = (n, e) => n === e ? !0 : Ye(n) === Ye(e), he = () => {
|
|
299
305
|
const n = document.referrer;
|
|
300
306
|
if (!n)
|
|
301
307
|
return "Direct";
|
|
302
308
|
try {
|
|
303
309
|
const e = new URL(n).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
|
|
304
|
-
return
|
|
310
|
+
return ts(e, t) ? "Direct" : n;
|
|
305
311
|
} catch (e) {
|
|
306
312
|
return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: n } }), n;
|
|
307
313
|
}
|
|
308
|
-
},
|
|
314
|
+
}, fe = () => {
|
|
309
315
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
310
|
-
return
|
|
316
|
+
return Tt.forEach((s) => {
|
|
311
317
|
const r = n.get(s);
|
|
312
318
|
if (r) {
|
|
313
319
|
const i = s.split("utm_")[1];
|
|
314
320
|
e[i] = r;
|
|
315
321
|
}
|
|
316
322
|
}), Object.keys(e).length ? e : void 0;
|
|
317
|
-
},
|
|
323
|
+
}, at = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (n) => {
|
|
318
324
|
const e = Math.random() * 16 | 0;
|
|
319
325
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
320
326
|
});
|
|
321
327
|
let W = 0, j = 0;
|
|
322
|
-
const
|
|
328
|
+
const ss = () => {
|
|
323
329
|
let n = Date.now();
|
|
324
330
|
n < j && (n = j), n === j ? W = (W + 1) % 1e3 : W = 0, j = n;
|
|
325
331
|
const e = W.toString().padStart(3, "0");
|
|
@@ -332,13 +338,13 @@ const Jt = () => {
|
|
|
332
338
|
} catch {
|
|
333
339
|
}
|
|
334
340
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
335
|
-
},
|
|
341
|
+
}, ns = (n) => {
|
|
336
342
|
try {
|
|
337
343
|
return new URL(n).protocol === "https:";
|
|
338
344
|
} catch {
|
|
339
345
|
return !1;
|
|
340
346
|
}
|
|
341
|
-
},
|
|
347
|
+
}, rs = (n) => {
|
|
342
348
|
try {
|
|
343
349
|
const t = new URL(window.location.href).hostname;
|
|
344
350
|
if (!t || typeof t != "string")
|
|
@@ -356,35 +362,35 @@ const Jt = () => {
|
|
|
356
362
|
if (!r || r.split(".").length < 2)
|
|
357
363
|
throw new Error("Invalid domain structure for SaaS");
|
|
358
364
|
const i = `https://${n}.${r}/collect`;
|
|
359
|
-
if (!
|
|
365
|
+
if (!ns(i))
|
|
360
366
|
throw new Error("Generated URL failed validation");
|
|
361
367
|
return i;
|
|
362
368
|
} catch (e) {
|
|
363
369
|
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
364
370
|
}
|
|
365
|
-
},
|
|
371
|
+
}, is = (n) => {
|
|
366
372
|
const e = {};
|
|
367
|
-
return n.integrations?.tracelog?.projectId && (e.saas =
|
|
368
|
-
},
|
|
373
|
+
return n.integrations?.tracelog?.projectId && (e.saas = rs(n.integrations.tracelog.projectId)), e;
|
|
374
|
+
}, ye = (n, e = []) => {
|
|
369
375
|
if (!n || typeof n != "string")
|
|
370
376
|
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
371
377
|
try {
|
|
372
|
-
const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([...
|
|
378
|
+
const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([..._t, ...e])];
|
|
373
379
|
let i = !1;
|
|
374
380
|
const o = [];
|
|
375
|
-
return r.forEach((
|
|
376
|
-
s.has(
|
|
381
|
+
return r.forEach((c) => {
|
|
382
|
+
s.has(c) && (s.delete(c), i = !0, o.push(c));
|
|
377
383
|
}), !i && n.includes("?") ? n : (t.search = s.toString(), t.toString());
|
|
378
384
|
} catch (t) {
|
|
379
385
|
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
380
386
|
}
|
|
381
|
-
},
|
|
387
|
+
}, qe = (n) => {
|
|
382
388
|
if (!n || typeof n != "string" || n.trim().length === 0)
|
|
383
389
|
return "";
|
|
384
390
|
let e = n;
|
|
385
391
|
n.length > 1e3 && (e = n.slice(0, Math.max(0, 1e3)));
|
|
386
392
|
let t = 0;
|
|
387
|
-
for (const r of
|
|
393
|
+
for (const r of yt) {
|
|
388
394
|
const i = e;
|
|
389
395
|
e = e.replace(r, ""), i !== e && t++;
|
|
390
396
|
}
|
|
@@ -394,11 +400,11 @@ const Jt = () => {
|
|
|
394
400
|
valueLength: n.length
|
|
395
401
|
}
|
|
396
402
|
}), e.trim();
|
|
397
|
-
},
|
|
403
|
+
}, Ie = (n, e = 0) => {
|
|
398
404
|
if (n == null)
|
|
399
405
|
return null;
|
|
400
406
|
if (typeof n == "string")
|
|
401
|
-
return
|
|
407
|
+
return qe(n);
|
|
402
408
|
if (typeof n == "number")
|
|
403
409
|
return !Number.isFinite(n) || n < -Number.MAX_SAFE_INTEGER || n > Number.MAX_SAFE_INTEGER ? 0 : n;
|
|
404
410
|
if (typeof n == "boolean")
|
|
@@ -406,30 +412,30 @@ const Jt = () => {
|
|
|
406
412
|
if (e > 10)
|
|
407
413
|
return null;
|
|
408
414
|
if (Array.isArray(n))
|
|
409
|
-
return n.slice(0, 1e3).map((r) =>
|
|
415
|
+
return n.slice(0, 1e3).map((r) => Ie(r, e + 1)).filter((r) => r !== null);
|
|
410
416
|
if (typeof n == "object") {
|
|
411
417
|
const t = {}, r = Object.entries(n).slice(0, 200);
|
|
412
418
|
for (const [i, o] of r) {
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
const
|
|
416
|
-
|
|
419
|
+
const c = qe(i);
|
|
420
|
+
if (c) {
|
|
421
|
+
const l = Ie(o, e + 1);
|
|
422
|
+
l !== null && (t[c] = l);
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
425
|
return t;
|
|
420
426
|
}
|
|
421
427
|
return null;
|
|
422
|
-
},
|
|
428
|
+
}, os = (n) => {
|
|
423
429
|
if (typeof n != "object" || n === null)
|
|
424
430
|
return {};
|
|
425
431
|
try {
|
|
426
|
-
const e =
|
|
432
|
+
const e = Ie(n);
|
|
427
433
|
return typeof e == "object" && e !== null ? e : {};
|
|
428
434
|
} catch (e) {
|
|
429
435
|
const t = e instanceof Error ? e.message : String(e);
|
|
430
436
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
431
437
|
}
|
|
432
|
-
},
|
|
438
|
+
}, as = [
|
|
433
439
|
// Email addresses.
|
|
434
440
|
// Quantifiers are bounded (local part ≤64, each label ≤63, TLD ≤63 per RFC/DNS limits)
|
|
435
441
|
// and the domain is matched as discrete dot-separated labels so the local-part and
|
|
@@ -452,18 +458,18 @@ const Jt = () => {
|
|
|
452
458
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
453
459
|
], Y = (n) => {
|
|
454
460
|
let e = n;
|
|
455
|
-
for (const t of
|
|
461
|
+
for (const t of as)
|
|
456
462
|
e = e.replace(t, "[REDACTED]");
|
|
457
463
|
return e;
|
|
458
|
-
},
|
|
464
|
+
}, cs = (n) => {
|
|
459
465
|
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
460
466
|
throw new m("Configuration must be an object", "config");
|
|
461
467
|
if (n) {
|
|
462
468
|
if (n.sessionTimeout !== void 0 && (typeof n.sessionTimeout != "number" || n.sessionTimeout < 3e4 || n.sessionTimeout > 864e5))
|
|
463
|
-
throw new
|
|
469
|
+
throw new At(y.INVALID_SESSION_TIMEOUT, "config");
|
|
464
470
|
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
465
471
|
throw new m(y.INVALID_GLOBAL_METADATA, "config");
|
|
466
|
-
if (n.integrations &&
|
|
472
|
+
if (n.integrations && ls(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
467
473
|
if (!Array.isArray(n.sensitiveQueryParams))
|
|
468
474
|
throw new m(y.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
469
475
|
for (const e of n.sensitiveQueryParams)
|
|
@@ -471,9 +477,9 @@ const Jt = () => {
|
|
|
471
477
|
throw new m("All sensitive query params must be strings", "config");
|
|
472
478
|
}
|
|
473
479
|
if (n.errorSampling !== void 0 && (typeof n.errorSampling != "number" || n.errorSampling < 0 || n.errorSampling > 1))
|
|
474
|
-
throw new
|
|
480
|
+
throw new Be(y.INVALID_ERROR_SAMPLING_RATE, "config");
|
|
475
481
|
if (n.samplingRate !== void 0 && (typeof n.samplingRate != "number" || n.samplingRate < 0 || n.samplingRate > 1))
|
|
476
|
-
throw new
|
|
482
|
+
throw new Be(y.INVALID_SAMPLING_RATE, "config");
|
|
477
483
|
if (n.pageViewThrottleMs !== void 0 && (typeof n.pageViewThrottleMs != "number" || n.pageViewThrottleMs < 0))
|
|
478
484
|
throw new m(y.INVALID_PAGE_VIEW_THROTTLE, "config");
|
|
479
485
|
if (n.clickThrottleMs !== void 0 && (typeof n.clickThrottleMs != "number" || n.clickThrottleMs < 0))
|
|
@@ -523,19 +529,19 @@ const Jt = () => {
|
|
|
523
529
|
}
|
|
524
530
|
}
|
|
525
531
|
}
|
|
526
|
-
},
|
|
532
|
+
}, ls = (n) => {
|
|
527
533
|
if (n && n.tracelog) {
|
|
528
534
|
if (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === "")
|
|
529
|
-
throw new
|
|
535
|
+
throw new Xe(y.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
530
536
|
if (n.tracelog.shopify !== void 0 && typeof n.tracelog.shopify != "boolean")
|
|
531
|
-
throw new
|
|
537
|
+
throw new Xe("tracelog.shopify must be a boolean", "config");
|
|
532
538
|
}
|
|
533
|
-
},
|
|
539
|
+
}, us = (n) => (cs(n), {
|
|
534
540
|
...n ?? {},
|
|
535
541
|
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
536
542
|
globalMetadata: n?.globalMetadata ?? {},
|
|
537
543
|
sensitiveQueryParams: n?.sensitiveQueryParams ?? [],
|
|
538
|
-
errorSampling: n?.errorSampling ??
|
|
544
|
+
errorSampling: n?.errorSampling ?? it,
|
|
539
545
|
samplingRate: n?.samplingRate ?? 1,
|
|
540
546
|
pageViewThrottleMs: n?.pageViewThrottleMs ?? 1e3,
|
|
541
547
|
clickThrottleMs: n?.clickThrottleMs ?? 300,
|
|
@@ -543,18 +549,18 @@ const Jt = () => {
|
|
|
543
549
|
sendIntervalMs: n?.sendIntervalMs ?? 1e4,
|
|
544
550
|
flushOnSpaNavigation: n?.flushOnSpaNavigation ?? !1,
|
|
545
551
|
flushOnPageHidden: n?.flushOnPageHidden ?? !0
|
|
546
|
-
}),
|
|
552
|
+
}), we = (n, e = /* @__PURE__ */ new Set()) => {
|
|
547
553
|
if (n == null)
|
|
548
554
|
return !0;
|
|
549
555
|
const t = typeof n;
|
|
550
|
-
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(n) ? !1 : (e.add(n), Array.isArray(n) ? n.every((s) =>
|
|
551
|
-
},
|
|
556
|
+
return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(n) ? !1 : (e.add(n), Array.isArray(n) ? n.every((s) => we(s, e)) : t === "object" ? Object.values(n).every((s) => we(s, e)) : !1);
|
|
557
|
+
}, ds = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
|
|
552
558
|
if (typeof n != "object" || n === null || Array.isArray(n)) return;
|
|
553
559
|
const e = {};
|
|
554
560
|
for (const [t, s] of Object.entries(n))
|
|
555
561
|
typeof s == "string" && (e[t] = s);
|
|
556
562
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
557
|
-
},
|
|
563
|
+
}, hs = (n) => typeof n != "string" ? {
|
|
558
564
|
valid: !1,
|
|
559
565
|
error: "Event name must be a string"
|
|
560
566
|
} : n.length === 0 ? {
|
|
@@ -569,9 +575,9 @@ const Jt = () => {
|
|
|
569
575
|
} : ["constructor", "prototype", "__proto__", "eval", "function", "var", "let", "const"].includes(n.toLowerCase()) ? {
|
|
570
576
|
valid: !1,
|
|
571
577
|
error: "Event name cannot be a reserved word"
|
|
572
|
-
} : { valid: !0 },
|
|
573
|
-
const s =
|
|
574
|
-
if (!
|
|
578
|
+
} : { valid: !0 }, Je = (n, e, t) => {
|
|
579
|
+
const s = os(e), r = `${t} "${n}" metadata error`;
|
|
580
|
+
if (!ds(s))
|
|
575
581
|
return {
|
|
576
582
|
valid: !1,
|
|
577
583
|
error: `${r}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -595,31 +601,31 @@ const Jt = () => {
|
|
|
595
601
|
valid: !1,
|
|
596
602
|
error: `${r}: object has too many keys (max 100 keys).`
|
|
597
603
|
};
|
|
598
|
-
for (const [
|
|
604
|
+
for (const [l, u] of Object.entries(s)) {
|
|
599
605
|
if (Array.isArray(u)) {
|
|
600
606
|
if (u.length > 500)
|
|
601
607
|
return {
|
|
602
608
|
valid: !1,
|
|
603
|
-
error: `${r}: array property "${
|
|
609
|
+
error: `${r}: array property "${l}" is too large (max 500 items).`
|
|
604
610
|
};
|
|
605
611
|
for (const h of u)
|
|
606
612
|
if (typeof h == "string" && h.length > 500)
|
|
607
613
|
return {
|
|
608
614
|
valid: !1,
|
|
609
|
-
error: `${r}: array property "${
|
|
615
|
+
error: `${r}: array property "${l}" contains strings that are too long (max 500 characters).`
|
|
610
616
|
};
|
|
611
617
|
}
|
|
612
618
|
if (typeof u == "string" && u.length > 1e3)
|
|
613
619
|
return {
|
|
614
620
|
valid: !1,
|
|
615
|
-
error: `${r}: property "${
|
|
621
|
+
error: `${r}: property "${l}" is too long (max 1000 characters).`
|
|
616
622
|
};
|
|
617
623
|
}
|
|
618
624
|
return {
|
|
619
625
|
valid: !0,
|
|
620
626
|
sanitizedMetadata: s
|
|
621
627
|
};
|
|
622
|
-
},
|
|
628
|
+
}, fs = (n, e, t) => {
|
|
623
629
|
if (Array.isArray(e)) {
|
|
624
630
|
const s = [], r = `${t} "${n}" metadata error`;
|
|
625
631
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -629,29 +635,29 @@ const Jt = () => {
|
|
|
629
635
|
valid: !1,
|
|
630
636
|
error: `${r}: array item at index ${i} must be an object.`
|
|
631
637
|
};
|
|
632
|
-
const
|
|
633
|
-
if (!
|
|
638
|
+
const c = Je(n, o, t);
|
|
639
|
+
if (!c.valid)
|
|
634
640
|
return {
|
|
635
641
|
valid: !1,
|
|
636
|
-
error: `${r}: array item at index ${i} is invalid: ${
|
|
642
|
+
error: `${r}: array item at index ${i} is invalid: ${c.error}`
|
|
637
643
|
};
|
|
638
|
-
|
|
644
|
+
c.sanitizedMetadata && s.push(c.sanitizedMetadata);
|
|
639
645
|
}
|
|
640
646
|
return {
|
|
641
647
|
valid: !0,
|
|
642
648
|
sanitizedMetadata: s
|
|
643
649
|
};
|
|
644
650
|
}
|
|
645
|
-
return
|
|
646
|
-
},
|
|
647
|
-
const t =
|
|
651
|
+
return Je(n, e, t);
|
|
652
|
+
}, gs = (n, e) => {
|
|
653
|
+
const t = hs(n);
|
|
648
654
|
if (!t.valid)
|
|
649
655
|
return a("error", "Event name validation failed", {
|
|
650
656
|
data: { eventName: n, error: t.error }
|
|
651
657
|
}), t;
|
|
652
658
|
if (!e)
|
|
653
659
|
return { valid: !0 };
|
|
654
|
-
const s =
|
|
660
|
+
const s = fs(n, e, "customEvent");
|
|
655
661
|
return s.valid || a("error", "Event metadata validation failed", {
|
|
656
662
|
data: {
|
|
657
663
|
eventName: n,
|
|
@@ -659,7 +665,7 @@ const Jt = () => {
|
|
|
659
665
|
}
|
|
660
666
|
}), s;
|
|
661
667
|
};
|
|
662
|
-
class
|
|
668
|
+
class ms {
|
|
663
669
|
listeners = /* @__PURE__ */ new Map();
|
|
664
670
|
/**
|
|
665
671
|
* Subscribes to an event channel
|
|
@@ -776,36 +782,53 @@ class ds {
|
|
|
776
782
|
this.listeners.clear();
|
|
777
783
|
}
|
|
778
784
|
}
|
|
779
|
-
const
|
|
780
|
-
function
|
|
781
|
-
return n.replace(
|
|
785
|
+
const ps = /https?:\/\/\S+/g, Ss = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Es = /0x[0-9a-fA-F]{4,}/g, vs = /(?<!\d)\d{4,}(?!\d)/g, Ts = /(['"])[^'"]{20,}\1/g;
|
|
786
|
+
function _s(n) {
|
|
787
|
+
return n.replace(ps, "[URL]").replace(Ss, "[ID]").replace(Es, "[ADDR]").replace(vs, "[N]").replace(Ts, "$1[VAR]$1").toLowerCase().trim();
|
|
782
788
|
}
|
|
783
|
-
function
|
|
784
|
-
const e =
|
|
785
|
-
return
|
|
789
|
+
function Ze(n) {
|
|
790
|
+
const e = n.search(/[?#]/);
|
|
791
|
+
return e === -1 ? n : n.slice(0, e);
|
|
792
|
+
}
|
|
793
|
+
function ys(n, e) {
|
|
794
|
+
const t = Ze((n ?? "").trim());
|
|
795
|
+
if (!t) return "";
|
|
796
|
+
let s;
|
|
797
|
+
try {
|
|
798
|
+
s = new URL(t);
|
|
799
|
+
} catch {
|
|
800
|
+
return t;
|
|
801
|
+
}
|
|
802
|
+
if (s.protocol !== "http:" && s.protocol !== "https:") return "";
|
|
803
|
+
const r = Ze((e ?? "").trim());
|
|
804
|
+
return r && t === r ? s.origin : t;
|
|
786
805
|
}
|
|
787
|
-
|
|
806
|
+
function Is(n) {
|
|
807
|
+
const e = _s(n.message), t = ys(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
|
|
808
|
+
return `${e}|${t}|${s}`;
|
|
809
|
+
}
|
|
810
|
+
const ge = { config: {} };
|
|
788
811
|
class T {
|
|
789
812
|
/**
|
|
790
813
|
* Retrieves a value from global state.
|
|
791
814
|
*/
|
|
792
815
|
get(e) {
|
|
793
|
-
return
|
|
816
|
+
return ge[e];
|
|
794
817
|
}
|
|
795
818
|
/**
|
|
796
819
|
* Sets a value in global state.
|
|
797
820
|
*/
|
|
798
821
|
set(e, t) {
|
|
799
|
-
|
|
822
|
+
ge[e] = t;
|
|
800
823
|
}
|
|
801
824
|
/**
|
|
802
825
|
* Returns an immutable snapshot of the entire global state.
|
|
803
826
|
*/
|
|
804
827
|
getState() {
|
|
805
|
-
return { ...
|
|
828
|
+
return { ...ge };
|
|
806
829
|
}
|
|
807
830
|
}
|
|
808
|
-
class
|
|
831
|
+
class ws extends T {
|
|
809
832
|
storeManager;
|
|
810
833
|
apiUrl;
|
|
811
834
|
lastPermanentErrorLog = null;
|
|
@@ -850,12 +873,12 @@ class vs extends T {
|
|
|
850
873
|
* cases so the migration is one-shot per browser.
|
|
851
874
|
*/
|
|
852
875
|
migrateLegacyV2Keys() {
|
|
853
|
-
const e = this.get("userId") || "anonymous", t = `${
|
|
876
|
+
const e = this.get("userId") || "anonymous", t = `${ce(e)}:saas`, s = `${ce(e)}:custom`, r = `${le(e)}:saas`, i = `${le(e)}:custom`;
|
|
854
877
|
try {
|
|
855
878
|
const o = this.storeManager.getItem(t);
|
|
856
879
|
if (o) {
|
|
857
|
-
const
|
|
858
|
-
|
|
880
|
+
const c = this.getQueueStorageKey(), l = this.storeManager.getItem(c);
|
|
881
|
+
l ? this.mergeLegacyIntoCurrent(c, o, l) : (this.storeManager.setItem(c, o), a("debug", "Migrated v2 SaaS queue to v3 unscoped key")), this.storeManager.removeItem(t);
|
|
859
882
|
}
|
|
860
883
|
} catch (o) {
|
|
861
884
|
a("debug", "Failed to migrate v2 SaaS queue, discarding legacy key", { error: o });
|
|
@@ -878,17 +901,17 @@ class vs extends T {
|
|
|
878
901
|
a("debug", "Legacy or current queue malformed, keeping current only");
|
|
879
902
|
return;
|
|
880
903
|
}
|
|
881
|
-
const o = new Set(i.events.map((u) => u.id)),
|
|
904
|
+
const o = new Set(i.events.map((u) => u.id)), c = [
|
|
882
905
|
...i.events,
|
|
883
906
|
...r.events.filter((u) => typeof u.id == "string" && !o.has(u.id))
|
|
884
|
-
],
|
|
907
|
+
], l = {
|
|
885
908
|
...i,
|
|
886
|
-
events:
|
|
909
|
+
events: c,
|
|
887
910
|
timestamp: typeof i.timestamp == "number" && typeof r.timestamp == "number" ? Math.min(i.timestamp, r.timestamp) : i.timestamp ?? r.timestamp ?? Date.now(),
|
|
888
911
|
recoveryFailures: Math.max(i.recoveryFailures ?? 0, r.recoveryFailures ?? 0) || void 0
|
|
889
912
|
};
|
|
890
|
-
this.storeManager.setItem(e, JSON.stringify(
|
|
891
|
-
data: { added:
|
|
913
|
+
this.storeManager.setItem(e, JSON.stringify(l)), a("debug", "Merged v2 SaaS queue into existing v3 queue", {
|
|
914
|
+
data: { added: c.length - i.events.length, total: c.length }
|
|
892
915
|
});
|
|
893
916
|
} catch (r) {
|
|
894
917
|
a("debug", "Failed to merge legacy queue, keeping current", { error: r });
|
|
@@ -896,11 +919,11 @@ class vs extends T {
|
|
|
896
919
|
}
|
|
897
920
|
getQueueStorageKey() {
|
|
898
921
|
const e = this.get("userId") || "anonymous";
|
|
899
|
-
return
|
|
922
|
+
return ce(e);
|
|
900
923
|
}
|
|
901
924
|
getRateLimitStorageKey() {
|
|
902
925
|
const e = this.get("userId") || "anonymous";
|
|
903
|
-
return
|
|
926
|
+
return le(e);
|
|
904
927
|
}
|
|
905
928
|
getActiveRateLimitKey() {
|
|
906
929
|
return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
|
|
@@ -1051,46 +1074,46 @@ class vs extends T {
|
|
|
1051
1074
|
}
|
|
1052
1075
|
}), !1;
|
|
1053
1076
|
if (this.consecutiveNetworkFailures >= 3) {
|
|
1054
|
-
const
|
|
1055
|
-
if (
|
|
1077
|
+
const c = Date.now() - this.circuitOpenedAt;
|
|
1078
|
+
if (c < 12e4)
|
|
1056
1079
|
return a("debug", "Network circuit open, skipping send", {
|
|
1057
1080
|
data: {
|
|
1058
1081
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
1059
|
-
cooldownRemainingMs: 12e4 -
|
|
1082
|
+
cooldownRemainingMs: 12e4 - c
|
|
1060
1083
|
}
|
|
1061
1084
|
}), !1;
|
|
1062
1085
|
}
|
|
1063
1086
|
const { url: s, payload: r } = this.prepareRequest(t);
|
|
1064
1087
|
let i = !0, o = !1;
|
|
1065
|
-
for (let
|
|
1088
|
+
for (let c = 1; c <= 3; c++)
|
|
1066
1089
|
try {
|
|
1067
|
-
return (await this.sendWithTimeout(s, r)).ok ? (
|
|
1068
|
-
data: { events: t.events.length, attempt:
|
|
1090
|
+
return (await this.sendWithTimeout(s, r)).ok ? (c > 1 && a("info", `Send succeeded after ${c - 1} retry attempt(s)`, {
|
|
1091
|
+
data: { events: t.events.length, attempt: c }
|
|
1069
1092
|
}), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
|
|
1070
|
-
} catch (
|
|
1071
|
-
const u =
|
|
1072
|
-
if (
|
|
1073
|
-
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0,
|
|
1074
|
-
if (
|
|
1093
|
+
} catch (l) {
|
|
1094
|
+
const u = c === 3;
|
|
1095
|
+
if (l instanceof M)
|
|
1096
|
+
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l;
|
|
1097
|
+
if (l instanceof J) {
|
|
1075
1098
|
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, i = !1, o = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", "Rate limited, skipping retries", {
|
|
1076
|
-
data: { events: e.events.length, attempt:
|
|
1099
|
+
data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
|
|
1077
1100
|
});
|
|
1078
1101
|
break;
|
|
1079
1102
|
}
|
|
1080
|
-
if (
|
|
1103
|
+
if (l instanceof Z || (i = !1), l instanceof TypeError || (o = !0), a(
|
|
1081
1104
|
u ? "error" : "warn",
|
|
1082
|
-
`Send attempt ${
|
|
1105
|
+
`Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
|
|
1083
1106
|
{
|
|
1084
|
-
error:
|
|
1107
|
+
error: l,
|
|
1085
1108
|
data: {
|
|
1086
1109
|
events: e.events.length,
|
|
1087
1110
|
url: s.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1088
|
-
attempt:
|
|
1111
|
+
attempt: c,
|
|
1089
1112
|
maxAttempts: 3
|
|
1090
1113
|
}
|
|
1091
1114
|
}
|
|
1092
1115
|
), !u) {
|
|
1093
|
-
await this.backoffDelay(
|
|
1116
|
+
await this.backoffDelay(c);
|
|
1094
1117
|
continue;
|
|
1095
1118
|
}
|
|
1096
1119
|
return i ? (a("debug", "All retry attempts timed out, preserving batch for retry", {
|
|
@@ -1122,8 +1145,8 @@ class vs extends T {
|
|
|
1122
1145
|
});
|
|
1123
1146
|
if (!o.ok) {
|
|
1124
1147
|
if (o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429) {
|
|
1125
|
-
const
|
|
1126
|
-
throw new M(u, o.status,
|
|
1148
|
+
const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
|
|
1149
|
+
throw new M(u, o.status, l);
|
|
1127
1150
|
}
|
|
1128
1151
|
throw o.status === 429 ? new J(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1129
1152
|
}
|
|
@@ -1137,7 +1160,7 @@ class vs extends T {
|
|
|
1137
1160
|
async readTraceLogErrorCode(e) {
|
|
1138
1161
|
try {
|
|
1139
1162
|
const t = await e.clone().json();
|
|
1140
|
-
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <=
|
|
1163
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= jt)
|
|
1141
1164
|
return t.code;
|
|
1142
1165
|
} catch {
|
|
1143
1166
|
}
|
|
@@ -1151,8 +1174,8 @@ class vs extends T {
|
|
|
1151
1174
|
const o = new Blob([i], { type: "application/json" });
|
|
1152
1175
|
if (!this.isSendBeaconAvailable())
|
|
1153
1176
|
return a("warn", "sendBeacon not available, persisting events for recovery"), this.persistEvents(t), !1;
|
|
1154
|
-
const
|
|
1155
|
-
return
|
|
1177
|
+
const c = navigator.sendBeacon(r, o);
|
|
1178
|
+
return c || (a("warn", "sendBeacon rejected request, persisting events for recovery"), this.persistEvents(t)), c;
|
|
1156
1179
|
}
|
|
1157
1180
|
prepareRequest(e) {
|
|
1158
1181
|
let t = Date.now();
|
|
@@ -1164,7 +1187,7 @@ class vs extends T {
|
|
|
1164
1187
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1165
1188
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1166
1189
|
timestamp: t,
|
|
1167
|
-
client_version:
|
|
1190
|
+
client_version: Yt
|
|
1168
1191
|
}
|
|
1169
1192
|
};
|
|
1170
1193
|
return {
|
|
@@ -1208,16 +1231,16 @@ class vs extends T {
|
|
|
1208
1231
|
return !e.timestamp || typeof e.timestamp != "number" ? !1 : (Date.now() - e.timestamp) / (1e3 * 60 * 60) < 2;
|
|
1209
1232
|
}
|
|
1210
1233
|
createRecoveryBody(e) {
|
|
1211
|
-
const { timestamp: t, recoveryFailures: s, ...r } = e, i = r.events ?? [], o = Date.now() - 5184e5,
|
|
1212
|
-
const u = typeof
|
|
1234
|
+
const { timestamp: t, recoveryFailures: s, ...r } = e, i = r.events ?? [], o = Date.now() - 5184e5, c = i.filter((l) => {
|
|
1235
|
+
const u = typeof l.timestamp == "number" ? l.timestamp : new Date(l.timestamp).getTime();
|
|
1213
1236
|
return Number.isFinite(u) && u >= o;
|
|
1214
1237
|
});
|
|
1215
|
-
return
|
|
1238
|
+
return c.length < i.length && a("debug", "Recovery dropped stale events", {
|
|
1216
1239
|
data: {
|
|
1217
|
-
dropped: i.length -
|
|
1218
|
-
kept:
|
|
1240
|
+
dropped: i.length - c.length,
|
|
1241
|
+
kept: c.length
|
|
1219
1242
|
}
|
|
1220
|
-
}), { ...r, events:
|
|
1243
|
+
}), { ...r, events: c };
|
|
1221
1244
|
}
|
|
1222
1245
|
persistEvents(e) {
|
|
1223
1246
|
const t = this.getPersistedData(), s = typeof t?.recoveryFailures == "number" && Number.isFinite(t.recoveryFailures) ? t.recoveryFailures : 0;
|
|
@@ -1227,10 +1250,10 @@ class vs extends T {
|
|
|
1227
1250
|
try {
|
|
1228
1251
|
const r = this.getPersistedData();
|
|
1229
1252
|
if (!s && r && r.timestamp) {
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1253
|
+
const c = Date.now() - r.timestamp;
|
|
1254
|
+
if (c < 1e3)
|
|
1232
1255
|
return a("debug", "Skipping persistence, another tab recently persisted events", {
|
|
1233
|
-
data: { timeSinceExisting:
|
|
1256
|
+
data: { timeSinceExisting: c }
|
|
1234
1257
|
}), !0;
|
|
1235
1258
|
}
|
|
1236
1259
|
const i = {
|
|
@@ -1256,12 +1279,12 @@ class vs extends T {
|
|
|
1256
1279
|
}
|
|
1257
1280
|
logPermanentError(e, t) {
|
|
1258
1281
|
const s = Date.now(), r = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1259
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >=
|
|
1282
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Wt) && (a("error", e, {
|
|
1260
1283
|
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1261
1284
|
}), this.lastPermanentErrorLog = { key: r, timestamp: s });
|
|
1262
1285
|
}
|
|
1263
1286
|
}
|
|
1264
|
-
class
|
|
1287
|
+
class As extends T {
|
|
1265
1288
|
bootTime;
|
|
1266
1289
|
bootTimestamp;
|
|
1267
1290
|
hasPerformanceNow;
|
|
@@ -1295,8 +1318,8 @@ class Ts extends T {
|
|
|
1295
1318
|
} : { valid: !0 };
|
|
1296
1319
|
}
|
|
1297
1320
|
}
|
|
1298
|
-
const
|
|
1299
|
-
class
|
|
1321
|
+
const Ls = new Set(Object.values(d));
|
|
1322
|
+
class bs extends T {
|
|
1300
1323
|
dataSenders;
|
|
1301
1324
|
emitter;
|
|
1302
1325
|
timeManager;
|
|
@@ -1328,9 +1351,9 @@ class ys extends T {
|
|
|
1328
1351
|
* @param emitter - Optional event emitter for local event consumption
|
|
1329
1352
|
*/
|
|
1330
1353
|
constructor(e, t = null) {
|
|
1331
|
-
super(), this.emitter = t, this.timeManager = new
|
|
1354
|
+
super(), this.emitter = t, this.timeManager = new As(), this.dataSenders = [];
|
|
1332
1355
|
const s = this.get("collectApiUrls");
|
|
1333
|
-
s?.saas && this.dataSenders.push(new
|
|
1356
|
+
s?.saas && this.dataSenders.push(new ws(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
|
|
1334
1357
|
this.saveSessionCounts(r);
|
|
1335
1358
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1336
1359
|
}
|
|
@@ -1363,7 +1386,7 @@ class ys extends T {
|
|
|
1363
1386
|
async (t) => t.recoverPersistedEvents({
|
|
1364
1387
|
onSuccess: (s, r, i) => {
|
|
1365
1388
|
if (r && r.length > 0) {
|
|
1366
|
-
const o = r.map((
|
|
1389
|
+
const o = r.map((c) => c.id);
|
|
1367
1390
|
this.removeProcessedEvents(o), i && this.emitEventsQueue(i);
|
|
1368
1391
|
}
|
|
1369
1392
|
},
|
|
@@ -1440,15 +1463,15 @@ class ys extends T {
|
|
|
1440
1463
|
scroll_data: r,
|
|
1441
1464
|
click_data: i,
|
|
1442
1465
|
custom_event: o,
|
|
1443
|
-
web_vitals:
|
|
1444
|
-
error_data:
|
|
1466
|
+
web_vitals: c,
|
|
1467
|
+
error_data: l,
|
|
1445
1468
|
page_view: u
|
|
1446
1469
|
}) {
|
|
1447
1470
|
if (!e) {
|
|
1448
1471
|
a("error", "Event type is required - event will be ignored");
|
|
1449
1472
|
return;
|
|
1450
1473
|
}
|
|
1451
|
-
if (!
|
|
1474
|
+
if (!Ls.has(e)) {
|
|
1452
1475
|
a("error", "Invalid event type - event will be ignored", {
|
|
1453
1476
|
data: { type: e }
|
|
1454
1477
|
});
|
|
@@ -1465,8 +1488,8 @@ class ys extends T {
|
|
|
1465
1488
|
scroll_data: r,
|
|
1466
1489
|
click_data: i,
|
|
1467
1490
|
custom_event: o,
|
|
1468
|
-
web_vitals:
|
|
1469
|
-
error_data:
|
|
1491
|
+
web_vitals: c,
|
|
1492
|
+
error_data: l,
|
|
1470
1493
|
page_view: u
|
|
1471
1494
|
});
|
|
1472
1495
|
return;
|
|
@@ -1509,19 +1532,19 @@ class ys extends T {
|
|
|
1509
1532
|
if (!this.checkPerEventRateLimit(o.name, _))
|
|
1510
1533
|
return;
|
|
1511
1534
|
}
|
|
1512
|
-
const
|
|
1535
|
+
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), G = this.buildEventPayload({
|
|
1513
1536
|
type: S,
|
|
1514
|
-
page_url:
|
|
1537
|
+
page_url: Et,
|
|
1515
1538
|
from_page_url: s,
|
|
1516
1539
|
scroll_data: r,
|
|
1517
1540
|
click_data: i,
|
|
1518
1541
|
custom_event: o,
|
|
1519
|
-
web_vitals:
|
|
1520
|
-
error_data:
|
|
1542
|
+
web_vitals: c,
|
|
1543
|
+
error_data: l,
|
|
1521
1544
|
page_view: u
|
|
1522
1545
|
});
|
|
1523
1546
|
if (G && !(!p && !this.shouldSample())) {
|
|
1524
|
-
if (
|
|
1547
|
+
if (St) {
|
|
1525
1548
|
const _ = this.get("sessionId");
|
|
1526
1549
|
if (!_) {
|
|
1527
1550
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -1927,7 +1950,7 @@ class ys extends T {
|
|
|
1927
1950
|
), r = await Promise.allSettled(s), i = r.some((o) => this.isSuccessfulResult(o));
|
|
1928
1951
|
if (i) {
|
|
1929
1952
|
this.removeProcessedEvents(t), this.emitEventsQueue(e);
|
|
1930
|
-
const o = r.filter((
|
|
1953
|
+
const o = r.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
1931
1954
|
o > 0 && a("debug", "Async send completed with some failures, removed from queue and persisted per-integration", {
|
|
1932
1955
|
data: { eventCount: t.length, failedCount: o, sessionId: e.session_id }
|
|
1933
1956
|
});
|
|
@@ -1981,14 +2004,14 @@ class ys extends T {
|
|
|
1981
2004
|
const h = this.createEventSignature(u);
|
|
1982
2005
|
s.has(h) || r.push(h), s.set(h, u);
|
|
1983
2006
|
}
|
|
1984
|
-
const i = r.map((u) => s.get(u)).filter((u) => !!u).sort((u, h) => u.type === d.SESSION_START && h.type !== d.SESSION_START ? -1 : h.type === d.SESSION_START && u.type !== d.SESSION_START ? 1 : u.timestamp - h.timestamp).map(({ _session_id: u, ...h }) => h), o = this.get("config")?.globalMetadata,
|
|
2007
|
+
const i = r.map((u) => s.get(u)).filter((u) => !!u).sort((u, h) => u.type === d.SESSION_START && h.type !== d.SESSION_START ? -1 : h.type === d.SESSION_START && u.type !== d.SESSION_START ? 1 : u.timestamp - h.timestamp).map(({ _session_id: u, ...h }) => h), o = this.get("config")?.globalMetadata, c = this.get("identity");
|
|
1985
2008
|
return {
|
|
1986
2009
|
user_id: this.get("userId"),
|
|
1987
2010
|
session_id: e,
|
|
1988
2011
|
device: this.get("device"),
|
|
1989
2012
|
events: i,
|
|
1990
2013
|
...o && { global_metadata: o },
|
|
1991
|
-
...
|
|
2014
|
+
...c && { identify: c }
|
|
1992
2015
|
};
|
|
1993
2016
|
}
|
|
1994
2017
|
buildEventPayload(e) {
|
|
@@ -2002,13 +2025,13 @@ class ys extends T {
|
|
|
2002
2025
|
o.valid || a("warn", "Event timestamp validation failed", {
|
|
2003
2026
|
data: { type: e.type, error: o.error }
|
|
2004
2027
|
});
|
|
2005
|
-
const
|
|
2028
|
+
const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
|
|
2006
2029
|
return { ...{
|
|
2007
|
-
id:
|
|
2030
|
+
id: ss(),
|
|
2008
2031
|
type: e.type,
|
|
2009
2032
|
page_url: r,
|
|
2010
2033
|
timestamp: i,
|
|
2011
|
-
...
|
|
2034
|
+
...c && { referrer: c },
|
|
2012
2035
|
...e.from_page_url && { from_page_url: e.from_page_url },
|
|
2013
2036
|
...e.scroll_data && { scroll_data: e.scroll_data },
|
|
2014
2037
|
...e.click_data && { click_data: e.click_data },
|
|
@@ -2016,7 +2039,8 @@ class ys extends T {
|
|
|
2016
2039
|
...e.web_vitals && { web_vitals: e.web_vitals },
|
|
2017
2040
|
...e.error_data && { error_data: e.error_data },
|
|
2018
2041
|
...e.page_view && { page_view: e.page_view },
|
|
2019
|
-
...
|
|
2042
|
+
...l && { utm: l },
|
|
2043
|
+
...u && { click_ids: u }
|
|
2020
2044
|
}, _session_id: t };
|
|
2021
2045
|
}
|
|
2022
2046
|
isDuplicateEvent(e) {
|
|
@@ -2111,11 +2135,11 @@ class ys extends T {
|
|
|
2111
2135
|
emitEvent(e) {
|
|
2112
2136
|
if (this.emitter) {
|
|
2113
2137
|
const { _session_id: t, ...s } = e;
|
|
2114
|
-
this.emitter.emit(
|
|
2138
|
+
this.emitter.emit(D.EVENT, s);
|
|
2115
2139
|
}
|
|
2116
2140
|
}
|
|
2117
2141
|
emitEventsQueue(e) {
|
|
2118
|
-
this.emitter && this.emitter.emit(
|
|
2142
|
+
this.emitter && this.emitter.emit(D.QUEUE, e);
|
|
2119
2143
|
}
|
|
2120
2144
|
/**
|
|
2121
2145
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2190,13 +2214,13 @@ class ys extends T {
|
|
|
2190
2214
|
loadSessionCounts(e) {
|
|
2191
2215
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2192
2216
|
return this.getInitialCounts();
|
|
2193
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2217
|
+
const t = this.get("userId") || "anonymous", s = Ve(t, e);
|
|
2194
2218
|
try {
|
|
2195
2219
|
const r = localStorage.getItem(s);
|
|
2196
2220
|
if (!r)
|
|
2197
2221
|
return this.getInitialCounts();
|
|
2198
2222
|
const i = JSON.parse(r);
|
|
2199
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2223
|
+
return i._timestamp && Date.now() - i._timestamp > He ? (a("debug", "Session counts expired, clearing", {
|
|
2200
2224
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2201
2225
|
}), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[d.CLICK] == "number" && typeof i[d.PAGE_VIEW] == "number" && typeof i[d.CUSTOM] == "number" && typeof i[d.SCROLL] == "number" ? {
|
|
2202
2226
|
total: i.total,
|
|
@@ -2240,12 +2264,12 @@ class ys extends T {
|
|
|
2240
2264
|
cleanupExpiredSessionCounts() {
|
|
2241
2265
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2242
2266
|
try {
|
|
2243
|
-
const e = localStorage.getItem(
|
|
2267
|
+
const e = localStorage.getItem(xe);
|
|
2244
2268
|
if (e) {
|
|
2245
2269
|
const i = Date.now() - parseInt(e, 10);
|
|
2246
|
-
if (i <
|
|
2270
|
+
if (i < $e) {
|
|
2247
2271
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2248
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2272
|
+
data: { timeSinceLastCleanup: i, throttleMs: $e }
|
|
2249
2273
|
});
|
|
2250
2274
|
return;
|
|
2251
2275
|
}
|
|
@@ -2255,17 +2279,17 @@ class ys extends T {
|
|
|
2255
2279
|
const o = localStorage.key(i);
|
|
2256
2280
|
if (o?.startsWith(s))
|
|
2257
2281
|
try {
|
|
2258
|
-
const
|
|
2259
|
-
if (
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2282
|
+
const c = localStorage.getItem(o);
|
|
2283
|
+
if (c) {
|
|
2284
|
+
const l = JSON.parse(c);
|
|
2285
|
+
l._timestamp && Date.now() - l._timestamp > He && r.push(o);
|
|
2262
2286
|
}
|
|
2263
2287
|
} catch {
|
|
2264
2288
|
}
|
|
2265
2289
|
}
|
|
2266
2290
|
r.forEach((i) => {
|
|
2267
2291
|
localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
|
|
2268
|
-
}), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem(
|
|
2292
|
+
}), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem(xe, Date.now().toString());
|
|
2269
2293
|
} catch (e) {
|
|
2270
2294
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2271
2295
|
}
|
|
@@ -2299,7 +2323,7 @@ class ys extends T {
|
|
|
2299
2323
|
* @internal
|
|
2300
2324
|
*/
|
|
2301
2325
|
saveSessionCounts(e) {
|
|
2302
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2326
|
+
const t = this.get("userId") || "anonymous", s = Ve(t, e);
|
|
2303
2327
|
try {
|
|
2304
2328
|
const r = {
|
|
2305
2329
|
...this.sessionEventCounts,
|
|
@@ -2315,7 +2339,7 @@ class ys extends T {
|
|
|
2315
2339
|
}
|
|
2316
2340
|
}
|
|
2317
2341
|
}
|
|
2318
|
-
class
|
|
2342
|
+
class Ms {
|
|
2319
2343
|
/**
|
|
2320
2344
|
* Gets or creates a unique user ID.
|
|
2321
2345
|
*
|
|
@@ -2333,15 +2357,15 @@ class Is {
|
|
|
2333
2357
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2334
2358
|
*/
|
|
2335
2359
|
static getId(e) {
|
|
2336
|
-
const t = e.getItem(
|
|
2360
|
+
const t = e.getItem(Se);
|
|
2337
2361
|
if (t)
|
|
2338
2362
|
return t;
|
|
2339
|
-
const s =
|
|
2340
|
-
return e.setItem(
|
|
2363
|
+
const s = at();
|
|
2364
|
+
return e.setItem(Se, s), s;
|
|
2341
2365
|
}
|
|
2342
2366
|
}
|
|
2343
|
-
const
|
|
2344
|
-
class
|
|
2367
|
+
const Cs = /^\d{13}-[a-z0-9]{9}$/;
|
|
2368
|
+
class Rs extends T {
|
|
2345
2369
|
storageManager;
|
|
2346
2370
|
eventManager;
|
|
2347
2371
|
projectId;
|
|
@@ -2351,6 +2375,7 @@ class As extends T {
|
|
|
2351
2375
|
broadcastChannel = null;
|
|
2352
2376
|
isTracking = !1;
|
|
2353
2377
|
needsRenewal = !1;
|
|
2378
|
+
prerenderActivationHandler = null;
|
|
2354
2379
|
/**
|
|
2355
2380
|
* Creates a SessionManager instance.
|
|
2356
2381
|
*
|
|
@@ -2367,9 +2392,14 @@ class As extends T {
|
|
|
2367
2392
|
return;
|
|
2368
2393
|
}
|
|
2369
2394
|
const e = this.getProjectId();
|
|
2370
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2395
|
+
this.broadcastChannel = new BroadcastChannel(wt(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2371
2396
|
const { action: s, sessionId: r, timestamp: i, projectId: o } = t.data ?? {};
|
|
2372
|
-
o === e
|
|
2397
|
+
if (o === e)
|
|
2398
|
+
if (s === "session_start" && r && typeof i == "number" && i > Date.now() - 5e3) {
|
|
2399
|
+
this.set("sessionId", r);
|
|
2400
|
+
const c = this.loadStoredSession();
|
|
2401
|
+
this.set("sessionReferrer", c?.referrer), this.set("sessionUtm", c?.utm), this.set("sessionClickIds", c?.clickIds), this.persistSession(r, i, c?.referrer, c?.utm, c?.clickIds), this.isTracking && this.setupSessionTimeout();
|
|
2402
|
+
} else s && s !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: s } });
|
|
2373
2403
|
};
|
|
2374
2404
|
}
|
|
2375
2405
|
shareSession(e) {
|
|
@@ -2387,19 +2417,20 @@ class As extends T {
|
|
|
2387
2417
|
const e = this.loadStoredSession();
|
|
2388
2418
|
if (!e)
|
|
2389
2419
|
return null;
|
|
2390
|
-
if (!
|
|
2420
|
+
if (!Cs.test(e.id))
|
|
2391
2421
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2392
2422
|
data: { sessionId: e.id }
|
|
2393
2423
|
}), this.clearStoredSession(), null;
|
|
2394
2424
|
const t = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2395
2425
|
return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
|
|
2396
2426
|
}
|
|
2397
|
-
persistSession(e, t = Date.now(), s, r) {
|
|
2427
|
+
persistSession(e, t = Date.now(), s, r, i) {
|
|
2398
2428
|
this.saveStoredSession({
|
|
2399
2429
|
id: e,
|
|
2400
2430
|
lastActivity: t,
|
|
2401
2431
|
...s && { referrer: s },
|
|
2402
|
-
...r && { utm: r }
|
|
2432
|
+
...r && { utm: r },
|
|
2433
|
+
...i && { clickIds: i }
|
|
2403
2434
|
});
|
|
2404
2435
|
}
|
|
2405
2436
|
clearStoredSession() {
|
|
@@ -2432,7 +2463,7 @@ class As extends T {
|
|
|
2432
2463
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2433
2464
|
}
|
|
2434
2465
|
getSessionStorageKey() {
|
|
2435
|
-
return
|
|
2466
|
+
return It(this.getProjectId());
|
|
2436
2467
|
}
|
|
2437
2468
|
getProjectId() {
|
|
2438
2469
|
return this.projectId;
|
|
@@ -2471,6 +2502,13 @@ class As extends T {
|
|
|
2471
2502
|
* - Prevents race condition with secondary tabs
|
|
2472
2503
|
* - Ensures secondary tabs can receive session_start message
|
|
2473
2504
|
*
|
|
2505
|
+
* **Pre-rendering**:
|
|
2506
|
+
* - On a pre-rendered page (`document.prerendering === true`), every observable side
|
|
2507
|
+
* effect (persistence, cross-tab sync, SESSION_START, listeners) is deferred to the
|
|
2508
|
+
* `prerenderingchange` activation event via `activateSession()`. `sessionId` is still
|
|
2509
|
+
* set in state synchronously so `init()` returns a real id. A prerender that is never
|
|
2510
|
+
* activated persists and emits nothing.
|
|
2511
|
+
*
|
|
2474
2512
|
* **Called by**: `SessionHandler.startTracking()` during `App.init()`
|
|
2475
2513
|
*
|
|
2476
2514
|
* **Important**: After successful call, `sessionId` is available in global state
|
|
@@ -2495,33 +2533,48 @@ class As extends T {
|
|
|
2495
2533
|
return;
|
|
2496
2534
|
}
|
|
2497
2535
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
2498
|
-
let s, r;
|
|
2536
|
+
let s, r, i;
|
|
2499
2537
|
if (e) {
|
|
2500
|
-
const
|
|
2501
|
-
s =
|
|
2538
|
+
const o = this.loadStoredSession();
|
|
2539
|
+
s = o?.referrer ?? he(), r = o?.utm ?? fe(), i = o?.clickIds ?? de();
|
|
2502
2540
|
} else
|
|
2503
|
-
s =
|
|
2541
|
+
s = he(), r = fe(), i = de();
|
|
2504
2542
|
a("debug", "Session tracking initialized", {
|
|
2505
2543
|
data: {
|
|
2506
2544
|
sessionId: t,
|
|
2507
2545
|
wasRecovered: !!e,
|
|
2508
2546
|
willEmitSessionStart: !e,
|
|
2509
2547
|
sessionReferrer: s,
|
|
2510
|
-
hasUtm: !!r
|
|
2548
|
+
hasUtm: !!r,
|
|
2549
|
+
hasClickIds: !!i
|
|
2511
2550
|
}
|
|
2512
2551
|
}), this.isTracking = !0;
|
|
2513
2552
|
try {
|
|
2514
|
-
this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", r), this.
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
} catch (
|
|
2522
|
-
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null),
|
|
2553
|
+
if (this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", r), this.set("sessionClickIds", i), ot()) {
|
|
2554
|
+
this.prerenderActivationHandler = () => {
|
|
2555
|
+
this.prerenderActivationHandler = null, this.activateSession(t, e, s, r, i);
|
|
2556
|
+
}, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 });
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
this.activateSession(t, e, s, r, i);
|
|
2560
|
+
} catch (o) {
|
|
2561
|
+
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), o;
|
|
2523
2562
|
}
|
|
2524
2563
|
}
|
|
2564
|
+
/**
|
|
2565
|
+
* Commits all observable session side effects: persistence, cross-tab sync, the
|
|
2566
|
+
* SESSION_START emit (new sessions only) and the activity/lifecycle/timeout listeners.
|
|
2567
|
+
*
|
|
2568
|
+
* Runs synchronously on a normal page load. On a pre-rendered page it is deferred to
|
|
2569
|
+
* the `prerenderingchange` (activation) event, so a prerender that is never activated
|
|
2570
|
+
* persists nothing and emits nothing.
|
|
2571
|
+
*
|
|
2572
|
+
* BroadcastChannel is initialized before SESSION_START so secondary tabs can receive
|
|
2573
|
+
* the `session_start` message (avoids a cross-tab race).
|
|
2574
|
+
*/
|
|
2575
|
+
activateSession(e, t, s, r, i) {
|
|
2576
|
+
this.persistSession(e, Date.now(), s, r, i), this.initCrossTabSync(), this.shareSession(e), t ? a("debug", "Session recovered, skipping SESSION_START", { data: { sessionId: e } }) : (a("debug", "Emitting SESSION_START event", { data: { sessionId: e } }), this.eventManager.track({ type: d.SESSION_START })), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
|
|
2577
|
+
}
|
|
2525
2578
|
generateSessionId() {
|
|
2526
2579
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
2527
2580
|
}
|
|
@@ -2535,7 +2588,13 @@ class As extends T {
|
|
|
2535
2588
|
resetSessionTimeout() {
|
|
2536
2589
|
this.setupSessionTimeout();
|
|
2537
2590
|
const e = this.get("sessionId");
|
|
2538
|
-
e && this.persistSession(
|
|
2591
|
+
e && this.persistSession(
|
|
2592
|
+
e,
|
|
2593
|
+
Date.now(),
|
|
2594
|
+
this.get("sessionReferrer"),
|
|
2595
|
+
this.get("sessionUtm"),
|
|
2596
|
+
this.get("sessionClickIds")
|
|
2597
|
+
);
|
|
2539
2598
|
}
|
|
2540
2599
|
clearSessionTimeout() {
|
|
2541
2600
|
this.sessionTimeoutId && (clearTimeout(this.sessionTimeoutId), this.sessionTimeoutId = null);
|
|
@@ -2551,10 +2610,10 @@ class As extends T {
|
|
|
2551
2610
|
*/
|
|
2552
2611
|
renewSession() {
|
|
2553
2612
|
this.needsRenewal = !1;
|
|
2554
|
-
const e = this.generateSessionId(), t =
|
|
2613
|
+
const e = this.generateSessionId(), t = he(), s = fe(), r = de();
|
|
2555
2614
|
a("debug", "Renewing session after timeout", {
|
|
2556
2615
|
data: { newSessionId: e }
|
|
2557
|
-
}), 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({
|
|
2616
|
+
}), this.set("sessionId", e), this.set("sessionReferrer", t), this.set("sessionUtm", s), this.set("sessionClickIds", r), this.persistSession(e, Date.now(), t, s, r), this.cleanupCrossTabSync(), this.initCrossTabSync(), this.shareSession(e), this.eventManager.track({
|
|
2558
2617
|
type: d.SESSION_START
|
|
2559
2618
|
}), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
|
|
2560
2619
|
}
|
|
@@ -2596,14 +2655,14 @@ class As extends T {
|
|
|
2596
2655
|
* Called by session timeout timer.
|
|
2597
2656
|
*/
|
|
2598
2657
|
enterRenewalMode() {
|
|
2599
|
-
this.clearSessionTimeout(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.needsRenewal = !0, a("debug", "Session timed out, entering renewal mode");
|
|
2658
|
+
this.clearSessionTimeout(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.set("sessionClickIds", void 0), this.needsRenewal = !0, a("debug", "Session timed out, entering renewal mode");
|
|
2600
2659
|
}
|
|
2601
2660
|
/**
|
|
2602
2661
|
* Fully resets session state and cleans up all resources.
|
|
2603
2662
|
* Called by stopTracking() for explicit session termination.
|
|
2604
2663
|
*/
|
|
2605
2664
|
resetSessionState() {
|
|
2606
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.needsRenewal = !1, this.isTracking = !1;
|
|
2665
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.cleanupPrerenderActivation(), this.clearStoredSession(), this.set("sessionId", null), this.set("hasStartSession", !1), this.set("sessionReferrer", void 0), this.set("sessionUtm", void 0), this.set("sessionClickIds", void 0), this.needsRenewal = !1, this.isTracking = !1;
|
|
2607
2666
|
}
|
|
2608
2667
|
/**
|
|
2609
2668
|
* Stops session tracking and cleans up all resources.
|
|
@@ -2669,10 +2728,19 @@ class As extends T {
|
|
|
2669
2728
|
* ```
|
|
2670
2729
|
*/
|
|
2671
2730
|
destroy() {
|
|
2672
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
2731
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.cleanupPrerenderActivation(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
2732
|
+
}
|
|
2733
|
+
/**
|
|
2734
|
+
* Removes the pending `prerenderingchange` listener when the manager is torn
|
|
2735
|
+
* down before activation (the discarded-prerender case). On the activation path
|
|
2736
|
+
* `{ once: true }` removes the listener and the handler nulls its own reference,
|
|
2737
|
+
* so this is a no-op then.
|
|
2738
|
+
*/
|
|
2739
|
+
cleanupPrerenderActivation() {
|
|
2740
|
+
this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
|
|
2673
2741
|
}
|
|
2674
2742
|
}
|
|
2675
|
-
class
|
|
2743
|
+
class Ns extends T {
|
|
2676
2744
|
eventManager;
|
|
2677
2745
|
storageManager;
|
|
2678
2746
|
sessionManager = null;
|
|
@@ -2707,7 +2775,7 @@ class bs extends T {
|
|
|
2707
2775
|
}
|
|
2708
2776
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2709
2777
|
try {
|
|
2710
|
-
this.sessionManager = new
|
|
2778
|
+
this.sessionManager = new Rs(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2711
2779
|
} catch (s) {
|
|
2712
2780
|
if (this.sessionManager) {
|
|
2713
2781
|
try {
|
|
@@ -2760,7 +2828,7 @@ class bs extends T {
|
|
|
2760
2828
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2761
2829
|
}
|
|
2762
2830
|
}
|
|
2763
|
-
class
|
|
2831
|
+
class Os extends T {
|
|
2764
2832
|
eventManager;
|
|
2765
2833
|
onTrack;
|
|
2766
2834
|
originalPushState;
|
|
@@ -2800,7 +2868,7 @@ class Ls extends T {
|
|
|
2800
2868
|
};
|
|
2801
2869
|
}
|
|
2802
2870
|
trackCurrentPage = () => {
|
|
2803
|
-
const e = window.location.href, t =
|
|
2871
|
+
const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
|
|
2804
2872
|
if (this.get("pageUrl") === t)
|
|
2805
2873
|
return;
|
|
2806
2874
|
const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2818,7 +2886,7 @@ class Ls extends T {
|
|
|
2818
2886
|
}), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
|
|
2819
2887
|
};
|
|
2820
2888
|
trackInitialPageView() {
|
|
2821
|
-
const e =
|
|
2889
|
+
const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
2822
2890
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
2823
2891
|
type: d.PAGE_VIEW,
|
|
2824
2892
|
page_url: e,
|
|
@@ -2834,7 +2902,7 @@ class Ls extends T {
|
|
|
2834
2902
|
};
|
|
2835
2903
|
}
|
|
2836
2904
|
}
|
|
2837
|
-
class
|
|
2905
|
+
class Ps extends T {
|
|
2838
2906
|
eventManager;
|
|
2839
2907
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
2840
2908
|
clickHandler;
|
|
@@ -2867,7 +2935,7 @@ class Ms extends T {
|
|
|
2867
2935
|
const i = this.get("config")?.clickThrottleMs ?? 300;
|
|
2868
2936
|
if (i > 0 && !this.checkClickThrottle(r, i))
|
|
2869
2937
|
return;
|
|
2870
|
-
const o = this.findTrackingElement(r),
|
|
2938
|
+
const o = this.findTrackingElement(r), c = this.getRelevantClickElement(r), l = this.calculateClickCoordinates(t);
|
|
2871
2939
|
if (o) {
|
|
2872
2940
|
const h = this.extractTrackingData(o);
|
|
2873
2941
|
if (h) {
|
|
@@ -2881,11 +2949,11 @@ class Ms extends T {
|
|
|
2881
2949
|
});
|
|
2882
2950
|
}
|
|
2883
2951
|
}
|
|
2884
|
-
if (!
|
|
2952
|
+
if (!l) {
|
|
2885
2953
|
a("debug", "Click skipped: invalid coordinates (likely synthetic)");
|
|
2886
2954
|
return;
|
|
2887
2955
|
}
|
|
2888
|
-
const u = this.generateClickData(r,
|
|
2956
|
+
const u = this.generateClickData(r, c, l);
|
|
2889
2957
|
this.eventManager.track({
|
|
2890
2958
|
type: d.CLICK,
|
|
2891
2959
|
click_data: u
|
|
@@ -2902,7 +2970,7 @@ class Ms extends T {
|
|
|
2902
2970
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
2903
2971
|
}
|
|
2904
2972
|
shouldIgnoreElement(e) {
|
|
2905
|
-
return e.hasAttribute(`${
|
|
2973
|
+
return e.hasAttribute(`${L}-ignore`) ? !0 : e.closest(`[${L}-ignore]`) !== null;
|
|
2906
2974
|
}
|
|
2907
2975
|
/**
|
|
2908
2976
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -2932,7 +3000,7 @@ class Ms extends T {
|
|
|
2932
3000
|
for (const [s, r] of this.lastClickTimes.entries())
|
|
2933
3001
|
r < t && this.lastClickTimes.delete(s);
|
|
2934
3002
|
if (this.lastClickTimes.size > 1e3) {
|
|
2935
|
-
const s = Array.from(this.lastClickTimes.entries()).sort((o,
|
|
3003
|
+
const s = Array.from(this.lastClickTimes.entries()).sort((o, c) => o[1] - c[1]), r = this.lastClickTimes.size - 1e3, i = s.slice(0, r);
|
|
2936
3004
|
for (const [o] of i)
|
|
2937
3005
|
this.lastClickTimes.delete(o);
|
|
2938
3006
|
a("debug", "ClickHandler: Pruned throttle cache", {
|
|
@@ -2953,8 +3021,8 @@ class Ms extends T {
|
|
|
2953
3021
|
const t = e.getAttribute("data-testid");
|
|
2954
3022
|
if (t)
|
|
2955
3023
|
return `[data-testid="${t}"]`;
|
|
2956
|
-
const s = e.getAttribute(`${
|
|
2957
|
-
return s ? `[${
|
|
3024
|
+
const s = e.getAttribute(`${L}-name`);
|
|
3025
|
+
return s ? `[${L}-name="${s}"]` : this.getElementPath(e);
|
|
2958
3026
|
}
|
|
2959
3027
|
/**
|
|
2960
3028
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -2973,10 +3041,10 @@ class Ms extends T {
|
|
|
2973
3041
|
return t.join(">") || "unknown";
|
|
2974
3042
|
}
|
|
2975
3043
|
findTrackingElement(e) {
|
|
2976
|
-
return e.hasAttribute(`${
|
|
3044
|
+
return e.hasAttribute(`${L}-name`) ? e : e.closest(`[${L}-name]`);
|
|
2977
3045
|
}
|
|
2978
3046
|
getRelevantClickElement(e) {
|
|
2979
|
-
for (const t of
|
|
3047
|
+
for (const t of vt)
|
|
2980
3048
|
try {
|
|
2981
3049
|
if (e.matches(t))
|
|
2982
3050
|
return e;
|
|
@@ -2994,7 +3062,7 @@ class Ms extends T {
|
|
|
2994
3062
|
return typeof t != "number" || typeof s != "number" || !Number.isFinite(t) || !Number.isFinite(s) || t === 0 && s === 0 && !e.isTrusted ? null : { x: t, y: s };
|
|
2995
3063
|
}
|
|
2996
3064
|
extractTrackingData(e) {
|
|
2997
|
-
const t = e.getAttribute(`${
|
|
3065
|
+
const t = e.getAttribute(`${L}-name`), s = e.getAttribute(`${L}-value`);
|
|
2998
3066
|
if (t)
|
|
2999
3067
|
return {
|
|
3000
3068
|
element: e,
|
|
@@ -3003,7 +3071,7 @@ class Ms extends T {
|
|
|
3003
3071
|
};
|
|
3004
3072
|
}
|
|
3005
3073
|
generateClickData(e, t, s) {
|
|
3006
|
-
const { x: r, y: i } = s, o = this.getRelevantText(e, t),
|
|
3074
|
+
const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href") ?? void 0;
|
|
3007
3075
|
return {
|
|
3008
3076
|
x: r,
|
|
3009
3077
|
y: i,
|
|
@@ -3011,7 +3079,7 @@ class Ms extends T {
|
|
|
3011
3079
|
...t.id && { id: t.id },
|
|
3012
3080
|
...t.className && { class: t.className },
|
|
3013
3081
|
...o && { text: o },
|
|
3014
|
-
...
|
|
3082
|
+
...c && { href: c }
|
|
3015
3083
|
};
|
|
3016
3084
|
}
|
|
3017
3085
|
getRelevantText(e, t) {
|
|
@@ -3028,7 +3096,7 @@ class Ms extends T {
|
|
|
3028
3096
|
};
|
|
3029
3097
|
}
|
|
3030
3098
|
}
|
|
3031
|
-
class
|
|
3099
|
+
class ks extends T {
|
|
3032
3100
|
eventManager;
|
|
3033
3101
|
containers = [];
|
|
3034
3102
|
limitWarningLogged = !1;
|
|
@@ -3095,7 +3163,7 @@ class Rs extends T {
|
|
|
3095
3163
|
return t.tagName.toLowerCase();
|
|
3096
3164
|
}
|
|
3097
3165
|
setupScrollContainer(e, t) {
|
|
3098
|
-
if (this.containers.some((
|
|
3166
|
+
if (this.containers.some((l) => l.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3099
3167
|
return;
|
|
3100
3168
|
const r = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3101
3169
|
r,
|
|
@@ -3109,13 +3177,13 @@ class Rs extends T {
|
|
|
3109
3177
|
lastEventTime: 0,
|
|
3110
3178
|
debounceTimer: null,
|
|
3111
3179
|
listener: null
|
|
3112
|
-
},
|
|
3180
|
+
}, c = () => {
|
|
3113
3181
|
this.get("suppressNextScroll") || (this.clearContainerTimer(o), o.debounceTimer = window.setTimeout(() => {
|
|
3114
|
-
const
|
|
3115
|
-
|
|
3182
|
+
const l = this.calculateScrollData(o);
|
|
3183
|
+
l && this.processScrollEvent(o, l, Date.now()), o.debounceTimer = null;
|
|
3116
3184
|
}, 250));
|
|
3117
3185
|
};
|
|
3118
|
-
o.listener =
|
|
3186
|
+
o.listener = c, this.containers.push(o), e === window ? window.addEventListener("scroll", c, { passive: !0 }) : e.addEventListener("scroll", c, { passive: !0 });
|
|
3119
3187
|
}
|
|
3120
3188
|
processScrollEvent(e, t, s) {
|
|
3121
3189
|
if (!this.shouldEmitScrollEvent(e, t, s))
|
|
@@ -3154,7 +3222,7 @@ class Rs extends T {
|
|
|
3154
3222
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3155
3223
|
}
|
|
3156
3224
|
getScrollDirection(e, t) {
|
|
3157
|
-
return e > t ?
|
|
3225
|
+
return e > t ? Ee.DOWN : Ee.UP;
|
|
3158
3226
|
}
|
|
3159
3227
|
calculateScrollDepth(e, t, s) {
|
|
3160
3228
|
if (t <= s)
|
|
@@ -3166,8 +3234,8 @@ class Rs extends T {
|
|
|
3166
3234
|
const { element: t, lastScrollPos: s } = e, r = this.getScrollTop(t);
|
|
3167
3235
|
if (Math.abs(r - s) < 10 || t === window && !this.isWindowScrollable())
|
|
3168
3236
|
return null;
|
|
3169
|
-
const o = this.getViewportHeight(t),
|
|
3170
|
-
return e.lastScrollPos = r, { depth: u, direction:
|
|
3237
|
+
const o = this.getViewportHeight(t), c = this.getScrollHeight(t), l = this.getScrollDirection(r, s), u = this.calculateScrollDepth(r, c, o);
|
|
3238
|
+
return e.lastScrollPos = r, { depth: u, direction: l };
|
|
3171
3239
|
}
|
|
3172
3240
|
getScrollTop(e) {
|
|
3173
3241
|
return e === window ? window.scrollY : e.scrollTop;
|
|
@@ -3183,8 +3251,8 @@ class Rs extends T {
|
|
|
3183
3251
|
return s && r;
|
|
3184
3252
|
}
|
|
3185
3253
|
}
|
|
3186
|
-
const
|
|
3187
|
-
class
|
|
3254
|
+
const Ds = "tracelog_session_id", Us = "tracelog_user_id";
|
|
3255
|
+
class Fs extends T {
|
|
3188
3256
|
visibilityHandler = null;
|
|
3189
3257
|
pageshowHandler = null;
|
|
3190
3258
|
lastSyncedKey = null;
|
|
@@ -3205,8 +3273,8 @@ class Os extends T {
|
|
|
3205
3273
|
r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
|
|
3206
3274
|
}
|
|
3207
3275
|
postCartUpdate(e, t) {
|
|
3208
|
-
const s = { [
|
|
3209
|
-
t.length > 0 && (s[
|
|
3276
|
+
const s = { [Ds]: e };
|
|
3277
|
+
t.length > 0 && (s[Us] = t);
|
|
3210
3278
|
try {
|
|
3211
3279
|
fetch("/cart/update.js", {
|
|
3212
3280
|
method: "POST",
|
|
@@ -3243,7 +3311,7 @@ class Os extends T {
|
|
|
3243
3311
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
|
|
3244
3312
|
}
|
|
3245
3313
|
}
|
|
3246
|
-
class
|
|
3314
|
+
class Vs {
|
|
3247
3315
|
storage;
|
|
3248
3316
|
sessionStorageRef;
|
|
3249
3317
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3304,7 +3372,7 @@ class Ps {
|
|
|
3304
3372
|
const e = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], t = [], s = [];
|
|
3305
3373
|
for (let i = 0; i < this.storage.length; i++) {
|
|
3306
3374
|
const o = this.storage.key(i);
|
|
3307
|
-
o?.startsWith("tracelog_") && (o.startsWith("tracelog_persisted_events_") ? t.push(o) : e.some((
|
|
3375
|
+
o?.startsWith("tracelog_") && (o.startsWith("tracelog_persisted_events_") ? t.push(o) : e.some((c) => o.startsWith(c)) || s.push(o));
|
|
3308
3376
|
}
|
|
3309
3377
|
const r = [...t, ...s.slice(0, 5)];
|
|
3310
3378
|
return r.length === 0 ? !1 : (r.forEach((i) => {
|
|
@@ -3356,7 +3424,7 @@ class Ps {
|
|
|
3356
3424
|
this.fallbackSessionStorage.delete(e);
|
|
3357
3425
|
}
|
|
3358
3426
|
}
|
|
3359
|
-
class
|
|
3427
|
+
class Hs extends T {
|
|
3360
3428
|
eventManager;
|
|
3361
3429
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3362
3430
|
navigationHistory = [];
|
|
@@ -3366,7 +3434,7 @@ class Ds extends T {
|
|
|
3366
3434
|
navigationCounter = 0;
|
|
3367
3435
|
// Counter for handling simultaneous navigations edge case
|
|
3368
3436
|
constructor(e) {
|
|
3369
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
3437
|
+
super(), this.eventManager = e, this.vitalThresholds = Qe(_e);
|
|
3370
3438
|
}
|
|
3371
3439
|
/**
|
|
3372
3440
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3382,8 +3450,8 @@ class Ds extends T {
|
|
|
3382
3450
|
* @returns Promise that resolves when tracking is initialized
|
|
3383
3451
|
*/
|
|
3384
3452
|
async startTracking() {
|
|
3385
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
3386
|
-
this.vitalThresholds =
|
|
3453
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? _e;
|
|
3454
|
+
this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
|
|
3387
3455
|
}
|
|
3388
3456
|
/**
|
|
3389
3457
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -3423,8 +3491,8 @@ class Ds extends T {
|
|
|
3423
3491
|
for (const o of i) {
|
|
3424
3492
|
if (o.hadRecentInput === !0)
|
|
3425
3493
|
continue;
|
|
3426
|
-
const
|
|
3427
|
-
e +=
|
|
3494
|
+
const c = typeof o.value == "number" ? o.value : 0;
|
|
3495
|
+
e += c;
|
|
3428
3496
|
}
|
|
3429
3497
|
this.sendVital({ type: "CLS", value: Number(e.toFixed(2)) });
|
|
3430
3498
|
},
|
|
@@ -3443,8 +3511,8 @@ class Ds extends T {
|
|
|
3443
3511
|
let r = 0;
|
|
3444
3512
|
const i = s.getEntries();
|
|
3445
3513
|
for (const o of i) {
|
|
3446
|
-
const
|
|
3447
|
-
r = Math.max(r,
|
|
3514
|
+
const c = (o.processingEnd ?? 0) - (o.startTime ?? 0);
|
|
3515
|
+
r = Math.max(r, c);
|
|
3448
3516
|
}
|
|
3449
3517
|
r > 0 && this.sendVital({ type: "INP", value: Number(r.toFixed(2)) });
|
|
3450
3518
|
},
|
|
@@ -3453,9 +3521,9 @@ class Ds extends T {
|
|
|
3453
3521
|
}
|
|
3454
3522
|
async initWebVitals() {
|
|
3455
3523
|
try {
|
|
3456
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() =>
|
|
3457
|
-
const u = Number(
|
|
3458
|
-
this.sendVital({ type:
|
|
3524
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => hn), o = (c) => (l) => {
|
|
3525
|
+
const u = Number(l.value.toFixed(2));
|
|
3526
|
+
this.sendVital({ type: c, value: u });
|
|
3459
3527
|
};
|
|
3460
3528
|
e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), s(o("FCP"), { reportAllChanges: !1 }), r(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
|
|
3461
3529
|
} catch (e) {
|
|
@@ -3483,7 +3551,7 @@ class Ds extends T {
|
|
|
3483
3551
|
return;
|
|
3484
3552
|
if (s)
|
|
3485
3553
|
s.add(e.type);
|
|
3486
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
3554
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > zt) {
|
|
3487
3555
|
const i = this.navigationHistory.shift();
|
|
3488
3556
|
i && this.reportedByNav.delete(i);
|
|
3489
3557
|
}
|
|
@@ -3544,18 +3612,18 @@ class Ds extends T {
|
|
|
3544
3612
|
try {
|
|
3545
3613
|
if (!this.isObserverSupported(e))
|
|
3546
3614
|
return !1;
|
|
3547
|
-
const i = new PerformanceObserver((o,
|
|
3615
|
+
const i = new PerformanceObserver((o, c) => {
|
|
3548
3616
|
try {
|
|
3549
|
-
t(o,
|
|
3550
|
-
} catch (
|
|
3617
|
+
t(o, c);
|
|
3618
|
+
} catch (l) {
|
|
3551
3619
|
a("debug", "Observer callback failed", {
|
|
3552
|
-
error:
|
|
3620
|
+
error: l,
|
|
3553
3621
|
data: { type: e }
|
|
3554
3622
|
});
|
|
3555
3623
|
}
|
|
3556
3624
|
if (r)
|
|
3557
3625
|
try {
|
|
3558
|
-
|
|
3626
|
+
c.disconnect();
|
|
3559
3627
|
} catch {
|
|
3560
3628
|
}
|
|
3561
3629
|
});
|
|
@@ -3601,7 +3669,7 @@ class se extends T {
|
|
|
3601
3669
|
this.resetPageviewCounter();
|
|
3602
3670
|
}, window.addEventListener("pagehide", this.pagehideHandler, { passive: !0 }), this.emitter && (this.pageviewResetListener = (e) => {
|
|
3603
3671
|
(e.type === d.SESSION_START || e.type === d.PAGE_VIEW) && this.resetPageviewCounter();
|
|
3604
|
-
}, this.emitter.on(
|
|
3672
|
+
}, this.emitter.on(D.EVENT, this.pageviewResetListener));
|
|
3605
3673
|
}
|
|
3606
3674
|
/**
|
|
3607
3675
|
* Stops tracking errors and cleans up resources.
|
|
@@ -3612,7 +3680,7 @@ class se extends T {
|
|
|
3612
3680
|
* - Resets burst detection counters
|
|
3613
3681
|
*/
|
|
3614
3682
|
stopTracking() {
|
|
3615
|
-
window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(
|
|
3683
|
+
window.removeEventListener("error", this.handleError), window.removeEventListener("unhandledrejection", this.handleRejection), this.pagehideHandler && (window.removeEventListener("pagehide", this.pagehideHandler), this.pagehideHandler = null), this.emitter && this.pageviewResetListener && (this.emitter.off(D.EVENT, this.pageviewResetListener), this.pageviewResetListener = null), this.recentErrors.clear(), this.pageviewSignatureCounts.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
|
|
3616
3684
|
}
|
|
3617
3685
|
/**
|
|
3618
3686
|
* Clears the per-pageview signature counter.
|
|
@@ -3631,14 +3699,14 @@ class se extends T {
|
|
|
3631
3699
|
const e = Date.now();
|
|
3632
3700
|
if (e < this.burstBackoffUntil)
|
|
3633
3701
|
return !1;
|
|
3634
|
-
if (e - this.burstWindowStart >
|
|
3635
|
-
return this.burstBackoffUntil = e +
|
|
3702
|
+
if (e - this.burstWindowStart > $t && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > Bt)
|
|
3703
|
+
return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
|
|
3636
3704
|
data: {
|
|
3637
3705
|
errorsInWindow: this.errorBurstCounter,
|
|
3638
|
-
cooldownMs:
|
|
3706
|
+
cooldownMs: Ke
|
|
3639
3707
|
}
|
|
3640
3708
|
}), !1;
|
|
3641
|
-
const s = this.get("config").errorSampling ??
|
|
3709
|
+
const s = this.get("config").errorSampling ?? it;
|
|
3642
3710
|
return Math.random() < s;
|
|
3643
3711
|
}
|
|
3644
3712
|
/**
|
|
@@ -3648,17 +3716,13 @@ class se extends T {
|
|
|
3648
3716
|
* later signature that recycles the same map key after a counter reset.
|
|
3649
3717
|
*/
|
|
3650
3718
|
shouldThrottleBySignature(e) {
|
|
3651
|
-
const t =
|
|
3652
|
-
|
|
3653
|
-
filename: e.filename,
|
|
3654
|
-
line: e.line
|
|
3655
|
-
}), s = this.pageviewSignatureCounts.get(t) ?? 0;
|
|
3656
|
-
if (s >= Ht)
|
|
3719
|
+
const t = Is(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
|
|
3720
|
+
if (s >= Xt)
|
|
3657
3721
|
return a("debug", "Error throttled (pageview cap)", {
|
|
3658
3722
|
data: { signature: t, count: s }
|
|
3659
3723
|
}), !0;
|
|
3660
3724
|
const r = s + 1;
|
|
3661
|
-
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size >
|
|
3725
|
+
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Gt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
|
|
3662
3726
|
}
|
|
3663
3727
|
handleError = (e) => {
|
|
3664
3728
|
if (!this.shouldSample())
|
|
@@ -3667,7 +3731,11 @@ class se extends T {
|
|
|
3667
3731
|
if (this.shouldSuppressError(V.JS_ERROR, t) || this.shouldThrottleBySignature({
|
|
3668
3732
|
message: t,
|
|
3669
3733
|
filename: e.filename,
|
|
3670
|
-
line: e.lineno
|
|
3734
|
+
line: e.lineno,
|
|
3735
|
+
// Inline-script errors report the page URL as `filename`; passing the current
|
|
3736
|
+
// page URL lets buildErrorSignatureKey collapse them to origin, byte-identical
|
|
3737
|
+
// to the server cap/dedup hash. normalizeFilename strips query/hash internally.
|
|
3738
|
+
page_url: window.location.href
|
|
3671
3739
|
}))
|
|
3672
3740
|
return;
|
|
3673
3741
|
const s = typeof e.error?.stack == "string" ? this.truncateStack(e.error.stack) : void 0, r = typeof e.error?.name == "string" && e.error.name !== "Error" ? e.error.name : void 0;
|
|
@@ -3715,24 +3783,24 @@ class se extends T {
|
|
|
3715
3783
|
}
|
|
3716
3784
|
}
|
|
3717
3785
|
sanitize(e) {
|
|
3718
|
-
const t = e.length >
|
|
3786
|
+
const t = e.length > Ge ? e.slice(0, Ge) + "..." : e;
|
|
3719
3787
|
return Y(t);
|
|
3720
3788
|
}
|
|
3721
3789
|
shouldSuppressError(e, t) {
|
|
3722
3790
|
const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
|
|
3723
|
-
return i !== void 0 && s - i <
|
|
3791
|
+
return i !== void 0 && s - i < je ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > xt ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
3724
3792
|
}
|
|
3725
3793
|
static TRUNCATION_SUFFIX = `
|
|
3726
3794
|
...truncated`;
|
|
3727
3795
|
truncateStack(e) {
|
|
3728
|
-
if (e.length <=
|
|
3729
|
-
const t =
|
|
3796
|
+
if (e.length <= We) return Y(e);
|
|
3797
|
+
const t = We - se.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + se.TRUNCATION_SUFFIX;
|
|
3730
3798
|
return Y(s);
|
|
3731
3799
|
}
|
|
3732
3800
|
pruneOldErrors() {
|
|
3733
3801
|
const e = Date.now();
|
|
3734
3802
|
for (const [r, i] of this.recentErrors.entries())
|
|
3735
|
-
e - i >
|
|
3803
|
+
e - i > je && this.recentErrors.delete(r);
|
|
3736
3804
|
if (this.recentErrors.size <= Q)
|
|
3737
3805
|
return;
|
|
3738
3806
|
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - Q;
|
|
@@ -3742,13 +3810,14 @@ class se extends T {
|
|
|
3742
3810
|
}
|
|
3743
3811
|
}
|
|
3744
3812
|
}
|
|
3745
|
-
class
|
|
3813
|
+
class xs extends T {
|
|
3746
3814
|
isInitialized = !1;
|
|
3747
3815
|
suppressNextScrollTimer = null;
|
|
3748
3816
|
pageUnloadHandler = null;
|
|
3749
3817
|
pageShowHandler = null;
|
|
3750
3818
|
visibilityFlushHandler = null;
|
|
3751
|
-
|
|
3819
|
+
prerenderActivationHandler = null;
|
|
3820
|
+
emitter = new ms();
|
|
3752
3821
|
managers = {};
|
|
3753
3822
|
handlers = {};
|
|
3754
3823
|
integrationInstances = {};
|
|
@@ -3763,9 +3832,9 @@ class ks extends T {
|
|
|
3763
3832
|
async init(e = {}) {
|
|
3764
3833
|
if (this.isInitialized)
|
|
3765
3834
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
3766
|
-
this.managers.storage = new
|
|
3835
|
+
this.managers.storage = new Vs();
|
|
3767
3836
|
try {
|
|
3768
|
-
return this.setupState(e), this.managers.event = new
|
|
3837
|
+
return this.setupState(e), this.managers.event = new bs(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
3769
3838
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
3770
3839
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
3771
3840
|
} catch (t) {
|
|
@@ -3786,7 +3855,7 @@ class ks extends T {
|
|
|
3786
3855
|
}
|
|
3787
3856
|
let r = t;
|
|
3788
3857
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
3789
|
-
const { valid: i, error: o, sanitizedMetadata:
|
|
3858
|
+
const { valid: i, error: o, sanitizedMetadata: c } = gs(e, r);
|
|
3790
3859
|
if (!i) {
|
|
3791
3860
|
if (this.get("mode") === ee.QA)
|
|
3792
3861
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
|
|
@@ -3797,7 +3866,7 @@ class ks extends T {
|
|
|
3797
3866
|
type: d.CUSTOM,
|
|
3798
3867
|
custom_event: {
|
|
3799
3868
|
name: e,
|
|
3800
|
-
...
|
|
3869
|
+
...c && { metadata: c }
|
|
3801
3870
|
}
|
|
3802
3871
|
}), s?.critical === !0 && (this.managers.event.flushImmediatelySync() || a("debug", "Critical event flush returned false (deferred to in-flight send or empty queue)", {
|
|
3803
3872
|
data: { name: e }
|
|
@@ -3821,18 +3890,18 @@ class ks extends T {
|
|
|
3821
3890
|
} catch (s) {
|
|
3822
3891
|
a("warn", "Failed to stop tracking", { error: s });
|
|
3823
3892
|
}
|
|
3824
|
-
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.pageUnloadHandler && (window.removeEventListener("pagehide", this.pageUnloadHandler), window.removeEventListener("beforeunload", this.pageUnloadHandler), this.pageUnloadHandler = null), this.pageShowHandler && (window.removeEventListener("pageshow", this.pageShowHandler), this.pageShowHandler = null), this.visibilityFlushHandler && (document.removeEventListener("visibilitychange", this.visibilityFlushHandler), this.visibilityFlushHandler = null), this.managers.event?.flushImmediatelySync(), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.set("suppressNextScroll", !1), this.set("sessionId", null), this.set("identity", void 0), this.clearPersistedIdentity(), this.integrationInstances.shopifyCartLinker?.deactivate(), this.integrationInstances = {}, this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
3893
|
+
}), this.suppressNextScrollTimer && (clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = null), this.pageUnloadHandler && (window.removeEventListener("pagehide", this.pageUnloadHandler), window.removeEventListener("beforeunload", this.pageUnloadHandler), this.pageUnloadHandler = null), this.pageShowHandler && (window.removeEventListener("pageshow", this.pageShowHandler), this.pageShowHandler = null), this.visibilityFlushHandler && (document.removeEventListener("visibilitychange", this.visibilityFlushHandler), this.visibilityFlushHandler = null), this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null), this.managers.event?.flushImmediatelySync(), this.managers.event?.stop(), this.emitter.removeAllListeners(), this.set("suppressNextScroll", !1), this.set("sessionId", null), this.set("identity", void 0), this.clearPersistedIdentity(), this.integrationInstances.shopifyCartLinker?.deactivate(), this.integrationInstances = {}, this.isInitialized = !1, this.handlers = {}, this.managers = {});
|
|
3825
3894
|
}
|
|
3826
3895
|
setupState(e = {}) {
|
|
3827
3896
|
this.set("config", e);
|
|
3828
|
-
const t =
|
|
3897
|
+
const t = Ms.getId(this.managers.storage);
|
|
3829
3898
|
this.set("userId", t);
|
|
3830
|
-
const s =
|
|
3899
|
+
const s = is(e);
|
|
3831
3900
|
this.set("collectApiUrls", s);
|
|
3832
|
-
const r =
|
|
3901
|
+
const r = Ht();
|
|
3833
3902
|
this.set("device", r);
|
|
3834
|
-
const i =
|
|
3835
|
-
this.set("pageUrl", i),
|
|
3903
|
+
const i = ye(window.location.href, e.sensitiveQueryParams);
|
|
3904
|
+
this.set("pageUrl", i), Zt() && this.set("mode", ee.QA);
|
|
3836
3905
|
}
|
|
3837
3906
|
/**
|
|
3838
3907
|
* @internal Used by api.ts for configuration access
|
|
@@ -3887,7 +3956,7 @@ class ks extends T {
|
|
|
3887
3956
|
a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
|
|
3888
3957
|
return;
|
|
3889
3958
|
}
|
|
3890
|
-
const s = e.trim(), r =
|
|
3959
|
+
const s = e.trim(), r = Ae(t), i = {
|
|
3891
3960
|
userId: s,
|
|
3892
3961
|
...r ? { traits: r } : {}
|
|
3893
3962
|
};
|
|
@@ -3910,8 +3979,8 @@ class ks extends T {
|
|
|
3910
3979
|
*/
|
|
3911
3980
|
async resetIdentity() {
|
|
3912
3981
|
await this.managers.event?.flushImmediately().catch((t) => (a("debug", "Failed to flush before identity reset", { error: t }), !1)), this.set("identity", void 0), this.clearPersistedIdentity();
|
|
3913
|
-
const e =
|
|
3914
|
-
this.managers.storage.setItem(
|
|
3982
|
+
const e = at();
|
|
3983
|
+
this.managers.storage.setItem(Se, e), this.set("userId", e), this.set("hasStartSession", !1), this.set("sessionId", null), this.handlers.session?.stopTracking(), this.handlers.session?.startTracking(), a("debug", "Identity reset, new UUID generated");
|
|
3915
3984
|
}
|
|
3916
3985
|
/**
|
|
3917
3986
|
* Returns the project ID used for identity storage scoping.
|
|
@@ -3983,7 +4052,7 @@ class ks extends T {
|
|
|
3983
4052
|
* localStorage values.
|
|
3984
4053
|
*/
|
|
3985
4054
|
normalizePersistedIdentity(e) {
|
|
3986
|
-
const t =
|
|
4055
|
+
const t = Ae(e.traits);
|
|
3987
4056
|
return {
|
|
3988
4057
|
userId: e.userId.trim(),
|
|
3989
4058
|
...t ? { traits: t } : {}
|
|
@@ -4013,7 +4082,7 @@ class ks extends T {
|
|
|
4013
4082
|
}
|
|
4014
4083
|
initializeHandlers() {
|
|
4015
4084
|
const e = this.get("config");
|
|
4016
|
-
this.handlers.session = new
|
|
4085
|
+
this.handlers.session = new Ns(
|
|
4017
4086
|
this.managers.storage,
|
|
4018
4087
|
this.managers.event
|
|
4019
4088
|
), this.handlers.session.startTracking();
|
|
@@ -4022,28 +4091,34 @@ class ks extends T {
|
|
|
4022
4091
|
this.set("suppressNextScroll", !1);
|
|
4023
4092
|
}, 500);
|
|
4024
4093
|
};
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
r
|
|
4031
|
-
|
|
4032
|
-
|
|
4094
|
+
this.handlers.pageView = new Os(this.managers.event, t), this.handlers.click = new Ps(this.managers.event), this.handlers.scroll = new ks(this.managers.event), this.handlers.performance = new Hs(this.managers.event), this.handlers.error = new se(this.managers.event, this.emitter);
|
|
4095
|
+
const s = () => {
|
|
4096
|
+
if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
|
|
4097
|
+
a("warn", "Failed to start performance tracking", { error: r });
|
|
4098
|
+
}), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
|
|
4099
|
+
const r = new Fs();
|
|
4100
|
+
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(D.EVENT, (i) => {
|
|
4101
|
+
i.type === d.SESSION_START && r.onSessionChange();
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4104
|
+
};
|
|
4105
|
+
ot() ? (this.prerenderActivationHandler = () => {
|
|
4106
|
+
this.prerenderActivationHandler = null, s();
|
|
4107
|
+
}, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 })) : s();
|
|
4033
4108
|
}
|
|
4034
4109
|
}
|
|
4035
|
-
const
|
|
4036
|
-
let f = null,
|
|
4037
|
-
const
|
|
4110
|
+
const R = [];
|
|
4111
|
+
let f = null, k = !1, A = !1, C = null;
|
|
4112
|
+
const $s = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (k && C || (k = !0, C = (async () => {
|
|
4038
4113
|
try {
|
|
4039
|
-
const e =
|
|
4114
|
+
const e = us(n ?? {}), t = new xs();
|
|
4040
4115
|
try {
|
|
4041
|
-
|
|
4042
|
-
t.on(o,
|
|
4043
|
-
}),
|
|
4044
|
-
const s = t.init(e), r = new Promise((o,
|
|
4116
|
+
R.forEach(({ event: o, callback: c }) => {
|
|
4117
|
+
t.on(o, c);
|
|
4118
|
+
}), R.length = 0;
|
|
4119
|
+
const s = t.init(e), r = new Promise((o, c) => {
|
|
4045
4120
|
setTimeout(() => {
|
|
4046
|
-
|
|
4121
|
+
c(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4047
4122
|
}, 1e4);
|
|
4048
4123
|
}), i = await Promise.race([s, r]);
|
|
4049
4124
|
return f = t, i;
|
|
@@ -4058,9 +4133,9 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4058
4133
|
} catch (e) {
|
|
4059
4134
|
throw f = null, e;
|
|
4060
4135
|
} finally {
|
|
4061
|
-
|
|
4136
|
+
k = !1, C = null;
|
|
4062
4137
|
}
|
|
4063
|
-
})()),
|
|
4138
|
+
})()), C)), Bs = (n, e, t) => {
|
|
4064
4139
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4065
4140
|
if (!f)
|
|
4066
4141
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4068,24 +4143,24 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4068
4143
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4069
4144
|
f.sendCustomEvent(n, e, t);
|
|
4070
4145
|
}
|
|
4071
|
-
},
|
|
4146
|
+
}, Xs = (n, e) => {
|
|
4072
4147
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4073
|
-
if (!f ||
|
|
4074
|
-
|
|
4148
|
+
if (!f || k) {
|
|
4149
|
+
R.push({ event: n, callback: e });
|
|
4075
4150
|
return;
|
|
4076
4151
|
}
|
|
4077
4152
|
f.on(n, e);
|
|
4078
4153
|
}
|
|
4079
|
-
},
|
|
4154
|
+
}, Gs = (n, e) => {
|
|
4080
4155
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4081
4156
|
if (!f) {
|
|
4082
|
-
const t =
|
|
4083
|
-
t !== -1 &&
|
|
4157
|
+
const t = R.findIndex((s) => s.event === n && s.callback === e);
|
|
4158
|
+
t !== -1 && R.splice(t, 1);
|
|
4084
4159
|
return;
|
|
4085
4160
|
}
|
|
4086
4161
|
f.off(n, e);
|
|
4087
4162
|
}
|
|
4088
|
-
},
|
|
4163
|
+
}, Ws = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, js = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Ks = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), zs = () => {
|
|
4089
4164
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4090
4165
|
if (A)
|
|
4091
4166
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4095,12 +4170,12 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4095
4170
|
}
|
|
4096
4171
|
A = !0;
|
|
4097
4172
|
try {
|
|
4098
|
-
f.destroy(), f = null,
|
|
4173
|
+
f.destroy(), f = null, k = !1, C = null, R.length = 0, A = !1;
|
|
4099
4174
|
} catch (n) {
|
|
4100
|
-
f = null,
|
|
4175
|
+
f = null, k = !1, C = null, R.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4101
4176
|
}
|
|
4102
4177
|
}
|
|
4103
|
-
},
|
|
4178
|
+
}, Qs = (n, e) => {
|
|
4104
4179
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4105
4180
|
if (!n || typeof n != "string" || n.trim().length === 0) {
|
|
4106
4181
|
a("warn", "identify() called with invalid userId");
|
|
@@ -4119,7 +4194,7 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4119
4194
|
return;
|
|
4120
4195
|
}
|
|
4121
4196
|
try {
|
|
4122
|
-
const t =
|
|
4197
|
+
const t = Ae(e), s = {
|
|
4123
4198
|
userId: n.trim(),
|
|
4124
4199
|
...t ? { traits: t } : {}
|
|
4125
4200
|
};
|
|
@@ -4128,7 +4203,7 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4128
4203
|
a("debug", "Failed to persist pre-init identity");
|
|
4129
4204
|
}
|
|
4130
4205
|
}
|
|
4131
|
-
},
|
|
4206
|
+
}, Ys = async () => {
|
|
4132
4207
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4133
4208
|
if (!f) {
|
|
4134
4209
|
try {
|
|
@@ -4141,31 +4216,31 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4141
4216
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
4142
4217
|
await f.resetIdentity();
|
|
4143
4218
|
}
|
|
4144
|
-
},
|
|
4145
|
-
init:
|
|
4146
|
-
event:
|
|
4147
|
-
on:
|
|
4148
|
-
off:
|
|
4149
|
-
isInitialized:
|
|
4150
|
-
getSessionId:
|
|
4151
|
-
getUserId:
|
|
4152
|
-
destroy:
|
|
4153
|
-
identify:
|
|
4154
|
-
resetIdentity:
|
|
4219
|
+
}, wn = {
|
|
4220
|
+
init: $s,
|
|
4221
|
+
event: Bs,
|
|
4222
|
+
on: Xs,
|
|
4223
|
+
off: Gs,
|
|
4224
|
+
isInitialized: Ws,
|
|
4225
|
+
getSessionId: js,
|
|
4226
|
+
getUserId: Ks,
|
|
4227
|
+
destroy: zs,
|
|
4228
|
+
identify: Qs,
|
|
4229
|
+
resetIdentity: Ys
|
|
4155
4230
|
};
|
|
4156
|
-
var
|
|
4231
|
+
var Le, b, x, ct, ne, lt = -1, N = function(n) {
|
|
4157
4232
|
addEventListener("pageshow", (function(e) {
|
|
4158
|
-
e.persisted && (
|
|
4233
|
+
e.persisted && (lt = e.timeStamp, n(e));
|
|
4159
4234
|
}), !0);
|
|
4160
|
-
},
|
|
4235
|
+
}, Pe = function() {
|
|
4161
4236
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4162
4237
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4163
4238
|
}, ie = function() {
|
|
4164
|
-
var n =
|
|
4239
|
+
var n = Pe();
|
|
4165
4240
|
return n && n.activationStart || 0;
|
|
4166
4241
|
}, E = function(n, e) {
|
|
4167
|
-
var t =
|
|
4168
|
-
return
|
|
4242
|
+
var t = Pe(), s = "navigate";
|
|
4243
|
+
return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || ie() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: n, 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 };
|
|
4169
4244
|
}, U = function(n, e, t) {
|
|
4170
4245
|
try {
|
|
4171
4246
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
@@ -4181,11 +4256,11 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4181
4256
|
}, v = function(n, e, t, s) {
|
|
4182
4257
|
var r, i;
|
|
4183
4258
|
return function(o) {
|
|
4184
|
-
e.value >= 0 && (o || s) && ((i = e.value - (r || 0)) || r === void 0) && (r = e.value, e.delta = i, e.rating = (function(
|
|
4185
|
-
return
|
|
4259
|
+
e.value >= 0 && (o || s) && ((i = e.value - (r || 0)) || r === void 0) && (r = e.value, e.delta = i, e.rating = (function(c, l) {
|
|
4260
|
+
return c > l[1] ? "poor" : c > l[0] ? "needs-improvement" : "good";
|
|
4186
4261
|
})(e.value, t), n(e));
|
|
4187
4262
|
};
|
|
4188
|
-
},
|
|
4263
|
+
}, ke = function(n) {
|
|
4189
4264
|
requestAnimationFrame((function() {
|
|
4190
4265
|
return requestAnimationFrame((function() {
|
|
4191
4266
|
return n();
|
|
@@ -4200,18 +4275,18 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4200
4275
|
return function() {
|
|
4201
4276
|
e || (n(), e = !0);
|
|
4202
4277
|
};
|
|
4203
|
-
}, P = -1,
|
|
4278
|
+
}, P = -1, et = function() {
|
|
4204
4279
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4205
4280
|
}, re = function(n) {
|
|
4206
|
-
document.visibilityState === "hidden" && P > -1 && (P = n.type === "visibilitychange" ? n.timeStamp : 0,
|
|
4207
|
-
},
|
|
4281
|
+
document.visibilityState === "hidden" && P > -1 && (P = n.type === "visibilitychange" ? n.timeStamp : 0, qs());
|
|
4282
|
+
}, tt = function() {
|
|
4208
4283
|
addEventListener("visibilitychange", re, !0), addEventListener("prerenderingchange", re, !0);
|
|
4209
|
-
},
|
|
4284
|
+
}, qs = function() {
|
|
4210
4285
|
removeEventListener("visibilitychange", re, !0), removeEventListener("prerenderingchange", re, !0);
|
|
4211
4286
|
}, De = function() {
|
|
4212
|
-
return P < 0 && (P =
|
|
4287
|
+
return P < 0 && (P = et(), tt(), N((function() {
|
|
4213
4288
|
setTimeout((function() {
|
|
4214
|
-
P =
|
|
4289
|
+
P = et(), tt();
|
|
4215
4290
|
}), 0);
|
|
4216
4291
|
}))), { get firstHiddenTime() {
|
|
4217
4292
|
return P;
|
|
@@ -4220,50 +4295,50 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4220
4295
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4221
4296
|
return n();
|
|
4222
4297
|
}), !0) : n();
|
|
4223
|
-
}, be = [1800, 3e3],
|
|
4298
|
+
}, be = [1800, 3e3], ut = function(n, e) {
|
|
4224
4299
|
e = e || {}, X((function() {
|
|
4225
4300
|
var t, s = De(), r = E("FCP"), i = U("paint", (function(o) {
|
|
4226
|
-
o.forEach((function(
|
|
4227
|
-
|
|
4301
|
+
o.forEach((function(c) {
|
|
4302
|
+
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime - ie(), 0), r.entries.push(c), t(!0)));
|
|
4228
4303
|
}));
|
|
4229
4304
|
}));
|
|
4230
4305
|
i && (t = v(n, r, be, e.reportAllChanges), N((function(o) {
|
|
4231
|
-
r = E("FCP"), t = v(n, r, be, e.reportAllChanges),
|
|
4306
|
+
r = E("FCP"), t = v(n, r, be, e.reportAllChanges), ke((function() {
|
|
4232
4307
|
r.value = performance.now() - o.timeStamp, t(!0);
|
|
4233
4308
|
}));
|
|
4234
4309
|
})));
|
|
4235
4310
|
}));
|
|
4236
|
-
},
|
|
4237
|
-
e = e || {},
|
|
4238
|
-
var t, s = E("CLS", 0), r = 0, i = [], o = function(
|
|
4239
|
-
|
|
4311
|
+
}, Me = [0.1, 0.25], Js = function(n, e) {
|
|
4312
|
+
e = e || {}, ut(oe((function() {
|
|
4313
|
+
var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
|
|
4314
|
+
l.forEach((function(u) {
|
|
4240
4315
|
if (!u.hadRecentInput) {
|
|
4241
4316
|
var h = i[0], p = i[i.length - 1];
|
|
4242
4317
|
r && u.startTime - p.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (r += u.value, i.push(u)) : (r = u.value, i = [u]);
|
|
4243
4318
|
}
|
|
4244
4319
|
})), r > s.value && (s.value = r, s.entries = i, t());
|
|
4245
|
-
},
|
|
4246
|
-
|
|
4247
|
-
o(
|
|
4320
|
+
}, c = U("layout-shift", o);
|
|
4321
|
+
c && (t = v(n, s, Me, e.reportAllChanges), B((function() {
|
|
4322
|
+
o(c.takeRecords()), t(!0);
|
|
4248
4323
|
})), N((function() {
|
|
4249
|
-
r = 0, s = E("CLS", 0), t = v(n, s,
|
|
4324
|
+
r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
|
|
4250
4325
|
return t();
|
|
4251
4326
|
}));
|
|
4252
4327
|
})), setTimeout(t, 0));
|
|
4253
4328
|
})));
|
|
4254
|
-
},
|
|
4329
|
+
}, dt = 0, me = 1 / 0, K = 0, Zs = function(n) {
|
|
4255
4330
|
n.forEach((function(e) {
|
|
4256
|
-
e.interactionId && (
|
|
4331
|
+
e.interactionId && (me = Math.min(me, e.interactionId), K = Math.max(K, e.interactionId), dt = K ? (K - me) / 7 + 1 : 0);
|
|
4257
4332
|
}));
|
|
4258
|
-
},
|
|
4259
|
-
return
|
|
4260
|
-
},
|
|
4261
|
-
"interactionCount" in performance ||
|
|
4262
|
-
}, I = [], q = /* @__PURE__ */ new Map(),
|
|
4263
|
-
var n = Math.min(I.length - 1, Math.floor((
|
|
4333
|
+
}, ht = function() {
|
|
4334
|
+
return Le ? dt : performance.interactionCount || 0;
|
|
4335
|
+
}, en = function() {
|
|
4336
|
+
"interactionCount" in performance || Le || (Le = U("event", Zs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4337
|
+
}, I = [], q = /* @__PURE__ */ new Map(), ft = 0, tn = function() {
|
|
4338
|
+
var n = Math.min(I.length - 1, Math.floor((ht() - ft) / 50));
|
|
4264
4339
|
return I[n];
|
|
4265
|
-
},
|
|
4266
|
-
if (
|
|
4340
|
+
}, sn = [], nn = function(n) {
|
|
4341
|
+
if (sn.forEach((function(r) {
|
|
4267
4342
|
return r(n);
|
|
4268
4343
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4269
4344
|
var e = I[I.length - 1], t = q.get(n.interactionId);
|
|
@@ -4280,152 +4355,152 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4280
4355
|
}));
|
|
4281
4356
|
}
|
|
4282
4357
|
}
|
|
4283
|
-
},
|
|
4358
|
+
}, gt = function(n) {
|
|
4284
4359
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4285
4360
|
return n = oe(n), document.visibilityState === "hidden" ? n() : (t = e(n), B(n)), t;
|
|
4286
|
-
},
|
|
4361
|
+
}, Ce = [200, 500], rn = function(n, e) {
|
|
4287
4362
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, X((function() {
|
|
4288
4363
|
var t;
|
|
4289
|
-
|
|
4290
|
-
var s, r = E("INP"), i = function(
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
var
|
|
4294
|
-
|
|
4364
|
+
en();
|
|
4365
|
+
var s, r = E("INP"), i = function(c) {
|
|
4366
|
+
gt((function() {
|
|
4367
|
+
c.forEach(nn);
|
|
4368
|
+
var l = tn();
|
|
4369
|
+
l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
|
|
4295
4370
|
}));
|
|
4296
4371
|
}, o = U("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4297
|
-
s = v(n, r,
|
|
4372
|
+
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), B((function() {
|
|
4298
4373
|
i(o.takeRecords()), s(!0);
|
|
4299
4374
|
})), N((function() {
|
|
4300
|
-
|
|
4375
|
+
ft = ht(), I.length = 0, q.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
|
|
4301
4376
|
})));
|
|
4302
4377
|
})));
|
|
4303
|
-
}, Re = [2500, 4e3],
|
|
4378
|
+
}, Re = [2500, 4e3], pe = {}, on = function(n, e) {
|
|
4304
4379
|
e = e || {}, X((function() {
|
|
4305
|
-
var t, s = De(), r = E("LCP"), i = function(
|
|
4306
|
-
e.reportAllChanges || (
|
|
4380
|
+
var t, s = De(), r = E("LCP"), i = function(l) {
|
|
4381
|
+
e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
|
|
4307
4382
|
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - ie(), 0), r.entries = [u], t());
|
|
4308
4383
|
}));
|
|
4309
4384
|
}, o = U("largest-contentful-paint", i);
|
|
4310
4385
|
if (o) {
|
|
4311
4386
|
t = v(n, r, Re, e.reportAllChanges);
|
|
4312
|
-
var
|
|
4313
|
-
|
|
4387
|
+
var c = oe((function() {
|
|
4388
|
+
pe[r.id] || (i(o.takeRecords()), o.disconnect(), pe[r.id] = !0, t(!0));
|
|
4314
4389
|
}));
|
|
4315
|
-
["keydown", "click"].forEach((function(
|
|
4316
|
-
addEventListener(
|
|
4317
|
-
return
|
|
4390
|
+
["keydown", "click"].forEach((function(l) {
|
|
4391
|
+
addEventListener(l, (function() {
|
|
4392
|
+
return gt(c);
|
|
4318
4393
|
}), { once: !0, capture: !0 });
|
|
4319
|
-
})), B(
|
|
4320
|
-
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges),
|
|
4321
|
-
r.value = performance.now() -
|
|
4394
|
+
})), B(c), N((function(l) {
|
|
4395
|
+
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
|
|
4396
|
+
r.value = performance.now() - l.timeStamp, pe[r.id] = !0, t(!0);
|
|
4322
4397
|
}));
|
|
4323
4398
|
}));
|
|
4324
4399
|
}
|
|
4325
4400
|
}));
|
|
4326
|
-
},
|
|
4401
|
+
}, Ne = [800, 1800], an = function n(e) {
|
|
4327
4402
|
document.prerendering ? X((function() {
|
|
4328
4403
|
return n(e);
|
|
4329
4404
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4330
4405
|
return n(e);
|
|
4331
4406
|
}), !0) : setTimeout(e, 0);
|
|
4332
|
-
},
|
|
4407
|
+
}, cn = function(n, e) {
|
|
4333
4408
|
e = e || {};
|
|
4334
|
-
var t = E("TTFB"), s = v(n, t,
|
|
4335
|
-
|
|
4336
|
-
var r =
|
|
4409
|
+
var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
|
|
4410
|
+
an((function() {
|
|
4411
|
+
var r = Pe();
|
|
4337
4412
|
r && (t.value = Math.max(r.responseStart - ie(), 0), t.entries = [r], s(!0), N((function() {
|
|
4338
|
-
t = E("TTFB", 0), (s = v(n, t,
|
|
4413
|
+
t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
|
|
4339
4414
|
})));
|
|
4340
4415
|
}));
|
|
4341
|
-
}, H = { passive: !0, capture: !0 },
|
|
4342
|
-
|
|
4343
|
-
},
|
|
4344
|
-
if (x >= 0 && x <
|
|
4345
|
-
var n = { entryType: "first-input", name:
|
|
4416
|
+
}, H = { passive: !0, capture: !0 }, ln = /* @__PURE__ */ new Date(), st = function(n, e) {
|
|
4417
|
+
b || (b = e, x = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
|
|
4418
|
+
}, mt = function() {
|
|
4419
|
+
if (x >= 0 && x < ct - ln) {
|
|
4420
|
+
var n = { entryType: "first-input", name: b.type, target: b.target, cancelable: b.cancelable, startTime: b.timeStamp, processingStart: b.timeStamp + x };
|
|
4346
4421
|
ne.forEach((function(e) {
|
|
4347
4422
|
e(n);
|
|
4348
4423
|
})), ne = [];
|
|
4349
4424
|
}
|
|
4350
|
-
},
|
|
4425
|
+
}, un = function(n) {
|
|
4351
4426
|
if (n.cancelable) {
|
|
4352
4427
|
var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
|
|
4353
4428
|
n.type == "pointerdown" ? (function(t, s) {
|
|
4354
4429
|
var r = function() {
|
|
4355
|
-
|
|
4430
|
+
st(t, s), o();
|
|
4356
4431
|
}, i = function() {
|
|
4357
4432
|
o();
|
|
4358
4433
|
}, o = function() {
|
|
4359
4434
|
removeEventListener("pointerup", r, H), removeEventListener("pointercancel", i, H);
|
|
4360
4435
|
};
|
|
4361
4436
|
addEventListener("pointerup", r, H), addEventListener("pointercancel", i, H);
|
|
4362
|
-
})(e, n) :
|
|
4437
|
+
})(e, n) : st(e, n);
|
|
4363
4438
|
}
|
|
4364
|
-
},
|
|
4439
|
+
}, pt = function(n) {
|
|
4365
4440
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
4366
|
-
return n(e,
|
|
4441
|
+
return n(e, un, H);
|
|
4367
4442
|
}));
|
|
4368
|
-
},
|
|
4443
|
+
}, Oe = [100, 300], dn = function(n, e) {
|
|
4369
4444
|
e = e || {}, X((function() {
|
|
4370
|
-
var t, s = De(), r = E("FID"), i = function(
|
|
4371
|
-
|
|
4372
|
-
}, o = function(
|
|
4373
|
-
|
|
4374
|
-
},
|
|
4375
|
-
t = v(n, r,
|
|
4376
|
-
o(
|
|
4445
|
+
var t, s = De(), r = E("FID"), i = function(l) {
|
|
4446
|
+
l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
|
|
4447
|
+
}, o = function(l) {
|
|
4448
|
+
l.forEach(i);
|
|
4449
|
+
}, c = U("first-input", o);
|
|
4450
|
+
t = v(n, r, Oe, e.reportAllChanges), c && (B(oe((function() {
|
|
4451
|
+
o(c.takeRecords()), c.disconnect();
|
|
4377
4452
|
}))), N((function() {
|
|
4378
|
-
var
|
|
4379
|
-
r = E("FID"), t = v(n, r,
|
|
4453
|
+
var l;
|
|
4454
|
+
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), ne = [], x = -1, b = null, pt(addEventListener), l = i, ne.push(l), mt();
|
|
4380
4455
|
})));
|
|
4381
4456
|
}));
|
|
4382
4457
|
};
|
|
4383
|
-
const
|
|
4458
|
+
const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4384
4459
|
__proto__: null,
|
|
4385
|
-
CLSThresholds:
|
|
4460
|
+
CLSThresholds: Me,
|
|
4386
4461
|
FCPThresholds: be,
|
|
4387
|
-
FIDThresholds:
|
|
4388
|
-
INPThresholds:
|
|
4462
|
+
FIDThresholds: Oe,
|
|
4463
|
+
INPThresholds: Ce,
|
|
4389
4464
|
LCPThresholds: Re,
|
|
4390
|
-
TTFBThresholds:
|
|
4391
|
-
onCLS:
|
|
4392
|
-
onFCP:
|
|
4393
|
-
onFID:
|
|
4394
|
-
onINP:
|
|
4395
|
-
onLCP:
|
|
4396
|
-
onTTFB:
|
|
4465
|
+
TTFBThresholds: Ne,
|
|
4466
|
+
onCLS: Js,
|
|
4467
|
+
onFCP: ut,
|
|
4468
|
+
onFID: dn,
|
|
4469
|
+
onINP: rn,
|
|
4470
|
+
onLCP: on,
|
|
4471
|
+
onTTFB: cn
|
|
4397
4472
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4398
4473
|
export {
|
|
4399
4474
|
m as AppConfigValidationError,
|
|
4400
|
-
|
|
4401
|
-
|
|
4475
|
+
fn as DEFAULT_SESSION_TIMEOUT,
|
|
4476
|
+
_e as DEFAULT_WEB_VITALS_MODE,
|
|
4402
4477
|
w as DeviceType,
|
|
4403
|
-
|
|
4478
|
+
D as EmitterEvent,
|
|
4404
4479
|
V as ErrorType,
|
|
4405
4480
|
d as EventType,
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4481
|
+
yn as InitializationTimeoutError,
|
|
4482
|
+
Xe as IntegrationValidationError,
|
|
4483
|
+
_n as MAX_ARRAY_LENGTH,
|
|
4484
|
+
Sn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4485
|
+
pn as MAX_CUSTOM_EVENT_KEYS,
|
|
4486
|
+
gn as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4487
|
+
mn as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4488
|
+
En as MAX_NESTED_OBJECT_KEYS,
|
|
4489
|
+
vn as MAX_STRING_LENGTH,
|
|
4490
|
+
Tn as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4416
4491
|
ee as Mode,
|
|
4417
|
-
|
|
4492
|
+
as as PII_PATTERNS,
|
|
4418
4493
|
M as PermanentError,
|
|
4419
4494
|
J as RateLimitError,
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4495
|
+
Be as SamplingRateValidationError,
|
|
4496
|
+
Ee as ScrollDirection,
|
|
4497
|
+
At as SessionTimeoutValidationError,
|
|
4423
4498
|
F as SpecialApiUrl,
|
|
4424
4499
|
Z as TimeoutError,
|
|
4425
4500
|
$ as TraceLogValidationError,
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4501
|
+
In as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4502
|
+
ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4503
|
+
Kt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4504
|
+
Qe as getWebVitalsThresholds,
|
|
4505
|
+
wn as tracelog
|
|
4431
4506
|
};
|