Skip to content

Conversation

@jamescrosswell
Copy link
Collaborator

@jamescrosswell jamescrosswell commented Oct 22, 2025

Part of #2136

This PR adds basic support for Session Replay, including associating replays with exceptions and traces.

It does not implement any way to configure granular masks... only basic options to mask all text / images or none are provided. That can be done in a separate PR.

Note

Note that there are no new tests here as the enabling functionality was added in #4133 (those tests cover this functionality already)

Warning

We should bump the Cocoa SDK to 8.57.2 before releasing this

@jamescrosswell jamescrosswell changed the title Ios replay Session Replay for iOS Oct 22, 2025
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (version6@4e86db9). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             version6    #4664   +/-   ##
===========================================
  Coverage            ?   73.26%           
===========================================
  Files               ?      480           
  Lines               ?    17432           
  Branches            ?     3439           
===========================================
  Hits                ?    12771           
  Misses              ?     3815           
  Partials            ?      846           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

{
// For replay to work on iOS, session tracking must be enabled in the Cocoa SDKt
options.AutoSessionTracking = false;
nativeOptions.EnableAutoSessionTracking = true;
Copy link
Collaborator Author

@jamescrosswell jamescrosswell Oct 28, 2025

Choose a reason for hiding this comment

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

I'm not sure how we now want to handle situations like this:

var hasTerminalException = processedEvent.HasTerminalException();
if (hasTerminalException)
{
// Event contains a terminal exception -> end session as crashed
_options.LogDebug("Ending session as Crashed, due to unhandled exception.");
scope.SessionUpdate = _sessionManager.EndSession(SessionEndStatus.Crashed);
}
else if (processedEvent.HasException())
{
// Event contains a non-terminal exception -> report error
// (this might return null if the session has already reported errors before)
scope.SessionUpdate = _sessionManager.ReportError();
}

... or this:

// Start a new session
try
{
var sessionUpdate = _sessionManager.StartSession();
if (sessionUpdate is not null)
{
CaptureSession(sessionUpdate);
}
}

If the CocoaSdk owns the session, do we still need to be able to start/stop sessions from the .NET SDK?

Copy link
Member

Choose a reason for hiding this comment

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

these sessions are not the same as session replay. let's not conflate these APIs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Flash0ver it's relatively complex to work around this. We could go with what's here for a 1st experimental release... basically if folks have session replay enabled for iOS then they can't manually start/stop sessions (since all of that has to be done via the Cocoa SDK). This is not ideal, but would allow us to ship some version of this functionality with version 6... get some feedback and then iterate from there.

If you're OK with that, this is ready for review again.

Copy link
Member

Choose a reason for hiding this comment

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

Releasing as experimental feature for early feedback that we can improve on sounds great ... if #4704 is included.

@jamescrosswell jamescrosswell marked this pull request as ready for review October 30, 2025 03:32
@jamescrosswell jamescrosswell marked this pull request as ready for review November 3, 2025 03:17
cursor[bot]

This comment was marked as outdated.

/// to <c>false</c>.
/// </summary>
/// <remarks>Defaults to <c>true</c></remarks>
public bool EnableViewRendererV2 { get; set; } = true;
Copy link
Member

Choose a reason for hiding this comment

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

question: are EnableViewRendererV2 and EnableFastViewRendering mutually exclusive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They're separate flags in the underlying Cocoa SDK... we don't actually need to surface these in .NET though. I could just remove them unless/until we have some need to expose them.

Copy link
Member

Choose a reason for hiding this comment

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

I was just wondering.
Since they're under ExperimentalOptions, I'm fine exposing the Option, so various combinations can be tested.

@jamescrosswell jamescrosswell marked this pull request as draft November 4, 2025 21:12
@jamescrosswell jamescrosswell marked this pull request as ready for review November 12, 2025 00:21
@jamescrosswell jamescrosswell merged commit 6a67f5e into version6 Nov 12, 2025
15 of 16 checks passed
@jamescrosswell jamescrosswell deleted the ios-replay branch November 12, 2025 00:21
@github-actions
Copy link
Contributor

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Session Replay for iOS ([#4664](https://github.com/getsentry/sentry-dotnet/pull/4664))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 271a446

#elif __IOS__
string? nativeId = null;
SentryCocoaSdk.ConfigureScope(scope => nativeId = scope.ReplayId);
return (nativeId is { } id) ? SentryId.Parse(id) : null;
Copy link

Choose a reason for hiding this comment

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

Bug: Sentry ID Parsing Inconsistency Across Platforms

When nativeId is an empty string, SentryId.Parse(id) may fail or return an invalid ID. The Android implementation checks for SentryId.Empty but the iOS version lacks this validation, potentially causing issues with malformed replay IDs.

Fix in Cursor Fix in Web

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.

5 participants