Skip to content

PII scrubbing for ingest and stored telemetry #470

Closed

Description

@unjica

Summary

Telemetry payloads (error messages, stacks, event properties, breadcrumbs/context) can contain emails, tokens, query secrets, and other PII. Today we sanitize text for workspace brief snapshots (brief-snapshot-sanitize.ts), but raw ingest → storage → dashboard keeps data as sent. We need first-class PII scrubbing so hosted cloud and self-hosters can reduce accidental PII retention.

Problem / Motivation

  • Error messages and URLs often embed emails, JWTs, API keys, and auth query parameters.
  • Event properties / error context are free-form JSON and can easily contain sensitive information.
  • Privacy expectations for a telemetry product are high (GDPR, customer trust, compliance requirements).
  • Brief sanitization is a good starting point but does not protect the primary ingest path.
  • Server-side protection should exist even if users bypass the official SDKs.

Proposed Solution (Phased)

Phase 1 — Shared Scrubber + Ingest Defaults

  • Extract / generalize scrubbing from apps/api/src/lib/brief-snapshot-sanitize.ts into a shared module.
  • Enable default server-side scrubbing for all deployments.
  • Self-hosters may disable or extend the default rules if desired.
  • Add default rules for:
    • Emails
    • JWTs
    • Bearer tokens
    • Common API key shapes
    • Sensitive query/assignment parameters
    • Cookie and Authorization headers
  • Apply scrubbing on ingest to:
    • Error messages
    • Stack traces
    • Event properties
    • Error context
    • Breadcrumbs and metadata payloads
  • Recursively scrub nested objects and arrays.
  • Match sensitive keys case-insensitively (email, Email, EMAIL, etc.).
  • Support configurable depth and size limits for recursive scrubbing.
  • Document default behavior and available override mechanisms.

Phase 2 — SDK + Project Controls

  • Optional client-side scrubbing support in @telemetry-tracker/core.
  • SDK scrubbing complements (but never replaces) server-side ingest scrubbing.
  • Project / organization settings for:
    • Enabling/disabling additional scrubbing rules
    • Configuring deny-listed property keys (e.g. email, phone, ssn)
    • Extending default scrubbing patterns
  • Dashboard documentation and privacy copy updates.

Phase 3 (Optional Follow-ups)

  • Backfill / one-off scrub job for existing rows (opt-in; potentially expensive).
  • Credit-card and phone-number heuristics with false-positive guidance.
  • Audit logs when scrubbing configuration changes.

Default Architecture

SDK
 ↓
(optional)
client-side scrub
 ↓
network
 ↓
API ingest
 ↓
(always)
server-side scrub
 ↓
database
 ↓
dashboard

Server-side scrubbing should remain the source of truth. SDK-level scrubbing provides an additional privacy layer but should never be relied upon exclusively.

Redaction Strategy

Prefer stable placeholders over a generic [REDACTED] value.

Examples:

{
  "email": "[email]",
  "token": "[token]",
  "authorization": "[bearer-token]",
  "apiKey": "[api-key]",
  "cookie": "[cookie]"
}

This preserves useful debugging context while ensuring sensitive values are never stored.

Out of Scope (Initially)

Acceptance Criteria (Phase 1)

  • Known PII patterns are redacted before telemetry data is stored.
  • Default server-side scrubbing is enabled for all deployments.
  • Nested objects and arrays are scrubbed recursively.
  • Stable placeholders are used ([email], [token], [api-key], etc.).
  • Sensitive keys are matched case-insensitively.
  • Unit tests cover:
    • Message scrubbing
    • Stack trace scrubbing
    • Nested properties/context payloads
    • Known token and API key patterns
    • Ingest integration
  • Brief sanitization either reuses the shared scrubber or remains consistent with it.
  • Documentation describes default scrubbing behavior and available configuration options.
  • pnpm lint && pnpm test && pnpm build pass.
  • Database migration only if project/organization settings require schema changes.

Base Branch

Open PRs against develop. See CONTRIBUTING.md and docs/RELEASE.md.

Activity

  1. self-assigned this
    on Jul 16, 2026
  2. added
    enhancement
    sdk
    api
    on Jul 16, 2026
  3. added a commit that references this issue on Jul 16, 2026
  4. unjica commented on Jul 16, 2026

    @unjica
    CollaboratorAuthor

    Closing out #470 after Phases 1–3 (ingest defaults, SDK + project controls, phone/card heuristics, audit logs, session email scrubbing, historical backfill).

    Follow-ups tracked separately:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

apienhancementsdk

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions