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.
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.