@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,104 @@
|
|
|
1
|
+
import { MetadataType } from './common.types';
|
|
2
|
+
import { SessionEndReason } from './session.types';
|
|
3
|
+
export type WebVitalType = 'LCP' | 'CLS' | 'INP' | 'FCP' | 'TTFB' | 'LONG_TASK';
|
|
4
|
+
export declare enum EventType {
|
|
5
|
+
PAGE_VIEW = "page_view",
|
|
6
|
+
CLICK = "click",
|
|
7
|
+
SCROLL = "scroll",
|
|
8
|
+
SESSION_START = "session_start",
|
|
9
|
+
SESSION_END = "session_end",
|
|
10
|
+
CUSTOM = "custom",
|
|
11
|
+
WEB_VITALS = "web_vitals",
|
|
12
|
+
ERROR = "error"
|
|
13
|
+
}
|
|
14
|
+
export declare enum ScrollDirection {
|
|
15
|
+
UP = "up",
|
|
16
|
+
DOWN = "down"
|
|
17
|
+
}
|
|
18
|
+
export declare enum ErrorType {
|
|
19
|
+
JS_ERROR = "js_error",
|
|
20
|
+
PROMISE_REJECTION = "promise_rejection",
|
|
21
|
+
NETWORK_ERROR = "network_error"
|
|
22
|
+
}
|
|
23
|
+
export interface ScrollData {
|
|
24
|
+
depth: number;
|
|
25
|
+
direction: ScrollDirection;
|
|
26
|
+
}
|
|
27
|
+
export interface ClickData {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
relativeX: number;
|
|
31
|
+
relativeY: number;
|
|
32
|
+
id?: string;
|
|
33
|
+
class?: string;
|
|
34
|
+
tag?: string;
|
|
35
|
+
text?: string;
|
|
36
|
+
href?: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
alt?: string;
|
|
39
|
+
role?: string;
|
|
40
|
+
ariaLabel?: string;
|
|
41
|
+
dataAttributes?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export interface ClickCoordinates {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
relativeX: number;
|
|
47
|
+
relativeY: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ClickTrackingElementData {
|
|
50
|
+
element: HTMLElement;
|
|
51
|
+
name: string;
|
|
52
|
+
value?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CustomEventData {
|
|
55
|
+
name: string;
|
|
56
|
+
metadata?: Record<string, MetadataType>;
|
|
57
|
+
}
|
|
58
|
+
export interface WebVitalsData {
|
|
59
|
+
type: WebVitalType;
|
|
60
|
+
value: number;
|
|
61
|
+
}
|
|
62
|
+
export interface ErrorData {
|
|
63
|
+
type: ErrorType;
|
|
64
|
+
message: string;
|
|
65
|
+
method?: string;
|
|
66
|
+
url?: string;
|
|
67
|
+
status?: number;
|
|
68
|
+
statusText?: string;
|
|
69
|
+
duration?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface UTM {
|
|
72
|
+
source?: string;
|
|
73
|
+
medium?: string;
|
|
74
|
+
campaign?: string;
|
|
75
|
+
term?: string;
|
|
76
|
+
content?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface PageViewData {
|
|
79
|
+
referrer?: string;
|
|
80
|
+
title?: string;
|
|
81
|
+
pathname?: string;
|
|
82
|
+
search?: string;
|
|
83
|
+
hash?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface EventData {
|
|
86
|
+
type: EventType;
|
|
87
|
+
page_url: string;
|
|
88
|
+
timestamp: number;
|
|
89
|
+
referrer?: string;
|
|
90
|
+
from_page_url?: string;
|
|
91
|
+
scroll_data?: ScrollData;
|
|
92
|
+
click_data?: ClickData;
|
|
93
|
+
custom_event?: CustomEventData;
|
|
94
|
+
web_vitals?: WebVitalsData;
|
|
95
|
+
page_view?: PageViewData;
|
|
96
|
+
session_start_recovered?: boolean;
|
|
97
|
+
session_end_reason?: SessionEndReason;
|
|
98
|
+
error_data?: ErrorData;
|
|
99
|
+
utm?: UTM;
|
|
100
|
+
tags?: string[] | {
|
|
101
|
+
id: string;
|
|
102
|
+
key: string;
|
|
103
|
+
}[];
|
|
104
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorType = exports.ScrollDirection = exports.EventType = void 0;
|
|
4
|
+
var EventType;
|
|
5
|
+
(function (EventType) {
|
|
6
|
+
EventType["PAGE_VIEW"] = "page_view";
|
|
7
|
+
EventType["CLICK"] = "click";
|
|
8
|
+
EventType["SCROLL"] = "scroll";
|
|
9
|
+
EventType["SESSION_START"] = "session_start";
|
|
10
|
+
EventType["SESSION_END"] = "session_end";
|
|
11
|
+
EventType["CUSTOM"] = "custom";
|
|
12
|
+
EventType["WEB_VITALS"] = "web_vitals";
|
|
13
|
+
EventType["ERROR"] = "error";
|
|
14
|
+
})(EventType || (exports.EventType = EventType = {}));
|
|
15
|
+
var ScrollDirection;
|
|
16
|
+
(function (ScrollDirection) {
|
|
17
|
+
ScrollDirection["UP"] = "up";
|
|
18
|
+
ScrollDirection["DOWN"] = "down";
|
|
19
|
+
})(ScrollDirection || (exports.ScrollDirection = ScrollDirection = {}));
|
|
20
|
+
var ErrorType;
|
|
21
|
+
(function (ErrorType) {
|
|
22
|
+
ErrorType["JS_ERROR"] = "js_error";
|
|
23
|
+
ErrorType["PROMISE_REJECTION"] = "promise_rejection";
|
|
24
|
+
ErrorType["NETWORK_ERROR"] = "network_error";
|
|
25
|
+
})(ErrorType || (exports.ErrorType = ErrorType = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './api.types';
|
|
2
|
+
export * from './common.types';
|
|
3
|
+
export * from './config.types';
|
|
4
|
+
export * from './device.types';
|
|
5
|
+
export * from './event.types';
|
|
6
|
+
export * from './log.types';
|
|
7
|
+
export * from './mode.types';
|
|
8
|
+
export * from './queue.types';
|
|
9
|
+
export * from './state.types';
|
|
10
|
+
export * from './tag.types';
|
|
11
|
+
export * from './validation-error.types';
|
|
12
|
+
export * from './web-vitals.types';
|
|
13
|
+
export * from './window.types';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api.types"), exports);
|
|
18
|
+
__exportStar(require("./common.types"), exports);
|
|
19
|
+
__exportStar(require("./config.types"), exports);
|
|
20
|
+
__exportStar(require("./device.types"), exports);
|
|
21
|
+
__exportStar(require("./event.types"), exports);
|
|
22
|
+
__exportStar(require("./log.types"), exports);
|
|
23
|
+
__exportStar(require("./mode.types"), exports);
|
|
24
|
+
__exportStar(require("./queue.types"), exports);
|
|
25
|
+
__exportStar(require("./state.types"), exports);
|
|
26
|
+
__exportStar(require("./tag.types"), exports);
|
|
27
|
+
__exportStar(require("./validation-error.types"), exports);
|
|
28
|
+
__exportStar(require("./web-vitals.types"), exports);
|
|
29
|
+
__exportStar(require("./window.types"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* App modes for the TraceLog Library
|
|
6
|
+
*/
|
|
7
|
+
var Mode;
|
|
8
|
+
(function (Mode) {
|
|
9
|
+
Mode["QA"] = "qa";
|
|
10
|
+
Mode["DEBUG"] = "debug";
|
|
11
|
+
})(Mode || (exports.Mode = Mode = {}));
|
|
@@ -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,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,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,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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TagConditionOperator = exports.TagConditionType = exports.TagLogicalOperator = void 0;
|
|
4
|
+
var TagLogicalOperator;
|
|
5
|
+
(function (TagLogicalOperator) {
|
|
6
|
+
TagLogicalOperator["AND"] = "AND";
|
|
7
|
+
TagLogicalOperator["OR"] = "OR";
|
|
8
|
+
})(TagLogicalOperator || (exports.TagLogicalOperator = TagLogicalOperator = {}));
|
|
9
|
+
var TagConditionType;
|
|
10
|
+
(function (TagConditionType) {
|
|
11
|
+
TagConditionType["URL_MATCHES"] = "url_matches";
|
|
12
|
+
TagConditionType["ELEMENT_MATCHES"] = "element_matches";
|
|
13
|
+
TagConditionType["DEVICE_TYPE"] = "device_type";
|
|
14
|
+
TagConditionType["ELEMENT_TEXT"] = "element_text";
|
|
15
|
+
TagConditionType["ELEMENT_ATTRIBUTE"] = "element_attribute";
|
|
16
|
+
TagConditionType["UTM_SOURCE"] = "utm_source";
|
|
17
|
+
TagConditionType["UTM_MEDIUM"] = "utm_medium";
|
|
18
|
+
TagConditionType["UTM_CAMPAIGN"] = "utm_campaign";
|
|
19
|
+
})(TagConditionType || (exports.TagConditionType = TagConditionType = {}));
|
|
20
|
+
var TagConditionOperator;
|
|
21
|
+
(function (TagConditionOperator) {
|
|
22
|
+
TagConditionOperator["EQUALS"] = "equals";
|
|
23
|
+
TagConditionOperator["CONTAINS"] = "contains";
|
|
24
|
+
TagConditionOperator["STARTS_WITH"] = "starts_with";
|
|
25
|
+
TagConditionOperator["ENDS_WITH"] = "ends_with";
|
|
26
|
+
TagConditionOperator["REGEX"] = "regex";
|
|
27
|
+
TagConditionOperator["GREATER_THAN"] = "greater_than";
|
|
28
|
+
TagConditionOperator["LESS_THAN"] = "less_than";
|
|
29
|
+
TagConditionOperator["EXISTS"] = "exists";
|
|
30
|
+
TagConditionOperator["NOT_EXISTS"] = "not_exists";
|
|
31
|
+
})(TagConditionOperator || (exports.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,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom error classes for TraceLog validation errors
|
|
4
|
+
* Provides better error handling and consistency across validation layers
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.IntegrationValidationError = exports.SamplingRateValidationError = exports.SessionTimeoutValidationError = exports.AppConfigValidationError = exports.ProjectIdValidationError = exports.TraceLogValidationError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Base class for all TraceLog validation errors
|
|
10
|
+
*/
|
|
11
|
+
class TraceLogValidationError extends Error {
|
|
12
|
+
constructor(message, errorCode, layer) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.errorCode = errorCode;
|
|
15
|
+
this.layer = layer;
|
|
16
|
+
this.name = this.constructor.name;
|
|
17
|
+
// Maintains proper stack trace for where error was thrown (only available on V8)
|
|
18
|
+
if (Error.captureStackTrace) {
|
|
19
|
+
Error.captureStackTrace(this, this.constructor);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.TraceLogValidationError = TraceLogValidationError;
|
|
24
|
+
/**
|
|
25
|
+
* Thrown when project ID validation fails
|
|
26
|
+
*/
|
|
27
|
+
class ProjectIdValidationError extends TraceLogValidationError {
|
|
28
|
+
constructor(message = 'Project ID is required', layer = 'config') {
|
|
29
|
+
super(message, 'PROJECT_ID_INVALID', layer);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ProjectIdValidationError = ProjectIdValidationError;
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when app configuration validation fails
|
|
35
|
+
*/
|
|
36
|
+
class AppConfigValidationError extends TraceLogValidationError {
|
|
37
|
+
constructor(message, layer = 'config') {
|
|
38
|
+
super(message, 'APP_CONFIG_INVALID', layer);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.AppConfigValidationError = AppConfigValidationError;
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when session timeout validation fails
|
|
44
|
+
*/
|
|
45
|
+
class SessionTimeoutValidationError extends TraceLogValidationError {
|
|
46
|
+
constructor(message, layer = 'config') {
|
|
47
|
+
super(message, 'SESSION_TIMEOUT_INVALID', layer);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.SessionTimeoutValidationError = SessionTimeoutValidationError;
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when sampling rate validation fails
|
|
53
|
+
*/
|
|
54
|
+
class SamplingRateValidationError extends TraceLogValidationError {
|
|
55
|
+
constructor(message, layer = 'config') {
|
|
56
|
+
super(message, 'SAMPLING_RATE_INVALID', layer);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.SamplingRateValidationError = SamplingRateValidationError;
|
|
60
|
+
/**
|
|
61
|
+
* Thrown when integrations validation fails
|
|
62
|
+
*/
|
|
63
|
+
class IntegrationValidationError extends TraceLogValidationError {
|
|
64
|
+
constructor(message, layer = 'config') {
|
|
65
|
+
super(message, 'INTEGRATION_INVALID', layer);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.IntegrationValidationError = IntegrationValidationError;
|
|
@@ -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,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDeviceType = void 0;
|
|
4
|
+
const device_types_1 = require("../../types/device.types");
|
|
5
|
+
const logging_1 = require("../logging");
|
|
6
|
+
let coarsePointerQuery;
|
|
7
|
+
let noHoverQuery;
|
|
8
|
+
const initMediaQueries = () => {
|
|
9
|
+
if (typeof window !== 'undefined' && !coarsePointerQuery) {
|
|
10
|
+
coarsePointerQuery = window.matchMedia('(pointer: coarse)');
|
|
11
|
+
noHoverQuery = window.matchMedia('(hover: none)');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Detects the device type based on screen size, user agent, and browser capabilities
|
|
16
|
+
* @returns The detected device type
|
|
17
|
+
*/
|
|
18
|
+
const getDeviceType = () => {
|
|
19
|
+
try {
|
|
20
|
+
logging_1.debugLog.debug('DeviceDetector', 'Starting device detection');
|
|
21
|
+
const nav = navigator;
|
|
22
|
+
if (nav.userAgentData && typeof nav.userAgentData.mobile === 'boolean') {
|
|
23
|
+
logging_1.debugLog.debug('DeviceDetector', 'Using modern User-Agent Client Hints API', {
|
|
24
|
+
mobile: nav.userAgentData.mobile,
|
|
25
|
+
platform: nav.userAgentData.platform,
|
|
26
|
+
});
|
|
27
|
+
if (nav.userAgentData.platform && /ipad|tablet/i.test(nav.userAgentData.platform)) {
|
|
28
|
+
logging_1.debugLog.debug('DeviceDetector', 'Device detected as tablet via platform hint');
|
|
29
|
+
return device_types_1.DeviceType.Tablet;
|
|
30
|
+
}
|
|
31
|
+
const result = nav.userAgentData.mobile ? device_types_1.DeviceType.Mobile : device_types_1.DeviceType.Desktop;
|
|
32
|
+
logging_1.debugLog.debug('DeviceDetector', 'Device detected via User-Agent hints', { result });
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
logging_1.debugLog.debug('DeviceDetector', 'Using fallback detection methods');
|
|
36
|
+
initMediaQueries();
|
|
37
|
+
const width = window.innerWidth;
|
|
38
|
+
const hasCoarsePointer = coarsePointerQuery?.matches ?? false;
|
|
39
|
+
const hasNoHover = noHoverQuery?.matches ?? false;
|
|
40
|
+
const hasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
41
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
42
|
+
const isMobileUA = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(ua);
|
|
43
|
+
const isTabletUA = /tablet|ipad|android(?!.*mobile)/.test(ua);
|
|
44
|
+
const detectionData = {
|
|
45
|
+
width,
|
|
46
|
+
hasCoarsePointer,
|
|
47
|
+
hasNoHover,
|
|
48
|
+
hasTouchSupport,
|
|
49
|
+
isMobileUA,
|
|
50
|
+
isTabletUA,
|
|
51
|
+
maxTouchPoints: navigator.maxTouchPoints,
|
|
52
|
+
};
|
|
53
|
+
if (width <= 767 || (isMobileUA && hasTouchSupport)) {
|
|
54
|
+
logging_1.debugLog.debug('DeviceDetector', 'Device detected as mobile', detectionData);
|
|
55
|
+
return device_types_1.DeviceType.Mobile;
|
|
56
|
+
}
|
|
57
|
+
if ((width >= 768 && width <= 1024) || isTabletUA || (hasCoarsePointer && hasNoHover && hasTouchSupport)) {
|
|
58
|
+
logging_1.debugLog.debug('DeviceDetector', 'Device detected as tablet', detectionData);
|
|
59
|
+
return device_types_1.DeviceType.Tablet;
|
|
60
|
+
}
|
|
61
|
+
logging_1.debugLog.debug('DeviceDetector', 'Device detected as desktop', detectionData);
|
|
62
|
+
return device_types_1.DeviceType.Desktop;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
logging_1.debugLog.warn('DeviceDetector', 'Device detection failed, defaulting to desktop', {
|
|
66
|
+
error: error instanceof Error ? error.message : error,
|
|
67
|
+
});
|
|
68
|
+
return device_types_1.DeviceType.Desktop;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.getDeviceType = getDeviceType;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./device-detector.utils"), exports);
|
|
18
|
+
__exportStar(require("./utm-params.utils"), exports);
|