@rejourneyco/react-native 1.0.1 → 1.0.2

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.
Files changed (43) hide show
  1. package/android/src/main/java/com/rejourney/RejourneyModuleImpl.kt +35 -29
  2. package/android/src/newarch/java/com/rejourney/RejourneyModule.kt +7 -0
  3. package/android/src/oldarch/java/com/rejourney/RejourneyModule.kt +9 -0
  4. package/ios/Capture/RJCaptureEngine.m +3 -34
  5. package/ios/Capture/RJVideoEncoder.m +0 -26
  6. package/ios/Core/Rejourney.mm +32 -95
  7. package/ios/Utils/RJPerfTiming.m +0 -5
  8. package/ios/Utils/RJWindowUtils.m +0 -1
  9. package/lib/commonjs/components/Mask.js +1 -6
  10. package/lib/commonjs/index.js +4 -87
  11. package/lib/commonjs/sdk/autoTracking.js +39 -310
  12. package/lib/commonjs/sdk/constants.js +2 -13
  13. package/lib/commonjs/sdk/errorTracking.js +1 -29
  14. package/lib/commonjs/sdk/metricsTracking.js +3 -24
  15. package/lib/commonjs/sdk/navigation.js +3 -42
  16. package/lib/commonjs/sdk/networkInterceptor.js +7 -49
  17. package/lib/commonjs/sdk/utils.js +0 -5
  18. package/lib/module/components/Mask.js +1 -6
  19. package/lib/module/index.js +3 -91
  20. package/lib/module/sdk/autoTracking.js +39 -311
  21. package/lib/module/sdk/constants.js +2 -13
  22. package/lib/module/sdk/errorTracking.js +1 -29
  23. package/lib/module/sdk/index.js +0 -2
  24. package/lib/module/sdk/metricsTracking.js +3 -24
  25. package/lib/module/sdk/navigation.js +3 -42
  26. package/lib/module/sdk/networkInterceptor.js +7 -49
  27. package/lib/module/sdk/utils.js +0 -5
  28. package/lib/typescript/NativeRejourney.d.ts +1 -0
  29. package/lib/typescript/sdk/autoTracking.d.ts +4 -4
  30. package/lib/typescript/types/index.d.ts +0 -1
  31. package/package.json +2 -8
  32. package/src/NativeRejourney.ts +2 -0
  33. package/src/components/Mask.tsx +0 -3
  34. package/src/index.ts +3 -73
  35. package/src/sdk/autoTracking.ts +51 -282
  36. package/src/sdk/constants.ts +13 -13
  37. package/src/sdk/errorTracking.ts +1 -17
  38. package/src/sdk/index.ts +0 -2
  39. package/src/sdk/metricsTracking.ts +5 -33
  40. package/src/sdk/navigation.ts +8 -29
  41. package/src/sdk/networkInterceptor.ts +9 -33
  42. package/src/sdk/utils.ts +0 -5
  43. package/src/types/index.ts +0 -29
package/src/index.ts CHANGED
@@ -79,13 +79,11 @@ function getReactNative(): typeof import('react-native') | null {
79
79
  }
80
80
  }
81
81
 
82
- // Lazy-loaded logger
83
82
  let _logger: typeof import('./sdk/utils').logger | null = null;
84
83
 
85
84
  function getLogger() {
86
85
  if (_logger) return _logger;
87
86
  if (_sdkDisabled) {
88
- // Return a no-op logger if SDK is disabled
89
87
  return {
90
88
  debug: () => { },
91
89
  info: console.log.bind(console, '[Rejourney]'),
@@ -175,7 +173,7 @@ const noopAutoTracking = {
175
173
  notifyStateChange: () => { },
176
174
  getSessionMetrics: () => ({}),
177
175
  resetMetrics: () => { },
178
- collectDeviceInfo: () => ({}),
176
+ collectDeviceInfo: async () => ({} as any),
179
177
  ensurePersistentAnonymousId: async () => 'anonymous',
180
178
  };
181
179
 
@@ -219,7 +217,7 @@ async function loadPersistedUserIdentity(): Promise<string | null> {
219
217
 
220
218
  // NATIVE STORAGE: Read directly from SharedPreferences/NSUserDefaults
221
219
  return await nativeModule.getUserIdentity();
222
- } catch (e) {
220
+ } catch {
223
221
  return null;
224
222
  }
225
223
  }
@@ -241,9 +239,7 @@ function isRuntimeReady(): boolean {
241
239
  if (_runtimeReady) return true;
242
240
 
243
241
  try {
244
- // Try to access a core module to verify runtime is ready
245
242
  const RN = require('react-native');
246
- // If we can access NativeModules without error, runtime is ready
247
243
  if (RN.NativeModules) {
248
244
  _runtimeReady = true;
249
245
  return true;
@@ -325,12 +321,10 @@ function getRejourneyNative(): Spec | null {
325
321
  }
326
322
  }
327
323
  } catch (error) {
328
- // If any access fails, log and return null
329
324
  getLogger().warn('Rejourney: Failed to access native modules:', error);
330
325
  _rejourneyNative = null;
331
326
  }
332
327
 
333
- // Ensure we never return undefined - convert to null
334
328
  if (_rejourneyNative === undefined) {
335
329
  _rejourneyNative = null;
336
330
  }
@@ -493,7 +487,7 @@ const Rejourney: RejourneyAPI = {
493
487
  // Collect and log device info
494
488
  if (_storedConfig?.collectDeviceInfo !== false) {
495
489
  try {
496
- const deviceInfo = getAutoTracking().collectDeviceInfo();
490
+ const deviceInfo = await getAutoTracking().collectDeviceInfo();
497
491
  this.logEvent('device_info', deviceInfo as unknown as Record<string, unknown>);
498
492
  } catch (deviceError) {
499
493
  getLogger().warn('Failed to collect device info:', deviceError);
@@ -527,13 +521,11 @@ const Rejourney: RejourneyAPI = {
527
521
  }
528
522
  );
529
523
 
530
- // logger.debug('Network interception enabled');
531
524
  } catch (networkError) {
532
525
  getLogger().warn('Failed to setup network interception:', networkError);
533
526
  }
534
527
  }
535
528
 
536
- // logger.debug('Auto tracking enabled');
537
529
 
538
530
  return true;
539
531
  } catch (error) {
@@ -553,11 +545,9 @@ const Rejourney: RejourneyAPI = {
553
545
  }
554
546
 
555
547
  try {
556
- // Get session metrics before stopping
557
548
  const metrics = getAutoTracking().getSessionMetrics();
558
549
  this.logEvent('session_metrics', metrics as unknown as Record<string, unknown>);
559
550
 
560
- // Cleanup
561
551
  getNetworkInterceptor().disableNetworkInterceptor();
562
552
  getAutoTracking().cleanupAutoTracking();
563
553
  getAutoTracking().resetMetrics();
@@ -565,7 +555,6 @@ const Rejourney: RejourneyAPI = {
565
555
  await safeNativeCall('stopSession', () => getRejourneyNative()!.stopSession(), undefined);
566
556
 
567
557
  _isRecording = false;
568
- // Use lifecycle log for session end - only shown in dev builds
569
558
  getLogger().logSessionEnd('current');
570
559
  } catch (error) {
571
560
  getLogger().error('Failed to stop recording:', error);
@@ -603,9 +592,7 @@ const Rejourney: RejourneyAPI = {
603
592
  setUserIdentity(userId: string): void {
604
593
  _userIdentity = userId;
605
594
  persistUserIdentity(userId).catch(() => { });
606
- // logger.debug(`User identity set: ${userId}`);
607
595
 
608
- // If recording is active, update the native module immediately
609
596
  if (_isRecording && getRejourneyNative()) {
610
597
  safeNativeCallSync(
611
598
  'setUserIdentity',
@@ -624,9 +611,7 @@ const Rejourney: RejourneyAPI = {
624
611
  clearUserIdentity(): void {
625
612
  _userIdentity = null;
626
613
  persistUserIdentity(null).catch(() => { });
627
- // logger.debug('User identity cleared');
628
614
 
629
- // If recording is active, update the native module immediately
630
615
  if (_isRecording && getRejourneyNative()) {
631
616
  safeNativeCallSync(
632
617
  'setUserIdentity',
@@ -645,10 +630,7 @@ const Rejourney: RejourneyAPI = {
645
630
  * @param params - Optional screen parameters
646
631
  */
647
632
  tagScreen(screenName: string, _params?: Record<string, unknown>): void {
648
- // Track screen for metrics and funnel tracking
649
633
  getAutoTracking().trackScreen(screenName);
650
-
651
- // Notify state change (kept for API compatibility)
652
634
  getAutoTracking().notifyStateChange();
653
635
 
654
636
  safeNativeCallSync(
@@ -845,10 +827,6 @@ const Rejourney: RejourneyAPI = {
845
827
  );
846
828
  },
847
829
 
848
- // ========================================================================
849
- // OAuth / External URL Tracking
850
- // ========================================================================
851
-
852
830
  /**
853
831
  * Notify the SDK that an OAuth flow is starting
854
832
  *
@@ -1004,10 +982,6 @@ const Rejourney: RejourneyAPI = {
1004
982
  );
1005
983
  },
1006
984
 
1007
- // ========================================================================
1008
- // SDK Telemetry / Observability
1009
- // ========================================================================
1010
-
1011
985
  /**
1012
986
  * Get SDK telemetry metrics for observability
1013
987
  *
@@ -1065,10 +1039,6 @@ const Rejourney: RejourneyAPI = {
1065
1039
  }
1066
1040
  },
1067
1041
 
1068
- // ========================================================================
1069
- // Privacy / View Masking
1070
- // ========================================================================
1071
-
1072
1042
  /**
1073
1043
  * Mask a view by its nativeID prop (will be occluded in recordings)
1074
1044
  *
@@ -1113,10 +1083,6 @@ const Rejourney: RejourneyAPI = {
1113
1083
  },
1114
1084
  };
1115
1085
 
1116
- // =============================================================================
1117
- // Automatic Lifecycle Management
1118
- // =============================================================================
1119
-
1120
1086
  /**
1121
1087
  * Handle app state changes for automatic session management
1122
1088
  * - Pauses recording when app goes to background
@@ -1150,20 +1116,14 @@ function setupLifecycleManagement(): void {
1150
1116
  const RN = getReactNative();
1151
1117
  if (!RN) return;
1152
1118
 
1153
- // Remove any existing subscription
1154
1119
  if (_appStateSubscription) {
1155
1120
  _appStateSubscription.remove();
1156
1121
  _appStateSubscription = null;
1157
1122
  }
1158
1123
 
1159
1124
  try {
1160
- // Get current app state
1161
1125
  _currentAppState = RN.AppState.currentState || 'active';
1162
-
1163
- // Subscribe to app state changes
1164
1126
  _appStateSubscription = RN.AppState.addEventListener('change', handleAppStateChange);
1165
-
1166
- // Setup auth error listener from native module
1167
1127
  setupAuthErrorListener();
1168
1128
 
1169
1129
  getLogger().debug('Lifecycle management enabled');
@@ -1190,9 +1150,6 @@ function setupAuthErrorListener(): void {
1190
1150
  try {
1191
1151
  const nativeModule = getRejourneyNative();
1192
1152
  if (nativeModule) {
1193
- // RN warns if a non-null module is passed without addListener/removeListeners.
1194
- // Our native module may not implement these no-op methods yet, so only pass
1195
- // the module when those hooks exist; otherwise use the global emitter.
1196
1153
  const maybeAny = nativeModule as any;
1197
1154
  const hasEventEmitterHooks =
1198
1155
  typeof maybeAny?.addListener === 'function' && typeof maybeAny?.removeListeners === 'function';
@@ -1212,10 +1169,8 @@ function setupAuthErrorListener(): void {
1212
1169
  getLogger().logInvalidProjectKey();
1213
1170
  }
1214
1171
 
1215
- // Update SDK state - recording has been stopped by native
1216
1172
  _isRecording = false;
1217
1173
 
1218
- // Call user's error handler if provided
1219
1174
  if (_storedConfig?.onAuthError) {
1220
1175
  try {
1221
1176
  _storedConfig.onAuthError(error);
@@ -1227,7 +1182,6 @@ function setupAuthErrorListener(): void {
1227
1182
  );
1228
1183
  }
1229
1184
  } catch (error) {
1230
- // Event emitter not available on this platform - that's OK
1231
1185
  getLogger().debug('Auth error listener not available:', error);
1232
1186
  }
1233
1187
  }
@@ -1246,10 +1200,6 @@ function cleanupLifecycleManagement(): void {
1246
1200
  }
1247
1201
  }
1248
1202
 
1249
- // =============================================================================
1250
- // Simple Initialization API
1251
- // =============================================================================
1252
-
1253
1203
  /**
1254
1204
  * Initialize Rejourney SDK - STEP 1 of 3
1255
1205
  *
@@ -1282,14 +1232,12 @@ export function initRejourney(
1282
1232
  publicRouteKey: string,
1283
1233
  options?: Omit<RejourneyConfig, 'publicRouteKey'>
1284
1234
  ): void {
1285
- // Validate public route key
1286
1235
  if (!publicRouteKey || typeof publicRouteKey !== 'string') {
1287
1236
  getLogger().warn('Rejourney: Invalid public route key provided. SDK will be disabled.');
1288
1237
  _initializationFailed = true;
1289
1238
  return;
1290
1239
  }
1291
1240
 
1292
- // Store config for later use
1293
1241
  _storedConfig = {
1294
1242
  ...options,
1295
1243
  publicRouteKey,
@@ -1350,7 +1298,6 @@ export function startRejourney(): void {
1350
1298
  getLogger().logRecordingStart();
1351
1299
  getLogger().debug('Starting session...');
1352
1300
 
1353
- // Fire and forget - don't block the caller
1354
1301
  (async () => {
1355
1302
  try {
1356
1303
  const started = await Rejourney._startSession();
@@ -1384,11 +1331,8 @@ export function stopRejourney(): void {
1384
1331
 
1385
1332
  export default Rejourney;
1386
1333
 
1387
- // Export types
1388
1334
  export * from './types';
1389
1335
 
1390
- // Export auto tracking utilities for advanced usage
1391
- // These are used internally but can be called manually if needed
1392
1336
  export {
1393
1337
  trackTap,
1394
1338
  trackScroll,
@@ -1399,11 +1343,8 @@ export {
1399
1343
  getSessionMetrics,
1400
1344
  } from './sdk/autoTracking';
1401
1345
 
1402
- // Navigation
1403
1346
  export { trackNavigationState, useNavigationTracking } from './sdk/autoTracking';
1404
1347
 
1405
- // Re-export LogLevel enum from utils
1406
- // Note: This is safe because the enum itself doesn't trigger react-native imports
1407
1348
  export { LogLevel } from './sdk/utils';
1408
1349
 
1409
1350
  /**
@@ -1438,15 +1379,4 @@ export function setLogLevel(level: number): void {
1438
1379
  getLogger().setLogLevel(level);
1439
1380
  }
1440
1381
 
1441
- // Note: Components and hooks removed in new engine
1442
- // Session replay now handled by dashboard web UI
1443
- // export { RejourneyReplay } from './components/replay/RejourneyReplay';
1444
- // export { GestureTracker } from './components/GestureTracker';
1445
- // export { SessionList } from './components/SessionList';
1446
- // export { useRejourney } from './hooks/useRejourney';
1447
- // export { useReplay } from './hooks/useReplay';
1448
-
1449
- // Note: SDK managers removed in new engine - all functionality handled by native module
1450
-
1451
- // Export Mask component
1452
1382
  export { Mask } from './components/Mask';