Newer Version Available

This content describes an older version of this product. View Latest

LogoutEventStream (Beta)

LogoutEventStream represents an event associated with a user UI logout. A logout event records a successful user logout from your org’s UI. This object is read only, and you can’t retrieve it using a SOQL query. This object is available in API version 41.0 and later.

As a beta feature, the LogoutEventStream object is a preview and isn’t part of the “Services” under your master subscription agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature. You can provide feedback and suggestions for the LogoutEventStream object in the Salesforce Identity group in the Trailblazer Community. For information on enabling this feature in your org, contact Salesforce.

Note

When LogoutEventStream is enabled, Salesforce publishes logout events, and you can add an Apex trigger to subscribe to those events. You can then implement custom logic during logout. For example, you can revoke all refresh tokens for a user at logout.

LogoutEventStream records logouts, not timeouts. Timeouts don't cause a LogoutEventStream object to be published. An exception is when a user is automatically logged out of the org after their session times out because the org has the Force logout on session timeout setting enabled. In this case, a logout event is recorded. However, if users close their browser during a session, regardless of whether the Force logout on session timeout setting is enabled, a logout event isn't recorded.

Note

Supported Calls

describeSObjects()

Fields

Field Name Details
EventDate
Type
datetime
Properties
Nillable
Description
Represents when the event started.
EventIdentifier
Type
string
Properties
Nillable
Description
Represents the event ID for correlation purposes.
LoginKey
Type
string
Properties
Nillable
Description
The string that ties together all events in a given user’s login session. It starts with a login event and ends with either a logout event or the user session expiring.
RelatedEventIdentifier
Type
string
Properties
Nillable
Description
Represents the EventIdentifier of the related event.
ReplayId
Type
string
Properties
Nillable
Description
Represents the Numeric ID that identifies the logout event. Each ID is incremented automatically and guaranteed to be higher than the ID of the previous event, but not necessarily contiguous for consecutive events.
SessionKey
Type
string
Properties
Nillable
Description
The user’s unique session ID. You can use this value to identify all user events within a session. When a user logs out and logs in again, a new session is started.
SessionLevel
Type
picklist
Properties
Nillable, Restricted picklist
Description
Indicates the session-level security of the session that the user is logging out of for this event. Session-level security controls user access to features that support it, such as connected apps and reporting. Possible values are:
  • LOW - The user’s security level for the current session meets the lowest requirements.

    This low level is not available, nor used, in the Salesforce UI. User sessions through the UI are either standard or high assurance. You can set this level using the API, but users assigned this level n experience unpredictable and reduced functionality in their Salesforce org.

    Note

  • STANDARD - The user’s security level for the current session meets the Standard requirements set in the current organization Session Security Levels.
  • HIGH_ASSURANCE - A high assurance session was used for the current session. For example, when the user tries to access a resource such as a connected app, report, or dashboard that requires a high assurance session level.
This field is available in API version 43.0 and later.
SourceIp
Type
string
Properties
Nillable
Description
The source IP address of the client logging out. For example, 126.7.4.2. This field is available in API version 43.0 and later.
UserId
Type
reference
Properties
Nillable
Description
Represents the ID of the user associated with the logout event.
Username
Type
string
Properties
Nillable
Description
Represents the username of the user associated with the logout event.

Usage

In this example, the subscriber inserts a custom logout event record during logout.

1trigger LogoutEventTrigger on LogoutEventStream (after insert) { 
2  LogoutEventStream event = Trigger.new[0];
3  LogoutEvent__c record = new LogoutEvent__c();
4  record.EventIdentifier__c = event.EventIdentifier;
5  record.UserId__c = event.UserId;
6  record.Username__c = event.Username;
7  record.EventDate__c = event.EventDate;
8  record.RelatedEventIdentifier__c = event.RelatedEventIdentifier;
9  record.SessionKey__c = event.SessionKey;
10  record.LoginKey__c = event.LoginKey;
11  insert(record);
12}