3.4.0: `umami.identify()` splits a visitor into two sessions
Describe the Bug
Since 3.4.0 the session ID includes the distinct ID
(src/app/api/send/route.ts#L162):
const sessionId = uuid(sourceId, ip, userAgent, sessionSalt, distinctId ?? '');The documented way to identify a visitor is to call umami.identify(id) after
the tracker loads. The first page view goes out before that call, with no
id. Every request after the call carries the id. So one visitor on one
device now ends up in two sessions:
- An anonymous session with the landing page view(s).
- An identified session with everything after
identify().
Before 3.4.0 both halves shared uuid(website, ip, userAgent, salt), and
identify() only set distinct_id on that same session.
This breaks anything that joins an identified user's actions to how they
arrived: referrer, UTM, entry page, funnels, journeys, and revenue attribution.
It also breaks server-side events that send id for a known user, such as a
purchase event from a payment webhook. Those land in the identified session,
not in the one that holds the visit.
To reproduce
- Load a page with the tracker, then call
umami.identify('user-1'). - Navigate to another page.
- The first page view is in one session and the second is in another. Both
have the same IP and user agent, and only the second has
distinct_id.
Impact we measured (self-hosted, PostgreSQL)
| Member sessions | With no page views | |
|---|---|---|
| 24h on 3.3.1 | 450 | 1 |
| 48 min on 3.4.0 | 79 | 17 |
We rolled back to 3.3.1.
Suggestion
Keep identified and anonymous visitors apart on a shared IP without splitting
one visitor. For example, reuse the session from the cache token when the
request adds an id to an existing anonymous session. Or leave distinctId
out of the key and keep it as an attribute, as before. At the least, the
release notes should say that identify() now starts a new session, and
recommend data-distinct-id for sites that know the user at page load.
Environment
- Umami 3.4.0, Docker image, PostgreSQL
- Tracker served through a proxy,
identify()called after load
Database
PostgreSQL
Relevant log output
Which Umami version are you using?
3.4.0
How are you deploying your application?
Docker
Which browser are you using?
Any (the bug is on the server)
Source: umami-software/umami