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(mentions): drop the sentiment columns from Competitor framing and say what the last one counts (#1151)
Cihanafb6eeed2a9b
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 37ddc7d75..1289b38ee 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -3251,11 +3251,9 @@"brand": "Brand","mentions": "Mentions","rate": "Rate",- "sentiment": "Sentiment",- "net": "Net",- "sameAnswer": "Same answer as you",+ "alsoNamesYou": "Also names you",+ "alsoNamesYouTip": "Of the responses naming this competitor, how many name {brand} too, and what share of its mentions that is.","you": "You",- "ownSentimentOnly": "Sentiment is measured for your brand only.","none": "No competitors yet. Add them on the Competitors page to compare."}},diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsxindex 9866b2df2..f85bebeef 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.test.tsx@@ -4,7 +4,7 @@ import { NextIntlClientProvider } from 'next-intl';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import messages from '../../../../../../messages/en.json';import type { InsightsSummary, TrackedPromptsKpi } from '@/lib/actions/tracking';-import { KpiRows } from './_kpi-cards';+import { InfoTip, KpiRows } from './_kpi-cards';(globalThis as typeof globalThis & {@@ -123,3 +123,30 @@ describe('the Mentions and Citations cards', () => {expect(container.textContent).not.toContain('vs previous period');});});++describe('InfoTip', () => {+ /** Hovers an icon whose box starts at `left`, and returns where the tooltip is centred. */+ function tooltipCentreFor(left: number) {+ act(() => {+ root.render(<InfoTip content="What this counts" />);+ });+ const icon = container.querySelector<HTMLElement>('[aria-label="More information"]')!;+ icon.getBoundingClientRect = () => ({ left, width: 12, bottom: 100 }) as DOMRect;+ act(() => {+ icon.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));+ });+ const tooltip = document.querySelector<HTMLElement>('[role="tooltip"]')!;+ expect(tooltip.textContent).toBe('What this counts');+ return parseFloat(tooltip.style.left);+ }++ it('centres on its icon', () => {+ expect(tooltipCentreFor(500)).toBe(506);+ });++ it("stays on screen beside the window's edges", () => {+ // 224px wide, 8px from either edge.+ expect(tooltipCentreFor(window.innerWidth - 20)).toBe(window.innerWidth - 120);+ expect(tooltipCentreFor(2)).toBe(120);+ });+});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsxindex 303fdabc2..f6565edeb 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_kpi-cards.tsx@@ -44,6 +44,9 @@ import {// ─── Info tooltip ─────────────────────────────────────────────────────────────+/** Half the tooltip's width (w-56, 224px) and an 8px margin from the window's edge. */+const INFO_TIP_HALF_WIDTH = 120;+export function InfoTip({ content }: { content: string }) {const [pos, setPos] = useState<{ x: number; y: number } | null>(null);const ref = useRef<HTMLSpanElement>(null);@@ -51,7 +54,14 @@ export function InfoTip({ content }: { content: string }) {function show() {const r = ref.current?.getBoundingClientRect();- if (r) setPos({ x: r.left + r.width / 2, y: r.bottom + 6 });+ if (!r) return;+ // Centred on the icon, but kept on screen: an icon by the window's edge+ // (a table's last column) would push half the tooltip past it.+ const x = Math.min(+ Math.max(r.left + r.width / 2, INFO_TIP_HALF_WIDTH),+ window.innerWidth - INFO_TIP_HALF_WIDTH,+ );+ setPos({ x, y: r.bottom + 6 });}function hide() {diff --git a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_competitor-table.tsx b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_competitor-table.tsxindex 33db07f79..21fbf403d 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_competitor-table.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_competitor-table.tsx@@ -2,24 +2,16 @@import { useLocale, useTranslations } from 'next-intl';import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';-import { cn } from '@/lib/utils';import { numberFormat } from '@/lib/number-format';-import { wholeNet } from '@/lib/mentions-headline';-import {- isLowSample,- mentionRate,- sentimentSplit,- type MentionsOverview,-} from '@/lib/mentions-overview';-import { signedValue, TONE_TEXT } from '../insights/kpi-format';-import { SentimentSplitBar } from './_sentiment-split';+import { mentionRate, type MentionsOverview } from '@/lib/mentions-overview';+import { InfoTip } from '../insights/_kpi-cards';/*** "Competitor framing" (MS-06): your brand, then each competitor with its- * mentions, its rate over the same responses, and how many of those name you- * too. Sentiment is stored toward your brand only, so a competitor's tone- * stays "—" until it is measured; the strength and weakness columns come- * with the themes.+ * mentions, its rate over the same responses, and how many of its mentions+ * name you too. Mentions only: sentiment is measured toward your brand alone,+ * and the KPI cards above show yours, so a sentiment column read "—" for+ * every competitor. The strength and weakness columns come with the themes.*/export function CompetitorTable({overview,@@ -35,12 +27,9 @@ export function CompetitorTable({const f = numberFormat(locale);const { current: cur } = overview;const ownRate = mentionRate(cur);- const split = sentimentSplit(cur);- const net = wholeNet(cur);const rateOf = (mentions: number) => (cur.answers > 0 ? (mentions * 100) / cur.answers : null);const competitors = [...overview.competitors].sort((a, b) => b.mentions - a.mentions);const pct = (n: number | null) => (n === null ? '—' : f.percent(n, 1));- const dash = <span className="text-muted-foreground">—</span>;return (<Card className={className}>@@ -49,15 +38,18 @@ export function CompetitorTable({<p className="text-xs text-muted-foreground">{t('description')}</p></CardHeader><CardContent className="overflow-x-auto">- <table className="w-full min-w-[640px] text-sm" aria-label={t('tableLabel')}>+ <table className="w-full min-w-[480px] text-sm" aria-label={t('tableLabel')}><thead><tr className="border-b text-[11px] uppercase tracking-wide text-muted-foreground"><th className="py-2 pr-3 text-left font-medium">{t('brand')}</th><th className="w-24 px-2 py-2 text-right font-medium">{t('mentions')}</th><th className="w-20 px-2 py-2 text-right font-medium">{t('rate')}</th>- <th className="w-40 px-2 py-2 text-left font-medium">{t('sentiment')}</th>- <th className="w-16 px-2 py-2 text-right font-medium">{t('net')}</th>- <th className="w-40 py-2 pl-2 text-right font-medium">{t('sameAnswer')}</th>+ <th className="w-44 py-2 pl-2 text-right font-medium">+ <span className="inline-flex items-center gap-1">+ {t('alsoNamesYou')}+ <InfoTip content={t('alsoNamesYouTip', { brand })} />+ </span>+ </th></tr></thead><tbody>@@ -72,34 +64,30 @@ export function CompetitorTable({</td><td className="px-2 py-2.5 text-right tabular-nums">{f.number(cur.mentions)}</td><td className="px-2 py-2.5 text-right tabular-nums">{pct(ownRate)}</td>- <td className="px-2 py-2.5">{split ? <SentimentSplitBar split={split} /> : dash}</td>- <td- className={cn(- 'px-2 py-2.5 text-right font-semibold tabular-nums',- net === null || isLowSample(cur)- ? 'text-muted-foreground'- : TONE_TEXT[net > 0 ? 'good' : net < 0 ? 'bad' : 'neutral'],- )}- >- {net === null ? '—' : signedValue(net, locale)}- </td>- <td className="py-2.5 pl-2 text-right">{dash}</td>+ {/* A question about competitors: left empty for you, not "—". */}+ <td className="py-2.5 pl-2" /></tr>{competitors.map((c) => (<tr key={c.competitorId} className="border-b last:border-b-0"><td className="py-2.5 pr-3">{c.name}</td><td className="px-2 py-2.5 text-right tabular-nums">{f.number(c.mentions)}</td><td className="px-2 py-2.5 text-right tabular-nums">{pct(rateOf(c.mentions))}</td>- <td className="px-2 py-2.5">{dash}</td>- <td className="px-2 py-2.5 text-right">{dash}</td>- <td className="py-2.5 pl-2 text-right tabular-nums">{f.number(c.coMentions)}</td>+ <td className="py-2.5 pl-2 text-right tabular-nums">+ {f.number(c.coMentions)}+ {c.mentions > 0 && (+ <span className="text-muted-foreground">+ {' · '}+ {f.percent((c.coMentions * 100) / c.mentions, 0)}+ </span>+ )}+ </td></tr>))}</tbody></table>- <p className="mt-3 text-xs text-muted-foreground">- {competitors.length === 0 ? t('none') : t('ownSentimentOnly')}- </p>+ {competitors.length === 0 && (+ <p className="mt-3 text-xs text-muted-foreground">{t('none')}</p>+ )}</CardContent></Card>);diff --git a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_overview.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_overview.test.tsxindex 4d5ee11ec..b84491ee0 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_overview.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_overview.test.tsx@@ -206,18 +206,23 @@ describe('PlatformTable', () => {});describe('CompetitorTable', () => {- it('puts you first, then competitors by mentions, with sentiment only for you', () => {+ it('puts you first, then competitors by mentions and how often they name you too', () => {render(<CompetitorTable overview={overview} brand="Ansvisor" />);+ const headers = [...container.querySelectorAll('th')].map((th) => th.textContent);+ expect(headers).toEqual(['Brand', 'Mentions', 'Rate', 'Also names you']);const rows = [...container.querySelectorAll('tbody tr')].map((r) =>[...r.querySelectorAll('td')].map((td) => td.textContent),);- expect(rows[0]).toEqual(['AnsvisorYou', '100', '25.0%', '', '+34', '—']);+ // The last column asks about competitors: empty for you, not "—".+ expect(rows[0]).toEqual(['AnsvisorYou', '100', '25.0%', '']);+ // Each competitor's mentions that name you too, and their share.expect(rows.slice(1)).toEqual([- ['Profound', '260', '65.0%', '—', '—', '41'],- ['Otterly AI', '120', '30.0%', '—', '—', '31'],- ['Peec AI', '90', '22.5%', '—', '—', '36'],+ ['Profound', '260', '65.0%', '41 · 16%'],+ ['Otterly AI', '120', '30.0%', '31 · 26%'],+ ['Peec AI', '90', '22.5%', '36 · 40%'],]);- expect(container.textContent).toContain('Sentiment is measured for your brand only.');+ // Sentiment is measured toward your brand alone, and shown in the KPI cards.+ expect(container.textContent).not.toMatch(/Sentiment|—/);});});