Skip to content

feat(session-replay): upload replay envelope from the native crash daemon#1809

Merged
tustanivsky merged 24 commits into
masterfrom
feat/session-replay-prod
Jul 2, 2026
Merged

feat(session-replay): upload replay envelope from the native crash daemon#1809
tustanivsky merged 24 commits into
masterfrom
feat/session-replay-prod

Conversation

@tustanivsky

@tustanivsky tustanivsky commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

This PR adds Session Replay product support to the native backend. When a downstream SDK (e.g. sentry-unreal) has staged a recorded clip on disk, the crash daemon now builds a replay_video envelope from it and performs an upload so the clip becomes a first-class Session Replay in Sentry, linked to the crash instead of only being available as a file attachment.

Key Changes

  • New internal sentry__session_replay_flush_pending(): scans <database>/replays/ for embedder-staged clips (a replay-<id>.json metadata sidecar + its .mp4), builds the replay_event + replay_recording + video into a replay_video envelope, and hands it to the transport.
  • Scope/trace sync: the replay event reuses the crash event's already-applied scope (tags, contexts, release, environment, user, sdk) and lifts its trace_id, read back from <run>/__sentry-event. This makes the replay carry the same tags as the crash and correlate via the same trace.
  • Wired into the crash daemon: after the crash report is captured, the daemon calls flush_pending out-of-process, so the replay is sent in the same session as the crash (no next-launch step).
  • No new public API - the embedder communicates entirely through the on-disk replays/ convention.
  • Rate-limiting/client-reports: replay_video envelope items are now classified under a dedicated replay data category instead of falling back to error. This stops error rate limits from dropping replays, honors a server-side replay rate limit, and reports discarded replays under the correct category.

Known Limitations

  • Native daemon backend only - not wired for crashpad / breakpad / inproc.

Related items

#skip-changelog

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 6cabda1

@tustanivsky tustanivsky force-pushed the feat/session-replay-prod branch from 154ce2f to b437853 Compare June 25, 2026 07:30
@tustanivsky tustanivsky changed the title feat: add Session Replay envelope capture utility feat(session-replay): upload replay envelope from the native crash daemon Jun 29, 2026
Comment thread src/session_replay/sentry_session_replay.c Outdated
@tustanivsky tustanivsky marked this pull request as ready for review June 30, 2026 03:46
Comment thread src/backends/native/sentry_crash_daemon.c
Comment thread src/session_replay/sentry_session_replay.c
Comment thread src/session_replay/sentry_session_replay.c
Comment thread src/session_replay/sentry_session_replay.c Outdated
Comment thread src/session_replay/sentry_session_replay.c Outdated
@tustanivsky tustanivsky requested a review from jpnurmi July 1, 2026 12:58
@tustanivsky tustanivsky requested a review from JoshuaMoelans July 1, 2026 12:58
Comment thread src/backends/native/sentry_crash_daemon.c Outdated

@jpnurmi jpnurmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very cool to see session replays becoming properly integrated! 🎉

Comment thread src/session_replay/sentry_session_replay.c
Comment thread src/session_replay/sentry_session_replay.c Outdated

@jpnurmi jpnurmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

Even if this feature is currently only used and tested by sentry-unreal, it wouldn't hurt to have something in test_integration_native.py to verify that a correctly structured replay envelope is sent when a dummy replays/foo.mp4 exists.

Not sure if you saw the discussion about the overhead of the continuously flushed __sentry-event file yesterday and how it will likely be replaced by IPC messaging in the future. Such a change would also impact the replay envelope, so it'd be nice to prevent potential regressions early. 🙏

Comment thread src/session_replay/sentry_session_replay.c
Comment thread src/session_replay/sentry_session_replay.c
@tustanivsky

Copy link
Copy Markdown
Collaborator Author

Added a minimal set of tests in b1ab19c. Maybe creating a dummy mp4 will work to test this end-to-end in Unreal too 🤔

@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 6cabda1. Configure here.

Comment thread src/session_replay/sentry_session_replay.c
Comment thread src/session_replay/sentry_session_replay.c
@tustanivsky tustanivsky merged commit 1d73ae8 into master Jul 2, 2026
65 checks passed
@tustanivsky tustanivsky deleted the feat/session-replay-prod branch July 2, 2026 12:49
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