@tracelog/lib 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/tracelog.esm.js +394 -379
- 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 +33 -15
- package/dist/public-api.d.ts +33 -15
- package/dist/public-api.js +2 -2
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const En = 9e5;
|
|
2
|
+
const vn = 120, Tn = 49152, _n = 100, yn = 500, In = 200;
|
|
3
|
+
const wn = 1e3, An = 500, bn = 1e3;
|
|
4
4
|
const b = "data-tlog", vt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
@@ -38,6 +38,11 @@ const b = "data-tlog", vt = [
|
|
|
38
38
|
"auth",
|
|
39
39
|
"key",
|
|
40
40
|
"session",
|
|
41
|
+
"sessionid",
|
|
42
|
+
"session_id",
|
|
43
|
+
"jwt",
|
|
44
|
+
"bearer",
|
|
45
|
+
"oauth",
|
|
41
46
|
"reset",
|
|
42
47
|
"password",
|
|
43
48
|
"api_key",
|
|
@@ -67,8 +72,8 @@ const y = {
|
|
|
67
72
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
68
73
|
/<embed\b[^>]*>/gi,
|
|
69
74
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
70
|
-
], g = "tlog",
|
|
71
|
-
var M = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(M || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}),
|
|
75
|
+
], g = "tlog", Y = `${g}:qa_mode`, Ee = `${g}:uid`, nt = "tlog_mode", Ue = "qa", Fe = "qa_off", le = (n) => n ? `${g}:${n}:queue` : `${g}:queue`, ue = (n) => n ? `${g}:${n}:rate_limit` : `${g}:rate_limit`, It = (n, e) => `${g}:beacon:${n}:${e}`, wt = (n) => n ? `${g}:${n}:session` : `${g}:session`, At = (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, de = (n) => n ? `${g}:${n}:identity` : `${g}:identity`, P = `${g}:pending_identity`;
|
|
76
|
+
var M = /* @__PURE__ */ ((n) => (n.Localhost = "localhost:8080", n.Fail = "localhost:9999", n))(M || {}), w = /* @__PURE__ */ ((n) => (n.Mobile = "mobile", n.Tablet = "tablet", n.Desktop = "desktop", n.Unknown = "unknown", n))(w || {}), V = /* @__PURE__ */ ((n) => (n.EVENT = "event", n.QUEUE = "queue", n))(V || {});
|
|
72
77
|
class C extends Error {
|
|
73
78
|
constructor(e, t, s) {
|
|
74
79
|
super(e), this.statusCode = t, this.responseCode = s, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, C);
|
|
@@ -76,57 +81,57 @@ class C extends Error {
|
|
|
76
81
|
statusCode;
|
|
77
82
|
responseCode;
|
|
78
83
|
}
|
|
79
|
-
class
|
|
84
|
+
class Z extends Error {
|
|
80
85
|
constructor(e) {
|
|
81
|
-
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
86
|
+
super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, Z);
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
|
-
class
|
|
89
|
+
class ee extends Error {
|
|
85
90
|
constructor(e) {
|
|
86
|
-
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this,
|
|
91
|
+
super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ee);
|
|
87
92
|
}
|
|
88
93
|
}
|
|
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 || {}),
|
|
90
|
-
class
|
|
94
|
+
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 || {}), ve = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(ve || {}), x = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n))(x || {}), te = /* @__PURE__ */ ((n) => (n.QA = "qa", n))(te || {});
|
|
95
|
+
class X extends Error {
|
|
91
96
|
constructor(e, t, s) {
|
|
92
97
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
93
98
|
}
|
|
94
99
|
errorCode;
|
|
95
100
|
layer;
|
|
96
101
|
}
|
|
97
|
-
class m extends
|
|
102
|
+
class m extends X {
|
|
98
103
|
constructor(e, t = "config") {
|
|
99
104
|
super(e, "APP_CONFIG_INVALID", t);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
class bt extends
|
|
107
|
+
class bt extends X {
|
|
103
108
|
constructor(e, t = "config") {
|
|
104
109
|
super(e, "SESSION_TIMEOUT_INVALID", t);
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
|
-
class Be extends
|
|
112
|
+
class Be extends X {
|
|
108
113
|
constructor(e, t = "config") {
|
|
109
114
|
super(e, "SAMPLING_RATE_INVALID", t);
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
|
-
class Xe extends
|
|
117
|
+
class Xe extends X {
|
|
113
118
|
constructor(e, t = "config") {
|
|
114
119
|
super(e, "INTEGRATION_INVALID", t);
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
|
-
class
|
|
122
|
+
class Ln extends X {
|
|
118
123
|
constructor(e, t, s = "runtime") {
|
|
119
124
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
120
125
|
}
|
|
121
126
|
timeoutMs;
|
|
122
127
|
}
|
|
123
|
-
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"],
|
|
128
|
+
const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], he = () => {
|
|
124
129
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
125
130
|
return Lt.forEach((s) => {
|
|
126
131
|
const r = n.get(s);
|
|
127
132
|
r && (e[s] = r);
|
|
128
133
|
}), Object.keys(e).length ? e : void 0;
|
|
129
|
-
}, Mt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;",
|
|
134
|
+
}, Mt = "https://ingest.tracelog.io", Ct = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Rt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Nt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Ot = (n, e) => {
|
|
130
135
|
if (e) {
|
|
131
136
|
if (e instanceof Error) {
|
|
132
137
|
const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
|
|
@@ -145,24 +150,24 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
|
145
150
|
return `[TraceLog] ${n}: ${String(e)}`;
|
|
146
151
|
}
|
|
147
152
|
return `[TraceLog] ${n}`;
|
|
148
|
-
},
|
|
153
|
+
}, Pt = () => {
|
|
149
154
|
if (typeof window > "u" || typeof sessionStorage > "u")
|
|
150
155
|
return !1;
|
|
151
156
|
try {
|
|
152
|
-
return sessionStorage.getItem(
|
|
157
|
+
return sessionStorage.getItem(Y) === "true";
|
|
153
158
|
} catch {
|
|
154
159
|
return !1;
|
|
155
160
|
}
|
|
156
161
|
}, a = (n, e, t) => {
|
|
157
|
-
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ?
|
|
158
|
-
if (!
|
|
162
|
+
const { error: s, data: r, showToClient: i = !1, style: o, visibility: c } = t ?? {}, l = s ? Ot(e, s) : `[TraceLog] ${e}`, u = n === "error" ? "error" : n === "warn" ? "warn" : "log";
|
|
163
|
+
if (!kt(c, i))
|
|
159
164
|
return;
|
|
160
|
-
const p =
|
|
161
|
-
|
|
162
|
-
},
|
|
165
|
+
const p = Dt(c, o), S = r !== void 0 ? Te(r) : void 0;
|
|
166
|
+
Ut(u, l, p, S);
|
|
167
|
+
}, kt = (n, e) => n === "critical" ? !0 : n === "qa" || e ? Pt() : !1, Dt = (n, e) => e !== void 0 && e !== "" ? e : n === "critical" ? Nt : "", Ut = (n, e, t, s) => {
|
|
163
168
|
const r = t !== void 0 && t !== "", i = r ? `%c${e}` : e;
|
|
164
169
|
s !== void 0 ? r ? console[n](i, t, s) : console[n](i, s) : r ? console[n](i, t) : console[n](i);
|
|
165
|
-
},
|
|
170
|
+
}, Te = (n) => {
|
|
166
171
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
167
172
|
for (const [s, r] of Object.entries(n)) {
|
|
168
173
|
const i = s.toLowerCase();
|
|
@@ -170,16 +175,16 @@ const Lt = ["gclid", "gbraid", "wbraid", "fbclid", "ttclid"], de = () => {
|
|
|
170
175
|
e[s] = "[REDACTED]";
|
|
171
176
|
continue;
|
|
172
177
|
}
|
|
173
|
-
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] =
|
|
174
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
178
|
+
r !== null && typeof r == "object" && !Array.isArray(r) ? e[s] = Te(r) : Array.isArray(r) ? e[s] = r.map(
|
|
179
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? Te(o) : o
|
|
175
180
|
) : e[s] = r;
|
|
176
181
|
}
|
|
177
182
|
return e;
|
|
178
183
|
};
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
typeof window < "u" && !
|
|
182
|
-
},
|
|
184
|
+
let _e, rt;
|
|
185
|
+
const Ft = () => {
|
|
186
|
+
typeof window < "u" && !_e && (_e = window.matchMedia("(pointer: coarse)"), rt = window.matchMedia("(hover: none)"));
|
|
187
|
+
}, se = "Unknown", Vt = (n) => {
|
|
183
188
|
const e = n.userAgentData?.platform;
|
|
184
189
|
if (e != null && e !== "") {
|
|
185
190
|
if (/windows/i.test(e)) return "Windows";
|
|
@@ -190,8 +195,8 @@ const Ut = () => {
|
|
|
190
195
|
if (/ios/i.test(e)) return "iOS";
|
|
191
196
|
}
|
|
192
197
|
const t = navigator.userAgent;
|
|
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" :
|
|
194
|
-
},
|
|
198
|
+
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" : se;
|
|
199
|
+
}, Ht = (n) => {
|
|
195
200
|
const e = n.userAgentData?.brands;
|
|
196
201
|
if (e != null && e.length > 0) {
|
|
197
202
|
const r = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
|
|
@@ -201,36 +206,36 @@ const Ut = () => {
|
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
const t = navigator.userAgent;
|
|
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" :
|
|
205
|
-
},
|
|
209
|
+
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" : se;
|
|
210
|
+
}, xt = () => {
|
|
206
211
|
try {
|
|
207
212
|
const n = navigator;
|
|
208
213
|
if (n.userAgentData != null && typeof n.userAgentData.mobile == "boolean") {
|
|
209
214
|
const l = n.userAgentData.platform;
|
|
210
215
|
return l != null && l !== "" && /ipad|tablet/i.test(l) ? w.Tablet : n.userAgentData.mobile ? w.Mobile : w.Desktop;
|
|
211
216
|
}
|
|
212
|
-
|
|
213
|
-
const e = window.innerWidth, t =
|
|
217
|
+
Ft();
|
|
218
|
+
const e = window.innerWidth, t = _e?.matches ?? !1, s = rt?.matches ?? !1, r = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), c = /tablet|ipad|android(?!.*mobile)/.test(i);
|
|
214
219
|
return e <= 767 || o && r ? w.Mobile : e >= 768 && e <= 1024 || c || t && s && r ? w.Tablet : w.Desktop;
|
|
215
220
|
} catch (n) {
|
|
216
221
|
return a("debug", "Device detection failed, defaulting to desktop", { error: n }), w.Desktop;
|
|
217
222
|
}
|
|
218
|
-
},
|
|
223
|
+
}, $t = () => {
|
|
219
224
|
try {
|
|
220
225
|
const n = navigator;
|
|
221
226
|
return {
|
|
222
|
-
type:
|
|
223
|
-
os:
|
|
224
|
-
browser:
|
|
227
|
+
type: xt(),
|
|
228
|
+
os: Vt(n),
|
|
229
|
+
browser: Ht(n)
|
|
225
230
|
};
|
|
226
231
|
} catch (n) {
|
|
227
232
|
return a("debug", "Device info detection failed, using defaults", { error: n }), {
|
|
228
233
|
type: w.Desktop,
|
|
229
|
-
os:
|
|
230
|
-
browser:
|
|
234
|
+
os: se,
|
|
235
|
+
browser: se
|
|
231
236
|
};
|
|
232
237
|
}
|
|
233
|
-
}, je = 500, Ge = 2e3, We = 5e3,
|
|
238
|
+
}, je = 500, Ge = 2e3, We = 5e3, q = 50, Bt = q * 2, it = 1, Xt = 1e3, jt = 10, Ke = 5e3, Gt = 3, Wt = 200, Kt = 6e4, zt = 64, Qt = 10 * 6e4, Yt = 200, Mn = {
|
|
234
239
|
LCP: 2500,
|
|
235
240
|
FCP: 1800,
|
|
236
241
|
CLS: 0.1,
|
|
@@ -242,24 +247,24 @@ const Ut = () => {
|
|
|
242
247
|
CLS: 0.1,
|
|
243
248
|
INP: 200,
|
|
244
249
|
TTFB: 800
|
|
245
|
-
},
|
|
250
|
+
}, qt = {
|
|
246
251
|
LCP: 4e3,
|
|
247
252
|
FCP: 3e3,
|
|
248
253
|
CLS: 0.25,
|
|
249
254
|
INP: 500,
|
|
250
255
|
TTFB: 1800
|
|
251
|
-
},
|
|
256
|
+
}, ye = "needs-improvement", Qe = (n = ye) => {
|
|
252
257
|
switch (n) {
|
|
253
258
|
case "all":
|
|
254
259
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0 };
|
|
255
260
|
case "needs-improvement":
|
|
256
261
|
return ze;
|
|
257
262
|
case "poor":
|
|
258
|
-
return
|
|
263
|
+
return qt;
|
|
259
264
|
default:
|
|
260
265
|
return ze;
|
|
261
266
|
}
|
|
262
|
-
},
|
|
267
|
+
}, Jt = 50, Zt = "3.2.0", es = Zt, ts = () => typeof window < "u" && typeof sessionStorage < "u", ss = () => {
|
|
263
268
|
try {
|
|
264
269
|
const n = new URLSearchParams(window.location.search);
|
|
265
270
|
n.delete(nt);
|
|
@@ -267,23 +272,75 @@ const Ut = () => {
|
|
|
267
272
|
window.history.replaceState({}, "", t);
|
|
268
273
|
} catch {
|
|
269
274
|
}
|
|
270
|
-
},
|
|
271
|
-
if (!
|
|
275
|
+
}, ns = () => {
|
|
276
|
+
if (!ts())
|
|
272
277
|
return !1;
|
|
273
278
|
try {
|
|
274
|
-
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(
|
|
279
|
+
const e = new URLSearchParams(window.location.search).get(nt), t = sessionStorage.getItem(Y);
|
|
275
280
|
let s = null;
|
|
276
|
-
return e === Ue ? (s = !0, sessionStorage.setItem(
|
|
277
|
-
visibility: "qa",
|
|
278
|
-
style: Mt
|
|
279
|
-
})) : e === Fe && (s = !1, sessionStorage.setItem(z, "false"), a("info", "QA Mode DISABLED", {
|
|
281
|
+
return e === Ue ? (s = !0, sessionStorage.setItem(Y, "true"), a("info", "QA Mode ACTIVE", {
|
|
280
282
|
visibility: "qa",
|
|
281
283
|
style: Ct
|
|
282
|
-
}))
|
|
284
|
+
})) : e === Fe && (s = !1, sessionStorage.setItem(Y, "false"), a("info", "QA Mode DISABLED", {
|
|
285
|
+
visibility: "qa",
|
|
286
|
+
style: Rt
|
|
287
|
+
})), (e === Ue || e === Fe) && ss(), s ?? t === "true";
|
|
283
288
|
} catch {
|
|
284
289
|
return !1;
|
|
285
290
|
}
|
|
286
|
-
}, ot = () => typeof document < "u" && document.prerendering === !0,
|
|
291
|
+
}, ot = () => typeof document < "u" && document.prerendering === !0, rs = (n) => {
|
|
292
|
+
try {
|
|
293
|
+
return new URL(n).protocol === "https:";
|
|
294
|
+
} catch {
|
|
295
|
+
return !1;
|
|
296
|
+
}
|
|
297
|
+
}, is = (n) => `${Mt}/p/${encodeURIComponent(n)}/collect`, os = (n) => {
|
|
298
|
+
try {
|
|
299
|
+
const t = new URL(window.location.href).hostname;
|
|
300
|
+
if (!t || typeof t != "string")
|
|
301
|
+
throw new Error("Invalid hostname");
|
|
302
|
+
if (t === "localhost" || t === "127.0.0.1" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))
|
|
303
|
+
throw new Error(
|
|
304
|
+
"SaaS integration requires a domain hostname; localhost and IP addresses are not supported. For local development, omit `integrations.tracelog` to run in standalone mode (events emitted locally, no network requests), or test against a staging domain that resolves to your dev machine via /etc/hosts."
|
|
305
|
+
);
|
|
306
|
+
const s = t.split(".");
|
|
307
|
+
if (!s || !Array.isArray(s) || s.length === 0 || s.length === 1 && s[0] === "")
|
|
308
|
+
throw new Error("Invalid hostname structure");
|
|
309
|
+
if (s.length === 1)
|
|
310
|
+
throw new Error("Single-part domain not supported for SaaS integration");
|
|
311
|
+
const r = s.length === 2 ? s.join(".") : s.slice(-2).join(".");
|
|
312
|
+
if (!r || r.split(".").length < 2)
|
|
313
|
+
throw new Error("Invalid domain structure for SaaS");
|
|
314
|
+
const i = `https://${n}.${r}/collect`;
|
|
315
|
+
if (!rs(i))
|
|
316
|
+
throw new Error("Generated URL failed validation");
|
|
317
|
+
return i;
|
|
318
|
+
} catch (e) {
|
|
319
|
+
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
320
|
+
}
|
|
321
|
+
}, as = (n) => {
|
|
322
|
+
const e = {}, t = n.integrations?.tracelog;
|
|
323
|
+
return t?.projectId && (e.saas = t.firstParty ? os(t.projectId) : is(t.projectId)), e;
|
|
324
|
+
}, D = (n, e = []) => {
|
|
325
|
+
if (!n || typeof n != "string")
|
|
326
|
+
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
327
|
+
try {
|
|
328
|
+
let t, s = !1;
|
|
329
|
+
try {
|
|
330
|
+
t = new URL(n);
|
|
331
|
+
} catch {
|
|
332
|
+
const c = window.location.href;
|
|
333
|
+
t = new URL(n, c), s = t.origin === new URL(c).origin;
|
|
334
|
+
}
|
|
335
|
+
const r = t.searchParams, i = [.../* @__PURE__ */ new Set([..._t, ...e])];
|
|
336
|
+
let o = !1;
|
|
337
|
+
for (const c of i)
|
|
338
|
+
r.has(c) && (r.delete(c), o = !0);
|
|
339
|
+
return !o && (s || n.includes("?")) ? n : (t.search = r.toString(), s ? `${t.pathname}${t.search}${t.hash}` : t.toString());
|
|
340
|
+
} catch (t) {
|
|
341
|
+
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
342
|
+
}
|
|
343
|
+
}, cs = [
|
|
287
344
|
"co.uk",
|
|
288
345
|
"org.uk",
|
|
289
346
|
"com.au",
|
|
@@ -300,18 +357,18 @@ const Ut = () => {
|
|
|
300
357
|
if (e.length <= 2)
|
|
301
358
|
return n.toLowerCase();
|
|
302
359
|
const t = e.slice(-2).join(".");
|
|
303
|
-
return
|
|
304
|
-
},
|
|
305
|
-
const
|
|
306
|
-
if (!
|
|
360
|
+
return cs.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
|
|
361
|
+
}, ls = (n, e) => n === e ? !0 : Ye(n) === Ye(e), fe = (n = []) => {
|
|
362
|
+
const e = document.referrer;
|
|
363
|
+
if (!e)
|
|
307
364
|
return "Direct";
|
|
308
365
|
try {
|
|
309
|
-
const
|
|
310
|
-
return
|
|
311
|
-
} catch (
|
|
312
|
-
return a("debug", "Failed to parse referrer URL, using raw value", { error:
|
|
366
|
+
const t = new URL(e).hostname.toLowerCase(), s = window.location.hostname.toLowerCase();
|
|
367
|
+
return ls(t, s) ? "Direct" : D(e, n);
|
|
368
|
+
} catch (t) {
|
|
369
|
+
return a("debug", "Failed to parse referrer URL, using raw value", { error: t, data: { referrer: e } }), e;
|
|
313
370
|
}
|
|
314
|
-
},
|
|
371
|
+
}, ge = () => {
|
|
315
372
|
const n = new URLSearchParams(window.location.search), e = {};
|
|
316
373
|
return Tt.forEach((s) => {
|
|
317
374
|
const r = n.get(s);
|
|
@@ -324,11 +381,11 @@ const Ut = () => {
|
|
|
324
381
|
const e = Math.random() * 16 | 0;
|
|
325
382
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
326
383
|
});
|
|
327
|
-
let
|
|
328
|
-
const
|
|
384
|
+
let K = 0, z = 0;
|
|
385
|
+
const us = () => {
|
|
329
386
|
let n = Date.now();
|
|
330
|
-
n <
|
|
331
|
-
const e =
|
|
387
|
+
n < z && (n = z), n === z ? K = (K + 1) % 1e3 : K = 0, z = n;
|
|
388
|
+
const e = K.toString().padStart(3, "0");
|
|
332
389
|
let t = "";
|
|
333
390
|
try {
|
|
334
391
|
if (typeof crypto < "u" && crypto.getRandomValues) {
|
|
@@ -338,52 +395,6 @@ const is = () => {
|
|
|
338
395
|
} catch {
|
|
339
396
|
}
|
|
340
397
|
return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${n}-${e}-${t}`;
|
|
341
|
-
}, os = (n) => {
|
|
342
|
-
try {
|
|
343
|
-
return new URL(n).protocol === "https:";
|
|
344
|
-
} catch {
|
|
345
|
-
return !1;
|
|
346
|
-
}
|
|
347
|
-
}, as = (n) => {
|
|
348
|
-
try {
|
|
349
|
-
const t = new URL(window.location.href).hostname;
|
|
350
|
-
if (!t || typeof t != "string")
|
|
351
|
-
throw new Error("Invalid hostname");
|
|
352
|
-
if (t === "localhost" || t === "127.0.0.1" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))
|
|
353
|
-
throw new Error(
|
|
354
|
-
"SaaS integration requires a domain hostname; localhost and IP addresses are not supported. For local development, omit `integrations.tracelog` to run in standalone mode (events emitted locally, no network requests), or test against a staging domain that resolves to your dev machine via /etc/hosts."
|
|
355
|
-
);
|
|
356
|
-
const s = t.split(".");
|
|
357
|
-
if (!s || !Array.isArray(s) || s.length === 0 || s.length === 1 && s[0] === "")
|
|
358
|
-
throw new Error("Invalid hostname structure");
|
|
359
|
-
if (s.length === 1)
|
|
360
|
-
throw new Error("Single-part domain not supported for SaaS integration");
|
|
361
|
-
const r = s.length === 2 ? s.join(".") : s.slice(-2).join(".");
|
|
362
|
-
if (!r || r.split(".").length < 2)
|
|
363
|
-
throw new Error("Invalid domain structure for SaaS");
|
|
364
|
-
const i = `https://${n}.${r}/collect`;
|
|
365
|
-
if (!os(i))
|
|
366
|
-
throw new Error("Generated URL failed validation");
|
|
367
|
-
return i;
|
|
368
|
-
} catch (e) {
|
|
369
|
-
throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
|
|
370
|
-
}
|
|
371
|
-
}, cs = (n) => {
|
|
372
|
-
const e = {};
|
|
373
|
-
return n.integrations?.tracelog?.projectId && (e.saas = as(n.integrations.tracelog.projectId)), e;
|
|
374
|
-
}, ye = (n, e = []) => {
|
|
375
|
-
if (!n || typeof n != "string")
|
|
376
|
-
return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof n } }), n || "";
|
|
377
|
-
try {
|
|
378
|
-
const t = new URL(n), s = t.searchParams, r = [.../* @__PURE__ */ new Set([..._t, ...e])];
|
|
379
|
-
let i = !1;
|
|
380
|
-
const o = [];
|
|
381
|
-
return r.forEach((c) => {
|
|
382
|
-
s.has(c) && (s.delete(c), i = !0, o.push(c));
|
|
383
|
-
}), !i && n.includes("?") ? n : (t.search = s.toString(), t.toString());
|
|
384
|
-
} catch (t) {
|
|
385
|
-
return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: n?.length } }), n;
|
|
386
|
-
}
|
|
387
398
|
}, qe = (n) => {
|
|
388
399
|
if (!n || typeof n != "string" || n.trim().length === 0)
|
|
389
400
|
return "";
|
|
@@ -425,7 +436,7 @@ const is = () => {
|
|
|
425
436
|
return t;
|
|
426
437
|
}
|
|
427
438
|
return null;
|
|
428
|
-
},
|
|
439
|
+
}, ds = (n) => {
|
|
429
440
|
if (typeof n != "object" || n === null)
|
|
430
441
|
return {};
|
|
431
442
|
try {
|
|
@@ -435,7 +446,7 @@ const is = () => {
|
|
|
435
446
|
const t = e instanceof Error ? e.message : String(e);
|
|
436
447
|
throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
|
|
437
448
|
}
|
|
438
|
-
},
|
|
449
|
+
}, hs = [
|
|
439
450
|
// Email addresses.
|
|
440
451
|
// Quantifiers are bounded (local part ≤64, each label ≤63, TLD ≤63 per RFC/DNS limits)
|
|
441
452
|
// and the domain is matched as discrete dot-separated labels so the local-part and
|
|
@@ -456,12 +467,12 @@ const is = () => {
|
|
|
456
467
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
457
468
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, …)
|
|
458
469
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
459
|
-
],
|
|
470
|
+
], U = (n) => {
|
|
460
471
|
let e = n;
|
|
461
|
-
for (const t of
|
|
472
|
+
for (const t of hs)
|
|
462
473
|
e = e.replace(t, "[REDACTED]");
|
|
463
474
|
return e;
|
|
464
|
-
},
|
|
475
|
+
}, fs = (n) => {
|
|
465
476
|
if (n !== void 0 && (n === null || typeof n != "object"))
|
|
466
477
|
throw new m("Configuration must be an object", "config");
|
|
467
478
|
if (n) {
|
|
@@ -469,7 +480,7 @@ const is = () => {
|
|
|
469
480
|
throw new bt(y.INVALID_SESSION_TIMEOUT, "config");
|
|
470
481
|
if (n.globalMetadata !== void 0 && (typeof n.globalMetadata != "object" || n.globalMetadata === null))
|
|
471
482
|
throw new m(y.INVALID_GLOBAL_METADATA, "config");
|
|
472
|
-
if (n.integrations &&
|
|
483
|
+
if (n.integrations && gs(n.integrations), n.sensitiveQueryParams !== void 0) {
|
|
473
484
|
if (!Array.isArray(n.sensitiveQueryParams))
|
|
474
485
|
throw new m(y.INVALID_SENSITIVE_QUERY_PARAMS, "config");
|
|
475
486
|
for (const e of n.sensitiveQueryParams)
|
|
@@ -529,14 +540,14 @@ const is = () => {
|
|
|
529
540
|
}
|
|
530
541
|
}
|
|
531
542
|
}
|
|
532
|
-
},
|
|
543
|
+
}, gs = (n) => {
|
|
533
544
|
if (n && n.tracelog) {
|
|
534
545
|
if (!n.tracelog.projectId || typeof n.tracelog.projectId != "string" || n.tracelog.projectId.trim() === "")
|
|
535
546
|
throw new Xe(y.INVALID_TRACELOG_PROJECT_ID, "config");
|
|
536
547
|
if (n.tracelog.shopify !== void 0 && typeof n.tracelog.shopify != "boolean")
|
|
537
548
|
throw new Xe("tracelog.shopify must be a boolean", "config");
|
|
538
549
|
}
|
|
539
|
-
},
|
|
550
|
+
}, ms = (n) => (fs(n), {
|
|
540
551
|
...n ?? {},
|
|
541
552
|
sessionTimeout: n?.sessionTimeout ?? 9e5,
|
|
542
553
|
globalMetadata: n?.globalMetadata ?? {},
|
|
@@ -554,13 +565,13 @@ const is = () => {
|
|
|
554
565
|
return !0;
|
|
555
566
|
const t = typeof n;
|
|
556
567
|
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
|
-
},
|
|
568
|
+
}, ps = (n) => typeof n != "object" || n === null ? !1 : we(n), Ae = (n) => {
|
|
558
569
|
if (typeof n != "object" || n === null || Array.isArray(n)) return;
|
|
559
570
|
const e = {};
|
|
560
571
|
for (const [t, s] of Object.entries(n))
|
|
561
572
|
typeof s == "string" && (e[t] = s);
|
|
562
573
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
563
|
-
},
|
|
574
|
+
}, Ss = (n) => typeof n != "string" ? {
|
|
564
575
|
valid: !1,
|
|
565
576
|
error: "Event name must be a string"
|
|
566
577
|
} : n.length === 0 ? {
|
|
@@ -576,8 +587,8 @@ const is = () => {
|
|
|
576
587
|
valid: !1,
|
|
577
588
|
error: "Event name cannot be a reserved word"
|
|
578
589
|
} : { valid: !0 }, Je = (n, e, t) => {
|
|
579
|
-
const s =
|
|
580
|
-
if (!
|
|
590
|
+
const s = ds(e), r = `${t} "${n}" metadata error`;
|
|
591
|
+
if (!ps(s))
|
|
581
592
|
return {
|
|
582
593
|
valid: !1,
|
|
583
594
|
error: `${r}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -625,7 +636,7 @@ const is = () => {
|
|
|
625
636
|
valid: !0,
|
|
626
637
|
sanitizedMetadata: s
|
|
627
638
|
};
|
|
628
|
-
},
|
|
639
|
+
}, Es = (n, e, t) => {
|
|
629
640
|
if (Array.isArray(e)) {
|
|
630
641
|
const s = [], r = `${t} "${n}" metadata error`;
|
|
631
642
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -649,15 +660,15 @@ const is = () => {
|
|
|
649
660
|
};
|
|
650
661
|
}
|
|
651
662
|
return Je(n, e, t);
|
|
652
|
-
},
|
|
653
|
-
const t =
|
|
663
|
+
}, vs = (n, e) => {
|
|
664
|
+
const t = Ss(n);
|
|
654
665
|
if (!t.valid)
|
|
655
666
|
return a("error", "Event name validation failed", {
|
|
656
667
|
data: { eventName: n, error: t.error }
|
|
657
668
|
}), t;
|
|
658
669
|
if (!e)
|
|
659
670
|
return { valid: !0 };
|
|
660
|
-
const s =
|
|
671
|
+
const s = Es(n, e, "customEvent");
|
|
661
672
|
return s.valid || a("error", "Event metadata validation failed", {
|
|
662
673
|
data: {
|
|
663
674
|
eventName: n,
|
|
@@ -665,7 +676,7 @@ const is = () => {
|
|
|
665
676
|
}
|
|
666
677
|
}), s;
|
|
667
678
|
};
|
|
668
|
-
class
|
|
679
|
+
class Ts {
|
|
669
680
|
listeners = /* @__PURE__ */ new Map();
|
|
670
681
|
/**
|
|
671
682
|
* Subscribes to an event channel
|
|
@@ -782,15 +793,15 @@ class Es {
|
|
|
782
793
|
this.listeners.clear();
|
|
783
794
|
}
|
|
784
795
|
}
|
|
785
|
-
const
|
|
786
|
-
function
|
|
787
|
-
return n.replace(
|
|
796
|
+
const _s = /https?:\/\/\S+/g, ys = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, Is = /0x[0-9a-fA-F]{4,}/g, ws = /(?<!\d)\d{4,}(?!\d)/g, As = /(['"])[^'"]{20,}\1/g;
|
|
797
|
+
function bs(n) {
|
|
798
|
+
return n.replace(_s, "[URL]").replace(ys, "[ID]").replace(Is, "[ADDR]").replace(ws, "[N]").replace(As, "$1[VAR]$1").toLowerCase().trim();
|
|
788
799
|
}
|
|
789
800
|
function Ze(n) {
|
|
790
801
|
const e = n.search(/[?#]/);
|
|
791
802
|
return e === -1 ? n : n.slice(0, e);
|
|
792
803
|
}
|
|
793
|
-
function
|
|
804
|
+
function Ls(n, e) {
|
|
794
805
|
const t = Ze((n ?? "").trim());
|
|
795
806
|
if (!t) return "";
|
|
796
807
|
let s;
|
|
@@ -803,32 +814,32 @@ function As(n, e) {
|
|
|
803
814
|
const r = Ze((e ?? "").trim());
|
|
804
815
|
return r && t === r ? s.origin : t;
|
|
805
816
|
}
|
|
806
|
-
function
|
|
807
|
-
const e =
|
|
817
|
+
function Ms(n) {
|
|
818
|
+
const e = bs(n.message), t = Ls(n.filename, n.page_url), s = n.line == null ? "" : String(n.line);
|
|
808
819
|
return `${e}|${t}|${s}`;
|
|
809
820
|
}
|
|
810
|
-
const
|
|
821
|
+
const me = { config: {} };
|
|
811
822
|
class T {
|
|
812
823
|
/**
|
|
813
824
|
* Retrieves a value from global state.
|
|
814
825
|
*/
|
|
815
826
|
get(e) {
|
|
816
|
-
return
|
|
827
|
+
return me[e];
|
|
817
828
|
}
|
|
818
829
|
/**
|
|
819
830
|
* Sets a value in global state.
|
|
820
831
|
*/
|
|
821
832
|
set(e, t) {
|
|
822
|
-
|
|
833
|
+
me[e] = t;
|
|
823
834
|
}
|
|
824
835
|
/**
|
|
825
836
|
* Returns an immutable snapshot of the entire global state.
|
|
826
837
|
*/
|
|
827
838
|
getState() {
|
|
828
|
-
return { ...
|
|
839
|
+
return { ...me };
|
|
829
840
|
}
|
|
830
841
|
}
|
|
831
|
-
class
|
|
842
|
+
class Cs extends T {
|
|
832
843
|
storeManager;
|
|
833
844
|
apiUrl;
|
|
834
845
|
lastPermanentErrorLog = null;
|
|
@@ -880,7 +891,7 @@ class Ls extends T {
|
|
|
880
891
|
* cases so the migration is one-shot per browser.
|
|
881
892
|
*/
|
|
882
893
|
migrateLegacyV2Keys() {
|
|
883
|
-
const e = this.get("userId") || "anonymous", t = `${
|
|
894
|
+
const e = this.get("userId") || "anonymous", t = `${le(e)}:saas`, s = `${le(e)}:custom`, r = `${ue(e)}:saas`, i = `${ue(e)}:custom`;
|
|
884
895
|
try {
|
|
885
896
|
const o = this.storeManager.getItem(t);
|
|
886
897
|
if (o) {
|
|
@@ -926,11 +937,11 @@ class Ls extends T {
|
|
|
926
937
|
}
|
|
927
938
|
getQueueStorageKey() {
|
|
928
939
|
const e = this.get("userId") || "anonymous";
|
|
929
|
-
return
|
|
940
|
+
return le(e);
|
|
930
941
|
}
|
|
931
942
|
getRateLimitStorageKey() {
|
|
932
943
|
const e = this.get("userId") || "anonymous";
|
|
933
|
-
return
|
|
944
|
+
return ue(e);
|
|
934
945
|
}
|
|
935
946
|
getActiveRateLimitKey() {
|
|
936
947
|
return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
|
|
@@ -1101,13 +1112,13 @@ class Ls extends T {
|
|
|
1101
1112
|
const u = c === 3;
|
|
1102
1113
|
if (l instanceof C)
|
|
1103
1114
|
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l.statusCode === 403 && this.emitHealthBeacon("events_blocked", l.message), l;
|
|
1104
|
-
if (l instanceof
|
|
1115
|
+
if (l instanceof Z) {
|
|
1105
1116
|
this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, i = !1, o = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", "Rate limited, skipping retries", {
|
|
1106
1117
|
data: { events: e.events.length, attempt: c, cooldownMs: 6e4 }
|
|
1107
1118
|
});
|
|
1108
1119
|
break;
|
|
1109
1120
|
}
|
|
1110
|
-
if (l instanceof
|
|
1121
|
+
if (l instanceof ee || (i = !1), l instanceof TypeError || (o = !0), a(
|
|
1111
1122
|
u ? "error" : "warn",
|
|
1112
1123
|
`Send attempt ${c} failed${u ? " (all retries exhausted)" : ", will retry"}`,
|
|
1113
1124
|
{
|
|
@@ -1155,11 +1166,11 @@ class Ls extends T {
|
|
|
1155
1166
|
const l = await this.readTraceLogErrorCode(o), u = l ? `HTTP ${o.status}: ${o.statusText} (${l})` : `HTTP ${o.status}: ${o.statusText}`;
|
|
1156
1167
|
throw new C(u, o.status, l);
|
|
1157
1168
|
}
|
|
1158
|
-
throw o.status === 429 ? new
|
|
1169
|
+
throw o.status === 429 ? new Z(`HTTP 429: ${o.statusText}`) : new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1159
1170
|
}
|
|
1160
1171
|
return o;
|
|
1161
1172
|
} catch (o) {
|
|
1162
|
-
throw o instanceof C ? o : r ? new
|
|
1173
|
+
throw o instanceof C ? o : r ? new ee("Request timed out") : o;
|
|
1163
1174
|
} finally {
|
|
1164
1175
|
clearTimeout(i), this.pendingControllers.delete(s);
|
|
1165
1176
|
}
|
|
@@ -1167,7 +1178,7 @@ class Ls extends T {
|
|
|
1167
1178
|
async readTraceLogErrorCode(e) {
|
|
1168
1179
|
try {
|
|
1169
1180
|
const t = await e.clone().json();
|
|
1170
|
-
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <=
|
|
1181
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= zt)
|
|
1171
1182
|
return t.code;
|
|
1172
1183
|
} catch {
|
|
1173
1184
|
}
|
|
@@ -1194,7 +1205,7 @@ class Ls extends T {
|
|
|
1194
1205
|
idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
|
|
1195
1206
|
referer: typeof window < "u" ? window.location.href : void 0,
|
|
1196
1207
|
timestamp: t,
|
|
1197
|
-
client_version:
|
|
1208
|
+
client_version: es
|
|
1198
1209
|
}
|
|
1199
1210
|
};
|
|
1200
1211
|
return {
|
|
@@ -1286,7 +1297,7 @@ class Ls extends T {
|
|
|
1286
1297
|
}
|
|
1287
1298
|
logPermanentError(e, t) {
|
|
1288
1299
|
const s = Date.now(), r = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1289
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >=
|
|
1300
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== r || s - this.lastPermanentErrorLog.timestamp >= Kt) && (a("error", e, {
|
|
1290
1301
|
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1291
1302
|
}), this.lastPermanentErrorLog = { key: r, timestamp: s });
|
|
1292
1303
|
}
|
|
@@ -1307,7 +1318,7 @@ class Ls extends T {
|
|
|
1307
1318
|
projectId: s.projectId,
|
|
1308
1319
|
reason: e,
|
|
1309
1320
|
origin: i,
|
|
1310
|
-
...t ? { lastError: t.slice(0,
|
|
1321
|
+
...t ? { lastError: t.slice(0, Yt) } : {}
|
|
1311
1322
|
});
|
|
1312
1323
|
this.postBeacon(r, o);
|
|
1313
1324
|
} catch {
|
|
@@ -1331,7 +1342,7 @@ class Ls extends T {
|
|
|
1331
1342
|
Number.isFinite(o) && o > i && (i = o);
|
|
1332
1343
|
} catch {
|
|
1333
1344
|
}
|
|
1334
|
-
if (s - i <
|
|
1345
|
+
if (s - i < Qt) return !1;
|
|
1335
1346
|
this.lastBeaconAt[t] = s;
|
|
1336
1347
|
try {
|
|
1337
1348
|
this.storeManager.setItem(r, String(s));
|
|
@@ -1357,7 +1368,7 @@ class Ls extends T {
|
|
|
1357
1368
|
});
|
|
1358
1369
|
}
|
|
1359
1370
|
}
|
|
1360
|
-
class
|
|
1371
|
+
class Rs extends T {
|
|
1361
1372
|
bootTime;
|
|
1362
1373
|
bootTimestamp;
|
|
1363
1374
|
hasPerformanceNow;
|
|
@@ -1391,8 +1402,8 @@ class Ms extends T {
|
|
|
1391
1402
|
} : { valid: !0 };
|
|
1392
1403
|
}
|
|
1393
1404
|
}
|
|
1394
|
-
const
|
|
1395
|
-
class
|
|
1405
|
+
const Ns = new Set(Object.values(d));
|
|
1406
|
+
class Os extends T {
|
|
1396
1407
|
dataSenders;
|
|
1397
1408
|
emitter;
|
|
1398
1409
|
timeManager;
|
|
@@ -1424,9 +1435,9 @@ class Rs extends T {
|
|
|
1424
1435
|
* @param emitter - Optional event emitter for local event consumption
|
|
1425
1436
|
*/
|
|
1426
1437
|
constructor(e, t = null) {
|
|
1427
|
-
super(), this.emitter = t, this.timeManager = new
|
|
1438
|
+
super(), this.emitter = t, this.timeManager = new Rs(), this.dataSenders = [];
|
|
1428
1439
|
const s = this.get("collectApiUrls");
|
|
1429
|
-
s?.saas && this.dataSenders.push(new
|
|
1440
|
+
s?.saas && this.dataSenders.push(new Cs(e, s.saas)), this.saveSessionCountsDebounced = this.debounce((r) => {
|
|
1430
1441
|
this.saveSessionCounts(r);
|
|
1431
1442
|
}, 500), this.cleanupExpiredSessionCounts();
|
|
1432
1443
|
}
|
|
@@ -1544,7 +1555,7 @@ class Rs extends T {
|
|
|
1544
1555
|
a("error", "Event type is required - event will be ignored");
|
|
1545
1556
|
return;
|
|
1546
1557
|
}
|
|
1547
|
-
if (!
|
|
1558
|
+
if (!Ns.has(e)) {
|
|
1548
1559
|
a("error", "Invalid event type - event will be ignored", {
|
|
1549
1560
|
data: { type: e }
|
|
1550
1561
|
});
|
|
@@ -1587,12 +1598,12 @@ class Rs extends T {
|
|
|
1587
1598
|
}
|
|
1588
1599
|
const _ = this.getTypeLimitForEvent(S);
|
|
1589
1600
|
if (_) {
|
|
1590
|
-
const
|
|
1591
|
-
if (
|
|
1601
|
+
const ce = this.sessionEventCounts[S];
|
|
1602
|
+
if (ce !== void 0 && ce >= _) {
|
|
1592
1603
|
a("warn", "Session event type limit reached", {
|
|
1593
1604
|
data: {
|
|
1594
1605
|
type: S,
|
|
1595
|
-
count:
|
|
1606
|
+
count: ce,
|
|
1596
1607
|
limit: _
|
|
1597
1608
|
}
|
|
1598
1609
|
});
|
|
@@ -1605,7 +1616,7 @@ class Rs extends T {
|
|
|
1605
1616
|
if (!this.checkPerEventRateLimit(o.name, _))
|
|
1606
1617
|
return;
|
|
1607
1618
|
}
|
|
1608
|
-
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"),
|
|
1619
|
+
const St = S === d.SESSION_START, Et = t || this.get("pageUrl"), W = this.buildEventPayload({
|
|
1609
1620
|
type: S,
|
|
1610
1621
|
page_url: Et,
|
|
1611
1622
|
from_page_url: s,
|
|
@@ -1616,7 +1627,7 @@ class Rs extends T {
|
|
|
1616
1627
|
error_data: l,
|
|
1617
1628
|
page_view: u
|
|
1618
1629
|
});
|
|
1619
|
-
if (
|
|
1630
|
+
if (W && !(!p && !this.shouldSample())) {
|
|
1620
1631
|
if (St) {
|
|
1621
1632
|
const _ = this.get("sessionId");
|
|
1622
1633
|
if (!_) {
|
|
@@ -1631,18 +1642,18 @@ class Rs extends T {
|
|
|
1631
1642
|
}
|
|
1632
1643
|
this.set("hasStartSession", !0);
|
|
1633
1644
|
}
|
|
1634
|
-
if (!this.isDuplicateEvent(
|
|
1635
|
-
if (this.get("mode") ===
|
|
1645
|
+
if (!this.isDuplicateEvent(W)) {
|
|
1646
|
+
if (this.get("mode") === te.QA && S === d.CUSTOM && o) {
|
|
1636
1647
|
a("info", `Custom Event: ${o.name}`, {
|
|
1637
1648
|
visibility: "qa",
|
|
1638
1649
|
data: {
|
|
1639
1650
|
name: o.name,
|
|
1640
1651
|
...o.metadata && { metadata: o.metadata }
|
|
1641
1652
|
}
|
|
1642
|
-
}), this.emitEvent(
|
|
1653
|
+
}), this.emitEvent(W);
|
|
1643
1654
|
return;
|
|
1644
1655
|
}
|
|
1645
|
-
if (this.addToQueue(
|
|
1656
|
+
if (this.addToQueue(W), !p) {
|
|
1646
1657
|
this.sessionEventCounts.total++, this.sessionEventCounts[S] !== void 0 && this.sessionEventCounts[S]++;
|
|
1647
1658
|
const _ = this.get("sessionId");
|
|
1648
1659
|
_ && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(_);
|
|
@@ -2100,7 +2111,7 @@ class Rs extends T {
|
|
|
2100
2111
|
});
|
|
2101
2112
|
const c = this.get("sessionReferrer"), l = this.get("sessionUtm"), u = this.get("sessionClickIds");
|
|
2102
2113
|
return { ...{
|
|
2103
|
-
id:
|
|
2114
|
+
id: us(),
|
|
2104
2115
|
type: e.type,
|
|
2105
2116
|
page_url: r,
|
|
2106
2117
|
timestamp: i,
|
|
@@ -2208,11 +2219,11 @@ class Rs extends T {
|
|
|
2208
2219
|
emitEvent(e) {
|
|
2209
2220
|
if (this.emitter) {
|
|
2210
2221
|
const { _session_id: t, ...s } = e;
|
|
2211
|
-
this.emitter.emit(
|
|
2222
|
+
this.emitter.emit(V.EVENT, s);
|
|
2212
2223
|
}
|
|
2213
2224
|
}
|
|
2214
2225
|
emitEventsQueue(e) {
|
|
2215
|
-
this.emitter && this.emitter.emit(
|
|
2226
|
+
this.emitter && this.emitter.emit(V.QUEUE, e);
|
|
2216
2227
|
}
|
|
2217
2228
|
/**
|
|
2218
2229
|
* Creates a debounced version of a function that delays execution until after
|
|
@@ -2412,7 +2423,7 @@ class Rs extends T {
|
|
|
2412
2423
|
}
|
|
2413
2424
|
}
|
|
2414
2425
|
}
|
|
2415
|
-
class
|
|
2426
|
+
class Ps {
|
|
2416
2427
|
/**
|
|
2417
2428
|
* Gets or creates a unique user ID.
|
|
2418
2429
|
*
|
|
@@ -2430,15 +2441,15 @@ class Ns {
|
|
|
2430
2441
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
2431
2442
|
*/
|
|
2432
2443
|
static getId(e) {
|
|
2433
|
-
const t = e.getItem(
|
|
2444
|
+
const t = e.getItem(Ee);
|
|
2434
2445
|
if (t)
|
|
2435
2446
|
return t;
|
|
2436
2447
|
const s = at();
|
|
2437
|
-
return e.setItem(
|
|
2448
|
+
return e.setItem(Ee, s), s;
|
|
2438
2449
|
}
|
|
2439
2450
|
}
|
|
2440
|
-
const
|
|
2441
|
-
class
|
|
2451
|
+
const ks = /^\d{13}-[a-z0-9]{9}$/;
|
|
2452
|
+
class Ds extends T {
|
|
2442
2453
|
storageManager;
|
|
2443
2454
|
eventManager;
|
|
2444
2455
|
projectId;
|
|
@@ -2490,7 +2501,7 @@ class Ps extends T {
|
|
|
2490
2501
|
const e = this.loadStoredSession();
|
|
2491
2502
|
if (!e)
|
|
2492
2503
|
return null;
|
|
2493
|
-
if (!
|
|
2504
|
+
if (!ks.test(e.id))
|
|
2494
2505
|
return a("warn", "Invalid session ID format recovered from storage, clearing", {
|
|
2495
2506
|
data: { sessionId: e.id }
|
|
2496
2507
|
}), this.clearStoredSession(), null;
|
|
@@ -2609,9 +2620,9 @@ class Ps extends T {
|
|
|
2609
2620
|
let s, r, i;
|
|
2610
2621
|
if (e) {
|
|
2611
2622
|
const o = this.loadStoredSession();
|
|
2612
|
-
s = o?.referrer ??
|
|
2623
|
+
s = o?.referrer ?? fe(this.get("config").sensitiveQueryParams), r = o?.utm ?? ge(), i = o?.clickIds ?? he();
|
|
2613
2624
|
} else
|
|
2614
|
-
s =
|
|
2625
|
+
s = fe(this.get("config").sensitiveQueryParams), r = ge(), i = he();
|
|
2615
2626
|
a("debug", "Session tracking initialized", {
|
|
2616
2627
|
data: {
|
|
2617
2628
|
sessionId: t,
|
|
@@ -2683,7 +2694,7 @@ class Ps extends T {
|
|
|
2683
2694
|
*/
|
|
2684
2695
|
renewSession() {
|
|
2685
2696
|
this.needsRenewal = !1;
|
|
2686
|
-
const e = this.generateSessionId(), t =
|
|
2697
|
+
const e = this.generateSessionId(), t = fe(this.get("config").sensitiveQueryParams), s = ge(), r = he();
|
|
2687
2698
|
a("debug", "Renewing session after timeout", {
|
|
2688
2699
|
data: { newSessionId: e }
|
|
2689
2700
|
}), 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({
|
|
@@ -2813,7 +2824,7 @@ class Ps extends T {
|
|
|
2813
2824
|
this.prerenderActivationHandler && (document.removeEventListener("prerenderingchange", this.prerenderActivationHandler), this.prerenderActivationHandler = null);
|
|
2814
2825
|
}
|
|
2815
2826
|
}
|
|
2816
|
-
class
|
|
2827
|
+
class Us extends T {
|
|
2817
2828
|
eventManager;
|
|
2818
2829
|
storageManager;
|
|
2819
2830
|
sessionManager = null;
|
|
@@ -2848,7 +2859,7 @@ class ks extends T {
|
|
|
2848
2859
|
}
|
|
2849
2860
|
const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
|
|
2850
2861
|
try {
|
|
2851
|
-
this.sessionManager = new
|
|
2862
|
+
this.sessionManager = new Ds(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
|
|
2852
2863
|
} catch (s) {
|
|
2853
2864
|
if (this.sessionManager) {
|
|
2854
2865
|
try {
|
|
@@ -2901,7 +2912,7 @@ class ks extends T {
|
|
|
2901
2912
|
this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
|
|
2902
2913
|
}
|
|
2903
2914
|
}
|
|
2904
|
-
class
|
|
2915
|
+
class Fs extends T {
|
|
2905
2916
|
eventManager;
|
|
2906
2917
|
onTrack;
|
|
2907
2918
|
originalPushState;
|
|
@@ -2941,7 +2952,7 @@ class Ds extends T {
|
|
|
2941
2952
|
};
|
|
2942
2953
|
}
|
|
2943
2954
|
trackCurrentPage = () => {
|
|
2944
|
-
const e = window.location.href, t =
|
|
2955
|
+
const e = window.location.href, t = D(e, this.get("config").sensitiveQueryParams);
|
|
2945
2956
|
if (this.get("pageUrl") === t)
|
|
2946
2957
|
return;
|
|
2947
2958
|
const s = Date.now(), r = this.get("config").pageViewThrottleMs ?? 1e3;
|
|
@@ -2959,7 +2970,7 @@ class Ds extends T {
|
|
|
2959
2970
|
}), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
|
|
2960
2971
|
};
|
|
2961
2972
|
trackInitialPageView() {
|
|
2962
|
-
const e =
|
|
2973
|
+
const e = D(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
2963
2974
|
this.lastPageViewTime = Date.now(), this.eventManager.track({
|
|
2964
2975
|
type: d.PAGE_VIEW,
|
|
2965
2976
|
page_url: e,
|
|
@@ -2967,7 +2978,7 @@ class Ds extends T {
|
|
|
2967
2978
|
}), this.onTrack();
|
|
2968
2979
|
}
|
|
2969
2980
|
extractPageViewData() {
|
|
2970
|
-
const
|
|
2981
|
+
const e = document.referrer ? D(document.referrer, this.get("config").sensitiveQueryParams) : "", { title: t } = document;
|
|
2971
2982
|
if (!(!e && !t))
|
|
2972
2983
|
return {
|
|
2973
2984
|
...e && { referrer: e },
|
|
@@ -2975,7 +2986,7 @@ class Ds extends T {
|
|
|
2975
2986
|
};
|
|
2976
2987
|
}
|
|
2977
2988
|
}
|
|
2978
|
-
class
|
|
2989
|
+
class Vs extends T {
|
|
2979
2990
|
eventManager;
|
|
2980
2991
|
lastClickTimes = /* @__PURE__ */ new Map();
|
|
2981
2992
|
clickHandler;
|
|
@@ -3144,15 +3155,15 @@ class Us extends T {
|
|
|
3144
3155
|
};
|
|
3145
3156
|
}
|
|
3146
3157
|
generateClickData(e, t, s) {
|
|
3147
|
-
const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href")
|
|
3158
|
+
const { x: r, y: i } = s, o = this.getRelevantText(e, t), c = t.getAttribute("href"), l = c ? D(c, this.get("config").sensitiveQueryParams) : void 0;
|
|
3148
3159
|
return {
|
|
3149
3160
|
x: r,
|
|
3150
3161
|
y: i,
|
|
3151
3162
|
tag: t.tagName.toLowerCase(),
|
|
3152
|
-
...t.id && { id: t.id },
|
|
3153
|
-
...t.className && { class: t.className },
|
|
3163
|
+
...t.id && { id: U(t.id) },
|
|
3164
|
+
...t.className && { class: U(t.className) },
|
|
3154
3165
|
...o && { text: o },
|
|
3155
|
-
...
|
|
3166
|
+
...l && { href: l }
|
|
3156
3167
|
};
|
|
3157
3168
|
}
|
|
3158
3169
|
getRelevantText(e, t) {
|
|
@@ -3160,7 +3171,7 @@ class Us extends T {
|
|
|
3160
3171
|
if (!s && !r)
|
|
3161
3172
|
return "";
|
|
3162
3173
|
let i = "";
|
|
3163
|
-
return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...",
|
|
3174
|
+
return s && s.length <= 255 ? i = s : r.length <= 255 ? i = r : i = r.slice(0, 252) + "...", U(i);
|
|
3164
3175
|
}
|
|
3165
3176
|
createCustomEventData(e) {
|
|
3166
3177
|
return {
|
|
@@ -3169,7 +3180,7 @@ class Us extends T {
|
|
|
3169
3180
|
};
|
|
3170
3181
|
}
|
|
3171
3182
|
}
|
|
3172
|
-
class
|
|
3183
|
+
class Hs extends T {
|
|
3173
3184
|
eventManager;
|
|
3174
3185
|
containers = [];
|
|
3175
3186
|
limitWarningLogged = !1;
|
|
@@ -3295,7 +3306,7 @@ class Fs extends T {
|
|
|
3295
3306
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
3296
3307
|
}
|
|
3297
3308
|
getScrollDirection(e, t) {
|
|
3298
|
-
return e > t ?
|
|
3309
|
+
return e > t ? ve.DOWN : ve.UP;
|
|
3299
3310
|
}
|
|
3300
3311
|
calculateScrollDepth(e, t, s) {
|
|
3301
3312
|
if (t <= s)
|
|
@@ -3324,8 +3335,8 @@ class Fs extends T {
|
|
|
3324
3335
|
return s && r;
|
|
3325
3336
|
}
|
|
3326
3337
|
}
|
|
3327
|
-
const
|
|
3328
|
-
class
|
|
3338
|
+
const xs = "tracelog_session_id", $s = "tracelog_user_id";
|
|
3339
|
+
class Bs extends T {
|
|
3329
3340
|
visibilityHandler = null;
|
|
3330
3341
|
pageshowHandler = null;
|
|
3331
3342
|
lastSyncedKey = null;
|
|
@@ -3346,8 +3357,8 @@ class xs extends T {
|
|
|
3346
3357
|
r !== this.lastSyncedKey && (this.lastSyncedKey = r, this.postCartUpdate(e, s));
|
|
3347
3358
|
}
|
|
3348
3359
|
postCartUpdate(e, t) {
|
|
3349
|
-
const s = { [
|
|
3350
|
-
t.length > 0 && (s[
|
|
3360
|
+
const s = { [xs]: e };
|
|
3361
|
+
t.length > 0 && (s[$s] = t);
|
|
3351
3362
|
try {
|
|
3352
3363
|
fetch("/cart/update.js", {
|
|
3353
3364
|
method: "POST",
|
|
@@ -3384,7 +3395,7 @@ class xs extends T {
|
|
|
3384
3395
|
this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.pageshowHandler && (window.removeEventListener("pageshow", this.pageshowHandler), this.pageshowHandler = null);
|
|
3385
3396
|
}
|
|
3386
3397
|
}
|
|
3387
|
-
class
|
|
3398
|
+
class Xs {
|
|
3388
3399
|
storage;
|
|
3389
3400
|
sessionStorageRef;
|
|
3390
3401
|
fallbackStorage = /* @__PURE__ */ new Map();
|
|
@@ -3497,7 +3508,7 @@ class $s {
|
|
|
3497
3508
|
this.fallbackSessionStorage.delete(e);
|
|
3498
3509
|
}
|
|
3499
3510
|
}
|
|
3500
|
-
class
|
|
3511
|
+
class js extends T {
|
|
3501
3512
|
eventManager;
|
|
3502
3513
|
reportedByNav = /* @__PURE__ */ new Map();
|
|
3503
3514
|
navigationHistory = [];
|
|
@@ -3505,9 +3516,11 @@ class Bs extends T {
|
|
|
3505
3516
|
observers = [];
|
|
3506
3517
|
vitalThresholds;
|
|
3507
3518
|
navigationCounter = 0;
|
|
3508
|
-
//
|
|
3519
|
+
// Suffix counter for repeat navigations to the same path (SPA A→B→A)
|
|
3520
|
+
currentNavBase = null;
|
|
3521
|
+
currentNavId = null;
|
|
3509
3522
|
constructor(e) {
|
|
3510
|
-
super(), this.eventManager = e, this.vitalThresholds = Qe(
|
|
3523
|
+
super(), this.eventManager = e, this.vitalThresholds = Qe(ye);
|
|
3511
3524
|
}
|
|
3512
3525
|
/**
|
|
3513
3526
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -3523,7 +3536,7 @@ class Bs extends T {
|
|
|
3523
3536
|
* @returns Promise that resolves when tracking is initialized
|
|
3524
3537
|
*/
|
|
3525
3538
|
async startTracking() {
|
|
3526
|
-
const e = this.get("config"), t = e?.webVitalsMode ??
|
|
3539
|
+
const e = this.get("config"), t = e?.webVitalsMode ?? ye;
|
|
3527
3540
|
this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals();
|
|
3528
3541
|
}
|
|
3529
3542
|
/**
|
|
@@ -3542,7 +3555,7 @@ class Bs extends T {
|
|
|
3542
3555
|
} catch (s) {
|
|
3543
3556
|
a("debug", "Failed to disconnect performance observer", { error: s, data: { observerIndex: t } });
|
|
3544
3557
|
}
|
|
3545
|
-
}), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0;
|
|
3558
|
+
}), this.observers.length = 0, this.reportedByNav.clear(), this.navigationHistory.length = 0, this.navigationCounter = 0, this.currentNavBase = null, this.currentNavId = null;
|
|
3546
3559
|
}
|
|
3547
3560
|
observeWebVitalsFallback() {
|
|
3548
3561
|
this.reportTTFB(), this.safeObserve(
|
|
@@ -3594,7 +3607,7 @@ class Bs extends T {
|
|
|
3594
3607
|
}
|
|
3595
3608
|
async initWebVitals() {
|
|
3596
3609
|
try {
|
|
3597
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() =>
|
|
3610
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: i } = await Promise.resolve().then(() => Sn), o = (c) => (l) => {
|
|
3598
3611
|
const u = Number(l.value.toFixed(2));
|
|
3599
3612
|
this.sendVital({ type: c, value: u });
|
|
3600
3613
|
};
|
|
@@ -3624,7 +3637,7 @@ class Bs extends T {
|
|
|
3624
3637
|
return;
|
|
3625
3638
|
if (s)
|
|
3626
3639
|
s.add(e.type);
|
|
3627
|
-
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length >
|
|
3640
|
+
else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Jt) {
|
|
3628
3641
|
const i = this.navigationHistory.shift();
|
|
3629
3642
|
i && this.reportedByNav.delete(i);
|
|
3630
3643
|
}
|
|
@@ -3645,21 +3658,23 @@ class Bs extends T {
|
|
|
3645
3658
|
});
|
|
3646
3659
|
}
|
|
3647
3660
|
/**
|
|
3648
|
-
* Generates a
|
|
3649
|
-
*
|
|
3650
|
-
* **Purpose**: Creates deterministic IDs to prevent duplicate Web Vitals reporting
|
|
3651
|
-
* across multiple metrics for the same navigation event.
|
|
3661
|
+
* Generates a deterministic navigation identifier for deduplication.
|
|
3652
3662
|
*
|
|
3653
|
-
* **
|
|
3663
|
+
* **Purpose**: Every call within the same navigation must return the SAME id,
|
|
3664
|
+
* so `reportedByNav` can collapse duplicate Web Vitals (one emission per
|
|
3665
|
+
* metric type per navigation — critical for the fallback observers, which
|
|
3666
|
+
* fire per entry batch).
|
|
3654
3667
|
*
|
|
3655
|
-
* **
|
|
3656
|
-
* - If multiple navigations occur to the same pathname in the same millisecond,
|
|
3657
|
-
* a counter suffix is appended (e.g., `1234.56_/home_2`)
|
|
3658
|
-
* - Counter only added when > 1 to minimize ID length for common case
|
|
3668
|
+
* **ID Format**: `{startTime}_{pathname}` or `{startTime}_{pathname}_{counter}`
|
|
3659
3669
|
*
|
|
3660
|
-
* **
|
|
3661
|
-
* -
|
|
3662
|
-
*
|
|
3670
|
+
* **Determinism**:
|
|
3671
|
+
* - Base id is derived only from the navigation entry's `startTime` (0 by spec
|
|
3672
|
+
* for the document navigation — no `performance.now()` fallback, which made
|
|
3673
|
+
* every call unique) and the current pathname.
|
|
3674
|
+
* - The id is cached per navigation; the counter suffix is appended ONLY on a
|
|
3675
|
+
* real collision: a new navigation whose base id was already reported
|
|
3676
|
+
* (SPA revisit to the same path, e.g. A→B→A), so the revisit's vitals are
|
|
3677
|
+
* not suppressed by the first visit's dedup entries.
|
|
3663
3678
|
*
|
|
3664
3679
|
* @returns Navigation ID string or null if navigation timing unavailable
|
|
3665
3680
|
*
|
|
@@ -3670,8 +3685,8 @@ class Bs extends T {
|
|
|
3670
3685
|
const e = performance.getEntriesByType("navigation")[0];
|
|
3671
3686
|
if (!e)
|
|
3672
3687
|
return null;
|
|
3673
|
-
const t = e.startTime
|
|
3674
|
-
return
|
|
3688
|
+
const t = `${e.startTime.toFixed(2)}_${window.location.pathname}`;
|
|
3689
|
+
return t === this.currentNavBase && this.currentNavId !== null ? this.currentNavId : (this.currentNavBase = t, this.currentNavId = this.reportedByNav.has(t) ? `${t}_${++this.navigationCounter}` : t, this.currentNavId);
|
|
3675
3690
|
} catch (e) {
|
|
3676
3691
|
return a("debug", "Failed to get navigation ID", { error: e }), null;
|
|
3677
3692
|
}
|
|
@@ -3715,7 +3730,7 @@ class Bs extends T {
|
|
|
3715
3730
|
return !(typeof s == "number" && t <= s);
|
|
3716
3731
|
}
|
|
3717
3732
|
}
|
|
3718
|
-
class
|
|
3733
|
+
class ne extends T {
|
|
3719
3734
|
eventManager;
|
|
3720
3735
|
emitter;
|
|
3721
3736
|
recentErrors = /* @__PURE__ */ new Map();
|
|
@@ -3742,7 +3757,7 @@ class se extends T {
|
|
|
3742
3757
|
this.resetPageviewCounter();
|
|
3743
3758
|
}, window.addEventListener("pagehide", this.pagehideHandler, { passive: !0 }), this.emitter && (this.pageviewResetListener = (e) => {
|
|
3744
3759
|
(e.type === d.SESSION_START || e.type === d.PAGE_VIEW) && this.resetPageviewCounter();
|
|
3745
|
-
}, this.emitter.on(
|
|
3760
|
+
}, this.emitter.on(V.EVENT, this.pageviewResetListener));
|
|
3746
3761
|
}
|
|
3747
3762
|
/**
|
|
3748
3763
|
* Stops tracking errors and cleans up resources.
|
|
@@ -3753,7 +3768,7 @@ class se extends T {
|
|
|
3753
3768
|
* - Resets burst detection counters
|
|
3754
3769
|
*/
|
|
3755
3770
|
stopTracking() {
|
|
3756
|
-
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(
|
|
3771
|
+
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(V.EVENT, this.pageviewResetListener), this.pageviewResetListener = null), this.recentErrors.clear(), this.pageviewSignatureCounts.clear(), this.errorBurstCounter = 0, this.burstWindowStart = 0, this.burstBackoffUntil = 0;
|
|
3757
3772
|
}
|
|
3758
3773
|
/**
|
|
3759
3774
|
* Clears the per-pageview signature counter.
|
|
@@ -3772,7 +3787,7 @@ class se extends T {
|
|
|
3772
3787
|
const e = Date.now();
|
|
3773
3788
|
if (e < this.burstBackoffUntil)
|
|
3774
3789
|
return !1;
|
|
3775
|
-
if (e - this.burstWindowStart >
|
|
3790
|
+
if (e - this.burstWindowStart > Xt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > jt)
|
|
3776
3791
|
return this.burstBackoffUntil = e + Ke, a("debug", "Error burst detected - entering cooldown", {
|
|
3777
3792
|
data: {
|
|
3778
3793
|
errorsInWindow: this.errorBurstCounter,
|
|
@@ -3789,19 +3804,19 @@ class se extends T {
|
|
|
3789
3804
|
* later signature that recycles the same map key after a counter reset.
|
|
3790
3805
|
*/
|
|
3791
3806
|
shouldThrottleBySignature(e) {
|
|
3792
|
-
const t =
|
|
3793
|
-
if (s >=
|
|
3807
|
+
const t = Ms(e), s = this.pageviewSignatureCounts.get(t) ?? 0;
|
|
3808
|
+
if (s >= Gt)
|
|
3794
3809
|
return a("debug", "Error throttled (pageview cap)", {
|
|
3795
3810
|
data: { signature: t, count: s }
|
|
3796
3811
|
}), !0;
|
|
3797
3812
|
const r = s + 1;
|
|
3798
|
-
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size >
|
|
3813
|
+
return this.pageviewSignatureCounts.set(t, r), this.pageviewSignatureCounts.size > Wt && (this.pageviewSignatureCounts.clear(), this.pageviewSignatureCounts.set(t, r)), !1;
|
|
3799
3814
|
}
|
|
3800
3815
|
handleError = (e) => {
|
|
3801
3816
|
if (!this.shouldSample())
|
|
3802
3817
|
return;
|
|
3803
3818
|
const t = this.sanitize(e.message || "Unknown error");
|
|
3804
|
-
if (this.shouldSuppressError(
|
|
3819
|
+
if (this.shouldSuppressError(x.JS_ERROR, t) || this.shouldThrottleBySignature({
|
|
3805
3820
|
message: t,
|
|
3806
3821
|
filename: e.filename,
|
|
3807
3822
|
line: e.lineno,
|
|
@@ -3816,7 +3831,7 @@ class se extends T {
|
|
|
3816
3831
|
this.eventManager.track({
|
|
3817
3832
|
type: d.ERROR,
|
|
3818
3833
|
error_data: {
|
|
3819
|
-
type:
|
|
3834
|
+
type: x.JS_ERROR,
|
|
3820
3835
|
message: t,
|
|
3821
3836
|
...r !== void 0 && { name: r },
|
|
3822
3837
|
...e.filename !== "" && { filename: e.filename },
|
|
@@ -3830,13 +3845,13 @@ class se extends T {
|
|
|
3830
3845
|
if (!this.shouldSample())
|
|
3831
3846
|
return;
|
|
3832
3847
|
const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
|
|
3833
|
-
if (this.shouldSuppressError(
|
|
3848
|
+
if (this.shouldSuppressError(x.PROMISE_REJECTION, s) || this.shouldThrottleBySignature({ message: s }))
|
|
3834
3849
|
return;
|
|
3835
3850
|
const r = e.reason instanceof Error && typeof e.reason.stack == "string" ? this.truncateStack(e.reason.stack) : void 0, i = e.reason instanceof Error && e.reason.name !== "Error" ? e.reason.name : void 0;
|
|
3836
3851
|
this.eventManager.track({
|
|
3837
3852
|
type: d.ERROR,
|
|
3838
3853
|
error_data: {
|
|
3839
|
-
type:
|
|
3854
|
+
type: x.PROMISE_REJECTION,
|
|
3840
3855
|
message: s,
|
|
3841
3856
|
...i !== void 0 && { name: i },
|
|
3842
3857
|
...r !== void 0 && { stack: r }
|
|
@@ -3858,40 +3873,40 @@ class se extends T {
|
|
|
3858
3873
|
}
|
|
3859
3874
|
sanitize(e) {
|
|
3860
3875
|
const t = e.length > je ? e.slice(0, je) + "..." : e;
|
|
3861
|
-
return
|
|
3876
|
+
return U(t);
|
|
3862
3877
|
}
|
|
3863
3878
|
shouldSuppressError(e, t) {
|
|
3864
3879
|
const s = Date.now(), r = `${e}:${t}`, i = this.recentErrors.get(r);
|
|
3865
|
-
return i !== void 0 && s - i < We ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size >
|
|
3880
|
+
return i !== void 0 && s - i < We ? (this.recentErrors.set(r, s), !0) : (this.recentErrors.set(r, s), this.recentErrors.size > Bt ? (this.recentErrors.clear(), this.recentErrors.set(r, s), !1) : (this.recentErrors.size > q && this.pruneOldErrors(), !1));
|
|
3866
3881
|
}
|
|
3867
3882
|
static TRUNCATION_SUFFIX = `
|
|
3868
3883
|
...truncated`;
|
|
3869
3884
|
truncateStack(e) {
|
|
3870
|
-
if (e.length <= Ge) return
|
|
3871
|
-
const t = Ge -
|
|
3872
|
-
return
|
|
3885
|
+
if (e.length <= Ge) return U(e);
|
|
3886
|
+
const t = Ge - ne.TRUNCATION_SUFFIX.length, s = e.slice(0, t) + ne.TRUNCATION_SUFFIX;
|
|
3887
|
+
return U(s);
|
|
3873
3888
|
}
|
|
3874
3889
|
pruneOldErrors() {
|
|
3875
3890
|
const e = Date.now();
|
|
3876
3891
|
for (const [r, i] of this.recentErrors.entries())
|
|
3877
3892
|
e - i > We && this.recentErrors.delete(r);
|
|
3878
|
-
if (this.recentErrors.size <=
|
|
3893
|
+
if (this.recentErrors.size <= q)
|
|
3879
3894
|
return;
|
|
3880
|
-
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size -
|
|
3895
|
+
const t = Array.from(this.recentErrors.entries()).sort((r, i) => r[1] - i[1]), s = this.recentErrors.size - q;
|
|
3881
3896
|
for (let r = 0; r < s; r += 1) {
|
|
3882
3897
|
const i = t[r];
|
|
3883
3898
|
i && this.recentErrors.delete(i[0]);
|
|
3884
3899
|
}
|
|
3885
3900
|
}
|
|
3886
3901
|
}
|
|
3887
|
-
class
|
|
3902
|
+
class Gs extends T {
|
|
3888
3903
|
isInitialized = !1;
|
|
3889
3904
|
suppressNextScrollTimer = null;
|
|
3890
3905
|
pageUnloadHandler = null;
|
|
3891
3906
|
pageShowHandler = null;
|
|
3892
3907
|
visibilityFlushHandler = null;
|
|
3893
3908
|
prerenderActivationHandler = null;
|
|
3894
|
-
emitter = new
|
|
3909
|
+
emitter = new Ts();
|
|
3895
3910
|
managers = {};
|
|
3896
3911
|
handlers = {};
|
|
3897
3912
|
integrationInstances = {};
|
|
@@ -3906,9 +3921,9 @@ class Xs extends T {
|
|
|
3906
3921
|
async init(e = {}) {
|
|
3907
3922
|
if (this.isInitialized)
|
|
3908
3923
|
return { sessionId: this.get("sessionId") ?? "" };
|
|
3909
|
-
this.managers.storage = new
|
|
3924
|
+
this.managers.storage = new Xs();
|
|
3910
3925
|
try {
|
|
3911
|
-
return this.setupState(e), this.managers.event = new
|
|
3926
|
+
return this.setupState(e), this.managers.event = new Os(this.managers.storage, this.emitter), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((t) => {
|
|
3912
3927
|
a("warn", "Failed to recover persisted events", { error: t });
|
|
3913
3928
|
}), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
|
|
3914
3929
|
} catch (t) {
|
|
@@ -3929,9 +3944,9 @@ class Xs extends T {
|
|
|
3929
3944
|
}
|
|
3930
3945
|
let r = t;
|
|
3931
3946
|
t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (r = Object.assign({}, t));
|
|
3932
|
-
const { valid: i, error: o, sanitizedMetadata: c } =
|
|
3947
|
+
const { valid: i, error: o, sanitizedMetadata: c } = vs(e, r);
|
|
3933
3948
|
if (!i) {
|
|
3934
|
-
if (this.get("mode") ===
|
|
3949
|
+
if (this.get("mode") === te.QA)
|
|
3935
3950
|
throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${o}`);
|
|
3936
3951
|
a("warn", `Custom event "${e}" dropped: ${o}`);
|
|
3937
3952
|
return;
|
|
@@ -3968,14 +3983,14 @@ class Xs extends T {
|
|
|
3968
3983
|
}
|
|
3969
3984
|
setupState(e = {}) {
|
|
3970
3985
|
this.set("config", e);
|
|
3971
|
-
const t =
|
|
3986
|
+
const t = Ps.getId(this.managers.storage);
|
|
3972
3987
|
this.set("userId", t);
|
|
3973
|
-
const s =
|
|
3988
|
+
const s = as(e);
|
|
3974
3989
|
this.set("collectApiUrls", s);
|
|
3975
|
-
const r =
|
|
3990
|
+
const r = $t();
|
|
3976
3991
|
this.set("device", r);
|
|
3977
|
-
const i =
|
|
3978
|
-
this.set("pageUrl", i),
|
|
3992
|
+
const i = D(window.location.href, e.sensitiveQueryParams);
|
|
3993
|
+
this.set("pageUrl", i), ns() && this.set("mode", te.QA);
|
|
3979
3994
|
}
|
|
3980
3995
|
/**
|
|
3981
3996
|
* @internal Used by api.ts for configuration access
|
|
@@ -4054,7 +4069,7 @@ class Xs extends T {
|
|
|
4054
4069
|
async resetIdentity() {
|
|
4055
4070
|
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();
|
|
4056
4071
|
const e = at();
|
|
4057
|
-
this.managers.storage.setItem(
|
|
4072
|
+
this.managers.storage.setItem(Ee, 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");
|
|
4058
4073
|
}
|
|
4059
4074
|
/**
|
|
4060
4075
|
* Returns the project ID used for identity storage scoping.
|
|
@@ -4067,7 +4082,7 @@ class Xs extends T {
|
|
|
4067
4082
|
*/
|
|
4068
4083
|
persistIdentity(e) {
|
|
4069
4084
|
try {
|
|
4070
|
-
const t = this.getProjectId(), s =
|
|
4085
|
+
const t = this.getProjectId(), s = de(t);
|
|
4071
4086
|
this.managers.storage.setItem(s, JSON.stringify(e));
|
|
4072
4087
|
} catch {
|
|
4073
4088
|
a("debug", "Failed to persist identity to localStorage");
|
|
@@ -4078,7 +4093,7 @@ class Xs extends T {
|
|
|
4078
4093
|
* Also migrates pending identity (set before init) to the project-scoped key.
|
|
4079
4094
|
*/
|
|
4080
4095
|
loadPersistedIdentity() {
|
|
4081
|
-
const e = this.managers.storage, t = this.getProjectId(), s =
|
|
4096
|
+
const e = this.managers.storage, t = this.getProjectId(), s = de(t);
|
|
4082
4097
|
try {
|
|
4083
4098
|
const r = e.getItem(P);
|
|
4084
4099
|
if (r) {
|
|
@@ -4138,7 +4153,7 @@ class Xs extends T {
|
|
|
4138
4153
|
clearPersistedIdentity() {
|
|
4139
4154
|
try {
|
|
4140
4155
|
const e = this.managers.storage, t = this.getProjectId();
|
|
4141
|
-
e.removeItem(
|
|
4156
|
+
e.removeItem(de(t)), e.removeItem(P);
|
|
4142
4157
|
} catch {
|
|
4143
4158
|
a("debug", "Failed to clear persisted identity");
|
|
4144
4159
|
}
|
|
@@ -4156,7 +4171,7 @@ class Xs extends T {
|
|
|
4156
4171
|
}
|
|
4157
4172
|
initializeHandlers() {
|
|
4158
4173
|
const e = this.get("config");
|
|
4159
|
-
this.handlers.session = new
|
|
4174
|
+
this.handlers.session = new Us(
|
|
4160
4175
|
this.managers.storage,
|
|
4161
4176
|
this.managers.event
|
|
4162
4177
|
), this.handlers.session.startTracking();
|
|
@@ -4165,13 +4180,13 @@ class Xs extends T {
|
|
|
4165
4180
|
this.set("suppressNextScroll", !1);
|
|
4166
4181
|
}, 500);
|
|
4167
4182
|
};
|
|
4168
|
-
this.handlers.pageView = new
|
|
4183
|
+
this.handlers.pageView = new Fs(this.managers.event, t), this.handlers.click = new Vs(this.managers.event), this.handlers.scroll = new Hs(this.managers.event), this.handlers.performance = new js(this.managers.event), this.handlers.error = new ne(this.managers.event, this.emitter);
|
|
4169
4184
|
const s = () => {
|
|
4170
4185
|
if (this.handlers.pageView?.startTracking(), this.handlers.click?.startTracking(), this.handlers.scroll?.startTracking(), this.handlers.performance?.startTracking().catch((r) => {
|
|
4171
4186
|
a("warn", "Failed to start performance tracking", { error: r });
|
|
4172
4187
|
}), this.handlers.error?.startTracking(), e.integrations?.tracelog?.shopify) {
|
|
4173
|
-
const r = new
|
|
4174
|
-
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(
|
|
4188
|
+
const r = new Bs();
|
|
4189
|
+
r.activate(), this.integrationInstances.shopifyCartLinker = r, this.emitter.on(V.EVENT, (i) => {
|
|
4175
4190
|
i.type === d.SESSION_START && r.onSessionChange();
|
|
4176
4191
|
});
|
|
4177
4192
|
}
|
|
@@ -4182,10 +4197,10 @@ class Xs extends T {
|
|
|
4182
4197
|
}
|
|
4183
4198
|
}
|
|
4184
4199
|
const N = [];
|
|
4185
|
-
let f = null,
|
|
4186
|
-
const
|
|
4200
|
+
let f = null, F = !1, A = !1, R = null;
|
|
4201
|
+
const Ws = async (n) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (A = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : f ? { sessionId: f.getSessionId() ?? "" } : (F && R || (F = !0, R = (async () => {
|
|
4187
4202
|
try {
|
|
4188
|
-
const e =
|
|
4203
|
+
const e = ms(n ?? {}), t = new Gs();
|
|
4189
4204
|
try {
|
|
4190
4205
|
N.forEach(({ event: o, callback: c }) => {
|
|
4191
4206
|
t.on(o, c);
|
|
@@ -4207,9 +4222,9 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4207
4222
|
} catch (e) {
|
|
4208
4223
|
throw f = null, e;
|
|
4209
4224
|
} finally {
|
|
4210
|
-
|
|
4225
|
+
F = !1, R = null;
|
|
4211
4226
|
}
|
|
4212
|
-
})()), R)),
|
|
4227
|
+
})()), R)), Ks = (n, e, t) => {
|
|
4213
4228
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4214
4229
|
if (!f)
|
|
4215
4230
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -4217,15 +4232,15 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4217
4232
|
throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
|
|
4218
4233
|
f.sendCustomEvent(n, e, t);
|
|
4219
4234
|
}
|
|
4220
|
-
},
|
|
4235
|
+
}, zs = (n, e) => {
|
|
4221
4236
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4222
|
-
if (!f ||
|
|
4237
|
+
if (!f || F) {
|
|
4223
4238
|
N.push({ event: n, callback: e });
|
|
4224
4239
|
return;
|
|
4225
4240
|
}
|
|
4226
4241
|
f.on(n, e);
|
|
4227
4242
|
}
|
|
4228
|
-
},
|
|
4243
|
+
}, Qs = (n, e) => {
|
|
4229
4244
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4230
4245
|
if (!f) {
|
|
4231
4246
|
const t = N.findIndex((s) => s.event === n && s.callback === e);
|
|
@@ -4234,7 +4249,7 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4234
4249
|
}
|
|
4235
4250
|
f.off(n, e);
|
|
4236
4251
|
}
|
|
4237
|
-
},
|
|
4252
|
+
}, Ys = () => typeof window > "u" || typeof document > "u" ? !1 : f !== null, qs = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getSessionId(), Js = () => typeof window > "u" || typeof document > "u" || !f ? null : f.getUserId(), Zs = () => {
|
|
4238
4253
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4239
4254
|
if (A)
|
|
4240
4255
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -4244,12 +4259,12 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4244
4259
|
}
|
|
4245
4260
|
A = !0;
|
|
4246
4261
|
try {
|
|
4247
|
-
f.destroy(), f = null,
|
|
4262
|
+
f.destroy(), f = null, F = !1, R = null, N.length = 0, A = !1;
|
|
4248
4263
|
} catch (n) {
|
|
4249
|
-
f = null,
|
|
4264
|
+
f = null, F = !1, R = null, N.length = 0, A = !1, a("warn", "Error during destroy, forced cleanup completed", { error: n });
|
|
4250
4265
|
}
|
|
4251
4266
|
}
|
|
4252
|
-
},
|
|
4267
|
+
}, en = (n, e) => {
|
|
4253
4268
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4254
4269
|
if (!n || typeof n != "string" || n.trim().length === 0) {
|
|
4255
4270
|
a("warn", "identify() called with invalid userId");
|
|
@@ -4277,7 +4292,7 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4277
4292
|
a("debug", "Failed to persist pre-init identity");
|
|
4278
4293
|
}
|
|
4279
4294
|
}
|
|
4280
|
-
},
|
|
4295
|
+
}, tn = async () => {
|
|
4281
4296
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
4282
4297
|
if (!f) {
|
|
4283
4298
|
try {
|
|
@@ -4290,32 +4305,32 @@ const js = async (n) => typeof window > "u" || typeof document > "u" ? { session
|
|
|
4290
4305
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
4291
4306
|
await f.resetIdentity();
|
|
4292
4307
|
}
|
|
4293
|
-
},
|
|
4294
|
-
init:
|
|
4295
|
-
event:
|
|
4296
|
-
on:
|
|
4297
|
-
off:
|
|
4298
|
-
isInitialized:
|
|
4299
|
-
getSessionId:
|
|
4300
|
-
getUserId:
|
|
4301
|
-
destroy:
|
|
4302
|
-
identify:
|
|
4303
|
-
resetIdentity:
|
|
4308
|
+
}, Cn = {
|
|
4309
|
+
init: Ws,
|
|
4310
|
+
event: Ks,
|
|
4311
|
+
on: zs,
|
|
4312
|
+
off: Qs,
|
|
4313
|
+
isInitialized: Ys,
|
|
4314
|
+
getSessionId: qs,
|
|
4315
|
+
getUserId: Js,
|
|
4316
|
+
destroy: Zs,
|
|
4317
|
+
identify: en,
|
|
4318
|
+
resetIdentity: tn
|
|
4304
4319
|
};
|
|
4305
|
-
var be, L,
|
|
4320
|
+
var be, L, B, ct, re, lt = -1, O = function(n) {
|
|
4306
4321
|
addEventListener("pageshow", (function(e) {
|
|
4307
4322
|
e.persisted && (lt = e.timeStamp, n(e));
|
|
4308
4323
|
}), !0);
|
|
4309
4324
|
}, Pe = function() {
|
|
4310
4325
|
var n = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
|
|
4311
4326
|
if (n && n.responseStart > 0 && n.responseStart < performance.now()) return n;
|
|
4312
|
-
},
|
|
4327
|
+
}, oe = function() {
|
|
4313
4328
|
var n = Pe();
|
|
4314
4329
|
return n && n.activationStart || 0;
|
|
4315
4330
|
}, E = function(n, e) {
|
|
4316
4331
|
var t = Pe(), s = "navigate";
|
|
4317
|
-
return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering ||
|
|
4318
|
-
},
|
|
4332
|
+
return lt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || oe() > 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 };
|
|
4333
|
+
}, H = function(n, e, t) {
|
|
4319
4334
|
try {
|
|
4320
4335
|
if (PerformanceObserver.supportedEntryTypes.includes(n)) {
|
|
4321
4336
|
var s = new PerformanceObserver((function(r) {
|
|
@@ -4340,23 +4355,23 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
|
4340
4355
|
return n();
|
|
4341
4356
|
}));
|
|
4342
4357
|
}));
|
|
4343
|
-
},
|
|
4358
|
+
}, j = function(n) {
|
|
4344
4359
|
document.addEventListener("visibilitychange", (function() {
|
|
4345
4360
|
document.visibilityState === "hidden" && n();
|
|
4346
4361
|
}));
|
|
4347
|
-
},
|
|
4362
|
+
}, ae = function(n) {
|
|
4348
4363
|
var e = !1;
|
|
4349
4364
|
return function() {
|
|
4350
4365
|
e || (n(), e = !0);
|
|
4351
4366
|
};
|
|
4352
4367
|
}, k = -1, et = function() {
|
|
4353
4368
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
4354
|
-
},
|
|
4355
|
-
document.visibilityState === "hidden" && k > -1 && (k = n.type === "visibilitychange" ? n.timeStamp : 0,
|
|
4369
|
+
}, ie = function(n) {
|
|
4370
|
+
document.visibilityState === "hidden" && k > -1 && (k = n.type === "visibilitychange" ? n.timeStamp : 0, sn());
|
|
4356
4371
|
}, tt = function() {
|
|
4357
|
-
addEventListener("visibilitychange",
|
|
4358
|
-
},
|
|
4359
|
-
removeEventListener("visibilitychange",
|
|
4372
|
+
addEventListener("visibilitychange", ie, !0), addEventListener("prerenderingchange", ie, !0);
|
|
4373
|
+
}, sn = function() {
|
|
4374
|
+
removeEventListener("visibilitychange", ie, !0), removeEventListener("prerenderingchange", ie, !0);
|
|
4360
4375
|
}, De = function() {
|
|
4361
4376
|
return k < 0 && (k = et(), tt(), O((function() {
|
|
4362
4377
|
setTimeout((function() {
|
|
@@ -4365,15 +4380,15 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
|
4365
4380
|
}))), { get firstHiddenTime() {
|
|
4366
4381
|
return k;
|
|
4367
4382
|
} };
|
|
4368
|
-
},
|
|
4383
|
+
}, G = function(n) {
|
|
4369
4384
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
4370
4385
|
return n();
|
|
4371
4386
|
}), !0) : n();
|
|
4372
4387
|
}, Le = [1800, 3e3], ut = function(n, e) {
|
|
4373
|
-
e = e || {},
|
|
4374
|
-
var t, s = De(), r = E("FCP"), i =
|
|
4388
|
+
e = e || {}, G((function() {
|
|
4389
|
+
var t, s = De(), r = E("FCP"), i = H("paint", (function(o) {
|
|
4375
4390
|
o.forEach((function(c) {
|
|
4376
|
-
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime -
|
|
4391
|
+
c.name === "first-contentful-paint" && (i.disconnect(), c.startTime < s.firstHiddenTime && (r.value = Math.max(c.startTime - oe(), 0), r.entries.push(c), t(!0)));
|
|
4377
4392
|
}));
|
|
4378
4393
|
}));
|
|
4379
4394
|
i && (t = v(n, r, Le, e.reportAllChanges), O((function(o) {
|
|
@@ -4382,8 +4397,8 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
|
4382
4397
|
}));
|
|
4383
4398
|
})));
|
|
4384
4399
|
}));
|
|
4385
|
-
}, Me = [0.1, 0.25],
|
|
4386
|
-
e = e || {}, ut(
|
|
4400
|
+
}, Me = [0.1, 0.25], nn = function(n, e) {
|
|
4401
|
+
e = e || {}, ut(ae((function() {
|
|
4387
4402
|
var t, s = E("CLS", 0), r = 0, i = [], o = function(l) {
|
|
4388
4403
|
l.forEach((function(u) {
|
|
4389
4404
|
if (!u.hadRecentInput) {
|
|
@@ -4391,8 +4406,8 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
|
4391
4406
|
r && u.startTime - p.startTime < 1e3 && u.startTime - h.startTime < 5e3 ? (r += u.value, i.push(u)) : (r = u.value, i = [u]);
|
|
4392
4407
|
}
|
|
4393
4408
|
})), r > s.value && (s.value = r, s.entries = i, t());
|
|
4394
|
-
}, c =
|
|
4395
|
-
c && (t = v(n, s, Me, e.reportAllChanges),
|
|
4409
|
+
}, c = H("layout-shift", o);
|
|
4410
|
+
c && (t = v(n, s, Me, e.reportAllChanges), j((function() {
|
|
4396
4411
|
o(c.takeRecords()), t(!0);
|
|
4397
4412
|
})), O((function() {
|
|
4398
4413
|
r = 0, s = E("CLS", 0), t = v(n, s, Me, e.reportAllChanges), ke((function() {
|
|
@@ -4400,103 +4415,103 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
|
4400
4415
|
}));
|
|
4401
4416
|
})), setTimeout(t, 0));
|
|
4402
4417
|
})));
|
|
4403
|
-
}, dt = 0,
|
|
4418
|
+
}, dt = 0, pe = 1 / 0, Q = 0, rn = function(n) {
|
|
4404
4419
|
n.forEach((function(e) {
|
|
4405
|
-
e.interactionId && (
|
|
4420
|
+
e.interactionId && (pe = Math.min(pe, e.interactionId), Q = Math.max(Q, e.interactionId), dt = Q ? (Q - pe) / 7 + 1 : 0);
|
|
4406
4421
|
}));
|
|
4407
4422
|
}, ht = function() {
|
|
4408
4423
|
return be ? dt : performance.interactionCount || 0;
|
|
4409
|
-
},
|
|
4410
|
-
"interactionCount" in performance || be || (be =
|
|
4411
|
-
}, I = [],
|
|
4424
|
+
}, on = function() {
|
|
4425
|
+
"interactionCount" in performance || be || (be = H("event", rn, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
4426
|
+
}, I = [], J = /* @__PURE__ */ new Map(), ft = 0, an = function() {
|
|
4412
4427
|
var n = Math.min(I.length - 1, Math.floor((ht() - ft) / 50));
|
|
4413
4428
|
return I[n];
|
|
4414
|
-
},
|
|
4415
|
-
if (
|
|
4429
|
+
}, cn = [], ln = function(n) {
|
|
4430
|
+
if (cn.forEach((function(r) {
|
|
4416
4431
|
return r(n);
|
|
4417
4432
|
})), n.interactionId || n.entryType === "first-input") {
|
|
4418
|
-
var e = I[I.length - 1], t =
|
|
4433
|
+
var e = I[I.length - 1], t = J.get(n.interactionId);
|
|
4419
4434
|
if (t || I.length < 10 || n.duration > e.latency) {
|
|
4420
4435
|
if (t) n.duration > t.latency ? (t.entries = [n], t.latency = n.duration) : n.duration === t.latency && n.startTime === t.entries[0].startTime && t.entries.push(n);
|
|
4421
4436
|
else {
|
|
4422
4437
|
var s = { id: n.interactionId, latency: n.duration, entries: [n] };
|
|
4423
|
-
|
|
4438
|
+
J.set(s.id, s), I.push(s);
|
|
4424
4439
|
}
|
|
4425
4440
|
I.sort((function(r, i) {
|
|
4426
4441
|
return i.latency - r.latency;
|
|
4427
4442
|
})), I.length > 10 && I.splice(10).forEach((function(r) {
|
|
4428
|
-
return
|
|
4443
|
+
return J.delete(r.id);
|
|
4429
4444
|
}));
|
|
4430
4445
|
}
|
|
4431
4446
|
}
|
|
4432
4447
|
}, gt = function(n) {
|
|
4433
4448
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
4434
|
-
return n =
|
|
4435
|
-
}, Ce = [200, 500],
|
|
4436
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
4449
|
+
return n = ae(n), document.visibilityState === "hidden" ? n() : (t = e(n), j(n)), t;
|
|
4450
|
+
}, Ce = [200, 500], un = function(n, e) {
|
|
4451
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, G((function() {
|
|
4437
4452
|
var t;
|
|
4438
|
-
|
|
4453
|
+
on();
|
|
4439
4454
|
var s, r = E("INP"), i = function(c) {
|
|
4440
4455
|
gt((function() {
|
|
4441
|
-
c.forEach(
|
|
4442
|
-
var l =
|
|
4456
|
+
c.forEach(ln);
|
|
4457
|
+
var l = an();
|
|
4443
4458
|
l && l.latency !== r.value && (r.value = l.latency, r.entries = l.entries, s());
|
|
4444
4459
|
}));
|
|
4445
|
-
}, o =
|
|
4446
|
-
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }),
|
|
4460
|
+
}, o = H("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
4461
|
+
s = v(n, r, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), j((function() {
|
|
4447
4462
|
i(o.takeRecords()), s(!0);
|
|
4448
4463
|
})), O((function() {
|
|
4449
|
-
ft = ht(), I.length = 0,
|
|
4464
|
+
ft = ht(), I.length = 0, J.clear(), r = E("INP"), s = v(n, r, Ce, e.reportAllChanges);
|
|
4450
4465
|
})));
|
|
4451
4466
|
})));
|
|
4452
|
-
}, Re = [2500, 4e3],
|
|
4453
|
-
e = e || {},
|
|
4467
|
+
}, Re = [2500, 4e3], Se = {}, dn = function(n, e) {
|
|
4468
|
+
e = e || {}, G((function() {
|
|
4454
4469
|
var t, s = De(), r = E("LCP"), i = function(l) {
|
|
4455
4470
|
e.reportAllChanges || (l = l.slice(-1)), l.forEach((function(u) {
|
|
4456
|
-
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime -
|
|
4471
|
+
u.startTime < s.firstHiddenTime && (r.value = Math.max(u.startTime - oe(), 0), r.entries = [u], t());
|
|
4457
4472
|
}));
|
|
4458
|
-
}, o =
|
|
4473
|
+
}, o = H("largest-contentful-paint", i);
|
|
4459
4474
|
if (o) {
|
|
4460
4475
|
t = v(n, r, Re, e.reportAllChanges);
|
|
4461
|
-
var c =
|
|
4462
|
-
|
|
4476
|
+
var c = ae((function() {
|
|
4477
|
+
Se[r.id] || (i(o.takeRecords()), o.disconnect(), Se[r.id] = !0, t(!0));
|
|
4463
4478
|
}));
|
|
4464
4479
|
["keydown", "click"].forEach((function(l) {
|
|
4465
4480
|
addEventListener(l, (function() {
|
|
4466
4481
|
return gt(c);
|
|
4467
4482
|
}), { once: !0, capture: !0 });
|
|
4468
|
-
})),
|
|
4483
|
+
})), j(c), O((function(l) {
|
|
4469
4484
|
r = E("LCP"), t = v(n, r, Re, e.reportAllChanges), ke((function() {
|
|
4470
|
-
r.value = performance.now() - l.timeStamp,
|
|
4485
|
+
r.value = performance.now() - l.timeStamp, Se[r.id] = !0, t(!0);
|
|
4471
4486
|
}));
|
|
4472
4487
|
}));
|
|
4473
4488
|
}
|
|
4474
4489
|
}));
|
|
4475
|
-
}, Ne = [800, 1800],
|
|
4476
|
-
document.prerendering ?
|
|
4490
|
+
}, Ne = [800, 1800], hn = function n(e) {
|
|
4491
|
+
document.prerendering ? G((function() {
|
|
4477
4492
|
return n(e);
|
|
4478
4493
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
4479
4494
|
return n(e);
|
|
4480
4495
|
}), !0) : setTimeout(e, 0);
|
|
4481
|
-
},
|
|
4496
|
+
}, fn = function(n, e) {
|
|
4482
4497
|
e = e || {};
|
|
4483
4498
|
var t = E("TTFB"), s = v(n, t, Ne, e.reportAllChanges);
|
|
4484
|
-
|
|
4499
|
+
hn((function() {
|
|
4485
4500
|
var r = Pe();
|
|
4486
|
-
r && (t.value = Math.max(r.responseStart -
|
|
4501
|
+
r && (t.value = Math.max(r.responseStart - oe(), 0), t.entries = [r], s(!0), O((function() {
|
|
4487
4502
|
t = E("TTFB", 0), (s = v(n, t, Ne, e.reportAllChanges))(!0);
|
|
4488
4503
|
})));
|
|
4489
4504
|
}));
|
|
4490
|
-
},
|
|
4491
|
-
L || (L = e,
|
|
4505
|
+
}, $ = { passive: !0, capture: !0 }, gn = /* @__PURE__ */ new Date(), st = function(n, e) {
|
|
4506
|
+
L || (L = e, B = n, ct = /* @__PURE__ */ new Date(), pt(removeEventListener), mt());
|
|
4492
4507
|
}, mt = function() {
|
|
4493
|
-
if (
|
|
4494
|
-
var n = { entryType: "first-input", name: L.type, target: L.target, cancelable: L.cancelable, startTime: L.timeStamp, processingStart: L.timeStamp +
|
|
4495
|
-
|
|
4508
|
+
if (B >= 0 && B < ct - gn) {
|
|
4509
|
+
var n = { entryType: "first-input", name: L.type, target: L.target, cancelable: L.cancelable, startTime: L.timeStamp, processingStart: L.timeStamp + B };
|
|
4510
|
+
re.forEach((function(e) {
|
|
4496
4511
|
e(n);
|
|
4497
|
-
})),
|
|
4512
|
+
})), re = [];
|
|
4498
4513
|
}
|
|
4499
|
-
},
|
|
4514
|
+
}, mn = function(n) {
|
|
4500
4515
|
if (n.cancelable) {
|
|
4501
4516
|
var e = (n.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - n.timeStamp;
|
|
4502
4517
|
n.type == "pointerdown" ? (function(t, s) {
|
|
@@ -4505,31 +4520,31 @@ var be, L, x, ct, ne, lt = -1, O = function(n) {
|
|
|
4505
4520
|
}, i = function() {
|
|
4506
4521
|
o();
|
|
4507
4522
|
}, o = function() {
|
|
4508
|
-
removeEventListener("pointerup", r,
|
|
4523
|
+
removeEventListener("pointerup", r, $), removeEventListener("pointercancel", i, $);
|
|
4509
4524
|
};
|
|
4510
|
-
addEventListener("pointerup", r,
|
|
4525
|
+
addEventListener("pointerup", r, $), addEventListener("pointercancel", i, $);
|
|
4511
4526
|
})(e, n) : st(e, n);
|
|
4512
4527
|
}
|
|
4513
4528
|
}, pt = function(n) {
|
|
4514
4529
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
4515
|
-
return n(e,
|
|
4530
|
+
return n(e, mn, $);
|
|
4516
4531
|
}));
|
|
4517
|
-
}, Oe = [100, 300],
|
|
4518
|
-
e = e || {},
|
|
4532
|
+
}, Oe = [100, 300], pn = function(n, e) {
|
|
4533
|
+
e = e || {}, G((function() {
|
|
4519
4534
|
var t, s = De(), r = E("FID"), i = function(l) {
|
|
4520
4535
|
l.startTime < s.firstHiddenTime && (r.value = l.processingStart - l.startTime, r.entries.push(l), t(!0));
|
|
4521
4536
|
}, o = function(l) {
|
|
4522
4537
|
l.forEach(i);
|
|
4523
|
-
}, c =
|
|
4524
|
-
t = v(n, r, Oe, e.reportAllChanges), c && (
|
|
4538
|
+
}, c = H("first-input", o);
|
|
4539
|
+
t = v(n, r, Oe, e.reportAllChanges), c && (j(ae((function() {
|
|
4525
4540
|
o(c.takeRecords()), c.disconnect();
|
|
4526
4541
|
}))), O((function() {
|
|
4527
4542
|
var l;
|
|
4528
|
-
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges),
|
|
4543
|
+
r = E("FID"), t = v(n, r, Oe, e.reportAllChanges), re = [], B = -1, L = null, pt(addEventListener), l = i, re.push(l), mt();
|
|
4529
4544
|
})));
|
|
4530
4545
|
}));
|
|
4531
4546
|
};
|
|
4532
|
-
const
|
|
4547
|
+
const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4533
4548
|
__proto__: null,
|
|
4534
4549
|
CLSThresholds: Me,
|
|
4535
4550
|
FCPThresholds: Le,
|
|
@@ -4537,44 +4552,44 @@ const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4537
4552
|
INPThresholds: Ce,
|
|
4538
4553
|
LCPThresholds: Re,
|
|
4539
4554
|
TTFBThresholds: Ne,
|
|
4540
|
-
onCLS:
|
|
4555
|
+
onCLS: nn,
|
|
4541
4556
|
onFCP: ut,
|
|
4542
|
-
onFID:
|
|
4543
|
-
onINP:
|
|
4544
|
-
onLCP:
|
|
4545
|
-
onTTFB:
|
|
4557
|
+
onFID: pn,
|
|
4558
|
+
onINP: un,
|
|
4559
|
+
onLCP: dn,
|
|
4560
|
+
onTTFB: fn
|
|
4546
4561
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4547
4562
|
export {
|
|
4548
4563
|
m as AppConfigValidationError,
|
|
4549
|
-
|
|
4550
|
-
|
|
4564
|
+
En as DEFAULT_SESSION_TIMEOUT,
|
|
4565
|
+
ye as DEFAULT_WEB_VITALS_MODE,
|
|
4551
4566
|
w as DeviceType,
|
|
4552
|
-
|
|
4553
|
-
|
|
4567
|
+
V as EmitterEvent,
|
|
4568
|
+
x as ErrorType,
|
|
4554
4569
|
d as EventType,
|
|
4555
|
-
|
|
4570
|
+
Ln as InitializationTimeoutError,
|
|
4556
4571
|
Xe as IntegrationValidationError,
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4572
|
+
bn as MAX_ARRAY_LENGTH,
|
|
4573
|
+
yn as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
4574
|
+
_n as MAX_CUSTOM_EVENT_KEYS,
|
|
4575
|
+
vn as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
4576
|
+
Tn as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
4577
|
+
In as MAX_NESTED_OBJECT_KEYS,
|
|
4578
|
+
wn as MAX_STRING_LENGTH,
|
|
4579
|
+
An as MAX_STRING_LENGTH_IN_ARRAY,
|
|
4580
|
+
te as Mode,
|
|
4581
|
+
hs as PII_PATTERNS,
|
|
4567
4582
|
C as PermanentError,
|
|
4568
|
-
|
|
4583
|
+
Z as RateLimitError,
|
|
4569
4584
|
Be as SamplingRateValidationError,
|
|
4570
|
-
|
|
4585
|
+
ve as ScrollDirection,
|
|
4571
4586
|
bt as SessionTimeoutValidationError,
|
|
4572
4587
|
M as SpecialApiUrl,
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4588
|
+
ee as TimeoutError,
|
|
4589
|
+
X as TraceLogValidationError,
|
|
4590
|
+
Mn as WEB_VITALS_GOOD_THRESHOLDS,
|
|
4576
4591
|
ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
4577
|
-
|
|
4592
|
+
qt as WEB_VITALS_POOR_THRESHOLDS,
|
|
4578
4593
|
Qe as getWebVitalsThresholds,
|
|
4579
|
-
|
|
4594
|
+
Cn as tracelog
|
|
4580
4595
|
};
|