@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,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service to detect when the app is swiped away from recent apps or killed.
|
|
3
|
+
*
|
|
4
|
+
* This service uses onTaskRemoved() callback which is called when the user
|
|
5
|
+
* swipes the app away from the recent apps screen. By setting stopWithTask="false"
|
|
6
|
+
* in the manifest, this callback will fire even when the app is killed.
|
|
7
|
+
*
|
|
8
|
+
* IMPORTANT: This is not 100% reliable across all Android versions and OEMs,
|
|
9
|
+
* but it's the best available mechanism for detecting app termination.
|
|
10
|
+
*/
|
|
11
|
+
package com.rejourney.lifecycle
|
|
12
|
+
|
|
13
|
+
import android.app.Service
|
|
14
|
+
import android.content.Intent
|
|
15
|
+
import android.os.IBinder
|
|
16
|
+
import android.os.SystemClock
|
|
17
|
+
import com.rejourney.core.Logger
|
|
18
|
+
import com.rejourney.utils.OEMDetector
|
|
19
|
+
import kotlinx.coroutines.*
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Callback interface for notifying when app is being killed.
|
|
23
|
+
* Defined outside the class for better accessibility.
|
|
24
|
+
*
|
|
25
|
+
* CRITICAL: This callback is invoked SYNCHRONOUSLY on the main thread.
|
|
26
|
+
* The implementation should complete session end as fast as possible
|
|
27
|
+
* since the process may be killed immediately after this returns.
|
|
28
|
+
*/
|
|
29
|
+
interface TaskRemovedListener {
|
|
30
|
+
/**
|
|
31
|
+
* Called when the app is being killed/swiped away.
|
|
32
|
+
* Implementation should be as fast as possible and use runBlocking
|
|
33
|
+
* to ensure critical operations complete before process death.
|
|
34
|
+
*/
|
|
35
|
+
fun onTaskRemoved()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Service that detects app termination via onTaskRemoved() callback.
|
|
40
|
+
*
|
|
41
|
+
* This service must be registered in AndroidManifest.xml with:
|
|
42
|
+
* - android:stopWithTask="false" (critical - allows onTaskRemoved to fire)
|
|
43
|
+
* - android:exported="false" (security - don't allow external apps to start it)
|
|
44
|
+
*/
|
|
45
|
+
class SessionLifecycleService : Service() {
|
|
46
|
+
|
|
47
|
+
companion object {
|
|
48
|
+
private const val TAG = "SessionLifecycleService"
|
|
49
|
+
|
|
50
|
+
// Static listener reference - set by RejourneyModuleImpl
|
|
51
|
+
@Volatile
|
|
52
|
+
var taskRemovedListener: TaskRemovedListener? = null
|
|
53
|
+
|
|
54
|
+
// Track if service is running
|
|
55
|
+
@Volatile
|
|
56
|
+
var isRunning = false
|
|
57
|
+
private set
|
|
58
|
+
|
|
59
|
+
// Minimum time between service start and onTaskRemoved to be considered valid
|
|
60
|
+
// Samsung devices sometimes fire onTaskRemoved immediately on app launch
|
|
61
|
+
private const val MIN_TIME_BEFORE_TASK_REMOVED_MS = 2000L // 2 seconds
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private val serviceScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
|
65
|
+
|
|
66
|
+
// Track service start time to detect false positives (Samsung bug)
|
|
67
|
+
// Instance variable, not static, since each service instance has its own start time
|
|
68
|
+
private var serviceStartTime: Long = 0
|
|
69
|
+
|
|
70
|
+
override fun onCreate() {
|
|
71
|
+
super.onCreate()
|
|
72
|
+
isRunning = true
|
|
73
|
+
serviceStartTime = SystemClock.elapsedRealtime()
|
|
74
|
+
Logger.debug("[$TAG] Service created (OEM: ${OEMDetector.getOEM()})")
|
|
75
|
+
Logger.debug("[$TAG] ${OEMDetector.getRecommendations()}")
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
79
|
+
serviceStartTime = SystemClock.elapsedRealtime()
|
|
80
|
+
Logger.debug("[$TAG] Service started (startId=$startId, OEM: ${OEMDetector.getOEM()})")
|
|
81
|
+
// Return START_STICKY to allow system to restart service if killed
|
|
82
|
+
// This helps ensure the service stays alive to catch termination events
|
|
83
|
+
return START_STICKY
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Called when the user removes a task from the recent apps list.
|
|
88
|
+
*
|
|
89
|
+
* This is the key callback for detecting app swipe-away/kill events.
|
|
90
|
+
* It fires when:
|
|
91
|
+
* - User swipes the app away from recent apps
|
|
92
|
+
* - User taps "Clear all" in recent apps (on some devices)
|
|
93
|
+
*
|
|
94
|
+
* NOTE: This may NOT fire in all cases:
|
|
95
|
+
* - Some OEMs suppress this callback
|
|
96
|
+
* - "Clear all" on some devices may not trigger it
|
|
97
|
+
* - System-initiated kills (low memory) may not trigger it
|
|
98
|
+
* - Samsung devices have a bug where this fires on app launch (we filter this)
|
|
99
|
+
*
|
|
100
|
+
* That's why we also use ApplicationExitInfo (Android 11+) and
|
|
101
|
+
* persistent state checking on next app launch as fallbacks.
|
|
102
|
+
*/
|
|
103
|
+
override fun onTaskRemoved(rootIntent: Intent?) {
|
|
104
|
+
val timeSinceStart = SystemClock.elapsedRealtime() - serviceStartTime
|
|
105
|
+
val oem = OEMDetector.getOEM()
|
|
106
|
+
|
|
107
|
+
Logger.debug("[$TAG] ⚠️ onTaskRemoved() called (OEM: $oem, timeSinceStart: ${timeSinceStart}ms)")
|
|
108
|
+
|
|
109
|
+
// SAMSUNG BUG FIX: Samsung devices sometimes fire onTaskRemoved() immediately
|
|
110
|
+
// after app launch (within 1-2 seconds). This is a known bug on Samsung devices.
|
|
111
|
+
// We filter out these false positives by checking the time since service start.
|
|
112
|
+
if (OEMDetector.isSamsung() && timeSinceStart < Companion.MIN_TIME_BEFORE_TASK_REMOVED_MS) {
|
|
113
|
+
Logger.warning("[$TAG] ⚠️ Ignoring onTaskRemoved() - likely Samsung false positive (fired ${timeSinceStart}ms after start, expected > ${MIN_TIME_BEFORE_TASK_REMOVED_MS}ms)")
|
|
114
|
+
Logger.warning("[$TAG] This is a known Samsung bug where onTaskRemoved fires on app launch")
|
|
115
|
+
super.onTaskRemoved(rootIntent)
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// For other OEMs with aggressive task killing, log but still process
|
|
120
|
+
if (OEMDetector.hasAggressiveTaskKilling()) {
|
|
121
|
+
Logger.debug("[$TAG] OEM has aggressive task killing - onTaskRemoved may be unreliable")
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Logger.debug("[$TAG] ✅ Valid onTaskRemoved() - app is being killed/swiped away")
|
|
125
|
+
|
|
126
|
+
// CRITICAL: Notify the listener IMMEDIATELY and SYNCHRONOUSLY
|
|
127
|
+
// The previous implementation used a coroutine with 100ms delay which caused
|
|
128
|
+
// the process to be killed before session end could complete.
|
|
129
|
+
//
|
|
130
|
+
// We now call the listener directly on the main thread. The listener
|
|
131
|
+
// (RejourneyModuleImpl) is responsible for doing synchronous work as fast
|
|
132
|
+
// as possible since the process may be killed immediately after this returns.
|
|
133
|
+
try {
|
|
134
|
+
Logger.debug("[$TAG] Calling listener synchronously...")
|
|
135
|
+
taskRemovedListener?.onTaskRemoved()
|
|
136
|
+
Logger.debug("[$TAG] Task removed listener completed")
|
|
137
|
+
} catch (e: Exception) {
|
|
138
|
+
Logger.error("[$TAG] Error notifying task removed listener", e)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Stop the service - no need for async since listener is already done
|
|
142
|
+
try {
|
|
143
|
+
stopSelf()
|
|
144
|
+
} catch (e: Exception) {
|
|
145
|
+
Logger.warning("[$TAG] Error stopping service: ${e.message}")
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
super.onTaskRemoved(rootIntent)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
override fun onBind(intent: Intent?): IBinder? {
|
|
152
|
+
// This is a started service, not a bound service
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
override fun onDestroy() {
|
|
157
|
+
isRunning = false
|
|
158
|
+
serviceScope.cancel()
|
|
159
|
+
Logger.debug("[$TAG] Service destroyed")
|
|
160
|
+
super.onDestroy()
|
|
161
|
+
}
|
|
162
|
+
}
|