Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

SessionWithActivities

The SessionWithActivities object is a modified Session object. It contains most of the information that the Session object stores, adding extra information about the current session's latest activity.

The additional data included in the latest activity are useful for analytics purposes. A SessionActivity object will provide information about the user's location, device and browser.

While the SessionWithActivities object wraps the most important information around a Session object, the two objects have entirely different methods.

Properties

NameTypeDescription
idstringA unique identifier for the session.
statusSessionStatusThe current state of the session.
lastActiveAtDateThe time the session was last active on the Client.
abandonAtDateThe time when the session was abandoned by the user.
expireAtDateThe time the session expires and will seize to be active.
latestActivitySessionActivityAn object that provides additional information about this session, focused around user activity data.

Methods

revoke()

function revoke(): Promise<SessionWithActivities>;

Marks this session as revoked. If this is the active session, the attempt to revoke it will fail.

Users can revoke only their own sessions.

Types

SessionActivity

NameTypeDescription
idstringA unique identifier for the session activity record.
browserNamestring | undefinedThe name of the browser from which this session activity occurred.
browserVersionstring | undefinedThe version of the browser from which this session activity occurred.
deviceTypestring | undefinedThe type of the device which was used in this session activity.
ipAddressstring | undefinedThe IP address from which this session activity originated.
citystring | undefinedThe city from which this session activity occurred. Resolved by IP address geo-location.
countrystring | undefinedThe country from which this session activity occurred. Resolved by IP address geo-location.
isMobileboolean | undefinedWill be set to true if the session activity came from a mobile device. Set to false otherwise.

SessionStatus

type SessionStatus = "abandoned" | "active" | "ended" | "expired" | "removed" | "replaced" | "revoked";
ValueDescription
abandonedThe session was abandoned client-side.
activeThe session is valid and all activity is allowed.
endedThe user signed out of the session, but the Session remains in the Client object.
expiredThe period of allowed activity for this session has passed.
removedThe user signed out of the session and the Session was removed from the Client object.
replacedThe session has been replaced by another one, but the Session remains in the Client object.
revokedThe application ended the session and the Session was removed from the Client object.

What did you think of this content?

Clerk © 2023