API Reference

identify

Attach a user identity to the current session. Future events from this session will be associated with this user.

Signature#

typescript
function identify(user: UserIdentity): void;

interface UserIdentity {
  externalId: string;
  email?: string;
  name?: string;
  traits?: Record<string, unknown>;
}

Parameters#

NameTypeDefaultDescription
user.externalId*stringYour stable user ID. Use the same ID you use in your own database — it's how you'll cross-reference Reliable data with your other tools.
user.emailstringOptional email. Shown in the dashboard for quick recognition; used for filtering.
user.namestringOptional display name.
user.traitsobjectFree-form attributes (plan, signup date, role, anything). Useful for filtering errors by user segment.

Example#

typescript
import { identify } from '@reliableapp/frontend-core';

// On login
identify({
  externalId: 'user_abc123',
  email: 'jane@acme.com',
  name: 'Jane Doe',
  traits: {
    plan: 'pro',
    org_id: 'org_xyz',
    signup_date: '2024-08-12',
    is_admin: true,
  },
});

When to call it#

Call identify as soon as you know who the user is — typically right after a successful login, or on app boot if the user is already authenticated. You can call it multiple times — the new identity replaces the old one. If externalId changes, Reliable rotates the session UUID so events from the new user don't get bundled with the old user's session.

On logout#

There's no unidentify(). To clear the identity, either:

typescript
// Option 1 — call identify with an anonymous ID after logout
identify({ externalId: `anon_${crypto.randomUUID()}` });

// Option 2 — reload the page (recommended for security flows)
window.location.href = '/login';

Reloading is the safer choice in apps that handle sensitive data: it guarantees no cached state from the previous user persists in the SDK or anywhere else.

Working with anonymous users#

Without identify, sessions are still recorded — just not linked to a user. The session UUID alone is enough to group all events from one tab. You can identify mid-session: events that fired before identify() are retroactively associated with the user via the shared session UUID.

React users

Use the useIdentify(user) hook instead — it handles re-identification automatically when externalId changes (e.g. on account switch).