PoC: CrUX field data — Core Web Vitals dashboard card + get_core_web_vitals MCP tool - #243
Open
GambitIsHere wants to merge 1 commit into
Open
PoC: CrUX field data — Core Web Vitals dashboard card + get_core_web_vitals MCP tool#243GambitIsHere wants to merge 1 commit into
GambitIsHere wants to merge 1 commit into
Conversation
… check Real-user Core Web Vitals from the Chrome UX Report API, gated on an optional CRUX_API_KEY (hidden when unset, like OPENROUTER_API_KEY/SAM): - lib: cruxClient (queryRecord + queryHistoryRecord, 404 = expected no-data outcome) + leaf cruxErrors module - feature: CruxService (project domain -> origin, R2-cached 24h) + pure cruxShaping helpers; shared CWV thresholds in src/shared/cwv.ts - serverFunctions: getCruxApiKeyStatus + getCruxSnapshot - UI: CruxCard on the project dashboard - LCP/INP/CLS p75 tiles (lower-is-better tones), 28-day stamp, weekly-LCP trendline from the CrUX History API (useChartWidth, no ResponsiveContainer) - MCP: get_core_web_vitals (withMcpProjectAuth, defaults to the project domain) + /ai Available-tools entry - self-host preflight/health: crux check (info when key unset) Stateless by design: the History API supplies ~40 weeks of weekly p75s, so no DB tables or migrations. 11 new vitest tests; test/types:check/ lint/knip/prettier all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6 tasks
oluwaseunmauwedo
pushed a commit
to oluwaseunmauwedo/open-seo
that referenced
this pull request
Aug 25, 2026
ramonmnavarro-byte
pushed a commit
to ramonmnavarro-byte/open-seo
that referenced
this pull request
Aug 25, 2026
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.
Reference implementation for #242 — real-user Core Web Vitals from the Chrome UX Report API, gated on an optional
CRUX_API_KEY(hidden when unset, mirroring theOPENROUTER_API_KEY/SAM pattern).Per CONTRIBUTING this is a proof of concept, not a merge request — it exists to make #242 concrete and to be taken apart for inspiration.
What's inside
cruxClient(records:queryRecord+records:queryHistoryRecord; 404 modeled as an expectedno_dataoutcome, not an error) + leafcruxErrorsmodule (gscErrors pattern)CruxService(project domain → origin, R2-cached 24h with zod-validated reads) + purecruxShapinghelpers; shared thresholds/ratings insrc/shared/cwv.tsso the client never value-imports server codegetCruxApiKeyStatus+getCruxSnapshotCruxCardon the project dashboard — p75 LCP/INP/CLS tiles (lower-is-better tones), 28-day stamp, weekly-LCP trendline via the exporteduseChartWidth+formatDateTick(no ResponsiveContainer); four states (key missing / loading / no field data / data)get_core_web_vitals(withMcpProjectAuth, defaults to the project domain, optionalurl+formFactor) — registered inserver.tsand appended to the hardcoded /ai Available-tools listcruxpreflight/health check (info when unset) + the four env touches (package.jsonbindings,compose.yaml,.env.example,env.d.ts)Stateless: the History API supplies ~40 weeks of weekly p75s, so no tables or migrations.
Testing
types:check,lint(oxlint),knip,prettier --checkall cleancrux: ok, the card renders real data + trendline, the MCP tool returns the table belowNotes / open questions
worker-configuration.d.tsdeliberately not regenerated —wrangler typesoutput is machine/.env-dependent; the optional declaration follows theOPENROUTER_API_KEYprecedent inenv.d.ts.🤖 Generated with Claude Code