Skip to content

fix(insights): CSV export writes platform display names, not slugs - #234

Merged
gkhngyk merged 1 commit into
mainfrom
fix/insights-csv-platform-labels
Jun 11, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/insights-csv-platform-labels

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Closes #187

Problem

On /dashboard/insights, Export CSV wrote the raw platform slug (e.g. chatgpt-web, google-aio) in the platform column, while the charts and tables everywhere else show display names (ChatGPT, Google AI Overview). handleExportCsv mapped platform: r.platform directly.

The label map existed but lived locally — and was in fact duplicated in both _charts.tsx and page.tsx — so the export couldn't reach it.

Fix

  • New shared module web/src/config/platform-labels.ts exporting PLATFORM_LABELS — the union of the two local copies, every existing label preserved (generic slugs, the tracked *-web/google-aio/google-aimode slugs, plus the handful of model-slug fallback labels the charts already carried).
  • _charts.tsx and insights/page.tsx now import from it; both local definitions removed.
  • CSV export maps platform: PLATFORM_LABELS[r.platform] ?? r.platform — falls back to the raw slug for unknown platforms so nothing disappears.

Verification

  • yarn typecheck — clean
  • yarn lint — clean (the one groupResultsByPrompt warning is pre-existing on main, unrelated)
  • yarn format:check — clean
  • yarn build — compiles; /[locale]/dashboard/insights and /insights/[id] render

Follow-up (out of scope, noted)

There are three more copies of essentially the same map, with minor label drift between them, in insights/[id]/page.tsx, prompts/[id]/page.tsx, and citations/page.tsx (e.g. gemini-web is Gemini in some, Google Gemini in others; google-ai-overviews is Google AI vs Google AI Overview). I kept this PR scoped to the export bug rather than silently changing labels on those unrelated pages — happy to follow up with a second PR that migrates all three onto the shared module if wanted.

The insights Export CSV wrote the raw platform slug (e.g. chatgpt-web) in the
platform column, while the charts and tables showed display names (ChatGPT).
The label map lived locally in both _charts.tsx and page.tsx and the export
never used it.

Centralize the map into web/src/config/platform-labels.ts (union of both
local copies, all existing labels preserved) and import it in both files.
The CSV row now maps platform via PLATFORM_LABELS[r.platform] ?? r.platform,
so unknown slugs still fall through to the raw value.
@gkhngyk
gkhngyk merged commit 07ba4c8 into main Jun 11, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the fix/insights-csv-platform-labels branch June 11, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(insights): CSV export writes platform slugs instead of display names

1 participant