Repository navigation
feat(insights): period-aware Tracked Prompts KPI card with plan quota - #471
Merged
Merged
Conversation
The KPI row gave no hint of the denominator behind its numbers — how many tracked prompts actually produced the data — and the plan's prompt quota was invisible outside Settings. Adds a Tracked Prompts card between Visibility Score and Mentions: - The main value is period-aware: a new tracked_prompt_count RPC (migration 00024, SECURITY INVOKER) counts distinct prompts with results under the same filters as insights_aggregates, shopping excluded — so the card recomputes with the date preset like its neighbors instead of sitting as a static account-state number in a filter-reactive row. - The sub-line shows org-wide quota usage (the same count enforceLimit writes against) vs the effective limit via getOrgPlan, so Enterprise plan_overrides are respected; unlimited plans show just the count. - At >=90% usage an Upgrade link appears, navigating to Settings with stopPropagation; the card itself navigates to the Prompts page, mirroring the Citations card pattern. - KPI grid goes grid-cols-2 / sm:grid-cols-3 / xl:grid-cols-5 for five cards. - Fetched inside getInsightsData's server-side Promise.all — no extra client round trip. Closes #457
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
The Insights KPI row gave no hint of the denominator behind its numbers — how many tracked prompts actually produced the data — and the plan's prompt quota was invisible outside Settings.
This adds a Tracked Prompts card between Visibility Score and Mentions:
tracked_prompt_countRPC (migration00024, SECURITY INVOKER per the 00014 convention, already applied to the hosted project) counts distinct prompts with results under the same filters asinsights_aggregates— date range, model, region, topic,chatgpt-shoppingexcluded. The card recomputes with the date preset like its neighbors; a static account-state number in a filter-reactive row was explicitly rejected in Insights: period-aware Tracked Prompts KPI card with plan quota and upgrade link #457 (see the issue for the reasoning).enforceLimitwrites against — vs the effective limit fromgetOrgPlan, so Enterpriseplan_overridesare respected. Unlimited plans show just the count, no fraction, never an Upgrade link.stopPropagation; the card itself navigates to the Prompts page (same pattern as the Citations card).grid-cols-2 sm:grid-cols-3 xl:grid-cols-5for five cards.getInsightsData's server-sidePromise.all— no extra client round trip. Verified against production data: the RPC returns 87 distinct prompts for a brand with 13k results in its 30d window.Related issue
Closes #457
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
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)