Repository navigation
feat(action-center): measure opportunity actions on their own basket - #956
Merged
Merged
Conversation
The Action Center measured every completed action on the whole brand. For a piece of content answering 20 of a brand's 700 prompts, that buries its effect, and the spec asks for results "for the same basket" (#857, Phase 4). - Actions sent from a content opportunity are measured over the same before/after windows on their own prompts and pages: AI visibility and share of voice on the prompts, lead over the strongest competitor, brand mentions, citations of the target pages, and AI referral traffic to them. A metric the window cannot answer stays unmeasured, not zero. - Migration 00113 adds opportunity_basket_metrics, reading the Insights rollups, the citation tables and GA AI traffic for one window. - The prompt ids are fixed on the action when it is sent, so a later re-clustering does not change what it is judged by. Actions sent before take them from the opportunity's clusters. - "Lead over top competitor" has a label, and points render with a sign.
gkhngyk
added a commit
that referenced
this pull request
Oct 7, 2026
Two migrations shared 00113 after #956 merged alongside another. This moves opportunity_basket_metrics to the next free number. The file only create-or-replaces a function, so running it again is harmless.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second PR of Phase 4 in #857. The Action Center measures a completed action over a window before it was raised and one after it closed, and it reads the whole brand. That suits signal-driven actions. A content opportunity, though, answers maybe 20 of a brand's 700 prompts, and brand-wide numbers bury its effect. The spec asks for the results of a published piece to be measured "for the same basket" (§28). Actions sent from an opportunity are now measured that way.
What is measured (
lib/action-center/basket-metrics.js)The windows are the same as before; only the scope changes.
ai_visibilityshare_of_voicecompetitor_leadmentionscitationswww.or a trailing slashai_referral_trafficderiveOutcomeapplies unchanged.validationrecords the scope with the prompt and page counts.Data (migration 00113)
opportunity_basket_metricsreturns one window's raw figures.citation_urls, narrowed through its domain index before the URL match, plusprompt_result_citations.ga_ai_traffic_stats.Which prompts
UI
Tried on production data
00112_opportunity_basket_metrics; the repo file became 00113 after main took 00112).Related issue
Part of #857 (Phase 4)
Type of change
feat— New featuretest— Adding or updating testsHow to test
validation.scope.kindisbasket.basket-metrics.test.jscovers URL scoping, the metric arithmetic and unmeasured metrics.Checklist
yarn lint,yarn typecheck,yarn format:check,yarn test(418) andyarn buildpass (run fromweb/)yarn lint,yarn format:checkandyarn test(1002) pass (run fromserver/)supabase/schema.sqlrebuilt withbuild-schema.sh🤖 Generated with Claude Code