(SP: 2) [Monitoring] Add Sentry for production error tracking#307
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for develop-devlovers ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughIntegrates Sentry into the Next.js frontend: adds Sentry configs for server/edge, client instrumentation, a client-side global error boundary, updates Next.js config to wrap with Sentry, and updates package and gitignore. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@frontend/instrumentation-client.ts`:
- Around line 7-16: The Sentry client init is using scaffold defaults; update
the Sentry.init call to (1) read dsn from process.env.NEXT_PUBLIC_SENTRY_DSN
instead of hardcoding, (2) set sendDefaultPii to false, (3) set tracesSampleRate
to 0.1, (4) include environment and release using NEXT_PUBLIC_VERCEL_ENV and
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA, and (5) gate initialization so it only runs
in production (mirror the server/edge enabled:isProduction behavior); locate and
modify the Sentry.init invocation in frontend/instrumentation-client.ts to apply
these changes.
In `@frontend/package.json`:
- Line 33: The dependency version for "@sentry/nextjs" in package.json is
invalid; update the version string for the "@sentry/nextjs" dependency (the
entry named "@sentry/nextjs") from "^10.38.0" to a valid release such as
"10.10.0" (or any 10.10.x / lower valid tag) and save package.json so npm
install will succeed.
🧹 Nitpick comments (1)
frontend/app/global-error.tsx (1)
7-27: Consider accepting and using theresetprop for error recovery.The App Router's
global-errorcomponent receives aresetfunction alongsideerror. Without exposing a retry/reset button, users must do a full page reload to recover. This is a minor UX consideration.♻️ Optional: Add a reset button for error recovery
export default function GlobalError({ error, + reset, }: { error: Error & { digest?: string }; + reset: () => void; }) { useEffect(() => { Sentry.captureException(error); }, [error]); return ( <html lang="en"> <body> - {/* `NextError` is the default Next.js error page component. Its type - definition requires a `statusCode` prop. However, since the App Router - does not expose status codes for errors, we simply pass 0 to render a - generic error message. */} - <NextError statusCode={0} /> + <NextError statusCode={0} /> + <button onClick={() => reset()}>Try again</button> </body> </html> ); }
Add Sentry monitoring (production setup)
Goal
Add production-ready error and performance monitoring for DevLovers.
Scope
@sentry/nextjsResult
Closes #306
Summary by CodeRabbit
New Features
Chores