Skip to content

feat(api): ingest PII scrubbing (Phase 1 of #470) - #472

Merged
unjica merged 2 commits into
developfrom
feat/pii-scrubbing-ingest
Jul 16, 2026
Merged

unjica merged 2 commits into
developfrom
feat/pii-scrubbing-ingest

Conversation

@unjica

@unjica unjica commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements Phase 1 of #470: default server-side PII scrubbing on the ingest write path.

  • Shared scrubber (pii-scrub.ts) with stable placeholders ([email], [token], [bearer-token], [api-key], …)
  • Applied after Zod parse on /ingest/error, /ingest/event, and /ingest/batch (events only — same helper as /event)
  • Scrubs before computeFingerprint + Prisma writes so redacted values are stored and grouped
  • scrubPiiText preserves stack newlines (no brief whitespace collapse; brief still collapses after reuse)
  • Default enabled when unset; self-host override TELEMETRY_INGEST_PII_SCRUB=false
  • Depth/node limits never throw or drop ingest; remainder pass still redacts nested keys/strings
  • Brief sanitization reuses scrubPiiText
  • Docs: docs/PII-SCRUBBING.md, .env.example, DEPLOYMENT.md, README, CHANGELOG

Implements Phase 1 of #470.

Intentionally deferred (later phases of #470)

  • Breadcrumbs ingest scrubbing (no breadcrumbs ingest yet)
  • session.user_email column rewriting
  • SDK-side scrubbing (@telemetry-tracker/core)
  • Project / organization scrubbing controls

Verification (pre-PR)

Check Result
Stack newlines preserved / no brief collapse in scrubPiiText Covered by unit tests
Scrub before fingerprint /error calls scrubIngestErrorFields then computeFingerprint; test asserts emails do not affect fingerprints
/batch consistent with /event Both use scrubIngestEventFields (batch has no error payloads)
TELEMETRY_INGEST_PII_SCRUB=false self-host override, default on Docs + isIngestPiiScrubEnabled tests
Limit exhaustion safe No throw; nested PII still scrubbed in remainder pass
Non-sensitive payloads unchanged Unit tests for clean messages/properties

Test results

pnpm lint                          ✅
pnpm --filter api test             ✅  601 passed | 58 skipped
pnpm --filter dashboard test       ✅  71 passed
pnpm --filter api build            ✅
pnpm --filter dashboard build      ✅
/review-bugbot (vs develop)        ✅ finding fixed (nested scrub after limits)

Focused scrubber suites: pii-scrub.test.ts (20), ingest-pii-scrub.test.ts (8), brief-snapshot-sanitize.test.ts (11).

Test plan

  • Unit tests for message/stack/properties/context + fingerprint + limit fallback
  • Lint / API + dashboard tests / build
  • Spot-check POST /ingest/error with an email in message → stored as [email]
  • Spot-check TELEMETRY_INGEST_PII_SCRUB=false stores raw email
  • Confirm Issues grouping collapses distinct emails into one fingerprint

Made with Cursor

unjica and others added 2 commits July 16, 2026 20:11
Default server-side redaction for error messages/stacks/context and event
properties; shared scrubber reused by brief sanitization. Disable with
TELEMETRY_INGEST_PII_SCRUB=false for self-host overrides.

Implements Phase 1 of #470.

Co-authored-by: Cursor <[email protected]>
When maxDepth/maxNodes are exceeded, continue a key/string remainder pass
so crafted deep payloads cannot persist raw emails under nested keys.

Co-authored-by: Cursor <[email protected]>
@unjica
unjica merged commit 3cd323c into develop Jul 16, 2026
5 of 6 checks passed
@unjica
unjica deleted the feat/pii-scrubbing-ingest branch July 16, 2026 18:19
@unjica unjica added this to the v1.12.x — PII scrubbing milestone Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant