Repository navigation
feat(audit): group Site Audit pages by template, "fix once, applies to N pages" - #1141
Merged
Merged
Conversation
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]>
…nities-competitors
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]>
…o N pages"
Site Audit's template grouping (SA-007): pages built from one template
share most of their gaps, so fixing the template fixes them all. A page's
template is its path with the last part as a wildcard (/blog/* for
/blog/milk-drinks); a template counts with three pages or more, from the
site's pages and the audited ones, and its shared gaps are the signals
that fail or warn on two-thirds of its audited pages. Checkout, login and
legal pages are left out, as the inbox leaves them out.
As in the v2 mockup, a template whose pages share gaps is a row of the
Opportunities inbox ("/blog/* · 38 pages", its gaps as chips, its pages'
AI visits added up, "12 of 38" audited), scored on its own. Audit
selected audits its pages not audited yet; Exclude adds its pattern to
the brand's exclude patterns, with Undo. Pages of such a template get a
template fix on their ease. Pages › Group by template lists the pages
under their template: "/blog/* · 12 of 38 pages audited · Fix once:
Author byline, FAQ schema · applies to 38 pages".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
@gkhngyk This is SA-007: template grouping as in the v2 mockup — a "/blog/* · 38 pages" row in Opportunities (shared gaps, summed AI visits, "12 of 38"; Audit selected audits its unaudited pages, Exclude adds the pattern) and Group by template on Pages. It's stacked on #1140 and has no migration. Thanks! |
8 of 12 tasks
supabase/schema.sql regenerated with build-schema.sh. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
approved these changes
Oct 18, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Rebuilt on main after #1140: the templates, priority, auto-audit and route tests and the Pages and Opportunities table tests pass (web run locally with the Excel writer stubbed, as CI's web job doesn't run tests), and CI is green. The template groups' signal read is chunked under the 1000-row page and runs alongside the competitor read, so the inbox waits for no extra round trip.
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
Site Audit groups pages by template: "Fix once, applies to N pages". Pages built from one template (the blog's posts, the product pages) share most of their gaps, so fixing the template fixes them all. This is task SA-007 of the Site Audit v2 spec (§5), built as the v2 mockup shows it: a template row in the Opportunities inbox, and Group by template on Pages.
Server
lib/audit/templates.js(new, pure):/blog/milk-drinks→/blog/*. A top-level page has none.site_pagesand the audited pages on the primary domain.isExcludedPath) are left out, as the inbox leaves them out.templateOpportunities: turns a template with shared gaps into an inbox row. Itstemplatefield carries its pages, how many are audited, and the pages an audit of it starts: those without a completed audit, up to 50. The brand's exclude patterns leave it out.priority.js:scoreTemplate:ease.templateFix(+0.1, up to 1), as SA-005 left room for.GET /api/audits/opportunities:GET /api/audits/templates: the template groups, for Pages.GET /api/audits/pages: each row carries itstemplate(primary domain only).Web
/blog/*to the brand's exclude patterns (feat(audit): audit top-priority pages automatically each billing week #1139's settings), so its pages leave the inbox too; Undo puts the patterns back. Changing patterns needs admin or manager, as in Settings.en.jsonunderaudit.opportunitiesandaudit.pages.Related issue
None. Site Audit v2 spec, task SA-007.
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
site_pages(e.g./blog/…), two or more of them audited, with a signal failing on most of them.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): no errors; the 7 warnings are in files this PR does not touchyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
server:npm run format,npm run lintandnpm testpass (1578; the related 262 again after the review fix).lib/audit/templates.test.js: the template of a path; counting site and audited pages once; shared gaps at ⅔; the minimums; the primary host; incomplete audits; sessions; running; pages without opportunity; the inbox rows and their exclusion.lib/audit/priority.test.js:scoreTemplate, the template ease bonus, template rows ranked with pages.lib/audit/auto-audit.test.js: runs skip template rows.routes/audits-opportunities.test.js: the template row, its AI visits, the ease bonus, a pattern leaving it out, andGET /templates.routes/audits-pages.test.js: each Pages row's template.web:yarn test(1356) andyarn buildpass._opportunities-table.test.tsx: the template row andopportunityAuditUrls._pages-table.test.tsx:groupPagesByTemplateand the group headers._bulk-bar.test.tsx: a template's pages counted against the quota./blog/pages on the demo brand's primary domain, three audited with shared gaps.🤖 Generated with Claude Code