Identifying users
When a user is logged in to your application and an error or trace occurs, you can attach information about that user to the report so you can see who was affected in Flare.
Call flare.setUser() once you know who the user is (after login, on app boot, in a route guard, etc.):
import { flare } from '@flareapp/js';
flare.setUser({
id: 123,
email: '[email protected]',
fullName: 'Jane Doe',
});
The following fields are recognised:
| Field | Attribute sent | Description |
|---|---|---|
id |
user.id |
The user's unique identifier. Used to group occurrences. |
email |
user.email |
Shown as the user's label, with a Gravatar. |
fullName |
user.full_name |
Shown as the user's label when no email is present. |
All fields are optional. Provide whichever you have; id is what links occurrences to a single user.
Sending extra attributes
Any additional keys you pass are collected under user.attributes and shown alongside the user in Flare:
flare.setUser({
id: 123,
email: '[email protected]',
fullName: 'Jane Doe',
plan: 'pro',
teamId: 42,
});
Here plan and teamId are sent as user.attributes.
Clearing the user
When the user logs out, clear the attached user by passing null:
flare.setUser(null);
Per-request scope (Node)
In @flareapp/node, setUser() attaches the user to the current request scope, so concurrent requests do
not share or leak each other's user. Call it inside your request handler (typically within
runWithContext(...)). See the
@flareapp/node README
for details on request-scoped context:
import { flare } from '@flareapp/node';
flare.setUser({ id: user.id, email: user.email, fullName: user.name });