Commit 04807b0
fix(amplitude-session): recover lastEventTime on partial persist
Replace incorrect 1-second timestamp guard with proper root cause fix.
The 0-second session bug is caused by non-atomic AsyncStorage persistence:
when the app is killed (e.g. during iOS Background Fetch), sessionId may
persist while lastEventTime does not. On relaunch, lastEventTime === -1
with a valid sessionId falsely triggers session expiration, ending the
just-created session immediately.
The fix recovers lastEventTime from sessionId when partial persistence
is detected, preventing the false expiration. Also adds hypothesis-driven
reproduction tests that verify the fix.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent ada90d2 commit 04807b0
2 files changed
Lines changed: 472 additions & 47 deletions
File tree
- packages/plugins/plugin-amplitudeSession/src
- __tests__
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | 210 | | |
218 | 211 | | |
219 | 212 | | |
| |||
226 | 219 | | |
227 | 220 | | |
228 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
0 commit comments