Skip to main content

User Identification

Link errors to specific users to understand who is affected.

Identifying Users

After a user logs in:

Syntropy.identify({
id: 'user-123', // Required: unique user ID
email: 'user@example.com', // Optional
name: 'John Doe', // Optional

// Custom properties
plan: 'pro',
company: 'Acme Inc',
});

Clearing User Data

On logout:

Syntropy.reset();

This clears:

  • User identification
  • Session data
  • Global tags and extras

User Context in Errors

When an error occurs, user data is attached:

{
"type": "error",
"payload": {
"message": "Cannot read property 'id' of undefined"
},
"user": {
"id": "user-123",
"email": "user@example.com",
"name": "John Doe",
"plan": "pro"
}
}

Server-Side Identification

For server SDKs, identify users per-request:

Express

app.use((req, res, next) => {
if (req.user) {
Syntropy.setUser({
id: req.user.id,
email: req.user.email,
});
}
next();
});

Node.js with Async Context

import { Syntropy, runWithContext } from '@eclosion-tech/syntropy-node';

app.use((req, res, next) => {
runWithContext(
{ user: req.user },
() => next()
);
});

Privacy Considerations

Don't Send PII You Don't Need

// Good - just the ID
Syntropy.identify({ id: 'user-123' });

// Avoid if not needed
Syntropy.identify({
id: 'user-123',
ssn: '123-45-6789', // Don't do this!
creditCard: '...', // Don't do this!
});

Scrub Sensitive Data

Syntropy.init({
projectId: 'your-project-id',
beforeSend: (event) => {
// Scrub sensitive fields
if (event.user) {
delete event.user.ssn;
delete event.user.creditCard;
}
return event;
},
});

Affected Users

In the Syntropy dashboard, you can see:

  • How many unique users are affected by an issue
  • Which specific users hit an error
  • Error frequency per user
  • User environment details