@lukethegenius/sentry-pii-scrub
v0.1.0
Published
Scrub PII (IBAN, Italian codice fiscale, email, sensitive keys) from Sentry events before they're sent.
Readme
@lukethegenius/sentry-pii-scrub
Scrub PII (IBAN, Italian codice fiscale, email, and a set of sensitive object
keys) from Sentry events in beforeSend, plus a filter for noisy
console.error-sourced events that keeps only recovered React hydration errors.
Install
npm install @lukethegenius/sentry-pii-scrub @sentry/typesUsage
import { scrubSentryEvent, isNonHydrationConsoleEvent, scrubText } from '@lukethegenius/sentry-pii-scrub'
Sentry.init({
beforeSend(event) {
if (isNonHydrationConsoleEvent(event)) return null // drop noisy console.error events
return scrubSentryEvent(event)
},
})
scrubText('IBAN: IT60X0542811101000000123456') // "IBAN: [IBAN_REDACTED]"scrubSentryEvent regex-scrubs message/exception/breadcrumb text and redacts a fixed set of sensitive object keys (iban, codice_fiscale, phone, ...) anywhere in extra/contexts/request.data.
