Which Customers Hit That Error? Identify Users in Production
Tie errors and sessions to signed-in user ids and plans, so you know which paying customers hit a bug before they e-mail you. Browser, Node and Python code, plus the privacy rules that keep it safe.
To know which customers hit an error before they write to you, attach the signed-in user's id (and their plan) to every session and every server request at the moment they log in or authenticate, clear it on logout, and group errors by that id. Send ids, not e-mail addresses, to anything outside your own systems, keep an export and erase path per person, and rank incidents by who was hit: one failure for ten paying customers matters more than a hundred failures for anonymous visitors.
An error count tells you something broke. It does not tell you that the customer who broke was your biggest account, halfway through a renewal. Most teams only learn that from a support ticket, hours later. The fix is not a new tool. It is a few lines in the places where your app already knows who the user is.
Step 1: Pick a Stable User Id
Use your database's primary key or a stable public id, never the e-mail address. E-mails change, get reused, and are personal data in every privacy law you will meet. A random id is meaningless outside your system, which is exactly what you want when it travels to third-party tools.
Decide also which plan field to pass. A plain value such as free, growth or pro is enough. Read it from the same place your billing logic reads it, so the plan on the error is the plan that was true at the time.
Step 2: Identify the User in the Browser
Call your identify function right after login and on every page load where a session already exists, then reset on logout. Without the reset, the next person on a shared computer inherits the previous user's identity.
// after login, or when the app boots with an existing session
function onSignedIn(user: { id: string; plan: string }) {
currentUser = { id: user.id, plan: user.plan }
}
window.addEventListener('error', event => {
reportError({
message: event.message,
stack: event.error?.stack,
userId: currentUser?.id ?? null,
plan: currentUser?.plan ?? null,
})
})
function onSignedOut() {
currentUser = null
}
The same identity should label the whole session, not only errors, so you can see what the customer did before the failure. Session context is what turns "TypeError on checkout" into "this customer clicked Pay twice and saw nothing"; see debugging with session evidence.
Step 3: Stamp Server Requests in Node.js and Express
Many failures never reach the browser as a JavaScript error: the API answers 500 and the page shows a generic message. Attach the user to the server span right after authentication. With OpenTelemetry:
import { trace } from '@opentelemetry/api'
// after your auth middleware has set req.user
app.use((req, res, next) => {
const span = trace.getActiveSpan()
if (req.user && span) {
span.setAttribute('user.id', String(req.user.id))
span.setAttribute('app.user.plan', req.user.plan ?? 'unknown')
}
next()
})
Put it after authentication and before your routes. Any error recorded on that request, including ones caught by your Express error middleware, now carries the user id.
Step 4: Do the Same in Python
In FastAPI, a dependency that resolves the current user is the natural place:
from fastapi import Depends
from opentelemetry import trace
def current_user(token: str = Depends(oauth2_scheme)) -> User:
user = load_user(token)
span = trace.get_current_span()
span.set_attribute("user.id", str(user.id))
span.set_attribute("app.user.plan", user.plan or "unknown")
return user
Django and Flask work the same way: set the attributes in middleware or a before_request hook once the user is known.
Step 5: Keep It Private by Design
Identity data is useful and risky. Four rules keep it on the right side:
- Ids, not e-mails, leave your systems. Server-side, send only the id and plan. If a tool needs a name or e-mail to show you, send it from the browser only after the user is signed in, and only to a tool you have a data agreement with.
- Allow-list traits. Pass only what you decided on (id, e-mail, name, plan). Never forward a whole user object; it will eventually contain a phone number, an address or a token.
- Mask in lists. Show
r…@acme.comin tables and the full value only on a single person's page. - Answer access and erasure requests. You need a way to export everything stored about one id and to blank it. Plan this before the first request arrives, not after.
Step 6: Reach Out Before They Do
Once errors carry ids, an incident review becomes a short list of names. A message like "We saw checkout fail for you at 14:05; it is fixed now, please try again" turns a silent churn risk into goodwill. Reach out when the customer was blocked from a core action, not for every warning.
Step 7: Rank Incidents by Who Was Hit
Sort open problems by distinct affected users, then by plan. Ten failures for one free trial user is less urgent than three failures for three paying customers. This is also how you cut noise: an error that only ever hits test accounts can wait. For more on choosing what deserves an alert, see too many production alerts and finding bugs before users report them.
How Relia Shows Who a Problem Hit
Relia is an observability agent for solo founders and small teams. Identifying users is opt-in, and the setup asks you about it. In the browser:
import { Relia } from 'relia-sdk'
Relia.identify(user.id, { email: user.email, name: user.name, plan: user.plan })
// on logout
Relia.reset()
On the server, Node uses relia.setUser(req, { id, plan }) and Python uses relia.set_user(id, plan="pro"). Server SDKs send only the id and plan, never an e-mail or name.
Only what you pass is kept: id, e-mail, name, plan and up to 12 plain custom traits. Keys that look like secrets or regulated data (password, token, card, phone and similar) are dropped by the SDK and again by the server. Names and e-mails never go to the AI and never appear in alerts: an incident says how many customers were hit and on which plans, for example "38 customers, 9 on Pro". The People page lists each identified person with their sessions and errors, with e-mails masked in the list; opening a profile is recorded in the audit log. Owners and admins can export a person's data or erase their identity.
People is on every plan. The incident explanation, including who it hit, comes with Growth ($19 a month) and Pro ($49 a month); Free finds problems and e-mails you. Every new account starts with 14 days of Pro.
FAQ
Should I send the user's e-mail to my error tracker?
Prefer the id. Send an e-mail only if you need to see it in that tool, only from a signed-in context, and only to a vendor covered by your data agreement. Never put it in alert messages that pass through chat or e-mail providers.
What about errors before the user logs in?
They stay anonymous. If your tool links a browser's earlier anonymous visits once that browser signs in, you get the full story; otherwise accept the gap.
Does tracking the plan create privacy risk?
Little. A plan name is not personal on its own. Keep it to a short fixed value, and record the plan at the time of each session so a later upgrade does not rewrite history.