Overview
Error tracking automatically captures JavaScript errors, unhandled promise rejections, and React component errors. This helps you identify and fix issues quickly, improving application stability and user experience.Quick Start
1
Enable Error Tracking
Set
enableErrorTracking: true in your analytics configuration:2
Automatic Error Capture
Once enabled, the SDK automatically captures:
- JavaScript runtime errors
- Unhandled promise rejections
- React component errors (when using ErrorBoundary)
- Network errors (optional)
3
View in Dashboard
Access error reports in your MentiQ dashboard to:
- See error frequency and trends
- View stack traces and context
- Identify affected users
- Track error resolution
Automatic Error Tracking
When enabled, the SDK automatically captures errors:JavaScript Errors
Fromsrc/analytics.ts:321-365, the SDK listens for global error events:
Error Data Structure
Manual Error Tracking
Using the Hook
Using Analytics Instance
React Error Boundaries
Use theAnalyticsErrorBoundary component to catch React component errors:
Granular Error Boundaries
Wrap specific components for better error isolation:Use Cases
Track API Errors
Track Form Validation Errors
Track Authentication Errors
Track Third-Party Integration Errors
Error Context & Enrichment
Add contextual information to errors for better debugging:Error Sampling
For high-volume applications, sample errors to reduce noise:Error Grouping
Group similar errors for better insights:Privacy Considerations
Safe Error Logging
Error Hook API
Fromsrc/hooks.ts:117-172, the useErrorTracking hook provides:
Best Practices
Error Tracking Tips:
- Always include context (what the user was doing)
- Add user and session identifiers for debugging
- Group related errors for better insights
- Set severity levels (critical, warning, info)
- Don’t log sensitive user data
- Sample high-frequency errors to avoid noise
- Monitor error trends, not just counts
Troubleshooting
Errors Not Being Captured
- Verify
enableErrorTracking: truein config - Check browser console for SDK errors (enable
debug: true) - Ensure error occurs after SDK initialization
Missing Stack Traces
Stack traces may be missing for:- Cross-origin errors (CORS)
- Minified code without source maps
- Some browser privacy settings
Duplicate Errors
If seeing duplicate errors:- Check for multiple error listeners
- Ensure only one AnalyticsProvider exists
- Verify error boundary isn’t re-mounting