captureException() for error objects and captureMessage() for custom log messages.
captureException()
Capture and send error objects to your VIJ Admin dashboard.Basic Usage
Signature
Parameters
Error
required
The error object to capture. Can be any JavaScript Error instance or object with
name, message, and stack properties.Supported Types:- Native JavaScript errors (
Error,TypeError,ReferenceError, etc.) - Custom error classes extending
Error - Objects with error-like structure
object
default:"{}"
Additional contextual information to attach to this specific error.Use Cases:
- User information (ID, email, role)
- Request details (URL, method, headers)
- Application state at time of error
- Feature or component context
string
default:"error"
The severity level of this error.Options:
"error"- Critical errors requiring immediate attention"warning"- Non-critical issues that should be investigated"info"- Informational logs for tracking behavior
Severity levels help you filter and prioritize errors in the dashboard.
Automatic Error Capture
The SDK automatically captures uncaught errors and unhandled promise rejections without any additional code:- Browser
- Node.js
window.onerror- Uncaught exceptionswindow.onunhandledrejection- Unhandled promise rejections
Advanced Examples
Capturing with Rich Metadata
Capturing Errors in React Components
Capturing Errors in Express Middleware
captureMessage()
Capture custom log messages without an error object.Basic Usage
Signature
Parameters
string
required
The log message to capture.Best Practices:
- Use clear, descriptive messages
- Include relevant details in the message or metadata
- Keep messages concise but informative
object
default:"{}"
Additional contextual information to attach to this message.
string
default:"info"
The severity level of this message.Options:
"info"- Informational messages (default for captureMessage)"warning"- Warning messages"error"- Error messages
Use Cases
- User Actions
- System Events
- Performance Monitoring
- Business Logic
Contextual Information
BothcaptureException() and captureMessage() automatically collect rich contextual information:
Browser Context
Node.js Context
This context is collected automatically. You don’t need to add it manually.
Best Practices
Always include relevant metadata
Always include relevant metadata
Add contextual information that will help debug the issue:
Use appropriate severity levels
Use appropriate severity levels
Error: Critical issues requiring immediate attentionWarning: Issues that should be investigated but aren’t criticalInfo: Tracking and informational purposes
Avoid capturing sensitive data
Avoid capturing sensitive data
Never log passwords, tokens, or PII without sanitization:
Don't capture errors in tight loops
Don't capture errors in tight loops
Avoid overwhelming your VIJ instance with duplicate errors:
Re-throw errors after capturing
Re-throw errors after capturing
Capture the error but don’t swallow it:
Integration Patterns
React Error Boundary
Vue Error Handler
Express Error Middleware
Async/Await Error Handling
Troubleshooting
Errors not appearing in dashboard
Errors not appearing in dashboard
Check the following:
- Verify
init()was called beforecaptureException() - Check browser console/server logs for network errors
- Ensure VIJ Admin endpoint is accessible
- Verify batching settings aren’t delaying delivery too long
- Check that error object has
name,message, andstackproperties
Duplicate errors appearing
Duplicate errors appearing
Cause: Same error being captured multiple timesSolutions:
- Check if error is being captured in both automatic handlers and manual try/catch
- Implement deduplication logic for recurring errors
- Use error grouping features in VIJ Admin dashboard
Metadata not appearing
Metadata not appearing
Issue: Custom metadata not showing in dashboardSolution: Ensure metadata is JSON-serializable
Next Steps
SDK Configuration
Learn about all available SDK configuration options
API Reference
Explore the complete SDK API documentation
Error Grouping
Understand how VIJ groups similar errors
Dashboard Features
Explore VIJ Admin dashboard features