diff --git a/android/build.gradle b/android/build.gradle index cb9ceaf..c69391e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -83,7 +83,7 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // Stable native SDK (main branch). 3.1.0 adds startRecording/stopRecording/isRecording. - implementation 'io.github.middleware-labs:android-sdk:3.1.5' + implementation 'io.github.middleware-labs:android-sdk:3.1.6' coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4" // Compile-visible OTel for the JS-span reconstruction (SpanData etc.); // runtime classes come transitively from android-sdk. Keep aligned with diff --git a/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java b/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java index 1536596..bec7e4c 100644 --- a/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java +++ b/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java @@ -2,6 +2,7 @@ import static io.middleware.android.sdk.utils.Constants.LOG_TAG; +import android.app.Activity; import android.app.Application; import android.content.Context; import android.util.Log; @@ -163,7 +164,14 @@ public void initialize(ReadableMap configMap, Promise promise) { UiThreadUtil.runOnUiThread(() -> { try { // v3 session recording starts inside build() (sampler-gated); no explicit start needed. - builder.build((Application) getReactApplicationContext().getApplicationContext()); + // JS calls this after the host Activity has already resumed, so the recorder + // never sees the onActivityResumed it attaches on; given only the Application + // it would capture nothing until the app is backgrounded and reopened. Passing + // the Activity seeds the recorder's current activity. + Activity activity = getReactApplicationContext().getCurrentActivity(); + builder.build(activity != null + ? activity + : (Application) getReactApplicationContext().getApplicationContext()); // Link the JS-owned session immediately — before the v3 recorder captures // its first frame — so no native telemetry lands under the native diff --git a/package.json b/package.json index 7fda164..71c0f76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@middleware.io/middleware-react-native", - "version": "2.1.8", + "version": "2.1.9", "description": "Middleware React Native real user monitoring SDK", "main": "lib/commonjs/index", "module": "lib/module/index",