Skip to content

feat(react-native): Propagate LDContext to Android session replay via afterIdentify hook#495

Merged
beekld merged 10 commits intomainfrom
beeklimt/O11Y-1345
Apr 23, 2026
Merged

feat(react-native): Propagate LDContext to Android session replay via afterIdentify hook#495
beekld merged 10 commits intomainfrom
beeklimt/O11Y-1345

Conversation

@beekld
Copy link
Copy Markdown
Contributor

@beekld beekld commented Apr 23, 2026

Summary

Wires LDContext changes from the React Native LaunchDarkly SDK through to the Android Session Replay instance so that session replay sessions are correctly attributed to the identified user/context. Re-uses the existing hook for MAUI.

Also changes the default context to be an anonymous context, rather than "placeholder", per advice from the JS SDK team.

Test plan

  • New unit tests in JS and Android.
  • Manual: run the React Native example app and verify sessions are attributed correctly in the session replay backend.

Note

Medium Risk
Adds a new cross-platform afterIdentify bridge and changes Android initialization context handling, which can affect session attribution and replay data if the context/canonical key logic is wrong. Scope is limited to session replay integrations and includes new unit tests to reduce regression risk.

Overview
Propagates React Native identify() context changes into native Session Replay so replay sessions are attributed to the correct user/context.

On React Native, adds an afterIdentify TurboModule API plus a plugin Hook.afterIdentify that converts LDContext (single/multi/legacy) into {kind: key} maps and a canonical key (with escaping and deterministic ordering) before calling native.

On Android, the RN adapter now accepts afterIdentify, caches the latest completed LDContext, forwards it to LDReplay.hookProxy?.afterIdentify(...), and uses the cached (anonymous-by-default) context during LDClient.init instead of a placeholder; includes Android + JS unit tests. iOS stubs the new method for parity.

Reviewed by Cursor Bugbot for commit 8e58d17. Bugbot is set up for automated code reviews on this repo. Configure here.

@beekld beekld requested a review from a team as a code owner April 23, 2026 20:53
Copy link
Copy Markdown
Contributor

@abelonogov-ld abelonogov-ld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Merge after fixing Cursor comments

Comment thread sdk/@launchdarkly/react-native-ld-session-replay/src/index.tsx Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8e58d17. Configure here.

@beekld beekld merged commit 8179a8e into main Apr 23, 2026
25 checks passed
@beekld beekld deleted the beeklimt/O11Y-1345 branch April 23, 2026 22:48
beekld pushed a commit that referenced this pull request Apr 24, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>launchdarkly-observability-android: 0.41.0</summary>

##
[0.41.0](launchdarkly-observability-android-0.40.0...launchdarkly-observability-android-0.41.0)
(2026-04-23)


### Features

* **react-native:** Propagate LDContext to Android session replay via
afterIdentify hook
([#495](#495))
([8179a8e](8179a8e))
</details>

<details><summary>session-replay-react-native: 0.5.0</summary>

##
[0.5.0](session-replay-react-native-0.4.3...session-replay-react-native-0.5.0)
(2026-04-23)


### Features

* **react-native:** Propagate LDContext to Android session replay via
afterIdentify hook
([#495](#495))
([8179a8e](8179a8e))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: this PR is release metadata only (version bumps and
changelog entries) with no functional code changes in the diff.
> 
> **Overview**
> Updates release artifacts to publish new versions of
`@launchdarkly/observability-android` (**0.40.0 → 0.41.0**) and
`@launchdarkly/session-replay-react-native` (**0.4.3 → 0.5.0**).
> 
> Refreshes `.release-please-manifest.json`, the Android
`gradle.properties` version, and both packages’ `CHANGELOG.md` entries
noting LDContext propagation to Android session replay via the
`afterIdentify` hook.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a5f425a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants