feat(session-replay-react-native): add teardown and runtime opt-out - #1951
Merged
Conversation
Remove autoStart and replay-property stamping. Standalone consumers now initialize first and explicitly start recording. BREAKING CHANGE: SessionReplayConfig.autoStart and getSessionReplayProperties() are removed. Events are no longer stamped with session replay properties.
…onfigure The standalone SDK no longer auto-starts, so adding this plugin left recording off. Restore the previous behavior with a plugin-owned `autoStart` option (default true) that calls `start()` after `init()`. `autoStart` is stripped before `init()` so it is not forwarded across the native bridge, and the README no longer claims the plugin enriches events. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
size-limit report 📦
|
…ted out session-replay-android still has no runtime opt-out setter. Instead of rebuilding a constructor-opted-out instance, keep JS/native config and do not construct SessionReplay until opt-out is false.
Base automatically changed from
sdkrn-63-remove-autostart-getsessionreplayproperties
to
main
August 22, 2026 00:27
Keep Android recording intent as shouldStart, reconstruct the native instance when opt-out changes, and drop unused JS fullConfig after init.
…OS setOptOut Wire the plugin to the analytics timeline onOptOutChanged hook, pass config.optOut into native setup, and avoid force-unwrapping after teardown.
…rdown safe Create the next Android SessionReplay instance before shutting down the current one, and make remaining iOS bridge methods nil-safe after teardown.
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Reviewed by Cursor Bugbot for commit 3e698ce. Configure here.
chungdaniel
approved these changes
Aug 25, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
teardown()and runtimesetOptOut(boolean)APIs across JavaScript, TurboModule, iOS, and AndroidSDKRN-62
Checklist
Test plan
@amplitude/session-replay-react-nativeand@amplitude/segment-session-replay-plugin-react-nativeNative example compilation was not completed because the example Gradle setup requires a Yarn-hoisted React Native Gradle plugin, while this worktree's package-manager metadata blocks that Yarn install; package builds, type generation, lint, and unit tests pass.
Posted automatically with Cursor. LLMs make mistakes — please verify before acting.
Note
Medium Risk
Touches privacy-sensitive opt-out and native lifecycle teardown/re-init across platforms; Android’s reboot-on-opt-out path is non-trivial and could affect recording state if mis-timed.
Overview
Adds
setOptOut(boolean)andteardown()end-to-end (JS public API, TurboModule spec, iOS, Android) so apps can disable replay collection at runtime and fully shut down the native SDK.teardown()resets JS module state (isInitialized, logger) soinit()can run again; pluginteardown()paths now call nativeteardown()instead of onlystop().The Amplitude
SessionReplayPluginforwardsconfig.optOutinto native setup and implementsonOptOutChangedsoclient.setOptOut()updates replay. The Segment plugin’sshutdown()usesteardown()and exposessetOptOut.On Android, opt-out is implemented by persisting bridge config and rebooting the native instance (skip construction while opted out; recreate on opt-in, respecting
shouldStart). On iOS, runtime opt-out sets the nativeoptOutproperty. The example app adds manual buttons for the new APIs.Reviewed by Cursor Bugbot for commit 3e698ce. Bugbot is set up for automated code reviews on this repo. Configure here.