Skip to content

Investigate mobile replay capturing for error events dropped by sampleRate sampling #6598

Description

@antonis

Background

As of @sentry/core 10.70.0 (getsentry/sentry-javascript#22819), error event sampleRate sampling was moved from before _prepareEvent to after it. This means beforeSend now runs before the sampling decision.

The mobile replay integration wraps beforeSend to call NATIVE.captureReplay for error events (mobilereplay.ts:375). With the new ordering, replay segments can be captured for events that are subsequently dropped by sampleRate sampling.

Previous behavior (< 10.70.0)

  1. sampleRate check → event dropped before beforeSend → no replay captured

Current behavior (>= 10.70.0)

  1. _prepareEventbeforeSend → mobile replay captures native segment → sampleRate check → event dropped
  2. The replay segment is captured and linked via replay_id, but the error event it's linked to is never sent

Impact

Apps with sampleRate below 1.0 will capture native replay segments for error events that are then dropped by sampling, resulting in orphaned replays and wasted native work.

Suggested investigation

  • Confirm whether orphaned replay segments cause any server-side issues (e.g. unlinked replays in the UI)
  • Consider checking sampleRate in processEvent before calling NATIVE.captureReplay
  • Alternatively, coordinate with the JS SDK team on whether a hook or event metadata could signal the sampling decision earlier

References

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions