Privacy Considerations in Error Tracking
You'll learn how to prevent sensitive user data from leaking into error reports by scrubbing it at the source using configuration and hooks.
Error tracking tools like Sentry are powerful, but they can accidentally capture private information—passwords, credit card numbers, personal identifiers, API tokens—in error messages, stack traces, breadcrumbs, or user context. Since error data often gets stored on third-party servers and viewed by multiple team members, this creates serious privacy and compliance risks (GDPR, HIPAA, etc.).
The Core Problem
When an error occurs, tracking tools capture everything they can find: URLs, form data, cookies, local storage, custom context you've added. Without careful filtering, you might log something like:
Error: Payment failed for card ending in 4242
Context: { email: "user@example.com", ssn: "123-45-6789" }
The Solution: Proactive Scrubbing
Use beforeSend hooks and configuration options to sanitize data before it leaves the browser:
Sentry.init({
dsn: 'your-dsn-here',
beforeSend(event, hint) {
// Remove sensitive user context
if (event.user) {
delete event.user.email;
delete event.user.ip_address;
}
// Scrub breadcrumbs for password fields
if (event.breadcrumbs) {
event.breadcrumbs = event.breadcrumbs.map(crumb => {
if (crumb.message && crumb.message.includes('password')) {
return { ...crumb, message: '[Filtered]' };
}
return crumb;
});
}
return event;
}
});
You can also configure automatic scrubbing for common patterns (credit cards, SSNs) and prevent capturing specific HTTP headers or cookies entirely.
Key Takeaway: Always scrub personally identifiable information (PII) from error reports using beforeSend hooks and configuration filters—never trust default capture settings when privacy compliance matters.