I want to capture how many hours in a day user spends time , one of the way is to capture through Auth0 login and logout events , how to capture that for a user ?
Hello @rshah
Thank you for reaching out to us!
You should indeed be able to base the time a user spends by considering the login and logout events. It is possible to retrieve the logs via the Auth0 Management API, using the GET /api/v2/logs
endpoint, which can then be filtered by user_id. Within these logs, you would want to consider the success login event ( s ) and the success logout event ( slo ), please see the following documentation for the full list of Log Type Codes. A user’s spent time should potentially be calculated as Session Duration = Logout Timestamp - Login Timestamp.
Please do take into consideration that a user could stay inactive on the tenant, which might not create a Success Logout event within the logs and the user would essentially ’ logout ’ once their session expires. If the logout event in the logs is missing, it should be an indication of this.
Hope that helped!
Gerald