Privacy-Focused Error Tracking: What to Collect and Verify

Apr 22, 2026
6 min read
TL;DR

Design minimal error records, inspect sensitive fields, verify grouping and access, and test retention and collection controls with synthetic data.

Privacy-Focused Error Tracking: What to Collect and Verify

A person studies code and a chart on two monitors, with lock and shield symbols on the wall.

The short answer: send the smallest error record that still lets a developer fix the bug, scrub free text before it leaves the browser, and prove it with a planted fake value. In practice that means:

  1. Keep the error type, a scrubbed message, the stack, a route pattern and, if you set one, the release.
  2. Drop full URLs with query strings, request and response bodies, headers and form values.
  3. Scrub messages and stacks by pattern, not only by field name, because emails and tokens hide inside free text.
  4. Throw a synthetic error containing a fake email and token, and confirm neither reaches the stored event.
  5. Limit who can read errors and how long they are kept.

Error telemetry helps developers diagnose failures, but messages, URLs, request objects and stack traces can contain sensitive or identifying values. Design a minimal error record and verify it before sending application data to any collector.

Decide field by field

FieldKeep?Why
Error type, such as TypeErrorKeepGroups errors without revealing data
MessageKeep after scrubbingMessages often interpolate values: Invalid email jane@example.com
Stack traceKeep after scrubbingNeeded for diagnosis; can contain URLs with query strings
Release or build versionKeepTies the error to a deploy
Route pattern, such as /accounts/:idKeepShows where it failed without the account ID
Full URL with query stringDropReset links, magic links and search pages carry tokens and emails
Request and response bodiesDropForm values, addresses, payment details
HeadersDropAuthorization and Cookie carry credentials
User or account IDOnly if neededUse an opaque application ID, not an email

The OWASP Logging Cheat Sheet describes data to exclude or protect, including access tokens, passwords and sensitive personal data. It also covers validation, sanitization, access and disposal. Do not turn that guidance into a claim that every logging purpose prohibits every identifier in all circumstances.

Scrub free text before you send it

Redacting by field name misses the common case: a value interpolated into a message or a URL inside a stack trace. Scrub the text itself with a few patterns, then send the cleaned error. With Databuddy's SDK, trackError() accepts an Error and records its message, type and stack (tracker reference):

import { trackError } from "@databuddy/sdk";

const PATTERNS: [RegExp, string][] = [
	[/[\w.+-]{1,64}@[\w-]{1,63}(?:\.[\w-]{1,63})+/g, "[email]"],
	[/\b(Bearer|Basic)\s+[\w.~+/-]+=*/gi, "$1 [token]"],
	[/\beyJ[\w-]+\.[\w-]+\.[\w-]+/g, "[jwt]"],
	[/\b(\w*(?:token|key|code|password|secret|email)\s*[=:]\s*)[^&#\s,]+/gi, "$1[redacted]"],
];

function scrub(text: string): string {
	return PATTERNS.reduce(
		(out, [pattern, replacement]) => out.replace(pattern, replacement),
		text
	);
}

export function reportError(error: unknown, context: string) {
	const original = error instanceof Error ? error : new Error(String(error));
	const clean = new Error(scrub(original.message));
	clean.name = original.name;
	clean.stack = original.stack ? scrub(original.stack) : undefined;
	trackError(clean, { context });
}

Call reportError() from catch blocks and error boundaries. Extend the patterns with the identifiers your product uses, such as order numbers or phone formats. Patterns reduce exposure; they do not catch every value, which is why the planted-value test below matters.

Automatic capture works differently. With autocapture: { errors: true }, Databuddy records uncaught errors and rejected promises with their message, type, stack, source file, line and column, the page path, and the visitor and session IDs, before your code can scrub them. Turn it on only after you have checked that your messages do not carry sensitive values, or report errors through a scrubbing function like the one above. The page path follows your maskPaths patterns, so a /users/* pattern records /users/* instead of /users/42.

Inspect both the browser and collector

Generate a synthetic error containing recognizable fake sensitive values and confirm they are removed or transformed as intended before persistence. Inspect network payloads as well as the final event. Include nested properties, query parameters, headers and exception messages in the test.

For example, throw new Error("Signup failed for qa-planted@example.com token=PLANTED123") on a test page, then search the network request and the stored event for qa-planted and PLANTED123. Both searches should come back empty.

Client filtering can reduce collection, while collector controls provide another enforcement point. Verify the controls your system actually offers rather than assuming every SDK has the same sanitization API. A browser collection failure should not make the underlying application fail.

Review identifiers and IP handling independently

Hashing, truncation and rotation can reduce linkability, but do not automatically establish anonymisation or eliminate all data-protection requirements. The EDPB distinguishes these concepts. Another persistent identifier or custom property can still link events even when one field rotates.

For Databuddy, inspect the documented collection model and your own error properties. Avoid a blanket promise that no raw IP or identifying value can ever appear anywhere in an application's infrastructure, logs or supplied payloads.

Test grouping without collecting unnecessary context

Trigger the same synthetic exception twice and a materially different one once. Check whether grouping is useful for diagnosis and whether it depends on a field you should remove. An error group, a visitor count and a user profile represent different concepts.

Scrubbing helps grouping too. Invalid email jane@example.com and Invalid email sam@example.com become one message, Invalid email [email], instead of one group per visitor.

Use the Databuddy error workflow to evaluate investigation alongside website events and performance. Optional identification and richer context should be deliberate decisions, not accidental consequences of serializing a whole request.

Choose and verify the lifecycle controls

Set retention according to the diagnostic purpose, applicable obligations and the organization's review. This guide does not prescribe a universally lawful 30-, 90- or 365-day period. Include exports, backups and downstream destinations in the procedure.

Test access with a restricted synthetic teammate, verify the supported deletion mechanism and confirm what happens when collection or storage is unavailable. Handle the relevant collection choices and opt-out signals under the policy established for the deployment; a minimal payload does not make every signal a no-op.

Keep a repeatable acceptance record

  1. Record allowed fields and recognizable synthetic values that must be removed.

  2. Inspect sent, received and stored representations.

  3. Verify grouping and useful diagnosis with the minimized record.

  4. Test access, retention/deletion and relevant collection decisions.

  5. Repeat the checks when optional features, sources or destinations change.

The privacy review worksheet helps document the processing arrangement. The AI-assisted analytics guide covers the additional review when connected assistants can access diagnostic data.