Skip to content

feat(audit): show the month's audits as the v2 quota card and summary strip - #1140

Merged
gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/audit-quota-card
Oct 18, 2026
Merged

gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/audit-quota-card

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Site Audit shows the month's audits as the v2 mockup's quota card and summary strip. This is task SA-019 of the Site Audit v2 spec (§4.4, §4.5).

Stacked on #1139 (auto-audit). The diff includes its commits until it merges. No migration.

Web

  • Audits this month card:
    • Big number: what's left, the runs' scheduled share included, as "45 of 100 left".
    • Thin bar: split into auto used · auto scheduled · you used · free. Its tooltip and label read "Auto used 15 · Auto scheduled 10 · You used 40 · Free 35".
    • The five runs on one line, 1 · 7 · 14 · 21 · 28, joined by a thin line: done filled, next outlined and bold, upcoming empty.
    • "Auto 25% · How it works": it opens four short points under the cards, closed by default. The last point's Settings opens the Site Audit settings.
    • Auto-audit off: "Auto-audit off" and no runs.
    • Plans without a monthly limit: they keep "Unlimited"; with auto-audit on they show the runs and "Auto · 25 pages a run".
  • "Mark fixed" point: the mockup's "Re-checks after Mark fixed are free" is left out until SA-012 brings Mark fixed.
  • Summary strip: "68 site score +3 · 2 pages audited · Lowest: E-E-A-T 36 · Next auto-audit on Oct 21 · 5 pages", with the primary domain on the right.
    • The next run reads today, tomorrow or a date.
    • The strip leaves out what has no data.
  • Empty pool (spec §4.4): when the user's share is used up while runs are still scheduled, the run bar and the bulk bar say "You've used your 375 audits. 25 auto audits are still scheduled. Turn off auto-audit to use them now, or upgrade." In the run bar, the link opens Settings.
  • Old sub-line removed: feat(audit): audit top-priority pages automatically each billing week #1139's temporary sub-line ("3 used · 10 for auto-audit") is gone; the card now shows this.
  • Copy: the strings are in en.json under audit.quota and audit.strip.

Server

  • getSiteAuditQuotaStatus: auto.running counts the runs' audits still running. While a run is going, its audits count as auto, not as the user's.
  • buildOverview: adds lowestCategory, the weakest of the five categories over the primary domain's latest audits. A tie goes to the rubric order.

Design rules (§4.5)

  • Typeface: one typeface; Site Audit uses no monospace.
  • Bulk bar: light.
  • Score over time: kept.
  • Wrapping: the strip and the card stay on one line at 1280px and 1440px.

Related issue

None. Site Audit v2 spec, task SA-019.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. With feat(audit): audit top-priority pages automatically each billing week #1139's migration 00167 applied, use a cloud org on Starter or Growth whose auto-audit runs have recorded at least one run this month.
  2. Open Site Audit.
    • The strip reads the site score, pages audited, the lowest category and the next run.
    • The card reads "N of {limit} left", with the split bar and the runs: done filled, next outlined.
  3. Click How it works: four points open under the cards. Its Settings link opens the settings.
  4. Turn auto-audit off in Settings: the card shows "Auto-audit off" without runs, and the scheduled share comes back to what's left.
  5. Use up the user's share while runs are still to come: the run bar and the bulk bar show the empty-pool message.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no errors; the 7 warnings are in files this PR does not touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • server: npm run format, npm run lint and npm test (1564) pass.
    • plan-guard-site-audit.test.js: the runs' running audits apart.
    • overview.test.js: the lowest category and its tie-break.
  • web: yarn test (1350) and yarn build pass.
    • _overview-cards.test.tsx: the split, the widths, the runs, the running audits, How it works and its Settings link, auto off, and plans without a limit.
    • _summary-strip.test.tsx: the items, today/tomorrow/date, auto off, missing data.
    • _bulk-bar.test.tsx: the empty-pool message with the spec's numbers.
  • Browser: this branch's server (cloud mode) and web, with the demo org on Starter and sample data.
    • Sample data: three runs done this month, 40 of the user's audits, three audits on the primary domain.
    • Checked: the strip, the card (45 of 100 left; 15 / 10 / 40 / 35), How it works, the Settings link, and the empty-pool message after filling the user's share.
    • Views: 1440px and 1280px (one line), 1024px (no overflow), light and dark.
    • Afterwards: the samples were deleted and the plan restored.

🤖 Generated with Claude Code

cihan-gyk and others added 9 commits October 17, 2026 20:47
SA-004 of the Site Audit v2 spec, first sources: audits were only of the
URLs someone typed, with nothing suggesting which pages to audit (F5, F7).

- GET /api/audits/opportunities builds the inbox (lib/audit/opportunities.js):
  Google Analytics' open "no AI traffic" pages (page_opportunities: valuable
  pages AI engines send no visitors to) and the site's pages (site_pages)
  never audited or audited more than auditMaxAgeDays (90) ago. One row per
  page across spellings, with why (chips), its last audit and its AI visits
  over 30 days (Analytics where it has the page, else the snippet). Pinned
  pages come first; excluded ones are listed apart; checkout-like paths stay
  out. Until the priority score (SA-005) rows follow GA value, then never
  audited, then citations and sessions.
- Migration 00164 adds site_audit_page_prefs (pinned / excluded per page),
  written through PUT /api/audits/opportunities/prefs.
- The hub gets Opportunities and Pages tabs; Opportunities opens when it
  lists pages. Select pages to Audit selected (the bulk audit, within the
  quota), Pin / Unpin or Exclude (with Undo); excluded pages can be
  restored from the list under the table. The bulk bar takes each table's
  own audit label and actions.

Competitor-cited pages and Search Console sources come in later PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t Opportunities

SA-004's citation source: prompts where a competitor's page is cited and
the brand's never is point to the brand page closest to them, as a page
worth auditing.

- Migration 00165 adds audit_competitor_cited_prompts (service role only):
  per active prompt over a window, answers citing a competitor's domain,
  answers citing the brand's own, and the competitor domains cited, read
  from prompt_result_citations (domains match with their subdomains).
- competitorGapPages (lib/audit/opportunities.js) keeps the prompts the
  brand was never cited on and maps each to its target URL, else the best
  site_pages match (candidatePages, as Content opportunities use), one row
  per page with its prompts and competitor names.
- GET /api/audits/opportunities adds them as a competitor_cited reason over
  the last 30 days; without competitor domains it asks nothing, and on a
  database without 00165 (PGRST202) the other sources still list. Until
  the priority score (SA-005) these pages rank after GA's valuable pages and
  before pages never audited.
- The Opportunities table shows them as "Crema Club cited on 3 prompts"
  ("+N" for more competitors).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main took 00164 (insights topic rollups), so this branch's migration moves
to 00165_site_audit_page_prefs.sql; schema.sql rebuilt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main took 00164 (insights topic rollups) and the Opportunities prefs
migration moved to 00165, so this one follows as 00166; schema.sql rebuilt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each page in the Opportunities inbox gets a 0-100 priority: its value to
the business x the opportunity an audit can win x how easy it is to fix,
each 0-1, shown as the cube root of the product (SA-005). Pinned pages
stay on top; the rest are ordered by priority. The table shows the score
in a pill (dark from 80) with its parts on hover.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Site Audit's auto-audit (SA-006): 25% of the monthly quota audits the
Opportunities inbox's top pages by itself, in five runs of 5% (at least
one page) on days 1, 7, 14, 21 and 28 of the billing month. A daily sweep
after the GA sync claims each org's due run once, picks pinned pages
first and then the highest priority across its brands, skipping pages
audited or tried in the last 30 days, and runs them in their own pool.
The runs still to come keep their slots out of the user's pool; a run's
unused slots return when it is recorded.

Settings (admins and managers): auto-audit on/off for the organization
(on by default with a monthly quota, off without one), an e-mail after
each run, the brand's exclude patterns and its pinned pages. The Site
Audit page shows the latest run ("3 pages audited · 6 critical issues ·
next run Oct 21") and the quota card what auto-audit keeps.

Migration 00167 adds the settings and run tables and a source column on
site_audits and site_audit_usage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	server/src/lib/audit/opportunities.js
#	server/src/lib/audit/opportunities.test.js
#	server/src/routes/audits-opportunities.test.js
#	server/src/routes/audits.js
#	supabase/migrations/00166_audit_competitor_cited_prompts.sql
#	supabase/schema.sql
#	web/src/app/[locale]/(dashboard)/dashboard/audit/page.tsx
#	web/src/lib/actions/audits.ts
… strip

Site Audit's quota UI (SA-019, spec §4.4): the Audits this month card
shows what's left of the plan's audits, a thin bar split into auto used,
auto scheduled, the user's and free, the five runs on one line (done
filled, next outlined, upcoming empty) and "Auto 25% · How it works",
which opens four short points under the cards. A summary strip on top
reads "68 site score +3 · 2 pages audited · Lowest: E-E-A-T 36 · Next
auto-audit on Oct 21 · 5 pages". When the user's share is used up while
runs are still scheduled, the run bar and the bulk bar say so and point
to turning auto-audit off.

The quota counts the runs' running audits apart, and the overview adds
the lowest of the five categories.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk This is SA-019: the Audits this month card as in the v2 mockup (split bar, the five runs, How it works), the summary strip on top, and the empty-pool message. It's stacked on #1139 and has no migration; the server only adds auto.running to the quota and lowestCategory to the overview. Thanks!

@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 18, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebuilt on main after #1139: the overview, plan-guard, quota card, summary strip and bulk bar tests pass (web run locally with the Excel writer stubbed, as CI's web job doesn't run tests), and CI is green. No migration.

@gkhngyk
gkhngyk merged commit 8bdaab6 into ansvisor:main Oct 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants