redactPii()
function redactPii<T>(data: T): T;
Redact PII from a log payload before it is sent to diagnostics.
Redaction is key-aware:
- Sensitive keys (email, ssn, password, token, …) — entire value replaced.
- Free-text keys (
message,stack,description) — inline PII regexes. - Base schema keys and
context— pass through unchanged. - All other keys — pass through unchanged (structured fields such as
duration).
Returns the original reference when nothing changed (copy-on-write).
Type Parameters
T
T
Parameters
data
T
Object to redact.
Returns
T
Redacted object, or the same reference when no redaction was needed.