// Provide analysis and recommendations for error handling patterns, Sentry integration, and error monitoring strategies - ANALYSIS-ONLY skill that provides guidance without modifying code
| name | error-tracking |
| description | Provide analysis and recommendations for error handling patterns, Sentry integration, and error monitoring strategies - ANALYSIS-ONLY skill that provides guidance without modifying code |
| schema_version | 1 |
Type: ANALYSIS-ONLY DAIC Modes: DISCUSS, ALIGN, IMPLEMENT, CHECK (all modes) Priority: Medium
This skill activates on:
**/instrument.ts, **/sentry*.tsFrom: skill-rules.json - error-tracking configuration
Provide analysis and recommendations for error handling patterns, Sentry integration, and error monitoring strategies. This is an ANALYSIS-ONLY skill that never modifies code directly but provides guidance and suggestions.
In any DAIC mode (DISCUSS, ALIGN, IMPLEMENT, CHECK):
Error Handling Analysis
Sentry Integration Guidance
Error Monitoring Strategy
Best Practices Enforcement
ANALYSIS-ONLY RULES:
Recommendation Quality:
✓ "How should I handle errors in this Express route?" ✓ "Add Sentry to this project" ✓ "Review error handling in auth.js" ✓ "What errors should I track with Sentry?" ✓ "How do I capture user context with errors?"
Analysis:
### Error Handling Analysis: auth.js
**Issues Found:**
1. Line 45: Uncaught promise rejection in loginUser()
2. Line 67: Generic catch block without context
3. Missing error boundary for async middleware
**Recommendations:**
1. **Add Promise Rejection Handling (Line 45)**
```javascript
// Before
const user = await User.findOne({ email });
// After
try {
const user = await User.findOne({ email });
} catch (error) {
Sentry.captureException(error, {
tags: { operation: 'user_lookup' },
extra: { email }
});
throw new AuthenticationError('User lookup failed');
}
Enrich Error Context (Line 67)
// Before
catch (error) {
console.error(error);
}
// After
catch (error) {
Sentry.captureException(error, {
tags: {
auth_stage: 'token_verification',
user_id: userId
},
level: 'error'
});
res.status(401).json({ error: 'Authentication failed' });
}
Add Error Boundary Middleware
app.use((error, req, res, next) => {
Sentry.captureException(error, {
tags: {
path: req.path,
method: req.method
},
user: { id: req.user?.id }
});
res.status(error.status || 500).json({
error: process.env.NODE_ENV === 'production'
? 'Internal server error'
: error.message
});
});
### When NOT to Activate
✗ User is asking about general debugging (not error tracking)
✗ Question is about testing, not error handling
✗ Focus is on performance, not errors
✗ User wants to implement errors (recommend activating a WRITE-CAPABLE skill)
## Sentry Setup Recommendations
### Basic Node.js/Express Setup
```javascript
// instrument.js (must be first import)
const Sentry = require('@sentry/node');
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
tracesSampleRate: 0.1, // Adjust based on traffic
beforeSend(event, hint) {
// Filter sensitive data
if (event.request?.data) {
delete event.request.data.password;
delete event.request.data.token;
}
return event;
}
});
module.exports = Sentry;
Recommend error severity levels:
Critical - System failures, database connectivity
Sentry.captureException(error, { level: 'fatal' });
Error - Request failures, auth failures
Sentry.captureException(error, { level: 'error' });
Warning - Deprecations, rate limits
Sentry.captureMessage('Rate limit approaching', { level: 'warning' });
Info - Notable events
Sentry.captureMessage('Large file uploaded', { level: 'info' });
const asyncHandler = (fn) => (req, res, next) => {
Promise.resolve(fn(req, res, next))
.catch((error) => {
Sentry.captureException(error, {
tags: { route: req.route.path },
user: { id: req.user?.id }
});
next(error);
});
};
// Usage
app.get('/users/:id', asyncHandler(async (req, res) => {
const user = await User.findById(req.params.id);
res.json(user);
}));
try {
await processPayment(order);
} catch (error) {
Sentry.captureException(error, {
tags: {
payment_provider: order.paymentProvider,
order_id: order.id
},
extra: {
amount: order.total,
currency: order.currency
},
level: 'error'
});
throw new PaymentError('Payment processing failed', { cause: error });
}
Sentry.init({
dsn: process.env.SENTRY_DSN,
beforeSend(event) {
// Don't send validation errors to Sentry
if (event.exception?.values?.[0]?.type === 'ValidationError') {
return null;
}
// Don't send 404s
if (event.request?.url && event.exception?.values?.[0]?.value?.includes('404')) {
return null;
}
return event;
}
});
When user is in IMPLEMENT mode and ready to add Sentry:
When providing significant error handling recommendations:
### Error Tracking Recommendation: [Date]
- **File:** src/api/auth.js
- **Issue:** Missing error boundaries for async operations
- **Recommendation:** Add asyncHandler wrapper + Sentry integration
- **Rationale:** Current implementation silently fails on promise rejections
- **Next Steps:** Implement in IMPLEMENT mode, review in CHECK mode
Last Updated: 2025-11-15 Framework Version: 2.0