What problem does it solve? Security violations like XSS attempts, CSRF failures, and rate limit abuse often go unrecorded or are logged inconsistently with unsanitized PII, making incident response and compliance auditing difficult. ## Core Features & Use Cases - Centralized Security Logger: Use the logSecurity function in convex/lib/securityLogger.ts to record events with automatic PII sanitization of emails, names, and IDs. - Typed Event Taxonomy: Classify events with 19 predefined SecurityEventType values (xss_attempt, csrf_validation_failed, rate_limit_exceeded, prompt_injection_attempt) and four severity levels. - Attack Detection Patterns: Apply built-in regex patterns for XSS, SQL injection, and prompt injection detection before logging violations. - Use Case: When a user submits content containing a script tag, detect the XSS pattern, log a critical xss_attempt event with a truncated payload, and surface it on the admin security dashboard at /dashboard/security. ## Quick Start Add security event logging to my Convex mutation so XSS attempts are detected, sanitized, and recorded to the securityEvents table.