Skip to content

fix(insights): don't floor the visibility score to 0 - #283

Merged
gkhngyk merged 1 commit into
mainfrom
fix/visibility-score-rounding
Jun 21, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/visibility-score-rounding

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The Insights Visibility Score card could show 0 for a brand that clearly has mentions and citations (reported on a brand showing 67 mentions / 11 citations but a score of 0).

Root cause — not a calculation bug. The per-row visibility scores are correct (a row with a mention is always non-zero; verified 0 rows with a mention-but-zero-score). The headline number is the average score across all prompt runs:

avgVisibilityScore = Math.round(sum_visibility / total_results)

total_results is every prompt × platform × region run, the vast majority of which don't mention the brand (score 0). For the reported brand: 1370 / 3473 = 0.39, and Math.round(0.39) = 0. The brand genuinely appears in only ~23 of 3473 answers (~0.7%), so its average visibility is a real ~0.4/100 — but flooring it to 0 reads like the metric is broken.

Fix (display only — metric meaning unchanged). Keep one decimal for the brand-level visibility score and its period-over-period delta, via a small roundTo1 helper. The denominator and semantics are untouched (still an average over all runs); small-but-nonzero visibility now shows as 0.4 instead of 0. Whole-number scores still render cleanly (e.g. 64, not 64.0).

Scope kept tight to the Insights summary headline + its delta. The same Math.round(sum/count) pattern exists for per-platform/competitor/topic averages — happy to extend if you want full consistency, but left out here to keep the change focused on the reported card.

Related issue

None — reported directly.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open Insights for a brand that appears in a small fraction of answers (e.g. brand with ~0.4 average).
  2. The Visibility Score card now reads 0.4 instead of 0; mentions/citations are unchanged.
  3. A brand with whole-number average still shows a clean integer (e.g. 64).
  4. The delta badge shows fractional pts where applicable (e.g. +0.1 pts).

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

The headline Visibility Score is the average score across all prompt runs
(brand-mentioned or not). For a brand that appears in only a small fraction of
AI answers, that average is a genuine sub-1 value (e.g. 0.4) — but it was passed
through Math.round, collapsing it to a flat "0" that read as a broken metric
next to non-zero mention/citation counts.

Keep one decimal for the brand-level visibility score and its period-over-period
delta via a small roundTo1 helper. The metric's meaning is unchanged (still an
average over all runs); only the display precision is fixed so small-but-nonzero
visibility is no longer shown as 0. Whole-number scores still render without a
trailing .0.
@gkhngyk
gkhngyk merged commit 0528049 into main Jun 21, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the fix/visibility-score-rounding branch June 21, 2026 13:54
@gkhngyk gkhngyk mentioned this pull request Jul 6, 2026
5 tasks done
gkhngyk added a commit that referenced this pull request Jul 6, 2026
Bump all packages + docker-compose image tags to 0.1.5 and write the
CHANGELOG for everything merged since 0.1.4 (#283–#342): the Query Fan-out
capture + tab, Citations Competitor Gaps, brand pause, Site Audit MCP
tools, sortable All Prompts, structured logging Phase 2, the topic-detail
perf refactor, the invite share-link fix, and more.
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.

1 participant