Repository navigation
feat(mentions): show the Perception tab - #1124
Conversation
Built on main without the Perception commits (ansvisor#1123, ansvisor#1124), which are on hold; this branch only shared context lines with them. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
@cihan-gyk please rebase this on main after #1123 lands. Its own change is the Perception UI (d05c1bc5); everything below it comes from the stack. There are no migrations in this PR, and main still shows the "on its way" placeholder, so nothing here is superseded.
Conflicts:
page.tsx: keep main's header (MentionsHeaderActions,useMentionsExport, theexporterprop on the Mentions tab) and only swap the placeholder forMentionsPerceptionTab.en.json: dropcomingSoonand add theperceptionblock._mentions-tab.test.tsxandactions/mentions.ts: take main's version. These conflicts come from the stack, not from this PR.
Small fixes:
- Colours. Since #1217 / #1220 the Mentions page draws your brand in ink (
var(--primary)) and no longer uses indigo or violet.- The radar uses
OWN_BRAND_COLOR(green) andCOMPETITOR_PALETTE, whose second colour is violet. - The heat map tints cells with indigo (
rgba(99, 102, 241, …)). - Draw the brand in ink on both, as the trend chart does, and use a neutral tint for the cells.
- The radar uses
- If #1226 merges first, "mention" on this page means every time the brand is named. The Perception shares are over the responses that name a brand, so label them "of responses naming …" rather than "of mentions" to keep the two pages consistent.
The Perception tab's data (MS-09), deterministic as spec §9 asks for V1: - migration 00161: mention_terms() takes the sentences of an answer that name an entity and returns their words and two-word phrases, minus stop words in 13 languages (Snowball dictionaries), words answers use about every brand alike, every brand's names and the question's own words; mentions_answer_terms keeps the distinct terms per answer and entity named (the brand or a competitor), filled by refresh_mentions_daily with the mention rollups; mentions_perception() reads a window and the one before: the brand's top terms with their trend, the 8 attributes that tell it and its four most mentioned competitors apart with each one's share of mentions, and the competitors named in the same answers - the mention history refreshes three days a call: the terms make each call heavier than the citation rollups' fortnight - web: getMentionsPerception, the parsed shape, shares, and the biggest gap (a competitor leading an attribute by 20+ points) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reading the answers' text for their terms takes about 2.4 ms per answer and entity named: about 7 s for a recent day of the largest brand, and more on its busier days. Inside refresh_mentions_daily that also ran in a sentiment correction (00160), within the person's 8 s request, where the terms never change. refresh_mention_terms now holds that part, and refresh_mentions_daily stays as 00157 wrote it. The server calls both for a completed run, the nightly sweep and the backfill; the backfill goes a day at a time. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
…day at a time - refresh_mention_terms takes a per-brand advisory lock of its own, as refresh_mentions_daily does since 00192: a run's refresh and the nightly sweep can cover the same days, and the second insert would fail on the (result_id, entity) key. - refreshMentionsDaily refreshes the rollups for the range in one call and the terms one day per call, so the sweep's three days stay well inside the service role's statement timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Mentions & Sentiment Perception tab (MS-09) reads mentions_perception and shows what AI associates with the brand, a radar of the brand against its three most mentioned competitors, the brand x attribute heat map, the competitors named beside it and the biggest gap. The gap leaves out shares taken over fewer than 20 mentions, as the Overview does, and only names a brand the radar draws. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he shares are of responses naming a brand - The radar draws the brand in ink (var(--primary)), as the rest of the Mentions page does since ansvisor#1217/ansvisor#1220, and the competitors in orange, teal and red (no violet); insights-trend keeps its palette to itself. - The brand × attribute cells take a neutral tint instead of indigo. - The shares are over the responses that name a brand, so the labels say "of responses naming …" rather than "of mentions", which on this page counts every time a brand is named. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7f2c7f3 to
aa24cb2
Compare
|
@gkhngyk Rebased on
Fixes (aa24cb2):
Checked through #1126, which sits on this PR: the Perception tests (50) and tsc here; the full web suite and |
gkhngyk
left a comment
There was a problem hiding this comment.
Ready to merge after #1123. There are no migrations and nothing to apply on the database.
Rebase
- The branch is #1123 plus
842845c8(the Perception tab) andaa24cb2e(the fixes). git merge-treeonto the current main (4ac82ce5) is clean. Against main, the result touches only #1123's files and this PR's 9.page.tsxkeeps main's header actions and exporter, and only swaps the placeholder forMentionsPerceptionTab.en.jsononly dropscomingSoonand adds theperceptionblock.insights-trend.tsis back to main's.- CI is green.
Colours
- The radar draws the brand in
var(--primary), as main's trend chart does, and the competitors in#f97316,#0d9488and#ef4444. There's no violet left. - The heat map tint is neutral:
rgba(120, 113, 108, …), capped at 0.45. The indigo is gone.
Labels
- The terms tooltip says "… of responses naming {brand}".
- The gap note says "… of the responses naming it".
- The heat map and radar say "Share of the responses naming each brand".
- These are right whether or not #1226 changes what "mention" means.
Nit (optional): a doc comment in _perception-cards.tsx (line 100) and one test title in _perception.test.tsx still say "share of each brand's mentions". They aren't shown to users.
ansvisor#1123 is squash-merged on main; this keeps only this branch's own change on top. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
Merging. #1123 is in, refresh_mention_terms with the lock is applied on production, and the terms are backfilled for all history: 603k rows across 72 brands, from 2026-04-16.
One follow-up for you: mentions_perception on the biggest brand is close to the 8 s authenticated timeout. Timed on production as a member:
| Brand · window | Time |
|---|---|
| Biggest · 30 days, first call | 9.97 s |
| Biggest · 30 days, warm | 5.8 s |
| Biggest · 7 days | 0.83 s |
| Second biggest · 30 days | 0.26 s |
So a cold first open of the Perception tab for that brand can time out. The read aggregates the terms per answer at request time. A daily per-entity terms rollup, or force_custom_plan plus a narrower read, would keep it well under. A member of another organization gets null, as expected.
The tool description said null only when no competitor leads by 20+ points; it is also null when the brand or that competitor has fewer than 20 mentions (ansvisor#1124's low-sample rule), as the skills now say (ansvisor#1127). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p is - Only changes.netSentimentPoints is null on a low sample (and the mention rate's change under 20 tracked responses); mentionsPct isn't gated. - biggestGap is also null when the brand or the leading competitor has fewer than 20 mentions (ansvisor#1124's low-sample rule). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m the API and MCP (#1126) * feat(mentions): read Mentions & Sentiment and correct a sentiment from the API and MCP The Mentions page's figures over the API and MCP (MS-13): summary, the mentions list, one answer, competitors and perception, under the page's filters, from the page's own database functions after a brand check; and "Sentiment is wrong" as the API key's owner. Migration 00162 lets override_mention_sentiment correct for that person when the service role calls, still only for an admin or manager of the answer's organization. The in-app agent gets the five reads. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(mentions): say when get_mentions_perception's biggestGap is null The tool description said null only when no competitor leads by 20+ points; it is also null when the brand or that competitor has fewer than 20 mentions (#1124's low-sample rule), as the skills now say (#1127). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(mentions): read get_mentions_summary's changes as the page's cards do Total mentions' change is now on times named (occurrences), and every change is taken on the prompts both windows answered (changeBasis, 00195), with the counts behind it in changes.basis. The mention rate's change is null when either window has under 20 responses, as on the card. Adds promptsWithMentionsPct, and timesNamed per platform and day. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
* docs(skills): teach the AEO coach the Mentions & Sentiment tools Both skills learn the six Mentions tools and REST endpoints from #1126: the numbers to quote (net sentiment, low sample, brand only), a workflow for "why did sentiment drop on Gemini?", and the correction as a write. The sentiment reference explains net sentiment and the README lists the new questions. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(skills): say which Mentions changes are null, and when biggestGap is - Only changes.netSentimentPoints is null on a low sample (and the mention rate's change under 20 tracked responses); mentionsPct isn't gated. - biggestGap is also null when the brand or the leading competitor has fewer than 20 mentions (#1124's low-sample rule). Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(skills): say Mentions changes are on the prompts both windows answered, and mentionsPct is times named Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(skills): lead the Mentions glossary with times named, the page's Total mentions As the Overview card counts them, "mentions" are every time AI names the brand (timesNamed): the coach quotes that for "how many mentions", and mentions (responses naming the brand) as the base of the rate, net sentiment and lowSample, whose 20 is responses naming the brand. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
The Mentions & Sentiment Perception tab (MS-09): what AI says next to the brand, and how that compares with its competitors. It replaces the "on its way" placeholder and reads
mentions_perceptionfrom the previous PR, with the page's filters (date range, platform, country, topic, search).Cards (
web/src/app/[locale]/(dashboard)/dashboard/mentions/)_perception-cards.tsx): the brand's top terms with a bar, the responses each comes in (on hover, its share of the responses naming the brand) and the change against the previous window. The change is neutral in colour, since more of a term isn't better or worse._brand-shape.tsx,_brand-shape-chart.tsx):var(--primary)), as the rest of the Mentions page since feat(traffic): draw the AI Traffic and Mentions charts in the brand's colors #1217/feat(mentions): mark your brand in ink instead of violet #1220, and the competitors in orange, teal and red (no violet);biggestGapnow leaves out shares taken over fewer than 20 mentions (LOW_SAMPLE_MENTIONS, as the Overview's net sentiment does). On a 24h window one answer would otherwise read as 100%.Tab (
_perception.tsx)The same pattern as the Overview:
PGRST202) and a brand AI never named in the period.At
xlthe cards sit two by two; below that they stack.Text
The strings are in
en.jsonundermentions.perception. The unusedmentions.comingSoonis removed.Related issue
None.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
node src/scripts/backfill-mentions-daily.js(server), as in the previous PRs.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): no errors; the 7 warnings are in files this PR does not touchyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
web:yarn test(1,963) andyarn buildpass (checked on feat(mentions): read Mentions & Sentiment and correct a sentiment from the API and MCP #1126, which sits on this PR).mentions/_perception.test.tsx(13):lib/mentions-perception.test.ts: the gap leaves out shares over fewer than 20 mentions.🤖 Generated with Claude Code