Skip to content

feat: client-side sampleRate to Android session replay#660

Merged
abelonogov-ld merged 3 commits into
mainfrom
andrey/android-session-replay-sample-rate
Jun 30, 2026
Merged

feat: client-side sampleRate to Android session replay#660
abelonogov-ld merged 3 commits into
mainfrom
andrey/android-session-replay-sample-rate

Conversation

@abelonogov-ld

Copy link
Copy Markdown
Contributor

Summary

  • Add sampleRate to ReplayOptions, mirroring iOS SessionReplayOptions.sampleRate (probability from 0.0–1.0 that replay starts when enabled).
  • Introduce SessionReplaySampling / SessionReplaySamplingSession to evaluate sampling once per enable cycle and reset on stop.
  • Update SessionReplayService to separate user intent (isEnabled) from active recording (isRunning), gating collectors and capture on the latter.

Test plan

  • ./gradlew :lib:testDebugUnitTest in observability-android
  • Verify a session with sampleRate = 0.0 never records
  • Verify a session with sampleRate = 1.0 records as before
  • Merge and publish Android library before RN bridge PR that depends on this API

Made with Cursor

Mirror iOS SessionReplayOptions.sampleRate: ReplayOptions gains sampleRate,
SessionReplaySampling gates capture per enable cycle, and SessionReplayService
tracks isEnabled vs isRunning so sampled-out sessions do not record.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld abelonogov-ld requested a review from a team as a code owner June 30, 2026 18:38
@abelonogov-ld abelonogov-ld changed the title Add client-side sampleRate to Android session replay feat: client-side sampleRate to Android session replay Jun 30, 2026
Gate identifySession on isRunning so sampled-out sessions do not send replay
identify payloads, matching tracks and collectors.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use paths-filter so turbo test runs only when files outside
observability-android, mobile-dotnet, and android e2e workflows change.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld abelonogov-ld enabled auto-merge (squash) June 30, 2026 19:15
@abelonogov-ld abelonogov-ld merged commit 44b0e44 into main Jun 30, 2026
22 checks passed
@abelonogov-ld abelonogov-ld deleted the andrey/android-session-replay-sample-rate branch June 30, 2026 19:18

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 9e399f7. Configure here.

// Sampled-out sessions are enabled but not recording; skip identify like tracks/collectors.
if (!_isRunning.value) {
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sampled-out replay drops identify

Medium Severity

When replay is enabled but excluded by sampleRate, identifySession returns immediately without caching the payload. That differs from the disabled path, which stores pending identify for the next start. After a later stop/start that wins sampling, recording can begin without the user context that was already identified.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9e399f7. Configure here.

abelonogov-ld pushed a commit that referenced this pull request Jun 30, 2026
🤖 I have created a release *beep* *boop*
---


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

##
[0.60.0](launchdarkly-observability-android-0.59.0...launchdarkly-observability-android-0.60.0)
(2026-06-30)


### Features

* client-side sampleRate to Android session replay
([#660](#660))
([44b0e44](44b0e44))
</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**
> Version and changelog-only changes from Release Please; no new code in
this diff.
> 
> **Overview**
> Release Please bumps **`launchdarkly-observability-android`** from
**0.59.0** to **0.60.0** in `.release-please-manifest.json` and
`gradle.properties`, and adds the matching **0.60.0** changelog entry.
> 
> The release ships the already-merged feature from
[#660](#660):
**client-side `sampleRate`** on Android session replay
(`ReplayOptions`), so apps can probabilistically start capture when
replay is enabled (decision once per enable cycle; default remains full
sampling).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
68d1f96. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
abelonogov-ld added a commit that referenced this pull request Jun 30, 2026
…act Native (#661)

## Summary
- Expose `frameRate`, `scale`, `minimumAlpha`, and `sampleRate` on RN
`SessionReplayOptions` and forward them through the iOS and Android
native adapters.
- Add client-side `sampleRate` to Android session replay (mirroring
iOS), including sampling gating and skipping identify export when
sampled out.
- Add unit tests for JS passthrough, Android adapter mapping, and
Android sampling logic.

## Dependency
Merge and publish the Android library changes first
([#660](#660)).
This branch includes the same `observability-android` updates inline;
after #660 lands, rebase and bump `launchdarkly-observability-android`
in the RN podspec/Gradle dependency if needed.

## Test plan
- [x] `yarn test` in `react-native-ld-session-replay`
- [x] `./gradlew :lib:testDebugUnitTest` in `observability-android`
- [ ] Verify `createSessionReplayPlugin({ frameRate, scale, sampleRate
})` on iOS and Android
- [ ] Confirm sampled-out sessions (`sampleRate: 0`) do not record or
export identify events


Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
abelonogov-ld added a commit that referenced this pull request Jun 30, 2026
* main: (39 commits)
  chore: release main (#666)
  feat: Propagate session replay frameRate, scale, and sampleRate in React Native (#661)
  ci: skip yarn test for .NET/Python/Ruby plugin-only changes (#664)
  chore: release main (#663)
  chore: Skip yarn test for Android and MAUI, Flutter PRs (#662)
  feat: client-side sampleRate to Android session replay (#660)
  chore: release main (#659)
  feat(observability-react-native): expose LDTracer with withSpan via getTracer() (#658)
  chore: release main (#657)
  feat(ruby): boot-time OTel auto-instrumentation; keep it working on Rails 7.0 (#643)
  feat: add GraphQL operation attributes to instrumented spans (#644)
  chore: release main (#656)
  feat(observability-react-native): accept plain nested dictionaries in track (#650)
  chore: release main (#655)
  fix: backendurl and otlpendpoind pass through (#648)
  feat(session-replay-react-native): support React Native legacy architecture (RN 0.75+) (#653)
  fix: MAUI - drop OTel activity instrumentation dependency (#651)
  chore: release main (#652)
  feat: supporting advanced trace cases (#645)
  chore: release main (#649)
  ...

# Conflicts:
#	sdk/@launchdarkly/flutter/packages/observability/ios/launchdarkly_flutter_observability.podspec
#	sdk/@launchdarkly/flutter/packages/observability/ios/launchdarkly_flutter_observability/Package.swift
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