Skip to main content
SessionEvent is an append-only time-series log of Firebase auth token issuances, recording one row per distinct (membership, token_issued_at) tuple. It is written exclusively by the Firebase authentication strategy at request time and is the canonical source for WAU/MAU, retention, stickiness, and engagement-bucketing analytics. Each row is tied to a Membership (which in turn scopes a user to a workspace); there is no workspace FK on the row itself. The table was renamed from login_events in migration 20260511113135 and carries no soft-delete column β€” it is explicitly append-only.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

Data model

Attributes

Relationships

System-computed

  • session_event_id β€” generated via gen_random_uuid() DB default; also initialised in-process via randomUUID() as the ORM default value
  • created_at β€” set by MikroORM onCreate hook to new Date() at insert time; never updated
  • token_issued_at β€” sourced from decoded Firebase ID token iat field by firebase.strategy.ts; NOT user-supplied
  • event_type β€” derived from decoded.auth_time vs decoded.iat comparison in firebase.strategy.ts; default β€˜login’
  • Dedup on (membership_pk, token_issued_at) β€” enforced at the DB layer by the unique index; SessionEventRepository.recordIfNew catches SQLSTATE 23505 with constraint name session_events_membership_pk_token_issued_at_unique for silent dedup without swallowing unrelated unique violations
  • No deleted_at β€” the table is append-only by design; soft-delete does not apply to this entity

Example

Source: apps/api/src/database/entities/SessionEvent.ts Β· domain: platform Β· tier: Activity