feat(android): [Unhandled Sessions 4] Add session update for dropped hybrid errors - #5990
Conversation
Hybrid SDKs skip captureEnvelopeNonTerminating when an error is unsampled, so the session never records it. Expose the same non-terminating session update without sending the event. Co-authored-by: Cursor <cursoragent@cursor.com>
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
|
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
📲 Install BuildsAndroid
|
…nt PR Leave the stack's capture methods as they are and add the dropped-event API as a standalone method so this PR stays additive. Co-authored-by: Cursor <cursoragent@cursor.com>
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
…ed-sessions-dropped-event Co-authored-by: Cursor <cursoragent@cursor.com>
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
Performance metrics 🚀
|
This path is for hybrid errors dropped by sample rate, not rate limiting. Co-authored-by: Cursor <cursoragent@cursor.com>
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
…ed-sessions-dropped-event
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
There was a problem hiding this comment.
Pull request overview
Adds an internal Android API for updating sessions when hybrid errors are dropped by sampling.
Changes:
- Adds dropped-event session update handling.
- Adds tests for handled and unhandled dropped errors.
- Updates API metadata and changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Summary |
|---|---|
sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt |
Adds coverage for dropped-error session behavior and finalization. |
sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java |
Adds the session-update API. Moderate issue remains: terminal sessions should be guarded before updates. (2 votes) |
sentry-android-core/api/sentry-android-core.api |
Records the new API surface. |
CHANGELOG.md |
Documents the API addition. Nit: align the changelog entry with the PR checklist policy. (4 votes) |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
PR Stack (Unhandled Sessions)
📜 Description
Adds
InternalSentrySdk.updateSessionForDroppedEventNonTerminating(boolean crashed)so hybrid SDKs can apply the same session side effects ascaptureEnvelopeNonTerminatingwhen an error is dropped by sampling.It delegates to the private
updateSessionNonTerminatinghelper extracted in #5921.crashed=truerecords a non-terminating unhandled error (same session id, stayOk, persist)crashed=falseincrements the error count without the unhandled flagendSessionstill finalizes asunhandled💡 Motivation and Context
Hybrid SDKs sample in Dart/JS before calling into Java. Unsampled errors never reach
captureEnvelopeNonTerminating, so the session is not updated. NativeSentryClientupdates the session before sampling; this API closes that gap for the non-terminating hybrid path.Do not call this for events dropped by
beforeSendor ignored exception types.💚 How did you test it?
New
InternalSentrySdkTestcoverage: an unhandled dropped error flags and persists the session without sending an envelope; a handled dropped error incrementserrorsonly;endSessionafterwards finalizes asunhandled.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Update the Flutter Android bridge to call this when an error is dropped by sampling, instead of skipping the native session update.