Overview
Kuest integrates with Sentry for comprehensive error tracking, performance monitoring, and debugging. This guide covers monitoring setup, health checks, and troubleshooting.Sentry Integration
Configuration
Sentry is configured in multiple files for complete coverage:Environment Variables
Configure Sentry in your.env file:
Create Sentry Project
- Sign up at sentry.io
- Create a new project (choose Next.js)
- Copy your DSN from project settings
Error Tracking
Automatic Error Capture
Sentry automatically captures:Unhandled Exceptions
Runtime errors that crash the application
Promise Rejections
Unhandled rejected promises
Server Errors
API route failures and server-side errors
Client Errors
Browser-side JavaScript errors
Manual Error Reporting
Capture errors explicitly when needed:Error Context
Enrich errors with additional context:Health Checks
API Health Endpoint
While not explicitly implemented in the source, you should add a health check endpoint:Cron Job Monitoring
Monitor automated tasks:Database Health
Monitor database performance:Performance Monitoring
Transaction Tracking
Track performance of key operations:Custom Metrics
Track business metrics:Logging Best Practices
Structured Logging
Use consistent log formats:Log Levels
Use appropriate log levels:Sensitive Data
Never log sensitive information:Alerting
Sentry Alerts
Configure alerts in Sentry dashboard:Error Rate Alerts
Alert when error rate exceeds threshold:
- Trigger: > 10 errors in 5 minutes
- Notify: Email, Slack, PagerDuty
Performance Degradation
Alert on slow transactions:
- Trigger: P95 latency > 3 seconds
- Notify: Slack channel
Cron Job Failures
Alert when scheduled tasks fail:
- Trigger: Cron job returns error status
- Notify: On-call engineer
Custom Alerts
Implement application-level alerts:Debugging
Error Context
Access full error context in Sentry:- Stack Trace: See where the error occurred
- Breadcrumbs: User actions leading to the error
- User Context: Who experienced the issue
- Environment: Browser, OS, app version
- Request Data: URL, headers, body
Source Maps
Debug minified production code:Replay Sessions
Enable session replay for visual debugging:Monitoring Checklist
Daily Monitoring
Daily Monitoring
- Check Sentry dashboard for new errors
- Review error trends and patterns
- Verify cron jobs executed successfully
- Check API response times
- Monitor database query performance
Weekly Reviews
Weekly Reviews
- Analyze error rate trends
- Review most common errors
- Check performance regressions
- Verify alert configurations
- Update monitoring thresholds
Monthly Maintenance
Monthly Maintenance
- Archive old Sentry issues
- Review and update alert rules
- Analyze monitoring costs
- Update documentation
- Test monitoring infrastructure
Troubleshooting
Sentry Not Capturing Errors
Issue: Errors occur but don’t appear in Sentry. Solution:- Verify
SENTRY_DSNis set in environment variables - Check Sentry initialization in
instrumentation.ts - Ensure errors are not caught without re-throwing
- Verify network connectivity to Sentry servers
- Check browser console for Sentry initialization errors
Source Maps Not Working
Issue: Stack traces show minified code. Solution:- Verify
SENTRY_AUTH_TOKENis configured - Check build logs for source map upload
- Ensure
sentry.propertiesfile exists - Verify organization and project names match
- Re-upload source maps manually if needed:
High Error Volume
Issue: Too many errors flooding Sentry. Solution:- Identify and fix the most common error first
- Add error grouping rules in Sentry
- Implement rate limiting on error capture
- Filter out known non-critical errors
- Use
beforeSendto sample errors:
Performance Overhead
Issue: Monitoring impacting app performance. Solution:- Reduce
tracesSampleRate(e.g., 0.01 for 1%) - Disable session replay on low-end devices
- Limit breadcrumb collection
- Use edge runtime for critical paths
- Implement sampling strategies
Related Resources
Sentry Documentation
Official Sentry Next.js integration guide
Admin Panel
Monitor platform operations
Resolution Sync
Monitor resolution synchronization
Deployment
Production deployment best practices