Web SDK

Identify signed-in users

Attach your user ID, name and email to On-Live sessions, so you can see who a visitor was and find all of their visits.

Sessions are anonymous by default. Call Flamio.identify when a user signs in, and Flamio On-Live shows who the visitor was and lets you find all of their visits.

Before you begin

  • The web SDK is installed and sending data. See Install the web SDK.
  • Sending a user's name or email to Flamio is processing personal data. Make sure your privacy notice covers it.

Call identify after sign-in

Call Flamio.identify after Flamio.init, as soon as you know who the user is. Pass your stable user ID first:

import { Flamio } from '@flamioai/web-sdk';

Flamio.identify('user_123', {
  name: 'Ada Lovelace',
  email: 'ada@example.com',
  plan: 'pro',
});

Calls made before Flamio.init are ignored. In a React app, call both from the same component, in this order:

app/flamio-recorder.tsx
'use client';

import { useEffect } from 'react';
import { Flamio } from '@flamioai/web-sdk';

type SignedInUser = { id: string; name: string; email: string; plan: string };

export function FlamioRecorder({ user }: { user: SignedInUser | null }) {
  useEffect(() => {
    Flamio.init({
      projectKey: 'YOUR_KEY_HERE',
      endpoint: 'https://api.flamio.org/api',
    });
  }, []);

  useEffect(() => {
    if (user) {
      Flamio.identify(user.id, { name: user.name, email: user.email, plan: user.plan });
    }
  }, [user]);

  return null;
}

YOUR_KEY_HERE is your project's API key from Flamio On-Live > Setup.

Choose the traits

  • name and email (strings) are what On-Live shows for the visitor.
  • Any other key, such as plan, role or company, becomes a detail you can filter visits by.
  • Keep the traits small. If they are larger than 4 KB as JSON, the SDK drops all of them and sends only the user ID.
  • Never put passwords, tokens or other secrets in traits.

Deploy and check

Deploy your site. Then open Flamio On-Live > Visits: the Visitor column shows the name, or the email, instead of Anonymous.

Result

  • The whole session is attributed to the user, including what was recorded before the identify call.
  • In Visits, type an address into the User email box of the filter bar to see one person's visits.
  • To filter by another trait, type plan=pro into the meta key=value box and press Enter.
  • In a replay, the Info tab shows the Visitor row with the identified user.

With consent: 'wait', you can call Flamio.identify before the visitor decides. The SDK keeps the identity in memory and sends it only after Flamio.consent('granted'). While the visitor has not agreed, it is not sent.

When the user signs out

Version 0.9.0 has no call that clears the identity. If several people share one browser, call Flamio.stop() when a user signs out, then Flamio.init() again. The SDK starts a new session, and you call Flamio.identify for the next user.