Skip to content

Insights: period-aware Tracked Prompts KPI card with plan quota and upgrade link #457

Closed

Description

@gkhngyk

Problem

The Insights KPI row (Visibility Score / Mentions / Citations / Positive Sentiment) gives no hint of the denominator behind those numbers — how many tracked prompts actually produced the data — and the plan's prompt quota is invisible outside Settings. Internal feedback asked for a prompt card in the KPI row with the quota and an upgrade path.

A naive "total tracked prompts" card was considered and rejected: every card in that row recomputes when the date preset changes (24h/7d/30d/…), and a static account-state number sitting between them breaks the row's "these numbers describe the selected period" contract — the same class of inconsistency the citations mismatch taught us to avoid.

Design (period-aware)

Add a Tracked Prompts card between Visibility Score and Mentions in web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx:

  • Main value follows the date filter: the number of distinct prompts that produced results in the selected range — count(distinct prompt_id) over prompt_results for the brand + range. On 24h this may read 38 while the brand has 45 active prompts; that is informative ("your 24h view covers 38 prompts so far"), not a bug.
  • Sub-line shows the org quota: 45 / 50 prompts — current state, deliberately not period-scoped (quotas are "now" facts; only the main value must react to the filter). Notes:
    • The limit must be the effective one — read via getOrgPlan, which merges Enterprise plan_overrides, not the static plan config.
    • maxPrompts is org-wide (getOrgPromptCount in web/src/lib/actions/prompt.ts counts prompts across all brands), so word the sub-line accordingly (e.g. "45/50 across your organization" in the tooltip).
    • Unlimited plans: hide the quota fraction, show just the active-prompt count.
  • Click behavior: the card navigates to /dashboard/prompts (same pattern as the Citations card → /dashboard/citations). When org usage is at ≥90% of the quota, the sub-line shows an Upgrade link that navigates to Settings — with stopPropagation so the nested link doesn't trigger the card's navigation.
  • Layout: the row is currently grid grid-cols-2 gap-4 sm:grid-cols-4; five cards need something like sm:grid-cols-3 xl:grid-cols-5 — check both breakpoints and the mobile 2-column flow.
  • Tooltip on the card title explaining the metric ("Distinct prompts that produced tracked results in the selected period"), matching the other cards' tooltip pattern.

Acceptance criteria

  • Changing the date preset updates the Tracked Prompts value together with the other four cards; the quota sub-line stays constant.
  • Quota reflects plan_overrides for Enterprise orgs; unlimited plans show no fraction and never show Upgrade.
  • Upgrade link appears only at ≥90% usage, goes to Settings, and does not trigger the card's Prompts navigation.
  • KPI grid renders cleanly at mobile / sm / xl widths with five cards.

Activity

  1. self-assigned this
    on Jul 17, 2026
  2. added
    enhancement
    on Jul 17, 2026
  3. added a commit that references this issue on Jul 18, 2026
    9a5bb6a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions