@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
@@ -67,13 +67,10 @@ function getReactNative() {
67
67
  return null;
68
68
  }
69
69
  }
70
-
71
- // Lazy-loaded logger
72
70
  let _logger = null;
73
71
  function getLogger() {
74
72
  if (_logger) return _logger;
75
73
  if (_sdkDisabled) {
76
- // Return a no-op logger if SDK is disabled
77
74
  return {
78
75
  debug: () => {},
79
76
  info: console.log.bind(console, '[Rejourney]'),
@@ -152,7 +149,7 @@ const noopAutoTracking = {
152
149
  notifyStateChange: () => {},
153
150
  getSessionMetrics: () => ({}),
154
151
  resetMetrics: () => {},
155
- collectDeviceInfo: () => ({}),
152
+ collectDeviceInfo: async () => ({}),
156
153
  ensurePersistentAnonymousId: async () => 'anonymous'
157
154
  };
158
155
  function getAutoTracking() {
@@ -193,7 +190,7 @@ async function loadPersistedUserIdentity() {
193
190
 
194
191
  // NATIVE STORAGE: Read directly from SharedPreferences/NSUserDefaults
195
192
  return await nativeModule.getUserIdentity();
196
- } catch (e) {
193
+ } catch {
197
194
  return null;
198
195
  }
199
196
  }
@@ -213,9 +210,7 @@ let _runtimeReady = false;
213
210
  function isRuntimeReady() {
214
211
  if (_runtimeReady) return true;
215
212
  try {
216
- // Try to access a core module to verify runtime is ready
217
213
  const RN = require('react-native');
218
- // If we can access NativeModules without error, runtime is ready
219
214
  if (RN.NativeModules) {
220
215
  _runtimeReady = true;
221
216
  return true;
@@ -298,12 +293,9 @@ function getRejourneyNative() {
298
293
  }
299
294
  }
300
295
  } catch (error) {
301
- // If any access fails, log and return null
302
296
  getLogger().warn('Rejourney: Failed to access native modules:', error);
303
297
  _rejourneyNative = null;
304
298
  }
305
-
306
- // Ensure we never return undefined - convert to null
307
299
  if (_rejourneyNative === undefined) {
308
300
  _rejourneyNative = null;
309
301
  }
@@ -445,7 +437,7 @@ const Rejourney = {
445
437
  // Collect and log device info
446
438
  if (_storedConfig?.collectDeviceInfo !== false) {
447
439
  try {
448
- const deviceInfo = getAutoTracking().collectDeviceInfo();
440
+ const deviceInfo = await getAutoTracking().collectDeviceInfo();
449
441
  this.logEvent('device_info', deviceInfo);
450
442
  } catch (deviceError) {
451
443
  getLogger().warn('Failed to collect device info:', deviceError);
@@ -463,15 +455,10 @@ const Rejourney = {
463
455
  ignoreUrls,
464
456
  captureSizes: _storedConfig?.networkCaptureSizes !== false
465
457
  });
466
-
467
- // logger.debug('Network interception enabled');
468
458
  } catch (networkError) {
469
459
  getLogger().warn('Failed to setup network interception:', networkError);
470
460
  }
471
461
  }
472
-
473
- // logger.debug('Auto tracking enabled');
474
-
475
462
  return true;
476
463
  } catch (error) {
477
464
  getLogger().error('Failed to start recording:', error);
@@ -488,17 +475,13 @@ const Rejourney = {
488
475
  return;
489
476
  }
490
477
  try {
491
- // Get session metrics before stopping
492
478
  const metrics = getAutoTracking().getSessionMetrics();
493
479
  this.logEvent('session_metrics', metrics);
494
-
495
- // Cleanup
496
480
  getNetworkInterceptor().disableNetworkInterceptor();
497
481
  getAutoTracking().cleanupAutoTracking();
498
482
  getAutoTracking().resetMetrics();
499
483
  await safeNativeCall('stopSession', () => getRejourneyNative().stopSession(), undefined);
500
484
  _isRecording = false;
501
- // Use lifecycle log for session end - only shown in dev builds
502
485
  getLogger().logSessionEnd('current');
503
486
  } catch (error) {
504
487
  getLogger().error('Failed to stop recording:', error);
@@ -530,9 +513,6 @@ const Rejourney = {
530
513
  setUserIdentity(userId) {
531
514
  _userIdentity = userId;
532
515
  persistUserIdentity(userId).catch(() => {});
533
- // logger.debug(`User identity set: ${userId}`);
534
-
535
- // If recording is active, update the native module immediately
536
516
  if (_isRecording && getRejourneyNative()) {
537
517
  safeNativeCallSync('setUserIdentity', () => {
538
518
  getRejourneyNative().setUserIdentity(userId).catch(() => {});
@@ -546,9 +526,6 @@ const Rejourney = {
546
526
  clearUserIdentity() {
547
527
  _userIdentity = null;
548
528
  persistUserIdentity(null).catch(() => {});
549
- // logger.debug('User identity cleared');
550
-
551
- // If recording is active, update the native module immediately
552
529
  if (_isRecording && getRejourneyNative()) {
553
530
  safeNativeCallSync('setUserIdentity', () => {
554
531
  getRejourneyNative().setUserIdentity('anonymous').catch(() => {});
@@ -562,10 +539,7 @@ const Rejourney = {
562
539
  * @param params - Optional screen parameters
563
540
  */
564
541
  tagScreen(screenName, _params) {
565
- // Track screen for metrics and funnel tracking
566
542
  getAutoTracking().trackScreen(screenName);
567
-
568
- // Notify state change (kept for API compatibility)
569
543
  getAutoTracking().notifyStateChange();
570
544
  safeNativeCallSync('tagScreen', () => {
571
545
  getRejourneyNative().screenChanged(screenName).catch(() => {});
@@ -743,10 +717,6 @@ const Rejourney = {
743
717
  getAutoTracking().trackScroll();
744
718
  await safeNativeCall('onScroll', () => getRejourneyNative().onScroll(scrollOffset), undefined);
745
719
  },
746
- // ========================================================================
747
- // OAuth / External URL Tracking
748
- // ========================================================================
749
-
750
720
  /**
751
721
  * Notify the SDK that an OAuth flow is starting
752
722
  *
@@ -882,10 +852,6 @@ const Rejourney = {
882
852
  getRejourneyNative().logEvent('network_request', networkEvent).catch(() => {});
883
853
  }, undefined);
884
854
  },
885
- // ========================================================================
886
- // SDK Telemetry / Observability
887
- // ========================================================================
888
-
889
855
  /**
890
856
  * Get SDK telemetry metrics for observability
891
857
  *
@@ -933,10 +899,6 @@ const Rejourney = {
933
899
  getLogger().warn('debugTriggerANR is only available in development mode');
934
900
  }
935
901
  },
936
- // ========================================================================
937
- // Privacy / View Masking
938
- // ========================================================================
939
-
940
902
  /**
941
903
  * Mask a view by its nativeID prop (will be occluded in recordings)
942
904
  *
@@ -972,10 +934,6 @@ const Rejourney = {
972
934
  }
973
935
  };
974
936
 
975
- // =============================================================================
976
- // Automatic Lifecycle Management
977
- // =============================================================================
978
-
979
937
  /**
980
938
  * Handle app state changes for automatic session management
981
939
  * - Pauses recording when app goes to background
@@ -1006,20 +964,13 @@ function setupLifecycleManagement() {
1006
964
  if (_sdkDisabled) return;
1007
965
  const RN = getReactNative();
1008
966
  if (!RN) return;
1009
-
1010
- // Remove any existing subscription
1011
967
  if (_appStateSubscription) {
1012
968
  _appStateSubscription.remove();
1013
969
  _appStateSubscription = null;
1014
970
  }
1015
971
  try {
1016
- // Get current app state
1017
972
  _currentAppState = RN.AppState.currentState || 'active';
1018
-
1019
- // Subscribe to app state changes
1020
973
  _appStateSubscription = RN.AppState.addEventListener('change', handleAppStateChange);
1021
-
1022
- // Setup auth error listener from native module
1023
974
  setupAuthErrorListener();
1024
975
  getLogger().debug('Lifecycle management enabled');
1025
976
  } catch (error) {
@@ -1042,9 +993,6 @@ function setupAuthErrorListener() {
1042
993
  try {
1043
994
  const nativeModule = getRejourneyNative();
1044
995
  if (nativeModule) {
1045
- // RN warns if a non-null module is passed without addListener/removeListeners.
1046
- // Our native module may not implement these no-op methods yet, so only pass
1047
- // the module when those hooks exist; otherwise use the global emitter.
1048
996
  const maybeAny = nativeModule;
1049
997
  const hasEventEmitterHooks = typeof maybeAny?.addListener === 'function' && typeof maybeAny?.removeListeners === 'function';
1050
998
  const eventEmitter = hasEventEmitterHooks ? new RN.NativeEventEmitter(maybeAny) : new RN.NativeEventEmitter();
@@ -1055,11 +1003,7 @@ function setupAuthErrorListener() {
1055
1003
  } else if (error?.code === 404) {
1056
1004
  getLogger().logInvalidProjectKey();
1057
1005
  }
1058
-
1059
- // Update SDK state - recording has been stopped by native
1060
1006
  _isRecording = false;
1061
-
1062
- // Call user's error handler if provided
1063
1007
  if (_storedConfig?.onAuthError) {
1064
1008
  try {
1065
1009
  _storedConfig.onAuthError(error);
@@ -1070,7 +1014,6 @@ function setupAuthErrorListener() {
1070
1014
  });
1071
1015
  }
1072
1016
  } catch (error) {
1073
- // Event emitter not available on this platform - that's OK
1074
1017
  getLogger().debug('Auth error listener not available:', error);
1075
1018
  }
1076
1019
  }
@@ -1089,10 +1032,6 @@ function cleanupLifecycleManagement() {
1089
1032
  }
1090
1033
  }
1091
1034
 
1092
- // =============================================================================
1093
- // Simple Initialization API
1094
- // =============================================================================
1095
-
1096
1035
  /**
1097
1036
  * Initialize Rejourney SDK - STEP 1 of 3
1098
1037
  *
@@ -1122,14 +1061,11 @@ function cleanupLifecycleManagement() {
1122
1061
  * ```
1123
1062
  */
1124
1063
  export function initRejourney(publicRouteKey, options) {
1125
- // Validate public route key
1126
1064
  if (!publicRouteKey || typeof publicRouteKey !== 'string') {
1127
1065
  getLogger().warn('Rejourney: Invalid public route key provided. SDK will be disabled.');
1128
1066
  _initializationFailed = true;
1129
1067
  return;
1130
1068
  }
1131
-
1132
- // Store config for later use
1133
1069
  _storedConfig = {
1134
1070
  ...options,
1135
1071
  publicRouteKey
@@ -1183,8 +1119,6 @@ export function startRejourney() {
1183
1119
  }
1184
1120
  getLogger().logRecordingStart();
1185
1121
  getLogger().debug('Starting session...');
1186
-
1187
- // Fire and forget - don't block the caller
1188
1122
  (async () => {
1189
1123
  try {
1190
1124
  const started = await Rejourney._startSession();
@@ -1216,19 +1150,9 @@ export function stopRejourney() {
1216
1150
  }
1217
1151
  }
1218
1152
  export default Rejourney;
1219
-
1220
- // Export types
1221
1153
  export * from './types';
1222
-
1223
- // Export auto tracking utilities for advanced usage
1224
- // These are used internally but can be called manually if needed
1225
1154
  export { trackTap, trackScroll, trackGesture, trackInput, trackScreen, captureError, getSessionMetrics } from './sdk/autoTracking';
1226
-
1227
- // Navigation
1228
1155
  export { trackNavigationState, useNavigationTracking } from './sdk/autoTracking';
1229
-
1230
- // Re-export LogLevel enum from utils
1231
- // Note: This is safe because the enum itself doesn't trigger react-native imports
1232
1156
  export { LogLevel } from './sdk/utils';
1233
1157
 
1234
1158
  /**
@@ -1262,17 +1186,5 @@ export { LogLevel } from './sdk/utils';
1262
1186
  export function setLogLevel(level) {
1263
1187
  getLogger().setLogLevel(level);
1264
1188
  }
1265
-
1266
- // Note: Components and hooks removed in new engine
1267
- // Session replay now handled by dashboard web UI
1268
- // export { RejourneyReplay } from './components/replay/RejourneyReplay';
1269
- // export { GestureTracker } from './components/GestureTracker';
1270
- // export { SessionList } from './components/SessionList';
1271
- // export { useRejourney } from './hooks/useRejourney';
1272
- // export { useReplay } from './hooks/useReplay';
1273
-
1274
- // Note: SDK managers removed in new engine - all functionality handled by native module
1275
-
1276
- // Export Mask component
1277
1189
  export { Mask } from './components/Mask';
1278
1190
  //# sourceMappingURL=index.js.map