@tracelog/lib 2.10.0-rc.113.17 → 3.0.0-rc.115.6
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 +536 -478
- 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 dn = 9e5;
|
|
2
|
+
const hn = 120, fn = 49152, gn = 100, mn = 500, pn = 200;
|
|
3
|
+
const Sn = 1e3, En = 500, vn = 1e3;
|
|
4
|
+
const L = "data-tlog", Et = [
|
|
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
|
+
], vt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], Tt = [
|
|
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
|
+
}, _t = [
|
|
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`, st = "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`, yt = (n) => n ? `${g}:${n}:session` : `${g}:session`, It = (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 wt 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 Tn 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 At = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
124
|
+
const n = new URLSearchParams(window.location.search), e = {};
|
|
125
|
+
return At.forEach((s) => {
|
|
126
|
+
const r = n.get(s);
|
|
127
|
+
r && (e[s] = r);
|
|
128
|
+
}), Object.keys(e).length ? e : void 0;
|
|
129
|
+
}, Lt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", bt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Mt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ct = (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
|
+
}, Rt = () => {
|
|
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 ? Ct(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
158
|
+
if (!Nt(c, i))
|
|
153
159
|
return;
|
|
154
|
-
const p =
|
|
155
|
-
|
|
156
|
-
},
|
|
160
|
+
const p = Ot(c, o), S = r !== void 0 ? ve(r) : void 0;
|
|
161
|
+
Pt(u, l, p, S);
|
|
162
|
+
}, Nt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Rt() : !1, Ot = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Mt : "", Pt = (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, nt;
|
|
180
|
+
const kt = () => {
|
|
181
|
+
typeof window < "u" && !Te && (Te = window.matchMedia("(pointer: coarse)"), nt = window.matchMedia("(hover: none)"));
|
|
182
|
+
}, te = "Unknown", Dt = (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
|
+
}, Ut = (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
|
+
}, Ft = () => {
|
|
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
|
+
kt();
|
|
213
|
+
const e = window.innerWidth, t = Te?.matches ?? !1, s = nt?.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
|
+
}, Vt = () => {
|
|
213
219
|
try {
|
|
214
220
|
const n = navigator;
|
|
215
221
|
return {
|
|
216
|
-
type:
|
|
217
|
-
os:
|
|
218
|
-
browser:
|
|
222
|
+
type: Ft(),
|
|
223
|
+
os: Dt(n),
|
|
224
|
+
browser: Ut(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, Ht = Q * 2, rt = 1, xt = 1e3, $t = 10, Ke = 5e3, Bt = 3, Xt = 200, Gt = 6e4, Wt = 64, _n = {
|
|
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
|
+
}, jt = {
|
|
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 jt;
|
|
253
259
|
default:
|
|
254
|
-
return
|
|
260
|
+
return ze;
|
|
255
261
|
}
|
|
256
|
-
},
|
|
262
|
+
}, Kt = 50, zt = "3.0.0", Qt = zt, Yt = () => typeof window < "u" && typeof sessionStorage < "u", qt = () => {
|
|
257
263
|
try {
|
|
258
264
|
const n = new URLSearchParams(window.location.search);
|
|
259
|
-
n.delete(
|
|
265
|
+
n.delete(st);
|
|
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
|
+
}, Jt = () => {
|
|
271
|
+
if (!Yt())
|
|
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(st), 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: Lt
|
|
279
|
+
})) : e === Fe && (s = !1, sessionStorage.setItem(z, "false"), a("info", "QA Mode DISABLED", {
|
|
274
280
|
visibility: "qa",
|
|
275
|
-
style:
|
|
276
|
-
})), (e ===
|
|
281
|
+
style: bt
|
|
282
|
+
})), (e === Ue || e === Fe) && qt(), s ?? t === "true";
|
|
277
283
|
} catch {
|
|
278
284
|
return !1;
|
|
279
285
|
}
|
|
280
|
-
},
|
|
286
|
+
}, it = () => typeof document < "u" && document.prerendering === !0, Zt = [
|
|
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 Zt.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
304
|
+
}, es = (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 es(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 vt.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
|
+
}, ot = () => 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 ts = () => {
|
|
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
|
+
}, ss = (n) => {
|
|
336
342
|
try {
|
|
337
343
|
return new URL(n).protocol === "https:";
|
|
338
344
|
} catch {
|
|
339
345
|
return !1;
|
|
340
346
|
}
|
|
341
|
-
},
|
|
347
|
+
}, ns = (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 (!ss(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
|
+
}, rs = (n) => {
|
|
366
372
|
const e = {};
|
|
367
|
-
return n.integrations?.tracelog?.projectId && (e.saas =
|
|
368
|
-
},
|
|
373
|
+
return n.integrations?.tracelog?.projectId && (e.saas = ns(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([...Tt, ...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 _t) {
|
|
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
|
+
}, is = (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
|
+
}, os = [
|
|
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 os)
|
|
456
462
|
e = e.replace(t, "[REDACTED]");
|
|
457
463
|
return e;
|
|
458
|
-
},
|
|
464
|
+
}, as = (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 wt(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 && cs(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
|
+
}, cs = (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
|
+
}, ls = (n) => (as(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 ?? rt,
|
|
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
|
+
}, us = (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
|
+
}, ds = (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 = is(e), r = `${t} "${n}" metadata error`;
|
|
580
|
+
if (!us(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
|
+
}, hs = (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
|
+
}, fs = (n, e) => {
|
|
653
|
+
const t = ds(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 = hs(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 gs {
|
|
663
669
|
listeners = /* @__PURE__ */ new Map();
|
|
664
670
|
/**
|
|
665
671
|
* Subscribes to an event channel
|
|
@@ -776,36 +782,36 @@ class ds {
|
|
|
776
782
|
this.listeners.clear();
|
|
777
783
|
}
|
|
778
784
|
}
|
|
779
|
-
const
|
|
780
|
-
function
|
|
781
|
-
return n.replace(
|
|
785
|
+
const ms = /https?:\/\/\S+/g, ps = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Ss = /0x[0-9a-fA-F]{4,}/g, Es = /(?<!\d)\d{4,}(?!\d)/g, vs = /(['"])[^'"]{20,}\1/g;
|
|
786
|
+
function Ts(n) {
|
|
787
|
+
return n.replace(ms, "[URL]").replace(ps, "[ID]").replace(Ss, "[ADDR]").replace(Es, "[N]").replace(vs, "$1[VAR]$1").toLowerCase().trim();
|
|
782
788
|
}
|
|
783
|
-
function
|
|
784
|
-
const e =
|
|
789
|
+
function _s(n) {
|
|
790
|
+
const e = Ts(n.message), t = (n.filename ?? "").trim(), s = t.search(/[?#]/), r = s === -1 ? t : t.slice(0, s), i = n.line == null ? "" : String(n.line);
|
|
785
791
|
return `${e}|${r}|${i}`;
|
|
786
792
|
}
|
|
787
|
-
const
|
|
793
|
+
const ge = { config: {} };
|
|
788
794
|
class T {
|
|
789
795
|
/**
|
|
790
796
|
* Retrieves a value from global state.
|
|
791
797
|
*/
|
|
792
798
|
get(e) {
|
|
793
|
-
return
|
|
799
|
+
return ge[e];
|
|
794
800
|
}
|
|
795
801
|
/**
|
|
796
802
|
* Sets a value in global state.
|
|
797
803
|
*/
|
|
798
804
|
set(e, t) {
|
|
799
|
-
|
|
805
|
+
ge[e] = t;
|
|
800
806
|
}
|
|
801
807
|
/**
|
|
802
808
|
* Returns an immutable snapshot of the entire global state.
|
|
803
809
|
*/
|
|
804
810
|
getState() {
|
|
805
|
-
return { ...
|
|
811
|
+
return { ...ge };
|
|
806
812
|
}
|
|
807
813
|
}
|
|
808
|
-
class
|
|
814
|
+
class ys extends T {
|
|
809
815
|
storeManager;
|
|
810
816
|
apiUrl;
|
|
811
817
|
lastPermanentErrorLog = null;
|
|
@@ -850,12 +856,12 @@ class vs extends T {
|
|
|
850
856
|
* cases so the migration is one-shot per browser.
|
|
851
857
|
*/
|
|
852
858
|
migrateLegacyV2Keys() {
|
|
853
|
-
const e = this.get("userId") || "anonymous", t = `${
|
|
859
|
+
const e = this.get("userId") || "anonymous", t = `${ce(e)}:saas`, s = `${ce(e)}:custom`, r = `${le(e)}:saas`, i = `${le(e)}:custom`;
|
|
854
860
|
try {
|
|
855
861
|
const o = this.storeManager.getItem(t);
|
|
856
862
|
if (o) {
|
|
857
|
-
const
|
|
858
|
-
|
|
863
|
+
const c = this.getQueueStorageKey(), l = this.storeManager.getItem(c);
|
|
864
|
+
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
865
|
}
|
|
860
866
|
} catch (o) {
|
|
861
867
|
a("debug", "Failed to migrate v2 SaaS queue, discarding legacy key", { error: o });
|
|
@@ -878,17 +884,17 @@ class vs extends T {
|
|
|
878
884
|
a("debug", "Legacy or current queue malformed, keeping current only");
|
|
879
885
|
return;
|
|
880
886
|
}
|
|
881
|
-
const o = new Set(i.events.map((u) => u.id)),
|
|
887
|
+
const o = new Set(i.events.map((u) => u.id)), c = [
|
|
882
888
|
...i.events,
|
|
883
889
|
...r.events.filter((u) => typeof u.id == "string" && !o.has(u.id))
|
|
884
|
-
],
|
|
890
|
+
], l = {
|
|
885
891
|
...i,
|
|
886
|
-
events:
|
|
892
|
+
events: c,
|
|
887
893
|
timestamp: typeof i.timestamp == "number" && typeof r.timestamp == "number" ? Math.min(i.timestamp, r.timestamp) : i.timestamp ?? r.timestamp ?? Date.now(),
|
|
888
894
|
recoveryFailures: Math.max(i.recoveryFailures ?? 0, r.recoveryFailures ?? 0) || void 0
|
|
889
895
|
};
|
|
890
|
-
this.storeManager.setItem(e, JSON.stringify(
|
|
891
|
-
data: { added:
|
|
896
|
+
this.storeManager.setItem(e, JSON.stringify(l)), a("debug", "Merged v2 SaaS queue into existing v3 queue", {
|
|
897
|
+
data: { added: c.length - i.events.length, total: c.length }
|
|
892
898
|
});
|
|
893
899
|
} catch (r) {
|
|
894
900
|
a("debug", "Failed to merge legacy queue, keeping current", { error: r });
|
|
@@ -896,11 +902,11 @@ class vs extends T {
|
|
|
896
902
|
}
|
|
897
903
|
getQueueStorageKey() {
|
|
898
904
|
const e = this.get("userId") || "anonymous";
|
|
899
|
-
return
|
|
905
|
+
return ce(e);
|
|
900
906
|
}
|
|
901
907
|
getRateLimitStorageKey() {
|
|
902
908
|
const e = this.get("userId") || "anonymous";
|
|
903
|
-
return
|
|
909
|
+
return le(e);
|
|
904
910
|
}
|
|
905
911
|
getActiveRateLimitKey() {
|
|
906
912
|
return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
|
|
@@ -1051,46 +1057,46 @@ class vs extends T {
|
|
|
1051
1057
|
}
|
|
1052
1058
|
}), !1;
|
|
1053
1059
|
if (this.consecutiveNetworkFailures >= 3) {
|
|
1054
|
-
const
|
|
1055
|
-
if (
|
|
1060
|
+
const c = Date.now() - this.circuitOpenedAt;
|
|
1061
|
+
if (c < 12e4)
|
|
1056
1062
|
return a("debug", "Network circuit open, skipping send", {
|
|
1057
1063
|
data: {
|
|
1058
1064
|
consecutiveNetworkFailures: this.consecutiveNetworkFailures,
|
|
1059
|
-
cooldownRemainingMs: 12e4 -
|
|
1065
|
+
cooldownRemainingMs: 12e4 - c
|
|
1060
1066
|
}
|
|
1061
1067
|
}), !1;
|
|
1062
1068
|
}
|
|
1063
1069
|
const { url: s, payload: r } = this.prepareRequest(t);
|
|
1064
1070
|
let i = !0, o = !1;
|
|
1065
|
-
for (let
|
|
1071
|
+
for (let c = 1; c <= 3; c++)
|
|
1066
1072
|
try {
|
|
1067
|
-
return (await this.sendWithTimeout(s, r)).ok ? (
|
|
1068
|
-
data: { events: t.events.length, attempt:
|
|
1073
|
+
return (await this.sendWithTimeout(s, r)).ok ? (c > 1 && a("info", `Send succeeded after ${c - 1} retry attempt(s)`, {
|
|
1074
|
+
data: { events: t.events.length, attempt: c }
|
|
1069
1075
|
}), 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 (
|
|
1076
|
+
} catch (l) {
|
|
1077
|
+
const u = c === 3;
|
|
1078
|
+
if (l instanceof M)
|
|
1079
|
+
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l;
|
|
1080
|
+
if (l instanceof J) {
|
|
1075
1081
|
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:
|
|
1082
|
+
data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
|
|
1077
1083
|
});
|
|
1078
1084
|
break;
|
|
1079
1085
|
}
|
|
1080
|
-
if (
|
|
1086
|
+
if (l instanceof Z || (i = !1), l instanceof TypeError || (o = !0), a(
|
|
1081
1087
|
u ? "error" : "warn",
|
|
1082
|
-
`Send attempt ${
|
|
1088
|
+
`Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
|
|
1083
1089
|
{
|
|
1084
|
-
error:
|
|
1090
|
+
error: l,
|
|
1085
1091
|
data: {
|
|
1086
1092
|
events: e.events.length,
|
|
1087
1093
|
url: s.replace(/\/\/[^/]+/, "//[DOMAIN]"),
|
|
1088
|
-
attempt:
|
|
1094
|
+
attempt: c,
|
|
1089
1095
|
maxAttempts: 3
|
|
1090
1096
|
}
|
|
1091
1097
|
}
|
|
1092
1098
|
), !u) {
|
|
1093
|
-
await this.backoffDelay(
|
|
1099
|
+
await this.backoffDelay(c);
|
|
1094
1100
|
continue;
|
|
1095
1101
|
}
|
|
1096
1102
|
return i ? (a("debug", "All retry attempts timed out, preserving batch for retry", {
|
|
@@ -1122,8 +1128,8 @@ class vs extends T {
|
|
|
1122
1128
|
});
|
|
1123
1129
|
if (!o.ok) {
|
|
1124
1130
|
if (o.status >= 400 && o.status < 500 && o.status !== 408 && o.status !== 429) {
|
|
1125
|
-
const
|
|
1126
|
-
throw new M(u, o.status,
|
|
1131
|
+
const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
|
|
1132
|
+
throw new M(u, o.status, l);
|
|
1127
1133
|
}
|
|
1128
1134
|
throw o.status === 429 ? new J(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1129
1135
|
}
|
|
@@ -1137,7 +1143,7 @@ class vs extends T {
|
|
|
1137
1143
|
async readTraceLogErrorCode(e) {
|
|
1138
1144
|
try {
|
|
1139
1145
|
const t = await e.clone().json();
|
|
1140
|
-
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <=
|
|
1146
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Wt)
|
|
1141
1147
|
return t.code;
|
|
1142
1148
|
} catch {
|
|
1143
1149
|
}
|
|
@@ -1151,8 +1157,8 @@ class vs extends T {
|
|
|
1151
1157
|
const o = new Blob([i], { type: "application/json" });
|
|
1152
1158
|
if (!this.isSendBeaconAvailable())
|
|
1153
1159
|
return a("warn", "sendBeacon not available, persisting events for recovery"), this.persistEvents(t), !1;
|
|
1154
|
-
const
|
|
1155
|
-
return
|
|
1160
|
+
const c = navigator.sendBeacon(r, o);
|
|
1161
|
+
return c || (a("warn", "sendBeacon rejected request, persisting events for recovery"), this.persistEvents(t)), c;
|
|
1156
1162
|
}
|
|
1157
1163
|
prepareRequest(e) {
|
|
1158
1164
|
let t = Date.now();
|
|
@@ -1164,7 +1170,7 @@ class vs extends T {
|
|
|
1164
1170
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1165
1171
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1166
1172
|
timestamp: t,
|
|
1167
|
-
client_version:
|
|
1173
|
+
client_version: Qt
|
|
1168
1174
|
}
|
|
1169
1175
|
};
|
|
1170
1176
|
return {
|
|
@@ -1208,16 +1214,16 @@ class vs extends T {
|
|
|
1208
1214
|
return !e.timestamp || typeof e.timestamp != "number" ? !1 : (Date.now() - e.timestamp) / (1e3 * 60 * 60) < 2;
|
|
1209
1215
|
}
|
|
1210
1216
|
createRecoveryBody(e) {
|
|
1211
|
-
const { timestamp: t, recoveryFailures: s, ...r } = e, i = r.events ?? [], o = Date.now() - 5184e5,
|
|
1212
|
-
const u = typeof
|
|
1217
|
+
const { timestamp: t, recoveryFailures: s, ...r } = e, i = r.events ?? [], o = Date.now() - 5184e5, c = i.filter((l) => {
|
|
1218
|
+
const u = typeof l.timestamp == "number" ? l.timestamp : new Date(l.timestamp).getTime();
|
|
1213
1219
|
return Number.isFinite(u) && u >= o;
|
|
1214
1220
|
});
|
|
1215
|
-
return
|
|
1221
|
+
return c.length < i.length && a("debug", "Recovery dropped stale events", {
|
|
1216
1222
|
data: {
|
|
1217
|
-
dropped: i.length -
|
|
1218
|
-
kept:
|
|
1223
|
+
dropped: i.length - c.length,
|
|
1224
|
+
kept: c.length
|
|
1219
1225
|
}
|
|
1220
|
-
}), { ...r, events:
|
|
1226
|
+
}), { ...r, events: c };
|
|
1221
1227
|
}
|
|
1222
1228
|
persistEvents(e) {
|
|
1223
1229
|
const t = this.getPersistedData(), s = typeof t?.recoveryFailures == "number" && Number.isFinite(t.recoveryFailures) ? t.recoveryFailures : 0;
|
|
@@ -1227,10 +1233,10 @@ class vs extends T {
|
|
|
1227
1233
|
try {
|
|
1228
1234
|
const r = this.getPersistedData();
|
|
1229
1235
|
if (!s && r && r.timestamp) {
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1236
|
+
const c = Date.now() - r.timestamp;
|
|
1237
|
+
if (c < 1e3)
|
|
1232
1238
|
return a("debug", "Skipping persistence, another tab recently persisted events", {
|
|
1233
|
-
data: { timeSinceExisting:
|
|
1239
|
+
data: { timeSinceExisting: c }
|
|
1234
1240
|
}), !0;
|
|
1235
1241
|
}
|
|
1236
1242
|
const i = {
|
|
@@ -1256,12 +1262,12 @@ class vs extends T {
|
|
|
1256
1262
|
}
|
|
1257
1263
|
logPermanentError(e, t) {
|
|
1258
1264
|
const s = Date.now(), r = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1259
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >=
|
|
1265
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Gt) && (a("error", e, {
|
|
1260
1266
|
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1261
1267
|
}), this.lastPermanentErrorLog = { key: r, timestamp: s });
|
|
1262
1268
|
}
|
|
1263
1269
|
}
|
|
1264
|
-
class
|
|
1270
|
+
class Is extends T {
|
|
1265
1271
|
bootTime;
|
|
1266
1272
|
bootTimestamp;
|
|
1267
1273
|
hasPerformanceNow;
|
|
@@ -1295,8 +1301,8 @@ class Ts extends T {
|
|
|
1295
1301
|
} : { valid: !0 };
|
|
1296
1302
|
}
|
|
1297
1303
|
}
|
|
1298
|
-
const
|
|
1299
|
-
class
|
|
1304
|
+
const ws = new Set(Object.values(d));
|
|
1305
|
+
class As extends T {
|
|
1300
1306
|
dataSenders;
|
|
1301
1307
|
emitter;
|
|
1302
1308
|
timeManager;
|
|
@@ -1328,9 +1334,9 @@ class ys extends T {
|
|
|
1328
1334
|
* @param emitter - Optional event emitter for local event consumption
|
|
1329
1335
|
*/
|
|
1330
1336
|
constructor(e, t = null) {
|
|
1331
|
-
super(), this.emitter = t, this.timeManager = new
|
|
1337
|
+
super(), this.emitter = t, this.timeManager = new Is(), this.dataSenders = [];
|
|
1332
1338
|
const s = this.get("collectApiUrls");
|
|
1333
|
-
s?.saas && this.dataSenders.push(new
|
|
1339
|
+
s?.saas && this.dataSenders.push(new ys(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
|
|
1334
1340
|
this.saveSessionCounts(r);
|
|
1335
1341
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1336
1342
|
}
|
|
@@ -1363,7 +1369,7 @@ class ys extends T {
|
|
|
1363
1369
|
async (t) => t.recoverPersistedEvents({
|
|
1364
1370
|
onSuccess: (s, r, i) => {
|
|
1365
1371
|
if (r && r.length > 0) {
|
|
1366
|
-
const o = r.map((
|
|
1372
|
+
const o = r.map((c) => c.id);
|
|
1367
1373
|
this.removeProcessedEvents(o), i && this.emitEventsQueue(i);
|
|
1368
1374
|
}
|
|
1369
1375
|
},
|
|
@@ -1440,15 +1446,15 @@ class ys extends T {
|
|
|
1440
1446
|
scroll_data: r,
|
|
1441
1447
|
click_data: i,
|
|
1442
1448
|
custom_event: o,
|
|
1443
|
-
web_vitals:
|
|
1444
|
-
error_data:
|
|
1449
|
+
web_vitals: c,
|
|
1450
|
+
error_data: l,
|
|
1445
1451
|
page_view: u
|
|
1446
1452
|
}) {
|
|
1447
1453
|
if (!e) {
|
|
1448
1454
|
a("error", "Event type is required - event will be ignored");
|
|
1449
1455
|
return;
|
|
1450
1456
|
}
|
|
1451
|
-
if (!
|
|
1457
|
+
if (!ws.has(e)) {
|
|
1452
1458
|
a("error", "Invalid event type - event will be ignored", {
|
|
1453
1459
|
data: { type: e }
|
|
1454
1460
|
});
|
|
@@ -1465,8 +1471,8 @@ class ys extends T {
|
|
|
1465
1471
|
scroll_data: r,
|
|
1466
1472
|
click_data: i,
|
|
1467
1473
|
custom_event: o,
|
|
1468
|
-
web_vitals:
|
|
1469
|
-
error_data:
|
|
1474
|
+
web_vitals: c,
|
|
1475
|
+
error_data: l,
|
|
1470
1476
|
page_view: u
|
|
1471
1477
|
});
|
|
1472
1478
|
return;
|
|
@@ -1509,19 +1515,19 @@ class ys extends T {
|
|
|
1509
1515
|
if (!this.checkPerEventRateLimit(o.name, _))
|
|
1510
1516
|
return;
|
|
1511
1517
|
}
|
|
1512
|
-
const
|
|
1518
|
+
const pt = S === d.SESSION_START, St = t || this.get("pageUrl"), G = this.buildEventPayload({
|
|
1513
1519
|
type: S,
|
|
1514
|
-
page_url:
|
|
1520
|
+
page_url: St,
|
|
1515
1521
|
from_page_url: s,
|
|
1516
1522
|
scroll_data: r,
|
|
1517
1523
|
click_data: i,
|
|
1518
1524
|
custom_event: o,
|
|
1519
|
-
web_vitals:
|
|
1520
|
-
error_data:
|
|
1525
|
+
web_vitals: c,
|
|
1526
|
+
error_data: l,
|
|
1521
1527
|
page_view: u
|
|
1522
1528
|
});
|
|
1523
1529
|
if (G && !(!p && !this.shouldSample())) {
|
|
1524
|
-
if (
|
|
1530
|
+
if (pt) {
|
|
1525
1531
|
const _ = this.get("sessionId");
|
|
1526
1532
|
if (!_) {
|
|
1527
1533
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
@@ -1927,7 +1933,7 @@ class ys extends T {
|
|
|
1927
1933
|
), r = await Promise.allSettled(s), i = r.some((o) => this.isSuccessfulResult(o));
|
|
1928
1934
|
if (i) {
|
|
1929
1935
|
this.removeProcessedEvents(t), this.emitEventsQueue(e);
|
|
1930
|
-
const o = r.filter((
|
|
1936
|
+
const o = r.filter((c) => !this.isSuccessfulResult(c)).length;
|
|
1931
1937
|
o > 0 && a("debug", "Async send completed with some failures, removed from queue and persisted per-integration", {
|
|
1932
1938
|
data: { eventCount: t.length, failedCount: o, sessionId: e.session_id }
|
|
1933
1939
|
});
|
|
@@ -1981,14 +1987,14 @@ class ys extends T {
|
|
|
1981
1987
|
const h = this.createEventSignature(u);
|
|
1982
1988
|
s.has(h) || r.push(h), s.set(h, u);
|
|
1983
1989
|
}
|
|
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,
|
|
1990
|
+
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
1991
|
return {
|
|
1986
1992
|
user_id: this.get("userId"),
|
|
1987
1993
|
session_id: e,
|
|
1988
1994
|
device: this.get("device"),
|
|
1989
1995
|
events: i,
|
|
1990
1996
|
...o && { global_metadata: o },
|
|
1991
|
-
...
|
|
1997
|
+
...c && { identify: c }
|
|
1992
1998
|
};
|
|
1993
1999
|
}
|
|
1994
2000
|
buildEventPayload(e) {
|
|
@@ -2002,13 +2008,13 @@ class ys extends T {
|
|
|
2002
2008
|
o.valid || a("warn", "Event timestamp validation failed", {
|
|
2003
2009
|
data: { type: e.type, error: o.error }
|
|
2004
2010
|
});
|
|
2005
|
-
const
|
|
2011
|
+
const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
|
|
2006
2012
|
return { ...{
|
|
2007
|
-
id:
|
|
2013
|
+
id: ts(),
|
|
2008
2014
|
type: e.type,
|
|
2009
2015
|
page_url: r,
|
|
2010
2016
|
timestamp: i,
|
|
2011
|
-
...
|
|
2017
|
+
...c && { referrer: c },
|
|
2012
2018
|
...e.from_page_url && { from_page_url: e.from_page_url },
|
|
2013
2019
|
...e.scroll_data && { scroll_data: e.scroll_data },
|
|
2014
2020
|
...e.click_data && { click_data: e.click_data },
|
|
@@ -2016,7 +2022,8 @@ class ys extends T {
|
|
|
2016
2022
|
...e.web_vitals && { web_vitals: e.web_vitals },
|
|
2017
2023
|
...e.error_data && { error_data: e.error_data },
|
|
2018
2024
|
...e.page_view && { page_view: e.page_view },
|
|
2019
|
-
...
|
|
2025
|
+
...l && { utm: l },
|
|
2026
|
+
...u && { click_ids: u }
|
|
2020
2027
|
}, _session_id: t };
|
|
2021
2028
|
}
|
|
2022
2029
|
isDuplicateEvent(e) {
|
|
@@ -2111,11 +2118,11 @@ class ys extends T {
|
|
|
2111
2118
|
emitEvent(e) {
|
|
2112
2119
|
if (this.emitter) {
|
|
2113
2120
|
const { _session_id: t, ...s } = e;
|
|
2114
|
-
this.emitter.emit(
|
|
2121
|
+
this.emitter.emit(D.EVENT, s);
|
|
2115
2122
|
}
|
|
2116
2123
|
}
|
|
2117
2124
|
emitEventsQueue(e) {
|
|
2118
|
-
this.emitter && this.emitter.emit(
|
|
2125
|
+
this.emitter && this.emitter.emit(D.QUEUE, e);
|
|
2119
2126
|
}
|
|
2120
2127
|
/**
|
|
2121
2128
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2190,13 +2197,13 @@ class ys extends T {
|
|
|
2190
2197
|
loadSessionCounts(e) {
|
|
2191
2198
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
2192
2199
|
return this.getInitialCounts();
|
|
2193
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2200
|
+
const t = this.get("userId") || "anonymous", s = Ve(t, e);
|
|
2194
2201
|
try {
|
|
2195
2202
|
const r = localStorage.getItem(s);
|
|
2196
2203
|
if (!r)
|
|
2197
2204
|
return this.getInitialCounts();
|
|
2198
2205
|
const i = JSON.parse(r);
|
|
2199
|
-
return i._timestamp && Date.now() - i._timestamp >
|
|
2206
|
+
return i._timestamp && Date.now() - i._timestamp > He ? (a("debug", "Session counts expired, clearing", {
|
|
2200
2207
|
data: { sessionId: e, age: Date.now() - i._timestamp }
|
|
2201
2208
|
}), 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
2209
|
total: i.total,
|
|
@@ -2240,12 +2247,12 @@ class ys extends T {
|
|
|
2240
2247
|
cleanupExpiredSessionCounts() {
|
|
2241
2248
|
if (!(typeof window > "u" || typeof localStorage > "u"))
|
|
2242
2249
|
try {
|
|
2243
|
-
const e = localStorage.getItem(
|
|
2250
|
+
const e = localStorage.getItem(xe);
|
|
2244
2251
|
if (e) {
|
|
2245
2252
|
const i = Date.now() - parseInt(e, 10);
|
|
2246
|
-
if (i <
|
|
2253
|
+
if (i < $e) {
|
|
2247
2254
|
a("debug", "Skipping session counts cleanup (throttled)", {
|
|
2248
|
-
data: { timeSinceLastCleanup: i, throttleMs:
|
|
2255
|
+
data: { timeSinceLastCleanup: i, throttleMs: $e }
|
|
2249
2256
|
});
|
|
2250
2257
|
return;
|
|
2251
2258
|
}
|
|
@@ -2255,17 +2262,17 @@ class ys extends T {
|
|
|
2255
2262
|
const o = localStorage.key(i);
|
|
2256
2263
|
if (o?.startsWith(s))
|
|
2257
2264
|
try {
|
|
2258
|
-
const
|
|
2259
|
-
if (
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2265
|
+
const c = localStorage.getItem(o);
|
|
2266
|
+
if (c) {
|
|
2267
|
+
const l = JSON.parse(c);
|
|
2268
|
+
l._timestamp && Date.now() - l._timestamp > He && r.push(o);
|
|
2262
2269
|
}
|
|
2263
2270
|
} catch {
|
|
2264
2271
|
}
|
|
2265
2272
|
}
|
|
2266
2273
|
r.forEach((i) => {
|
|
2267
2274
|
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(
|
|
2275
|
+
}), r.length > 0 && a("info", `Cleaned up ${r.length} expired session counts entries`), localStorage.setItem(xe, Date.now().toString());
|
|
2269
2276
|
} catch (e) {
|
|
2270
2277
|
a("warn", "Failed to cleanup expired session counts", { error: e });
|
|
2271
2278
|
}
|
|
@@ -2299,7 +2306,7 @@ class ys extends T {
|
|
|
2299
2306
|
* @internal
|
|
2300
2307
|
*/
|
|
2301
2308
|
saveSessionCounts(e) {
|
|
2302
|
-
const t = this.get("userId") || "anonymous", s =
|
|
2309
|
+
const t = this.get("userId") || "anonymous", s = Ve(t, e);
|
|
2303
2310
|
try {
|
|
2304
2311
|
const r = {
|
|
2305
2312
|
...this.sessionEventCounts,
|
|
@@ -2315,7 +2322,7 @@ class ys extends T {
|
|
|
2315
2322
|
}
|
|
2316
2323
|
}
|
|
2317
2324
|
}
|
|
2318
|
-
class
|
|
2325
|
+
class Ls {
|
|
2319
2326
|
/**
|
|
2320
2327
|
* Gets or creates a unique user ID.
|
|
2321
2328
|
*
|
|
@@ -2333,15 +2340,15 @@ class Is {
|
|
|
2333
2340
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2334
2341
|
*/
|
|
2335
2342
|
static getId(e) {
|
|
2336
|
-
const t = e.getItem(
|
|
2343
|
+
const t = e.getItem(Se);
|
|
2337
2344
|
if (t)
|
|
2338
2345
|
return t;
|
|
2339
|
-
const s =
|
|
2340
|
-
return e.setItem(
|
|
2346
|
+
const s = ot();
|
|
2347
|
+
return e.setItem(Se, s), s;
|
|
2341
2348
|
}
|
|
2342
2349
|
}
|
|
2343
|
-
const
|
|
2344
|
-
class
|
|
2350
|
+
const bs = /^\d{13}-[a-z0-9]{9}$/;
|
|
2351
|
+
class Ms extends T {
|
|
2345
2352
|
storageManager;
|
|
2346
2353
|
eventManager;
|
|
2347
2354
|
projectId;
|
|
@@ -2351,6 +2358,7 @@ class As extends T {
|
|
|
2351
2358
|
broadcastChannel = null;
|
|
2352
2359
|
isTracking = !1;
|
|
2353
2360
|
needsRenewal = !1;
|
|
2361
|
+
prerenderActivationHandler = null;
|
|
2354
2362
|
/**
|
|
2355
2363
|
* Creates a SessionManager instance.
|
|
2356
2364
|
*
|
|
@@ -2367,9 +2375,14 @@ class As extends T {
|
|
|
2367
2375
|
return;
|
|
2368
2376
|
}
|
|
2369
2377
|
const e = this.getProjectId();
|
|
2370
|
-
this.broadcastChannel = new BroadcastChannel(
|
|
2378
|
+
this.broadcastChannel = new BroadcastChannel(It(e)), this.broadcastChannel.onmessage = (t) => {
|
|
2371
2379
|
const { action: s, sessionId: r, timestamp: i, projectId: o } = t.data ?? {};
|
|
2372
|
-
o === e
|
|
2380
|
+
if (o === e)
|
|
2381
|
+
if (s === "session_start" && r && typeof i == "number" && i > Date.now() - 5e3) {
|
|
2382
|
+
this.set("sessionId", r);
|
|
2383
|
+
const c = this.loadStoredSession();
|
|
2384
|
+
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();
|
|
2385
|
+
} else s && s !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: s } });
|
|
2373
2386
|
};
|
|
2374
2387
|
}
|
|
2375
2388
|
shareSession(e) {
|
|
@@ -2387,19 +2400,20 @@ class As extends T {
|
|
|
2387
2400
|
const e = this.loadStoredSession();
|
|
2388
2401
|
if (!e)
|
|
2389
2402
|
return null;
|
|
2390
|
-
if (!
|
|
2403
|
+
if (!bs.test(e.id))
|
|
2391
2404
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2392
2405
|
data: { sessionId: e.id }
|
|
2393
2406
|
}), this.clearStoredSession(), null;
|
|
2394
2407
|
const t = this.get("config")?.sessionTimeout ?? 9e5;
|
|
2395
2408
|
return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
|
|
2396
2409
|
}
|
|
2397
|
-
persistSession(e, t = Date.now(), s, r) {
|
|
2410
|
+
persistSession(e, t = Date.now(), s, r, i) {
|
|
2398
2411
|
this.saveStoredSession({
|
|
2399
2412
|
id: e,
|
|
2400
2413
|
lastActivity: t,
|
|
2401
2414
|
...s && { referrer: s },
|
|
2402
|
-
...r && { utm: r }
|
|
2415
|
+
...r && { utm: r },
|
|
2416
|
+
...i && { clickIds: i }
|
|
2403
2417
|
});
|
|
2404
2418
|
}
|
|
2405
2419
|
clearStoredSession() {
|
|
@@ -2432,7 +2446,7 @@ class As extends T {
|
|
|
2432
2446
|
this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
|
|
2433
2447
|
}
|
|
2434
2448
|
getSessionStorageKey() {
|
|
2435
|
-
return
|
|
2449
|
+
return yt(this.getProjectId());
|
|
2436
2450
|
}
|
|
2437
2451
|
getProjectId() {
|
|
2438
2452
|
return this.projectId;
|
|
@@ -2471,6 +2485,13 @@ class As extends T {
|
|
|
2471
2485
|
* - Prevents race condition with secondary tabs
|
|
2472
2486
|
* - Ensures secondary tabs can receive session_start message
|
|
2473
2487
|
*
|
|
2488
|
+
* **Pre-rendering**:
|
|
2489
|
+
* - On a pre-rendered page (`document.prerendering === true`), every observable side
|
|
2490
|
+
* effect (persistence, cross-tab sync, SESSION_START, listeners) is deferred to the
|
|
2491
|
+
* `prerenderingchange` activation event via `activateSession()`. `sessionId` is still
|
|
2492
|
+
* set in state synchronously so `init()` returns a real id. A prerender that is never
|
|
2493
|
+
* activated persists and emits nothing.
|
|
2494
|
+
*
|
|
2474
2495
|
* **Called by**: `SessionHandler.startTracking()` during `App.init()`
|
|
2475
2496
|
*
|
|
2476
2497
|
* **Important**: After successful call, `sessionId` is available in global state
|
|
@@ -2495,33 +2516,48 @@ class As extends T {
|
|
|
2495
2516
|
return;
|
|
2496
2517
|
}
|
|
2497
2518
|
const e = this.recoverSession(), t = e ?? this.generateSessionId();
|
|
2498
|
-
let s, r;
|
|
2519
|
+
let s, r, i;
|
|
2499
2520
|
if (e) {
|
|
2500
|
-
const
|
|
2501
|
-
s =
|
|
2521
|
+
const o = this.loadStoredSession();
|
|
2522
|
+
s = o?.referrer ?? he(), r = o?.utm ?? fe(), i = o?.clickIds ?? de();
|
|
2502
2523
|
} else
|
|
2503
|
-
s =
|
|
2524
|
+
s = he(), r = fe(), i = de();
|
|
2504
2525
|
a("debug", "Session tracking initialized", {
|
|
2505
2526
|
data: {
|
|
2506
2527
|
sessionId: t,
|
|
2507
2528
|
wasRecovered: !!e,
|
|
2508
2529
|
willEmitSessionStart: !e,
|
|
2509
2530
|
sessionReferrer: s,
|
|
2510
|
-
hasUtm: !!r
|
|
2531
|
+
hasUtm: !!r,
|
|
2532
|
+
hasClickIds: !!i
|
|
2511
2533
|
}
|
|
2512
2534
|
}), this.isTracking = !0;
|
|
2513
2535
|
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),
|
|
2536
|
+
if (this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", r), this.set("sessionClickIds", i), it()) {
|
|
2537
|
+
this.prerenderActivationHandler = () => {
|
|
2538
|
+
this.prerenderActivationHandler = null, this.activateSession(t, e, s, r, i);
|
|
2539
|
+
}, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 });
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2542
|
+
this.activateSession(t, e, s, r, i);
|
|
2543
|
+
} catch (o) {
|
|
2544
|
+
throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), o;
|
|
2523
2545
|
}
|
|
2524
2546
|
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Commits all observable session side effects: persistence, cross-tab sync, the
|
|
2549
|
+
* SESSION_START emit (new sessions only) and the activity/lifecycle/timeout listeners.
|
|
2550
|
+
*
|
|
2551
|
+
* Runs synchronously on a normal page load. On a pre-rendered page it is deferred to
|
|
2552
|
+
* the `prerenderingchange` (activation) event, so a prerender that is never activated
|
|
2553
|
+
* persists nothing and emits nothing.
|
|
2554
|
+
*
|
|
2555
|
+
* BroadcastChannel is initialized before SESSION_START so secondary tabs can receive
|
|
2556
|
+
* the `session_start` message (avoids a cross-tab race).
|
|
2557
|
+
*/
|
|
2558
|
+
activateSession(e, t, s, r, i) {
|
|
2559
|
+
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();
|
|
2560
|
+
}
|
|
2525
2561
|
generateSessionId() {
|
|
2526
2562
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
2527
2563
|
}
|
|
@@ -2535,7 +2571,13 @@ class As extends T {
|
|
|
2535
2571
|
resetSessionTimeout() {
|
|
2536
2572
|
this.setupSessionTimeout();
|
|
2537
2573
|
const e = this.get("sessionId");
|
|
2538
|
-
e && this.persistSession(
|
|
2574
|
+
e && this.persistSession(
|
|
2575
|
+
e,
|
|
2576
|
+
Date.now(),
|
|
2577
|
+
this.get("sessionReferrer"),
|
|
2578
|
+
this.get("sessionUtm"),
|
|
2579
|
+
this.get("sessionClickIds")
|
|
2580
|
+
);
|
|
2539
2581
|
}
|
|
2540
2582
|
clearSessionTimeout() {
|
|
2541
2583
|
this.sessionTimeoutId && (clearTimeout(this.sessionTimeoutId), this.sessionTimeoutId = null);
|
|
@@ -2551,10 +2593,10 @@ class As extends T {
|
|
|
2551
2593
|
*/
|
|
2552
2594
|
renewSession() {
|
|
2553
2595
|
this.needsRenewal = !1;
|
|
2554
|
-
const e = this.generateSessionId(), t =
|
|
2596
|
+
const e = this.generateSessionId(), t = he(), s = fe(), r = de();
|
|
2555
2597
|
a("debug", "Renewing session after timeout", {
|
|
2556
2598
|
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({
|
|
2599
|
+
}), 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
2600
|
type: d.SESSION_START
|
|
2559
2601
|
}), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
|
|
2560
2602
|
}
|
|
@@ -2596,14 +2638,14 @@ class As extends T {
|
|
|
2596
2638
|
* Called by session timeout timer.
|
|
2597
2639
|
*/
|
|
2598
2640
|
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");
|
|
2641
|
+
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
2642
|
}
|
|
2601
2643
|
/**
|
|
2602
2644
|
* Fully resets session state and cleans up all resources.
|
|
2603
2645
|
* Called by stopTracking() for explicit session termination.
|
|
2604
2646
|
*/
|
|
2605
2647
|
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;
|
|
2648
|
+
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
2649
|
}
|
|
2608
2650
|
/**
|
|
2609
2651
|
* Stops session tracking and cleans up all resources.
|
|
@@ -2669,10 +2711,19 @@ class As extends T {
|
|
|
2669
2711
|
* ```
|
|
2670
2712
|
*/
|
|
2671
2713
|
destroy() {
|
|
2672
|
-
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
2714
|
+
this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.cleanupPrerenderActivation(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
|
|
2715
|
+
}
|
|
2716
|
+
/**
|
|
2717
|
+
* Removes the pending `prerenderingchange` listener when the manager is torn
|
|
2718
|
+
* down before activation (the discarded-prerender case). On the activation path
|
|
2719
|
+
* `{ once: true }` removes the listener and the handler nulls its own reference,
|
|
2720
|
+
* so this is a no-op then.
|
|
2721
|
+
*/
|
|
2722
|
+
cleanupPrerenderActivation() {
|
|
2723
|
+
this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
|
|
2673
2724
|
}
|
|
2674
2725
|
}
|
|
2675
|
-
class
|
|
2726
|
+
class Cs extends T {
|
|
2676
2727
|
eventManager;
|
|
2677
2728
|
storageManager;
|
|
2678
2729
|
sessionManager = null;
|
|
@@ -2707,7 +2758,7 @@ class bs extends T {
|
|
|
2707
2758
|
}
|
|
2708
2759
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2709
2760
|
try {
|
|
2710
|
-
this.sessionManager = new
|
|
2761
|
+
this.sessionManager = new Ms(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2711
2762
|
} catch (s) {
|
|
2712
2763
|
if (this.sessionManager) {
|
|
2713
2764
|
try {
|
|
@@ -2760,7 +2811,7 @@ class bs extends T {
|
|
|
2760
2811
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2761
2812
|
}
|
|
2762
2813
|
}
|
|
2763
|
-
class
|
|
2814
|
+
class Rs extends T {
|
|
2764
2815
|
eventManager;
|
|
2765
2816
|
onTrack;
|
|
2766
2817
|
originalPushState;
|
|
@@ -2800,7 +2851,7 @@ class Ls extends T {
|
|
|
2800
2851
|
};
|
|
2801
2852
|
}
|
|
2802
2853
|
trackCurrentPage = () => {
|
|
2803
|
-
const e = window.location.href, t =
|
|
2854
|
+
const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
|
|
2804
2855
|
if (this.get("pageUrl") === t)
|
|
2805
2856
|
return;
|
|
2806
2857
|
const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2818,7 +2869,7 @@ class Ls extends T {
|
|
|
2818
2869
|
}), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
|
|
2819
2870
|
};
|
|
2820
2871
|
trackInitialPageView() {
|
|
2821
|
-
const e =
|
|
2872
|
+
const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
2822
2873
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
2823
2874
|
type: d.PAGE_VIEW,
|
|
2824
2875
|
page_url: e,
|
|
@@ -2834,7 +2885,7 @@ class Ls extends T {
|
|
|
2834
2885
|
};
|
|
2835
2886
|
}
|
|
2836
2887
|
}
|
|
2837
|
-
class
|
|
2888
|
+
class Ns extends T {
|
|
2838
2889
|
eventManager;
|
|
2839
2890
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
2840
2891
|
clickHandler;
|
|
@@ -2867,7 +2918,7 @@ class Ms extends T {
|
|
|
2867
2918
|
const i = this.get("config")?.clickThrottleMs ?? 300;
|
|
2868
2919
|
if (i > 0 && !this.checkClickThrottle(r, i))
|
|
2869
2920
|
return;
|
|
2870
|
-
const o = this.findTrackingElement(r),
|
|
2921
|
+
const o = this.findTrackingElement(r), c = this.getRelevantClickElement(r), l = this.calculateClickCoordinates(t);
|
|
2871
2922
|
if (o) {
|
|
2872
2923
|
const h = this.extractTrackingData(o);
|
|
2873
2924
|
if (h) {
|
|
@@ -2881,11 +2932,11 @@ class Ms extends T {
|
|
|
2881
2932
|
});
|
|
2882
2933
|
}
|
|
2883
2934
|
}
|
|
2884
|
-
if (!
|
|
2935
|
+
if (!l) {
|
|
2885
2936
|
a("debug", "Click skipped: invalid coordinates (likely synthetic)");
|
|
2886
2937
|
return;
|
|
2887
2938
|
}
|
|
2888
|
-
const u = this.generateClickData(r,
|
|
2939
|
+
const u = this.generateClickData(r, c, l);
|
|
2889
2940
|
this.eventManager.track({
|
|
2890
2941
|
type: d.CLICK,
|
|
2891
2942
|
click_data: u
|
|
@@ -2902,7 +2953,7 @@ class Ms extends T {
|
|
|
2902
2953
|
this.clickHandler && (window.removeEventListener("click", this.clickHandler, !0), this.clickHandler = void 0), this.lastClickTimes.clear(), this.lastPruneTime = 0;
|
|
2903
2954
|
}
|
|
2904
2955
|
shouldIgnoreElement(e) {
|
|
2905
|
-
return e.hasAttribute(`${
|
|
2956
|
+
return e.hasAttribute(`${L}-ignore`) ? !0 : e.closest(`[${L}-ignore]`) !== null;
|
|
2906
2957
|
}
|
|
2907
2958
|
/**
|
|
2908
2959
|
* Checks per-element click throttling to prevent double-clicks and rapid spam
|
|
@@ -2932,7 +2983,7 @@ class Ms extends T {
|
|
|
2932
2983
|
for (const [s, r] of this.lastClickTimes.entries())
|
|
2933
2984
|
r < t && this.lastClickTimes.delete(s);
|
|
2934
2985
|
if (this.lastClickTimes.size > 1e3) {
|
|
2935
|
-
const s = Array.from(this.lastClickTimes.entries()).sort((o,
|
|
2986
|
+
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
2987
|
for (const [o] of i)
|
|
2937
2988
|
this.lastClickTimes.delete(o);
|
|
2938
2989
|
a("debug", "ClickHandler: Pruned throttle cache", {
|
|
@@ -2953,8 +3004,8 @@ class Ms extends T {
|
|
|
2953
3004
|
const t = e.getAttribute("data-testid");
|
|
2954
3005
|
if (t)
|
|
2955
3006
|
return `[data-testid="${t}"]`;
|
|
2956
|
-
const s = e.getAttribute(`${
|
|
2957
|
-
return s ? `[${
|
|
3007
|
+
const s = e.getAttribute(`${L}-name`);
|
|
3008
|
+
return s ? `[${L}-name="${s}"]` : this.getElementPath(e);
|
|
2958
3009
|
}
|
|
2959
3010
|
/**
|
|
2960
3011
|
* Generates a DOM path for an element (e.g., "body>div>button")
|
|
@@ -2973,10 +3024,10 @@ class Ms extends T {
|
|
|
2973
3024
|
return t.join(">") || "unknown";
|
|
2974
3025
|
}
|
|
2975
3026
|
findTrackingElement(e) {
|
|
2976
|
-
return e.hasAttribute(`${
|
|
3027
|
+
return e.hasAttribute(`${L}-name`) ? e : e.closest(`[${L}-name]`);
|
|
2977
3028
|
}
|
|
2978
3029
|
getRelevantClickElement(e) {
|
|
2979
|
-
for (const t of
|
|
3030
|
+
for (const t of Et)
|
|
2980
3031
|
try {
|
|
2981
3032
|
if (e.matches(t))
|
|
2982
3033
|
return e;
|
|
@@ -2994,7 +3045,7 @@ class Ms extends T {
|
|
|
2994
3045
|
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
3046
|
}
|
|
2996
3047
|
extractTrackingData(e) {
|
|
2997
|
-
const t = e.getAttribute(`${
|
|
3048
|
+
const t = e.getAttribute(`${L}-name`), s = e.getAttribute(`${L}-value`);
|
|
2998
3049
|
if (t)
|
|
2999
3050
|
return {
|
|
3000
3051
|
element: e,
|
|
@@ -3003,7 +3054,7 @@ class Ms extends T {
|
|
|
3003
3054
|
};
|
|
3004
3055
|
}
|
|
3005
3056
|
generateClickData(e, t, s) {
|
|
3006
|
-
const { x: r, y: i } = s, o = this.getRelevantText(e, t),
|
|
3057
|
+
const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href") ?? void 0;
|
|
3007
3058
|
return {
|
|
3008
3059
|
x: r,
|
|
3009
3060
|
y: i,
|
|
@@ -3011,7 +3062,7 @@ class Ms extends T {
|
|
|
3011
3062
|
...t.id && { id: t.id },
|
|
3012
3063
|
...t.className && { class: t.className },
|
|
3013
3064
|
...o && { text: o },
|
|
3014
|
-
...
|
|
3065
|
+
...c && { href: c }
|
|
3015
3066
|
};
|
|
3016
3067
|
}
|
|
3017
3068
|
getRelevantText(e, t) {
|
|
@@ -3028,7 +3079,7 @@ class Ms extends T {
|
|
|
3028
3079
|
};
|
|
3029
3080
|
}
|
|
3030
3081
|
}
|
|
3031
|
-
class
|
|
3082
|
+
class Os extends T {
|
|
3032
3083
|
eventManager;
|
|
3033
3084
|
containers = [];
|
|
3034
3085
|
limitWarningLogged = !1;
|
|
@@ -3095,7 +3146,7 @@ class Rs extends T {
|
|
|
3095
3146
|
return t.tagName.toLowerCase();
|
|
3096
3147
|
}
|
|
3097
3148
|
setupScrollContainer(e, t) {
|
|
3098
|
-
if (this.containers.some((
|
|
3149
|
+
if (this.containers.some((l) => l.element === e) || e !== window && !this.isElementScrollable(e))
|
|
3099
3150
|
return;
|
|
3100
3151
|
const r = this.getScrollTop(e), i = this.calculateScrollDepth(
|
|
3101
3152
|
r,
|
|
@@ -3109,13 +3160,13 @@ class Rs extends T {
|
|
|
3109
3160
|
lastEventTime: 0,
|
|
3110
3161
|
debounceTimer: null,
|
|
3111
3162
|
listener: null
|
|
3112
|
-
},
|
|
3163
|
+
}, c = () => {
|
|
3113
3164
|
this.get("suppressNextScroll") || (this.clearContainerTimer(o), o.debounceTimer = window.setTimeout(() => {
|
|
3114
|
-
const
|
|
3115
|
-
|
|
3165
|
+
const l = this.calculateScrollData(o);
|
|
3166
|
+
l && this.processScrollEvent(o, l, Date.now()), o.debounceTimer = null;
|
|
3116
3167
|
}, 250));
|
|
3117
3168
|
};
|
|
3118
|
-
o.listener =
|
|
3169
|
+
o.listener = c, this.containers.push(o), e === window ? window.addEventListener("scroll", c, { passive: !0 }) : e.addEventListener("scroll", c, { passive: !0 });
|
|
3119
3170
|
}
|
|
3120
3171
|
processScrollEvent(e, t, s) {
|
|
3121
3172
|
if (!this.shouldEmitScrollEvent(e, t, s))
|
|
@@ -3154,7 +3205,7 @@ class Rs extends T {
|
|
|
3154
3205
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3155
3206
|
}
|
|
3156
3207
|
getScrollDirection(e, t) {
|
|
3157
|
-
return e > t ?
|
|
3208
|
+
return e > t ? Ee.DOWN : Ee.UP;
|
|
3158
3209
|
}
|
|
3159
3210
|
calculateScrollDepth(e, t, s) {
|
|
3160
3211
|
if (t <= s)
|
|
@@ -3166,8 +3217,8 @@ class Rs extends T {
|
|
|
3166
3217
|
const { element: t, lastScrollPos: s } = e, r = this.getScrollTop(t);
|
|
3167
3218
|
if (Math.abs(r - s) < 10 || t === window && !this.isWindowScrollable())
|
|
3168
3219
|
return null;
|
|
3169
|
-
const o = this.getViewportHeight(t),
|
|
3170
|
-
return e.lastScrollPos = r, { depth: u, direction:
|
|
3220
|
+
const o = this.getViewportHeight(t), c = this.getScrollHeight(t), l = this.getScrollDirection(r, s), u = this.calculateScrollDepth(r, c, o);
|
|
3221
|
+
return e.lastScrollPos = r, { depth: u, direction: l };
|
|
3171
3222
|
}
|
|
3172
3223
|
getScrollTop(e) {
|
|
3173
3224
|
return e === window ? window.scrollY : e.scrollTop;
|
|
@@ -3183,8 +3234,8 @@ class Rs extends T {
|
|
|
3183
3234
|
return s && r;
|
|
3184
3235
|
}
|
|
3185
3236
|
}
|
|
3186
|
-
const
|
|
3187
|
-
class
|
|
3237
|
+
const Ps = "tracelog_session_id", ks = "tracelog_user_id";
|
|
3238
|
+
class Ds extends T {
|
|
3188
3239
|
visibilityHandler = null;
|
|
3189
3240
|
pageshowHandler = null;
|
|
3190
3241
|
lastSyncedKey = null;
|
|
@@ -3205,8 +3256,8 @@ class Os extends T {
|
|
|
3205
3256
|
r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
|
|
3206
3257
|
}
|
|
3207
3258
|
postCartUpdate(e, t) {
|
|
3208
|
-
const s = { [
|
|
3209
|
-
t.length > 0 && (s[
|
|
3259
|
+
const s = { [Ps]: e };
|
|
3260
|
+
t.length > 0 && (s[ks] = t);
|
|
3210
3261
|
try {
|
|
3211
3262
|
fetch("/cart/update.js", {
|
|
3212
3263
|
method: "POST",
|
|
@@ -3243,7 +3294,7 @@ class Os extends T {
|
|
|
3243
3294
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
|
|
3244
3295
|
}
|
|
3245
3296
|
}
|
|
3246
|
-
class
|
|
3297
|
+
class Us {
|
|
3247
3298
|
storage;
|
|
3248
3299
|
sessionStorageRef;
|
|
3249
3300
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3304,7 +3355,7 @@ class Ps {
|
|
|
3304
3355
|
const e = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], t = [], s = [];
|
|
3305
3356
|
for (let i = 0; i < this.storage.length; i++) {
|
|
3306
3357
|
const o = this.storage.key(i);
|
|
3307
|
-
o?.startsWith("tracelog_") && (o.startsWith("tracelog_persisted_events_") ? t.push(o) : e.some((
|
|
3358
|
+
o?.startsWith("tracelog_") && (o.startsWith("tracelog_persisted_events_") ? t.push(o) : e.some((c) => o.startsWith(c)) || s.push(o));
|
|
3308
3359
|
}
|
|
3309
3360
|
const r = [...t, ...s.slice(0, 5)];
|
|
3310
3361
|
return r.length === 0 ? !1 : (r.forEach((i) => {
|
|
@@ -3356,7 +3407,7 @@ class Ps {
|
|
|
3356
3407
|
this.fallbackSessionStorage.delete(e);
|
|
3357
3408
|
}
|
|
3358
3409
|
}
|
|
3359
|
-
class
|
|
3410
|
+
class Fs extends T {
|
|
3360
3411
|
eventManager;
|
|
3361
3412
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3362
3413
|
navigationHistory = [];
|
|
@@ -3366,7 +3417,7 @@ class Ds extends T {
|
|
|
3366
3417
|
navigationCounter = 0;
|
|
3367
3418
|
// Counter for handling simultaneous navigations edge case
|
|
3368
3419
|
constructor(e) {
|
|
3369
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
3420
|
+
super(), this.eventManager = e, this.vitalThresholds = Qe(_e);
|
|
3370
3421
|
}
|
|
3371
3422
|
/**
|
|
3372
3423
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3382,8 +3433,8 @@ class Ds extends T {
|
|
|
3382
3433
|
* @returns Promise that resolves when tracking is initialized
|
|
3383
3434
|
*/
|
|
3384
3435
|
async startTracking() {
|
|
3385
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
3386
|
-
this.vitalThresholds =
|
|
3436
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? _e;
|
|
3437
|
+
this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
|
|
3387
3438
|
}
|
|
3388
3439
|
/**
|
|
3389
3440
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -3423,8 +3474,8 @@ class Ds extends T {
|
|
|
3423
3474
|
for (const o of i) {
|
|
3424
3475
|
if (o.hadRecentInput === !0)
|
|
3425
3476
|
continue;
|
|
3426
|
-
const
|
|
3427
|
-
e +=
|
|
3477
|
+
const c = typeof o.value == "number" ? o.value : 0;
|
|
3478
|
+
e += c;
|
|
3428
3479
|
}
|
|
3429
3480
|
this.sendVital({ type: "CLS", value: Number(e.toFixed(2)) });
|
|
3430
3481
|
},
|
|
@@ -3443,8 +3494,8 @@ class Ds extends T {
|
|
|
3443
3494
|
let r = 0;
|
|
3444
3495
|
const i = s.getEntries();
|
|
3445
3496
|
for (const o of i) {
|
|
3446
|
-
const
|
|
3447
|
-
r = Math.max(r,
|
|
3497
|
+
const c = (o.processingEnd ?? 0) - (o.startTime ?? 0);
|
|
3498
|
+
r = Math.max(r, c);
|
|
3448
3499
|
}
|
|
3449
3500
|
r > 0 && this.sendVital({ type: "INP", value: Number(r.toFixed(2)) });
|
|
3450
3501
|
},
|
|
@@ -3453,9 +3504,9 @@ class Ds extends T {
|
|
|
3453
3504
|
}
|
|
3454
3505
|
async initWebVitals() {
|
|
3455
3506
|
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:
|
|
3507
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => un), o = (c) => (l) => {
|
|
3508
|
+
const u = Number(l.value.toFixed(2));
|
|
3509
|
+
this.sendVital({ type: c, value: u });
|
|
3459
3510
|
};
|
|
3460
3511
|
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
3512
|
} catch (e) {
|
|
@@ -3483,7 +3534,7 @@ class Ds extends T {
|
|
|
3483
3534
|
return;
|
|
3484
3535
|
if (s)
|
|
3485
3536
|
s.add(e.type);
|
|
3486
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
3537
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Kt) {
|
|
3487
3538
|
const i = this.navigationHistory.shift();
|
|
3488
3539
|
i && this.reportedByNav.delete(i);
|
|
3489
3540
|
}
|
|
@@ -3544,18 +3595,18 @@ class Ds extends T {
|
|
|
3544
3595
|
try {
|
|
3545
3596
|
if (!this.isObserverSupported(e))
|
|
3546
3597
|
return !1;
|
|
3547
|
-
const i = new PerformanceObserver((o,
|
|
3598
|
+
const i = new PerformanceObserver((o, c) => {
|
|
3548
3599
|
try {
|
|
3549
|
-
t(o,
|
|
3550
|
-
} catch (
|
|
3600
|
+
t(o, c);
|
|
3601
|
+
} catch (l) {
|
|
3551
3602
|
a("debug", "Observer callback failed", {
|
|
3552
|
-
error:
|
|
3603
|
+
error: l,
|
|
3553
3604
|
data: { type: e }
|
|
3554
3605
|
});
|
|
3555
3606
|
}
|
|
3556
3607
|
if (r)
|
|
3557
3608
|
try {
|
|
3558
|
-
|
|
3609
|
+
c.disconnect();
|
|
3559
3610
|
} catch {
|
|
3560
3611
|
}
|
|
3561
3612
|
});
|
|
@@ -3601,7 +3652,7 @@ class se extends T {
|
|
|
3601
3652
|
this.resetPageviewCounter();
|
|
3602
3653
|
}, window.addEventListener("pagehide", this.pagehideHandler, { passive: !0 }), this.emitter && (this.pageviewResetListener = (e) => {
|
|
3603
3654
|
(e.type === d.SESSION_START || e.type === d.PAGE_VIEW) && this.resetPageviewCounter();
|
|
3604
|
-
}, this.emitter.on(
|
|
3655
|
+
}, this.emitter.on(D.EVENT, this.pageviewResetListener));
|
|
3605
3656
|
}
|
|
3606
3657
|
/**
|
|
3607
3658
|
* Stops tracking errors and cleans up resources.
|
|
@@ -3612,7 +3663,7 @@ class se extends T {
|
|
|
3612
3663
|
* - Resets burst detection counters
|
|
3613
3664
|
*/
|
|
3614
3665
|
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(
|
|
3666
|
+
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
3667
|
}
|
|
3617
3668
|
/**
|
|
3618
3669
|
* Clears the per-pageview signature counter.
|
|
@@ -3631,14 +3682,14 @@ class se extends T {
|
|
|
3631
3682
|
const e = Date.now();
|
|
3632
3683
|
if (e < this.burstBackoffUntil)
|
|
3633
3684
|
return !1;
|
|
3634
|
-
if (e - this.burstWindowStart >
|
|
3635
|
-
return this.burstBackoffUntil = e +
|
|
3685
|
+
if (e - this.burstWindowStart > xt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > $t)
|
|
3686
|
+
return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
|
|
3636
3687
|
data: {
|
|
3637
3688
|
errorsInWindow: this.errorBurstCounter,
|
|
3638
|
-
cooldownMs:
|
|
3689
|
+
cooldownMs: Ke
|
|
3639
3690
|
}
|
|
3640
3691
|
}), !1;
|
|
3641
|
-
const s = this.get("config").errorSampling ??
|
|
3692
|
+
const s = this.get("config").errorSampling ?? rt;
|
|
3642
3693
|
return Math.random() < s;
|
|
3643
3694
|
}
|
|
3644
3695
|
/**
|
|
@@ -3648,17 +3699,17 @@ class se extends T {
|
|
|
3648
3699
|
* later signature that recycles the same map key after a counter reset.
|
|
3649
3700
|
*/
|
|
3650
3701
|
shouldThrottleBySignature(e) {
|
|
3651
|
-
const t =
|
|
3702
|
+
const t = _s({
|
|
3652
3703
|
message: e.message,
|
|
3653
3704
|
filename: e.filename,
|
|
3654
3705
|
line: e.line
|
|
3655
3706
|
}), s = this.pageviewSignatureCounts.get(t) ?? 0;
|
|
3656
|
-
if (s >=
|
|
3707
|
+
if (s >= Bt)
|
|
3657
3708
|
return a("debug", "Error throttled (pageview cap)", {
|
|
3658
3709
|
data: { signature: t, count: s }
|
|
3659
3710
|
}), !0;
|
|
3660
3711
|
const r = s + 1;
|
|
3661
|
-
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size >
|
|
3712
|
+
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Xt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
|
|
3662
3713
|
}
|
|
3663
3714
|
handleError = (e) => {
|
|
3664
3715
|
if (!this.shouldSample())
|
|
@@ -3715,24 +3766,24 @@ class se extends T {
|
|
|
3715
3766
|
}
|
|
3716
3767
|
}
|
|
3717
3768
|
sanitize(e) {
|
|
3718
|
-
const t = e.length >
|
|
3769
|
+
const t = e.length > Ge ? e.slice(0, Ge) + "..." : e;
|
|
3719
3770
|
return Y(t);
|
|
3720
3771
|
}
|
|
3721
3772
|
shouldSuppressError(e, t) {
|
|
3722
3773
|
const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
|
|
3723
|
-
return i !== void 0 && s - i <
|
|
3774
|
+
return i !== void 0 && s - i < je ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > Ht ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > Q && this.pruneOldErrors(), !1));
|
|
3724
3775
|
}
|
|
3725
3776
|
static TRUNCATION_SUFFIX = `
|
|
3726
3777
|
...truncated`;
|
|
3727
3778
|
truncateStack(e) {
|
|
3728
|
-
if (e.length <=
|
|
3729
|
-
const t =
|
|
3779
|
+
if (e.length <= We) return Y(e);
|
|
3780
|
+
const t = We - se.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + se.TRUNCATION_SUFFIX;
|
|
3730
3781
|
return Y(s);
|
|
3731
3782
|
}
|
|
3732
3783
|
pruneOldErrors() {
|
|
3733
3784
|
const e = Date.now();
|
|
3734
3785
|
for (const [r, i] of this.recentErrors.entries())
|
|
3735
|
-
e - i >
|
|
3786
|
+
e - i > je && this.recentErrors.delete(r);
|
|
3736
3787
|
if (this.recentErrors.size <= Q)
|
|
3737
3788
|
return;
|
|
3738
3789
|
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - Q;
|
|
@@ -3742,13 +3793,14 @@ class se extends T {
|
|
|
3742
3793
|
}
|
|
3743
3794
|
}
|
|
3744
3795
|
}
|
|
3745
|
-
class
|
|
3796
|
+
class Vs extends T {
|
|
3746
3797
|
isInitialized = !1;
|
|
3747
3798
|
suppressNextScrollTimer = null;
|
|
3748
3799
|
pageUnloadHandler = null;
|
|
3749
3800
|
pageShowHandler = null;
|
|
3750
3801
|
visibilityFlushHandler = null;
|
|
3751
|
-
|
|
3802
|
+
prerenderActivationHandler = null;
|
|
3803
|
+
emitter = new gs();
|
|
3752
3804
|
managers = {};
|
|
3753
3805
|
handlers = {};
|
|
3754
3806
|
integrationInstances = {};
|
|
@@ -3763,9 +3815,9 @@ class ks extends T {
|
|
|
3763
3815
|
async init(e = {}) {
|
|
3764
3816
|
if (this.isInitialized)
|
|
3765
3817
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
3766
|
-
this.managers.storage = new
|
|
3818
|
+
this.managers.storage = new Us();
|
|
3767
3819
|
try {
|
|
3768
|
-
return this.setupState(e), this.managers.event = new
|
|
3820
|
+
return this.setupState(e), this.managers.event = new As(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
3769
3821
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
3770
3822
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
3771
3823
|
} catch (t) {
|
|
@@ -3786,7 +3838,7 @@ class ks extends T {
|
|
|
3786
3838
|
}
|
|
3787
3839
|
let r = t;
|
|
3788
3840
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
3789
|
-
const { valid: i, error: o, sanitizedMetadata:
|
|
3841
|
+
const { valid: i, error: o, sanitizedMetadata: c } = fs(e, r);
|
|
3790
3842
|
if (!i) {
|
|
3791
3843
|
if (this.get("mode") === ee.QA)
|
|
3792
3844
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
|
|
@@ -3797,7 +3849,7 @@ class ks extends T {
|
|
|
3797
3849
|
type: d.CUSTOM,
|
|
3798
3850
|
custom_event: {
|
|
3799
3851
|
name: e,
|
|
3800
|
-
...
|
|
3852
|
+
...c && { metadata: c }
|
|
3801
3853
|
}
|
|
3802
3854
|
}), s?.critical === !0 && (this.managers.event.flushImmediatelySync() || a("debug", "Critical event flush returned false (deferred to in-flight send or empty queue)", {
|
|
3803
3855
|
data: { name: e }
|
|
@@ -3821,18 +3873,18 @@ class ks extends T {
|
|
|
3821
3873
|
} catch (s) {
|
|
3822
3874
|
a("warn", "Failed to stop tracking", { error: s });
|
|
3823
3875
|
}
|
|
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 = {});
|
|
3876
|
+
}), 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
3877
|
}
|
|
3826
3878
|
setupState(e = {}) {
|
|
3827
3879
|
this.set("config", e);
|
|
3828
|
-
const t =
|
|
3880
|
+
const t = Ls.getId(this.managers.storage);
|
|
3829
3881
|
this.set("userId", t);
|
|
3830
|
-
const s =
|
|
3882
|
+
const s = rs(e);
|
|
3831
3883
|
this.set("collectApiUrls", s);
|
|
3832
|
-
const r =
|
|
3884
|
+
const r = Vt();
|
|
3833
3885
|
this.set("device", r);
|
|
3834
|
-
const i =
|
|
3835
|
-
this.set("pageUrl", i),
|
|
3886
|
+
const i = ye(window.location.href, e.sensitiveQueryParams);
|
|
3887
|
+
this.set("pageUrl", i), Jt() && this.set("mode", ee.QA);
|
|
3836
3888
|
}
|
|
3837
3889
|
/**
|
|
3838
3890
|
* @internal Used by api.ts for configuration access
|
|
@@ -3887,7 +3939,7 @@ class ks extends T {
|
|
|
3887
3939
|
a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
|
|
3888
3940
|
return;
|
|
3889
3941
|
}
|
|
3890
|
-
const s = e.trim(), r =
|
|
3942
|
+
const s = e.trim(), r = Ae(t), i = {
|
|
3891
3943
|
userId: s,
|
|
3892
3944
|
...r ? { traits: r } : {}
|
|
3893
3945
|
};
|
|
@@ -3910,8 +3962,8 @@ class ks extends T {
|
|
|
3910
3962
|
*/
|
|
3911
3963
|
async resetIdentity() {
|
|
3912
3964
|
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(
|
|
3965
|
+
const e = ot();
|
|
3966
|
+
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
3967
|
}
|
|
3916
3968
|
/**
|
|
3917
3969
|
* Returns the project ID used for identity storage scoping.
|
|
@@ -3983,7 +4035,7 @@ class ks extends T {
|
|
|
3983
4035
|
* localStorage values.
|
|
3984
4036
|
*/
|
|
3985
4037
|
normalizePersistedIdentity(e) {
|
|
3986
|
-
const t =
|
|
4038
|
+
const t = Ae(e.traits);
|
|
3987
4039
|
return {
|
|
3988
4040
|
userId: e.userId.trim(),
|
|
3989
4041
|
...t ? { traits: t } : {}
|
|
@@ -4013,7 +4065,7 @@ class ks extends T {
|
|
|
4013
4065
|
}
|
|
4014
4066
|
initializeHandlers() {
|
|
4015
4067
|
const e = this.get("config");
|
|
4016
|
-
this.handlers.session = new
|
|
4068
|
+
this.handlers.session = new Cs(
|
|
4017
4069
|
this.managers.storage,
|
|
4018
4070
|
this.managers.event
|
|
4019
4071
|
), this.handlers.session.startTracking();
|
|
@@ -4022,28 +4074,34 @@ class ks extends T {
|
|
|
4022
4074
|
this.set("suppressNextScroll", !1);
|
|
4023
4075
|
}, 500);
|
|
4024
4076
|
};
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
r
|
|
4031
|
-
|
|
4032
|
-
|
|
4077
|
+
this.handlers.pageView = new Rs(this.managers.event, t), this.handlers.click = new Ns(this.managers.event), this.handlers.scroll = new Os(this.managers.event), this.handlers.performance = new Fs(this.managers.event), this.handlers.error = new se(this.managers.event, this.emitter);
|
|
4078
|
+
const s = () => {
|
|
4079
|
+
if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
|
|
4080
|
+
a("warn", "Failed to start performance tracking", { error: r });
|
|
4081
|
+
}), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
|
|
4082
|
+
const r = new Ds();
|
|
4083
|
+
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(D.EVENT, (i) => {
|
|
4084
|
+
i.type === d.SESSION_START && r.onSessionChange();
|
|
4085
|
+
});
|
|
4086
|
+
}
|
|
4087
|
+
};
|
|
4088
|
+
it() ? (this.prerenderActivationHandler = () => {
|
|
4089
|
+
this.prerenderActivationHandler = null, s();
|
|
4090
|
+
}, document.addEventListener("prerenderingchange", this.prerenderActivationHandler, { once: !0 })) : s();
|
|
4033
4091
|
}
|
|
4034
4092
|
}
|
|
4035
|
-
const
|
|
4036
|
-
let f = null,
|
|
4037
|
-
const
|
|
4093
|
+
const R = [];
|
|
4094
|
+
let f = null, k = !1, A = !1, C = null;
|
|
4095
|
+
const Hs = 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
4096
|
try {
|
|
4039
|
-
const e =
|
|
4097
|
+
const e = ls(n ?? {}), t = new Vs();
|
|
4040
4098
|
try {
|
|
4041
|
-
|
|
4042
|
-
t.on(o,
|
|
4043
|
-
}),
|
|
4044
|
-
const s = t.init(e), r = new Promise((o,
|
|
4099
|
+
R.forEach(({ event: o, callback: c }) => {
|
|
4100
|
+
t.on(o, c);
|
|
4101
|
+
}), R.length = 0;
|
|
4102
|
+
const s = t.init(e), r = new Promise((o, c) => {
|
|
4045
4103
|
setTimeout(() => {
|
|
4046
|
-
|
|
4104
|
+
c(new Error("[TraceLog] Initialization timeout after 10000ms"));
|
|
4047
4105
|
}, 1e4);
|
|
4048
4106
|
}), i = await Promise.race([s, r]);
|
|
4049
4107
|
return f = t, i;
|
|
@@ -4058,9 +4116,9 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4058
4116
|
} catch (e) {
|
|
4059
4117
|
throw f = null, e;
|
|
4060
4118
|
} finally {
|
|
4061
|
-
|
|
4119
|
+
k = !1, C = null;
|
|
4062
4120
|
}
|
|
4063
|
-
})()),
|
|
4121
|
+
})()), C)), xs = (n, e, t) => {
|
|
4064
4122
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4065
4123
|
if (!f)
|
|
4066
4124
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4068,24 +4126,24 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4068
4126
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4069
4127
|
f.sendCustomEvent(n, e, t);
|
|
4070
4128
|
}
|
|
4071
|
-
},
|
|
4129
|
+
}, $s = (n, e) => {
|
|
4072
4130
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4073
|
-
if (!f ||
|
|
4074
|
-
|
|
4131
|
+
if (!f || k) {
|
|
4132
|
+
R.push({ event: n, callback: e });
|
|
4075
4133
|
return;
|
|
4076
4134
|
}
|
|
4077
4135
|
f.on(n, e);
|
|
4078
4136
|
}
|
|
4079
|
-
},
|
|
4137
|
+
}, Bs = (n, e) => {
|
|
4080
4138
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4081
4139
|
if (!f) {
|
|
4082
|
-
const t =
|
|
4083
|
-
t !== -1 &&
|
|
4140
|
+
const t = R.findIndex((s) => s.event === n && s.callback === e);
|
|
4141
|
+
t !== -1 && R.splice(t, 1);
|
|
4084
4142
|
return;
|
|
4085
4143
|
}
|
|
4086
4144
|
f.off(n, e);
|
|
4087
4145
|
}
|
|
4088
|
-
},
|
|
4146
|
+
}, Xs = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, Gs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Ws = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), js = () => {
|
|
4089
4147
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4090
4148
|
if (A)
|
|
4091
4149
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4095,12 +4153,12 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4095
4153
|
}
|
|
4096
4154
|
A = !0;
|
|
4097
4155
|
try {
|
|
4098
|
-
f.destroy(), f = null,
|
|
4156
|
+
f.destroy(), f = null, k = !1, C = null, R.length = 0, A = !1;
|
|
4099
4157
|
} catch (n) {
|
|
4100
|
-
f = null,
|
|
4158
|
+
f = null, k = !1, C = null, R.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4101
4159
|
}
|
|
4102
4160
|
}
|
|
4103
|
-
},
|
|
4161
|
+
}, Ks = (n, e) => {
|
|
4104
4162
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4105
4163
|
if (!n || typeof n != "string" || n.trim().length === 0) {
|
|
4106
4164
|
a("warn", "identify() called with invalid userId");
|
|
@@ -4119,7 +4177,7 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4119
4177
|
return;
|
|
4120
4178
|
}
|
|
4121
4179
|
try {
|
|
4122
|
-
const t =
|
|
4180
|
+
const t = Ae(e), s = {
|
|
4123
4181
|
userId: n.trim(),
|
|
4124
4182
|
...t ? { traits: t } : {}
|
|
4125
4183
|
};
|
|
@@ -4128,7 +4186,7 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4128
4186
|
a("debug", "Failed to persist pre-init identity");
|
|
4129
4187
|
}
|
|
4130
4188
|
}
|
|
4131
|
-
},
|
|
4189
|
+
}, zs = async () => {
|
|
4132
4190
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4133
4191
|
if (!f) {
|
|
4134
4192
|
try {
|
|
@@ -4141,31 +4199,31 @@ const Us = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4141
4199
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
4142
4200
|
await f.resetIdentity();
|
|
4143
4201
|
}
|
|
4144
|
-
},
|
|
4145
|
-
init:
|
|
4146
|
-
event:
|
|
4147
|
-
on:
|
|
4148
|
-
off:
|
|
4149
|
-
isInitialized:
|
|
4150
|
-
getSessionId:
|
|
4151
|
-
getUserId:
|
|
4152
|
-
destroy:
|
|
4153
|
-
identify:
|
|
4154
|
-
resetIdentity:
|
|
4202
|
+
}, yn = {
|
|
4203
|
+
init: Hs,
|
|
4204
|
+
event: xs,
|
|
4205
|
+
on: $s,
|
|
4206
|
+
off: Bs,
|
|
4207
|
+
isInitialized: Xs,
|
|
4208
|
+
getSessionId: Gs,
|
|
4209
|
+
getUserId: Ws,
|
|
4210
|
+
destroy: js,
|
|
4211
|
+
identify: Ks,
|
|
4212
|
+
resetIdentity: zs
|
|
4155
4213
|
};
|
|
4156
|
-
var
|
|
4214
|
+
var Le, b, x, at, ne, ct = -1, N = function(n) {
|
|
4157
4215
|
addEventListener("pageshow", (function(e) {
|
|
4158
|
-
e.persisted && (
|
|
4216
|
+
e.persisted && (ct = e.timeStamp, n(e));
|
|
4159
4217
|
}), !0);
|
|
4160
|
-
},
|
|
4218
|
+
}, Pe = function() {
|
|
4161
4219
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4162
4220
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4163
4221
|
}, ie = function() {
|
|
4164
|
-
var n =
|
|
4222
|
+
var n = Pe();
|
|
4165
4223
|
return n && n.activationStart || 0;
|
|
4166
4224
|
}, E = function(n, e) {
|
|
4167
|
-
var t =
|
|
4168
|
-
return
|
|
4225
|
+
var t = Pe(), s = "navigate";
|
|
4226
|
+
return ct >= 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
4227
|
}, U = function(n, e, t) {
|
|
4170
4228
|
try {
|
|
4171
4229
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
@@ -4181,11 +4239,11 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4181
4239
|
}, v = function(n, e, t, s) {
|
|
4182
4240
|
var r, i;
|
|
4183
4241
|
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
|
|
4242
|
+
e.value >= 0 && (o || s) && ((i = e.value - (r || 0)) || r === void 0) && (r = e.value, e.delta = i, e.rating = (function(c, l) {
|
|
4243
|
+
return c > l[1] ? "poor" : c > l[0] ? "needs-improvement" : "good";
|
|
4186
4244
|
})(e.value, t), n(e));
|
|
4187
4245
|
};
|
|
4188
|
-
},
|
|
4246
|
+
}, ke = function(n) {
|
|
4189
4247
|
requestAnimationFrame((function() {
|
|
4190
4248
|
return requestAnimationFrame((function() {
|
|
4191
4249
|
return n();
|
|
@@ -4200,18 +4258,18 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4200
4258
|
return function() {
|
|
4201
4259
|
e || (n(), e = !0);
|
|
4202
4260
|
};
|
|
4203
|
-
}, P = -1,
|
|
4261
|
+
}, P = -1, Ze = function() {
|
|
4204
4262
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4205
4263
|
}, re = function(n) {
|
|
4206
|
-
document.visibilityState === "hidden" && P > -1 && (P = n.type === "visibilitychange" ? n.timeStamp : 0,
|
|
4207
|
-
},
|
|
4264
|
+
document.visibilityState === "hidden" && P > -1 && (P = n.type === "visibilitychange" ? n.timeStamp : 0, Qs());
|
|
4265
|
+
}, et = function() {
|
|
4208
4266
|
addEventListener("visibilitychange", re, !0), addEventListener("prerenderingchange", re, !0);
|
|
4209
|
-
},
|
|
4267
|
+
}, Qs = function() {
|
|
4210
4268
|
removeEventListener("visibilitychange", re, !0), removeEventListener("prerenderingchange", re, !0);
|
|
4211
4269
|
}, De = function() {
|
|
4212
|
-
return P < 0 && (P =
|
|
4270
|
+
return P < 0 && (P = Ze(), et(), N((function() {
|
|
4213
4271
|
setTimeout((function() {
|
|
4214
|
-
P =
|
|
4272
|
+
P = Ze(), et();
|
|
4215
4273
|
}), 0);
|
|
4216
4274
|
}))), { get firstHiddenTime() {
|
|
4217
4275
|
return P;
|
|
@@ -4220,50 +4278,50 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4220
4278
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4221
4279
|
return n();
|
|
4222
4280
|
}), !0) : n();
|
|
4223
|
-
}, be = [1800, 3e3],
|
|
4281
|
+
}, be = [1800, 3e3], lt = function(n, e) {
|
|
4224
4282
|
e = e || {}, X((function() {
|
|
4225
4283
|
var t, s = De(), r = E("FCP"), i = U("paint", (function(o) {
|
|
4226
|
-
o.forEach((function(
|
|
4227
|
-
|
|
4284
|
+
o.forEach((function(c) {
|
|
4285
|
+
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
4286
|
}));
|
|
4229
4287
|
}));
|
|
4230
4288
|
i && (t = v(n, r, be, e.reportAllChanges), N((function(o) {
|
|
4231
|
-
r = E("FCP"), t = v(n, r, be, e.reportAllChanges),
|
|
4289
|
+
r = E("FCP"), t = v(n, r, be, e.reportAllChanges), ke((function() {
|
|
4232
4290
|
r.value = performance.now() - o.timeStamp, t(!0);
|
|
4233
4291
|
}));
|
|
4234
4292
|
})));
|
|
4235
4293
|
}));
|
|
4236
|
-
},
|
|
4237
|
-
e = e || {},
|
|
4238
|
-
var t, s = E("CLS", 0), r = 0, i = [], o = function(
|
|
4239
|
-
|
|
4294
|
+
}, Me = [0.1, 0.25], Ys = function(n, e) {
|
|
4295
|
+
e = e || {}, lt(oe((function() {
|
|
4296
|
+
var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
|
|
4297
|
+
l.forEach((function(u) {
|
|
4240
4298
|
if (!u.hadRecentInput) {
|
|
4241
4299
|
var h = i[0], p = i[i.length - 1];
|
|
4242
4300
|
r && u.startTime - p.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (r += u.value, i.push(u)) : (r = u.value, i = [u]);
|
|
4243
4301
|
}
|
|
4244
4302
|
})), r > s.value && (s.value = r, s.entries = i, t());
|
|
4245
|
-
},
|
|
4246
|
-
|
|
4247
|
-
o(
|
|
4303
|
+
}, c = U("layout-shift", o);
|
|
4304
|
+
c && (t = v(n, s, Me, e.reportAllChanges), B((function() {
|
|
4305
|
+
o(c.takeRecords()), t(!0);
|
|
4248
4306
|
})), N((function() {
|
|
4249
|
-
r = 0, s = E("CLS", 0), t = v(n, s,
|
|
4307
|
+
r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
|
|
4250
4308
|
return t();
|
|
4251
4309
|
}));
|
|
4252
4310
|
})), setTimeout(t, 0));
|
|
4253
4311
|
})));
|
|
4254
|
-
},
|
|
4312
|
+
}, ut = 0, me = 1 / 0, K = 0, qs = function(n) {
|
|
4255
4313
|
n.forEach((function(e) {
|
|
4256
|
-
e.interactionId && (
|
|
4314
|
+
e.interactionId && (me = Math.min(me, e.interactionId), K = Math.max(K, e.interactionId), ut = K ? (K - me) / 7 + 1 : 0);
|
|
4257
4315
|
}));
|
|
4258
|
-
},
|
|
4259
|
-
return
|
|
4260
|
-
},
|
|
4261
|
-
"interactionCount" in performance ||
|
|
4262
|
-
}, I = [], q = /* @__PURE__ */ new Map(),
|
|
4263
|
-
var n = Math.min(I.length - 1, Math.floor((
|
|
4316
|
+
}, dt = function() {
|
|
4317
|
+
return Le ? ut : performance.interactionCount || 0;
|
|
4318
|
+
}, Js = function() {
|
|
4319
|
+
"interactionCount" in performance || Le || (Le = U("event", qs, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4320
|
+
}, I = [], q = /* @__PURE__ */ new Map(), ht = 0, Zs = function() {
|
|
4321
|
+
var n = Math.min(I.length - 1, Math.floor((dt() - ht) / 50));
|
|
4264
4322
|
return I[n];
|
|
4265
|
-
},
|
|
4266
|
-
if (
|
|
4323
|
+
}, en = [], tn = function(n) {
|
|
4324
|
+
if (en.forEach((function(r) {
|
|
4267
4325
|
return r(n);
|
|
4268
4326
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4269
4327
|
var e = I[I.length - 1], t = q.get(n.interactionId);
|
|
@@ -4280,152 +4338,152 @@ var Ae, L, x, it, ne, ot = -1, N = function(n) {
|
|
|
4280
4338
|
}));
|
|
4281
4339
|
}
|
|
4282
4340
|
}
|
|
4283
|
-
},
|
|
4341
|
+
}, ft = function(n) {
|
|
4284
4342
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4285
4343
|
return n = oe(n), document.visibilityState === "hidden" ? n() : (t = e(n), B(n)), t;
|
|
4286
|
-
},
|
|
4344
|
+
}, Ce = [200, 500], sn = function(n, e) {
|
|
4287
4345
|
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, X((function() {
|
|
4288
4346
|
var t;
|
|
4289
|
-
|
|
4290
|
-
var s, r = E("INP"), i = function(
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
var
|
|
4294
|
-
|
|
4347
|
+
Js();
|
|
4348
|
+
var s, r = E("INP"), i = function(c) {
|
|
4349
|
+
ft((function() {
|
|
4350
|
+
c.forEach(tn);
|
|
4351
|
+
var l = Zs();
|
|
4352
|
+
l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
|
|
4295
4353
|
}));
|
|
4296
4354
|
}, o = U("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4297
|
-
s = v(n, r,
|
|
4355
|
+
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), B((function() {
|
|
4298
4356
|
i(o.takeRecords()), s(!0);
|
|
4299
4357
|
})), N((function() {
|
|
4300
|
-
|
|
4358
|
+
ht = dt(), I.length = 0, q.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
|
|
4301
4359
|
})));
|
|
4302
4360
|
})));
|
|
4303
|
-
}, Re = [2500, 4e3],
|
|
4361
|
+
}, Re = [2500, 4e3], pe = {}, nn = function(n, e) {
|
|
4304
4362
|
e = e || {}, X((function() {
|
|
4305
|
-
var t, s = De(), r = E("LCP"), i = function(
|
|
4306
|
-
e.reportAllChanges || (
|
|
4363
|
+
var t, s = De(), r = E("LCP"), i = function(l) {
|
|
4364
|
+
e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
|
|
4307
4365
|
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - ie(), 0), r.entries = [u], t());
|
|
4308
4366
|
}));
|
|
4309
4367
|
}, o = U("largest-contentful-paint", i);
|
|
4310
4368
|
if (o) {
|
|
4311
4369
|
t = v(n, r, Re, e.reportAllChanges);
|
|
4312
|
-
var
|
|
4313
|
-
|
|
4370
|
+
var c = oe((function() {
|
|
4371
|
+
pe[r.id] || (i(o.takeRecords()), o.disconnect(), pe[r.id] = !0, t(!0));
|
|
4314
4372
|
}));
|
|
4315
|
-
["keydown", "click"].forEach((function(
|
|
4316
|
-
addEventListener(
|
|
4317
|
-
return
|
|
4373
|
+
["keydown", "click"].forEach((function(l) {
|
|
4374
|
+
addEventListener(l, (function() {
|
|
4375
|
+
return ft(c);
|
|
4318
4376
|
}), { once: !0, capture: !0 });
|
|
4319
|
-
})), B(
|
|
4320
|
-
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges),
|
|
4321
|
-
r.value = performance.now() -
|
|
4377
|
+
})), B(c), N((function(l) {
|
|
4378
|
+
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
|
|
4379
|
+
r.value = performance.now() - l.timeStamp, pe[r.id] = !0, t(!0);
|
|
4322
4380
|
}));
|
|
4323
4381
|
}));
|
|
4324
4382
|
}
|
|
4325
4383
|
}));
|
|
4326
|
-
},
|
|
4384
|
+
}, Ne = [800, 1800], rn = function n(e) {
|
|
4327
4385
|
document.prerendering ? X((function() {
|
|
4328
4386
|
return n(e);
|
|
4329
4387
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4330
4388
|
return n(e);
|
|
4331
4389
|
}), !0) : setTimeout(e, 0);
|
|
4332
|
-
},
|
|
4390
|
+
}, on = function(n, e) {
|
|
4333
4391
|
e = e || {};
|
|
4334
|
-
var t = E("TTFB"), s = v(n, t,
|
|
4335
|
-
|
|
4336
|
-
var r =
|
|
4392
|
+
var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
|
|
4393
|
+
rn((function() {
|
|
4394
|
+
var r = Pe();
|
|
4337
4395
|
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,
|
|
4396
|
+
t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
|
|
4339
4397
|
})));
|
|
4340
4398
|
}));
|
|
4341
|
-
}, H = { passive: !0, capture: !0 },
|
|
4342
|
-
|
|
4343
|
-
},
|
|
4344
|
-
if (x >= 0 && x <
|
|
4345
|
-
var n = { entryType: "first-input", name:
|
|
4399
|
+
}, H = { passive: !0, capture: !0 }, an = /* @__PURE__ */ new Date(), tt = function(n, e) {
|
|
4400
|
+
b || (b = e, x = n, at = /* @__PURE__ */ new Date(), mt(removeEventListener), gt());
|
|
4401
|
+
}, gt = function() {
|
|
4402
|
+
if (x >= 0 && x < at - an) {
|
|
4403
|
+
var n = { entryType: "first-input", name: b.type, target: b.target, cancelable: b.cancelable, startTime: b.timeStamp, processingStart: b.timeStamp + x };
|
|
4346
4404
|
ne.forEach((function(e) {
|
|
4347
4405
|
e(n);
|
|
4348
4406
|
})), ne = [];
|
|
4349
4407
|
}
|
|
4350
|
-
},
|
|
4408
|
+
}, cn = function(n) {
|
|
4351
4409
|
if (n.cancelable) {
|
|
4352
4410
|
var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
|
|
4353
4411
|
n.type == "pointerdown" ? (function(t, s) {
|
|
4354
4412
|
var r = function() {
|
|
4355
|
-
|
|
4413
|
+
tt(t, s), o();
|
|
4356
4414
|
}, i = function() {
|
|
4357
4415
|
o();
|
|
4358
4416
|
}, o = function() {
|
|
4359
4417
|
removeEventListener("pointerup", r, H), removeEventListener("pointercancel", i, H);
|
|
4360
4418
|
};
|
|
4361
4419
|
addEventListener("pointerup", r, H), addEventListener("pointercancel", i, H);
|
|
4362
|
-
})(e, n) :
|
|
4420
|
+
})(e, n) : tt(e, n);
|
|
4363
4421
|
}
|
|
4364
|
-
},
|
|
4422
|
+
}, mt = function(n) {
|
|
4365
4423
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
4366
|
-
return n(e,
|
|
4424
|
+
return n(e, cn, H);
|
|
4367
4425
|
}));
|
|
4368
|
-
},
|
|
4426
|
+
}, Oe = [100, 300], ln = function(n, e) {
|
|
4369
4427
|
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(
|
|
4428
|
+
var t, s = De(), r = E("FID"), i = function(l) {
|
|
4429
|
+
l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
|
|
4430
|
+
}, o = function(l) {
|
|
4431
|
+
l.forEach(i);
|
|
4432
|
+
}, c = U("first-input", o);
|
|
4433
|
+
t = v(n, r, Oe, e.reportAllChanges), c && (B(oe((function() {
|
|
4434
|
+
o(c.takeRecords()), c.disconnect();
|
|
4377
4435
|
}))), N((function() {
|
|
4378
|
-
var
|
|
4379
|
-
r = E("FID"), t = v(n, r,
|
|
4436
|
+
var l;
|
|
4437
|
+
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), ne = [], x = -1, b = null, mt(addEventListener), l = i, ne.push(l), gt();
|
|
4380
4438
|
})));
|
|
4381
4439
|
}));
|
|
4382
4440
|
};
|
|
4383
|
-
const
|
|
4441
|
+
const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4384
4442
|
__proto__: null,
|
|
4385
|
-
CLSThresholds:
|
|
4443
|
+
CLSThresholds: Me,
|
|
4386
4444
|
FCPThresholds: be,
|
|
4387
|
-
FIDThresholds:
|
|
4388
|
-
INPThresholds:
|
|
4445
|
+
FIDThresholds: Oe,
|
|
4446
|
+
INPThresholds: Ce,
|
|
4389
4447
|
LCPThresholds: Re,
|
|
4390
|
-
TTFBThresholds:
|
|
4391
|
-
onCLS:
|
|
4392
|
-
onFCP:
|
|
4393
|
-
onFID:
|
|
4394
|
-
onINP:
|
|
4395
|
-
onLCP:
|
|
4396
|
-
onTTFB:
|
|
4448
|
+
TTFBThresholds: Ne,
|
|
4449
|
+
onCLS: Ys,
|
|
4450
|
+
onFCP: lt,
|
|
4451
|
+
onFID: ln,
|
|
4452
|
+
onINP: sn,
|
|
4453
|
+
onLCP: nn,
|
|
4454
|
+
onTTFB: on
|
|
4397
4455
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4398
4456
|
export {
|
|
4399
4457
|
m as AppConfigValidationError,
|
|
4400
|
-
|
|
4401
|
-
|
|
4458
|
+
dn as DEFAULT_SESSION_TIMEOUT,
|
|
4459
|
+
_e as DEFAULT_WEB_VITALS_MODE,
|
|
4402
4460
|
w as DeviceType,
|
|
4403
|
-
|
|
4461
|
+
D as EmitterEvent,
|
|
4404
4462
|
V as ErrorType,
|
|
4405
4463
|
d as EventType,
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4464
|
+
Tn as InitializationTimeoutError,
|
|
4465
|
+
Xe as IntegrationValidationError,
|
|
4466
|
+
vn as MAX_ARRAY_LENGTH,
|
|
4467
|
+
mn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4468
|
+
gn as MAX_CUSTOM_EVENT_KEYS,
|
|
4469
|
+
hn as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4470
|
+
fn as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4471
|
+
pn as MAX_NESTED_OBJECT_KEYS,
|
|
4472
|
+
Sn as MAX_STRING_LENGTH,
|
|
4473
|
+
En as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4416
4474
|
ee as Mode,
|
|
4417
|
-
|
|
4475
|
+
os as PII_PATTERNS,
|
|
4418
4476
|
M as PermanentError,
|
|
4419
4477
|
J as RateLimitError,
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4478
|
+
Be as SamplingRateValidationError,
|
|
4479
|
+
Ee as ScrollDirection,
|
|
4480
|
+
wt as SessionTimeoutValidationError,
|
|
4423
4481
|
F as SpecialApiUrl,
|
|
4424
4482
|
Z as TimeoutError,
|
|
4425
4483
|
$ as TraceLogValidationError,
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4484
|
+
_n as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4485
|
+
ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4486
|
+
jt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4487
|
+
Qe as getWebVitalsThresholds,
|
|
4488
|
+
yn as tracelog
|
|
4431
4489
|
};
|