@rp_st does supertokens log user sessions? Need a way to tell how much time each user has spent online in the app
r
rp_st
04/25/2022, 1:11 PM
hey @renegade_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.
rp_st
04/25/2022, 1:15 PM
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
renegade_roosh
04/25/2022, 3:53 PM
Thanks for the help!
a
Adiboi
04/26/2022, 5:45 AM
Hi @renegade_roosh . Could you elaborate more on this requirement?
Why not use an analytics tool (eg: Amplitude, Google analytics) that would provide this information?
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).