Track session length for reporting
-
We are using FusionAuth refresh tokens as our session. Users can connect from multiple devices. We want to record the duration (plus other metadata) of each session for reporting purposes.
How can we do so?
-
The easiest way to do so is to listen for the
jwt.refresh-token.revoke
event.It's documented here: https://fusionauth.io/docs/v1/tech/events-webhooks/events/jwt-refresh-token-revoke
In particular, you have the date of the revocation (the end of the session). If it is an individual session revocation, you have the start date, which is the
startInstant
inside the eventsrefreshToken
field.If your webhook processor does the subtraction of these two values, you'll be able to find and record the duration of the session length.