Files
breakpilot-compliance/backend-compliance/migrations/116_banner_ab_testing.sql
T
Benjamin Admin 965af3a34c feat: A/B Testing + Compliance Report PDF (F5 + F8)
F5: A/B Testing for Consent Rate
- Migration 116: banner_variants table + variant tracking in audit log
- BannerABService: deterministic sticky bucketing via device hash,
  chi-squared significance testing, variant CRUD
- banner_ab_routes: 6 endpoints (CRUD + stats + assign)
- ABTestPanel.tsx: variant creation, traffic sliders, opt-in comparison
  chart with winner/significance badges
- New "A/B-Test" tab in cookie-banner page

F8: Compliance Report PDF
- CompliancePDFGenerator: reportlab-based A4 PDF covering all modules
  (Company Profile, TOM, VVT, DSFA, Risks, Vendors, Incidents,
  Reviews, Consents, Roles)
- compliance_report_routes: GET /compliance/report/pdf
- "Compliance-Report herunterladen" button on SDK dashboard

[migration-approved]

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-03 21:42:50 +02:00

32 lines
1.1 KiB
SQL

-- Migration 116: Banner A/B Testing
-- Enables variant testing for consent rate optimization
CREATE TABLE IF NOT EXISTS compliance_banner_variants (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
site_config_id UUID NOT NULL,
variant_name VARCHAR(100) NOT NULL,
variant_key VARCHAR(20) NOT NULL,
traffic_percent INT NOT NULL DEFAULT 50 CHECK (traffic_percent BETWEEN 0 AND 100),
is_control BOOLEAN NOT NULL DEFAULT FALSE,
banner_title TEXT,
banner_description TEXT,
position VARCHAR(20),
style VARCHAR(20),
primary_color VARCHAR(20),
show_decline_all BOOLEAN,
theme_overrides JSONB DEFAULT '{}',
is_active BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(site_config_id, variant_key)
);
CREATE INDEX IF NOT EXISTS idx_banner_variants_site
ON compliance_banner_variants(site_config_id);
ALTER TABLE compliance_banner_consent_audit_log
ADD COLUMN IF NOT EXISTS variant_id UUID;
ALTER TABLE compliance_banner_consent_audit_log
ADD COLUMN IF NOT EXISTS variant_key VARCHAR(20);