@rejourneyco/react-native 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- 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 +860 -0
- package/android/src/main/java/com/rejourney/engine/DeviceRegistrar.kt +290 -0
- package/android/src/main/java/com/rejourney/engine/DiagnosticLog.kt +385 -0
- package/android/src/main/java/com/rejourney/engine/RejourneyImpl.kt +512 -0
- package/android/src/main/java/com/rejourney/platform/OEMDetector.kt +173 -0
- package/android/src/main/java/com/rejourney/platform/PerfTiming.kt +384 -0
- package/android/src/main/java/com/rejourney/platform/SessionLifecycleService.kt +160 -0
- package/android/src/main/java/com/rejourney/platform/Telemetry.kt +301 -0
- package/android/src/main/java/com/rejourney/platform/WindowUtils.kt +100 -0
- package/android/src/main/java/com/rejourney/recording/AnrSentinel.kt +129 -0
- package/android/src/main/java/com/rejourney/recording/EventBuffer.kt +330 -0
- package/android/src/main/java/com/rejourney/recording/InteractionRecorder.kt +519 -0
- package/android/src/main/java/com/rejourney/recording/ReplayOrchestrator.kt +740 -0
- package/android/src/main/java/com/rejourney/recording/SegmentDispatcher.kt +559 -0
- package/android/src/main/java/com/rejourney/recording/StabilityMonitor.kt +238 -0
- package/android/src/main/java/com/rejourney/recording/TelemetryPipeline.kt +633 -0
- package/android/src/main/java/com/rejourney/recording/ViewHierarchyScanner.kt +232 -0
- package/android/src/main/java/com/rejourney/recording/VisualCapture.kt +474 -0
- package/android/src/main/java/com/rejourney/utility/DataCompression.kt +63 -0
- package/android/src/main/java/com/rejourney/utility/ImageBlur.kt +412 -0
- package/android/src/main/java/com/rejourney/utility/ViewIdentifier.kt +169 -0
- package/android/src/newarch/java/com/rejourney/RejourneyModule.kt +232 -0
- package/android/src/newarch/java/com/rejourney/RejourneyPackage.kt +40 -0
- package/android/src/oldarch/java/com/rejourney/RejourneyModule.kt +268 -0
- package/android/src/oldarch/java/com/rejourney/RejourneyPackage.kt +23 -0
- package/ios/Engine/DeviceRegistrar.swift +288 -0
- package/ios/Engine/DiagnosticLog.swift +387 -0
- package/ios/Engine/RejourneyImpl.swift +719 -0
- package/ios/Recording/AnrSentinel.swift +142 -0
- package/ios/Recording/EventBuffer.swift +326 -0
- package/ios/Recording/InteractionRecorder.swift +428 -0
- package/ios/Recording/ReplayOrchestrator.swift +624 -0
- package/ios/Recording/SegmentDispatcher.swift +492 -0
- package/ios/Recording/StabilityMonitor.swift +223 -0
- package/ios/Recording/TelemetryPipeline.swift +547 -0
- package/ios/Recording/ViewHierarchyScanner.swift +156 -0
- package/ios/Recording/VisualCapture.swift +675 -0
- package/ios/Rejourney.h +38 -0
- package/ios/Rejourney.mm +375 -0
- package/ios/Utility/DataCompression.swift +55 -0
- package/ios/Utility/ImageBlur.swift +89 -0
- package/ios/Utility/RuntimeMethodSwap.swift +41 -0
- package/ios/Utility/ViewIdentifier.swift +37 -0
- package/lib/commonjs/NativeRejourney.js +40 -0
- package/lib/commonjs/components/Mask.js +88 -0
- package/lib/commonjs/index.js +1443 -0
- package/lib/commonjs/sdk/autoTracking.js +1087 -0
- package/lib/commonjs/sdk/constants.js +166 -0
- package/lib/commonjs/sdk/errorTracking.js +187 -0
- package/lib/commonjs/sdk/index.js +50 -0
- package/lib/commonjs/sdk/metricsTracking.js +205 -0
- package/lib/commonjs/sdk/navigation.js +128 -0
- package/lib/commonjs/sdk/networkInterceptor.js +375 -0
- package/lib/commonjs/sdk/utils.js +433 -0
- package/lib/commonjs/sdk/version.js +13 -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 +83 -0
- package/lib/module/index.js +1341 -0
- package/lib/module/sdk/autoTracking.js +1059 -0
- package/lib/module/sdk/constants.js +154 -0
- package/lib/module/sdk/errorTracking.js +177 -0
- package/lib/module/sdk/index.js +26 -0
- package/lib/module/sdk/metricsTracking.js +187 -0
- package/lib/module/sdk/navigation.js +120 -0
- package/lib/module/sdk/networkInterceptor.js +364 -0
- package/lib/module/sdk/utils.js +412 -0
- package/lib/module/sdk/version.js +7 -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 +160 -0
- package/lib/typescript/components/Mask.d.ts +54 -0
- package/lib/typescript/index.d.ts +117 -0
- package/lib/typescript/sdk/autoTracking.d.ts +226 -0
- package/lib/typescript/sdk/constants.d.ts +138 -0
- package/lib/typescript/sdk/errorTracking.d.ts +47 -0
- package/lib/typescript/sdk/index.d.ts +24 -0
- package/lib/typescript/sdk/metricsTracking.d.ts +75 -0
- package/lib/typescript/sdk/navigation.d.ts +48 -0
- package/lib/typescript/sdk/networkInterceptor.d.ts +62 -0
- package/lib/typescript/sdk/utils.d.ts +193 -0
- package/lib/typescript/sdk/version.d.ts +6 -0
- package/lib/typescript/types/index.d.ts +618 -0
- package/package.json +122 -0
- package/rejourney.podspec +23 -0
- package/src/NativeRejourney.ts +185 -0
- package/src/components/Mask.tsx +93 -0
- package/src/index.ts +1555 -0
- package/src/sdk/autoTracking.ts +1245 -0
- package/src/sdk/constants.ts +155 -0
- package/src/sdk/errorTracking.ts +231 -0
- package/src/sdk/index.ts +25 -0
- package/src/sdk/metricsTracking.ts +227 -0
- package/src/sdk/navigation.ts +152 -0
- package/src/sdk/networkInterceptor.ts +423 -0
- package/src/sdk/utils.ts +442 -0
- package/src/sdk/version.ts +6 -0
- package/src/types/expo-router.d.ts +7 -0
- package/src/types/index.ts +709 -0
package/src/sdk/utils.ts
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Rejourney
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Rejourney Utility Functions
|
|
19
|
+
*
|
|
20
|
+
* IMPORTANT: This file uses lazy loading for react-native imports to avoid
|
|
21
|
+
* "PlatformConstants could not be found" errors on RN 0.81+.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { TouchPoint, GestureType } from '../types';
|
|
25
|
+
|
|
26
|
+
// Lazy-loaded Platform module
|
|
27
|
+
let _Platform: typeof import('react-native').Platform | null = null;
|
|
28
|
+
|
|
29
|
+
function getPlatform(): typeof import('react-native').Platform | null {
|
|
30
|
+
if (_Platform) return _Platform;
|
|
31
|
+
try {
|
|
32
|
+
const RN = require('react-native');
|
|
33
|
+
_Platform = RN.Platform;
|
|
34
|
+
return _Platform;
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generate a unique ID
|
|
42
|
+
*/
|
|
43
|
+
export function generateId(): string {
|
|
44
|
+
const timestamp = Date.now().toString(36);
|
|
45
|
+
const randomPart = Math.random().toString(36).substring(2, 9);
|
|
46
|
+
return `${timestamp}-${randomPart}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Generate a session ID
|
|
51
|
+
*/
|
|
52
|
+
export function generateSessionId(): string {
|
|
53
|
+
const date = new Date();
|
|
54
|
+
const dateStr = date.toISOString().split('T')[0]?.replace(/-/g, '') ?? '';
|
|
55
|
+
const timeStr = date.toTimeString().split(' ')[0]?.replace(/:/g, '') ?? '';
|
|
56
|
+
const random = Math.random().toString(36).substring(2, 6);
|
|
57
|
+
return `session_${dateStr}_${timeStr}_${random}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get current timestamp in milliseconds
|
|
62
|
+
*/
|
|
63
|
+
export function now(): number {
|
|
64
|
+
return Date.now();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Check if running in development mode
|
|
69
|
+
*/
|
|
70
|
+
export function isDevelopment(): boolean {
|
|
71
|
+
return __DEV__;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check platform
|
|
76
|
+
*/
|
|
77
|
+
export function isIOS(): boolean {
|
|
78
|
+
const platform = getPlatform();
|
|
79
|
+
return platform?.OS === 'ios';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function isAndroid(): boolean {
|
|
83
|
+
const platform = getPlatform();
|
|
84
|
+
return platform?.OS === 'android';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Calculate distance between two points
|
|
89
|
+
*/
|
|
90
|
+
export function distance(p1: TouchPoint, p2: TouchPoint): number {
|
|
91
|
+
const dx = p2.x - p1.x;
|
|
92
|
+
const dy = p2.y - p1.y;
|
|
93
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Calculate velocity between two points
|
|
98
|
+
*/
|
|
99
|
+
export function velocity(p1: TouchPoint, p2: TouchPoint): { x: number; y: number } {
|
|
100
|
+
const dt = p2.timestamp - p1.timestamp;
|
|
101
|
+
if (dt === 0) return { x: 0, y: 0 };
|
|
102
|
+
return {
|
|
103
|
+
x: (p2.x - p1.x) / dt,
|
|
104
|
+
y: (p2.y - p1.y) / dt,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Determine gesture type from touch points
|
|
110
|
+
*/
|
|
111
|
+
export function classifyGesture(
|
|
112
|
+
touches: TouchPoint[],
|
|
113
|
+
duration: number
|
|
114
|
+
): GestureType {
|
|
115
|
+
if (touches.length < 2) {
|
|
116
|
+
if (duration > 500) return 'long_press';
|
|
117
|
+
return 'tap';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const first = touches[0];
|
|
121
|
+
const last = touches[touches.length - 1];
|
|
122
|
+
|
|
123
|
+
if (!first || !last) return 'tap';
|
|
124
|
+
|
|
125
|
+
const dx = last.x - first.x;
|
|
126
|
+
const dy = last.y - first.y;
|
|
127
|
+
const dist = distance(first, last);
|
|
128
|
+
|
|
129
|
+
// If very little movement, it's a tap
|
|
130
|
+
if (dist < 10) {
|
|
131
|
+
if (duration > 500) return 'long_press';
|
|
132
|
+
return 'tap';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Determine swipe direction
|
|
136
|
+
const absX = Math.abs(dx);
|
|
137
|
+
const absY = Math.abs(dy);
|
|
138
|
+
|
|
139
|
+
if (absX > absY) {
|
|
140
|
+
return dx > 0 ? 'swipe_right' : 'swipe_left';
|
|
141
|
+
} else {
|
|
142
|
+
return dy > 0 ? 'swipe_down' : 'swipe_up';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Throttle function execution
|
|
148
|
+
*/
|
|
149
|
+
export function throttle<T extends (...args: any[]) => any>(
|
|
150
|
+
fn: T,
|
|
151
|
+
delay: number
|
|
152
|
+
): (...args: Parameters<T>) => void {
|
|
153
|
+
let lastCall = 0;
|
|
154
|
+
return (...args: Parameters<T>) => {
|
|
155
|
+
const currentTime = now();
|
|
156
|
+
if (currentTime - lastCall >= delay) {
|
|
157
|
+
lastCall = currentTime;
|
|
158
|
+
fn(...args);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Debounce function execution
|
|
165
|
+
*/
|
|
166
|
+
export function debounce<T extends (...args: any[]) => any>(
|
|
167
|
+
fn: T,
|
|
168
|
+
delay: number
|
|
169
|
+
): (...args: Parameters<T>) => void {
|
|
170
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
171
|
+
return (...args: Parameters<T>) => {
|
|
172
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
173
|
+
timeoutId = setTimeout(() => fn(...args), delay);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Format bytes to human readable string
|
|
179
|
+
*/
|
|
180
|
+
export function formatBytes(bytes: number): string {
|
|
181
|
+
if (bytes === 0) return '0 Bytes';
|
|
182
|
+
const k = 1024;
|
|
183
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
184
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
185
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Format duration to human readable string
|
|
190
|
+
*/
|
|
191
|
+
export function formatDuration(ms: number): string {
|
|
192
|
+
const seconds = Math.floor(ms / 1000);
|
|
193
|
+
const minutes = Math.floor(seconds / 60);
|
|
194
|
+
const hours = Math.floor(minutes / 60);
|
|
195
|
+
|
|
196
|
+
if (hours > 0) {
|
|
197
|
+
return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
|
|
198
|
+
}
|
|
199
|
+
if (minutes > 0) {
|
|
200
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
201
|
+
}
|
|
202
|
+
return `${seconds}s`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Format timestamp to readable time
|
|
207
|
+
*/
|
|
208
|
+
export function formatTime(ms: number): string {
|
|
209
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
210
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
211
|
+
const seconds = totalSeconds % 60;
|
|
212
|
+
return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Create a simple hash of a string
|
|
217
|
+
*/
|
|
218
|
+
export function simpleHash(str: string): string {
|
|
219
|
+
let hash = 0;
|
|
220
|
+
for (let i = 0; i < str.length; i++) {
|
|
221
|
+
const char = str.charCodeAt(i);
|
|
222
|
+
hash = ((hash << 5) - hash) + char;
|
|
223
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
224
|
+
}
|
|
225
|
+
return Math.abs(hash).toString(36);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Log levels for controlling verbosity.
|
|
230
|
+
*
|
|
231
|
+
* Default behavior minimizes log pollution for integrators:
|
|
232
|
+
* - Release/Production: SILENT (no logs)
|
|
233
|
+
* - Development: ERROR (only critical issues)
|
|
234
|
+
*/
|
|
235
|
+
export enum LogLevel {
|
|
236
|
+
DEBUG = 0,
|
|
237
|
+
INFO = 1,
|
|
238
|
+
WARNING = 2,
|
|
239
|
+
ERROR = 3,
|
|
240
|
+
SILENT = 4,
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Logger with production-aware log levels.
|
|
245
|
+
*
|
|
246
|
+
* Designed to minimize log pollution for integrators:
|
|
247
|
+
* - Production/Release: SILENT (completely silent, no logs)
|
|
248
|
+
* - Development/Debug: ERROR (only critical errors)
|
|
249
|
+
*
|
|
250
|
+
* Only essential lifecycle logs (init success, session start/end) bypass
|
|
251
|
+
* these levels via dedicated methods.
|
|
252
|
+
*/
|
|
253
|
+
class Logger {
|
|
254
|
+
private prefix = '[Rejourney]';
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Minimum log level to display.
|
|
259
|
+
*
|
|
260
|
+
* Defaults to SILENT to avoid polluting integrator's console.
|
|
261
|
+
* SDK developers can adjust this for internal debugging.
|
|
262
|
+
*
|
|
263
|
+
* Note: In production builds, this should remain SILENT.
|
|
264
|
+
* The native layers handle build-type detection automatically.
|
|
265
|
+
*/
|
|
266
|
+
private minimumLogLevel: LogLevel = typeof __DEV__ !== 'undefined' && __DEV__
|
|
267
|
+
? LogLevel.ERROR
|
|
268
|
+
: LogLevel.SILENT;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Set the minimum log level. Logs below this level will be suppressed.
|
|
272
|
+
* SDK developers can use this for internal debugging.
|
|
273
|
+
*/
|
|
274
|
+
setLogLevel(level: LogLevel): void {
|
|
275
|
+
this.minimumLogLevel = level;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
setDebugMode(enabled: boolean): void {
|
|
279
|
+
this.minimumLogLevel = enabled
|
|
280
|
+
? LogLevel.DEBUG
|
|
281
|
+
: typeof __DEV__ !== 'undefined' && __DEV__
|
|
282
|
+
? LogLevel.ERROR
|
|
283
|
+
: LogLevel.SILENT;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Log a debug message - SDK internal use only */
|
|
287
|
+
debug(...args: any[]): void {
|
|
288
|
+
if (this.minimumLogLevel <= LogLevel.DEBUG) {
|
|
289
|
+
console.log(this.prefix, ...args);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Log an info message - SDK internal use only */
|
|
294
|
+
info(...args: any[]): void {
|
|
295
|
+
if (this.minimumLogLevel <= LogLevel.INFO) {
|
|
296
|
+
console.info(this.prefix, ...args);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Log a warning message */
|
|
301
|
+
warn(...args: any[]): void {
|
|
302
|
+
if (this.minimumLogLevel <= LogLevel.WARNING) {
|
|
303
|
+
if (this.minimumLogLevel <= LogLevel.DEBUG) {
|
|
304
|
+
// Explicit Debug Mode: Show YellowBox
|
|
305
|
+
console.warn(this.prefix, ...args);
|
|
306
|
+
} else {
|
|
307
|
+
// Default Dev Mode: Log to console only, avoid YellowBox
|
|
308
|
+
console.log(this.prefix, '[WARN]', ...args);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Log an error message */
|
|
314
|
+
error(...args: any[]): void {
|
|
315
|
+
if (this.minimumLogLevel <= LogLevel.ERROR) {
|
|
316
|
+
if (this.minimumLogLevel <= LogLevel.DEBUG) {
|
|
317
|
+
// Explicit Debug Mode: Show RedBox
|
|
318
|
+
console.error(this.prefix, ...args);
|
|
319
|
+
} else {
|
|
320
|
+
// Default Dev Mode: Log to console only, avoid RedBox
|
|
321
|
+
console.log(this.prefix, '[ERROR]', ...args);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
notice(...args: any[]): void {
|
|
327
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
328
|
+
console.info(this.prefix, ...args);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Log SDK initialization success.
|
|
334
|
+
* Only shown in development builds - this is the minimal "SDK started" log.
|
|
335
|
+
*/
|
|
336
|
+
logInitSuccess(version: string): void {
|
|
337
|
+
this.notice(`✓ SDK initialized (v${version})`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Log SDK initialization failure.
|
|
342
|
+
* Always shown - this is a critical error.
|
|
343
|
+
*/
|
|
344
|
+
logInitFailure(reason: string): void {
|
|
345
|
+
console.error(this.prefix, `✗ Initialization failed: ${reason}`);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Log session start.
|
|
350
|
+
* Only shown in development builds.
|
|
351
|
+
*/
|
|
352
|
+
logSessionStart(sessionId: string): void {
|
|
353
|
+
this.notice(`Session started: ${sessionId}`);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Log session end.
|
|
358
|
+
* Only shown in development builds.
|
|
359
|
+
*/
|
|
360
|
+
logSessionEnd(sessionId: string): void {
|
|
361
|
+
this.notice(`Session ended: ${sessionId}`);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
logObservabilityStart(): void {
|
|
365
|
+
this.notice('💧 Starting Rejourney observability');
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
logRecordingStart(): void {
|
|
369
|
+
this.notice('Starting recording');
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
logRecordingRemoteDisabled(): void {
|
|
373
|
+
this.notice('Recording disabled by remote toggle');
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
logInvalidProjectKey(): void {
|
|
377
|
+
this.notice('Invalid project API key');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
logPackageMismatch(): void {
|
|
381
|
+
this.notice('Bundle ID / package name mismatch');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Log network request details
|
|
386
|
+
*/
|
|
387
|
+
logNetworkRequest(request: { method?: string; url?: string; statusCode?: number; duration?: number; error?: string }): void {
|
|
388
|
+
const statusIcon = request.error || (request.statusCode && request.statusCode >= 400) ? '🔴' : '🟢';
|
|
389
|
+
const method = request.method || 'GET';
|
|
390
|
+
// Shorten URL to just path if possible
|
|
391
|
+
let url = request.url || '';
|
|
392
|
+
try {
|
|
393
|
+
if (url.startsWith('http')) {
|
|
394
|
+
const urlObj = new URL(url);
|
|
395
|
+
url = urlObj.pathname;
|
|
396
|
+
}
|
|
397
|
+
} catch {
|
|
398
|
+
// Keep full URL if parsing fails
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const duration = request.duration ? `(${Math.round(request.duration)}ms)` : '';
|
|
402
|
+
const status = request.statusCode ? `${request.statusCode}` : 'ERR';
|
|
403
|
+
|
|
404
|
+
this.notice(`${statusIcon} [NET] ${status} ${method} ${url} ${duration} ${request.error ? `Error: ${request.error}` : ''}`);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Log frustration event (rage taps, etc)
|
|
409
|
+
*/
|
|
410
|
+
logFrustration(kind: string): void {
|
|
411
|
+
this.notice(`🤬 Frustration detected: ${kind}`);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Log error captured by SDK
|
|
416
|
+
*/
|
|
417
|
+
logError(message: string): void {
|
|
418
|
+
this.notice(`X Error captured: ${message}`);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Log lifecycle event (Background/Foreground)
|
|
423
|
+
* Visible in development builds.
|
|
424
|
+
*/
|
|
425
|
+
logLifecycleEvent(event: string): void {
|
|
426
|
+
this.notice(`🔄 Lifecycle: ${event}`);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Log upload statistics
|
|
431
|
+
*/
|
|
432
|
+
logUploadStats(metrics: { uploadSuccessCount: number; uploadFailureCount: number; totalBytesUploaded: number }): void {
|
|
433
|
+
const success = metrics.uploadSuccessCount;
|
|
434
|
+
const failed = metrics.uploadFailureCount;
|
|
435
|
+
const bytes = formatBytes(metrics.totalBytesUploaded);
|
|
436
|
+
|
|
437
|
+
// Always show in dev mode for reassurance, even if 0
|
|
438
|
+
this.notice(`📡 Upload Stats: ${success} success, ${failed} failed (${bytes} uploaded)`);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export const logger = new Logger();
|