Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
fix(web): populate the Citations Region filter from observed data (#622)
Patel Dhrit6debfb234331
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsxindex cb35826db..b980639d6 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx@@ -857,7 +857,6 @@ export default function CitationsPage() {// Surface filter options from the observed models/regions.const platformOptions = buildPlatformOptions(overview.rows);- const regions = new Set<string>();setAvailablePlatforms((prev) =>Array.from(new Map(@@ -865,9 +864,11 @@ export default function CitationsPage() {).values(),).sort((a, b) => a.label.localeCompare(b.label) || a.value.localeCompare(b.value)),);- if (regions.size > 0) {+ if (overview.availableRegions.length > 0) {setAvailableRegions((prev) =>- Array.from(new Set([...prev, ...regions])).sort((a, b) => a.localeCompare(b)),+ Array.from(new Set([...prev, ...overview.availableRegions])).sort((a, b) =>+ a.localeCompare(b),+ ),);}} catch {diff --git a/web/src/lib/actions/citations.ts b/web/src/lib/actions/citations.tsindex 2e243cdcf..5a9743204 100644--- a/web/src/lib/actions/citations.ts+++ b/web/src/lib/actions/citations.ts@@ -75,6 +75,8 @@ export interface CitationsOverview {avgCitationsPerResult: number;};sourceTypeBreakdown: CitationsSourceBreakdown[];+ /** Distinct regions observed on results in the scanned (filtered) window (#598). */+ availableRegions: string[];}// ─── Helpers ──────────────────────────────────────────────────────────────────@@ -273,6 +275,7 @@ export async function getCitationsOverview(const articleTypeCache = new Map<string, ArticleType | null>();let totalCitations = 0;+ const regionsSeen = new Set<string>();const aggregateResult = (result: OverviewResultRow) => {const citations = Array.isArray(result.citations) ? result.citations : [];@@ -349,7 +352,10 @@ export async function getCitationsOverview(filters,'id, prompt_id, platform, model_used, region, created_at, citations, citation_count',(batch) => {- for (const result of batch) aggregateResult(result);+ for (const result of batch) {+ if (result.region) regionsSeen.add(result.region);+ aggregateResult(result);+ }},);@@ -419,6 +425,7 @@ export async function getCitationsOverview(totalResults > 0 ? Math.round((totalCitations / totalResults) * 10) / 10 : 0,},sourceTypeBreakdown,+ availableRegions: Array.from(regionsSeen).sort(),};}