2

I am looking to draw charts/ graphs much like Google Analytics dashboards that answers questions around Salesforce user activity like:

  1. Which users are currently logged in our org? Where from?
  2. How many hours did they spend in the portal today or in the past week/month/quarter/year?
  3. How many times did they login in the past week/month/quarter/year? Where from?
  4. 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.

2

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:

System.debug([Select Id,UserId,LoginTime,LoginType,SourceIp,LoginUrl,AuthenticationServiceId,LoginGeoId,Browser,Platform,Status,Application,ClientVersion,ApiType,ApiVersion from LoginHistory]);

You can also see when an IP address was validated for login using LoginIp.

In v34.0 you can also access LoginGeo.

Represents the geographic location of the user’s IP address for a login event.

Check active sessions using AuthSession.

The AuthSession object represents an individual user session in your organization. This object is available in versions 29.0 and later.

[U]se this object to create a report showing who is signed in to your organization, or to create a tool to delete a session, ending that user’s session. For a user, only their own sessions are available, while administrators can see all sessions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.