@tracelog/lib 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/tracelog.js +26 -25
- package/dist/cjs/app.types.d.ts +1 -0
- package/dist/cjs/app.types.js +1 -0
- package/dist/esm/app.types.d.ts +1 -0
- package/dist/esm/app.types.js +1 -0
- package/package.json +1 -1
package/dist/browser/tracelog.js
CHANGED
|
@@ -158,14 +158,14 @@ const ke = () => {
|
|
|
158
158
|
error: n instanceof Error ? n.message : n
|
|
159
159
|
}), E.Desktop;
|
|
160
160
|
}
|
|
161
|
-
}, Ne = 2, Ue = 10, Ie = 1, ne = 500, Z = 3e4, ee = 864e5, re = 120, ae = 8 * 1024, oe = 10, ce = 10, _ = 255, M = 1e3, W = 100, le = 3,
|
|
161
|
+
}, Ne = 2, Ue = 10, Ie = 1, ne = 500, Z = 3e4, ee = 864e5, re = 120, ae = 8 * 1024, oe = 10, ce = 10, _ = 255, M = 1e3, W = 100, le = 3, N = 2, Pe = 4, He = 0.75, De = 0.2, xe = 2e3, Oe = 1e3, Fe = 10, F = 10, R = 15 * 60 * 1e3, ze = 3e4, Te = 1e3, Me = 250, Ve = 2e3, de = 1e3, $e = 1e4, je = 2500, he = 1e3, ue = 3e4, ge = 1e3, Ge = 24, Qe = 24 * 60 * 60 * 1e3, Be = Te, qe = 5e3, We = 2e3, Xe = 2, Ke = 3, X = 24 * 60 * 60 * 1e3, K = 2 * 60 * 1e3, Ye = "https://api.tracelog.io", Ae = {
|
|
162
162
|
samplingRate: Ie,
|
|
163
163
|
tags: [],
|
|
164
164
|
excludedUrlPaths: []
|
|
165
165
|
}, Je = (n) => ({
|
|
166
166
|
...Ae,
|
|
167
167
|
...n,
|
|
168
|
-
sessionTimeout:
|
|
168
|
+
sessionTimeout: R,
|
|
169
169
|
allowHttp: !1
|
|
170
170
|
}), z = "data-tl", fe = [
|
|
171
171
|
"button",
|
|
@@ -279,7 +279,7 @@ const ke = () => {
|
|
|
279
279
|
});
|
|
280
280
|
return i.verbose("UUIDUtils", "Generated new UUID", { uuid: n }), n;
|
|
281
281
|
};
|
|
282
|
-
var C = /* @__PURE__ */ ((n) => (n.HttpSkip = "http-skip", n.HttpLocal = "http-local", n))(C || {}), h = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.SESSION_END = "session_end", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(h || {}), j = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(j || {}), D = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n.NETWORK_ERROR = "network_error", n))(D || {}),
|
|
282
|
+
var C = /* @__PURE__ */ ((n) => (n.HttpSkip = "http-skip", n.HttpLocal = "http-local", n))(C || {}), h = /* @__PURE__ */ ((n) => (n.PAGE_VIEW = "page_view", n.CLICK = "click", n.SCROLL = "scroll", n.SESSION_START = "session_start", n.SESSION_END = "session_end", n.CUSTOM = "custom", n.WEB_VITALS = "web_vitals", n.ERROR = "error", n))(h || {}), j = /* @__PURE__ */ ((n) => (n.UP = "up", n.DOWN = "down", n))(j || {}), D = /* @__PURE__ */ ((n) => (n.JS_ERROR = "js_error", n.PROMISE_REJECTION = "promise_rejection", n.NETWORK_ERROR = "network_error", n))(D || {}), L = /* @__PURE__ */ ((n) => (n.QA = "qa", n.DEBUG = "debug", n))(L || {}), G = /* @__PURE__ */ ((n) => (n.AND = "AND", n.OR = "OR", n))(G || {}), m = /* @__PURE__ */ ((n) => (n.URL_MATCHES = "url_matches", n.ELEMENT_MATCHES = "element_matches", n.DEVICE_TYPE = "device_type", n.ELEMENT_TEXT = "element_text", n.ELEMENT_ATTRIBUTE = "element_attribute", n.UTM_SOURCE = "utm_source", n.UTM_MEDIUM = "utm_medium", n.UTM_CAMPAIGN = "utm_campaign", n))(m || {}), f = /* @__PURE__ */ ((n) => (n.EQUALS = "equals", n.CONTAINS = "contains", n.STARTS_WITH = "starts_with", n.ENDS_WITH = "ends_with", n.REGEX = "regex", n.GREATER_THAN = "greater_than", n.LESS_THAN = "less_than", n.EXISTS = "exists", n.NOT_EXISTS = "not_exists", n))(f || {});
|
|
283
283
|
class x extends Error {
|
|
284
284
|
constructor(e, t, s) {
|
|
285
285
|
super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -770,8 +770,8 @@ class wt {
|
|
|
770
770
|
isArray: Array.isArray(o)
|
|
771
771
|
}), new Error("Invalid config API response: expected object");
|
|
772
772
|
const l = gt(o), d = { ...{ ...Ae, ...l }, ...t };
|
|
773
|
-
new URLSearchParams(window.location.search).get("qaMode") === "true" && !d.mode && (d.mode =
|
|
774
|
-
const y = Object.values(
|
|
773
|
+
new URLSearchParams(window.location.search).get("qaMode") === "true" && !d.mode && (d.mode = L.QA, i.info("ConfigManager", "QA mode enabled via URL parameter"));
|
|
774
|
+
const y = Object.values(L).includes(d.mode) ? 1 : d.errorSampling ?? 0.1;
|
|
775
775
|
return { ...d, errorSampling: y };
|
|
776
776
|
} catch (r) {
|
|
777
777
|
const a = r instanceof Error ? r.message : "Unknown error";
|
|
@@ -789,7 +789,7 @@ class wt {
|
|
|
789
789
|
return Je({
|
|
790
790
|
...e,
|
|
791
791
|
errorSampling: 1,
|
|
792
|
-
...Object.values(C).includes(e.id) && { mode:
|
|
792
|
+
...Object.values(C).includes(e.id) && { mode: L.DEBUG }
|
|
793
793
|
});
|
|
794
794
|
}
|
|
795
795
|
}
|
|
@@ -996,7 +996,7 @@ class It extends p {
|
|
|
996
996
|
}
|
|
997
997
|
}
|
|
998
998
|
shouldSkipSend() {
|
|
999
|
-
const { id: e, mode: t } = this.get("config"), s = [
|
|
999
|
+
const { id: e, mode: t } = this.get("config"), s = [L.QA, L.DEBUG];
|
|
1000
1000
|
return e === C.HttpSkip ? !0 : !!t && s.includes(t) && e !== C.HttpLocal;
|
|
1001
1001
|
}
|
|
1002
1002
|
isSendBeaconAvailable() {
|
|
@@ -1312,12 +1312,12 @@ class At extends p {
|
|
|
1312
1312
|
session_end_reason: c,
|
|
1313
1313
|
session_start_recovered: d
|
|
1314
1314
|
})) {
|
|
1315
|
-
const
|
|
1315
|
+
const k = Date.now();
|
|
1316
1316
|
if (this.eventsQueue && this.eventsQueue.length > 0) {
|
|
1317
1317
|
const P = this.eventsQueue.at(-1);
|
|
1318
|
-
P && (P.timestamp =
|
|
1318
|
+
P && (P.timestamp = k);
|
|
1319
1319
|
}
|
|
1320
|
-
this.lastEvent && (this.lastEvent.timestamp =
|
|
1320
|
+
this.lastEvent && (this.lastEvent.timestamp = k), i.debug("EventManager", "Duplicate event detected, timestamp updated", {
|
|
1321
1321
|
type: e,
|
|
1322
1322
|
queueLength: this.eventsQueue.length
|
|
1323
1323
|
});
|
|
@@ -1345,11 +1345,11 @@ class At extends p {
|
|
|
1345
1345
|
...d && { session_start_recovered: d }
|
|
1346
1346
|
};
|
|
1347
1347
|
if (this.get("config")?.tags?.length) {
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1348
|
+
const k = this.tagsManager.getEventTagsIds(O, this.get("device"));
|
|
1349
|
+
k?.length && (O.tags = this.get("config")?.mode === "qa" || this.get("config")?.mode === "debug" ? k.map((P) => ({
|
|
1350
1350
|
id: P,
|
|
1351
1351
|
key: this.get("config")?.tags?.find((Le) => Le.id === P)?.key ?? ""
|
|
1352
|
-
})) :
|
|
1352
|
+
})) : k);
|
|
1353
1353
|
}
|
|
1354
1354
|
this.lastEvent = O, this.processAndSend(O);
|
|
1355
1355
|
}
|
|
@@ -1805,7 +1805,7 @@ class Ce extends p {
|
|
|
1805
1805
|
* Calculate the recovery window with bounds checking
|
|
1806
1806
|
*/
|
|
1807
1807
|
calculateRecoveryWindow() {
|
|
1808
|
-
const t = (this.get("config")?.sessionTimeout ??
|
|
1808
|
+
const t = (this.get("config")?.sessionTimeout ?? R) * Xe, s = Math.max(
|
|
1809
1809
|
Math.min(t, X),
|
|
1810
1810
|
K
|
|
1811
1811
|
);
|
|
@@ -1973,7 +1973,7 @@ class Pt extends p {
|
|
|
1973
1973
|
throttleDelay: Te,
|
|
1974
1974
|
visibilityTimeout: Ve,
|
|
1975
1975
|
motionThreshold: Ne,
|
|
1976
|
-
timeout: this.get("config")?.sessionTimeout ??
|
|
1976
|
+
timeout: this.get("config")?.sessionTimeout ?? R
|
|
1977
1977
|
}, this.sessionEndConfig = {
|
|
1978
1978
|
enablePageUnloadHandlers: !0,
|
|
1979
1979
|
syncTimeoutMs: 1e3,
|
|
@@ -2711,8 +2711,8 @@ class Ht extends p {
|
|
|
2711
2711
|
getEffectiveSessionTimeout() {
|
|
2712
2712
|
const e = this.getStoredSessionContext();
|
|
2713
2713
|
if (!e)
|
|
2714
|
-
return this.get("config")?.sessionTimeout ??
|
|
2715
|
-
const s = Date.now() - e.lastActivity, r = this.get("config")?.sessionTimeout ??
|
|
2714
|
+
return this.get("config")?.sessionTimeout ?? R;
|
|
2715
|
+
const s = Date.now() - e.lastActivity, r = this.get("config")?.sessionTimeout ?? R;
|
|
2716
2716
|
return Math.max(0, r - s);
|
|
2717
2717
|
}
|
|
2718
2718
|
/**
|
|
@@ -2913,7 +2913,7 @@ class Dt extends p {
|
|
|
2913
2913
|
const e = this.storageManager.getItem(this.sessionStorageKey);
|
|
2914
2914
|
if (e)
|
|
2915
2915
|
try {
|
|
2916
|
-
const t = JSON.parse(e), r = Date.now() - t.lastHeartbeat, a = this.get("config")?.sessionTimeout ??
|
|
2916
|
+
const t = JSON.parse(e), r = Date.now() - t.lastHeartbeat, a = this.get("config")?.sessionTimeout ?? R;
|
|
2917
2917
|
if (r > a) {
|
|
2918
2918
|
const o = this.recoveryManager?.hasRecoverableSession();
|
|
2919
2919
|
if (o && this.recoveryManager) {
|
|
@@ -3434,7 +3434,7 @@ class $t extends p {
|
|
|
3434
3434
|
"largest-contentful-paint",
|
|
3435
3435
|
(t) => {
|
|
3436
3436
|
const s = t.getEntries(), r = s[s.length - 1];
|
|
3437
|
-
r && this.sendVital({ type: "LCP", value: Number(r.startTime.toFixed(
|
|
3437
|
+
r && this.sendVital({ type: "LCP", value: Number(r.startTime.toFixed(N)) });
|
|
3438
3438
|
},
|
|
3439
3439
|
{ type: "largest-contentful-paint", buffered: !0 },
|
|
3440
3440
|
!0
|
|
@@ -3457,7 +3457,7 @@ class $t extends p {
|
|
|
3457
3457
|
"paint",
|
|
3458
3458
|
(t) => {
|
|
3459
3459
|
for (const s of t.getEntries())
|
|
3460
|
-
s.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(s.startTime.toFixed(
|
|
3460
|
+
s.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(s.startTime.toFixed(N)) });
|
|
3461
3461
|
},
|
|
3462
3462
|
{ type: "paint", buffered: !0 },
|
|
3463
3463
|
!0
|
|
@@ -3470,7 +3470,7 @@ class $t extends p {
|
|
|
3470
3470
|
const o = (a.processingEnd ?? 0) - (a.startTime ?? 0);
|
|
3471
3471
|
s = Math.max(s, o);
|
|
3472
3472
|
}
|
|
3473
|
-
s > 0 && this.sendVital({ type: "INP", value: Number(s.toFixed(
|
|
3473
|
+
s > 0 && this.sendVital({ type: "INP", value: Number(s.toFixed(N)) });
|
|
3474
3474
|
},
|
|
3475
3475
|
{ type: "event", buffered: !0 }
|
|
3476
3476
|
);
|
|
@@ -3478,7 +3478,7 @@ class $t extends p {
|
|
|
3478
3478
|
async initWebVitals() {
|
|
3479
3479
|
try {
|
|
3480
3480
|
const { onLCP: e, onCLS: t, onFCP: s, onTTFB: r, onINP: a } = await import("./web-vitals-CCnqwnC8.mjs"), o = (l) => (c) => {
|
|
3481
|
-
const d = Number(c.value.toFixed(
|
|
3481
|
+
const d = Number(c.value.toFixed(N));
|
|
3482
3482
|
this.sendVital({ type: l, value: d });
|
|
3483
3483
|
};
|
|
3484
3484
|
e(o("LCP")), t(o("CLS")), s(o("FCP")), r(o("TTFB")), a(o("INP"));
|
|
@@ -3496,7 +3496,7 @@ class $t extends p {
|
|
|
3496
3496
|
return;
|
|
3497
3497
|
}
|
|
3498
3498
|
const t = e.responseStart;
|
|
3499
|
-
typeof t == "number" && Number.isFinite(t) ? this.sendVital({ type: "TTFB", value: Number(t.toFixed(
|
|
3499
|
+
typeof t == "number" && Number.isFinite(t) ? this.sendVital({ type: "TTFB", value: Number(t.toFixed(N)) }) : i.debug("PerformanceHandler", "TTFB value is not a valid number", { ttfb: t });
|
|
3500
3500
|
} catch (e) {
|
|
3501
3501
|
i.warn("PerformanceHandler", "Failed to report TTFB", {
|
|
3502
3502
|
error: e instanceof Error ? e.message : "Unknown error"
|
|
@@ -3509,7 +3509,7 @@ class $t extends p {
|
|
|
3509
3509
|
(e) => {
|
|
3510
3510
|
const t = e.getEntries();
|
|
3511
3511
|
for (const s of t) {
|
|
3512
|
-
const r = Number(s.duration.toFixed(
|
|
3512
|
+
const r = Number(s.duration.toFixed(N)), a = Date.now();
|
|
3513
3513
|
a - this.lastLongTaskSentAt >= Be && (this.trackWebVital("LONG_TASK", r), this.lastLongTaskSentAt = a);
|
|
3514
3514
|
}
|
|
3515
3515
|
},
|
|
@@ -3933,13 +3933,14 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3933
3933
|
DeviceType: E,
|
|
3934
3934
|
ErrorType: D,
|
|
3935
3935
|
EventType: h,
|
|
3936
|
+
Mode: L,
|
|
3936
3937
|
ScrollDirection: j,
|
|
3937
3938
|
TagConditionOperator: f,
|
|
3938
3939
|
TagConditionType: m,
|
|
3939
3940
|
TagLogicalOperator: G
|
|
3940
3941
|
}, Symbol.toStringTag, { value: "Module" })), qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3941
3942
|
__proto__: null,
|
|
3942
|
-
DEFAULT_SESSION_TIMEOUT_MS:
|
|
3943
|
+
DEFAULT_SESSION_TIMEOUT_MS: R
|
|
3943
3944
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3944
3945
|
let v = null, T = !1;
|
|
3945
3946
|
const Wt = async (n) => {
|
package/dist/cjs/app.types.d.ts
CHANGED
package/dist/cjs/app.types.js
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./types/common.types"), exports);
|
|
|
18
18
|
__exportStar(require("./types/config.types"), exports);
|
|
19
19
|
__exportStar(require("./types/device.types"), exports);
|
|
20
20
|
__exportStar(require("./types/event.types"), exports);
|
|
21
|
+
__exportStar(require("./types/mode.types"), exports);
|
|
21
22
|
__exportStar(require("./types/queue.types"), exports);
|
|
22
23
|
__exportStar(require("./types/tag.types"), exports);
|
package/dist/esm/app.types.d.ts
CHANGED
package/dist/esm/app.types.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tracelog/lib",
|
|
3
3
|
"description": "JavaScript library for web analytics and real-time event tracking",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.2",
|
|
6
6
|
"main": "./dist/cjs/public-api.js",
|
|
7
7
|
"module": "./dist/esm/public-api.js",
|
|
8
8
|
"types": "./dist/esm/public-api.d.ts",
|