Skip to content

Code-resolved env config, PostHog error tracking, email + auth UX fixes#645

Open
spashii wants to merge 5 commits into
mainfrom
feat/code-resolved-env-and-error-tracking
Open

Code-resolved env config, PostHog error tracking, email + auth UX fixes#645
spashii wants to merge 5 commits into
mainfrom
feat/code-resolved-env-and-error-tracking

Conversation

@spashii

@spashii spashii commented Jun 10, 2026

Copy link
Copy Markdown
Member

What

Environment config in code (no more Vercel env vars)

  • src/config.ts resolves the environment (production / next / testing / local) from the hostname and exposes byEnv(). Base URLs (API, Directus, dashboard, portal), PostHog token/host/capture, agentic chat, and the agentation overlay all resolve in plain code.
  • PostHog: production reports to project 160282, next to 197841 (echo-next); testing and local opt out of capture entirely. Loopback hosts on any port count as local, so a prod build run via vite preview never pollutes prod analytics.
  • Participant router auto-detects portal.* hostnames. VITE_* vars remain honored as escape-hatch overrides, so existing Vercel vars can be deleted gradually without breakage.
  • frontend/.env and .env.sample deleted; .env.example documents the overrides.

Sentry removed, PostHog error tracking wired

  • @sentry/react uninstalled; init, DSNs, and all capture sites removed.
  • capture_exceptions autocapture in posthog.init, posthog.captureException at the former Sentry call sites, and the shared ErrorBoundary reports React render errors with component stacks.

Error surface

  • ErrorPage is auth-aware: a logged-out visitor on an errored or unmatched route (e.g. /en-US/w) is redirected to /login?next=... instead of seeing "Oops!". Logged-in users get a real 404 or error with Reload / Return home. Participant portal and auth pages are excluded from the gate.

Registration page

  • "Trying to join an existing organization?" with a Read more disclosure explaining wrong-email and needs-invite cases. Lingui catalogs extracted and compiled.

Email templates (all 20, both Directus liquid and SendGrid Jinja)

  • Single Regular (400) DM Sans weight and a single text color (graphite, Royal Blue for links/CTA), per brand/STYLE_GUIDE.md "one or two weights max".
  • New minified logo PNG at 30px (2x asset), served from frontend/public/dembrane-logo-email.png. Templates point at the echo-next dashboard host for the verify-first release; flip to dashboard.dembrane.com at GA.

Notes for reviewers

  • The deployed confirmation email's off-brand styling is a stale dbr-echo-directus image; these template fixes reach inboxes only after that image is rebuilt and redeployed.
  • Agentation's JSX __source Babel transform is now on in every build (runtime gate decides rendering; prod never downloads the lazy chunk). Main bundle grows ~290 kB raw; VITE_ENABLE_AGENTATION=0 builds without it.
  • Email weight change overrides the designer's DM Sans Light in favor of the brand guide's Regular-only scale; flag to design.
  • Vercel preview URLs (*.vercel.app) resolve to production; say the word if previews should map to next.

Test plan

  • tsc --noEmit, biome, and full vite build pass
  • Jinja templates parse; agentation verified in a separate lazy chunk
  • On echo-next: logged-out /en-US/w redirects to login; register flow shows the disclosure; emails render single weight/color with the new logo

🤖 Generated with Claude Code

…h UX fixes

Frontend:
- Resolve environment (production/next/testing/local) from hostname in
  src/config.ts via byEnv(); base URLs, PostHog, agentic chat, and the
  agentation overlay all resolve in code. No Vercel env vars needed.
- Replace Sentry with PostHog error tracking (capture_exceptions autocapture,
  captureException at former Sentry call sites, ErrorBoundary reporting).
- Auth-aware ErrorPage: logged-out visitors on errored or unmatched routes
  redirect to /login; fallbacks offer Reload and Return home.
- Registration page: "Trying to join an existing organization?" disclosure.
- Delete .env and .env.sample; .env.example documents escape-hatch overrides.

Emails (directus/templates + server/email_templates):
- Single Regular (400) DM Sans weight, single text color (graphite) with
  Royal Blue accents, per brand guide.
- Logo: new minified PNG at 30px, served from frontend/public on echo-next
  (flip host to dashboard.dembrane.com at GA).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@spashii spashii force-pushed the feat/code-resolved-env-and-error-tracking branch from c579871 to 197c38d Compare June 10, 2026 17:17
… hatch

- Base URLs (API, admin, participant, Directus), Slack URL, and Plausible
  host are plain code now; byEnv() covers every environment.
- Participant router detects portal.* hostnames, or port 5174 locally, so
  the participant:dev script needs no env var.
- Delete .env.example: the frontend has no env files at all. The two
  remaining knobs (VITE_DEBUG_MODE, VITE_ENABLE_AGENTATION=0) are
  documented in AGENTS.md.
- Note that plausible.io is already the EU host (EU-owned, German servers).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Replace plausible-tracker with posthog.capture at every call site;
  snake_case past-tense names per convention. Remove the analytics
  wrapper, event constants, dep, and PLAUSIBLE_API_HOST. Pageviews come
  from PostHog defaults (history_change), so no pageview tracker.
- Merge near-duplicates: contact_sales_clicked with a source property;
  chat_mode_selected captured once inside ChatModeSelector for all
  entry points (was split between a Plausible click event and a
  route-level capture). Audio interruption stays on captureException.
- New funnel events: workspace_request_started (UpgradeModal open,
  pairs with workspace_request_submitted) and
  registration_details_completed (pairs $pageview -> user_registered).
- CSP: drop Sentry and Plausible hosts, allow eu.i.posthog.com and
  eu-assets.i.posthog.com (PostHog was not in the CSP at all).
- Drop two dead Plausible events (announcement created, Slack join)
  and the unused ReactQueryDevtools import.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Unknown hostnames (Vercel previews, LAN IPs) now resolve to "next"
  instead of "production": prod requires an explicit hostname match, so
  stray hosts can never capture into prod analytics or hit prod backends
- ErrorPage no longer shows the not-found message for non-404 route
  errors; fallback copy now branches on isNotFound
- PostHog loaded callback opts back in when capture is enabled, so a
  persisted opt-out can't outlive a config flip (no $opt_in event)
- useAuthenticated takes an enabled flag; ErrorPage disables the session
  query on the participant portal instead of firing a doomed refresh
- ErrorBoundary honors fallback={null} as "render nothing" instead of
  falling through to the full-height default screen
- ErrorPage and ErrorBoundary strings wrapped in Lingui Trans; catalogs
  extracted, new error-surface strings translated, compiled
- Root AGENTS.md feature-flag section updated: frontend flags are code
  constants via byEnv(), not VITE_* env vars

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant