Skip to content

Conversation

@bitsandfoxes
Copy link
Contributor

Unity SDK integrations pause and resume sessions in response to lifecycle events without knowing if a session is active. This causes repeated warnings from GlobalSessionManager ("Attempted to pause/resume a session, but a session has not been started") with no way for integrations to prevent them.

_options.LogWarning("Attempted to resume a session, but a session has not been started.");

This PR adds IHub.IsSessionActive to allow checking session state before pause/resume operations. This also gives users insights into whether there currently is a session active. I don't know how else they are supposed to deal any manual session handling anyway.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

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

Generated by 🚫 dangerJS against 2805139

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.20%. Comparing base (01d6bb8) to head (2805139).
⚠️ Report is 1 commits behind head on feat/cache-unhandled-session.

Files with missing lines Patch % Lines
src/Sentry/Extensibility/DisabledHub.cs 0.00% 1 Missing ⚠️
src/Sentry/Extensibility/HubAdapter.cs 0.00% 1 Missing ⚠️
src/Sentry/Internal/Hub.cs 0.00% 1 Missing ⚠️
src/Sentry/SentrySdk.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                        @@
##           feat/cache-unhandled-session    #4662      +/-   ##
================================================================
- Coverage                         73.21%   73.20%   -0.02%     
================================================================
  Files                               479      479              
  Lines                             17370    17374       +4     
  Branches                           3431     3431              
================================================================
  Hits                              12718    12718              
- Misses                             3803     3807       +4     
  Partials                            849      849              

☔ 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.


public bool IsEnabled => _isEnabled;

public bool IsSessionActive => _sessionManager.IsSessionActive;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bitsandfoxes I'm wondering if what I'm building here might break this (and possibly other stuff):
#4664

Can Unity apps target iOS?

If so, I might need to build an IosSessionManager implementation for ISessionManager... which would be a wrapper around the CocoaSdk session manager.

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Although, I'm also guessing Session Replay isn't a thing in Unity... so maybe a non issue for this particular change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unity targets iOS, but sessions are entirely kept and controlled on the C# side of things to keep as close to the user's code as possible. The .NET SDK already allows to pause and resume sessions, I don't see how allowing to check whether a session is active would break things.

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.

3 participants