Skip to content

fix: always register activity lifecycle callbacks for accurate session tracking#355

Merged
polbins merged 1 commit intomainfrom
pintal/AMP-149057/fix-session-handling-without-lifecycle-autocapture
Feb 13, 2026
Merged

fix: always register activity lifecycle callbacks for accurate session tracking#355
polbins merged 1 commit intomainfrom
pintal/AMP-149057/fix-session-handling-without-lifecycle-autocapture

Conversation

@polbins
Copy link
Contributor

@polbins polbins commented Feb 13, 2026

Describe what this PR is addressing

Fixes #354. With default config (autocapture = setOf(SESSIONS)), activity lifecycle callbacks were never registered, so foreground stayed false and sessions reset after minTimeBetweenSessionsMillis even while the user was in-app.

Describe the solution

Always register activity lifecycle callbacks. Autocapture events are already individually guarded in AndroidLifecyclePlugin, so this only makes foreground detection always-on. Removes the now-dead REQUIRES_ACTIVITY_CALLBACKS constant and its test.

Steps to verify the change

UT and manual

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?

Note

Low Risk
Small behavior change limited to always-on lifecycle callback registration; main risk is minor overhead or unintended lifecycle side effects, but no auth/data-flow logic changes.

Overview
Always registers ActivityLifecycleObserver in Amplitude initialization, instead of doing so only when certain autocapture options are enabled, ensuring foreground/session state stays accurate even with session-only tracking.

Removes the now-unused AutocaptureOption.REQUIRES_ACTIVITY_CALLBACKS constant and deletes its unit test coverage.

Written by Cursor Bugbot for commit 1151016. This will update automatically on new commits. Configure here.

@polbins polbins force-pushed the pintal/AMP-149057/fix-session-handling-without-lifecycle-autocapture branch from f5d4357 to 1151016 Compare February 13, 2026 22:49
@polbins polbins changed the title fix: always register activity lifecycle callbacks for accurate sessio… fix: always register activity lifecycle callbacks for accurate session tracking Feb 13, 2026
@polbins polbins marked this pull request as ready for review February 13, 2026 22:53
@polbins polbins requested review from crleona and sojingle February 13, 2026 22:53
@polbins polbins merged commit 3624d45 into main Feb 13, 2026
11 of 12 checks passed
@polbins polbins deleted the pintal/AMP-149057/fix-session-handling-without-lifecycle-autocapture branch February 13, 2026 23:32
github-actions bot pushed a commit that referenced this pull request Feb 17, 2026
## [1.25.2](v1.25.1...v1.25.2) (2026-02-17)

### Bug Fixes

* always register activity lifecycle callbacks for accurate session tracking ([#355](#355)) ([3624d45](3624d45))
@github-actions
Copy link

🎉 This PR is included in version 1.25.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session Id change after minTimeBetweenSessionsMillis even if User is still in App

2 participants