Skip to content

fix(sessions): Finalize previous session even when auto session tracking is disabled#5154

Open
romtsn wants to merge 3 commits intomainfrom
romtsn/fix-session-finalization-with-manual-sessions
Open

fix(sessions): Finalize previous session even when auto session tracking is disabled#5154
romtsn wants to merge 3 commits intomainfrom
romtsn/fix-session-finalization-with-manual-sessions

Conversation

@romtsn
Copy link
Member

@romtsn romtsn commented Mar 4, 2026

Summary

  • Removed isEnableAutoSessionTracking() early-return guards from PreviousSessionFinalizer, MovePreviousSession, and InternalSentrySdk.deleteCurrentSessionFile
  • The flag controls automatic session lifecycle, not whether sessions exist — manually started sessions (via Sentry.startSession()) write the same files to disk and need the same finalization
  • Updated tests to verify sessions are finalized regardless of the auto-tracking flag

Test plan

  • Existing tests pass with updated assertions
  • Manual verification: start a session with Sentry.startSession() while enableAutoSessionTracking = false, kill the app, relaunch — previous session should be finalized

Fixes #5108

🤖 Generated with Claude Code

…is disabled

The `isEnableAutoSessionTracking` guard in `PreviousSessionFinalizer`,
`MovePreviousSession`, and `InternalSentrySdk.deleteCurrentSessionFile`
prevented finalization of manually started sessions (via `Sentry.startSession()`).

The flag controls *automatic* session lifecycle, not whether sessions exist at all.
Manual sessions write the same files to disk and need the same finalization.

Fixes #5108

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🚨 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:

  • sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (sessions) Finalize previous session even when auto session tracking is disabled by romtsn in #5154

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🚨 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:

  • sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🚨 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:

  • sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java

@romtsn romtsn changed the title fix(core): Finalize previous session even when auto session tracking is disabled fix(sessions): Finalize previous session even when auto session tracking is disabled Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 276.17 ms 334.43 ms 58.26 ms
Size 1.58 MiB 2.29 MiB 723.03 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
91bb874 314.47 ms 440.00 ms 125.53 ms
dba088c 333.98 ms 381.16 ms 47.18 ms
d15471f 310.66 ms 368.19 ms 57.53 ms
bbc35bb 298.53 ms 372.17 ms 73.64 ms
d15471f 307.28 ms 381.85 ms 74.57 ms
ad8da22 362.98 ms 453.94 ms 90.96 ms
cf708bd 408.35 ms 458.98 ms 50.63 ms
96449e8 361.30 ms 423.39 ms 62.09 ms
27d7cf8 309.43 ms 364.27 ms 54.85 ms
91bb874 311.00 ms 363.47 ms 52.47 ms

App size

Revision Plain With Sentry Diff
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
bbc35bb 1.58 MiB 2.12 MiB 553.01 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
ad8da22 1.58 MiB 2.29 MiB 719.83 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
96449e8 1.58 MiB 2.11 MiB 539.35 KiB
27d7cf8 1.58 MiB 2.12 MiB 549.42 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB

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.

Session crash detection skipped for manually started sessions

1 participant