Feature request: expose public method to retrieve current session state

Hi Snowplow team,

I’d like to request a new feature related to session tracking in Snowplow. Currently, we have a session state change callback, which is useful, but there isn’t a direct way to retrieve the current session state through a public method.

Would it be possible to add a public method that allows for accessing the current session state directly? This would be particularly helpful in situations where we need to check the session state on demand. Our team is mostly interested in having this functionality in the native iOS and Android trackers, but we believe that other trackers could benefit from it as well.

I believe this feature would offer more flexibility for developers integrating Snowplow in different environments.

Thank you and I look forward to any updates on this!

1 Like

Hi @dnedo - thanks for this suggestion.

Which parts of session state are you most interested in accessing specifically?

Hi @dnedo,

In the iOS and Android trackers, you can access the session information through the SessionController instance returned through tracker.session. For instance, you can get the session ID using tracker.session.sessionId.

Here are the API docs for the session controller and the info it provides:

Does that cover what you were interested in?

Hi @matus, @mike

Unfortunately the existing session data returned through tracker.session doesn’t fully cover our needs because of the discrepancy between what’s passed into the onSessionStateUpdate callback and what’s accessible through the tracker.session. For example, on iOS onSessionStateUpdate callback returns an instance of the SessionState class which provides some additional data that the SessionController doesn’t. Basically what we would like is a way to access the data in the SessionState directly.