Repository navigation
feat(mentions): take the Mentions page's changes on the same prompts as Insights - #1230
Conversation
…ghts and Mentions The two pages showed different "Mentions" and "Net sentiment" for the same days. Product decision: a mention is every time an answer names the brand (three times in one answer counts three), and net sentiment is positive minus negative over the answers that name the brand. - Insights: Net sentiment, its split, the same-prompt change and the Action Center Positive sentiment KPI now divide by the answers naming the brand (mention_results / mention_answers, 00191) rather than those naming or citing it (ansvisor#508); cited-only answers are always neutral and pulled the net toward zero. The net is rounded once, as the Mentions page does; a test checks the two formulas agree. - Mentions: Total mentions, its trend, the platform table and the summary line count occurrences (the RPC gains them per day and per platform). The competitor table keeps responses, as its rollup has no occurrences, and says so in its header. - Insights' Mentions and Net sentiment cards open Mentions on the same range, country and topic (All time opens Mentions' default 30 days). 00191 redefines insights_aggregates_daily, insights_kpi_series and mentions_overview with those fields added; existing fields are unchanged, and the web falls back to the old base until the migration is applied. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as Insights After ansvisor#1226 both pages show the same mentions and net sentiment, but their "vs the previous period" changes still differed: Insights compares only the prompts answered in both windows, so adding or removing prompts doesn't read as a rise or a fall, and the Mentions page compared all of them (on the dev data, 7 days read +25% on Insights and -69% on Mentions). mentions_overview (00195, from 00191's definition) also returns `same`: how many prompts both windows answered, how many are new or dropped, and both windows' totals on the shared ones; each platform row gains the same counts. The page takes every change from them (changeBasis): the four KPI cards, the summary line's net change and mover, and the platform table. The values stay the whole window's, and before the migration the changes fall back to all prompts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Following #1226, this PR closes the last gap between Insights and Mentions: the change vs the previous period. The Mentions page now takes all its changes on the prompts answered in both windows, as Insights does; until now it compared all prompts. On the dev data, 7 days moves from −69% to +25%, matching Insights. Migration 00195 adds |
gkhngyk
left a comment
There was a problem hiding this comment.
This looks right on top of #1226. 00195 has the same signature as 00191 and only adds fields, and the shared-prompt set matches Insights. After #1226's squash, please rebase onto main from cf821c4d (rebase --onto origin/main cf821c4d); merged as is, it conflicts in _overview-kpis.tsx, mentions-overview.test.ts and schema.sql. I'll apply 00195 after 00191 and 00192.
Smaller: the Net sentiment and Mention rate cards check the low-sample rule only on the whole window, while the summary line also needs both shared-prompt windows to pass (mentions-headline.ts). So a card can show a change taken over fewer than 20 shared responses while the summary line shows none. Add !isLowSample(base) && !isLowSample(prev) to the cards.
…ns-kpis # Conflicts: # supabase/schema.sql
… feature/mentions-same-prompt-changes
…ns-kpis # Conflicts: # supabase/schema.sql
… feature/mentions-same-prompt-changes # Conflicts: # supabase/schema.sql
00191 moved Insights' daily path and Action Center to the answers that name the brand, but the raw insights_aggregates RPC (reports, the 24h window) and the Daily Pulse still divided by answers that name or cite it, so they showed a lower positive share. 00191 now also redefines insights_aggregates (8 args, security invoker) with mention_results, and Pulse reads it, falling back before the migration. Also from the review: - the Mentions copy summary's Total mentions and its basis count occurrences, as the card does; the tab line and the CSV say "responses" where they count responses, and the CSV adds the card's Total mentions; - a custom range's days are UTC days, the days mentions_overview and Insights read, so a viewer west of UTC opens the same window; - mentions_overview orders platforms by occurrences, the column shown. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… feature/mentions-same-prompt-changes
…a low sample The Mention rate and Net sentiment cards checked the low-sample rule only on the whole window, while the summary line also needs both shared-prompt windows to pass, so a card could show a change taken over a handful of shared responses next to a summary line with none. Each card now also checks both shared windows over its own sample: the responses for the rate, the responses naming the brand for the net. 00195 redefines mentions_overview from 00191, so it carries ansvisor#1226's order of the platforms by occurrences, the column the table shows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk thanks, fixed in b97c28b (after merging #1226's latest, 8c03ead, in as a normal merge, 3b638f4):
Server 1840 and web 1802 tests + build pass; Still CONFLICTING against main on |
…ns-kpis # Conflicts: # supabase/schema.sql
… feature/mentions-same-prompt-changes # Conflicts: # supabase/schema.sql
gkhngyk
left a comment
There was a problem hiding this comment.
The fixes check out:
- The cards now hold a change on a low-sample shared window.
- 00195 carries #1226's platform order.
On production:
- 00195 is applied after 00191.
- Every value
mentions_overviewreturned before is still there; the only change is the addedsameandsame_*fields. - On the largest brand it reads in 2.1 s for 24 hours and 1.4 s for 30 days.
Merge: I merged main in after #1226's squash. The result is the tree I tested with #1226, which passes web (2,507 tests), server (2,011 tests), tsc, lint and Prettier.
…prompts as its card (#1628) Since #1230 the Mentions page takes every change on the prompts both windows answered, as Insights does, so adding or removing prompts doesn't read as a rise or a fall. Copy summary still took the Total mentions change on all of each window's responses: the copied text could say +30% under a card that said +10%. It now takes it on the same basis (changeBasis), as the card does. The other lines of the summary carry no change. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
After #1226, Insights and Mentions show the same values, but their "vs the previous period" changes still differed:
insights_same_prompt_compare_daily, 00164). Adding or removing prompts doesn't read as a rise or a fall.On the dev data for 7 days, Total mentions read +25% on Insights and −69% on Mentions. The product owner asked for the Mentions page to follow Insights.
Migration 00195 redefines
mentions_overviewfrom 00191's definition (#1226) with additions only:same:prompts: answered in both windows;new_prompts,dropped_prompts;current/previous: each window's totals on the shared prompts.same_*/same_prev_*(answers, mentions, positive, negative) on the shared prompts.Web
changeBasis(overview)returns the shared-prompt totals, or all prompts before 00195. Every change on the page uses it:platformNetChange).isLowSample).Related issue
Requested by the product owner after #1226 (Insights vs Mentions numbers).
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
?range=7dand note the Mentions card's change.On the dev DB (demo brand, 7 days):
mentions_overviewreads all prompts 25 vs 80 occurrences, and the shared prompt 25 vs 20;I checked it in the browser on :3002, in light and dark mode, at 1440 and 1024 px.
Tests:
mentions-overview.test.ts: parsingsameand the platformsamecounts;changeBasiswith and without them._overview.test.tsx: the cards' changes come from the shared prompts while the values stay the window's.mentions-headline.test.ts: the net change and the platform change on the shared prompts.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): 0 errors, only the existing warningsyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(1786 passed);yarn buildwith the CI placeholder env;bash supabase/build-schema.sh.🤖 Generated with Claude Code