Repository navigation
feat(reports): Simple Reports MVP — immutable snapshot reports with AI summary and vector PDF export - #390
Merged
Conversation
…I executive summary - reports table (00023) with org-membership RLS, immutable JSONB payload - POST /api/reports/summary: AI executive summary from the metric snapshot - createReport gathers insights/SoV/competitors/citations via existing actions - Reports library page: generate dialog (7d/30d/90d/custom) + list/view/delete - Report detail page renders fully from the saved payload (no live queries) - Sidebar nav item + en.json strings PDF download ships separately once the report view is validated.
…source types, best/worst prompts - payload gains visibilityTrend + promptPerformance (best/worst 5 by avg visibility, aggregated over the report's own [dateFrom, dateTo] window) - render the platformBreakdown and sourceTypeBreakdown data that was already snapshotted but never displayed - new sections guard on their payload field so pre-existing (immutable) reports render without them
… fan-out - trend bars now sit in full-height column wrappers (bare percentage heights on flex items are unreliable) and normalize to the window's peak score so low-visibility periods still read as a curve - remove the Platform Breakdown section per review - new Query Fan-out section: top 10 observed sub-queries in the report period (windowed to [dateFrom, dateTo], mirroring fanout.ts grouping)
Replace the hand-rolled div bars with the insights page's TrendChart (same VisibilityTrendPoint shape the payload already stores) — proper area chart with adaptive axis and the avg-competitor overlay, loaded client-only via next/dynamic like insights does.
… brands Two resolution killers stacked up: - getVisibilityTrend rounded daily averages to integers, crushing the realistic 0.3-1.5 band into a constant 1 (both brand and competitor series) — keep one decimal via roundTo1, matching getInsightsSummary - TrendChart pinned its Y axis to [0, 100]; switch it to the existing niceVisibilityYMax adaptive ceiling the other charts already use
Replace the html2canvas screenshot approach (blurry, layout shifts, raster text) with a real vector PDF document: selectable text, exact layout, smart page breaks, trend chart drawn with PDF SVG primitives, footer with page numbers. Static Inter TTFs are embedded from /public/fonts because the built-in Helvetica can't render Turkish characters (ş, ğ, ı) that appear in brand names and prompt texts. Renderer + document load on demand.
- remove the sidebar entry — Reports stays reachable at /dashboard/reports while we keep the feature quiet for now - drop the Source Type Breakdown bars from the citations card and the PDF (data stays in the payload, so re-enabling is a render-only change)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simple Reports MVP: generate an immutable, shareable AI-visibility report for a brand over a chosen period, with an AI-written executive summary and a true vector PDF export.
Data & backend
reportstable (migration00023, already applied to the hosted DB) — immutable JSONB payload, org-membership RLS mirroringsite_audits; no UPDATE policy on purpose.supabase/schema.sqlregenerated.POST /api/reports/summary— turns the metric snapshot into a 1–2 paragraph executive summary (content.js pattern:resolveModel+ onegenerateText,assertBrandAccess-guarded).Report generation (
web/src/lib/actions/reports.ts)createReportgathers insights KPIs, share of voice, competitor comparison, citations overview, daily visibility trend, best/worst prompts, and observed query fan-out — all in parallel — then saves the snapshot + AI summary as one payload. Prompt performance and fan-out aggregate over the report's own[dateFrom, dateTo]window (the existing helpers anchor to "now", which lies for historical ranges).getReports/getReport/deleteReport.UI
/dashboard/reports— generate dialog (7d/30d/90d/custom presets, optional title) + report library table (view/delete)./dashboard/reports/[id]— renders purely from the saved payload: executive summary, KPI cards with deltas, Recharts visibility trend (reuses the insightsTrendChart), SoV bars, competitor leaderboard, best/weakest prompts, query fan-out, top citation sources. Sections added after launch guard on their payload field, so older (immutable) reports render without them.@react-pdf/renderer(loaded on demand): selectable text, exact layout, page numbers, trend chart drawn with PDF SVG primitives. Static Inter TTFs are embedded because the built-in Helvetica can't render ş/ğ/ı in brand names and prompt texts./dashboard/reportsdirectly.Fixes that fell out of this
getVisibilityTrendrounded daily averages to integers, flattening realistic sub-2% averages into a constant1; now keeps one decimal (roundTo1).TrendChartpinned its Y axis to[0, 100]; it now uses the existingniceVisibilityYMaxadaptive ceiling.Related issue
—
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
/dashboard/reports(no sidebar entry yet).cd server && npm test(99 passing).Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)