I am looking to draw charts/ graphs much like Google Analytics dashboards that answers questions around Salesforce user activity like:
- Which users are currently logged in our org? Where from?
- How many hours did they spend in the portal today or in the past week/month/quarter/year?
- How many times did they login in the past week/month/quarter/year? Where from?
- Given a user, what activities did they perform while using the app? CRUD operations log, which pages did they view, etc.
I looked at this and this, but they tell how to do this on Salesforce native UI and no mention of object/apex/visualforce. Also browsed through all standard objects to see if I can find any matching keywords like 'session', 'login history', 'auth' etc, but no luck. Some of the articles I read mentioned UserAuth
and LoginHistory
objects but they don't seem to exist at all.
I think all I need is the names of objects that contain this data (if at all). Can someone please shed some light on this? Thank you.
Best Answer
I have access LoginHistory (key prefix 0Ya) via a SOQL query. Make sure you are using API version 21.0 or higher to see it.
You could test this from the developer console SOQL tool or anonymous Apex. For the latter:
You can also see when an IP address was validated for login using LoginIp.
In v34.0 you can also access LoginGeo.
Check active sessions using AuthSession.