feat(observability): configure PostHog error tracking#385
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
8e80334 to
e74924d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 405e4554ed
ℹ️ 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".
| if (process.env.NEXT_PUBLIC_POSTHOG_KEY) { | ||
| posthog.captureException(error) |
There was a problem hiding this comment.
Initialize PostHog before global error capture
When this shared ErrorBoundary is rendered from app/global-error.tsx, it is outside RootLayout/ClientProviders, so PostHogProvider never runs posthog.init; checking only NEXT_PUBLIC_POSTHOG_KEY here calls captureException on an uninitialized singleton and drops root-layout/provider failures. Use a path that initializes a client for the global fallback, or guard on a loaded client and handle global errors separately.
Useful? React with 👍 / 👎.
49a5aac to
5a89430
Compare
- Enable capture_exceptions (unhandled errors + rejections) in the PostHog provider and tag every event with an `environment` super-property derived from NEXT_PUBLIC_VERCEL_ENV (prod/preview/dev). - Report React render errors via posthog.captureException in the shared ErrorBoundary, and wrap the dashboard layout in a PostHogErrorBoundary. - Upload source maps during the build via @posthog/nextjs-config (deleteAfterUpload), gated on POSTHOG_API_KEY, release = commit SHA. - Add POSTHOG_API_KEY / POSTHOG_PROJECT_ID / NEXT_PUBLIC_VERCEL_ENV to the env schema and .env.example. - Mask the raw error message in the shared ErrorBoundary and vertically center the dashboard route error.
5a89430 to
ac6b8b8
Compare
Enables PostHog error tracking for the dashboard. Turns on
capture_exceptions(unhandled errors + rejections) and tags every event with anenvironmentsuper-property (fromNEXT_PUBLIC_VERCEL_ENV) so prod/preview/dev are distinguishable. Currently will be running only inprod.Reports React render errors via
posthog.captureExceptionin the sharedErrorBoundaryand wraps the dashboard layout in aPostHogErrorBoundary. Uploads source maps during the build via@posthog/nextjs-config(gated onPOSTHOG_API_KEY,deleteAfterUpload, release = commit SHA), with the new build-time env vars documented inenv.ts/.env.example.