@tracelog/lib 2.9.0-rc.108.13 → 2.9.0-rc.108.16
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 +2 -2
- package/dist/browser/tracelog-shopify-pixel.iife.js +1 -1
- package/dist/browser/tracelog-shopify-pixel.iife.js.map +1 -1
- package/dist/browser/tracelog.esm.js +179 -224
- 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/pixel/index.cjs +2 -2
- package/dist/pixel/index.cjs.map +1 -1
- package/dist/pixel/index.js +2 -2
- package/dist/pixel/index.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 +17 -43
- package/dist/public-api.d.ts +17 -43
- 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 pr = 9e5;
|
|
2
|
+
const Er = 120, Sr = 49152, Tr = 100, Ir = 500, vr = 200;
|
|
3
|
+
const _r = 1e3, yr = 500, wr = 1e3;
|
|
4
4
|
const b = "data-tlog", bt = [
|
|
5
5
|
"button",
|
|
6
6
|
"a",
|
|
@@ -79,7 +79,7 @@ const S = {
|
|
|
79
79
|
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
80
80
|
/<embed\b[^>]*>/gi,
|
|
81
81
|
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
|
|
82
|
-
],
|
|
82
|
+
], v = "tlog", G = `${v}:qa_mode`, Ie = `${v}:uid`, rt = "tlog_mode", Ue = "qa", He = "qa_off", Ct = (r) => r ? `${v}:${r}:queue` : `${v}:queue`, Rt = (r) => r ? `${v}:${r}:rate_limit` : `${v}:rate_limit`, Nt = (r) => r ? `${v}:${r}:session` : `${v}:session`, Ot = (r) => r ? `${v}:${r}:broadcast` : `${v}:broadcast`, Fe = (r, e) => `${v}:${r}:session_counts:${e}`, xe = 10080 * 60 * 1e3, $e = `${v}:session_counts_last_cleanup`, Be = 3600 * 1e3, me = (r) => r ? `${v}:${r}:identity` : `${v}:identity`, H = `${v}:pending_identity`;
|
|
83
83
|
var $ = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))($ || {}), A = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(A || {}), se = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(se || {});
|
|
84
84
|
class O extends Error {
|
|
85
85
|
constructor(e, t, s) {
|
|
@@ -99,7 +99,7 @@ class ne extends Error {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
var u = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r.VIEWPORT_VISIBLE = "viewport_visible", r))(u || {}), Z = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(Z || {}), B = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(B || {}), ie = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(ie || {});
|
|
102
|
-
const
|
|
102
|
+
const br = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !0, Lr = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !1;
|
|
103
103
|
class j extends Error {
|
|
104
104
|
constructor(e, t, s) {
|
|
105
105
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -127,7 +127,7 @@ class N extends j {
|
|
|
127
127
|
super(e, "INTEGRATION_INVALID", t);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
class
|
|
130
|
+
class Ar extends j {
|
|
131
131
|
constructor(e, t, s = "runtime") {
|
|
132
132
|
super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
|
|
133
133
|
}
|
|
@@ -164,12 +164,12 @@ const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
164
164
|
const { error: s, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, d = s ? kt(e, s) : `[TraceLog] ${e}`, c = r === "error" ? "error" : r === "warn" ? "warn" : "log";
|
|
165
165
|
if (!Ut(l, i))
|
|
166
166
|
return;
|
|
167
|
-
const
|
|
168
|
-
Ft(c, d,
|
|
167
|
+
const g = Ht(l, o), m = n !== void 0 ? ve(n) : void 0;
|
|
168
|
+
Ft(c, d, g, m);
|
|
169
169
|
}, Ut = (r, e) => r === "critical" ? !0 : r === "qa" || e ? Vt() : !1, Ht = (r, e) => e !== void 0 && e !== "" ? e : r === "critical" ? Dt : "", Ft = (r, e, t, s) => {
|
|
170
170
|
const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
|
|
171
171
|
s !== void 0 ? n ? console[r](i, t, s) : console[r](i, s) : n ? console[r](i, t) : console[r](i);
|
|
172
|
-
},
|
|
172
|
+
}, ve = (r) => {
|
|
173
173
|
const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
|
|
174
174
|
for (const [s, n] of Object.entries(r)) {
|
|
175
175
|
const i = s.toLowerCase();
|
|
@@ -177,8 +177,8 @@ const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
|
|
|
177
177
|
e[s] = "[REDACTED]";
|
|
178
178
|
continue;
|
|
179
179
|
}
|
|
180
|
-
n !== null && typeof n == "object" && !Array.isArray(n) ? e[s] =
|
|
181
|
-
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ?
|
|
180
|
+
n !== null && typeof n == "object" && !Array.isArray(n) ? e[s] = ve(n) : Array.isArray(n) ? e[s] = n.map(
|
|
181
|
+
(o) => o !== null && typeof o == "object" && !Array.isArray(o) ? ve(o) : o
|
|
182
182
|
) : e[s] = n;
|
|
183
183
|
}
|
|
184
184
|
return e;
|
|
@@ -254,7 +254,7 @@ const xt = () => {
|
|
|
254
254
|
/:\/\/[^:/]+:([^@]+)@/gi,
|
|
255
255
|
// Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, etc.)
|
|
256
256
|
/[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
|
|
257
|
-
], Ge = 500, Xe = 2e3, je = 5e3, ee = 50, Xt = ee * 2, lt = 1, jt = 1e3, Kt = 10, Ke = 5e3,
|
|
257
|
+
], Ge = 500, Xe = 2e3, je = 5e3, ee = 50, Xt = ee * 2, lt = 1, jt = 1e3, Kt = 10, Ke = 5e3, zt = 6e4, Qt = 64, Mr = {
|
|
258
258
|
LCP: 2500,
|
|
259
259
|
// Good: ≤ 2.5s
|
|
260
260
|
FCP: 1800,
|
|
@@ -266,7 +266,7 @@ const xt = () => {
|
|
|
266
266
|
TTFB: 800,
|
|
267
267
|
// Good: ≤ 800ms
|
|
268
268
|
LONG_TASK: 50
|
|
269
|
-
},
|
|
269
|
+
}, ze = {
|
|
270
270
|
LCP: 2500,
|
|
271
271
|
// Needs improvement: > 2.5s (same as good boundary)
|
|
272
272
|
FCP: 1800,
|
|
@@ -290,17 +290,17 @@ const xt = () => {
|
|
|
290
290
|
TTFB: 1800,
|
|
291
291
|
// Poor: > 1800ms
|
|
292
292
|
LONG_TASK: 50
|
|
293
|
-
}, ye = "needs-improvement",
|
|
293
|
+
}, ye = "needs-improvement", Qe = (r = ye) => {
|
|
294
294
|
switch (r) {
|
|
295
295
|
case "all":
|
|
296
296
|
return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
|
|
297
297
|
// Track everything
|
|
298
298
|
case "needs-improvement":
|
|
299
|
-
return
|
|
299
|
+
return ze;
|
|
300
300
|
case "poor":
|
|
301
301
|
return Yt;
|
|
302
302
|
default:
|
|
303
|
-
return
|
|
303
|
+
return ze;
|
|
304
304
|
}
|
|
305
305
|
}, qt = 1e3, Jt = 50, Zt = "2.9.0", es = Zt, ct = () => typeof window < "u" && typeof sessionStorage < "u", ts = () => {
|
|
306
306
|
try {
|
|
@@ -644,7 +644,7 @@ const os = () => {
|
|
|
644
644
|
clickThrottleMs: r?.clickThrottleMs ?? 300,
|
|
645
645
|
maxSameEventPerMinute: r?.maxSameEventPerMinute ?? 60,
|
|
646
646
|
sendIntervalMs: r?.sendIntervalMs ?? 1e4,
|
|
647
|
-
flushOnSpaNavigation: r?.flushOnSpaNavigation ?? !
|
|
647
|
+
flushOnSpaNavigation: r?.flushOnSpaNavigation ?? !1,
|
|
648
648
|
flushOnPageHidden: r?.flushOnPageHidden ?? !0
|
|
649
649
|
};
|
|
650
650
|
return e.integrations?.custom && (e.integrations.custom = {
|
|
@@ -1536,7 +1536,7 @@ class Ze extends _ {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
|
|
1538
1538
|
} catch (f) {
|
|
1539
|
-
const
|
|
1539
|
+
const g = c === 3;
|
|
1540
1540
|
if (f instanceof O)
|
|
1541
1541
|
throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, f;
|
|
1542
1542
|
if (f instanceof re) {
|
|
@@ -1546,8 +1546,8 @@ class Ze extends _ {
|
|
|
1546
1546
|
break;
|
|
1547
1547
|
}
|
|
1548
1548
|
if (f instanceof ne || (l = !1), f instanceof TypeError || (d = !0), a(
|
|
1549
|
-
|
|
1550
|
-
`Send attempt ${c} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${
|
|
1549
|
+
g ? "error" : "warn",
|
|
1550
|
+
`Send attempt ${c} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${g ? " (all retries exhausted)" : ", will retry"}`,
|
|
1551
1551
|
{
|
|
1552
1552
|
error: f,
|
|
1553
1553
|
data: {
|
|
@@ -1557,7 +1557,7 @@ class Ze extends _ {
|
|
|
1557
1557
|
maxAttempts: 3
|
|
1558
1558
|
}
|
|
1559
1559
|
}
|
|
1560
|
-
), !
|
|
1560
|
+
), !g) {
|
|
1561
1561
|
await this.backoffDelay(c);
|
|
1562
1562
|
continue;
|
|
1563
1563
|
}
|
|
@@ -1645,7 +1645,7 @@ class Ze extends _ {
|
|
|
1645
1645
|
async readTraceLogErrorCode(e) {
|
|
1646
1646
|
try {
|
|
1647
1647
|
const t = await e.clone().json();
|
|
1648
|
-
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <=
|
|
1648
|
+
if (typeof t.code == "string" && t.code.length > 0 && t.code.length <= Qt)
|
|
1649
1649
|
return t.code;
|
|
1650
1650
|
} catch {
|
|
1651
1651
|
}
|
|
@@ -1906,7 +1906,7 @@ class Ze extends _ {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
logPermanentError(e, t) {
|
|
1908
1908
|
const s = Date.now(), n = `${t.statusCode ?? "unknown"}:${t.responseCode ?? ""}`;
|
|
1909
|
-
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== n || s - this.lastPermanentErrorLog.timestamp >=
|
|
1909
|
+
(!this.lastPermanentErrorLog || this.lastPermanentErrorLog.key !== n || s - this.lastPermanentErrorLog.timestamp >= zt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
|
|
1910
1910
|
data: { status: t.statusCode, code: t.responseCode, message: t.message }
|
|
1911
1911
|
}), this.lastPermanentErrorLog = { key: n, timestamp: s });
|
|
1912
1912
|
}
|
|
@@ -2060,8 +2060,8 @@ class Ts extends _ {
|
|
|
2060
2060
|
};
|
|
2061
2061
|
}
|
|
2062
2062
|
}
|
|
2063
|
-
const
|
|
2064
|
-
class
|
|
2063
|
+
const Is = new Set(Object.values(u));
|
|
2064
|
+
class vs extends _ {
|
|
2065
2065
|
dataSenders;
|
|
2066
2066
|
emitter;
|
|
2067
2067
|
transformers;
|
|
@@ -2234,14 +2234,14 @@ class Is extends _ {
|
|
|
2234
2234
|
a("error", "Event type is required - event will be ignored");
|
|
2235
2235
|
return;
|
|
2236
2236
|
}
|
|
2237
|
-
if (!
|
|
2237
|
+
if (!Is.has(e)) {
|
|
2238
2238
|
a("error", "Invalid event type - event will be ignored", {
|
|
2239
2239
|
data: { type: e }
|
|
2240
2240
|
});
|
|
2241
2241
|
return;
|
|
2242
2242
|
}
|
|
2243
|
-
const
|
|
2244
|
-
if (!
|
|
2243
|
+
const g = this.get("sessionId");
|
|
2244
|
+
if (!g) {
|
|
2245
2245
|
this.pendingEventsBuffer.length >= 100 && (this.pendingEventsBuffer.shift(), a("debug", "Pending events buffer full - dropping oldest event", {
|
|
2246
2246
|
data: { maxBufferSize: 100 }
|
|
2247
2247
|
})), this.pendingEventsBuffer.push({
|
|
@@ -2258,14 +2258,14 @@ class Is extends _ {
|
|
|
2258
2258
|
});
|
|
2259
2259
|
return;
|
|
2260
2260
|
}
|
|
2261
|
-
this.lastSessionId !==
|
|
2262
|
-
const
|
|
2263
|
-
if (
|
|
2264
|
-
data: { sessionId:
|
|
2265
|
-
}), !
|
|
2261
|
+
this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
|
|
2262
|
+
const m = e === u.SESSION_START;
|
|
2263
|
+
if (m && a("debug", "Processing SESSION_START event", {
|
|
2264
|
+
data: { sessionId: g }
|
|
2265
|
+
}), !m && !this.checkRateLimit())
|
|
2266
2266
|
return;
|
|
2267
2267
|
const E = e;
|
|
2268
|
-
if (!
|
|
2268
|
+
if (!m) {
|
|
2269
2269
|
if (this.sessionEventCounts.total >= 1e3) {
|
|
2270
2270
|
a("warn", "Session event limit reached", {
|
|
2271
2271
|
data: {
|
|
@@ -2276,15 +2276,15 @@ class Is extends _ {
|
|
|
2276
2276
|
});
|
|
2277
2277
|
return;
|
|
2278
2278
|
}
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2279
|
+
const I = this.getTypeLimitForEvent(E);
|
|
2280
|
+
if (I) {
|
|
2281
2281
|
const fe = this.sessionEventCounts[E];
|
|
2282
|
-
if (fe !== void 0 && fe >=
|
|
2282
|
+
if (fe !== void 0 && fe >= I) {
|
|
2283
2283
|
a("warn", "Session event type limit reached", {
|
|
2284
2284
|
data: {
|
|
2285
2285
|
type: E,
|
|
2286
2286
|
count: fe,
|
|
2287
|
-
limit:
|
|
2287
|
+
limit: I
|
|
2288
2288
|
}
|
|
2289
2289
|
});
|
|
2290
2290
|
return;
|
|
@@ -2292,13 +2292,13 @@ class Is extends _ {
|
|
|
2292
2292
|
}
|
|
2293
2293
|
}
|
|
2294
2294
|
if (E === u.CUSTOM && o?.name) {
|
|
2295
|
-
const
|
|
2296
|
-
if (!this.checkPerEventRateLimit(o.name,
|
|
2295
|
+
const I = this.get("config")?.maxSameEventPerMinute ?? 60;
|
|
2296
|
+
if (!this.checkPerEventRateLimit(o.name, I))
|
|
2297
2297
|
return;
|
|
2298
2298
|
}
|
|
2299
|
-
const he = E === u.SESSION_START,
|
|
2299
|
+
const he = E === u.SESSION_START, Q = t || this.get("pageUrl"), U = this.buildEventPayload({
|
|
2300
2300
|
type: E,
|
|
2301
|
-
page_url:
|
|
2301
|
+
page_url: Q,
|
|
2302
2302
|
from_page_url: s,
|
|
2303
2303
|
scroll_data: n,
|
|
2304
2304
|
click_data: i,
|
|
@@ -2308,16 +2308,16 @@ class Is extends _ {
|
|
|
2308
2308
|
viewport_data: c,
|
|
2309
2309
|
page_view: f
|
|
2310
2310
|
});
|
|
2311
|
-
if (U && !(!
|
|
2311
|
+
if (U && !(!m && !this.shouldSample())) {
|
|
2312
2312
|
if (he) {
|
|
2313
|
-
const
|
|
2314
|
-
if (!
|
|
2313
|
+
const I = this.get("sessionId");
|
|
2314
|
+
if (!I) {
|
|
2315
2315
|
a("error", "Session start event requires sessionId - event will be ignored");
|
|
2316
2316
|
return;
|
|
2317
2317
|
}
|
|
2318
2318
|
if (this.get("hasStartSession")) {
|
|
2319
2319
|
a("debug", "Duplicate session_start detected", {
|
|
2320
|
-
data: { sessionId:
|
|
2320
|
+
data: { sessionId: I }
|
|
2321
2321
|
});
|
|
2322
2322
|
return;
|
|
2323
2323
|
}
|
|
@@ -2336,8 +2336,8 @@ class Is extends _ {
|
|
|
2336
2336
|
return;
|
|
2337
2337
|
}
|
|
2338
2338
|
if (E === u.VIEWPORT_VISIBLE && c) {
|
|
2339
|
-
const
|
|
2340
|
-
a("info", `Viewport Visible: ${
|
|
2339
|
+
const I = c.name || c.id || c.selector;
|
|
2340
|
+
a("info", `Viewport Visible: ${I}`, {
|
|
2341
2341
|
visibility: "qa",
|
|
2342
2342
|
data: {
|
|
2343
2343
|
selector: c.selector,
|
|
@@ -2350,10 +2350,10 @@ class Is extends _ {
|
|
|
2350
2350
|
return;
|
|
2351
2351
|
}
|
|
2352
2352
|
}
|
|
2353
|
-
if (this.addToQueue(U), !
|
|
2353
|
+
if (this.addToQueue(U), !m) {
|
|
2354
2354
|
this.sessionEventCounts.total++, this.sessionEventCounts[E] !== void 0 && this.sessionEventCounts[E]++;
|
|
2355
|
-
const
|
|
2356
|
-
|
|
2355
|
+
const I = this.get("sessionId");
|
|
2356
|
+
I && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(I);
|
|
2357
2357
|
}
|
|
2358
2358
|
}
|
|
2359
2359
|
}
|
|
@@ -2464,7 +2464,14 @@ class Is extends _ {
|
|
|
2464
2464
|
* - No retry on failure (sendBeacon is fire-and-forget)
|
|
2465
2465
|
* - 64KB payload limit (large batches may be truncated)
|
|
2466
2466
|
*
|
|
2467
|
-
*
|
|
2467
|
+
* **In-flight contract**: if an async send is already running this call is
|
|
2468
|
+
* deferred (queued for replay in the async send's `finally` block) and
|
|
2469
|
+
* returns `false` — nothing has been delivered yet at the point of return.
|
|
2470
|
+
* Mirrors `flushImmediately()`'s behaviour for the same condition.
|
|
2471
|
+
*
|
|
2472
|
+
* @returns `true` if at least one integration accepted the beacon batch
|
|
2473
|
+
* *during this call*, `false` otherwise (no events, all senders
|
|
2474
|
+
* failed, or the call was deferred behind an in-flight async send)
|
|
2468
2475
|
*
|
|
2469
2476
|
* @example
|
|
2470
2477
|
* ```typescript
|
|
@@ -2480,62 +2487,6 @@ class Is extends _ {
|
|
|
2480
2487
|
flushImmediatelySync() {
|
|
2481
2488
|
return this.flushEvents(!0);
|
|
2482
2489
|
}
|
|
2483
|
-
/**
|
|
2484
|
-
* Sends ONLY the most recently queued event via `navigator.sendBeacon()` in
|
|
2485
|
-
* a dedicated single-event batch.
|
|
2486
|
-
*
|
|
2487
|
-
* **Purpose**: Guarantee delivery of an event that *must* survive an
|
|
2488
|
-
* imminent page unload (purchase confirmation, signup completion, etc.),
|
|
2489
|
-
* independent of the main queue's size or in-flight async send state.
|
|
2490
|
-
*
|
|
2491
|
-
* **Why a dedicated batch**: `flushImmediatelySync()` serialises the entire
|
|
2492
|
-
* queue into one `sendBeacon` call. If the queue is heavy (>64KB) the
|
|
2493
|
-
* beacon fails and the batch is persisted to `localStorage`, which is only
|
|
2494
|
-
* recovered on the next `init()` — useless for one-shot conversion events
|
|
2495
|
-
* where the user never returns.
|
|
2496
|
-
*
|
|
2497
|
-
* **Behaviour**:
|
|
2498
|
-
* - Reads the last entry of `eventsQueue` (the just-tracked event).
|
|
2499
|
-
* - Wraps it in its own `EventsQueue` and dispatches synchronously through
|
|
2500
|
-
* every `SenderManager` via `sendEventsQueueSync()`.
|
|
2501
|
-
* - Leaves the main queue untouched; the same event will be re-delivered by
|
|
2502
|
-
* the next periodic / unload flush. Idempotency is the caller-side
|
|
2503
|
-
* contract: the backend MUST deduplicate by `event.id` (e.g. unique index
|
|
2504
|
-
* on the ingestion collection) — same guarantee the library already
|
|
2505
|
-
* relies on for the persisted-events recovery path.
|
|
2506
|
-
*
|
|
2507
|
-
* **Use it after** `track()` so the event is in the queue. Caller is
|
|
2508
|
-
* responsible for verifying that `track()` actually queued the event
|
|
2509
|
-
* (it can be dropped by rate limiting / sampling / `beforeSend`).
|
|
2510
|
-
*
|
|
2511
|
-
* **Standalone mode** (no senders configured): returns `false` without
|
|
2512
|
-
* emitting. The subsequent main-queue drain (`flushImmediatelySync()`) is
|
|
2513
|
-
* responsible for delivering the event to local listeners — emitting here
|
|
2514
|
-
* too would surface the same event twice to a `tracelog.on('queue', ...)`
|
|
2515
|
-
* subscriber.
|
|
2516
|
-
*
|
|
2517
|
-
* @returns `true` if at least one sender delivered the beacon successfully,
|
|
2518
|
-
* `false` otherwise (including standalone mode — the drain handles it).
|
|
2519
|
-
*/
|
|
2520
|
-
flushLastEventSync() {
|
|
2521
|
-
if (this.dataSenders.length === 0)
|
|
2522
|
-
return !1;
|
|
2523
|
-
const e = this.eventsQueue[this.eventsQueue.length - 1];
|
|
2524
|
-
if (!e)
|
|
2525
|
-
return !1;
|
|
2526
|
-
const { _session_id: t, ...s } = e;
|
|
2527
|
-
if (!t)
|
|
2528
|
-
return a("debug", "flushLastEventSync: last queued event missing _session_id, skipping"), !1;
|
|
2529
|
-
const n = this.get("config")?.globalMetadata, i = this.get("identity"), o = {
|
|
2530
|
-
user_id: this.get("userId"),
|
|
2531
|
-
session_id: t,
|
|
2532
|
-
device: this.get("device"),
|
|
2533
|
-
events: [s],
|
|
2534
|
-
...n && { global_metadata: n },
|
|
2535
|
-
...i && { identify: i }
|
|
2536
|
-
};
|
|
2537
|
-
return this.dataSenders.map((d) => d.sendEventsQueueSync(o)).some(Boolean);
|
|
2538
|
-
}
|
|
2539
2490
|
/**
|
|
2540
2491
|
* Sets the custom headers provider callback for the custom integration.
|
|
2541
2492
|
* Only affects requests to custom backend (not TraceLog SaaS).
|
|
@@ -2727,7 +2678,7 @@ class Is extends _ {
|
|
|
2727
2678
|
const s = t.reduce((n, i) => n + i.eventIds.length, 0);
|
|
2728
2679
|
return this.pendingSyncFlush = !0, a("debug", "Sync flush deferred: async send in-flight, will retry on settle", {
|
|
2729
2680
|
data: { eventCount: s }
|
|
2730
|
-
}), !
|
|
2681
|
+
}), !1;
|
|
2731
2682
|
}
|
|
2732
2683
|
if (e) {
|
|
2733
2684
|
const s = t.map(({ batch: n, eventIds: i }) => this.sendBatchSync(n, i));
|
|
@@ -2831,11 +2782,11 @@ class Is extends _ {
|
|
|
2831
2782
|
*/
|
|
2832
2783
|
buildBatchFromGroup(e, t) {
|
|
2833
2784
|
const s = /* @__PURE__ */ new Map(), n = [];
|
|
2834
|
-
for (const
|
|
2835
|
-
const E = this.createEventSignature(
|
|
2836
|
-
s.has(E) || n.push(E), s.set(E,
|
|
2785
|
+
for (const m of t) {
|
|
2786
|
+
const E = this.createEventSignature(m);
|
|
2787
|
+
s.has(E) || n.push(E), s.set(E, m);
|
|
2837
2788
|
}
|
|
2838
|
-
const i = n.map((
|
|
2789
|
+
const i = n.map((m) => s.get(m)).filter((m) => !!m).sort((m, E) => m.type === u.SESSION_START && E.type !== u.SESSION_START ? -1 : E.type === u.SESSION_START && m.type !== u.SESSION_START ? 1 : m.timestamp - E.timestamp).map(({ _session_id: m, ...E }) => E), o = this.get("config")?.globalMetadata, l = this.get("identity");
|
|
2839
2790
|
let d = {
|
|
2840
2791
|
user_id: this.get("userId"),
|
|
2841
2792
|
session_id: e,
|
|
@@ -2844,10 +2795,10 @@ class Is extends _ {
|
|
|
2844
2795
|
...o && { global_metadata: o },
|
|
2845
2796
|
...l && { identify: l }
|
|
2846
2797
|
};
|
|
2847
|
-
const c = this.get("collectApiUrls"), f = !!(c?.custom || c?.saas),
|
|
2848
|
-
if (!f &&
|
|
2849
|
-
const
|
|
2850
|
-
|
|
2798
|
+
const c = this.get("collectApiUrls"), f = !!(c?.custom || c?.saas), g = this.transformers.beforeBatch;
|
|
2799
|
+
if (!f && g) {
|
|
2800
|
+
const m = gt(d, g, "EventManager");
|
|
2801
|
+
m !== null && (d = m);
|
|
2851
2802
|
}
|
|
2852
2803
|
return d;
|
|
2853
2804
|
}
|
|
@@ -2879,12 +2830,12 @@ class Is extends _ {
|
|
|
2879
2830
|
...e.page_view && { page_view: e.page_view },
|
|
2880
2831
|
...d && { utm: d }
|
|
2881
2832
|
};
|
|
2882
|
-
const f = this.get("collectApiUrls"),
|
|
2883
|
-
if (
|
|
2884
|
-
const
|
|
2885
|
-
if (
|
|
2833
|
+
const f = this.get("collectApiUrls"), g = !!f?.custom, m = !!f?.saas, E = g || m, he = g && m, Q = this.transformers.beforeSend;
|
|
2834
|
+
if (Q && (!E || g && !he)) {
|
|
2835
|
+
const I = mt(c, Q, "EventManager");
|
|
2836
|
+
if (I === null)
|
|
2886
2837
|
return null;
|
|
2887
|
-
c =
|
|
2838
|
+
c = I;
|
|
2888
2839
|
}
|
|
2889
2840
|
return { ...c, _session_id: t };
|
|
2890
2841
|
}
|
|
@@ -3122,7 +3073,7 @@ class Is extends _ {
|
|
|
3122
3073
|
return;
|
|
3123
3074
|
}
|
|
3124
3075
|
}
|
|
3125
|
-
const t = this.get("userId") || "anonymous", s = `${
|
|
3076
|
+
const t = this.get("userId") || "anonymous", s = `${v}:${t}:session_counts:`, n = [];
|
|
3126
3077
|
for (let i = 0; i < localStorage.length; i++) {
|
|
3127
3078
|
const o = localStorage.key(i);
|
|
3128
3079
|
if (o?.startsWith(s))
|
|
@@ -3205,11 +3156,11 @@ class _s {
|
|
|
3205
3156
|
* @returns Persistent unique user ID (UUID v4 format)
|
|
3206
3157
|
*/
|
|
3207
3158
|
static getId(e) {
|
|
3208
|
-
const t = e.getItem(
|
|
3159
|
+
const t = e.getItem(Ie);
|
|
3209
3160
|
if (t)
|
|
3210
3161
|
return t;
|
|
3211
3162
|
const s = dt();
|
|
3212
|
-
return e.setItem(
|
|
3163
|
+
return e.setItem(Ie, s), s;
|
|
3213
3164
|
}
|
|
3214
3165
|
}
|
|
3215
3166
|
const ys = /^\d{13}-[a-z0-9]{9}$/;
|
|
@@ -3687,7 +3638,7 @@ class Ls extends _ {
|
|
|
3687
3638
|
page_url: this.get("pageUrl"),
|
|
3688
3639
|
from_page_url: i,
|
|
3689
3640
|
...o && { page_view: o }
|
|
3690
|
-
}), this.get("config").flushOnSpaNavigation
|
|
3641
|
+
}), this.get("config").flushOnSpaNavigation === !0 && this.eventManager.flushImmediately();
|
|
3691
3642
|
};
|
|
3692
3643
|
trackInitialPageView() {
|
|
3693
3644
|
const e = we(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
|
|
@@ -3745,12 +3696,12 @@ class As extends _ {
|
|
|
3745
3696
|
if (o) {
|
|
3746
3697
|
const f = this.extractTrackingData(o);
|
|
3747
3698
|
if (f) {
|
|
3748
|
-
const
|
|
3699
|
+
const g = this.createCustomEventData(f);
|
|
3749
3700
|
this.eventManager.track({
|
|
3750
3701
|
type: u.CUSTOM,
|
|
3751
3702
|
custom_event: {
|
|
3752
|
-
name:
|
|
3753
|
-
...
|
|
3703
|
+
name: g.name,
|
|
3704
|
+
...g.value && { metadata: { value: g.value } }
|
|
3754
3705
|
}
|
|
3755
3706
|
});
|
|
3756
3707
|
}
|
|
@@ -4156,12 +4107,12 @@ class Ms extends _ {
|
|
|
4156
4107
|
const { element: t, lastScrollPos: s, lastEventTime: n } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - s);
|
|
4157
4108
|
if (l < 10 || t === window && !this.isWindowScrollable())
|
|
4158
4109
|
return null;
|
|
4159
|
-
const d = this.getViewportHeight(t), c = this.getScrollHeight(t), f = this.getScrollDirection(i, s),
|
|
4160
|
-
let
|
|
4161
|
-
n > 0 ?
|
|
4162
|
-
const E = Math.round(l /
|
|
4163
|
-
return
|
|
4164
|
-
depth:
|
|
4110
|
+
const d = this.getViewportHeight(t), c = this.getScrollHeight(t), f = this.getScrollDirection(i, s), g = this.calculateScrollDepth(i, c, d);
|
|
4111
|
+
let m;
|
|
4112
|
+
n > 0 ? m = o - n : e.firstScrollEventTime !== null ? m = o - e.firstScrollEventTime : m = 250;
|
|
4113
|
+
const E = Math.round(l / m * 1e3);
|
|
4114
|
+
return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
|
|
4115
|
+
depth: g,
|
|
4165
4116
|
direction: f,
|
|
4166
4117
|
velocity: E,
|
|
4167
4118
|
max_depth_reached: e.maxDepthReached
|
|
@@ -4715,7 +4666,7 @@ class Ds extends _ {
|
|
|
4715
4666
|
navigationCounter = 0;
|
|
4716
4667
|
// Counter for handling simultaneous navigations edge case
|
|
4717
4668
|
constructor(e) {
|
|
4718
|
-
super(), this.eventManager = e, this.vitalThresholds =
|
|
4669
|
+
super(), this.eventManager = e, this.vitalThresholds = Qe(ye);
|
|
4719
4670
|
}
|
|
4720
4671
|
/**
|
|
4721
4672
|
* Starts tracking Web Vitals and performance metrics.
|
|
@@ -4733,7 +4684,7 @@ class Ds extends _ {
|
|
|
4733
4684
|
*/
|
|
4734
4685
|
async startTracking() {
|
|
4735
4686
|
const e = this.get("config"), t = e?.webVitalsMode ?? ye;
|
|
4736
|
-
this.vitalThresholds =
|
|
4687
|
+
this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
|
|
4737
4688
|
}
|
|
4738
4689
|
/**
|
|
4739
4690
|
* Stops tracking Web Vitals and cleans up resources.
|
|
@@ -4803,7 +4754,7 @@ class Ds extends _ {
|
|
|
4803
4754
|
}
|
|
4804
4755
|
async initWebVitals() {
|
|
4805
4756
|
try {
|
|
4806
|
-
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() =>
|
|
4757
|
+
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() => gr), o = (l) => (d) => {
|
|
4807
4758
|
const c = Number(d.value.toFixed(2));
|
|
4808
4759
|
this.sendVital({ type: l, value: c });
|
|
4809
4760
|
};
|
|
@@ -5098,7 +5049,7 @@ class ks extends _ {
|
|
|
5098
5049
|
try {
|
|
5099
5050
|
this.setupState(e);
|
|
5100
5051
|
const t = e.integrations?.custom?.headers ?? {}, s = e.integrations?.custom?.fetchCredentials ?? "include";
|
|
5101
|
-
return this.managers.event = new
|
|
5052
|
+
return this.managers.event = new vs(
|
|
5102
5053
|
this.managers.storage,
|
|
5103
5054
|
this.emitter,
|
|
5104
5055
|
this.transformers,
|
|
@@ -5144,14 +5095,14 @@ class ks extends _ {
|
|
|
5144
5095
|
*
|
|
5145
5096
|
* @param name - Event name
|
|
5146
5097
|
* @param metadata - Optional metadata
|
|
5147
|
-
* @param options - Optional event options. `{ critical: true }`
|
|
5148
|
-
*
|
|
5149
|
-
*
|
|
5150
|
-
*
|
|
5151
|
-
*
|
|
5152
|
-
*
|
|
5153
|
-
*
|
|
5154
|
-
*
|
|
5098
|
+
* @param options - Optional event options. `{ critical: true }` drains the
|
|
5099
|
+
* queue via `navigator.sendBeacon()` immediately after tracking — the
|
|
5100
|
+
* browser guarantees the request is queued for delivery even if the page
|
|
5101
|
+
* is about to unload (typical pattern: tracking a purchase, then
|
|
5102
|
+
* `window.location.href = '/thanks'`). If an async fetch is already in
|
|
5103
|
+
* flight when the critical event is tracked, the sync flush is deferred
|
|
5104
|
+
* and re-runs from the async send's `finally` block so the critical
|
|
5105
|
+
* event is not stranded in the queue.
|
|
5155
5106
|
* @internal Called from api.event()
|
|
5156
5107
|
*/
|
|
5157
5108
|
sendCustomEvent(e, t, s) {
|
|
@@ -5168,21 +5119,15 @@ class ks extends _ {
|
|
|
5168
5119
|
a("warn", `Custom event "${e}" dropped: ${o}`);
|
|
5169
5120
|
return;
|
|
5170
5121
|
}
|
|
5171
|
-
|
|
5172
|
-
if (this.managers.event.track({
|
|
5122
|
+
this.managers.event.track({
|
|
5173
5123
|
type: u.CUSTOM,
|
|
5174
5124
|
custom_event: {
|
|
5175
5125
|
name: e,
|
|
5176
5126
|
...l && { metadata: l }
|
|
5177
5127
|
}
|
|
5178
|
-
}), s?.critical === !0) {
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
return;
|
|
5182
|
-
}
|
|
5183
|
-
const f = this.managers.event.flushLastEventSync(), m = this.managers.event.flushImmediatelySync();
|
|
5184
|
-
!f && !m && a("debug", "Critical event: dedicated beacon and queue drain both failed", { data: { name: e } });
|
|
5185
|
-
}
|
|
5128
|
+
}), s?.critical === !0 && (this.managers.event.flushImmediatelySync() || a("debug", "Critical event flush returned false (deferred to in-flight send or empty queue)", {
|
|
5129
|
+
data: { name: e }
|
|
5130
|
+
}));
|
|
5186
5131
|
}
|
|
5187
5132
|
on(e, t) {
|
|
5188
5133
|
this.emitter.on(e, t);
|
|
@@ -5284,6 +5229,15 @@ class ks extends _ {
|
|
|
5284
5229
|
getSessionId() {
|
|
5285
5230
|
return this.get("sessionId");
|
|
5286
5231
|
}
|
|
5232
|
+
/**
|
|
5233
|
+
* Returns the current user ID.
|
|
5234
|
+
*
|
|
5235
|
+
* @returns The user ID string, or null if not yet initialized
|
|
5236
|
+
* @internal Used by api.getUserId()
|
|
5237
|
+
*/
|
|
5238
|
+
getUserId() {
|
|
5239
|
+
return this.get("userId");
|
|
5240
|
+
}
|
|
5287
5241
|
/**
|
|
5288
5242
|
* Validates metadata object structure and values.
|
|
5289
5243
|
*
|
|
@@ -5384,7 +5338,7 @@ class ks extends _ {
|
|
|
5384
5338
|
async resetIdentity() {
|
|
5385
5339
|
await this.managers.event?.flushImmediately(), this.set("identity", void 0), this.clearPersistedIdentity();
|
|
5386
5340
|
const e = dt();
|
|
5387
|
-
this.managers.storage.setItem(
|
|
5341
|
+
this.managers.storage.setItem(Ie, 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");
|
|
5388
5342
|
}
|
|
5389
5343
|
/**
|
|
5390
5344
|
* Returns the project ID used for identity storage scoping.
|
|
@@ -5601,7 +5555,7 @@ const Ws = (r) => {
|
|
|
5601
5555
|
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
5602
5556
|
h.removeCustomHeaders();
|
|
5603
5557
|
}
|
|
5604
|
-
}, js = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Ks = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Qs = () => {
|
|
5558
|
+
}, js = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Ks = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), zs = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getUserId(), Qs = () => {
|
|
5605
5559
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5606
5560
|
if (T)
|
|
5607
5561
|
throw new Error("[TraceLog] Destroy operation already in progress");
|
|
@@ -5616,9 +5570,9 @@ const Ws = (r) => {
|
|
|
5616
5570
|
h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, T = !1, a("warn", "Error during destroy, forced cleanup completed", { error: r });
|
|
5617
5571
|
}
|
|
5618
5572
|
}
|
|
5619
|
-
}, zs = (r) => {
|
|
5620
|
-
typeof window > "u" || typeof document > "u" || rs(r);
|
|
5621
5573
|
}, Ys = (r) => {
|
|
5574
|
+
typeof window > "u" || typeof document > "u" || rs(r);
|
|
5575
|
+
}, qs = (r) => {
|
|
5622
5576
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5623
5577
|
if (!h)
|
|
5624
5578
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5626,7 +5580,7 @@ const Ws = (r) => {
|
|
|
5626
5580
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5627
5581
|
h.updateGlobalMetadata(r);
|
|
5628
5582
|
}
|
|
5629
|
-
},
|
|
5583
|
+
}, Js = (r) => {
|
|
5630
5584
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5631
5585
|
if (!h)
|
|
5632
5586
|
throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
|
|
@@ -5634,7 +5588,7 @@ const Ws = (r) => {
|
|
|
5634
5588
|
throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
|
|
5635
5589
|
h.mergeGlobalMetadata(r);
|
|
5636
5590
|
}
|
|
5637
|
-
},
|
|
5591
|
+
}, Zs = (r, e) => {
|
|
5638
5592
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5639
5593
|
if (!r || typeof r != "string" || r.trim().length === 0) {
|
|
5640
5594
|
a("warn", "identify() called with invalid userId");
|
|
@@ -5662,7 +5616,7 @@ const Ws = (r) => {
|
|
|
5662
5616
|
a("debug", "Failed to persist pre-init identity");
|
|
5663
5617
|
}
|
|
5664
5618
|
}
|
|
5665
|
-
},
|
|
5619
|
+
}, er = async () => {
|
|
5666
5620
|
if (!(typeof window > "u" || typeof document > "u")) {
|
|
5667
5621
|
if (!h) {
|
|
5668
5622
|
try {
|
|
@@ -5675,7 +5629,7 @@ const Ws = (r) => {
|
|
|
5675
5629
|
throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
|
|
5676
5630
|
await h.resetIdentity();
|
|
5677
5631
|
}
|
|
5678
|
-
},
|
|
5632
|
+
}, Cr = {
|
|
5679
5633
|
init: Vs,
|
|
5680
5634
|
event: Us,
|
|
5681
5635
|
on: xs,
|
|
@@ -5686,12 +5640,13 @@ const Ws = (r) => {
|
|
|
5686
5640
|
removeCustomHeaders: Xs,
|
|
5687
5641
|
isInitialized: js,
|
|
5688
5642
|
getSessionId: Ks,
|
|
5643
|
+
getUserId: zs,
|
|
5689
5644
|
destroy: Qs,
|
|
5690
|
-
setQaMode:
|
|
5691
|
-
updateGlobalMetadata:
|
|
5692
|
-
mergeGlobalMetadata:
|
|
5693
|
-
identify:
|
|
5694
|
-
resetIdentity:
|
|
5645
|
+
setQaMode: Ys,
|
|
5646
|
+
updateGlobalMetadata: qs,
|
|
5647
|
+
mergeGlobalMetadata: Js,
|
|
5648
|
+
identify: Zs,
|
|
5649
|
+
resetIdentity: er,
|
|
5695
5650
|
flushImmediately: Hs,
|
|
5696
5651
|
flushImmediatelySync: Fs
|
|
5697
5652
|
};
|
|
@@ -5745,10 +5700,10 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5745
5700
|
}, F = -1, et = function() {
|
|
5746
5701
|
return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
|
|
5747
5702
|
}, ce = function(r) {
|
|
5748
|
-
document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0,
|
|
5703
|
+
document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0, tr());
|
|
5749
5704
|
}, tt = function() {
|
|
5750
5705
|
addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
|
|
5751
|
-
},
|
|
5706
|
+
}, tr = function() {
|
|
5752
5707
|
removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
|
|
5753
5708
|
}, Ve = function() {
|
|
5754
5709
|
return F < 0 && (F = et(), tt(), V((function() {
|
|
@@ -5758,12 +5713,12 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5758
5713
|
}))), { get firstHiddenTime() {
|
|
5759
5714
|
return F;
|
|
5760
5715
|
} };
|
|
5761
|
-
},
|
|
5716
|
+
}, z = function(r) {
|
|
5762
5717
|
document.prerendering ? addEventListener("prerenderingchange", (function() {
|
|
5763
5718
|
return r();
|
|
5764
5719
|
}), !0) : r();
|
|
5765
5720
|
}, Me = [1800, 3e3], St = function(r, e) {
|
|
5766
|
-
e = e || {},
|
|
5721
|
+
e = e || {}, z((function() {
|
|
5767
5722
|
var t, s = Ve(), n = y("FCP"), i = x("paint", (function(o) {
|
|
5768
5723
|
o.forEach((function(l) {
|
|
5769
5724
|
l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime - de(), 0), n.entries.push(l), t(!0)));
|
|
@@ -5775,13 +5730,13 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5775
5730
|
}));
|
|
5776
5731
|
})));
|
|
5777
5732
|
}));
|
|
5778
|
-
}, Ce = [0.1, 0.25],
|
|
5733
|
+
}, Ce = [0.1, 0.25], sr = function(r, e) {
|
|
5779
5734
|
e = e || {}, St(ue((function() {
|
|
5780
5735
|
var t, s = y("CLS", 0), n = 0, i = [], o = function(d) {
|
|
5781
5736
|
d.forEach((function(c) {
|
|
5782
5737
|
if (!c.hadRecentInput) {
|
|
5783
|
-
var f = i[0],
|
|
5784
|
-
n && c.startTime -
|
|
5738
|
+
var f = i[0], g = i[i.length - 1];
|
|
5739
|
+
n && c.startTime - g.startTime < 1e3 && c.startTime - f.startTime < 5e3 ? (n += c.value, i.push(c)) : (n = c.value, i = [c]);
|
|
5785
5740
|
}
|
|
5786
5741
|
})), n > s.value && (s.value = n, s.entries = i, t());
|
|
5787
5742
|
}, l = x("layout-shift", o);
|
|
@@ -5793,19 +5748,19 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5793
5748
|
}));
|
|
5794
5749
|
})), setTimeout(t, 0));
|
|
5795
5750
|
})));
|
|
5796
|
-
}, Tt = 0, Se = 1 / 0, J = 0,
|
|
5751
|
+
}, Tt = 0, Se = 1 / 0, J = 0, rr = function(r) {
|
|
5797
5752
|
r.forEach((function(e) {
|
|
5798
5753
|
e.interactionId && (Se = Math.min(Se, e.interactionId), J = Math.max(J, e.interactionId), Tt = J ? (J - Se) / 7 + 1 : 0);
|
|
5799
5754
|
}));
|
|
5800
|
-
},
|
|
5755
|
+
}, It = function() {
|
|
5801
5756
|
return Ae ? Tt : performance.interactionCount || 0;
|
|
5802
|
-
},
|
|
5803
|
-
"interactionCount" in performance || Ae || (Ae = x("event",
|
|
5804
|
-
}, L = [], te = /* @__PURE__ */ new Map(),
|
|
5805
|
-
var r = Math.min(L.length - 1, Math.floor((
|
|
5757
|
+
}, nr = function() {
|
|
5758
|
+
"interactionCount" in performance || Ae || (Ae = x("event", rr, { type: "event", buffered: !0, durationThreshold: 0 }));
|
|
5759
|
+
}, L = [], te = /* @__PURE__ */ new Map(), vt = 0, ir = function() {
|
|
5760
|
+
var r = Math.min(L.length - 1, Math.floor((It() - vt) / 50));
|
|
5806
5761
|
return L[r];
|
|
5807
|
-
},
|
|
5808
|
-
if (
|
|
5762
|
+
}, or = [], ar = function(r) {
|
|
5763
|
+
if (or.forEach((function(n) {
|
|
5809
5764
|
return n(r);
|
|
5810
5765
|
})), r.interactionId || r.entryType === "first-input") {
|
|
5811
5766
|
var e = L[L.length - 1], t = te.get(r.interactionId);
|
|
@@ -5825,25 +5780,25 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5825
5780
|
}, _t = function(r) {
|
|
5826
5781
|
var e = self.requestIdleCallback || self.setTimeout, t = -1;
|
|
5827
5782
|
return r = ue(r), document.visibilityState === "hidden" ? r() : (t = e(r), K(r)), t;
|
|
5828
|
-
}, Re = [200, 500],
|
|
5829
|
-
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {},
|
|
5783
|
+
}, Re = [200, 500], lr = function(r, e) {
|
|
5784
|
+
"PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, z((function() {
|
|
5830
5785
|
var t;
|
|
5831
|
-
|
|
5786
|
+
nr();
|
|
5832
5787
|
var s, n = y("INP"), i = function(l) {
|
|
5833
5788
|
_t((function() {
|
|
5834
|
-
l.forEach(
|
|
5835
|
-
var d =
|
|
5789
|
+
l.forEach(ar);
|
|
5790
|
+
var d = ir();
|
|
5836
5791
|
d && d.latency !== n.value && (n.value = d.latency, n.entries = d.entries, s());
|
|
5837
5792
|
}));
|
|
5838
5793
|
}, o = x("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
|
|
5839
5794
|
s = w(r, n, Re, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), K((function() {
|
|
5840
5795
|
i(o.takeRecords()), s(!0);
|
|
5841
5796
|
})), V((function() {
|
|
5842
|
-
|
|
5797
|
+
vt = It(), L.length = 0, te.clear(), n = y("INP"), s = w(r, n, Re, e.reportAllChanges);
|
|
5843
5798
|
})));
|
|
5844
5799
|
})));
|
|
5845
|
-
}, Ne = [2500, 4e3], Te = {},
|
|
5846
|
-
e = e || {},
|
|
5800
|
+
}, Ne = [2500, 4e3], Te = {}, cr = function(r, e) {
|
|
5801
|
+
e = e || {}, z((function() {
|
|
5847
5802
|
var t, s = Ve(), n = y("LCP"), i = function(d) {
|
|
5848
5803
|
e.reportAllChanges || (d = d.slice(-1)), d.forEach((function(c) {
|
|
5849
5804
|
c.startTime < s.firstHiddenTime && (n.value = Math.max(c.startTime - de(), 0), n.entries = [c], t());
|
|
@@ -5865,31 +5820,31 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5865
5820
|
}));
|
|
5866
5821
|
}
|
|
5867
5822
|
}));
|
|
5868
|
-
}, Oe = [800, 1800],
|
|
5869
|
-
document.prerendering ?
|
|
5823
|
+
}, Oe = [800, 1800], dr = function r(e) {
|
|
5824
|
+
document.prerendering ? z((function() {
|
|
5870
5825
|
return r(e);
|
|
5871
5826
|
})) : document.readyState !== "complete" ? addEventListener("load", (function() {
|
|
5872
5827
|
return r(e);
|
|
5873
5828
|
}), !0) : setTimeout(e, 0);
|
|
5874
|
-
},
|
|
5829
|
+
}, ur = function(r, e) {
|
|
5875
5830
|
e = e || {};
|
|
5876
5831
|
var t = y("TTFB"), s = w(r, t, Oe, e.reportAllChanges);
|
|
5877
|
-
|
|
5832
|
+
dr((function() {
|
|
5878
5833
|
var n = De();
|
|
5879
5834
|
n && (t.value = Math.max(n.responseStart - de(), 0), t.entries = [n], s(!0), V((function() {
|
|
5880
5835
|
t = y("TTFB", 0), (s = w(r, t, Oe, e.reportAllChanges))(!0);
|
|
5881
5836
|
})));
|
|
5882
5837
|
}));
|
|
5883
|
-
}, W = { passive: !0, capture: !0 },
|
|
5838
|
+
}, W = { passive: !0, capture: !0 }, hr = /* @__PURE__ */ new Date(), st = function(r, e) {
|
|
5884
5839
|
C || (C = e, X = r, pt = /* @__PURE__ */ new Date(), wt(removeEventListener), yt());
|
|
5885
5840
|
}, yt = function() {
|
|
5886
|
-
if (X >= 0 && X < pt -
|
|
5841
|
+
if (X >= 0 && X < pt - hr) {
|
|
5887
5842
|
var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + X };
|
|
5888
5843
|
le.forEach((function(e) {
|
|
5889
5844
|
e(r);
|
|
5890
5845
|
})), le = [];
|
|
5891
5846
|
}
|
|
5892
|
-
},
|
|
5847
|
+
}, fr = function(r) {
|
|
5893
5848
|
if (r.cancelable) {
|
|
5894
5849
|
var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
|
|
5895
5850
|
r.type == "pointerdown" ? (function(t, s) {
|
|
@@ -5905,10 +5860,10 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5905
5860
|
}
|
|
5906
5861
|
}, wt = function(r) {
|
|
5907
5862
|
["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
|
|
5908
|
-
return r(e,
|
|
5863
|
+
return r(e, fr, W);
|
|
5909
5864
|
}));
|
|
5910
|
-
}, Pe = [100, 300],
|
|
5911
|
-
e = e || {},
|
|
5865
|
+
}, Pe = [100, 300], mr = function(r, e) {
|
|
5866
|
+
e = e || {}, z((function() {
|
|
5912
5867
|
var t, s = Ve(), n = y("FID"), i = function(d) {
|
|
5913
5868
|
d.startTime < s.firstHiddenTime && (n.value = d.processingStart - d.startTime, n.entries.push(d), t(!0));
|
|
5914
5869
|
}, o = function(d) {
|
|
@@ -5922,7 +5877,7 @@ var Ae, C, X, pt, le, Et = -1, V = function(r) {
|
|
|
5922
5877
|
})));
|
|
5923
5878
|
}));
|
|
5924
5879
|
};
|
|
5925
|
-
const
|
|
5880
|
+
const gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5926
5881
|
__proto__: null,
|
|
5927
5882
|
CLSThresholds: Ce,
|
|
5928
5883
|
FCPThresholds: Me,
|
|
@@ -5930,31 +5885,31 @@ const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5930
5885
|
INPThresholds: Re,
|
|
5931
5886
|
LCPThresholds: Ne,
|
|
5932
5887
|
TTFBThresholds: Oe,
|
|
5933
|
-
onCLS:
|
|
5888
|
+
onCLS: sr,
|
|
5934
5889
|
onFCP: St,
|
|
5935
|
-
onFID:
|
|
5936
|
-
onINP:
|
|
5937
|
-
onLCP:
|
|
5938
|
-
onTTFB:
|
|
5890
|
+
onFID: mr,
|
|
5891
|
+
onINP: lr,
|
|
5892
|
+
onLCP: cr,
|
|
5893
|
+
onTTFB: ur
|
|
5939
5894
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5940
5895
|
export {
|
|
5941
5896
|
p as AppConfigValidationError,
|
|
5942
|
-
|
|
5897
|
+
pr as DEFAULT_SESSION_TIMEOUT,
|
|
5943
5898
|
ye as DEFAULT_WEB_VITALS_MODE,
|
|
5944
5899
|
A as DeviceType,
|
|
5945
5900
|
se as EmitterEvent,
|
|
5946
5901
|
B as ErrorType,
|
|
5947
5902
|
u as EventType,
|
|
5948
|
-
|
|
5903
|
+
Ar as InitializationTimeoutError,
|
|
5949
5904
|
N as IntegrationValidationError,
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5905
|
+
wr as MAX_ARRAY_LENGTH,
|
|
5906
|
+
Ir as MAX_CUSTOM_EVENT_ARRAY_SIZE,
|
|
5907
|
+
Tr as MAX_CUSTOM_EVENT_KEYS,
|
|
5908
|
+
Er as MAX_CUSTOM_EVENT_NAME_LENGTH,
|
|
5909
|
+
Sr as MAX_CUSTOM_EVENT_STRING_SIZE,
|
|
5955
5910
|
vr as MAX_NESTED_OBJECT_KEYS,
|
|
5956
|
-
|
|
5957
|
-
|
|
5911
|
+
_r as MAX_STRING_LENGTH,
|
|
5912
|
+
yr as MAX_STRING_LENGTH_IN_ARRAY,
|
|
5958
5913
|
ie as Mode,
|
|
5959
5914
|
at as PII_PATTERNS,
|
|
5960
5915
|
O as PermanentError,
|
|
@@ -5965,11 +5920,11 @@ export {
|
|
|
5965
5920
|
$ as SpecialApiUrl,
|
|
5966
5921
|
ne as TimeoutError,
|
|
5967
5922
|
j as TraceLogValidationError,
|
|
5968
|
-
|
|
5969
|
-
|
|
5923
|
+
Mr as WEB_VITALS_GOOD_THRESHOLDS,
|
|
5924
|
+
ze as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
|
|
5970
5925
|
Yt as WEB_VITALS_POOR_THRESHOLDS,
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5926
|
+
Qe as getWebVitalsThresholds,
|
|
5927
|
+
br as isPrimaryScrollEvent,
|
|
5928
|
+
Lr as isSecondaryScrollEvent,
|
|
5929
|
+
Cr as tracelog
|
|
5975
5930
|
};
|