
Error Monitoring in Production: Beyond console.log
The Gap Between Dev and Prod In development, errors are visible. In production, they're silent. A user hits a bug, refreshes, gives up. You never know. Until enough users give up that your retention numbers drop. Error monitoring closes that gap. Sentry: The Standard npm install @sentry/nextjs # or npm install @sentry/node // sentry.server.config.ts import * as Sentry from ' @sentry/nextjs ' ; Sentry . init ({ dsn : process . env . SENTRY_DSN , environment : process . env . NODE_ENV , tracesSampleRate : process . env . NODE_ENV === ' production ' ? 0.1 : 1.0 , // Filter out noise ignoreErrors : [ ' ResizeObserver loop limit exceeded ' , /^Network Error/ , ], beforeSend ( event , hint ) { // Don't send errors from bots const ua = event . request ?. headers ?.[ ' user-agent ' ] ?? '' ; if ( /bot|crawler|spider/i . test ( ua )) return null ; return event ; }, }); Capturing Errors with Context try { await processPayment ( userId , amount ); } catch ( error ) { Sentry . withScope (( scope )
Continue reading on Dev.to
Opens in a new tab


