Skip to content

On-error mobile replay orphaned when its error is dropped by sampleRate #6598

Closed

Description

@antonis

Root cause

Since @sentry/core 10.70.0 (getsentry/sentry-javascript#22819), the error sampleRate roll runs after beforeSend. The mobile-replay on-error flush lives in a beforeSend wrapper (mobilereplay.ts), so it now uploads the buffered replay before the sampling decision. When the error is then dropped by sampleRate, the replay is uploaded with no corresponding error event.

Who is affected

Only the intersection of:

  • Buffer / on-error replay (replaysOnErrorSampleRate)
  • sampleRate < 1.0 (error events are being sub-sampled)
  • A specific error that flushes the buffer and then loses the sampleRate roll

Full-session replays and default-sampleRate apps are not affected.

Proposed fix

  • JS: in beforeSend, only link the event to the buffered replay id (no upload); defer the native flush to the afterSendEvent client hook, which fires only for events that survive sampling and are actually sent. afterSendEvent already exists in core — no @sentry/core change needed.
  • Android: ✅ RN-repo-only. Read the buffered id from ReplayController.getReplayId() (public sentry-java API).
  • iOS: requires an upstream sentry-cocoa change. PrivateSentrySDKOnly.getReplayId reads the scope (empty while buffering) in all released versions incl. 9.27.0 / main; the buffered sessionReplayId is only reachable via internal APIs (getReplayIntegration, not in the public header). Fix: have getReplayId fall back to the integration's buffered sessionReplayId. iOS then follows with a cocoa bump.

Activity

  1. linear-code commented on Aug 21, 2026

    @linear-code
  2. self-assigned this
    on Aug 21, 2026
  3. changed the title [-]Investigate mobile replay capturing for error events dropped by sampleRate sampling[/-] [+]On-error mobile replay orphaned when its error is dropped by `sampleRate`[/+] on Sep 7, 2026
  4. github-actions commented on Sep 10, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #6685, which was included in the 8.26.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions