AuthEvent
Represents a single authentication event.Fields
Unique identifier for the event (UUID)
The type of authentication event (e.g.,
"user.joined", "user.logged_in")When the event occurred
Whether the event completed successfully or failed
ID of the user associated with this event
ID of the session associated with this event
ID of the organization associated with this event
Additional event-specific data (e.g., user name, email, changed fields)
IP address where the event originated
User agent string from the client
Source of the event - either from your app or API
AuthEventType
String union type of all possible authentication event types.EventQueryOptions
Options for querying events.Fields
Maximum number of events to return
Offset for pagination (fetch from N). When provided, cursor-based pagination is disabled.
Cursor for pagination (used when offset not provided). Returns events after this event ID.
Sort order:
"desc": Newest first (default)"asc": Oldest first
Filter by event type (e.g.,
"user.logged_in")Filter events for a specific user
Filter events since this timestamp
EventQueryResult
Result from querying events.Fields
Array of events matching the query
Whether there are more events available for pagination
Cursor to use for fetching the next page.
null if no more events.EventStats
Statistical breakdown of events by severity.Fields
Total number of events
Number of events with success severity
Number of events with failed severity
Number of events with warning severity
Number of events with info severity
EVENT_TEMPLATES
Mapping of event types to message template functions. Used to generate human-readable messages for events.Usage
Template Examples
user.joined(success):"Alice joined!"user.joined(failed):"[email protected] failed to join"user.logged_in(success):"Alice logged in"organization.created(success):"New organization \"Acme Corp\" created by Alice"login.failed:"Failed login attempt for [email protected]"
getEventSeverity
Helper function to determine the severity level of an event.Parameters
The event object or minimal event-like object with type and status
Optional status override. If provided, uses this instead of
event.status.Returns
The severity level based on event type and status:
"failed": Status is failed, or event type indicates failure/ban/deletion"success": Event indicates successful completion (joined, created, verified, logged in)"warning": Event indicates caution (reset requests, verifications)"info": Default for updates, changes, and other informational events