Skip to content

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

Merged
romtsn merged 4 commits intomainfrom
romtsn/fix-session-finalization-with-manual-sessions
Mar 5, 2026
Merged

fix(sessions): Finalize previous session even when auto session tracking is disabled#5154
romtsn merged 4 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 🐛

  • (screenshot) Add dontwarn replay rules to sentry-android-core by romtsn in #5153
  • (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 288.78 ms 361.29 ms 72.51 ms
Size 1.58 MiB 2.29 MiB 723.05 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ee747ae 374.71 ms 455.18 ms 80.47 ms
22f4345 314.79 ms 375.02 ms 60.23 ms
91bb874 311.00 ms 363.47 ms 52.47 ms
dba088c 328.51 ms 423.79 ms 95.28 ms
5b66efd 308.67 ms 363.85 ms 55.18 ms
96eeafa 361.43 ms 455.07 ms 93.63 ms
2124a46 319.19 ms 415.04 ms 95.85 ms
d15471f 379.40 ms 470.76 ms 91.36 ms
bbc35bb 324.88 ms 425.73 ms 100.85 ms
d15471f 304.55 ms 408.43 ms 103.87 ms

App size

Revision Plain With Sentry Diff
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
22f4345 1.58 MiB 2.29 MiB 719.83 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
5b66efd 1.58 MiB 2.13 MiB 559.07 KiB
96eeafa 1.58 MiB 2.19 MiB 620.21 KiB
2124a46 1.58 MiB 2.12 MiB 551.51 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

Previous results on branch: romtsn/fix-session-finalization-with-manual-sessions

Startup times

Revision Plain With Sentry Diff
c872ee0 276.17 ms 334.43 ms 58.26 ms

App size

Revision Plain With Sentry Diff
c872ee0 1.58 MiB 2.29 MiB 723.03 KiB

@romtsn romtsn enabled auto-merge (squash) March 5, 2026 12:51
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 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 merged commit 872b084 into main Mar 5, 2026
65 checks passed
@romtsn romtsn deleted the romtsn/fix-session-finalization-with-manual-sessions branch March 5, 2026 13:34
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

2 participants