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): take Copy summary's Total mentions change on the same prompts as its card (#1628)
Cihan00bba983c744
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_header-actions.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_header-actions.test.tsxindex 368ac8ae3..4134a6554 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_header-actions.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_header-actions.test.tsx@@ -218,6 +218,23 @@ describe('MentionsHeaderActions', () => {expect(toast.success).toHaveBeenCalledWith('Summary copied');});+ it('takes the Total mentions change on the prompts both windows answered, as its card does', async () => {+ // A prompt added this window brings 30 more mentions: on the same prompts, +10%.+ getMentionsOverview.mockResolvedValue({+ ...overview,+ same: {+ prompts: 18,+ newPrompts: 2,+ droppedPrompts: 0,+ current: totals({ answers: 360, mentions: 80, occurrences: 110 }),+ previous: totals({ answers: 360, mentions: 76, occurrences: 100 }),+ },+ });+ render();+ await click('Copy summary');+ expect(writeText.mock.calls[0][0]).toContain('Total mentions: 130 (+10%)');+ });+it('names the filters in use, and marks a low sample instead of a split', async () => {getMentionsOverview.mockResolvedValue({...overview,diff --git a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_use-mentions-export.ts b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_use-mentions-export.tsindex e39644919..92103862c 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/mentions/_use-mentions-export.ts+++ b/web/src/app/[locale]/(dashboard)/dashboard/mentions/_use-mentions-export.ts@@ -14,6 +14,7 @@ import { mentionsQuery, type MentionsFilters } from '@/lib/mentions-filters';import { mentionPlatformLabel, wholeNet } from '@/lib/mentions-headline';import { NO_COMPETITOR, type MentionsList, type MentionsTableState } from '@/lib/mentions-list';import {+ changeBasis,isLowSample,LOW_SAMPLE_MENTIONS,mentionRate,@@ -176,7 +177,10 @@ export function useMentionsExport({/** The Overview's figures as text: the summary line, the KPIs with their n, and the filters. */const summaryText = (overview: MentionsOverview): string => {- const { current: cur, previous: prev } = overview;+ const { current: cur } = overview;+ // The change as the Total mentions card takes it: on the prompts both+ // windows answered (changeBasis), as Insights does, not all of each.+ const { current: base, previous: prev } = changeBasis(overview);const plain = (key: string, values: Record<string, string | number>) =>tHeadline.markup(key, { ...values, b: (chunks) => chunks, tone: (chunks) => chunks });const line = (label: string, value: string, change?: string) =>@@ -186,7 +190,7 @@ export function useMentionsExport({const values = filterValues();// As the Total mentions card counts them: every time a response names the brand.- const change = relativeChange(cur.occurrences, prev.occurrences);+ const change = relativeChange(base.occurrences, prev.occurrences);const total = upIsGood(change === null ? null : Math.round(change), { percent: true, locale });const rate = mentionRate(cur);const net = wholeNet(cur);