feat: add PII filtering for UTM parameters#11
Conversation
Detect and filter personally identifiable information (emails, phone numbers) from UTM parameter values at capture time. Supports reject mode (discard values) and redact mode (replace with [REDACTED]), optional strict allowlist patterns, and an onPiiDetected callback. Disabled by default. 🤖 Generated with [Nori](https://nori.ai) Co-Authored-By: Nori <contact@tilework.tech>
WalkthroughAdds a comprehensive PII filtering feature to the UTM parameter tracking library. Introduces detection patterns (email, phone formats), multiple filtering modes (reject/redact), allowlist support, and optional callbacks. Integrates into the capture pipeline to filter PII values after sanitisation, including configuration defaults, type definitions, and extensive test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Capture as captureUtmParameters()
participant Parse as Parse & Extract
participant Allow as Allowlist Filter
participant Sanitize as Sanitisation
participant PII as PII Filter
participant Format as Format Keys
participant Result as Result
App->>Capture: url + options (piiFiltering)
Capture->>Parse: Extract UTM parameters
Parse->>Allow: Filter by allowedParameters
Allow->>Sanitize: Apply sanitisation
Sanitize->>PII: Apply PII filtering<br/>(enabled check)
PII->>PII: Detect PII via patterns<br/>Check allowlist
PII->>PII: Invoke callback if PII found<br/>(reject/redact mode)
PII->>Format: Filtered parameters
Format->>Result: Apply key formatting<br/>(camelCase, etc.)
Result->>App: Return utmParameters
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Comment |
Summary
🤖 Generated with Nori
reject(discard values containing PII) andredact(replace with[REDACTED]), plus an optional strict allowlist patternpiiFiltering: { enabled: false }) — zero impact on existing usersWhat changed
src/core/pii-filter.tswithdetectPii,filterValue,filterParamsPiiPatternandPiiFilterConfiginsrc/types/index.tsDEFAULT_PII_PATTERNS(email, phone_international, phone_uk, phone_us) andDEFAULT_PII_FILTER_CONFIGmergePiiFilterConfig, plus validation for pattern objects,allowlistPattern, andonPiiDetectedpiiFilteringconfig tocaptureUtmParameterssrc/core/index.ts,src/config/index.ts,src/index.tsdocs.mdfilesTest Plan
detectPii,filterValue,filterParams(reject/redact modes, allowlist, callback, callback resilience, false positive checks, disabled patterns, edge cases)Share Nori with your team: https://www.npmjs.com/package/nori-ai
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests