Repository navigation
feat(audit): list pages worth auditing in a Site Audit Opportunities tab - #1136
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]>
|
@gkhngyk This is SA-004 from the Site Audit v2 spec (first sources): an Opportunities tab listing GA's valuable pages without AI traffic and site pages never audited or audited over 90 days ago, with Audit selected / Pin / Exclude. It adds migration 00164 (site_audit_page_prefs; applied on the dev DB). Competitor-cited pages come next in their own PR; the Search Console sources need a page-level GSC sync first. Thanks! |
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]>
gkhngyk
left a comment
There was a problem hiding this comment.
The branch already merges current main; I reran its checks on that tree. The opportunities, audits-opportunities route, bulk bar and Opportunities table tests, typecheck, lint and format pass, and CI is green.
00165 (site_audit_page_prefs) is applied on production. RLS is on with the member select policy only, so pins and exclusions are written by the server alone. site_pages holds at most 500 rows per brand on production, under the 1000-row page the route reads it in.
Summary
Site Audit gets an Opportunities tab: the brand's pages worth auditing, each with why, ready to audit in bulk, pin or exclude. This is SA-004 of the Site Audit v2 spec, with its first sources. Until now audits covered only the URLs someone typed, and nothing suggested which pages to audit (F5, F7).
Sources in this PR
page_opportunities. These are valuable pages (revenue, transactions, key events or engagement in the site's top 30%) that AI engines send no visitors to. The rows are already computed nightly with the GA sync.site_pages(sitemap, GA and cited pages; up to 500) that were never audited, or whose last audit is older thanauditMaxAgeDays(90, the Action Center's threshold).Not in this PR:
Server
GET /api/audits/opportunities?brandId=…(pure logic inlib/audit/opportunities.js):www., path without a trailing slash), lowercased as GA paths are. Both sources merge into one row.no_ai_trafficwith signal, percentile and citation state;never_audited;stale_auditwith days);ae_page_traffic_evidence: Analytics where it has the page, else the snippet, never both (asmergeTrafficPages). The value is null when the brand has neither.isExcludedPath), unless pinned;00165_site_audit_page_prefs.sql:pinned/excludedrow per brand and page (unique (brand_id, page_key)).PUT /api/audits/opportunities/prefs({ brandId, urls, state }, Zod): pins, excludes, or clears (null) pages, once per page key.Web
audit/_opportunities-table.tsx):Deploy
Apply 00165. It was 00164 until main took that number for the insights topic rollups (#867).
Known limits
Related issue
None. Site Audit v2 spec, task SA-004 (first sources).
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/): 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 test(1519) pass.lib/audit/opportunities.test.js:routes/audits-opportunities.test.js:web:yarn test(1327) andyarn buildpass._opportunities-table.test.tsx: chips, links, selection (running pages left out), Show more, excluded pages and Restore, the empty state._bulk-bar.test.tsx: the table's own label and actions, and no Export without one.bash supabase/build-schema.sh: regeneratedschema.sql.🤖 Generated with Claude Code