Skip to content

Competitors & Topics: align visibility numbers with the prompt-level rate #493

Closed

Description

@gkhngyk

Problem

Insights now leads with the prompt-level Visibility Rate (#490), but two surfaces still display the all-rows score average, so the same entity shows contradictory numbers depending on the page:

  1. Competitors page (web/src/app/[locale]/(dashboard)/dashboard/competitors/page.tsx) — the competitor cards show entry.avgVisibilityScore as a percentage. A competitor at 57% on the Insights leaderboard can read ~5% here, side by side in the same product.
  2. Topics pages (web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsx and topics/[id]) — the Best/Weakest topic KPIs, the topic table, the CSV export and the topic detail's competitor table all show per-topic score averages, diluted by platform count exactly like the old brand-level number.

Fix

Competitors page — pure UI mapping, no backend change: CompetitorComparisonEntry already carries visibilityRate, visiblePrompts and promptCount since #490. Show the rate on the cards (with appeared in X/Y prompts, mirroring the Insights leaderboard rows) instead of the score average.

Topics — compute a per-topic rate: distinct prompts in the topic with at least one answer mentioning or citing the brand ÷ distinct prompts in the topic that produced results in the window (appeared = mention_count > 0 OR citation_count > 0, chatgpt-shopping excluded — same rules as visible_prompt_stats, see web/src/lib/actions/tracking.ts). web/src/lib/actions/topic.ts already fetches the raw rows with prompt_id, mention_count and citation_count, so the rate is computable in the existing aggregation loop — no new RPC. Use it for the topic table's visibility column, the Best/Weakest KPIs and the CSV export; the topic detail's competitor table should apply the same same-denominator rule (competitor rates divide by the topic's prompt count).

Keep the score average available where it adds depth (e.g. secondary column or tooltip) but the headline number on both surfaces must be the rate, matching Insights for the same window and filters.

Acceptance criteria

  • A competitor's percentage on the Competitors page equals its Insights leaderboard rate for the same period.
  • Topic visibility percentages are prompt-level rates; a topic whose every prompt surfaced the brand reads 100%, one with no appearances reads 0%.
  • CSV export headers/values reflect the new rate (rename the column if needed).
  • Brand and competitor rates on any topic surface share the same denominator.
  • yarn lint, yarn typecheck, yarn format:check pass from web/.

Getting started

Depends on #490 — start after it merges. See CONTRIBUTING.md for setup. Comment here to claim the issue before opening a PR.

Activity

  1. added
    enhancement
    on Jul 20, 2026
  2. gkhngyk commented on Jul 24, 2026

    @gkhngyk
    ContributorAuthor

    Status update — about half of this shipped in #499: the Topics overview page now uses the prompt-level rate everywhere (table column, Best/Weakest KPIs and the CSV export's visibility_rate column).

    Remaining scope for this issue:

    1. Competitors page cards (competitors/page.tsx) — still render entry.avgVisibilityScore; switch the headline to visibilityRate with an appeared in X/Y prompts sub-line. Pure UI mapping — the entry already carries visibilityRate, visiblePrompts and promptCount.
    2. Topic detail page (topics/[id]/page.tsx) — the headline KPI still shows summary.avgVisibilityScore and the Competitor Comparison table still shows per-competitor score averages. Both should move to the rate, with brand and competitor rates sharing the same denominator (the topic's prompt count).

    #499 and the Insights leaderboard are working reference implementations of the exact pattern. Comment here to claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions