Sentry
Leave Localhost is pre-configured with Sentry for error tracking in the Next.js frontend (apps/app).
Leave Localhost is pre-configured with Sentry for error
tracking in the Next.js frontend (apps/app).
Setup
- Create a Sentry account and project.
- Add your DSN to the environment variables:
NEXT_PUBLIC_SENTRY_DSN=https://...@...sentry.io/...- For sourcemap uploading during Vercel builds, provide the Auth Token:
SENTRY_AUTH_TOKEN=...
SENTRY_ORG=...
SENTRY_PROJECT=...Configuration Files
Sentry configuration lives in three files in apps/app:
sentry.client.config.ts— Browser configuration.sentry.server.config.ts— Node.js runtime configuration.sentry.edge.config.ts— Edge runtime configuration.
The Next.js instrumentation.ts and instrumentation-client.ts hooks load
these configurations automatically when NODE_ENV === "production".
Development vs Production
Sentry initialization is wrapped in a check:
if (
process.env.NODE_ENV === "production" &&
process.env.NEXT_PUBLIC_SENTRY_DSN
) {
Sentry.init({ ... });
}This prevents local development errors and test runner failures from polluting your Sentry dashboard.
Catching Errors
Sentry automatically catches:
- Unhandled React rendering errors
- Unhandled Promise rejections
- Next.js Route Handler exceptions
If you need to manually capture an error in a catch block:
import * as Sentry from "@sentry/nextjs";
try {
await doSomethingRisky();
} catch (error) {
Sentry.captureException(error);
// handle gracefully
}Error Handling
The backend utilizes a structured error handling pattern to ensure errors survive the Convex network boundary and arrive at the client with useful metadata.
Analytics (PostHog)
Leave Localhost uses PostHog as its first-class product analytics provider. All product and backend code talks to a single provider-neutral boundary, @leavelocalhost/analytics; only that package and the Convex analytics facade import the PostHog SDKs.