Skip to content

Session hydration, viewport export, Sentry sampling and auth field errors - #2052

Merged
yusuftomilola merged 2 commits into
DistinctCodes:mainfrom
akargi:feature/ui-metadata-sentry
Oct 18, 2026
Merged

yusuftomilola merged 2 commits into
DistinctCodes:mainfrom
akargi:feature/ui-metadata-sentry

Conversation

@akargi

@akargi akargi commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the session/config/monitoring work assigned to Akargi:

Test updates

  • require-admin.test.tsx — rewritten for the hydrated gate + cross-tab sign-out
  • auth-form.test.tsx — 5 new cases for 400 field arrays, 409, 429, 401, error clearing
  • session-store.test.ts (new) — hydration state machine, signal emission, private-browsing safety
  • sentry-client-config.test.ts — defaultTracesSampleRate + describeException coverage
  • payment-return-page.test.tsx — added use-session-hydration mock

Notes for reviewers

  • The session-store changes are additive: setAccessToken and the cookie behaviour are unchanged, so sign-in and sign-out keep working exactly as before. The only new behaviour is that the token starts as null and is populated by the hydration effect.
  • The Sentry server/edge configs now import from lib/sentry-sampling.ts instead of hardcoding tracesSampleRate: 1.0. This changes the default production behaviour from 100% to 10% sampling.
  • The auth-form changes are purely additive: existing behaviour (success redirect, password confirmation mismatch) is unchanged.
  • Merge coordination: ykargeee-bit's auth PR (Cookie-based session model, admin role gate and 401 handling #2049) replaces the session store wholesale; if both merge, resolve in favour of Cookie-based session model, admin role gate and 401 handling #2049's cookie session semantics and re-apply this PR's hydration gating on top.

Closes #1988
Closes #1987
Closes #1986
Closes #1983

…rors (Akargi)

- DistinctCodes#1983: hydrate the session store once inside a client effect instead of
  reading the cookie at store creation / during render. Adds a `hydrated`
  flag, a `useSessionHydration` hook and a `useSessionToken` replacement
  for the old non-reactive `useAdminToken` cookie read. All render-time
  cookie reads on /usage, /credits, /payments, /payments/new,
  /payments/return and the admin pages are replaced by store-driven,
  hydration-gated rendering, so the first client render matches the SSR
  output. Cross-tab sign-out syncs via a localStorage signal + storage
  event listener.
- DistinctCodes#1986: export `viewport` separately from `metadata` in app/layout.tsx
  (Next.js 14 requirement) with the same theme colour as app/manifest.ts.
- DistinctCodes#1987: unify Sentry sampling in lib/sentry-sampling.ts shared by the
  client, server and edge configs. Default trace sampling is 1.0 in
  development and 0.1 in production. Session replays are opt-in only
  (default 0). The beforeSend hook no longer crashes on non-Error
  rejections: strings, undefined and plain objects are reported as
  NonError events with a stringified message. SENTRY_SETUP.md documents
  the defaults.
- DistinctCodes#1988: auth API errors now carry structured field information
  (AuthApiError with status + fieldErrors). The auth form renders 400
  validation messages next to their own input (aria-invalid,
  aria-describedby), maps 409 taken-email onto the email field, shows a
  single form-level message for 429 rate limiting, and focuses the first
  invalid field. Field errors clear as the user edits.

Notes for reviewers:
- The session-store changes are additive: `setAccessToken` and the cookie
  behaviour are unchanged, so sign-in and sign-out keep working exactly
  as before. The only new behaviour is that the token starts as null and
  is populated by the hydration effect.
- The Sentry server/edge configs now import from lib/sentry-sampling.ts
  instead of hardcoding tracesSampleRate: 1.0. This changes the default
  production behaviour from 100% to 10% sampling.
- The auth-form changes are purely additive: existing behaviour (success
  redirect, password confirmation mismatch) is unchanged.
@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@akargi is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@akargi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…ession model, drop cookie-hydration hook, re-add AuthApiError field errors on the shared request layer
@yusuftomilola
yusuftomilola merged commit f2302cc into DistinctCodes:main Oct 18, 2026
1 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment