@tracelog/lib 0.0.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/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/browser/tracelog.js +4040 -0
- package/dist/browser/web-vitals-CCnqwnC8.mjs +198 -0
- package/dist/cjs/api.d.ts +46 -0
- package/dist/cjs/api.js +224 -0
- package/dist/cjs/app.constants.d.ts +1 -0
- package/dist/cjs/app.constants.js +5 -0
- package/dist/cjs/app.d.ts +59 -0
- package/dist/cjs/app.js +272 -0
- package/dist/cjs/app.types.d.ts +6 -0
- package/dist/cjs/app.types.js +22 -0
- package/dist/cjs/constants/api.constants.d.ts +4 -0
- package/dist/cjs/constants/api.constants.js +18 -0
- package/dist/cjs/constants/browser.constants.d.ts +3 -0
- package/dist/cjs/constants/browser.constants.js +41 -0
- package/dist/cjs/constants/index.d.ts +8 -0
- package/dist/cjs/constants/index.js +24 -0
- package/dist/cjs/constants/initialization.constants.d.ts +40 -0
- package/dist/cjs/constants/initialization.constants.js +48 -0
- package/dist/cjs/constants/limits.constants.d.ts +25 -0
- package/dist/cjs/constants/limits.constants.js +40 -0
- package/dist/cjs/constants/security.constants.d.ts +1 -0
- package/dist/cjs/constants/security.constants.js +12 -0
- package/dist/cjs/constants/storage.constants.d.ts +9 -0
- package/dist/cjs/constants/storage.constants.js +22 -0
- package/dist/cjs/constants/timing.constants.d.ts +22 -0
- package/dist/cjs/constants/timing.constants.js +34 -0
- package/dist/cjs/constants/validation.constants.d.ts +13 -0
- package/dist/cjs/constants/validation.constants.js +31 -0
- package/dist/cjs/handlers/click.handler.d.ts +17 -0
- package/dist/cjs/handlers/click.handler.js +199 -0
- package/dist/cjs/handlers/error.handler.d.ts +15 -0
- package/dist/cjs/handlers/error.handler.js +97 -0
- package/dist/cjs/handlers/network.handler.d.ts +16 -0
- package/dist/cjs/handlers/network.handler.js +136 -0
- package/dist/cjs/handlers/page-view.handler.d.ts +15 -0
- package/dist/cjs/handlers/page-view.handler.js +83 -0
- package/dist/cjs/handlers/performance.handler.d.ts +19 -0
- package/dist/cjs/handlers/performance.handler.js +255 -0
- package/dist/cjs/handlers/scroll.handler.d.ts +16 -0
- package/dist/cjs/handlers/scroll.handler.js +138 -0
- package/dist/cjs/handlers/session.handler.d.ts +29 -0
- package/dist/cjs/handlers/session.handler.js +357 -0
- package/dist/cjs/integrations/google-analytics.integration.d.ts +18 -0
- package/dist/cjs/integrations/google-analytics.integration.js +159 -0
- package/dist/cjs/listeners/activity-listener-manager.d.ts +8 -0
- package/dist/cjs/listeners/activity-listener-manager.js +32 -0
- package/dist/cjs/listeners/index.d.ts +6 -0
- package/dist/cjs/listeners/index.js +14 -0
- package/dist/cjs/listeners/input-listener-managers.d.ts +15 -0
- package/dist/cjs/listeners/input-listener-managers.js +58 -0
- package/dist/cjs/listeners/listeners.types.d.ts +4 -0
- package/dist/cjs/listeners/listeners.types.js +2 -0
- package/dist/cjs/listeners/touch-listener-manager.d.ts +10 -0
- package/dist/cjs/listeners/touch-listener-manager.js +56 -0
- package/dist/cjs/listeners/unload-listener-manager.d.ts +8 -0
- package/dist/cjs/listeners/unload-listener-manager.js +30 -0
- package/dist/cjs/listeners/visibility-listener-manager.d.ts +12 -0
- package/dist/cjs/listeners/visibility-listener-manager.js +83 -0
- package/dist/cjs/managers/api.manager.d.ts +3 -0
- package/dist/cjs/managers/api.manager.js +14 -0
- package/dist/cjs/managers/config.manager.d.ts +7 -0
- package/dist/cjs/managers/config.manager.js +94 -0
- package/dist/cjs/managers/cross-tab-session.manager.d.ts +170 -0
- package/dist/cjs/managers/cross-tab-session.manager.js +730 -0
- package/dist/cjs/managers/event.manager.d.ts +61 -0
- package/dist/cjs/managers/event.manager.js +508 -0
- package/dist/cjs/managers/sampling.manager.d.ts +8 -0
- package/dist/cjs/managers/sampling.manager.js +53 -0
- package/dist/cjs/managers/sender.manager.d.ts +46 -0
- package/dist/cjs/managers/sender.manager.js +304 -0
- package/dist/cjs/managers/session-recovery.manager.d.ts +65 -0
- package/dist/cjs/managers/session-recovery.manager.js +237 -0
- package/dist/cjs/managers/session.manager.d.ts +72 -0
- package/dist/cjs/managers/session.manager.js +587 -0
- package/dist/cjs/managers/state.manager.d.ts +5 -0
- package/dist/cjs/managers/state.manager.js +23 -0
- package/dist/cjs/managers/storage.manager.d.ts +10 -0
- package/dist/cjs/managers/storage.manager.js +81 -0
- package/dist/cjs/managers/tags.manager.d.ts +12 -0
- package/dist/cjs/managers/tags.manager.js +289 -0
- package/dist/cjs/managers/user.manager.d.ts +7 -0
- package/dist/cjs/managers/user.manager.js +22 -0
- package/dist/cjs/public-api.d.ts +1 -0
- package/dist/cjs/public-api.js +37 -0
- package/dist/cjs/types/api.types.d.ts +21 -0
- package/dist/cjs/types/api.types.js +25 -0
- package/dist/cjs/types/common.types.d.ts +1 -0
- package/dist/cjs/types/common.types.js +2 -0
- package/dist/cjs/types/config.types.d.ts +104 -0
- package/dist/cjs/types/config.types.js +2 -0
- package/dist/cjs/types/device.types.d.ts +6 -0
- package/dist/cjs/types/device.types.js +10 -0
- package/dist/cjs/types/event.types.d.ts +104 -0
- package/dist/cjs/types/event.types.js +25 -0
- package/dist/cjs/types/index.d.ts +13 -0
- package/dist/cjs/types/index.js +29 -0
- package/dist/cjs/types/log.types.d.ts +4 -0
- package/dist/cjs/types/log.types.js +2 -0
- package/dist/cjs/types/mode.types.d.ts +7 -0
- package/dist/cjs/types/mode.types.js +11 -0
- package/dist/cjs/types/queue.types.d.ts +23 -0
- package/dist/cjs/types/queue.types.js +2 -0
- package/dist/cjs/types/session.types.d.ts +65 -0
- package/dist/cjs/types/session.types.js +2 -0
- package/dist/cjs/types/state.types.d.ts +12 -0
- package/dist/cjs/types/state.types.js +2 -0
- package/dist/cjs/types/tag.types.d.ts +43 -0
- package/dist/cjs/types/tag.types.js +31 -0
- package/dist/cjs/types/validation-error.types.d.ts +42 -0
- package/dist/cjs/types/validation-error.types.js +68 -0
- package/dist/cjs/types/web-vitals.types.d.ts +6 -0
- package/dist/cjs/types/web-vitals.types.js +2 -0
- package/dist/cjs/types/window.types.d.ts +17 -0
- package/dist/cjs/types/window.types.js +2 -0
- package/dist/cjs/utils/browser/device-detector.utils.d.ts +6 -0
- package/dist/cjs/utils/browser/device-detector.utils.js +71 -0
- package/dist/cjs/utils/browser/index.d.ts +2 -0
- package/dist/cjs/utils/browser/index.js +18 -0
- package/dist/cjs/utils/browser/utm-params.utils.d.ts +6 -0
- package/dist/cjs/utils/browser/utm-params.utils.js +37 -0
- package/dist/cjs/utils/data/index.d.ts +1 -0
- package/dist/cjs/utils/data/index.js +17 -0
- package/dist/cjs/utils/data/uuid.utils.d.ts +5 -0
- package/dist/cjs/utils/data/uuid.utils.js +18 -0
- package/dist/cjs/utils/index.d.ts +6 -0
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/logging/debug-logger.utils.d.ts +56 -0
- package/dist/cjs/utils/logging/debug-logger.utils.js +139 -0
- package/dist/cjs/utils/logging/index.d.ts +1 -0
- package/dist/cjs/utils/logging/index.js +5 -0
- package/dist/cjs/utils/network/index.d.ts +1 -0
- package/dist/cjs/utils/network/index.js +17 -0
- package/dist/cjs/utils/network/url.utils.d.ts +20 -0
- package/dist/cjs/utils/network/url.utils.js +172 -0
- package/dist/cjs/utils/security/index.d.ts +1 -0
- package/dist/cjs/utils/security/index.js +17 -0
- package/dist/cjs/utils/security/sanitize.utils.d.ts +32 -0
- package/dist/cjs/utils/security/sanitize.utils.js +319 -0
- package/dist/cjs/utils/validations/config-validations.utils.d.ts +42 -0
- package/dist/cjs/utils/validations/config-validations.utils.js +297 -0
- package/dist/cjs/utils/validations/event-validations.utils.d.ts +12 -0
- package/dist/cjs/utils/validations/event-validations.utils.js +30 -0
- package/dist/cjs/utils/validations/index.d.ts +5 -0
- package/dist/cjs/utils/validations/index.js +21 -0
- package/dist/cjs/utils/validations/metadata-validations.utils.d.ts +22 -0
- package/dist/cjs/utils/validations/metadata-validations.utils.js +115 -0
- package/dist/cjs/utils/validations/type-guards.utils.d.ts +6 -0
- package/dist/cjs/utils/validations/type-guards.utils.js +31 -0
- package/dist/cjs/utils/validations/url-validations.utils.d.ts +15 -0
- package/dist/cjs/utils/validations/url-validations.utils.js +47 -0
- package/dist/esm/api.d.ts +46 -0
- package/dist/esm/api.js +183 -0
- package/dist/esm/app.constants.d.ts +1 -0
- package/dist/esm/app.constants.js +1 -0
- package/dist/esm/app.d.ts +59 -0
- package/dist/esm/app.js +268 -0
- package/dist/esm/app.types.d.ts +6 -0
- package/dist/esm/app.types.js +6 -0
- package/dist/esm/constants/api.constants.d.ts +4 -0
- package/dist/esm/constants/api.constants.js +14 -0
- package/dist/esm/constants/browser.constants.d.ts +3 -0
- package/dist/esm/constants/browser.constants.js +38 -0
- package/dist/esm/constants/index.d.ts +8 -0
- package/dist/esm/constants/index.js +8 -0
- package/dist/esm/constants/initialization.constants.d.ts +40 -0
- package/dist/esm/constants/initialization.constants.js +45 -0
- package/dist/esm/constants/limits.constants.d.ts +25 -0
- package/dist/esm/constants/limits.constants.js +37 -0
- package/dist/esm/constants/security.constants.d.ts +1 -0
- package/dist/esm/constants/security.constants.js +9 -0
- package/dist/esm/constants/storage.constants.d.ts +9 -0
- package/dist/esm/constants/storage.constants.js +11 -0
- package/dist/esm/constants/timing.constants.d.ts +22 -0
- package/dist/esm/constants/timing.constants.js +31 -0
- package/dist/esm/constants/validation.constants.d.ts +13 -0
- package/dist/esm/constants/validation.constants.js +28 -0
- package/dist/esm/handlers/click.handler.d.ts +17 -0
- package/dist/esm/handlers/click.handler.js +195 -0
- package/dist/esm/handlers/error.handler.d.ts +15 -0
- package/dist/esm/handlers/error.handler.js +93 -0
- package/dist/esm/handlers/network.handler.d.ts +16 -0
- package/dist/esm/handlers/network.handler.js +132 -0
- package/dist/esm/handlers/page-view.handler.d.ts +15 -0
- package/dist/esm/handlers/page-view.handler.js +79 -0
- package/dist/esm/handlers/performance.handler.d.ts +19 -0
- package/dist/esm/handlers/performance.handler.js +218 -0
- package/dist/esm/handlers/scroll.handler.d.ts +16 -0
- package/dist/esm/handlers/scroll.handler.js +134 -0
- package/dist/esm/handlers/session.handler.d.ts +29 -0
- package/dist/esm/handlers/session.handler.js +353 -0
- package/dist/esm/integrations/google-analytics.integration.d.ts +18 -0
- package/dist/esm/integrations/google-analytics.integration.js +155 -0
- package/dist/esm/listeners/activity-listener-manager.d.ts +8 -0
- package/dist/esm/listeners/activity-listener-manager.js +28 -0
- package/dist/esm/listeners/index.d.ts +6 -0
- package/dist/esm/listeners/index.js +5 -0
- package/dist/esm/listeners/input-listener-managers.d.ts +15 -0
- package/dist/esm/listeners/input-listener-managers.js +53 -0
- package/dist/esm/listeners/listeners.types.d.ts +4 -0
- package/dist/esm/listeners/listeners.types.js +1 -0
- package/dist/esm/listeners/touch-listener-manager.d.ts +10 -0
- package/dist/esm/listeners/touch-listener-manager.js +52 -0
- package/dist/esm/listeners/unload-listener-manager.d.ts +8 -0
- package/dist/esm/listeners/unload-listener-manager.js +26 -0
- package/dist/esm/listeners/visibility-listener-manager.d.ts +12 -0
- package/dist/esm/listeners/visibility-listener-manager.js +79 -0
- package/dist/esm/managers/api.manager.d.ts +3 -0
- package/dist/esm/managers/api.manager.js +10 -0
- package/dist/esm/managers/config.manager.d.ts +7 -0
- package/dist/esm/managers/config.manager.js +90 -0
- package/dist/esm/managers/cross-tab-session.manager.d.ts +170 -0
- package/dist/esm/managers/cross-tab-session.manager.js +726 -0
- package/dist/esm/managers/event.manager.d.ts +61 -0
- package/dist/esm/managers/event.manager.js +504 -0
- package/dist/esm/managers/sampling.manager.d.ts +8 -0
- package/dist/esm/managers/sampling.manager.js +49 -0
- package/dist/esm/managers/sender.manager.d.ts +46 -0
- package/dist/esm/managers/sender.manager.js +300 -0
- package/dist/esm/managers/session-recovery.manager.d.ts +65 -0
- package/dist/esm/managers/session-recovery.manager.js +233 -0
- package/dist/esm/managers/session.manager.d.ts +72 -0
- package/dist/esm/managers/session.manager.js +583 -0
- package/dist/esm/managers/state.manager.d.ts +5 -0
- package/dist/esm/managers/state.manager.js +19 -0
- package/dist/esm/managers/storage.manager.d.ts +10 -0
- package/dist/esm/managers/storage.manager.js +77 -0
- package/dist/esm/managers/tags.manager.d.ts +12 -0
- package/dist/esm/managers/tags.manager.js +285 -0
- package/dist/esm/managers/user.manager.d.ts +7 -0
- package/dist/esm/managers/user.manager.js +18 -0
- package/dist/esm/public-api.d.ts +1 -0
- package/dist/esm/public-api.js +1 -0
- package/dist/esm/types/api.types.d.ts +21 -0
- package/dist/esm/types/api.types.js +22 -0
- package/dist/esm/types/common.types.d.ts +1 -0
- package/dist/esm/types/common.types.js +1 -0
- package/dist/esm/types/config.types.d.ts +104 -0
- package/dist/esm/types/config.types.js +1 -0
- package/dist/esm/types/device.types.d.ts +6 -0
- package/dist/esm/types/device.types.js +7 -0
- package/dist/esm/types/event.types.d.ts +104 -0
- package/dist/esm/types/event.types.js +22 -0
- package/dist/esm/types/index.d.ts +13 -0
- package/dist/esm/types/index.js +13 -0
- package/dist/esm/types/log.types.d.ts +4 -0
- package/dist/esm/types/log.types.js +1 -0
- package/dist/esm/types/mode.types.d.ts +7 -0
- package/dist/esm/types/mode.types.js +8 -0
- package/dist/esm/types/queue.types.d.ts +23 -0
- package/dist/esm/types/queue.types.js +1 -0
- package/dist/esm/types/session.types.d.ts +65 -0
- package/dist/esm/types/session.types.js +1 -0
- package/dist/esm/types/state.types.d.ts +12 -0
- package/dist/esm/types/state.types.js +1 -0
- package/dist/esm/types/tag.types.d.ts +43 -0
- package/dist/esm/types/tag.types.js +28 -0
- package/dist/esm/types/validation-error.types.d.ts +42 -0
- package/dist/esm/types/validation-error.types.js +59 -0
- package/dist/esm/types/web-vitals.types.d.ts +6 -0
- package/dist/esm/types/web-vitals.types.js +1 -0
- package/dist/esm/types/window.types.d.ts +17 -0
- package/dist/esm/types/window.types.js +1 -0
- package/dist/esm/utils/browser/device-detector.utils.d.ts +6 -0
- package/dist/esm/utils/browser/device-detector.utils.js +67 -0
- package/dist/esm/utils/browser/index.d.ts +2 -0
- package/dist/esm/utils/browser/index.js +2 -0
- package/dist/esm/utils/browser/utm-params.utils.d.ts +6 -0
- package/dist/esm/utils/browser/utm-params.utils.js +33 -0
- package/dist/esm/utils/data/index.d.ts +1 -0
- package/dist/esm/utils/data/index.js +1 -0
- package/dist/esm/utils/data/uuid.utils.d.ts +5 -0
- package/dist/esm/utils/data/uuid.utils.js +14 -0
- package/dist/esm/utils/index.d.ts +6 -0
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/logging/debug-logger.utils.d.ts +56 -0
- package/dist/esm/utils/logging/debug-logger.utils.js +136 -0
- package/dist/esm/utils/logging/index.d.ts +1 -0
- package/dist/esm/utils/logging/index.js +1 -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.d.ts +20 -0
- package/dist/esm/utils/network/url.utils.js +166 -0
- package/dist/esm/utils/security/index.d.ts +1 -0
- package/dist/esm/utils/security/index.js +1 -0
- package/dist/esm/utils/security/sanitize.utils.d.ts +32 -0
- package/dist/esm/utils/security/sanitize.utils.js +311 -0
- package/dist/esm/utils/validations/config-validations.utils.d.ts +42 -0
- package/dist/esm/utils/validations/config-validations.utils.js +289 -0
- package/dist/esm/utils/validations/event-validations.utils.d.ts +12 -0
- package/dist/esm/utils/validations/event-validations.utils.js +26 -0
- package/dist/esm/utils/validations/index.d.ts +5 -0
- package/dist/esm/utils/validations/index.js +5 -0
- package/dist/esm/utils/validations/metadata-validations.utils.d.ts +22 -0
- package/dist/esm/utils/validations/metadata-validations.utils.js +110 -0
- package/dist/esm/utils/validations/type-guards.utils.d.ts +6 -0
- package/dist/esm/utils/validations/type-guards.utils.js +27 -0
- package/dist/esm/utils/validations/url-validations.utils.d.ts +15 -0
- package/dist/esm/utils/validations/url-validations.utils.js +42 -0
- package/package.json +80 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MetadataType } from './common.types';
|
|
2
|
+
import { DeviceType } from './device.types';
|
|
3
|
+
import { EventData } from './event.types';
|
|
4
|
+
export interface BaseEventsQueueDto {
|
|
5
|
+
user_id: string;
|
|
6
|
+
session_id: string;
|
|
7
|
+
device: DeviceType;
|
|
8
|
+
events: EventData[];
|
|
9
|
+
global_metadata?: Record<string, MetadataType>;
|
|
10
|
+
}
|
|
11
|
+
export interface ExtendedEventsQueueDto extends BaseEventsQueueDto {
|
|
12
|
+
project: string;
|
|
13
|
+
source: string;
|
|
14
|
+
ip: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PersistedQueueData {
|
|
17
|
+
userId: string;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
device: BaseEventsQueueDto['device'];
|
|
20
|
+
events: BaseEventsQueueDto['events'];
|
|
21
|
+
timestamp: number;
|
|
22
|
+
global_metadata?: BaseEventsQueueDto['global_metadata'];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type SessionEndReason = 'inactivity' | 'page_unload' | 'manual_stop' | 'orphaned_cleanup' | 'tab_closed';
|
|
2
|
+
export interface SessionEndConfig {
|
|
3
|
+
enablePageUnloadHandlers: boolean;
|
|
4
|
+
syncTimeoutMs: number;
|
|
5
|
+
maxRetries: number;
|
|
6
|
+
debugMode: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SessionEndResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
reason: SessionEndReason;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
eventsFlushed: number;
|
|
13
|
+
method: 'async' | 'sync';
|
|
14
|
+
}
|
|
15
|
+
export interface SessionEndStats {
|
|
16
|
+
totalSessionEnds: number;
|
|
17
|
+
successfulEnds: number;
|
|
18
|
+
failedEnds: number;
|
|
19
|
+
duplicatePrevented: number;
|
|
20
|
+
reasonCounts: Record<SessionEndReason, number>;
|
|
21
|
+
}
|
|
22
|
+
export interface CrossTabSessionConfig {
|
|
23
|
+
tabHeartbeatIntervalMs: number;
|
|
24
|
+
tabElectionTimeoutMs: number;
|
|
25
|
+
debugMode: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface TabInfo {
|
|
28
|
+
id: string;
|
|
29
|
+
lastHeartbeat: number;
|
|
30
|
+
isLeader: boolean;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
startTime: number;
|
|
33
|
+
}
|
|
34
|
+
export interface CrossTabMessage {
|
|
35
|
+
type: 'heartbeat' | 'session_start' | 'session_end' | 'tab_closing' | 'election_request' | 'election_response';
|
|
36
|
+
tabId: string;
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
timestamp: number;
|
|
39
|
+
data?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
export interface SessionRecoveryConfig {
|
|
42
|
+
recoveryWindowMs: number;
|
|
43
|
+
maxRecoveryAttempts: number;
|
|
44
|
+
contextPreservation: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface SessionContext {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
startTime: number;
|
|
49
|
+
lastActivity: number;
|
|
50
|
+
tabCount: number;
|
|
51
|
+
recoveryAttempts: number;
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
export interface RecoveryAttempt {
|
|
55
|
+
sessionId: string;
|
|
56
|
+
timestamp: number;
|
|
57
|
+
attempt: number;
|
|
58
|
+
context: SessionContext;
|
|
59
|
+
}
|
|
60
|
+
export interface SessionHealth {
|
|
61
|
+
recoveryAttempts: number;
|
|
62
|
+
sessionTimeouts: number;
|
|
63
|
+
crossTabConflicts: number;
|
|
64
|
+
lastHealthCheck: number;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config } from './config.types';
|
|
2
|
+
import { DeviceType } from './device.types';
|
|
3
|
+
export interface State {
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
config: Config;
|
|
6
|
+
sessionId: string | null;
|
|
7
|
+
userId: string;
|
|
8
|
+
device: DeviceType;
|
|
9
|
+
pageUrl: string;
|
|
10
|
+
hasStartSession: boolean;
|
|
11
|
+
suppressNextScroll: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EventType } from './event.types';
|
|
2
|
+
export declare enum TagLogicalOperator {
|
|
3
|
+
AND = "AND",
|
|
4
|
+
OR = "OR"
|
|
5
|
+
}
|
|
6
|
+
export declare enum TagConditionType {
|
|
7
|
+
URL_MATCHES = "url_matches",
|
|
8
|
+
ELEMENT_MATCHES = "element_matches",
|
|
9
|
+
DEVICE_TYPE = "device_type",
|
|
10
|
+
ELEMENT_TEXT = "element_text",
|
|
11
|
+
ELEMENT_ATTRIBUTE = "element_attribute",
|
|
12
|
+
UTM_SOURCE = "utm_source",
|
|
13
|
+
UTM_MEDIUM = "utm_medium",
|
|
14
|
+
UTM_CAMPAIGN = "utm_campaign"
|
|
15
|
+
}
|
|
16
|
+
export declare enum TagConditionOperator {
|
|
17
|
+
EQUALS = "equals",
|
|
18
|
+
CONTAINS = "contains",
|
|
19
|
+
STARTS_WITH = "starts_with",
|
|
20
|
+
ENDS_WITH = "ends_with",
|
|
21
|
+
REGEX = "regex",
|
|
22
|
+
GREATER_THAN = "greater_than",
|
|
23
|
+
LESS_THAN = "less_than",
|
|
24
|
+
EXISTS = "exists",
|
|
25
|
+
NOT_EXISTS = "not_exists"
|
|
26
|
+
}
|
|
27
|
+
export type TagConfig = Pick<Tag, 'key' | 'triggerType' | 'logicalOperator' | 'conditions'> & {
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
export interface Tag {
|
|
31
|
+
key: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
active: boolean;
|
|
35
|
+
triggerType: EventType;
|
|
36
|
+
logicalOperator?: TagLogicalOperator;
|
|
37
|
+
conditions: TagCondition[];
|
|
38
|
+
}
|
|
39
|
+
export interface TagCondition {
|
|
40
|
+
type: TagConditionType;
|
|
41
|
+
operator: TagConditionOperator;
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var TagLogicalOperator;
|
|
2
|
+
(function (TagLogicalOperator) {
|
|
3
|
+
TagLogicalOperator["AND"] = "AND";
|
|
4
|
+
TagLogicalOperator["OR"] = "OR";
|
|
5
|
+
})(TagLogicalOperator || (TagLogicalOperator = {}));
|
|
6
|
+
export var TagConditionType;
|
|
7
|
+
(function (TagConditionType) {
|
|
8
|
+
TagConditionType["URL_MATCHES"] = "url_matches";
|
|
9
|
+
TagConditionType["ELEMENT_MATCHES"] = "element_matches";
|
|
10
|
+
TagConditionType["DEVICE_TYPE"] = "device_type";
|
|
11
|
+
TagConditionType["ELEMENT_TEXT"] = "element_text";
|
|
12
|
+
TagConditionType["ELEMENT_ATTRIBUTE"] = "element_attribute";
|
|
13
|
+
TagConditionType["UTM_SOURCE"] = "utm_source";
|
|
14
|
+
TagConditionType["UTM_MEDIUM"] = "utm_medium";
|
|
15
|
+
TagConditionType["UTM_CAMPAIGN"] = "utm_campaign";
|
|
16
|
+
})(TagConditionType || (TagConditionType = {}));
|
|
17
|
+
export var TagConditionOperator;
|
|
18
|
+
(function (TagConditionOperator) {
|
|
19
|
+
TagConditionOperator["EQUALS"] = "equals";
|
|
20
|
+
TagConditionOperator["CONTAINS"] = "contains";
|
|
21
|
+
TagConditionOperator["STARTS_WITH"] = "starts_with";
|
|
22
|
+
TagConditionOperator["ENDS_WITH"] = "ends_with";
|
|
23
|
+
TagConditionOperator["REGEX"] = "regex";
|
|
24
|
+
TagConditionOperator["GREATER_THAN"] = "greater_than";
|
|
25
|
+
TagConditionOperator["LESS_THAN"] = "less_than";
|
|
26
|
+
TagConditionOperator["EXISTS"] = "exists";
|
|
27
|
+
TagConditionOperator["NOT_EXISTS"] = "not_exists";
|
|
28
|
+
})(TagConditionOperator || (TagConditionOperator = {}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for TraceLog validation errors
|
|
3
|
+
* Provides better error handling and consistency across validation layers
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all TraceLog validation errors
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class TraceLogValidationError extends Error {
|
|
9
|
+
readonly errorCode: string;
|
|
10
|
+
readonly layer: 'config' | 'app' | 'runtime';
|
|
11
|
+
constructor(message: string, errorCode: string, layer: 'config' | 'app' | 'runtime');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Thrown when project ID validation fails
|
|
15
|
+
*/
|
|
16
|
+
export declare class ProjectIdValidationError extends TraceLogValidationError {
|
|
17
|
+
constructor(message?: string, layer?: 'config' | 'app' | 'runtime');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Thrown when app configuration validation fails
|
|
21
|
+
*/
|
|
22
|
+
export declare class AppConfigValidationError extends TraceLogValidationError {
|
|
23
|
+
constructor(message: string, layer?: 'config' | 'app' | 'runtime');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when session timeout validation fails
|
|
27
|
+
*/
|
|
28
|
+
export declare class SessionTimeoutValidationError extends TraceLogValidationError {
|
|
29
|
+
constructor(message: string, layer?: 'config' | 'app' | 'runtime');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when sampling rate validation fails
|
|
33
|
+
*/
|
|
34
|
+
export declare class SamplingRateValidationError extends TraceLogValidationError {
|
|
35
|
+
constructor(message: string, layer?: 'config' | 'app' | 'runtime');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Thrown when integrations validation fails
|
|
39
|
+
*/
|
|
40
|
+
export declare class IntegrationValidationError extends TraceLogValidationError {
|
|
41
|
+
constructor(message: string, layer?: 'config' | 'app' | 'runtime');
|
|
42
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for TraceLog validation errors
|
|
3
|
+
* Provides better error handling and consistency across validation layers
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all TraceLog validation errors
|
|
7
|
+
*/
|
|
8
|
+
export class TraceLogValidationError extends Error {
|
|
9
|
+
constructor(message, errorCode, layer) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.errorCode = errorCode;
|
|
12
|
+
this.layer = layer;
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
// Maintains proper stack trace for where error was thrown (only available on V8)
|
|
15
|
+
if (Error.captureStackTrace) {
|
|
16
|
+
Error.captureStackTrace(this, this.constructor);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Thrown when project ID validation fails
|
|
22
|
+
*/
|
|
23
|
+
export class ProjectIdValidationError extends TraceLogValidationError {
|
|
24
|
+
constructor(message = 'Project ID is required', layer = 'config') {
|
|
25
|
+
super(message, 'PROJECT_ID_INVALID', layer);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Thrown when app configuration validation fails
|
|
30
|
+
*/
|
|
31
|
+
export class AppConfigValidationError extends TraceLogValidationError {
|
|
32
|
+
constructor(message, layer = 'config') {
|
|
33
|
+
super(message, 'APP_CONFIG_INVALID', layer);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when session timeout validation fails
|
|
38
|
+
*/
|
|
39
|
+
export class SessionTimeoutValidationError extends TraceLogValidationError {
|
|
40
|
+
constructor(message, layer = 'config') {
|
|
41
|
+
super(message, 'SESSION_TIMEOUT_INVALID', layer);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Thrown when sampling rate validation fails
|
|
46
|
+
*/
|
|
47
|
+
export class SamplingRateValidationError extends TraceLogValidationError {
|
|
48
|
+
constructor(message, layer = 'config') {
|
|
49
|
+
super(message, 'SAMPLING_RATE_INVALID', layer);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Thrown when integrations validation fails
|
|
54
|
+
*/
|
|
55
|
+
export class IntegrationValidationError extends TraceLogValidationError {
|
|
56
|
+
constructor(message, layer = 'config') {
|
|
57
|
+
super(message, 'INTEGRATION_INVALID', layer);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { App } from '../app';
|
|
2
|
+
/**
|
|
3
|
+
* Testing bridge interface for E2E tests
|
|
4
|
+
* Only available when NODE_ENV=dev
|
|
5
|
+
*/
|
|
6
|
+
export interface TraceLogTestBridge extends App {
|
|
7
|
+
isInitializing(): boolean;
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
/**
|
|
12
|
+
* Testing bridge for E2E tests
|
|
13
|
+
* Only available when NODE_ENV=dev
|
|
14
|
+
*/
|
|
15
|
+
__traceLogBridge?: TraceLogTestBridge;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DeviceType } from '../../types/device.types';
|
|
2
|
+
import { debugLog } from '../logging';
|
|
3
|
+
let coarsePointerQuery;
|
|
4
|
+
let noHoverQuery;
|
|
5
|
+
const initMediaQueries = () => {
|
|
6
|
+
if (typeof window !== 'undefined' && !coarsePointerQuery) {
|
|
7
|
+
coarsePointerQuery = window.matchMedia('(pointer: coarse)');
|
|
8
|
+
noHoverQuery = window.matchMedia('(hover: none)');
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Detects the device type based on screen size, user agent, and browser capabilities
|
|
13
|
+
* @returns The detected device type
|
|
14
|
+
*/
|
|
15
|
+
export const getDeviceType = () => {
|
|
16
|
+
try {
|
|
17
|
+
debugLog.debug('DeviceDetector', 'Starting device detection');
|
|
18
|
+
const nav = navigator;
|
|
19
|
+
if (nav.userAgentData && typeof nav.userAgentData.mobile === 'boolean') {
|
|
20
|
+
debugLog.debug('DeviceDetector', 'Using modern User-Agent Client Hints API', {
|
|
21
|
+
mobile: nav.userAgentData.mobile,
|
|
22
|
+
platform: nav.userAgentData.platform,
|
|
23
|
+
});
|
|
24
|
+
if (nav.userAgentData.platform && /ipad|tablet/i.test(nav.userAgentData.platform)) {
|
|
25
|
+
debugLog.debug('DeviceDetector', 'Device detected as tablet via platform hint');
|
|
26
|
+
return DeviceType.Tablet;
|
|
27
|
+
}
|
|
28
|
+
const result = nav.userAgentData.mobile ? DeviceType.Mobile : DeviceType.Desktop;
|
|
29
|
+
debugLog.debug('DeviceDetector', 'Device detected via User-Agent hints', { result });
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
debugLog.debug('DeviceDetector', 'Using fallback detection methods');
|
|
33
|
+
initMediaQueries();
|
|
34
|
+
const width = window.innerWidth;
|
|
35
|
+
const hasCoarsePointer = coarsePointerQuery?.matches ?? false;
|
|
36
|
+
const hasNoHover = noHoverQuery?.matches ?? false;
|
|
37
|
+
const hasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
38
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
39
|
+
const isMobileUA = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(ua);
|
|
40
|
+
const isTabletUA = /tablet|ipad|android(?!.*mobile)/.test(ua);
|
|
41
|
+
const detectionData = {
|
|
42
|
+
width,
|
|
43
|
+
hasCoarsePointer,
|
|
44
|
+
hasNoHover,
|
|
45
|
+
hasTouchSupport,
|
|
46
|
+
isMobileUA,
|
|
47
|
+
isTabletUA,
|
|
48
|
+
maxTouchPoints: navigator.maxTouchPoints,
|
|
49
|
+
};
|
|
50
|
+
if (width <= 767 || (isMobileUA && hasTouchSupport)) {
|
|
51
|
+
debugLog.debug('DeviceDetector', 'Device detected as mobile', detectionData);
|
|
52
|
+
return DeviceType.Mobile;
|
|
53
|
+
}
|
|
54
|
+
if ((width >= 768 && width <= 1024) || isTabletUA || (hasCoarsePointer && hasNoHover && hasTouchSupport)) {
|
|
55
|
+
debugLog.debug('DeviceDetector', 'Device detected as tablet', detectionData);
|
|
56
|
+
return DeviceType.Tablet;
|
|
57
|
+
}
|
|
58
|
+
debugLog.debug('DeviceDetector', 'Device detected as desktop', detectionData);
|
|
59
|
+
return DeviceType.Desktop;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
debugLog.warn('DeviceDetector', 'Device detection failed, defaulting to desktop', {
|
|
63
|
+
error: error instanceof Error ? error.message : error,
|
|
64
|
+
});
|
|
65
|
+
return DeviceType.Desktop;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UTM_PARAMS } from '../../constants';
|
|
2
|
+
import { debugLog } from '../logging';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts UTM parameters from the current URL
|
|
5
|
+
* @returns UTM parameters object or undefined if none found
|
|
6
|
+
*/
|
|
7
|
+
export const getUTMParameters = () => {
|
|
8
|
+
debugLog.debug('UTMParams', 'Extracting UTM parameters from URL', {
|
|
9
|
+
url: window.location.href,
|
|
10
|
+
search: window.location.search,
|
|
11
|
+
});
|
|
12
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
13
|
+
const utmParams = {};
|
|
14
|
+
UTM_PARAMS.forEach((param) => {
|
|
15
|
+
const value = urlParams.get(param);
|
|
16
|
+
if (value) {
|
|
17
|
+
const key = param.split('utm_')[1];
|
|
18
|
+
utmParams[key] = value;
|
|
19
|
+
debugLog.debug('UTMParams', 'Found UTM parameter', { param, key, value });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const result = Object.keys(utmParams).length ? utmParams : undefined;
|
|
23
|
+
if (result) {
|
|
24
|
+
debugLog.debug('UTMParams', 'UTM parameters extracted successfully', {
|
|
25
|
+
parameterCount: Object.keys(result).length,
|
|
26
|
+
parameters: Object.keys(result),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
debugLog.debug('UTMParams', 'No UTM parameters found in URL');
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './uuid.utils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './uuid.utils';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { debugLog } from '../logging';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a RFC4122 compliant UUID v4
|
|
4
|
+
* @returns A UUID string
|
|
5
|
+
*/
|
|
6
|
+
export const generateUUID = () => {
|
|
7
|
+
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
8
|
+
const r = (Math.random() * 16) | 0;
|
|
9
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
10
|
+
return v.toString(16);
|
|
11
|
+
});
|
|
12
|
+
debugLog.verbose('UUIDUtils', 'Generated new UUID', { uuid });
|
|
13
|
+
return uuid;
|
|
14
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { StateManager } from '../../managers/state.manager';
|
|
2
|
+
/**
|
|
3
|
+
* Debug logger class that extends StateManager for clean access to global state
|
|
4
|
+
*/
|
|
5
|
+
declare class DebugLogger extends StateManager {
|
|
6
|
+
/**
|
|
7
|
+
* Client-facing error - Configuration/usage errors by the client
|
|
8
|
+
* Console: qa and debug modes | Events: NODE_ENV=dev
|
|
9
|
+
*/
|
|
10
|
+
clientError(namespace: string, message: string, data?: unknown): void;
|
|
11
|
+
/**
|
|
12
|
+
* Client-facing warning - Configuration/usage warnings by the client
|
|
13
|
+
* Console: qa and debug modes | Events: NODE_ENV=dev
|
|
14
|
+
*/
|
|
15
|
+
clientWarn(namespace: string, message: string, data?: unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* General operational information
|
|
18
|
+
* Console: qa and debug modes | Events: NODE_ENV=dev
|
|
19
|
+
*/
|
|
20
|
+
info(namespace: string, message: string, data?: unknown): void;
|
|
21
|
+
/**
|
|
22
|
+
* Internal library errors
|
|
23
|
+
* Console: debug mode only | Events: NODE_ENV=dev
|
|
24
|
+
*/
|
|
25
|
+
error(namespace: string, message: string, data?: unknown): void;
|
|
26
|
+
/**
|
|
27
|
+
* Internal library warnings
|
|
28
|
+
* Console: debug mode only | Events: NODE_ENV=dev
|
|
29
|
+
*/
|
|
30
|
+
warn(namespace: string, message: string, data?: unknown): void;
|
|
31
|
+
/**
|
|
32
|
+
* Strategic debug information
|
|
33
|
+
* Console: debug mode only | Events: NODE_ENV=dev
|
|
34
|
+
*/
|
|
35
|
+
debug(namespace: string, message: string, data?: unknown): void;
|
|
36
|
+
/**
|
|
37
|
+
* Detailed trace information
|
|
38
|
+
* Console: debug mode only | Events: NODE_ENV=dev
|
|
39
|
+
*/
|
|
40
|
+
verbose(namespace: string, message: string, data?: unknown): void;
|
|
41
|
+
private getCurrentMode;
|
|
42
|
+
private shouldShowLog;
|
|
43
|
+
private formatMessage;
|
|
44
|
+
private getConsoleMethod;
|
|
45
|
+
private logMessage;
|
|
46
|
+
/**
|
|
47
|
+
* Dispatches tracelog:log events for E2E testing and development debugging
|
|
48
|
+
*/
|
|
49
|
+
private dispatchEvent;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Singleton debug logger instance
|
|
53
|
+
* Provides the same API as before: debugLog.clientError(), debugLog.info(), etc.
|
|
54
|
+
*/
|
|
55
|
+
export declare const debugLog: DebugLogger;
|
|
56
|
+
export {};
|