Skip to content

fix(replay): Backfill release, environment and SDK for replays from the previous run - #6253

Merged
0xadam-brown merged 7 commits into
mainfrom
fix/replay-backfill-previous-run-options
Oct 14, 2026
Merged

0xadam-brown merged 7 commits into
mainfrom
fix/replay-backfill-previous-run-options

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

📜 Description

When the SDK starts, ReplayIntegration.finalizePreviousReplay() sends the last cached segment of the previous run's replay using PreviousReplayHint, which is Backfillable. Because of that hint, MainEventProcessor intentionally skips release, environment, dist and SDK, since the current run's values may not describe the earlier one. Nothing filled them in afterwards (there was a TODO for this), so these segments went out with no sdk, release or environment.

This change reads those values from the options persisted by PersistingOptionsObserver and sets them on the replay event before it is captured. The integration registers before Sentry.init runs notifyOptionsObservers, and both use the single-threaded SDK executor, so the persisted values still belong to the run that recorded the replay. If no SDK version was persisted, it falls back to the current options.sdkVersion, because the SDK name stays the same between runs and a replay with no SDK info is worse than one with a slightly newer version.

Persisted scope values (user, tags, contexts) are still not backfilled; I left a TODO for that.

💡 Motivation and Context

On the Sentry side, a replay gets its SDK name from any of its segments. A replay whose only segment came through this path (e.g. buffer mode, app killed or crashed, replay flushed on next launch) has no sdk.name, release or environment at all. The replay details page then can't tell which mobile platform's docs to link to and reports Unknown mobile platform in configure card: null. We could reproduce this with single-segment buffer replays from an internal Android project.

💚 How did you test it?

Added unit tests in ReplayIntegrationTest covering both the persisted-options backfill and the SDK version fallback. Both tests fail without the fix.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Backfill persisted scope values (user, tags, contexts) for previous-run replays.

via roman.

--

View Junior Session [Sentry]

sentry-junior Bot and others added 2 commits October 14, 2026 09:08
…he previous run

Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
@sentry

sentry Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.60.0 (1) release

⚙️ sentry-android Build Distribution Settings

@romtsn
romtsn marked this pull request as ready for review October 14, 2026 10:50

@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 and found 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit f53c2e0. Configure here.

Comment thread sentry-android-replay/src/main/java/io/sentry/android/replay/ReplayIntegration.kt Outdated
@romtsn romtsn added the sanity-check PR needs a lightweight review for obvious issues label Oct 14, 2026
sentry-junior Bot and others added 3 commits October 14, 2026 10:58
… backfill

Co-Authored-By: roman <roman.zavarnitsyn@sentry.io>
Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
…previous-run backfill

Co-Authored-By: roman <roman.zavarnitsyn@sentry.io>

@adinauer adinauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@0xadam-brown 0xadam-brown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few quick comments for your consideration, but no blockers 👍

Comment thread sentry-android-replay/src/main/java/io/sentry/android/replay/ReplayCache.kt Outdated
@0xadam-brown
0xadam-brown merged commit e553354 into main Oct 14, 2026
70 checks passed
@0xadam-brown
0xadam-brown deleted the fix/replay-backfill-previous-run-options branch October 14, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants