Identity
Erised keeps one profile per person. A profile holds identities: anonymous ids (one per browser), at most one user id from your system, and emails. Joining two histories is never guessed: it happens only at a confirmed moment, it is recorded, and it can be undone from the app.
Before signup: anonymous
The snippet gives each browser an anonymous id (erised_anonymous_id). Browser events land on the profile of that id, and only on it. Even if a browser event claims a userId, it is stored as sent but never used to pick the profile, because anyone can send anything from a browser.
At signup and login: the verified identify
A server identify with the secret key is the confirmed moment:
- The
userIdandproperties.emailattach to the profile as verified. - When the request's
anonymousIdbelongs to one profile and itsuserIdto another (the person used a new device, then logged in), the two profiles are merged: one person, one timeline. - A new anonymous id seen for the first time attaches to the person's profile.
That is why the identify must be sent at every login: each new browser joins the person at that moment.
Rules that protect your data
- Two known users never share a profile. If a browser already belongs to a different user (a shared computer), the identify does not merge: the new user's events go to their own profile.
- A verified email beats an unverified one. An email claimed from the browser stays unverified. A verified identify that claims the same email takes it over; an email already held verified by another person is never taken, and never forces a merge.
- The browser cannot merge. A browser
identifycan attach an email to the current anonymous profile only, when no other profile owns it. It never merges, and it never sets the user id. - A guard rail on merges. A profile holds at most 50 anonymous ids; a merge that would go past it is refused and logged.
- Logout starts fresh.
cdp('reset')gives the browser a new anonymous id, so the next person on the device is not merged into the last.
Aliases
POST /v1/alias (secret key) links two anonymous ids of the same browser, for example across two of your domains. If both ids already have profiles, they merge, under the same guard rail.
Undoing a merge
Every merge is recorded with its reason (identify or alias). From a person's profile in the app, a merge can be undone; the events go back to the profiles they came from and the timelines are correct after.