RFC-002: GA4 Authentication Event Contract
Related Documents:
- RFC-001 (GA4 Event Contract & Reporting Alignment)]
- ADR-018 (Typed Analytics Architecture)
Abstract
This RFC specifies the GA4 authentication event contract for OneCMS. It defines the canonical authentication journey events, payload requirements, and trigger points for login, MFA, org selection, forgot/reset password, social login, logout, and session expiry.
The goal is to provide a stable, typed telemetry contract that supports product funnel analysis and operational diagnostics while remaining compact and implementation-ready.
1. Introduction
1.1 Background
OneCMS has a typed GA4 architecture but authentication analytics needs a dedicated, explicit contract so Product and Analytics can reason about drop-off and friction points across the auth journey.
1.2 Problem Statement
Without a specific auth contract, teams risk:
- inconsistent trigger points for the same user action,
- missing visibility into OTP and org-selection friction,
- mismatch between implemented auth flow and analytics payloads.
1.3 Goals
This RFC standardizes:
- The canonical authentication event set.
- Required payload fields for each event.
- Where each event is fired in the current flow.
- Outcome semantics (
success/fail/cancel) for async actions.
2. Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "MAY", and "OPTIONAL" are to be interpreted as described in RFC 2119.
- Intent Event: Event fired when user initiates an action.
- Result Event: Event fired after backend/result is known.
- Outcome: Standardized result value from RFC-001 envelope.
- Auth Funnel: End-to-end path from sign-in intent to authenticated session.
3. Scope
3.1 In Scope
- Authentication category events under
src/types/analytics/authentication. - Login (credentials + social), MFA, forgot/reset password, org selection, logout, session expiry.
- Trigger contracts for current auth implementation in
useAuthand auth modules.
3.2 Out of Scope
- UI-only micro-interactions not in contract (e.g., password visibility toggle).
- Dashboard design and KPI definitions.
- Backend telemetry pipeline changes.
4. Authentication Event Contract
4.1 Canonical Event Set
Authentication category includes:
loginforgot_password_clickforgot_passwordreset_passwordlogoutsession_expiredmfa_requiredmfaotp_resendorg_selection_vieworg_selectionsocial_login_clicksocial_login
Event Naming Rules
- Event names MUST be user-centric and action/state-oriented.
- Event names MUST use
snake_caseand align with existing authentication taxonomy. - Result events MUST represent business outcomes, not technical implementation steps.
- Intent interaction events MAY use explicit interaction suffixes (for example,
*_click) when user-intent capture is required. - New authentication events MUST be reviewed against this RFC before adoption.
Authentication Lifecycle Events
The following events represent transitions that end an authenticated session:
logoutsession_expired
4.2 Payload Requirements
| Event | Required Payload Fields | Optional Payload Fields |
|---|---|---|
login |
method |
error_code (fail only) |
forgot_password_click |
source |
— |
forgot_password |
channel |
error_code |
reset_password |
token_valid |
error_code |
mfa_required |
method |
— |
mfa |
method |
error_code |
otp_resend |
method, context |
error_code |
org_selection_view |
tenant_count |
— |
org_selection |
selection_mode |
tenant_count, error_code |
social_login_click |
provider |
— |
social_login |
provider |
error_code |
logout |
reason |
— |
session_expired |
— | duration_minutes |
4.3 Contract Constraints
- Provider values for social auth MUST be
google | microsoft. - OTP method values MUST use canonical auth method enum (
otp | sms | email) and current flow SHOULD emitotp. - For async auth actions, implementations SHOULD emit result events with explicit
outcome. - If an event represents completion of an asynchronous operation, it MUST be emitted only after the operation result is known.
- Authentication events MUST NOT include personally identifiable information (PII) such as email, phone number, access tokens, or tenant identifiers.
5. Event Trigger Matrix
| Flow Stage | Event | When Fired | Outcome | Notes |
|---|---|---|---|---|
| Sign-in | login |
Credentials submit result | success/fail | method=credentials |
| Login challenge | mfa_required |
Backend returns MFA required | success | pre-OTP gate |
| OTP verify (login) | mfa |
OTP verify result | success/fail | includes 2FA errors |
| OTP resend (login) | otp_resend |
Resend result | success/fail | context=login_2fa |
| Multi-tenant gate | org_selection_view |
Org-select screen shown | n/a | include tenant count |
| Org select action | org_selection |
Tenant select result | success/fail | selection_mode=manual |
| Social button click | social_login_click |
Google/Microsoft click | n/a | intent event |
| Social callback | social_login |
OAuth callback result | success/fail | provider required |
| Forgot entry | forgot_password_click |
Forgot link click | n/a | source=login_page |
| Forgot submit | forgot_password |
Email submit result | success/fail | channel=email |
| OTP verify (forgot) | mfa |
OTP verify result | success/fail | forgot-password mode |
| OTP resend (forgot) | otp_resend |
Resend result | success/fail | context=forgot_password |
| Reset submit | reset_password |
Reset API result | success/fail | set token validity |
| Manual sign out | logout |
User logout action | success/fail | reason=manual |
| Idle timeout | session_expired + logout |
Auto-logout timeout path | success | reason=session_expired |
5.1 Dual-Event Rationale for Timeout
Emitting both session_expired and logout for idle timeout is intentional:
session_expiredsupports passive timeout analysis.logoutpreserves a unified session-termination metric across manual and automatic termination paths.
6. Responsibilities
- Engineering: emit typed events at agreed trigger points and preserve payload contracts.
- Product: define funnel and success metrics using this event set.
- Analytics: maintain reporting logic and validate schema-versioned payload compatibility.
7. Versioning and Change Management
- This contract inherits versioning policy from RFC-001.
- Adding optional auth payload fields SHOULD be a minor version change.
- Renaming/removing auth events or required payload fields MUST be a major contract change.
- Any contract-breaking change MUST be proposed via a new RFC referencing RFC-002.
8. Risks and Considerations
- Over-instrumentation can reduce readability and increase implementation drift.
- Inconsistent
error_codemapping can break fail-path analysis. - Missing result events for async steps can create funnel blind spots.
9. Open Questions
- Should
login_page_viewandotp_page_viewbe added as first-class auth events? - Do we need explicit
auth_back_to_login_clickfor abandonment analysis? - Should we standardize a strict internal
error_codetaxonomy in a follow-up RFC?
10. Decision Outcome
- Accepted and implemented by Engineering, Product, and Analytics.
11. References
- RFC-001: GA4 Event Contract & Reporting Alignment
- ADR-018: Typed Analytics (GA) Architecture
src/types/analytics/index.tssrc/types/analytics/authentication/index.tssrc/hooks/auth/useAuth.ts
12. Document History
| Date | Version | Change Summary | Author |
|---|---|---|---|
| 2026-03-10 | 1.0 | Initial draft of authentication GA4 event contract published as proposed RFC | Aakash Jha |
| 2026-03-11 | 1.1 | Status promoted to APPROVED | Aakash Jha |
| 2026-03-14 | 1.2 | Status promoted to IMPLEMENTED and decision outcome updated to accepted delivery | Aakash Jha |