@rejourneyco/react-native 1.0.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/android/build.gradle.kts +135 -0
- package/android/consumer-rules.pro +10 -0
- package/android/proguard-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +15 -0
- package/android/src/main/java/com/rejourney/RejourneyModuleImpl.kt +2981 -0
- package/android/src/main/java/com/rejourney/capture/ANRHandler.kt +206 -0
- package/android/src/main/java/com/rejourney/capture/ActivityTracker.kt +98 -0
- package/android/src/main/java/com/rejourney/capture/CaptureEngine.kt +1553 -0
- package/android/src/main/java/com/rejourney/capture/CaptureHeuristics.kt +375 -0
- package/android/src/main/java/com/rejourney/capture/CrashHandler.kt +153 -0
- package/android/src/main/java/com/rejourney/capture/MotionEvent.kt +215 -0
- package/android/src/main/java/com/rejourney/capture/SegmentUploader.kt +512 -0
- package/android/src/main/java/com/rejourney/capture/VideoEncoder.kt +773 -0
- package/android/src/main/java/com/rejourney/capture/ViewHierarchyScanner.kt +633 -0
- package/android/src/main/java/com/rejourney/capture/ViewSerializer.kt +286 -0
- package/android/src/main/java/com/rejourney/core/Constants.kt +117 -0
- package/android/src/main/java/com/rejourney/core/Logger.kt +93 -0
- package/android/src/main/java/com/rejourney/core/Types.kt +124 -0
- package/android/src/main/java/com/rejourney/lifecycle/SessionLifecycleService.kt +162 -0
- package/android/src/main/java/com/rejourney/network/DeviceAuthManager.kt +747 -0
- package/android/src/main/java/com/rejourney/network/HttpClientProvider.kt +16 -0
- package/android/src/main/java/com/rejourney/network/NetworkMonitor.kt +272 -0
- package/android/src/main/java/com/rejourney/network/UploadManager.kt +1363 -0
- package/android/src/main/java/com/rejourney/network/UploadWorker.kt +492 -0
- package/android/src/main/java/com/rejourney/privacy/PrivacyMask.kt +645 -0
- package/android/src/main/java/com/rejourney/touch/GestureClassifier.kt +233 -0
- package/android/src/main/java/com/rejourney/touch/KeyboardTracker.kt +158 -0
- package/android/src/main/java/com/rejourney/touch/TextInputTracker.kt +181 -0
- package/android/src/main/java/com/rejourney/touch/TouchInterceptor.kt +591 -0
- package/android/src/main/java/com/rejourney/utils/EventBuffer.kt +284 -0
- package/android/src/main/java/com/rejourney/utils/OEMDetector.kt +154 -0
- package/android/src/main/java/com/rejourney/utils/PerfTiming.kt +235 -0
- package/android/src/main/java/com/rejourney/utils/Telemetry.kt +297 -0
- package/android/src/main/java/com/rejourney/utils/WindowUtils.kt +84 -0
- package/android/src/newarch/java/com/rejourney/RejourneyModule.kt +187 -0
- package/android/src/newarch/java/com/rejourney/RejourneyPackage.kt +40 -0
- package/android/src/oldarch/java/com/rejourney/RejourneyModule.kt +218 -0
- package/android/src/oldarch/java/com/rejourney/RejourneyPackage.kt +23 -0
- package/ios/Capture/RJANRHandler.h +42 -0
- package/ios/Capture/RJANRHandler.m +328 -0
- package/ios/Capture/RJCaptureEngine.h +275 -0
- package/ios/Capture/RJCaptureEngine.m +2062 -0
- package/ios/Capture/RJCaptureHeuristics.h +80 -0
- package/ios/Capture/RJCaptureHeuristics.m +903 -0
- package/ios/Capture/RJCrashHandler.h +46 -0
- package/ios/Capture/RJCrashHandler.m +313 -0
- package/ios/Capture/RJMotionEvent.h +183 -0
- package/ios/Capture/RJMotionEvent.m +183 -0
- package/ios/Capture/RJPerformanceManager.h +100 -0
- package/ios/Capture/RJPerformanceManager.m +373 -0
- package/ios/Capture/RJPixelBufferDownscaler.h +42 -0
- package/ios/Capture/RJPixelBufferDownscaler.m +85 -0
- package/ios/Capture/RJSegmentUploader.h +146 -0
- package/ios/Capture/RJSegmentUploader.m +778 -0
- package/ios/Capture/RJVideoEncoder.h +247 -0
- package/ios/Capture/RJVideoEncoder.m +1036 -0
- package/ios/Capture/RJViewControllerTracker.h +73 -0
- package/ios/Capture/RJViewControllerTracker.m +508 -0
- package/ios/Capture/RJViewHierarchyScanner.h +215 -0
- package/ios/Capture/RJViewHierarchyScanner.m +1464 -0
- package/ios/Capture/RJViewSerializer.h +119 -0
- package/ios/Capture/RJViewSerializer.m +498 -0
- package/ios/Core/RJConstants.h +124 -0
- package/ios/Core/RJConstants.m +88 -0
- package/ios/Core/RJLifecycleManager.h +85 -0
- package/ios/Core/RJLifecycleManager.m +308 -0
- package/ios/Core/RJLogger.h +61 -0
- package/ios/Core/RJLogger.m +211 -0
- package/ios/Core/RJTypes.h +176 -0
- package/ios/Core/RJTypes.m +66 -0
- package/ios/Core/Rejourney.h +64 -0
- package/ios/Core/Rejourney.mm +2495 -0
- package/ios/Network/RJDeviceAuthManager.h +94 -0
- package/ios/Network/RJDeviceAuthManager.m +967 -0
- package/ios/Network/RJNetworkMonitor.h +68 -0
- package/ios/Network/RJNetworkMonitor.m +267 -0
- package/ios/Network/RJRetryManager.h +73 -0
- package/ios/Network/RJRetryManager.m +325 -0
- package/ios/Network/RJUploadManager.h +267 -0
- package/ios/Network/RJUploadManager.m +2296 -0
- package/ios/Privacy/RJPrivacyMask.h +163 -0
- package/ios/Privacy/RJPrivacyMask.m +922 -0
- package/ios/Rejourney.h +63 -0
- package/ios/Touch/RJGestureClassifier.h +130 -0
- package/ios/Touch/RJGestureClassifier.m +333 -0
- package/ios/Touch/RJTouchInterceptor.h +169 -0
- package/ios/Touch/RJTouchInterceptor.m +772 -0
- package/ios/Utils/RJEventBuffer.h +112 -0
- package/ios/Utils/RJEventBuffer.m +358 -0
- package/ios/Utils/RJGzipUtils.h +33 -0
- package/ios/Utils/RJGzipUtils.m +89 -0
- package/ios/Utils/RJKeychainManager.h +48 -0
- package/ios/Utils/RJKeychainManager.m +111 -0
- package/ios/Utils/RJPerfTiming.h +209 -0
- package/ios/Utils/RJPerfTiming.m +264 -0
- package/ios/Utils/RJTelemetry.h +92 -0
- package/ios/Utils/RJTelemetry.m +320 -0
- package/ios/Utils/RJWindowUtils.h +66 -0
- package/ios/Utils/RJWindowUtils.m +133 -0
- package/lib/commonjs/NativeRejourney.js +40 -0
- package/lib/commonjs/components/Mask.js +79 -0
- package/lib/commonjs/index.js +1381 -0
- package/lib/commonjs/sdk/autoTracking.js +1259 -0
- package/lib/commonjs/sdk/constants.js +151 -0
- package/lib/commonjs/sdk/errorTracking.js +199 -0
- package/lib/commonjs/sdk/index.js +50 -0
- package/lib/commonjs/sdk/metricsTracking.js +204 -0
- package/lib/commonjs/sdk/navigation.js +151 -0
- package/lib/commonjs/sdk/networkInterceptor.js +412 -0
- package/lib/commonjs/sdk/utils.js +363 -0
- package/lib/commonjs/types/expo-router.d.js +2 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/module/NativeRejourney.js +38 -0
- package/lib/module/components/Mask.js +72 -0
- package/lib/module/index.js +1284 -0
- package/lib/module/sdk/autoTracking.js +1233 -0
- package/lib/module/sdk/constants.js +145 -0
- package/lib/module/sdk/errorTracking.js +189 -0
- package/lib/module/sdk/index.js +12 -0
- package/lib/module/sdk/metricsTracking.js +187 -0
- package/lib/module/sdk/navigation.js +143 -0
- package/lib/module/sdk/networkInterceptor.js +401 -0
- package/lib/module/sdk/utils.js +342 -0
- package/lib/module/types/expo-router.d.js +2 -0
- package/lib/module/types/index.js +2 -0
- package/lib/typescript/NativeRejourney.d.ts +147 -0
- package/lib/typescript/components/Mask.d.ts +39 -0
- package/lib/typescript/index.d.ts +117 -0
- package/lib/typescript/sdk/autoTracking.d.ts +204 -0
- package/lib/typescript/sdk/constants.d.ts +120 -0
- package/lib/typescript/sdk/errorTracking.d.ts +32 -0
- package/lib/typescript/sdk/index.d.ts +9 -0
- package/lib/typescript/sdk/metricsTracking.d.ts +58 -0
- package/lib/typescript/sdk/navigation.d.ts +33 -0
- package/lib/typescript/sdk/networkInterceptor.d.ts +47 -0
- package/lib/typescript/sdk/utils.d.ts +148 -0
- package/lib/typescript/types/index.d.ts +624 -0
- package/package.json +102 -0
- package/rejourney.podspec +21 -0
- package/src/NativeRejourney.ts +165 -0
- package/src/components/Mask.tsx +80 -0
- package/src/index.ts +1459 -0
- package/src/sdk/autoTracking.ts +1373 -0
- package/src/sdk/constants.ts +134 -0
- package/src/sdk/errorTracking.ts +231 -0
- package/src/sdk/index.ts +11 -0
- package/src/sdk/metricsTracking.ts +232 -0
- package/src/sdk/navigation.ts +157 -0
- package/src/sdk/networkInterceptor.ts +440 -0
- package/src/sdk/utils.ts +369 -0
- package/src/types/expo-router.d.ts +7 -0
- package/src/types/index.ts +739 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UPLOAD_SETTINGS = exports.STORAGE_SETTINGS = exports.SDK_VERSION = exports.PRIVACY = exports.PLAYBACK_SPEEDS = exports.MEMORY_SETTINGS = exports.GESTURE_TYPES = exports.EVENT_TYPES = exports.DEFAULT_CONFIG = exports.CPU_SETTINGS = exports.CAPTURE_SETTINGS = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Rejourney SDK Constants
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const SDK_VERSION = exports.SDK_VERSION = '1.0.0';
|
|
12
|
+
|
|
13
|
+
/** Default configuration values */
|
|
14
|
+
const DEFAULT_CONFIG = exports.DEFAULT_CONFIG = {
|
|
15
|
+
enabled: true,
|
|
16
|
+
captureFPS: 0.5,
|
|
17
|
+
// Every 2 seconds (only used in timer mode)
|
|
18
|
+
captureOnEvents: true,
|
|
19
|
+
// Event-driven capture (not time-based)
|
|
20
|
+
maxSessionDuration: 10 * 60 * 1000,
|
|
21
|
+
// 10 minutes (project-level configurable, clamped 1–10)
|
|
22
|
+
maxStorageSize: 50 * 1024 * 1024,
|
|
23
|
+
// 50MB
|
|
24
|
+
autoScreenTracking: true,
|
|
25
|
+
autoGestureTracking: true,
|
|
26
|
+
privacyOcclusion: true,
|
|
27
|
+
enableCompression: true,
|
|
28
|
+
inactivityThreshold: 5000,
|
|
29
|
+
// 5 seconds
|
|
30
|
+
disableInDev: false,
|
|
31
|
+
detectRageTaps: true,
|
|
32
|
+
rageTapThreshold: 3,
|
|
33
|
+
rageTapTimeWindow: 1000,
|
|
34
|
+
// 1 second
|
|
35
|
+
debug: false,
|
|
36
|
+
autoStartRecording: true,
|
|
37
|
+
collectDeviceInfo: true,
|
|
38
|
+
// Collect detailed device information
|
|
39
|
+
collectGeoLocation: true,
|
|
40
|
+
// Collect IP address and geolocation
|
|
41
|
+
postNavigationDelay: 300,
|
|
42
|
+
// 300ms - allow navigation animations to complete
|
|
43
|
+
postGestureDelay: 200,
|
|
44
|
+
// 200ms - show result of taps, not animations
|
|
45
|
+
postModalDelay: 400 // 400ms - ensure modals/alerts are fully rendered
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Event type constants */
|
|
49
|
+
const EVENT_TYPES = exports.EVENT_TYPES = {
|
|
50
|
+
GESTURE: 'gesture',
|
|
51
|
+
SCREEN_CHANGE: 'screen_change',
|
|
52
|
+
CUSTOM: 'custom',
|
|
53
|
+
APP_STATE: 'app_state',
|
|
54
|
+
FRUSTRATION: 'frustration',
|
|
55
|
+
ERROR: 'error'
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Gesture type constants */
|
|
59
|
+
const GESTURE_TYPES = exports.GESTURE_TYPES = {
|
|
60
|
+
TAP: 'tap',
|
|
61
|
+
DOUBLE_TAP: 'double_tap',
|
|
62
|
+
LONG_PRESS: 'long_press',
|
|
63
|
+
SWIPE_LEFT: 'swipe_left',
|
|
64
|
+
SWIPE_RIGHT: 'swipe_right',
|
|
65
|
+
SWIPE_UP: 'swipe_up',
|
|
66
|
+
SWIPE_DOWN: 'swipe_down',
|
|
67
|
+
PINCH: 'pinch',
|
|
68
|
+
SCROLL: 'scroll',
|
|
69
|
+
RAGE_TAP: 'rage_tap'
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Playback speeds */
|
|
73
|
+
const PLAYBACK_SPEEDS = exports.PLAYBACK_SPEEDS = [0.5, 1, 2, 4];
|
|
74
|
+
|
|
75
|
+
/** Capture settings */
|
|
76
|
+
const CAPTURE_SETTINGS = exports.CAPTURE_SETTINGS = {
|
|
77
|
+
DEFAULT_FPS: 0.5,
|
|
78
|
+
MIN_FPS: 0.1,
|
|
79
|
+
MAX_FPS: 2,
|
|
80
|
+
CAPTURE_SCALE: 0.25,
|
|
81
|
+
// 25% resolution for video segments
|
|
82
|
+
MIN_CAPTURE_DELTA_TIME: 0.5 // Minimum 0.5s between captures (rate limiting)
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Memory management settings */
|
|
86
|
+
const MEMORY_SETTINGS = exports.MEMORY_SETTINGS = {
|
|
87
|
+
/** Maximum events to keep in memory before flushing */
|
|
88
|
+
MAX_EVENTS_IN_MEMORY: 100,
|
|
89
|
+
/** Memory warning threshold in MB (flush when exceeded) */
|
|
90
|
+
MEMORY_WARNING_THRESHOLD_MB: 100,
|
|
91
|
+
/** Enable aggressive memory cleanup during low memory */
|
|
92
|
+
AGGRESSIVE_CLEANUP_ENABLED: true,
|
|
93
|
+
/** Bitmap pool size for reusing bitmaps (Android) */
|
|
94
|
+
BITMAP_POOL_SIZE: 3
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** CPU throttling settings */
|
|
98
|
+
const CPU_SETTINGS = exports.CPU_SETTINGS = {
|
|
99
|
+
/** Throttle captures when CPU usage exceeds this percentage */
|
|
100
|
+
CPU_THROTTLE_THRESHOLD: 80,
|
|
101
|
+
/** Minimum interval between captures when throttled (seconds) */
|
|
102
|
+
THROTTLED_MIN_INTERVAL: 2.0,
|
|
103
|
+
/** Skip captures when battery is below this level (0-100) */
|
|
104
|
+
LOW_BATTERY_THRESHOLD: 15,
|
|
105
|
+
/** Skip captures when device is thermally throttled */
|
|
106
|
+
THERMAL_THROTTLE_ENABLED: true,
|
|
107
|
+
/** Maximum consecutive captures before forced cooldown */
|
|
108
|
+
MAX_CONSECUTIVE_CAPTURES: 10,
|
|
109
|
+
/** Cooldown period after max consecutive captures (ms) */
|
|
110
|
+
CAPTURE_COOLDOWN_MS: 1000
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Storage management settings */
|
|
114
|
+
const STORAGE_SETTINGS = exports.STORAGE_SETTINGS = {
|
|
115
|
+
/** Maximum total storage for session data (bytes) */
|
|
116
|
+
MAX_STORAGE_SIZE: 50 * 1024 * 1024,
|
|
117
|
+
// 50MB
|
|
118
|
+
/** Storage warning threshold - start cleanup at this level */
|
|
119
|
+
STORAGE_WARNING_THRESHOLD: 0.8,
|
|
120
|
+
// 80% of max
|
|
121
|
+
/** Number of old sessions to keep */
|
|
122
|
+
MAX_SESSIONS_TO_KEEP: 5,
|
|
123
|
+
/** Auto-delete sessions older than this (hours) */
|
|
124
|
+
SESSION_EXPIRY_HOURS: 24,
|
|
125
|
+
/** Use efficient binary storage format */
|
|
126
|
+
USE_BINARY_FORMAT: true
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Network/Upload settings */
|
|
130
|
+
const UPLOAD_SETTINGS = exports.UPLOAD_SETTINGS = {
|
|
131
|
+
/** Batch upload interval (ms) */
|
|
132
|
+
BATCH_INTERVAL_MS: 30000,
|
|
133
|
+
// 30 seconds
|
|
134
|
+
/** Max retry attempts for failed uploads */
|
|
135
|
+
MAX_RETRY_ATTEMPTS: 3,
|
|
136
|
+
/** Retry delay multiplier (exponential backoff) */
|
|
137
|
+
RETRY_DELAY_MULTIPLIER: 2,
|
|
138
|
+
/** Initial retry delay (ms) */
|
|
139
|
+
INITIAL_RETRY_DELAY_MS: 1000,
|
|
140
|
+
/** Max events per upload batch */
|
|
141
|
+
MAX_EVENTS_PER_BATCH: 50,
|
|
142
|
+
/** Skip uploads when on cellular and battery is low */
|
|
143
|
+
CELLULAR_BATTERY_AWARE: true
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** Privacy constants */
|
|
147
|
+
const PRIVACY = exports.PRIVACY = {
|
|
148
|
+
OCCLUSION_COLOR: '#808080',
|
|
149
|
+
SENSITIVE_COMPONENT_TYPES: ['TextInput', 'SecureTextEntry', 'PasswordField']
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.captureError = captureError;
|
|
7
|
+
exports.cleanupErrorTracking = cleanupErrorTracking;
|
|
8
|
+
exports.getErrorCount = getErrorCount;
|
|
9
|
+
exports.resetErrorCount = resetErrorCount;
|
|
10
|
+
exports.setupErrorTracking = setupErrorTracking;
|
|
11
|
+
/**
|
|
12
|
+
* Error Tracking Module for Rejourney SDK
|
|
13
|
+
*
|
|
14
|
+
* Handles JS error capture, React Native ErrorUtils, and unhandled promise rejections.
|
|
15
|
+
* Split from autoTracking.ts for better code organization.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Type declarations for browser globals (only used in hybrid apps where DOM is available)
|
|
19
|
+
|
|
20
|
+
// Cast globalThis to work with both RN and hybrid scenarios
|
|
21
|
+
const _globalThis = globalThis;
|
|
22
|
+
|
|
23
|
+
// Original error handlers (for restoration)
|
|
24
|
+
let originalErrorHandler;
|
|
25
|
+
let originalOnError = null;
|
|
26
|
+
let originalOnUnhandledRejection = null;
|
|
27
|
+
|
|
28
|
+
// Callbacks
|
|
29
|
+
let onErrorCallback = null;
|
|
30
|
+
|
|
31
|
+
// Metrics
|
|
32
|
+
let errorCount = 0;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Setup error tracking with the given callback
|
|
36
|
+
*/
|
|
37
|
+
function setupErrorTracking(config, onError) {
|
|
38
|
+
onErrorCallback = onError;
|
|
39
|
+
errorCount = 0;
|
|
40
|
+
|
|
41
|
+
// Track React Native errors
|
|
42
|
+
if (config.trackReactNativeErrors !== false) {
|
|
43
|
+
setupReactNativeErrorHandler();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Track JavaScript errors (only works in web/debug)
|
|
47
|
+
if (config.trackJSErrors !== false && typeof _globalThis !== 'undefined') {
|
|
48
|
+
setupJSErrorHandler();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Track unhandled promise rejections
|
|
52
|
+
if (config.trackPromiseRejections !== false && typeof _globalThis !== 'undefined') {
|
|
53
|
+
setupPromiseRejectionHandler();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Cleanup error tracking and restore original handlers
|
|
59
|
+
*/
|
|
60
|
+
function cleanupErrorTracking() {
|
|
61
|
+
// Restore React Native handler
|
|
62
|
+
if (originalErrorHandler) {
|
|
63
|
+
try {
|
|
64
|
+
const ErrorUtils = _globalThis.ErrorUtils;
|
|
65
|
+
if (ErrorUtils) {
|
|
66
|
+
ErrorUtils.setGlobalHandler(originalErrorHandler);
|
|
67
|
+
}
|
|
68
|
+
} catch {
|
|
69
|
+
// Ignore
|
|
70
|
+
}
|
|
71
|
+
originalErrorHandler = undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Restore global onerror
|
|
75
|
+
if (originalOnError !== null) {
|
|
76
|
+
_globalThis.onerror = originalOnError;
|
|
77
|
+
originalOnError = null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Remove promise rejection handler
|
|
81
|
+
if (originalOnUnhandledRejection && typeof _globalThis.removeEventListener !== 'undefined') {
|
|
82
|
+
_globalThis.removeEventListener('unhandledrejection', originalOnUnhandledRejection);
|
|
83
|
+
originalOnUnhandledRejection = null;
|
|
84
|
+
}
|
|
85
|
+
onErrorCallback = null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get current error count
|
|
90
|
+
*/
|
|
91
|
+
function getErrorCount() {
|
|
92
|
+
return errorCount;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Reset error count
|
|
97
|
+
*/
|
|
98
|
+
function resetErrorCount() {
|
|
99
|
+
errorCount = 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Manually capture an error
|
|
104
|
+
*/
|
|
105
|
+
function captureError(message, stack, name) {
|
|
106
|
+
trackError({
|
|
107
|
+
type: 'error',
|
|
108
|
+
timestamp: Date.now(),
|
|
109
|
+
message,
|
|
110
|
+
stack,
|
|
111
|
+
name: name || 'Error'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Track an error internally
|
|
117
|
+
*/
|
|
118
|
+
function trackError(error) {
|
|
119
|
+
errorCount++;
|
|
120
|
+
if (onErrorCallback) {
|
|
121
|
+
onErrorCallback(error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Setup React Native ErrorUtils handler
|
|
127
|
+
*/
|
|
128
|
+
function setupReactNativeErrorHandler() {
|
|
129
|
+
try {
|
|
130
|
+
const ErrorUtils = _globalThis.ErrorUtils;
|
|
131
|
+
if (!ErrorUtils) return;
|
|
132
|
+
|
|
133
|
+
// Store original handler
|
|
134
|
+
originalErrorHandler = ErrorUtils.getGlobalHandler();
|
|
135
|
+
|
|
136
|
+
// Set new handler
|
|
137
|
+
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
138
|
+
trackError({
|
|
139
|
+
type: 'error',
|
|
140
|
+
timestamp: Date.now(),
|
|
141
|
+
message: error.message || String(error),
|
|
142
|
+
stack: error.stack,
|
|
143
|
+
name: error.name || 'Error'
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Call original handler
|
|
147
|
+
if (originalErrorHandler) {
|
|
148
|
+
originalErrorHandler(error, isFatal);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
} catch {
|
|
152
|
+
// ErrorUtils not available
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Setup global JS error handler
|
|
158
|
+
*/
|
|
159
|
+
function setupJSErrorHandler() {
|
|
160
|
+
if (typeof _globalThis.onerror !== 'undefined') {
|
|
161
|
+
originalOnError = _globalThis.onerror;
|
|
162
|
+
_globalThis.onerror = (message, source, lineno, colno, error) => {
|
|
163
|
+
trackError({
|
|
164
|
+
type: 'error',
|
|
165
|
+
timestamp: Date.now(),
|
|
166
|
+
message: typeof message === 'string' ? message : 'Unknown error',
|
|
167
|
+
stack: error?.stack || `${source}:${lineno}:${colno}`,
|
|
168
|
+
name: error?.name || 'Error'
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Call original handler
|
|
172
|
+
if (originalOnError) {
|
|
173
|
+
return originalOnError(message, source, lineno, colno, error);
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Setup unhandled promise rejection handler
|
|
182
|
+
*/
|
|
183
|
+
function setupPromiseRejectionHandler() {
|
|
184
|
+
if (typeof _globalThis.addEventListener !== 'undefined') {
|
|
185
|
+
const handler = event => {
|
|
186
|
+
const reason = event.reason;
|
|
187
|
+
trackError({
|
|
188
|
+
type: 'error',
|
|
189
|
+
timestamp: Date.now(),
|
|
190
|
+
message: reason?.message || String(reason) || 'Unhandled Promise Rejection',
|
|
191
|
+
stack: reason?.stack,
|
|
192
|
+
name: reason?.name || 'UnhandledRejection'
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
originalOnUnhandledRejection = handler;
|
|
196
|
+
_globalThis.addEventListener('unhandledrejection', handler);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=errorTracking.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _constants = require("./constants");
|
|
7
|
+
Object.keys(_constants).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _constants[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _utils = require("./utils");
|
|
18
|
+
Object.keys(_utils).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _utils[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _autoTracking = require("./autoTracking");
|
|
29
|
+
Object.keys(_autoTracking).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _autoTracking[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _autoTracking[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _networkInterceptor = require("./networkInterceptor");
|
|
40
|
+
Object.keys(_networkInterceptor).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _networkInterceptor[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _networkInterceptor[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addScreenVisited = addScreenVisited;
|
|
7
|
+
exports.createEmptyMetrics = createEmptyMetrics;
|
|
8
|
+
exports.getSessionMetrics = getSessionMetrics;
|
|
9
|
+
exports.incrementErrorCount = incrementErrorCount;
|
|
10
|
+
exports.incrementNavigationCount = incrementNavigationCount;
|
|
11
|
+
exports.incrementRageTapCount = incrementRageTapCount;
|
|
12
|
+
exports.incrementScrollCount = incrementScrollCount;
|
|
13
|
+
exports.incrementTouchCount = incrementTouchCount;
|
|
14
|
+
exports.initMetrics = initMetrics;
|
|
15
|
+
exports.resetMetrics = resetMetrics;
|
|
16
|
+
exports.setMaxSessionDurationMinutes = setMaxSessionDurationMinutes;
|
|
17
|
+
exports.trackAPIMetrics = trackAPIMetrics;
|
|
18
|
+
/**
|
|
19
|
+
* Session Metrics Module for Rejourney SDK
|
|
20
|
+
*
|
|
21
|
+
* Tracks and calculates session metrics including interaction scores,
|
|
22
|
+
* API performance, and user engagement metrics.
|
|
23
|
+
* Split from autoTracking.ts for better code organization.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Session metrics structure
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
// Metrics state
|
|
31
|
+
let metrics = createEmptyMetrics();
|
|
32
|
+
let sessionStartTime = 0;
|
|
33
|
+
let maxSessionDurationMs = 10 * 60 * 1000; // 10 minutes default
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create empty metrics object
|
|
37
|
+
*/
|
|
38
|
+
function createEmptyMetrics() {
|
|
39
|
+
return {
|
|
40
|
+
totalEvents: 0,
|
|
41
|
+
touchCount: 0,
|
|
42
|
+
scrollCount: 0,
|
|
43
|
+
gestureCount: 0,
|
|
44
|
+
inputCount: 0,
|
|
45
|
+
navigationCount: 0,
|
|
46
|
+
errorCount: 0,
|
|
47
|
+
rageTapCount: 0,
|
|
48
|
+
apiSuccessCount: 0,
|
|
49
|
+
apiErrorCount: 0,
|
|
50
|
+
apiTotalCount: 0,
|
|
51
|
+
netTotalDurationMs: 0,
|
|
52
|
+
netTotalBytes: 0,
|
|
53
|
+
screensVisited: [],
|
|
54
|
+
uniqueScreensCount: 0,
|
|
55
|
+
interactionScore: 100,
|
|
56
|
+
explorationScore: 100,
|
|
57
|
+
uxScore: 100
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Reset all metrics
|
|
63
|
+
*/
|
|
64
|
+
function resetMetrics() {
|
|
65
|
+
metrics = createEmptyMetrics();
|
|
66
|
+
sessionStartTime = 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Initialize metrics for new session
|
|
71
|
+
*/
|
|
72
|
+
function initMetrics() {
|
|
73
|
+
metrics = createEmptyMetrics();
|
|
74
|
+
sessionStartTime = Date.now();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get current session metrics with calculated scores
|
|
79
|
+
*/
|
|
80
|
+
function getSessionMetrics() {
|
|
81
|
+
// Calculate duration, clamped to max session duration
|
|
82
|
+
const rawDuration = Date.now() - sessionStartTime;
|
|
83
|
+
const durationMs = Math.min(rawDuration, maxSessionDurationMs);
|
|
84
|
+
|
|
85
|
+
// Calculate scores
|
|
86
|
+
const interactionScore = calculateInteractionScore(durationMs);
|
|
87
|
+
const explorationScore = calculateExplorationScore();
|
|
88
|
+
const uxScore = calculateUXScore();
|
|
89
|
+
return {
|
|
90
|
+
...metrics,
|
|
91
|
+
interactionScore,
|
|
92
|
+
explorationScore,
|
|
93
|
+
uxScore
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Set max session duration (in minutes)
|
|
99
|
+
*/
|
|
100
|
+
function setMaxSessionDurationMinutes(minutes) {
|
|
101
|
+
if (minutes !== undefined && minutes > 0) {
|
|
102
|
+
// Clamp to 1-10 minutes
|
|
103
|
+
const clampedMinutes = Math.max(1, Math.min(10, minutes));
|
|
104
|
+
maxSessionDurationMs = clampedMinutes * 60 * 1000;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ==================== Metric Increment Methods ====================
|
|
109
|
+
|
|
110
|
+
function incrementTouchCount() {
|
|
111
|
+
metrics.touchCount++;
|
|
112
|
+
metrics.totalEvents++;
|
|
113
|
+
}
|
|
114
|
+
function incrementScrollCount() {
|
|
115
|
+
metrics.scrollCount++;
|
|
116
|
+
metrics.totalEvents++;
|
|
117
|
+
}
|
|
118
|
+
function incrementNavigationCount() {
|
|
119
|
+
metrics.navigationCount++;
|
|
120
|
+
metrics.totalEvents++;
|
|
121
|
+
}
|
|
122
|
+
function incrementRageTapCount() {
|
|
123
|
+
metrics.rageTapCount++;
|
|
124
|
+
}
|
|
125
|
+
function incrementErrorCount() {
|
|
126
|
+
metrics.errorCount++;
|
|
127
|
+
metrics.totalEvents++;
|
|
128
|
+
}
|
|
129
|
+
function addScreenVisited(screenName) {
|
|
130
|
+
metrics.screensVisited.push(screenName);
|
|
131
|
+
metrics.uniqueScreensCount = new Set(metrics.screensVisited).size;
|
|
132
|
+
}
|
|
133
|
+
function trackAPIMetrics(success, durationMs = 0, responseBytes = 0) {
|
|
134
|
+
metrics.apiTotalCount++;
|
|
135
|
+
if (durationMs > 0) {
|
|
136
|
+
metrics.netTotalDurationMs += durationMs;
|
|
137
|
+
}
|
|
138
|
+
if (responseBytes > 0) {
|
|
139
|
+
metrics.netTotalBytes += responseBytes;
|
|
140
|
+
}
|
|
141
|
+
if (success) {
|
|
142
|
+
metrics.apiSuccessCount++;
|
|
143
|
+
} else {
|
|
144
|
+
metrics.apiErrorCount++;
|
|
145
|
+
metrics.errorCount++;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ==================== Score Calculations ====================
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Calculate interaction score based on engagement with app
|
|
153
|
+
* Higher = more engaged (more interactions per minute)
|
|
154
|
+
*/
|
|
155
|
+
function calculateInteractionScore(durationMs) {
|
|
156
|
+
if (durationMs <= 0) return 100;
|
|
157
|
+
const durationMinutes = durationMs / 60000;
|
|
158
|
+
const interactionsPerMinute = metrics.touchCount / Math.max(0.5, durationMinutes);
|
|
159
|
+
|
|
160
|
+
// Ideal: 10-30 interactions per minute
|
|
161
|
+
// Low (< 5): user passive/confused
|
|
162
|
+
// Very high (> 60): rage tapping
|
|
163
|
+
if (interactionsPerMinute < 2) return 20;
|
|
164
|
+
if (interactionsPerMinute < 5) return 50;
|
|
165
|
+
if (interactionsPerMinute < 10) return 70;
|
|
166
|
+
if (interactionsPerMinute <= 30) return 100;
|
|
167
|
+
if (interactionsPerMinute <= 60) return 80;
|
|
168
|
+
return 50; // Very high might indicate frustration
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Calculate exploration score based on screens visited
|
|
173
|
+
* Higher = user explored more of the app
|
|
174
|
+
*/
|
|
175
|
+
function calculateExplorationScore() {
|
|
176
|
+
const uniqueScreens = metrics.uniqueScreensCount;
|
|
177
|
+
|
|
178
|
+
// More unique screens = better exploration
|
|
179
|
+
if (uniqueScreens >= 10) return 100;
|
|
180
|
+
if (uniqueScreens >= 7) return 90;
|
|
181
|
+
if (uniqueScreens >= 5) return 80;
|
|
182
|
+
if (uniqueScreens >= 3) return 60;
|
|
183
|
+
if (uniqueScreens >= 2) return 40;
|
|
184
|
+
return 20; // Single screen visit
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Calculate UX score based on errors and frustration
|
|
189
|
+
* Higher = better experience (fewer issues)
|
|
190
|
+
*/
|
|
191
|
+
function calculateUXScore() {
|
|
192
|
+
let score = 100;
|
|
193
|
+
|
|
194
|
+
// Deduct for errors
|
|
195
|
+
score -= metrics.errorCount * 10;
|
|
196
|
+
|
|
197
|
+
// Deduct heavily for rage taps
|
|
198
|
+
score -= metrics.rageTapCount * 20;
|
|
199
|
+
|
|
200
|
+
// Deduct for API errors (less severe)
|
|
201
|
+
score -= metrics.apiErrorCount * 5;
|
|
202
|
+
return Math.max(0, Math.min(100, score));
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=metricsTracking.js.map
|