feat: send X-Spoo-Client attribution header on backend calls - #23
Conversation
Every request to the spoo.me backend now carries X-Spoo-Client so the API can attribute traffic by client. One wrapper (apiFetch) stamps the header; the surface is inferred from the route: /dashboard and /onboarding send dashboard, everything else sends landing. Third-party fetches (favicon upstream, geo assets) stay untouched.
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (10)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Zingzy
left a comment
There was a problem hiding this comment.
Mergeable, nothing blocking. One cross-repo observation worth a conscious call, inline below.
Coverage traced rather than assumed:
- Every remaining raw
fetchin the repo is deliberately untagged:apiFetch's own inner call, the country-map static asset, and the favicon proxy upstream (third-party host).lib/api/server.tsonly builds the base URL; the server-side public page fetches go through the convertedgetPublicStats/getPublicPreview. Coverage is complete. authedFetchroutes throughapiFetchon both the original request and the post-refresh retry, and the refresh call itself is tagged.headers.setstamps last, so a caller-providedX-Spoo-Clientcan never slip through. Right default.- The
/dashboardishtest case pins the route-boundary regex, which is exactly the case that would have silently misclassified.
Ran the new apiFetch tests locally (5 pass); repo checks are green.
Every request this app makes to the spoo.me backend now carries an
X-Spoo-Clientheader so the API can attribute traffic by client.Values sent:
dashboardwhen the call originates from the signed-in app (routes under/dashboardand/onboarding)landingfor the public surface (home shorten box, public stats and preview pages, report and contact forms, error pages) and for server-side fetches, which only happen from public pagesThe header is stamped in one place: a new
apiFetchwrapper inlib/api/client.tsthat infers the surface from the current route.authedFetchand the refresh call go through it, and the handful of rawfetchcallsites inlib/apiand components were switched over. Third-party fetches (favicon upstream, static geo assets, PostHog relay) are untouched and never see the header.No CORS coordination needed: every browser call rides the same-origin rewrite proxy, so no preflight is involved and this can merge independently of the backend change that reads the header. Until that lands the backend simply ignores it.
Includes unit tests for the surface inference and header injection.