Repository navigation
feat(web): owner analytics dashboard at /u/<handle>/dashboard - #164
Conversation
A dashboard link carries a 15-minute, single-use grant. next.config rewrites the grant-bearing request (beforeFiles, keyed on the grant query) to a route handler that exchanges it server-to-server with the relay-agent registry, sets an HttpOnly/Secure/SameSite=Lax session cookie scoped to the dashboard path with the session's absolute expiry, and 303s to the bare URL. No page, layout, or PostHog code runs for the exchange, and the grant is never echoed. The force-dynamic page reads the cookie server-side, fetches 7- and 30-day stats with the Bearer session, and renders daily conversations, messages, replies, latency, visitor-days, clients, countries, and outcomes, with expired, unavailable, empty, and estimated states. Exchange, redirect, and page responses are private/no-store, no-referrer, and CSP-locked; the page is noindex. PostHog page views and all captured events are dropped on dashboard paths. A Node-runtime proxy.ts was not used: OpenNext Cloudflare 1.20 refuses Node middleware at build time. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Session-Id: 8fa30995-3394-4357-aadf-23aee1464578
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 238a0da0a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
- GET/HEAD on a grant link renders a static, script-free confirmation; only its same-origin POST redeems the single-use grant, so link scanners, unfurlers and prefetchers cannot burn it. - A failed exchange clears any older handle-scoped session cookie. - The empty state considers every displayed metric. - Dashboard content is blocked from session replay (ph-no-capture). - Zero-conversation days render a zero-width bar. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Session-Id: 8fa30995-3394-4357-aadf-23aee1464578
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ced0e22. Configure here.
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…n check - A failed or replayed exchange redirects to ?link=used and leaves the cookie alone, so Back, a double submit, or a cross-site form cannot log the owner out; the page shows a notice above the current session. - The exchange requires an exact https origin (scheme, host, and port). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Session-Id: 8fa30995-3394-4357-aadf-23aee1464578
|
Preview deployed!
This is a Cloudflare Workers preview version of this PR's build. |

The company dashboard from relay-agent's
docs/ANALYTICS_BRIEF.md§5. Backend: AgentWorkforce/relay-agent#16 (link, exchange, and stats endpoints). Router companions: #162, which keeps/u/*and?grant=URLs out of the traffic recorder.Flow
The owner opens
https://agentrelay.com/u/<handle>/dashboard?grant=<signed grant>, a 15-minute single-use link fromPOST /api/v1/agents/<handle>/manage/dashboard-link.A
beforeFilesrewrite innext.config.mjs, keyed on a non-emptygrantquery, sends that request to the route handler/u/<handle>/dashboard/exchange. No page, layout, or PostHog code runs.proxy.tswas not used: Next 16 proxies run on the Node runtime, which OpenNext Cloudflare 1.20 rejects.value: '.+'is explicit because OpenNext treats a query condition with no value as always matching.The handler validates the handle (404 if invalid) and exchanges the grant server-to-server at
arelay.to/api/v1/agents/<handle>/dashboard/exchange.__Secure-relay_dashboardwithHttpOnly; Secure; SameSite=Lax; Path=/u/<handle>/dashboard; Expires=<the grant's absolute expiry>, never extending it.private, no-store,no-referrer, CSPdefault-src 'none'; frame-ancestors 'none'.The page is a server component. It reads the cookie, fetches 7- and 30-day stats server-to-server with the Bearer session, and renders:
The session never reaches client components, storage, analytics, or logs. Page headers are
private, no-store,no-referrer, CSPframe-ancestors 'none', and noindex.PostHog: dashboard paths are excluded from page views, and a
before_senddrops every event raised on a dashboard path.Tests
expiresAt;npm test: web 457/457, router 110/110.tscis clean,npm run buildsucceeds, andverify:recommended-flowspasses.next startsmoke test checked the grant 303 and its headers, the bare page's expired state, and the invalid-handle 404.Not verified locally: the OpenNext
cf:buildWorker itself. The preview deploy will exercise the rewrite and headers.🤖 Generated with Claude Code
Note
Medium Risk
Introduces grant-to-session auth, cookie scoping, and cross-origin exchange rules on a new sensitive surface; mitigated by server-only sessions, no grant echo, and broad test coverage.
Overview
Adds a private owner analytics dashboard at
/u/<handle>/dashboard, opened via a single-use?grant=link from the registry API.Access flow:
next.config.mjsrewrites grant-bearing requests to an exchange route before any React/PostHog runs. GET/HEAD shows a script-free confirmation page so scanners cannot burn the grant; only a same-origin POST redeems it server-to-server, sets a path-scopedHttpOnlysession cookie, and 303s to the bare URL (failures redirect with?link=usedand never clear an existing cookie). The dashboard page is a server component that reads the cookie and fetches 7/30-day stats as Bearer auth only on the server.Privacy: Dashboard paths get strict no-store/no-referrer/CSP/noindex headers; main content is marked for session-replay masking. PostHog adds
dropAgentDashboardAnalyticsinbefore_sendand excludes dashboard routes from site page tracking.UI: New dashboard page and CSS render comparisons, daily metrics, latency, visitor-days, and client/country/outcome breakdowns, with expired, empty, and unavailable states.
agent-registryexportsREGISTRY_ORIGINandreadBoundedBodyfor the newagent-dashboardhelpers. Lib and page tests cover exchange, cookies, headers, stats validation, routing config, and analytics exclusion.Reviewed by Cursor Bugbot for commit 895470b. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds the owner analytics dashboard at
/u/<handle>/dashboard, reachable only through a 15-minute single-use grant link issued byPOST /api/v1/agents/<handle>/manage/dashboard-link. Depends on the relay-agent exchange and stats endpoints in AgentWorkforce/relay-agent#16.Flow and privacy
HttpOnly,Secure,SameSite=Laxsession cookie scoped to the dashboard path with the grant's absolute expiry, and 303s to the bare URL.?link=used, so a Back press, double submit, or cross-site form can't log the owner out — the page keeps the current session and shows a notice.private, no-store,no-referrer, and CSP-locked; the page is noindex and dashboard paths are excluded from PostHog page views and captured events.proxy.tswas not used because Next 16 proxies run on the Node runtime, which OpenNext Cloudflare rejects.Dashboard content and test coverage
tscandnpm run buildare clean, and a localnext startsmoke test verified the redirect, headers, expired state, and invalid-handle 404.Written for commit 895470b. Summary will update on new commits.
Agent Relay sessions
claudesession8fa30995· opened viagh pr create· last active 2026-10-08