snowplow / snowplow-cpp-tracker

Snowplow event tracker for C++. Add analytics to your C++ applications, games and servers
http://snowplowanalytics.com
Apache License 2.0
9 stars 6 forks source link

Update session when events are tracked (close #35) #41

Closed matus-tomlein closed 2 years ago

matus-tomlein commented 2 years ago

Changed the behavior of the client session to reflect the more modern approach adopted by mobile trackers.

Instead of background thread that updates the session in regular intervals, the session info is now updated on each tracked event. It checks for timeouts since last tracked event and starts a new session if necessary.

In addition to checking for session updates when new events are tracked, I also added a check for session updates in the set_is_background() function. This ensures that transitions between background states are handled with the correct timeout and not ignored.

Session information is persisted in a SQLite database as before. However, instead of saving to the database in the background thread, changes are persisted when session context is fetched and updated. This might have a small toll on the time it takes to track an event. However, since session updates are relatively rare (only after timeouts), I thought it's not a problem.