https://supertokens.com/ logo
#support-questions
Title
# support-questions
r

Roosh

04/25/2022, 1:09 PM
@rp does supertokens log user sessions? Need a way to tell how much time each user has spent online in the app
r

rp

04/25/2022, 1:11 PM
hey @Roosh This is generally a tricky thing to calculate accurately. First off, we do not give an estimate of this ourselves. Since the access token verification happens in a stateless manner and the core doesn't know about them.
To calculate this accurately, you will want to: - log successful session verifications that happen in your APIs. In the log, you want to include the user ID and the timestamp. These logs should be saved in a db. - Then, you can run a job which will "club" logs that are within a certain time frame of each other. For example, club all logs that are within 10 mins of each other. - Then you will have a list of these sets and you can calculate the duration of these sets by taking the timestamp of the max log - time of the min log. - Then you would sum all these set's times and you would have an estimate of how much time the user has spent on the app.
r

Roosh

04/25/2022, 3:53 PM
Thanks for the help!
a

Adiboi

04/26/2022, 5:45 AM
Hi @Roosh . Could you elaborate more on this requirement? Why not use an analytics tool (eg: Amplitude, Google analytics) that would provide this information?