Amplitude-iOS icon indicating copy to clipboard operation
Amplitude-iOS copied to clipboard

Improve end session event

Open djih opened this issue 8 years ago • 0 comments

This addresses the issue when the end session event is logged on app open and the latest app state is logged (for example the app version name), with the old timestamp, resulting in events for certain app versions being logged before the version was actually released.

When app goes into background, we log an end session event and save it to the key value table (with session_end as the key). This end session event is timestamped at the time the app goes into the background.

When app comes into foreground and starts a new session, it checks the key value table for any saved end session events. If there isn't one, it logs one at that time (the old behavior) which will go to the key value table. It then reloads the saved end session event and just adds it to the events table.

We sanity check the saved end session event and make sure that its timestamp is the same as the last recorded time (when app went into background).

This change should not break any existing tests since the fallback behavior is just the old behavior.

djih avatar Nov 30 '16 03:11 djih