Mendix already logs some of the information when a user logs in to the log file for instance a successful/unsuccessful login.
But if this does not fulfil your use case and you’re using SAML, take a look at the following documentation:
https://docs.mendix.com/appstore/modules/saml#customuserprovisioning
Hope this helps!
EDIT: There was a module in Mx7 and 8, but I don’t know if that still works in 9. Here is the link to that module and its called SignIn microflow for Mx7 / Mx8. You could give it a shot to see if that works in 9.
https://marketplace.mendix.com/link/component/66443
Alternatively, Mendix also gives an option to check the metrics against an application environment once deployed to their licensed node. You can check metrics of an application via the developer portal.
This is their doc: https://docs.mendix.com/developerportal/operate/trends-v4#Trends-appmxruntimesessions