Cursor prompt
Add Error Monitoring with Sentry
Integrate Sentry with proper user context, breadcrumbs, React error boundaries, and custom error classification.
Integrate Sentry error monitoring into {{project_name}}. ## Framework: {{framework}} ## Sentry DSN: Set via environment variable SENTRY_DSN ### Installation and Configuration Install @sentry/nextjs. Configure sentry.client.config.ts and sentry.server.config.ts. Set up source map upload in next.config.js for readable stack traces in production. Set Sentry release from git commit SHA; set environment from NODE_ENV. ### User Identification ```typescript // On login Sentry.setUser({ id: user.id, email: user.email }); // On logout Sentry.setUser(null); ``` ### Custom Error Classes ```typescript class AppError extends Error { constructor( message: string, public readonly code: string, public readonly statusCode: number, public readonly isOperational: boolean = true ) { super(message); } } ``` Tag isOperational: false errors as bugs — alert on-call immediately. Operational errors (user input errors, external API failures) are expected — log, don't page. ### React Error Boundaries Wrap each major page section separately (don't catch everything globally). Show user-friendly fallback with error ID they can report. ```tsx <Sentry.ErrorBoundary fallback={<ErrorFallback />} showDialog> <ExpensiveComponent /> </Sentry.ErrorBoundary> ``` ### Breadcrumbs Add breadcrumbs for: user actions, API calls (method/url/status), route changes. ### Performance Monitoring tracesSampleRate: 0.1 in production. Add custom spans for DB queries > 50ms. ### Output Sentry config files, AppError class, ErrorBoundary component, API error handler.
Fill in: {{project_name}}, {{framework}}. In Loopy you fill these in a form and copy the finished prompt in one click.

