new-site/api/migrations/077_compliance_check_log.sql
justin c127cdd908 Improve compliance checker UX + add search logging
- Loading message: shows estimated time (30-90 seconds) + rotating status
  updates (RMD, CPNI, USAC, BDC, STIR/SHAKEN, compiling report)
- Timeout increased to 90s (was 60s)
- Error messages: "try again in a few minutes" (not "moments" or "check internet")
- New compliance_check_log table: logs every FCC lookup with FRN, entity,
  IP, user agent, referrer, issue count, severity, response time
- Enables conversion funnel analysis and follow-up

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-06 22:37:29 -05:00

26 lines
1 KiB
SQL

-- 077: Log every FCC compliance check for analytics and follow-up.
-- Tracks who runs checks, what results they see, and whether they convert.
CREATE TABLE IF NOT EXISTS compliance_check_log (
id SERIAL PRIMARY KEY,
frn TEXT NOT NULL,
entity_name TEXT,
ip_address TEXT,
user_agent TEXT,
referrer TEXT,
-- Results summary
total_checks INTEGER DEFAULT 0,
issues_found INTEGER DEFAULT 0,
severity TEXT, -- critical, major, minor, clean
check_slugs TEXT[], -- which services were flagged
-- Timing
response_ms INTEGER, -- how long the API call took
-- Conversion tracking
clicked_order BOOLEAN DEFAULT FALSE,
order_number TEXT, -- if they eventually ordered
-- Metadata
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_check_log_frn ON compliance_check_log(frn);
CREATE INDEX IF NOT EXISTS idx_check_log_created ON compliance_check_log(created_at);