fix: Enforce a 24-hour maximum session duration#470
Draft
marandaneto wants to merge 9 commits intomainfrom
Draft
fix: Enforce a 24-hour maximum session duration#470marandaneto wants to merge 9 commits intomainfrom
marandaneto wants to merge 9 commits intomainfrom
Conversation
…em.currentTimeMillis()
marandaneto
commented
Mar 26, 2026
...og-android/src/main/java/com/posthog/android/internal/PostHogLifecycleObserverIntegration.kt
Outdated
Show resolved
Hide resolved
Contributor
posthog-android Compliance ReportDate: 2026-03-27 15:36:37 UTC ✅ All Tests Passed!0/0 tests passed |
marandaneto
commented
Mar 27, 2026
Comment on lines
+79
to
+83
| if (postHog?.isSessionReplayActive() == true) { | ||
| postHog?.stopSessionReplay() | ||
|
|
||
| // startSessionReplay will rotate the session id internally | ||
| postHog?.startSessionReplay(resumeCurrent = false) |
Member
Author
There was a problem hiding this comment.
i need to do this here so all the snapshots and caching are cleared up from the previous sessions and wont leak to the new one
marandaneto
commented
Mar 27, 2026
| if (PostHogSessionManager.isSessionExceedingMaxDuration(currentTimeMillis)) { | ||
| cancelTask() | ||
| postHog?.endSession() | ||
| postHog?.stopSessionReplay() |
Member
Author
There was a problem hiding this comment.
i have to check if i need to call postHog?.startSessionReplay during onStart now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Enforce a 24-hour maximum session duration. When a session exceeds 24 hours, it is automatically rotated to a new one. This prevents excessively long sessions from accumulating unbounded data.
Closes #220
💚 How did you test it?
rotateSession(),getSessionStartedAt(), andsessionStartedAtlifecycle inPostHogSessionManagerTest.PostHogLifecycleObserverIntegrationTestverifying:PostHogDateProviderfor time mocking to make tests deterministic.make checkFormat— all formatting checks pass.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file