Skip to content

fix(amplitude-session): fix persistence model, reset(), inline helpers - #1168

Closed
abueide wants to merge 1 commit into
amp/transition-promisefrom
amp/persistence-cleanup
Closed

abueide wants to merge 1 commit into
amp/transition-promisefrom
amp/persistence-cleanup

Conversation

@abueide

@abueide abueide commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Stop persisting eventSessionId — it's a transient value bootstrapped from sessionId on load
  • Batch persistence with AsyncStorage.multiSet in performSessionTransition to prevent partial state on crash
  • Remove sessionId setter's AsyncStorage.setItem — persistence now only happens in performSessionTransition and reset()
  • Fix reset() to fire session_end before clearing state, use multiRemove for atomic cleanup
  • Inline endSession/trackSessionStart into performSessionTransition (single call site each)

Context

PR 4/4 in the fix stack. Depends on #1167. After this PR, the final source has no console.log, no resetPending, and no EVENT_SESSION_ID_KEY.

Test plan

  • Add test: eventSessionId is NOT persisted to AsyncStorage
  • Add test: eventSessionId is bootstrapped from sessionId on load
  • Add test: multiSet used for session transition persistence
  • Add test: reset() fires session_end and uses multiRemove
  • Add test: reset() does NOT fire session_end when no active session
  • yarn jest — 66 suites, 366 tests pass, no regressions

🤖 Generated with Claude Code

Stop persisting eventSessionId (transient value bootstrapped from
sessionId on load). Batch sessionId + lastEventTime writes with
AsyncStorage.multiSet in performSessionTransition to prevent partial
state on crash. Fix reset() to fire session_end before clearing state,
and use multiRemove for atomic cleanup. Inline endSession and
trackSessionStart into performSessionTransition since each had only
one call site.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abueide

abueide commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by a single combined PR.

@abueide abueide closed this Mar 12, 2026
@abueide
abueide deleted the amp/persistence-cleanup branch March 12, 2026 20:22
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.

1 participant