@tracelog/lib 0.2.0 → 0.2.1
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var y = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(y || {});
|
|
2
|
-
const ee = 15 * 60 * 1e3, Ze = 1e3, et = 1e4,
|
|
2
|
+
const ee = 15 * 60 * 1e3, Ze = 1e3, et = 1e4, xe = 250, tt = 24, Ee = 500, ve = 3, rt = 5e3, Ue = 1e4, nt = 10, ye = 5, Te = 500, Ie = 120, A = 1, st = 0, it = 1, z = 3e4, G = 864e5, _e = 120, we = 8 * 1024, Ae = 10, be = 10, Y = 255, T = 1e3, K = 100, Me = 3, _ = 2, at = 2e3, k = "data-tl", ot = [
|
|
3
3
|
"button",
|
|
4
4
|
"a",
|
|
5
5
|
'input[type="button"]',
|
|
@@ -224,7 +224,7 @@ const St = () => {
|
|
|
224
224
|
const e = Math.random() * 16 | 0;
|
|
225
225
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
226
226
|
});
|
|
227
|
-
var w = /* @__PURE__ */ ((r) => (r.Skip = "skip", r.Localhost = "localhost:", r))(w || {}), re = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(re || {}), d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.SESSION_END = "session_end", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r))(d || {}),
|
|
227
|
+
var w = /* @__PURE__ */ ((r) => (r.Skip = "skip", r.Localhost = "localhost:", r))(w || {}), re = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(re || {}), d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.SESSION_END = "session_end", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r))(d || {}), U = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(U || {}), N = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r.NETWORK_ERROR = "network_error", r))(N || {}), H = /* @__PURE__ */ ((r) => (r.QA = "qa", r.DEBUG = "debug", r))(H || {}), yt = /* @__PURE__ */ ((r) => (r.AND = "AND", r.OR = "OR", r))(yt || {}), Tt = /* @__PURE__ */ ((r) => (r.URL_MATCHES = "url_matches", r.ELEMENT_MATCHES = "element_matches", r.DEVICE_TYPE = "device_type", r.ELEMENT_TEXT = "element_text", r.ELEMENT_ATTRIBUTE = "element_attribute", r.UTM_SOURCE = "utm_source", r.UTM_MEDIUM = "utm_medium", r.UTM_CAMPAIGN = "utm_campaign", r))(Tt || {}), It = /* @__PURE__ */ ((r) => (r.EQUALS = "equals", r.CONTAINS = "contains", r.STARTS_WITH = "starts_with", r.ENDS_WITH = "ends_with", r.REGEX = "regex", r.GREATER_THAN = "greater_than", r.LESS_THAN = "less_than", r.EXISTS = "exists", r.NOT_EXISTS = "not_exists", r))(It || {});
|
|
228
228
|
class O extends Error {
|
|
229
229
|
constructor(e, t, n) {
|
|
230
230
|
super(e), this.errorCode = t, this.layer = n, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
@@ -522,7 +522,7 @@ const At = (r) => {
|
|
|
522
522
|
error: e instanceof Error ? e.message : e
|
|
523
523
|
}), new Error(`Metadata sanitization failed: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
524
524
|
}
|
|
525
|
-
},
|
|
525
|
+
}, xt = (r) => {
|
|
526
526
|
if (typeof r != "object" || r === null)
|
|
527
527
|
return !1;
|
|
528
528
|
for (const e of Object.values(r)) {
|
|
@@ -539,7 +539,7 @@ const At = (r) => {
|
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
return !0;
|
|
542
|
-
},
|
|
542
|
+
}, Ut = (r) => typeof r != "string" ? {
|
|
543
543
|
valid: !1,
|
|
544
544
|
error: "Event name must be a string"
|
|
545
545
|
} : r.length === 0 ? {
|
|
@@ -556,7 +556,7 @@ const At = (r) => {
|
|
|
556
556
|
error: "Event name cannot be a reserved word"
|
|
557
557
|
} : { valid: !0 }, Ht = (r, e, t) => {
|
|
558
558
|
const n = kt(e), s = `${t} "${r}" metadata error`;
|
|
559
|
-
if (!
|
|
559
|
+
if (!xt(n))
|
|
560
560
|
return {
|
|
561
561
|
valid: !1,
|
|
562
562
|
error: `${s}: object has invalid types. Valid types are string, number, boolean or string arrays.`
|
|
@@ -605,7 +605,7 @@ const At = (r) => {
|
|
|
605
605
|
sanitizedMetadata: n
|
|
606
606
|
};
|
|
607
607
|
}, Vt = (r, e) => {
|
|
608
|
-
const t =
|
|
608
|
+
const t = Ut(r);
|
|
609
609
|
if (!t.valid)
|
|
610
610
|
return a.clientError("EventValidation", "Event name validation failed", { eventName: r, error: t.error }), t;
|
|
611
611
|
if (!e)
|
|
@@ -762,7 +762,7 @@ class he {
|
|
|
762
762
|
const n = this.buildConfigUrl(e, t), s = this.buildHeaders(t), i = await Gt(n, {
|
|
763
763
|
method: "GET",
|
|
764
764
|
headers: s,
|
|
765
|
-
timeout:
|
|
765
|
+
timeout: Ue
|
|
766
766
|
});
|
|
767
767
|
if (!i.ok)
|
|
768
768
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
@@ -927,7 +927,7 @@ class Qt extends f {
|
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
929
|
async sendWithTimeout(e, t) {
|
|
930
|
-
const n = new AbortController(), s = setTimeout(() => n.abort(),
|
|
930
|
+
const n = new AbortController(), s = setTimeout(() => n.abort(), Ue);
|
|
931
931
|
try {
|
|
932
932
|
const i = await fetch(e, {
|
|
933
933
|
method: "POST",
|
|
@@ -1792,7 +1792,7 @@ class Jt extends f {
|
|
|
1792
1792
|
this.processScrollEvent(s, i, o);
|
|
1793
1793
|
}
|
|
1794
1794
|
s.debounceTimer = null;
|
|
1795
|
-
},
|
|
1795
|
+
}, xe));
|
|
1796
1796
|
}, n = this.getScrollTop(e), s = {
|
|
1797
1797
|
element: e,
|
|
1798
1798
|
lastScrollPos: n,
|
|
@@ -1801,7 +1801,7 @@ class Jt extends f {
|
|
|
1801
1801
|
this.getScrollHeight(e),
|
|
1802
1802
|
this.getViewportHeight(e)
|
|
1803
1803
|
),
|
|
1804
|
-
lastDirection:
|
|
1804
|
+
lastDirection: U.DOWN,
|
|
1805
1805
|
lastEventTime: 0,
|
|
1806
1806
|
debounceTimer: null,
|
|
1807
1807
|
listener: t
|
|
@@ -1845,7 +1845,7 @@ class Jt extends f {
|
|
|
1845
1845
|
e.debounceTimer !== null && (clearTimeout(e.debounceTimer), e.debounceTimer = null);
|
|
1846
1846
|
}
|
|
1847
1847
|
getScrollDirection(e, t) {
|
|
1848
|
-
return e > t ?
|
|
1848
|
+
return e > t ? U.DOWN : U.UP;
|
|
1849
1849
|
}
|
|
1850
1850
|
calculateScrollDepth(e, t, n) {
|
|
1851
1851
|
if (t <= n)
|
|
@@ -2388,7 +2388,7 @@ class nr extends f {
|
|
|
2388
2388
|
const e = () => {
|
|
2389
2389
|
this.set("suppressNextScroll", !0), this.suppressNextScrollTimer && clearTimeout(this.suppressNextScrollTimer), this.suppressNextScrollTimer = window.setTimeout(() => {
|
|
2390
2390
|
this.set("suppressNextScroll", !1);
|
|
2391
|
-
},
|
|
2391
|
+
}, xe * ct);
|
|
2392
2392
|
};
|
|
2393
2393
|
this.handlers.pageView = new Xt(this.managers.event, e), this.handlers.pageView.startTracking(), this.handlers.click = new qt(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new Jt(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new tr(this.managers.event), this.handlers.performance.startTracking().catch(() => {
|
|
2394
2394
|
a.warn("App", "Failed to start performance tracking");
|
|
@@ -2455,10 +2455,10 @@ const sr = async (r) => {
|
|
|
2455
2455
|
}
|
|
2456
2456
|
}, Ir = {
|
|
2457
2457
|
WEB_VITALS_THRESHOLDS: Fe
|
|
2458
|
-
//
|
|
2458
|
+
// Business thresholds for performance analysis
|
|
2459
2459
|
}, _r = {
|
|
2460
2460
|
PII_PATTERNS: ze
|
|
2461
|
-
//
|
|
2461
|
+
// Patterns for sensitive data protection
|
|
2462
2462
|
}, wr = {
|
|
2463
2463
|
LOW_ACTIVITY_EVENT_COUNT: 50,
|
|
2464
2464
|
HIGH_ACTIVITY_EVENT_COUNT: 1e3,
|
|
@@ -2528,10 +2528,6 @@ const sr = async (r) => {
|
|
|
2528
2528
|
MIN_BASELINE_DAYS: 7,
|
|
2529
2529
|
MIN_EVENTS_FOR_ANOMALY_DETECTION: 50
|
|
2530
2530
|
}, Or = {
|
|
2531
|
-
PAGE_URL_EXCLUDED: "excluded",
|
|
2532
|
-
PAGE_URL_UNKNOWN: "unknown",
|
|
2533
|
-
IPV6_IPV4_PREFIX: "::ffff:"
|
|
2534
|
-
}, Dr = ["localhost", "127.0.0.1", "::1"], kr = {
|
|
2535
2531
|
init: sr,
|
|
2536
2532
|
event: ir,
|
|
2537
2533
|
on: ar,
|
|
@@ -2637,9 +2633,9 @@ var ae, je = -1, L = function(r) {
|
|
|
2637
2633
|
});
|
|
2638
2634
|
}), setTimeout(t, 0));
|
|
2639
2635
|
}));
|
|
2640
|
-
}, We = 0, J = 1 / 0,
|
|
2636
|
+
}, We = 0, J = 1 / 0, x = 0, hr = function(r) {
|
|
2641
2637
|
r.forEach(function(e) {
|
|
2642
|
-
e.interactionId && (J = Math.min(J, e.interactionId),
|
|
2638
|
+
e.interactionId && (J = Math.min(J, e.interactionId), x = Math.max(x, e.interactionId), We = x ? (x - J) / 7 + 1 : 0);
|
|
2643
2639
|
});
|
|
2644
2640
|
}, Be = function() {
|
|
2645
2641
|
return ae ? We : performance.interactionCount || 0;
|
|
@@ -2749,16 +2745,14 @@ export {
|
|
|
2749
2745
|
N as ErrorType,
|
|
2750
2746
|
d as EventType,
|
|
2751
2747
|
Rr as INSIGHT_THRESHOLDS,
|
|
2752
|
-
Dr as LOCAL_IP_ADDRESSES,
|
|
2753
2748
|
H as Mode,
|
|
2754
2749
|
Ir as PERFORMANCE_CONFIG,
|
|
2755
2750
|
Nr as SEGMENTATION_ANALYTICS,
|
|
2756
2751
|
Ar as SESSION_ANALYTICS,
|
|
2757
|
-
|
|
2758
|
-
x as ScrollDirection,
|
|
2752
|
+
U as ScrollDirection,
|
|
2759
2753
|
Lr as TEMPORAL_ANALYSIS,
|
|
2760
2754
|
It as TagConditionOperator,
|
|
2761
2755
|
Tt as TagConditionType,
|
|
2762
2756
|
yt as TagLogicalOperator,
|
|
2763
|
-
|
|
2757
|
+
Or as tracelog
|
|
2764
2758
|
};
|
|
@@ -72,9 +72,3 @@ export declare const ANOMALY_DETECTION: {
|
|
|
72
72
|
readonly MIN_BASELINE_DAYS: 7;
|
|
73
73
|
readonly MIN_EVENTS_FOR_ANOMALY_DETECTION: 50;
|
|
74
74
|
};
|
|
75
|
-
export declare const SPECIAL_VALUES: {
|
|
76
|
-
readonly PAGE_URL_EXCLUDED: "excluded";
|
|
77
|
-
readonly PAGE_URL_UNKNOWN: "unknown";
|
|
78
|
-
readonly IPV6_IPV4_PREFIX: "::ffff:";
|
|
79
|
-
};
|
|
80
|
-
export declare const LOCAL_IP_ADDRESSES: readonly ["localhost", "127.0.0.1", "::1"];
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
// Solo importamos constantes con valor analítico real
|
|
3
|
+
exports.ANOMALY_DETECTION = exports.ANALYTICS_QUERY_LIMITS = exports.SEGMENTATION_ANALYTICS = exports.TEMPORAL_ANALYSIS = exports.INSIGHT_THRESHOLDS = exports.CONTENT_ANALYTICS = exports.DEVICE_ANALYTICS = exports.SESSION_ANALYTICS = exports.ENGAGEMENT_THRESHOLDS = exports.DATA_PROTECTION = exports.PERFORMANCE_CONFIG = void 0;
|
|
5
4
|
const performance_constants_1 = require("./constants/performance.constants");
|
|
6
5
|
const error_constants_1 = require("./constants/error.constants");
|
|
7
|
-
// ============================================================================
|
|
8
|
-
// PERFORMANCE ANALYTICS CONSTANTS
|
|
9
|
-
// ============================================================================
|
|
10
6
|
exports.PERFORMANCE_CONFIG = {
|
|
11
|
-
WEB_VITALS_THRESHOLDS: performance_constants_1.WEB_VITALS_THRESHOLDS, //
|
|
7
|
+
WEB_VITALS_THRESHOLDS: performance_constants_1.WEB_VITALS_THRESHOLDS, // Business thresholds for performance analysis
|
|
12
8
|
};
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// DATA PROTECTION CONSTANTS
|
|
15
|
-
// ============================================================================
|
|
16
9
|
exports.DATA_PROTECTION = {
|
|
17
|
-
PII_PATTERNS: error_constants_1.PII_PATTERNS, //
|
|
10
|
+
PII_PATTERNS: error_constants_1.PII_PATTERNS, // Patterns for sensitive data protection
|
|
18
11
|
};
|
|
19
12
|
exports.ENGAGEMENT_THRESHOLDS = {
|
|
20
13
|
LOW_ACTIVITY_EVENT_COUNT: 50,
|
|
@@ -84,9 +77,3 @@ exports.ANOMALY_DETECTION = {
|
|
|
84
77
|
MIN_BASELINE_DAYS: 7,
|
|
85
78
|
MIN_EVENTS_FOR_ANOMALY_DETECTION: 50,
|
|
86
79
|
};
|
|
87
|
-
exports.SPECIAL_VALUES = {
|
|
88
|
-
PAGE_URL_EXCLUDED: 'excluded',
|
|
89
|
-
PAGE_URL_UNKNOWN: 'unknown',
|
|
90
|
-
IPV6_IPV4_PREFIX: '::ffff:',
|
|
91
|
-
};
|
|
92
|
-
exports.LOCAL_IP_ADDRESSES = ['localhost', '127.0.0.1', '::1'];
|
|
@@ -72,9 +72,3 @@ export declare const ANOMALY_DETECTION: {
|
|
|
72
72
|
readonly MIN_BASELINE_DAYS: 7;
|
|
73
73
|
readonly MIN_EVENTS_FOR_ANOMALY_DETECTION: 50;
|
|
74
74
|
};
|
|
75
|
-
export declare const SPECIAL_VALUES: {
|
|
76
|
-
readonly PAGE_URL_EXCLUDED: "excluded";
|
|
77
|
-
readonly PAGE_URL_UNKNOWN: "unknown";
|
|
78
|
-
readonly IPV6_IPV4_PREFIX: "::ffff:";
|
|
79
|
-
};
|
|
80
|
-
export declare const LOCAL_IP_ADDRESSES: readonly ["localhost", "127.0.0.1", "::1"];
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
// Solo importamos constantes con valor analítico real
|
|
2
1
|
import { WEB_VITALS_THRESHOLDS } from './constants/performance.constants';
|
|
3
2
|
import { PII_PATTERNS } from './constants/error.constants';
|
|
4
|
-
// ============================================================================
|
|
5
|
-
// PERFORMANCE ANALYTICS CONSTANTS
|
|
6
|
-
// ============================================================================
|
|
7
3
|
export const PERFORMANCE_CONFIG = {
|
|
8
|
-
WEB_VITALS_THRESHOLDS, //
|
|
4
|
+
WEB_VITALS_THRESHOLDS, // Business thresholds for performance analysis
|
|
9
5
|
};
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// DATA PROTECTION CONSTANTS
|
|
12
|
-
// ============================================================================
|
|
13
6
|
export const DATA_PROTECTION = {
|
|
14
|
-
PII_PATTERNS, //
|
|
7
|
+
PII_PATTERNS, // Patterns for sensitive data protection
|
|
15
8
|
};
|
|
16
9
|
export const ENGAGEMENT_THRESHOLDS = {
|
|
17
10
|
LOW_ACTIVITY_EVENT_COUNT: 50,
|
|
@@ -81,9 +74,3 @@ export const ANOMALY_DETECTION = {
|
|
|
81
74
|
MIN_BASELINE_DAYS: 7,
|
|
82
75
|
MIN_EVENTS_FOR_ANOMALY_DETECTION: 50,
|
|
83
76
|
};
|
|
84
|
-
export const SPECIAL_VALUES = {
|
|
85
|
-
PAGE_URL_EXCLUDED: 'excluded',
|
|
86
|
-
PAGE_URL_UNKNOWN: 'unknown',
|
|
87
|
-
IPV6_IPV4_PREFIX: '::ffff:',
|
|
88
|
-
};
|
|
89
|
-
export const LOCAL_IP_ADDRESSES = ['localhost', '127.0.0.1', '::1'];
|
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.2.
|
|
5
|
+
"version": "0.2.1",
|
|
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",
|