Domain Rating + citation-landscape insights on the Citations page#327
Open
jrhizor wants to merge 9 commits into
Open
Domain Rating + citation-landscape insights on the Citations page#327jrhizor wants to merge 9 commits into
jrhizor wants to merge 9 commits into
Conversation
Pulls Ahrefs free Domain Rating per cited domain (cached locally via node:sqlite at $DR_CACHE_PATH) and adds an experimental insights area: DR citation quadrants with category toggles + authority verdict, a per-prompt citation map, sortable/searchable/filterable cited-domain (with DR + run-based volatility) and cited-URL data tables, plus source-type, scoreboard, kingmaker, winnability and branded/unbranded cuts. Reads-only over Postgres + the DR cache; no DB schema changes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Adds a global domain_ratings table (migration file only — NOT applied) caching Ahrefs DR per domain with a ~1-week TTL. New Postgres store mirrors the SQLite loader and is selected via DR_CACHE_BACKEND=postgres (default stays sqlite, so nothing activates until the migration is applied). Resilient: bulk PK load handles thousands of domains in one query; transient Ahrefs failures are never written (no cache poisoning); a single failing domain never aborts the batch; DB errors degrade gracefully.
Cleanup pass: removed the low-signal cards (scoreboard, source-type mix, kingmakers, possible-untracked-competitors, winnability, authority-bar-by-source-type). The landscape block is now Cited domains + Cited URLs data tables, a Competitor page opportunities prompt-bubble graph (demand vs. your citation share), and the per-prompt citation map. The server still returns the removed aggregates (unused by the UI) — can be trimmed in a follow-up.
…lists Server fn now computes only what the UI renders (cited-domains/URLs tables, per-prompt map); dropped the unused scoreboard/source-type/kingmaker/winnability/etc. aggregations and the orphaned getCitationPromptDomainStats read. Removed the old Top Cited Domains/URLs lists from citations-display (superseded by the new sortable data tables); kept the stats, what's-changed, opportunities, and subreddit sections.
… dead CitationsDisplay props Prompt-detail citations tab now renders the sortable/searchable CitedDomainsTable (DR/volatility columns hidden — no per-prompt DR) + CitedUrlsTable, restoring the lists lost when those sections moved out of the shared CitationsDisplay. Removed the now-unused brandName/maxDomains/maxUrls/onCompetitorAdded props from CitationsDisplayProps and both callers.
Conflicts resolved (citations rework #325 vs DR-experiment): - server/citations.ts: take main's getCitationsFn rewrite (Google module, page types, domain-categories.server split); keep the experiment's citation-filters helper (resolveEnabledPromptIds/hasTagFilter) which domain-ratings.ts also depends on. Faithful extraction of main's inline filter, so behavior is unchanged. - citations-display.tsx: take main's full component (Top Cited tables, Google Shopping, TrackDomainPopover). - citations.tsx route: render main's CitationsDisplay (with onCompetitorAdded + restored useQueryClient/brandKeys/dashboardKeys) and keep the experiment's DomainRatingCorrelation + CitationInsights below it. - prompts/$promptId.tsx: keep the experiment's CitedDomains/UrlsTable restore alongside CitationsDisplay; merge both import sets. - citation-insights.ts / domain-ratings.ts: import categorizeDomain from domain-categories.server (main moved it out of domain-categories).
Resolved against main's citations split (#336/#358 filtered-list shell, #353 prompt Google Shopping, #354 dep bumps): - server/citations.ts: keep citation-filters helper; take main's postgres-read import + google-module.ts extraction (dropped now-unused PerPromptCitationPageRow / getEffectiveBrandedStatus). - citations.tsx route: adopt main's FilteredListShell + useListFilters (router search params) structure; render DomainRatingCorrelation + CitationInsights inside the shell children, adapted to filters.tags. - apps/web/package.json: main's @TanStack bumps + keep @tanstack/react-table (DR cited-tables dep). - pnpm-lock.yaml: took main's lockfile, reran pnpm install to add react-table. - prompts/$promptId.tsx, citations-display.tsx, postgres-read.ts auto-merged; cited-tables restore + DR cache preserved, Google Shopping intact via CitationsDisplay. typecheck clean, 172 web unit tests pass.
Relocate the DR-experiment components alongside main's citation cards: - domain-rating-correlation.tsx, citation-insights.tsx, citation-tables.tsx → apps/web/src/components/citations/ - update imports in the citations route, prompt-detail, and stories. Left rendered as route-level siblings of CitationsDisplay (they self-fetch via useDomainRatings/useCitationInsights), since CitationsDisplay stays a pure presentational composition fed by citationData.
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.
What
A Domain Rating (DR) + citation-landscape area on the Citations page, built on Ahrefs' free, key-less DR API. Exploratory; iterated down to a focused set.
DR cache
packages/lib/src/ahrefs.ts— freedomain-rating-freeendpoint (no key). Transient failures (429/5xx) throw and are never written, so the cache can't be poisoned.apps/web/src/lib/domain-rating-cache.ts), selected byDR_CACHE_BACKEND:sqlite(default) — localnode:sqlitefile (temporary/experiment).postgres— the new global, cross-hostdomain_ratingstable (~1-week TTL). Migration file is committed but NOT applied (0010_domain_ratings_cache.sql); setDR_CACHE_BACKEND=postgresafter applying it. Bulk PK load handles thousands of domains in one query; one failing domain never aborts the batch; DB errors degrade gracefully.On the page
@tanstack/react-table+ shadcntable). The domains table folds in DR + run-based citation volatility as sortable columns.Notes
citations-display.tsx.Verification
@workspace/lib215 tests,@workspace/web127 tests pass;tsc --noEmit+biome lintclean on changed files. Storybook stories added (browser render not run here — no Playwright browser in this env).