@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
@@ -175,13 +175,10 @@ function getReactNative() {
175
175
  return null;
176
176
  }
177
177
  }
178
-
179
- // Lazy-loaded logger
180
178
  let _logger = null;
181
179
  function getLogger() {
182
180
  if (_logger) return _logger;
183
181
  if (_sdkDisabled) {
184
- // Return a no-op logger if SDK is disabled
185
182
  return {
186
183
  debug: () => {},
187
184
  info: console.log.bind(console, '[Rejourney]'),
@@ -260,7 +257,7 @@ const noopAutoTracking = {
260
257
  notifyStateChange: () => {},
261
258
  getSessionMetrics: () => ({}),
262
259
  resetMetrics: () => {},
263
- collectDeviceInfo: () => ({}),
260
+ collectDeviceInfo: async () => ({}),
264
261
  ensurePersistentAnonymousId: async () => 'anonymous'
265
262
  };
266
263
  function getAutoTracking() {
@@ -301,7 +298,7 @@ async function loadPersistedUserIdentity() {
301
298
 
302
299
  // NATIVE STORAGE: Read directly from SharedPreferences/NSUserDefaults
303
300
  return await nativeModule.getUserIdentity();
304
- } catch (e) {
301
+ } catch {
305
302
  return null;
306
303
  }
307
304
  }
@@ -321,9 +318,7 @@ let _runtimeReady = false;
321
318
  function isRuntimeReady() {
322
319
  if (_runtimeReady) return true;
323
320
  try {
324
- // Try to access a core module to verify runtime is ready
325
321
  const RN = require('react-native');
326
- // If we can access NativeModules without error, runtime is ready
327
322
  if (RN.NativeModules) {
328
323
  _runtimeReady = true;
329
324
  return true;
@@ -406,12 +401,9 @@ function getRejourneyNative() {
406
401
  }
407
402
  }
408
403
  } catch (error) {
409
- // If any access fails, log and return null
410
404
  getLogger().warn('Rejourney: Failed to access native modules:', error);
411
405
  _rejourneyNative = null;
412
406
  }
413
-
414
- // Ensure we never return undefined - convert to null
415
407
  if (_rejourneyNative === undefined) {
416
408
  _rejourneyNative = null;
417
409
  }
@@ -553,7 +545,7 @@ const Rejourney = {
553
545
  // Collect and log device info
554
546
  if (_storedConfig?.collectDeviceInfo !== false) {
555
547
  try {
556
- const deviceInfo = getAutoTracking().collectDeviceInfo();
548
+ const deviceInfo = await getAutoTracking().collectDeviceInfo();
557
549
  this.logEvent('device_info', deviceInfo);
558
550
  } catch (deviceError) {
559
551
  getLogger().warn('Failed to collect device info:', deviceError);
@@ -571,15 +563,10 @@ const Rejourney = {
571
563
  ignoreUrls,
572
564
  captureSizes: _storedConfig?.networkCaptureSizes !== false
573
565
  });
574
-
575
- // logger.debug('Network interception enabled');
576
566
  } catch (networkError) {
577
567
  getLogger().warn('Failed to setup network interception:', networkError);
578
568
  }
579
569
  }
580
-
581
- // logger.debug('Auto tracking enabled');
582
-
583
570
  return true;
584
571
  } catch (error) {
585
572
  getLogger().error('Failed to start recording:', error);
@@ -596,17 +583,13 @@ const Rejourney = {
596
583
  return;
597
584
  }
598
585
  try {
599
- // Get session metrics before stopping
600
586
  const metrics = getAutoTracking().getSessionMetrics();
601
587
  this.logEvent('session_metrics', metrics);
602
-
603
- // Cleanup
604
588
  getNetworkInterceptor().disableNetworkInterceptor();
605
589
  getAutoTracking().cleanupAutoTracking();
606
590
  getAutoTracking().resetMetrics();
607
591
  await safeNativeCall('stopSession', () => getRejourneyNative().stopSession(), undefined);
608
592
  _isRecording = false;
609
- // Use lifecycle log for session end - only shown in dev builds
610
593
  getLogger().logSessionEnd('current');
611
594
  } catch (error) {
612
595
  getLogger().error('Failed to stop recording:', error);
@@ -638,9 +621,6 @@ const Rejourney = {
638
621
  setUserIdentity(userId) {
639
622
  _userIdentity = userId;
640
623
  persistUserIdentity(userId).catch(() => {});
641
- // logger.debug(`User identity set: ${userId}`);
642
-
643
- // If recording is active, update the native module immediately
644
624
  if (_isRecording && getRejourneyNative()) {
645
625
  safeNativeCallSync('setUserIdentity', () => {
646
626
  getRejourneyNative().setUserIdentity(userId).catch(() => {});
@@ -654,9 +634,6 @@ const Rejourney = {
654
634
  clearUserIdentity() {
655
635
  _userIdentity = null;
656
636
  persistUserIdentity(null).catch(() => {});
657
- // logger.debug('User identity cleared');
658
-
659
- // If recording is active, update the native module immediately
660
637
  if (_isRecording && getRejourneyNative()) {
661
638
  safeNativeCallSync('setUserIdentity', () => {
662
639
  getRejourneyNative().setUserIdentity('anonymous').catch(() => {});
@@ -670,10 +647,7 @@ const Rejourney = {
670
647
  * @param params - Optional screen parameters
671
648
  */
672
649
  tagScreen(screenName, _params) {
673
- // Track screen for metrics and funnel tracking
674
650
  getAutoTracking().trackScreen(screenName);
675
-
676
- // Notify state change (kept for API compatibility)
677
651
  getAutoTracking().notifyStateChange();
678
652
  safeNativeCallSync('tagScreen', () => {
679
653
  getRejourneyNative().screenChanged(screenName).catch(() => {});
@@ -851,10 +825,6 @@ const Rejourney = {
851
825
  getAutoTracking().trackScroll();
852
826
  await safeNativeCall('onScroll', () => getRejourneyNative().onScroll(scrollOffset), undefined);
853
827
  },
854
- // ========================================================================
855
- // OAuth / External URL Tracking
856
- // ========================================================================
857
-
858
828
  /**
859
829
  * Notify the SDK that an OAuth flow is starting
860
830
  *
@@ -990,10 +960,6 @@ const Rejourney = {
990
960
  getRejourneyNative().logEvent('network_request', networkEvent).catch(() => {});
991
961
  }, undefined);
992
962
  },
993
- // ========================================================================
994
- // SDK Telemetry / Observability
995
- // ========================================================================
996
-
997
963
  /**
998
964
  * Get SDK telemetry metrics for observability
999
965
  *
@@ -1041,10 +1007,6 @@ const Rejourney = {
1041
1007
  getLogger().warn('debugTriggerANR is only available in development mode');
1042
1008
  }
1043
1009
  },
1044
- // ========================================================================
1045
- // Privacy / View Masking
1046
- // ========================================================================
1047
-
1048
1010
  /**
1049
1011
  * Mask a view by its nativeID prop (will be occluded in recordings)
1050
1012
  *
@@ -1080,10 +1042,6 @@ const Rejourney = {
1080
1042
  }
1081
1043
  };
1082
1044
 
1083
- // =============================================================================
1084
- // Automatic Lifecycle Management
1085
- // =============================================================================
1086
-
1087
1045
  /**
1088
1046
  * Handle app state changes for automatic session management
1089
1047
  * - Pauses recording when app goes to background
@@ -1114,20 +1072,13 @@ function setupLifecycleManagement() {
1114
1072
  if (_sdkDisabled) return;
1115
1073
  const RN = getReactNative();
1116
1074
  if (!RN) return;
1117
-
1118
- // Remove any existing subscription
1119
1075
  if (_appStateSubscription) {
1120
1076
  _appStateSubscription.remove();
1121
1077
  _appStateSubscription = null;
1122
1078
  }
1123
1079
  try {
1124
- // Get current app state
1125
1080
  _currentAppState = RN.AppState.currentState || 'active';
1126
-
1127
- // Subscribe to app state changes
1128
1081
  _appStateSubscription = RN.AppState.addEventListener('change', handleAppStateChange);
1129
-
1130
- // Setup auth error listener from native module
1131
1082
  setupAuthErrorListener();
1132
1083
  getLogger().debug('Lifecycle management enabled');
1133
1084
  } catch (error) {
@@ -1150,9 +1101,6 @@ function setupAuthErrorListener() {
1150
1101
  try {
1151
1102
  const nativeModule = getRejourneyNative();
1152
1103
  if (nativeModule) {
1153
- // RN warns if a non-null module is passed without addListener/removeListeners.
1154
- // Our native module may not implement these no-op methods yet, so only pass
1155
- // the module when those hooks exist; otherwise use the global emitter.
1156
1104
  const maybeAny = nativeModule;
1157
1105
  const hasEventEmitterHooks = typeof maybeAny?.addListener === 'function' && typeof maybeAny?.removeListeners === 'function';
1158
1106
  const eventEmitter = hasEventEmitterHooks ? new RN.NativeEventEmitter(maybeAny) : new RN.NativeEventEmitter();
@@ -1163,11 +1111,7 @@ function setupAuthErrorListener() {
1163
1111
  } else if (error?.code === 404) {
1164
1112
  getLogger().logInvalidProjectKey();
1165
1113
  }
1166
-
1167
- // Update SDK state - recording has been stopped by native
1168
1114
  _isRecording = false;
1169
-
1170
- // Call user's error handler if provided
1171
1115
  if (_storedConfig?.onAuthError) {
1172
1116
  try {
1173
1117
  _storedConfig.onAuthError(error);
@@ -1178,7 +1122,6 @@ function setupAuthErrorListener() {
1178
1122
  });
1179
1123
  }
1180
1124
  } catch (error) {
1181
- // Event emitter not available on this platform - that's OK
1182
1125
  getLogger().debug('Auth error listener not available:', error);
1183
1126
  }
1184
1127
  }
@@ -1197,10 +1140,6 @@ function cleanupLifecycleManagement() {
1197
1140
  }
1198
1141
  }
1199
1142
 
1200
- // =============================================================================
1201
- // Simple Initialization API
1202
- // =============================================================================
1203
-
1204
1143
  /**
1205
1144
  * Initialize Rejourney SDK - STEP 1 of 3
1206
1145
  *
@@ -1230,14 +1169,11 @@ function cleanupLifecycleManagement() {
1230
1169
  * ```
1231
1170
  */
1232
1171
  function initRejourney(publicRouteKey, options) {
1233
- // Validate public route key
1234
1172
  if (!publicRouteKey || typeof publicRouteKey !== 'string') {
1235
1173
  getLogger().warn('Rejourney: Invalid public route key provided. SDK will be disabled.');
1236
1174
  _initializationFailed = true;
1237
1175
  return;
1238
1176
  }
1239
-
1240
- // Store config for later use
1241
1177
  _storedConfig = {
1242
1178
  ...options,
1243
1179
  publicRouteKey
@@ -1291,8 +1227,6 @@ function startRejourney() {
1291
1227
  }
1292
1228
  getLogger().logRecordingStart();
1293
1229
  getLogger().debug('Starting session...');
1294
-
1295
- // Fire and forget - don't block the caller
1296
1230
  (async () => {
1297
1231
  try {
1298
1232
  const started = await Rejourney._startSession();
@@ -1323,12 +1257,7 @@ function stopRejourney() {
1323
1257
  getLogger().warn('Error stopping Rejourney:', error);
1324
1258
  }
1325
1259
  }
1326
- var _default = exports.default = Rejourney; // Export types
1327
- // Export auto tracking utilities for advanced usage
1328
- // These are used internally but can be called manually if needed
1329
- // Navigation
1330
- // Re-export LogLevel enum from utils
1331
- // Note: This is safe because the enum itself doesn't trigger react-native imports
1260
+ var _default = exports.default = Rejourney;
1332
1261
  /**
1333
1262
  * Configure SDK log verbosity.
1334
1263
  *
@@ -1360,16 +1289,4 @@ var _default = exports.default = Rejourney; // Export types
1360
1289
  function setLogLevel(level) {
1361
1290
  getLogger().setLogLevel(level);
1362
1291
  }
1363
-
1364
- // Note: Components and hooks removed in new engine
1365
- // Session replay now handled by dashboard web UI
1366
- // export { RejourneyReplay } from './components/replay/RejourneyReplay';
1367
- // export { GestureTracker } from './components/GestureTracker';
1368
- // export { SessionList } from './components/SessionList';
1369
- // export { useRejourney } from './hooks/useRejourney';
1370
- // export { useReplay } from './hooks/useReplay';
1371
-
1372
- // Note: SDK managers removed in new engine - all functionality handled by native module
1373
-
1374
- // Export Mask component
1375
1292
  //# sourceMappingURL=index.js.map