@tracelog/lib 0.0.8 → 0.2.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 +58 -24
- package/dist/browser/tracelog.js +1934 -3226
- package/dist/cjs/api.d.ts +33 -19
- package/dist/cjs/api.js +111 -156
- package/dist/cjs/app.constants.d.ts +80 -1
- package/dist/cjs/app.constants.js +90 -3
- package/dist/cjs/app.d.ts +29 -44
- package/dist/cjs/app.js +114 -212
- package/dist/cjs/app.types.d.ts +2 -7
- package/dist/cjs/app.types.js +10 -21
- package/dist/cjs/constants/api.constants.js +11 -5
- package/dist/cjs/constants/config.constants.d.ts +75 -0
- package/dist/cjs/constants/config.constants.js +178 -0
- package/dist/cjs/constants/error.constants.d.ts +29 -0
- package/dist/cjs/constants/error.constants.js +50 -0
- package/dist/cjs/constants/index.d.ts +3 -6
- package/dist/cjs/constants/index.js +3 -6
- package/dist/cjs/constants/performance.constants.d.ts +28 -0
- package/dist/cjs/constants/performance.constants.js +43 -0
- package/dist/cjs/handlers/click.handler.d.ts +1 -0
- package/dist/cjs/handlers/click.handler.js +30 -49
- package/dist/cjs/handlers/error.handler.d.ts +11 -6
- package/dist/cjs/handlers/error.handler.js +91 -51
- package/dist/cjs/handlers/page-view.handler.js +38 -29
- package/dist/cjs/handlers/performance.handler.d.ts +3 -0
- package/dist/cjs/handlers/performance.handler.js +76 -37
- package/dist/cjs/handlers/scroll.handler.d.ts +15 -0
- package/dist/cjs/handlers/scroll.handler.js +105 -31
- package/dist/cjs/handlers/session.handler.d.ts +6 -20
- package/dist/cjs/handlers/session.handler.js +38 -326
- package/dist/cjs/integrations/google-analytics.integration.d.ts +0 -1
- package/dist/cjs/integrations/google-analytics.integration.js +27 -98
- package/dist/cjs/listeners/input-listener-managers.d.ts +18 -9
- package/dist/cjs/listeners/input-listener-managers.js +24 -33
- package/dist/cjs/listeners/touch-listener-manager.d.ts +1 -3
- package/dist/cjs/listeners/touch-listener-manager.js +1 -23
- package/dist/cjs/listeners/visibility-listener-manager.d.ts +1 -4
- package/dist/cjs/listeners/visibility-listener-manager.js +6 -42
- package/dist/cjs/managers/api.manager.d.ts +13 -3
- package/dist/cjs/managers/api.manager.js +35 -5
- package/dist/cjs/managers/config.manager.d.ts +53 -3
- package/dist/cjs/managers/config.manager.js +131 -62
- package/dist/cjs/managers/event.manager.d.ts +57 -36
- package/dist/cjs/managers/event.manager.js +266 -417
- package/dist/cjs/managers/sender.manager.d.ts +40 -22
- package/dist/cjs/managers/sender.manager.js +200 -198
- package/dist/cjs/managers/session.manager.d.ts +80 -66
- package/dist/cjs/managers/session.manager.js +267 -522
- package/dist/cjs/managers/state.manager.d.ts +33 -0
- package/dist/cjs/managers/state.manager.js +79 -6
- package/dist/cjs/managers/storage.manager.d.ts +26 -2
- package/dist/cjs/managers/storage.manager.js +67 -34
- package/dist/cjs/managers/tags.manager.d.ts +31 -7
- package/dist/cjs/managers/tags.manager.js +123 -241
- package/dist/cjs/managers/user.manager.d.ts +14 -5
- package/dist/cjs/managers/user.manager.js +17 -9
- package/dist/cjs/public-api.d.ts +10 -1
- package/dist/cjs/public-api.js +18 -24
- package/dist/cjs/test-bridge.d.ts +48 -0
- package/dist/cjs/test-bridge.js +110 -0
- package/dist/cjs/types/api.types.d.ts +21 -6
- package/dist/cjs/types/api.types.js +21 -6
- package/dist/cjs/types/config.types.d.ts +22 -84
- package/dist/cjs/types/emitter.types.d.ts +11 -0
- package/dist/cjs/types/emitter.types.js +8 -0
- package/dist/cjs/types/event.types.d.ts +8 -11
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/cjs/types/index.js +3 -1
- package/dist/cjs/types/queue.types.d.ts +1 -0
- package/dist/cjs/types/session.types.d.ts +0 -64
- package/dist/cjs/types/state.types.d.ts +1 -0
- package/dist/cjs/types/test-bridge.types.d.ts +38 -0
- package/dist/cjs/types/validation-error.types.d.ts +7 -0
- package/dist/cjs/types/validation-error.types.js +11 -1
- package/dist/cjs/types/window.types.d.ts +1 -8
- package/dist/cjs/utils/data/uuid.utils.d.ts +1 -1
- package/dist/cjs/utils/data/uuid.utils.js +7 -5
- package/dist/cjs/utils/emitter.utils.d.ts +8 -0
- package/dist/cjs/utils/emitter.utils.js +33 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/logging/debug-logger.utils.d.ts +10 -51
- package/dist/cjs/utils/logging/debug-logger.utils.js +36 -127
- package/dist/cjs/utils/network/fetch-with-timeout.utils.d.ts +4 -0
- package/dist/cjs/utils/network/fetch-with-timeout.utils.js +25 -0
- package/dist/cjs/utils/network/index.d.ts +1 -0
- package/dist/cjs/utils/network/index.js +1 -0
- package/dist/cjs/utils/network/url.utils.js +2 -42
- package/dist/cjs/utils/security/sanitize.utils.d.ts +1 -8
- package/dist/cjs/utils/security/sanitize.utils.js +7 -41
- package/dist/cjs/utils/validations/config-validations.utils.d.ts +7 -0
- package/dist/cjs/utils/validations/config-validations.utils.js +77 -22
- package/dist/esm/api.d.ts +33 -19
- package/dist/esm/api.js +105 -118
- package/dist/esm/app.constants.d.ts +80 -1
- package/dist/esm/app.constants.js +89 -1
- package/dist/esm/app.d.ts +29 -44
- package/dist/esm/app.js +115 -213
- package/dist/esm/app.types.d.ts +2 -7
- package/dist/esm/app.types.js +1 -7
- package/dist/esm/constants/api.constants.js +10 -4
- package/dist/esm/constants/config.constants.d.ts +75 -0
- package/dist/esm/constants/config.constants.js +174 -0
- package/dist/esm/constants/error.constants.d.ts +29 -0
- package/dist/esm/constants/error.constants.js +47 -0
- package/dist/esm/constants/index.d.ts +3 -6
- package/dist/esm/constants/index.js +3 -6
- package/dist/esm/constants/performance.constants.d.ts +28 -0
- package/dist/esm/constants/performance.constants.js +40 -0
- package/dist/esm/handlers/click.handler.d.ts +1 -0
- package/dist/esm/handlers/click.handler.js +30 -49
- package/dist/esm/handlers/error.handler.d.ts +11 -6
- package/dist/esm/handlers/error.handler.js +91 -51
- package/dist/esm/handlers/page-view.handler.js +38 -29
- package/dist/esm/handlers/performance.handler.d.ts +3 -0
- package/dist/esm/handlers/performance.handler.js +71 -32
- package/dist/esm/handlers/scroll.handler.d.ts +15 -0
- package/dist/esm/handlers/scroll.handler.js +106 -32
- package/dist/esm/handlers/session.handler.d.ts +6 -20
- package/dist/esm/handlers/session.handler.js +38 -326
- package/dist/esm/integrations/google-analytics.integration.d.ts +0 -1
- package/dist/esm/integrations/google-analytics.integration.js +27 -98
- package/dist/esm/listeners/input-listener-managers.d.ts +18 -9
- package/dist/esm/listeners/input-listener-managers.js +23 -32
- package/dist/esm/listeners/touch-listener-manager.d.ts +1 -3
- package/dist/esm/listeners/touch-listener-manager.js +1 -23
- package/dist/esm/listeners/visibility-listener-manager.d.ts +1 -4
- package/dist/esm/listeners/visibility-listener-manager.js +6 -42
- package/dist/esm/managers/api.manager.d.ts +13 -3
- package/dist/esm/managers/api.manager.js +34 -3
- package/dist/esm/managers/config.manager.d.ts +53 -3
- package/dist/esm/managers/config.manager.js +133 -64
- package/dist/esm/managers/event.manager.d.ts +57 -36
- package/dist/esm/managers/event.manager.js +268 -419
- package/dist/esm/managers/sender.manager.d.ts +40 -22
- package/dist/esm/managers/sender.manager.js +201 -199
- package/dist/esm/managers/session.manager.d.ts +80 -66
- package/dist/esm/managers/session.manager.js +269 -524
- package/dist/esm/managers/state.manager.d.ts +33 -0
- package/dist/esm/managers/state.manager.js +78 -6
- package/dist/esm/managers/storage.manager.d.ts +26 -2
- package/dist/esm/managers/storage.manager.js +66 -33
- package/dist/esm/managers/tags.manager.d.ts +31 -7
- package/dist/esm/managers/tags.manager.js +124 -242
- package/dist/esm/managers/user.manager.d.ts +14 -5
- package/dist/esm/managers/user.manager.js +17 -9
- package/dist/esm/public-api.d.ts +10 -1
- package/dist/esm/public-api.js +14 -1
- package/dist/esm/test-bridge.d.ts +48 -0
- package/dist/esm/test-bridge.js +106 -0
- package/dist/esm/types/api.types.d.ts +21 -6
- package/dist/esm/types/api.types.js +21 -6
- package/dist/esm/types/config.types.d.ts +22 -84
- package/dist/esm/types/emitter.types.d.ts +11 -0
- package/dist/esm/types/emitter.types.js +5 -0
- package/dist/esm/types/event.types.d.ts +8 -11
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/esm/types/index.js +3 -1
- package/dist/esm/types/queue.types.d.ts +1 -0
- package/dist/esm/types/session.types.d.ts +0 -64
- package/dist/esm/types/state.types.d.ts +1 -0
- package/dist/esm/types/test-bridge.types.d.ts +38 -0
- package/dist/esm/types/validation-error.types.d.ts +7 -0
- package/dist/esm/types/validation-error.types.js +9 -0
- package/dist/esm/types/window.types.d.ts +1 -8
- package/dist/esm/utils/data/uuid.utils.d.ts +1 -1
- package/dist/esm/utils/data/uuid.utils.js +7 -5
- package/dist/esm/utils/emitter.utils.d.ts +8 -0
- package/dist/esm/utils/emitter.utils.js +29 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/logging/debug-logger.utils.d.ts +10 -51
- package/dist/esm/utils/logging/debug-logger.utils.js +36 -127
- package/dist/esm/utils/network/fetch-with-timeout.utils.d.ts +4 -0
- package/dist/esm/utils/network/fetch-with-timeout.utils.js +22 -0
- package/dist/esm/utils/network/index.d.ts +1 -0
- package/dist/esm/utils/network/index.js +1 -0
- package/dist/esm/utils/network/url.utils.js +2 -42
- package/dist/esm/utils/security/sanitize.utils.d.ts +1 -8
- package/dist/esm/utils/security/sanitize.utils.js +6 -39
- package/dist/esm/utils/validations/config-validations.utils.d.ts +7 -0
- package/dist/esm/utils/validations/config-validations.utils.js +76 -22
- package/package.json +23 -16
- package/dist/browser/web-vitals-CCnqwnC8.mjs +0 -198
- package/dist/cjs/constants/browser.constants.d.ts +0 -3
- package/dist/cjs/constants/browser.constants.js +0 -41
- package/dist/cjs/constants/initialization.constants.d.ts +0 -40
- package/dist/cjs/constants/initialization.constants.js +0 -48
- package/dist/cjs/constants/limits.constants.d.ts +0 -25
- package/dist/cjs/constants/limits.constants.js +0 -40
- package/dist/cjs/constants/security.constants.d.ts +0 -1
- package/dist/cjs/constants/security.constants.js +0 -12
- package/dist/cjs/constants/timing.constants.d.ts +0 -22
- package/dist/cjs/constants/timing.constants.js +0 -34
- package/dist/cjs/constants/validation.constants.d.ts +0 -13
- package/dist/cjs/constants/validation.constants.js +0 -31
- package/dist/cjs/handlers/network.handler.d.ts +0 -16
- package/dist/cjs/handlers/network.handler.js +0 -136
- package/dist/cjs/managers/cross-tab-session.manager.d.ts +0 -170
- package/dist/cjs/managers/cross-tab-session.manager.js +0 -730
- package/dist/cjs/managers/sampling.manager.d.ts +0 -8
- package/dist/cjs/managers/sampling.manager.js +0 -53
- package/dist/cjs/managers/session-recovery.manager.d.ts +0 -65
- package/dist/cjs/managers/session-recovery.manager.js +0 -237
- package/dist/cjs/types/web-vitals.types.d.ts +0 -6
- package/dist/esm/constants/browser.constants.d.ts +0 -3
- package/dist/esm/constants/browser.constants.js +0 -38
- package/dist/esm/constants/initialization.constants.d.ts +0 -40
- package/dist/esm/constants/initialization.constants.js +0 -45
- package/dist/esm/constants/limits.constants.d.ts +0 -25
- package/dist/esm/constants/limits.constants.js +0 -37
- package/dist/esm/constants/security.constants.d.ts +0 -1
- package/dist/esm/constants/security.constants.js +0 -9
- package/dist/esm/constants/timing.constants.d.ts +0 -22
- package/dist/esm/constants/timing.constants.js +0 -31
- package/dist/esm/constants/validation.constants.d.ts +0 -13
- package/dist/esm/constants/validation.constants.js +0 -28
- package/dist/esm/handlers/network.handler.d.ts +0 -16
- package/dist/esm/handlers/network.handler.js +0 -132
- package/dist/esm/managers/cross-tab-session.manager.d.ts +0 -170
- package/dist/esm/managers/cross-tab-session.manager.js +0 -726
- package/dist/esm/managers/sampling.manager.d.ts +0 -8
- package/dist/esm/managers/sampling.manager.js +0 -49
- package/dist/esm/managers/session-recovery.manager.d.ts +0 -65
- package/dist/esm/managers/session-recovery.manager.js +0 -233
- package/dist/esm/types/web-vitals.types.d.ts +0 -6
- /package/dist/cjs/types/{web-vitals.types.js → test-bridge.types.js} +0 -0
- /package/dist/esm/types/{web-vitals.types.js → test-bridge.types.js} +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Consolidated configuration constants for TraceLog
|
|
4
|
+
* This file centralizes all timing, limits, browser, and initialization constants
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SESSION_RECOVERY_WINDOW_MULTIPLIER = exports.TAB_CLEANUP_DELAY_MS = exports.TAB_ELECTION_TIMEOUT_MS = exports.TAB_HEARTBEAT_INTERVAL_MS = exports.CROSS_TAB_INITIALIZATION_LOCK_TIMEOUT_MS = exports.SESSION_CLEANUP_DELAY_MS = exports.SESSION_MAX_RETRY_ATTEMPTS = exports.SESSION_SYNC_TIMEOUT_MS = exports.INITIALIZATION_TIMEOUT_MS = exports.INITIALIZATION_CONCURRENT_RETRY_DELAY_MS = exports.INITIALIZATION_MAX_CONCURRENT_RETRIES = exports.UTM_PARAMS = exports.INTERACTIVE_SELECTORS = exports.HTML_DATA_ATTR_PREFIX = exports.MAX_FINGERPRINTS_HARD_LIMIT = exports.FINGERPRINT_CLEANUP_MULTIPLIER = exports.MAX_FINGERPRINTS = exports.SYNC_XHR_TIMEOUT_MS = exports.PRECISION_TWO_DECIMALS = exports.MAX_OBJECT_DEPTH = exports.MAX_ARRAY_LENGTH = exports.MAX_STRING_LENGTH = exports.MAX_TEXT_LENGTH = exports.MAX_CUSTOM_EVENT_ARRAY_SIZE = exports.MAX_CUSTOM_EVENT_KEYS = exports.MAX_CUSTOM_EVENT_STRING_SIZE = exports.MAX_CUSTOM_EVENT_NAME_LENGTH = exports.MAX_SESSION_TIMEOUT_MS = exports.MIN_SESSION_TIMEOUT_MS = exports.BATCH_SIZE_THRESHOLD = exports.MAX_SAMPLING_RATE = exports.MIN_SAMPLING_RATE = exports.DEFAULT_SAMPLING_RATE = exports.MAX_SCROLL_EVENTS_PER_SESSION = exports.SCROLL_MIN_EVENT_INTERVAL_MS = exports.MIN_SCROLL_DEPTH_CHANGE = exports.SIGNIFICANT_SCROLL_DELTA = exports.DEFAULT_MOTION_THRESHOLD = exports.MAX_METADATA_SIZE = exports.REQUEST_TIMEOUT_MS = exports.RETRY_DELAY_MS = exports.MAX_RETRIES = exports.MAX_EVENTS_QUEUE_LENGTH = exports.EVENT_PERSISTENCE_MAX_AGE_MS = exports.EVENT_EXPIRY_HOURS = exports.DEFAULT_VISIBILITY_TIMEOUT_MS = exports.SCROLL_DEBOUNCE_TIME_MS = exports.EVENT_SENT_INTERVAL_MS = exports.DUPLICATE_EVENT_THRESHOLD_MS = exports.DEFAULT_SESSION_TIMEOUT = void 0;
|
|
8
|
+
exports.XSS_PATTERNS = exports.VALIDATION_MESSAGES = exports.ALLOWED_API_CONFIG_KEYS = exports.MAX_RETRY_ATTEMPTS = exports.RATE_LIMIT_INTERVAL = exports.RETRY_BACKOFF_MAX = exports.RETRY_BACKOFF_INITIAL = exports.SCROLL_SUPPRESS_MULTIPLIER = exports.MIN_SESSION_RECOVERY_WINDOW_MS = exports.MAX_SESSION_RECOVERY_WINDOW_MS = exports.MAX_SESSION_RECOVERY_ATTEMPTS = void 0;
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// SESSION & TIMING
|
|
11
|
+
// ============================================================================
|
|
12
|
+
exports.DEFAULT_SESSION_TIMEOUT = 15 * 60 * 1000; // 15 minutes
|
|
13
|
+
exports.DUPLICATE_EVENT_THRESHOLD_MS = 1000; // 1 second
|
|
14
|
+
exports.EVENT_SENT_INTERVAL_MS = 10000; // 10 seconds
|
|
15
|
+
// Throttling and debouncing
|
|
16
|
+
exports.SCROLL_DEBOUNCE_TIME_MS = 250;
|
|
17
|
+
exports.DEFAULT_VISIBILITY_TIMEOUT_MS = 2000;
|
|
18
|
+
// Event expiry
|
|
19
|
+
exports.EVENT_EXPIRY_HOURS = 24;
|
|
20
|
+
exports.EVENT_PERSISTENCE_MAX_AGE_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// LIMITS & RETRIES
|
|
23
|
+
// ============================================================================
|
|
24
|
+
exports.MAX_EVENTS_QUEUE_LENGTH = 500;
|
|
25
|
+
exports.MAX_RETRIES = 3;
|
|
26
|
+
exports.RETRY_DELAY_MS = 5000;
|
|
27
|
+
exports.REQUEST_TIMEOUT_MS = 10000;
|
|
28
|
+
exports.MAX_METADATA_SIZE = 5000;
|
|
29
|
+
// Motion and interaction thresholds
|
|
30
|
+
exports.DEFAULT_MOTION_THRESHOLD = 2;
|
|
31
|
+
exports.SIGNIFICANT_SCROLL_DELTA = 10;
|
|
32
|
+
exports.MIN_SCROLL_DEPTH_CHANGE = 5;
|
|
33
|
+
exports.SCROLL_MIN_EVENT_INTERVAL_MS = 500;
|
|
34
|
+
exports.MAX_SCROLL_EVENTS_PER_SESSION = 120;
|
|
35
|
+
// Sampling and rate limits
|
|
36
|
+
exports.DEFAULT_SAMPLING_RATE = 1;
|
|
37
|
+
exports.MIN_SAMPLING_RATE = 0;
|
|
38
|
+
exports.MAX_SAMPLING_RATE = 1;
|
|
39
|
+
// Queue and batch limits
|
|
40
|
+
exports.BATCH_SIZE_THRESHOLD = 50;
|
|
41
|
+
// Session timeout validation limits
|
|
42
|
+
exports.MIN_SESSION_TIMEOUT_MS = 30000; // 30 seconds minimum
|
|
43
|
+
exports.MAX_SESSION_TIMEOUT_MS = 86400000; // 24 hours maximum
|
|
44
|
+
// Custom event validation limits
|
|
45
|
+
exports.MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
|
|
46
|
+
exports.MAX_CUSTOM_EVENT_STRING_SIZE = 8 * 1024; // 8KB
|
|
47
|
+
exports.MAX_CUSTOM_EVENT_KEYS = 10;
|
|
48
|
+
exports.MAX_CUSTOM_EVENT_ARRAY_SIZE = 10;
|
|
49
|
+
// Text content limits
|
|
50
|
+
exports.MAX_TEXT_LENGTH = 255; // For click tracking text content
|
|
51
|
+
// Data sanitization limits
|
|
52
|
+
exports.MAX_STRING_LENGTH = 1000;
|
|
53
|
+
exports.MAX_ARRAY_LENGTH = 100;
|
|
54
|
+
exports.MAX_OBJECT_DEPTH = 3;
|
|
55
|
+
// Precision for numeric metrics
|
|
56
|
+
exports.PRECISION_TWO_DECIMALS = 2;
|
|
57
|
+
// Sync XHR timeout
|
|
58
|
+
exports.SYNC_XHR_TIMEOUT_MS = 2000; // 2 seconds
|
|
59
|
+
// Event fingerprint management
|
|
60
|
+
exports.MAX_FINGERPRINTS = 1000; // Maximum fingerprints stored before cleanup
|
|
61
|
+
exports.FINGERPRINT_CLEANUP_MULTIPLIER = 10; // Cleanup fingerprints older than 10x threshold
|
|
62
|
+
exports.MAX_FINGERPRINTS_HARD_LIMIT = 2000; // Hard limit for aggressive cleanup
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// BROWSER & HTML
|
|
65
|
+
// ============================================================================
|
|
66
|
+
exports.HTML_DATA_ATTR_PREFIX = 'data-tl';
|
|
67
|
+
// Interactive element selectors for click tracking
|
|
68
|
+
exports.INTERACTIVE_SELECTORS = [
|
|
69
|
+
'button',
|
|
70
|
+
'a',
|
|
71
|
+
'input[type="button"]',
|
|
72
|
+
'input[type="submit"]',
|
|
73
|
+
'input[type="reset"]',
|
|
74
|
+
'input[type="checkbox"]',
|
|
75
|
+
'input[type="radio"]',
|
|
76
|
+
'select',
|
|
77
|
+
'textarea',
|
|
78
|
+
'[role="button"]',
|
|
79
|
+
'[role="link"]',
|
|
80
|
+
'[role="tab"]',
|
|
81
|
+
'[role="menuitem"]',
|
|
82
|
+
'[role="option"]',
|
|
83
|
+
'[role="checkbox"]',
|
|
84
|
+
'[role="radio"]',
|
|
85
|
+
'[role="switch"]',
|
|
86
|
+
'[routerLink]',
|
|
87
|
+
'[ng-click]',
|
|
88
|
+
'[data-action]',
|
|
89
|
+
'[data-click]',
|
|
90
|
+
'[data-navigate]',
|
|
91
|
+
'[data-toggle]',
|
|
92
|
+
'[onclick]',
|
|
93
|
+
'.btn',
|
|
94
|
+
'.button',
|
|
95
|
+
'.clickable',
|
|
96
|
+
'.nav-link',
|
|
97
|
+
'.menu-item',
|
|
98
|
+
'[data-testid]',
|
|
99
|
+
'[tabindex="0"]',
|
|
100
|
+
];
|
|
101
|
+
// UTM parameters for tracking
|
|
102
|
+
exports.UTM_PARAMS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'];
|
|
103
|
+
// ============================================================================
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// INITIALIZATION
|
|
106
|
+
// ============================================================================
|
|
107
|
+
exports.INITIALIZATION_MAX_CONCURRENT_RETRIES = 20;
|
|
108
|
+
exports.INITIALIZATION_CONCURRENT_RETRY_DELAY_MS = 50;
|
|
109
|
+
exports.INITIALIZATION_TIMEOUT_MS = 10000;
|
|
110
|
+
// ============================================================================
|
|
111
|
+
// SESSION MANAGEMENT
|
|
112
|
+
// ============================================================================
|
|
113
|
+
exports.SESSION_SYNC_TIMEOUT_MS = 2000;
|
|
114
|
+
exports.SESSION_MAX_RETRY_ATTEMPTS = 3;
|
|
115
|
+
exports.SESSION_CLEANUP_DELAY_MS = 100;
|
|
116
|
+
// Cross-tab coordination
|
|
117
|
+
exports.CROSS_TAB_INITIALIZATION_LOCK_TIMEOUT_MS = 5000;
|
|
118
|
+
exports.TAB_HEARTBEAT_INTERVAL_MS = 5000; // 5 seconds
|
|
119
|
+
exports.TAB_ELECTION_TIMEOUT_MS = 2000; // 2 seconds
|
|
120
|
+
exports.TAB_CLEANUP_DELAY_MS = 1000; // 1 second
|
|
121
|
+
// Session recovery
|
|
122
|
+
exports.SESSION_RECOVERY_WINDOW_MULTIPLIER = 2; // 2x session timeout
|
|
123
|
+
exports.MAX_SESSION_RECOVERY_ATTEMPTS = 3;
|
|
124
|
+
exports.MAX_SESSION_RECOVERY_WINDOW_MS = 24 * 60 * 60 * 1000; // 24 hours max
|
|
125
|
+
exports.MIN_SESSION_RECOVERY_WINDOW_MS = 2 * 60 * 1000; // 2 minutes minimum
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// SCROLL SUPPRESSION
|
|
128
|
+
// ============================================================================
|
|
129
|
+
exports.SCROLL_SUPPRESS_MULTIPLIER = 2;
|
|
130
|
+
// ============================================================================
|
|
131
|
+
// NETWORK TIMING
|
|
132
|
+
// ============================================================================
|
|
133
|
+
exports.RETRY_BACKOFF_INITIAL = 1000; // 1 second
|
|
134
|
+
exports.RETRY_BACKOFF_MAX = 30000; // 30 seconds
|
|
135
|
+
exports.RATE_LIMIT_INTERVAL = 1000; // 1 second
|
|
136
|
+
exports.MAX_RETRY_ATTEMPTS = 10;
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// VALIDATION
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// Allowed API config keys for runtime validation
|
|
141
|
+
exports.ALLOWED_API_CONFIG_KEYS = new Set([
|
|
142
|
+
'mode',
|
|
143
|
+
'tags',
|
|
144
|
+
'samplingRate',
|
|
145
|
+
'excludedUrlPaths',
|
|
146
|
+
'ipExcluded',
|
|
147
|
+
]);
|
|
148
|
+
// Validation error messages - standardized across all layers
|
|
149
|
+
exports.VALIDATION_MESSAGES = {
|
|
150
|
+
// Project ID validation - consistent message across all layers
|
|
151
|
+
MISSING_PROJECT_ID: 'Project ID is required',
|
|
152
|
+
PROJECT_ID_EMPTY_AFTER_TRIM: 'Project ID is required',
|
|
153
|
+
// Session timeout validation
|
|
154
|
+
INVALID_SESSION_TIMEOUT: `Session timeout must be between ${exports.MIN_SESSION_TIMEOUT_MS}ms (30 seconds) and ${exports.MAX_SESSION_TIMEOUT_MS}ms (24 hours)`,
|
|
155
|
+
// Sampling rate validation
|
|
156
|
+
INVALID_SAMPLING_RATE: 'Sampling rate must be greater than 0 and less than or equal to 1',
|
|
157
|
+
INVALID_ERROR_SAMPLING_RATE: 'Error sampling must be between 0 and 1',
|
|
158
|
+
// Integration validation
|
|
159
|
+
INVALID_GOOGLE_ANALYTICS_ID: 'Google Analytics measurement ID is required when integration is enabled',
|
|
160
|
+
// UI validation
|
|
161
|
+
INVALID_SCROLL_CONTAINER_SELECTORS: 'Scroll container selectors must be valid CSS selectors',
|
|
162
|
+
// Global metadata validation
|
|
163
|
+
INVALID_GLOBAL_METADATA: 'Global metadata must be an object',
|
|
164
|
+
// Array validation
|
|
165
|
+
INVALID_SENSITIVE_QUERY_PARAMS: 'Sensitive query params must be an array of strings',
|
|
166
|
+
};
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// SECURITY
|
|
169
|
+
// ============================================================================
|
|
170
|
+
// XSS protection patterns
|
|
171
|
+
exports.XSS_PATTERNS = [
|
|
172
|
+
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
173
|
+
/javascript:/gi,
|
|
174
|
+
/on\w+\s*=/gi,
|
|
175
|
+
/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
176
|
+
/<embed\b[^>]*>/gi,
|
|
177
|
+
/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi,
|
|
178
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling and PII sanitization constants for TraceLog
|
|
3
|
+
* Centralizes patterns and limits for error tracking and data protection
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
|
|
7
|
+
* These patterns are used to replace sensitive information with [REDACTED] in error messages
|
|
8
|
+
*/
|
|
9
|
+
export declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
10
|
+
/**
|
|
11
|
+
* Maximum length for error messages before truncation
|
|
12
|
+
* Prevents extremely long error messages from consuming excessive storage
|
|
13
|
+
*/
|
|
14
|
+
export declare const MAX_ERROR_MESSAGE_LENGTH = 500;
|
|
15
|
+
/**
|
|
16
|
+
* Time window for error suppression in milliseconds
|
|
17
|
+
* Prevents duplicate errors from flooding the system within this timeframe
|
|
18
|
+
*/
|
|
19
|
+
export declare const ERROR_SUPPRESSION_WINDOW_MS = 60000;
|
|
20
|
+
/**
|
|
21
|
+
* Maximum number of unique errors to track for suppression
|
|
22
|
+
* Prevents memory usage from growing indefinitely
|
|
23
|
+
*/
|
|
24
|
+
export declare const MAX_TRACKED_ERRORS = 50;
|
|
25
|
+
/**
|
|
26
|
+
* Default error sampling rate
|
|
27
|
+
* Controls what percentage of errors are actually reported
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_ERROR_SAMPLING_RATE = 0.1;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Error handling and PII sanitization constants for TraceLog
|
|
4
|
+
* Centralizes patterns and limits for error tracking and data protection
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DEFAULT_ERROR_SAMPLING_RATE = exports.MAX_TRACKED_ERRORS = exports.ERROR_SUPPRESSION_WINDOW_MS = exports.MAX_ERROR_MESSAGE_LENGTH = exports.PII_PATTERNS = void 0;
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// PII SANITIZATION PATTERNS
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
|
|
13
|
+
* These patterns are used to replace sensitive information with [REDACTED] in error messages
|
|
14
|
+
*/
|
|
15
|
+
exports.PII_PATTERNS = [
|
|
16
|
+
// Email addresses
|
|
17
|
+
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi,
|
|
18
|
+
// US Phone numbers (various formats)
|
|
19
|
+
/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g,
|
|
20
|
+
// Credit card numbers (16 digits with optional separators)
|
|
21
|
+
/\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g,
|
|
22
|
+
// IBAN (International Bank Account Number)
|
|
23
|
+
/\b[A-Z]{2}\d{2}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/gi,
|
|
24
|
+
];
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// ERROR TRACKING LIMITS
|
|
27
|
+
// ============================================================================
|
|
28
|
+
/**
|
|
29
|
+
* Maximum length for error messages before truncation
|
|
30
|
+
* Prevents extremely long error messages from consuming excessive storage
|
|
31
|
+
*/
|
|
32
|
+
exports.MAX_ERROR_MESSAGE_LENGTH = 500;
|
|
33
|
+
/**
|
|
34
|
+
* Time window for error suppression in milliseconds
|
|
35
|
+
* Prevents duplicate errors from flooding the system within this timeframe
|
|
36
|
+
*/
|
|
37
|
+
exports.ERROR_SUPPRESSION_WINDOW_MS = 60000; // 1 minute
|
|
38
|
+
/**
|
|
39
|
+
* Maximum number of unique errors to track for suppression
|
|
40
|
+
* Prevents memory usage from growing indefinitely
|
|
41
|
+
*/
|
|
42
|
+
exports.MAX_TRACKED_ERRORS = 50;
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// ERROR SAMPLING
|
|
45
|
+
// ============================================================================
|
|
46
|
+
/**
|
|
47
|
+
* Default error sampling rate
|
|
48
|
+
* Controls what percentage of errors are actually reported
|
|
49
|
+
*/
|
|
50
|
+
exports.DEFAULT_ERROR_SAMPLING_RATE = 0.1; // 10% of errors
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export * from './api.constants';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './initialization.constants';
|
|
4
|
-
export * from './limits.constants';
|
|
5
|
-
export * from './security.constants';
|
|
2
|
+
export * from './config.constants';
|
|
6
3
|
export * from './storage.constants';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
4
|
+
export * from './performance.constants';
|
|
5
|
+
export * from './error.constants';
|
|
@@ -15,10 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api.constants"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./initialization.constants"), exports);
|
|
20
|
-
__exportStar(require("./limits.constants"), exports);
|
|
21
|
-
__exportStar(require("./security.constants"), exports);
|
|
18
|
+
__exportStar(require("./config.constants"), exports);
|
|
22
19
|
__exportStar(require("./storage.constants"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./performance.constants"), exports);
|
|
21
|
+
__exportStar(require("./error.constants"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance monitoring and web vitals constants for TraceLog
|
|
3
|
+
* Centralizes thresholds and configuration for performance tracking
|
|
4
|
+
*/
|
|
5
|
+
import { WebVitalType } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Web Vitals thresholds in milliseconds (except CLS which is unitless)
|
|
8
|
+
* These define the minimum values required to report a web vital metric
|
|
9
|
+
*
|
|
10
|
+
* Based on Core Web Vitals standards:
|
|
11
|
+
* - LCP (Largest Contentful Paint): 4000ms threshold
|
|
12
|
+
* - FCP (First Contentful Paint): 1800ms threshold
|
|
13
|
+
* - CLS (Cumulative Layout Shift): 0.25 threshold (unitless)
|
|
14
|
+
* - INP (Interaction to Next Paint): 200ms threshold
|
|
15
|
+
* - TTFB (Time to First Byte): 600ms threshold
|
|
16
|
+
* - LONG_TASK: 50ms threshold for long task detection
|
|
17
|
+
*/
|
|
18
|
+
export declare const WEB_VITALS_THRESHOLDS: Record<WebVitalType, number>;
|
|
19
|
+
/**
|
|
20
|
+
* Long task throttling interval in milliseconds
|
|
21
|
+
* Prevents excessive long task events from being sent
|
|
22
|
+
*/
|
|
23
|
+
export declare const LONG_TASK_THROTTLE_MS = 1000;
|
|
24
|
+
/**
|
|
25
|
+
* Precision for performance metric values
|
|
26
|
+
* All performance metrics are rounded to 2 decimal places
|
|
27
|
+
*/
|
|
28
|
+
export declare const PERFORMANCE_PRECISION_DECIMALS: 2;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Performance monitoring and web vitals constants for TraceLog
|
|
4
|
+
* Centralizes thresholds and configuration for performance tracking
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PERFORMANCE_PRECISION_DECIMALS = exports.LONG_TASK_THROTTLE_MS = exports.WEB_VITALS_THRESHOLDS = void 0;
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// WEB VITALS THRESHOLDS
|
|
10
|
+
// ============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Web Vitals thresholds in milliseconds (except CLS which is unitless)
|
|
13
|
+
* These define the minimum values required to report a web vital metric
|
|
14
|
+
*
|
|
15
|
+
* Based on Core Web Vitals standards:
|
|
16
|
+
* - LCP (Largest Contentful Paint): 4000ms threshold
|
|
17
|
+
* - FCP (First Contentful Paint): 1800ms threshold
|
|
18
|
+
* - CLS (Cumulative Layout Shift): 0.25 threshold (unitless)
|
|
19
|
+
* - INP (Interaction to Next Paint): 200ms threshold
|
|
20
|
+
* - TTFB (Time to First Byte): 600ms threshold
|
|
21
|
+
* - LONG_TASK: 50ms threshold for long task detection
|
|
22
|
+
*/
|
|
23
|
+
exports.WEB_VITALS_THRESHOLDS = {
|
|
24
|
+
LCP: 4000,
|
|
25
|
+
FCP: 1800,
|
|
26
|
+
CLS: 0.25,
|
|
27
|
+
INP: 200,
|
|
28
|
+
TTFB: 600,
|
|
29
|
+
LONG_TASK: 50,
|
|
30
|
+
};
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// PERFORMANCE MONITORING LIMITS
|
|
33
|
+
// ============================================================================
|
|
34
|
+
/**
|
|
35
|
+
* Long task throttling interval in milliseconds
|
|
36
|
+
* Prevents excessive long task events from being sent
|
|
37
|
+
*/
|
|
38
|
+
exports.LONG_TASK_THROTTLE_MS = 1000;
|
|
39
|
+
/**
|
|
40
|
+
* Precision for performance metric values
|
|
41
|
+
* All performance metrics are rounded to 2 decimal places
|
|
42
|
+
*/
|
|
43
|
+
exports.PERFORMANCE_PRECISION_DECIMALS = 2;
|
|
@@ -12,10 +12,8 @@ class ClickHandler extends state_manager_1.StateManager {
|
|
|
12
12
|
}
|
|
13
13
|
startTracking() {
|
|
14
14
|
if (this.clickHandler) {
|
|
15
|
-
logging_1.debugLog.debug('ClickHandler', 'Click tracking already active');
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
|
-
logging_1.debugLog.debug('ClickHandler', 'Starting click tracking');
|
|
19
17
|
this.clickHandler = (event) => {
|
|
20
18
|
const mouseEvent = event;
|
|
21
19
|
const target = mouseEvent.target;
|
|
@@ -28,11 +26,6 @@ class ClickHandler extends state_manager_1.StateManager {
|
|
|
28
26
|
logging_1.debugLog.warn('ClickHandler', 'Click target not found or not an element');
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
|
-
logging_1.debugLog.info('ClickHandler', '🖱️ Click detected on element', {
|
|
32
|
-
tagName: clickedElement.tagName,
|
|
33
|
-
className: clickedElement.className || 'none',
|
|
34
|
-
textContent: clickedElement.textContent?.slice(0, 50) ?? 'empty',
|
|
35
|
-
});
|
|
36
29
|
const trackingElement = this.findTrackingElement(clickedElement);
|
|
37
30
|
const relevantClickElement = this.getRelevantClickElement(clickedElement);
|
|
38
31
|
const coordinates = this.calculateClickCoordinates(mouseEvent, clickedElement);
|
|
@@ -73,27 +66,18 @@ class ClickHandler extends state_manager_1.StateManager {
|
|
|
73
66
|
getRelevantClickElement(element) {
|
|
74
67
|
for (const selector of constants_1.INTERACTIVE_SELECTORS) {
|
|
75
68
|
try {
|
|
69
|
+
// First check if the element itself matches
|
|
76
70
|
if (element.matches(selector)) {
|
|
77
71
|
return element;
|
|
78
72
|
}
|
|
79
|
-
|
|
80
|
-
catch (error) {
|
|
81
|
-
logging_1.debugLog.warn('ClickHandler', 'Invalid selector in interactive elements check', {
|
|
82
|
-
selector,
|
|
83
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
84
|
-
});
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
for (const selector of constants_1.INTERACTIVE_SELECTORS) {
|
|
89
|
-
try {
|
|
73
|
+
// If not, search for matching ancestors
|
|
90
74
|
const parent = element.closest(selector);
|
|
91
75
|
if (parent) {
|
|
92
76
|
return parent;
|
|
93
77
|
}
|
|
94
78
|
}
|
|
95
79
|
catch (error) {
|
|
96
|
-
logging_1.debugLog.warn('ClickHandler', 'Invalid selector in
|
|
80
|
+
logging_1.debugLog.warn('ClickHandler', 'Invalid selector in element search', {
|
|
97
81
|
selector,
|
|
98
82
|
error: error instanceof Error ? error.message : 'Unknown error',
|
|
99
83
|
});
|
|
@@ -102,12 +86,15 @@ class ClickHandler extends state_manager_1.StateManager {
|
|
|
102
86
|
}
|
|
103
87
|
return element;
|
|
104
88
|
}
|
|
89
|
+
clamp(value) {
|
|
90
|
+
return Math.max(0, Math.min(1, Number(value.toFixed(3))));
|
|
91
|
+
}
|
|
105
92
|
calculateClickCoordinates(event, element) {
|
|
106
93
|
const rect = element.getBoundingClientRect();
|
|
107
94
|
const x = event.clientX;
|
|
108
95
|
const y = event.clientY;
|
|
109
|
-
const relativeX = rect.width > 0 ?
|
|
110
|
-
const relativeY = rect.height > 0 ?
|
|
96
|
+
const relativeX = rect.width > 0 ? this.clamp((x - rect.left) / rect.width) : 0;
|
|
97
|
+
const relativeY = rect.height > 0 ? this.clamp((y - rect.top) / rect.height) : 0;
|
|
111
98
|
return { x, y, relativeX, relativeY };
|
|
112
99
|
}
|
|
113
100
|
extractTrackingData(trackingElement) {
|
|
@@ -126,12 +113,6 @@ class ClickHandler extends state_manager_1.StateManager {
|
|
|
126
113
|
const { x, y, relativeX, relativeY } = coordinates;
|
|
127
114
|
const text = this.getRelevantText(clickedElement, relevantElement);
|
|
128
115
|
const attributes = this.extractElementAttributes(relevantElement);
|
|
129
|
-
const href = relevantElement.getAttribute('href');
|
|
130
|
-
const title = relevantElement.getAttribute('title');
|
|
131
|
-
const alt = relevantElement.getAttribute('alt');
|
|
132
|
-
const role = relevantElement.getAttribute('role');
|
|
133
|
-
const ariaLabel = relevantElement.getAttribute('aria-label');
|
|
134
|
-
const className = typeof relevantElement.className === 'string' ? relevantElement.className : String(relevantElement.className);
|
|
135
116
|
return {
|
|
136
117
|
x,
|
|
137
118
|
y,
|
|
@@ -139,47 +120,47 @@ class ClickHandler extends state_manager_1.StateManager {
|
|
|
139
120
|
relativeY,
|
|
140
121
|
tag: relevantElement.tagName.toLowerCase(),
|
|
141
122
|
...(relevantElement.id && { id: relevantElement.id }),
|
|
142
|
-
...(relevantElement.className && { class: className }),
|
|
123
|
+
...(relevantElement.className && { class: relevantElement.className }),
|
|
143
124
|
...(text && { text }),
|
|
144
|
-
...(href && { href }),
|
|
145
|
-
...(title && { title }),
|
|
146
|
-
...(alt && { alt }),
|
|
147
|
-
...(role && { role }),
|
|
148
|
-
...(
|
|
125
|
+
...(attributes.href && { href: attributes.href }),
|
|
126
|
+
...(attributes.title && { title: attributes.title }),
|
|
127
|
+
...(attributes.alt && { alt: attributes.alt }),
|
|
128
|
+
...(attributes.role && { role: attributes.role }),
|
|
129
|
+
...(attributes['aria-label'] && { ariaLabel: attributes['aria-label'] }),
|
|
149
130
|
...(Object.keys(attributes).length > 0 && { dataAttributes: attributes }),
|
|
150
131
|
};
|
|
151
132
|
}
|
|
152
133
|
getRelevantText(clickedElement, relevantElement) {
|
|
153
|
-
const LARGE_CONTAINER_TAGS = ['main', 'section', 'article', 'body', 'html', 'header', 'footer', 'aside', 'nav'];
|
|
154
134
|
const clickedText = clickedElement.textContent?.trim() ?? '';
|
|
155
135
|
const relevantText = relevantElement.textContent?.trim() ?? '';
|
|
136
|
+
// No text available
|
|
156
137
|
if (!clickedText && !relevantText) {
|
|
157
138
|
return '';
|
|
158
139
|
}
|
|
159
|
-
//
|
|
140
|
+
// Prefer clicked element text if it's reasonable length
|
|
160
141
|
if (clickedText && clickedText.length <= constants_1.MAX_TEXT_LENGTH) {
|
|
161
142
|
return clickedText;
|
|
162
143
|
}
|
|
163
|
-
//
|
|
164
|
-
const isLargeContainer = LARGE_CONTAINER_TAGS.includes(relevantElement.tagName.toLowerCase());
|
|
165
|
-
const hasExcessiveText = relevantText.length > constants_1.MAX_TEXT_LENGTH * 2; // 510 chars
|
|
166
|
-
if (isLargeContainer && hasExcessiveText) {
|
|
167
|
-
// Use clicked element text if available and reasonable, otherwise empty
|
|
168
|
-
return clickedText && clickedText.length <= constants_1.MAX_TEXT_LENGTH ? clickedText : '';
|
|
169
|
-
}
|
|
170
|
-
// Strategy 3: Use relevant text but truncate if needed
|
|
144
|
+
// Use relevant element text if it fits
|
|
171
145
|
if (relevantText.length <= constants_1.MAX_TEXT_LENGTH) {
|
|
172
146
|
return relevantText;
|
|
173
147
|
}
|
|
174
|
-
//
|
|
175
|
-
if (clickedText && clickedText.length < relevantText.length * 0.1) {
|
|
176
|
-
return clickedText.length <= constants_1.MAX_TEXT_LENGTH ? clickedText : clickedText.slice(0, constants_1.MAX_TEXT_LENGTH - 3) + '...';
|
|
177
|
-
}
|
|
178
|
-
// Fallback: truncate relevant text to exactly MAX_TEXT_LENGTH including ellipsis
|
|
148
|
+
// Truncate relevant text if too long
|
|
179
149
|
return relevantText.slice(0, constants_1.MAX_TEXT_LENGTH - 3) + '...';
|
|
180
150
|
}
|
|
181
151
|
extractElementAttributes(element) {
|
|
182
|
-
const commonAttributes = [
|
|
152
|
+
const commonAttributes = [
|
|
153
|
+
'id',
|
|
154
|
+
'class',
|
|
155
|
+
'data-testid',
|
|
156
|
+
'aria-label',
|
|
157
|
+
'title',
|
|
158
|
+
'href',
|
|
159
|
+
'type',
|
|
160
|
+
'name',
|
|
161
|
+
'alt',
|
|
162
|
+
'role',
|
|
163
|
+
];
|
|
183
164
|
const result = {};
|
|
184
165
|
for (const attributeName of commonAttributes) {
|
|
185
166
|
const value = element.getAttribute(attributeName);
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { EventManager } from '../managers/event.manager';
|
|
2
2
|
import { StateManager } from '../managers/state.manager';
|
|
3
|
+
/**
|
|
4
|
+
* Simplified error handler for tracking JavaScript errors and unhandled promise rejections
|
|
5
|
+
* Includes PII sanitization and sampling support
|
|
6
|
+
*/
|
|
3
7
|
export declare class ErrorHandler extends StateManager {
|
|
4
8
|
private readonly eventManager;
|
|
5
|
-
private readonly
|
|
9
|
+
private readonly recentErrors;
|
|
6
10
|
constructor(eventManager: EventManager);
|
|
7
11
|
startTracking(): void;
|
|
8
12
|
stopTracking(): void;
|
|
9
|
-
private setupErrorListener;
|
|
10
|
-
private setupUnhandledRejectionListener;
|
|
11
|
-
private readonly handleError;
|
|
12
|
-
private readonly handleUnhandledRejection;
|
|
13
|
-
private sanitizeText;
|
|
14
13
|
private shouldSample;
|
|
14
|
+
private readonly handleError;
|
|
15
|
+
private readonly handleRejection;
|
|
16
|
+
private extractRejectionMessage;
|
|
17
|
+
private sanitize;
|
|
18
|
+
private shouldSuppressError;
|
|
19
|
+
private pruneOldErrors;
|
|
15
20
|
}
|