Skip to main content
The vij-sdk provides extensive configuration options to customize error tracking behavior, batching, and metadata collection for your specific use case.

Configuration Options

All configuration is passed to the init() function as an InitOptions object.

Basic Configuration

string
required
The URL of your VIJ Admin API endpoint where logs will be sent.Format: Must be a complete URL including protocol and path.Example: https://your-vij-admin.com/api/logs
Ensure this endpoint is accessible from your application environment. Check CORS settings if running in a browser.
string
required
Unique identifier for your application. Used to distinguish logs from different apps in the dashboard.Best Practices:
  • Use descriptive names like frontend-web, backend-api, or mobile-app
  • Keep it consistent across deployments
  • Use different IDs for frontend and backend to track them separately
Example: my-react-app, payment-service, admin-dashboard
string
required
The deployment environment where your application is running.Common Values: production, staging, development, testUsage: Helps filter logs by environment in the dashboard and prevents development errors from polluting production logs.
Use process.env.NODE_ENV in Node.js or define environment-specific variables to automatically set this value.

Batching Configuration

Batching reduces network overhead by sending multiple logs in a single request.
boolean
default:"true"
Enable or disable batching of error logs.When true: Logs are queued and sent in batches according to maxBatchSize and flushIntervalMs.When false: Each log is sent immediately in a separate request.
Batching is recommended for production to reduce network requests and improve performance.
number
default:"10"
Maximum number of logs to accumulate before automatically flushing the batch.Range: 1 to 100 (recommended: 10-50)Behavior: When the queue reaches this size, logs are immediately sent regardless of flushIntervalMs.Use Cases:
  • High-traffic apps: Use larger batch sizes (30-50) to reduce request frequency
  • Low-traffic apps: Use smaller batch sizes (5-10) for faster delivery
  • Critical errors: Use smaller batches or disable batching for immediate alerts
number
default:"5000"
Time interval in milliseconds to automatically flush the batch queue.Range: 1000 (1 second) to 60000 (1 minute)Default: 5000 (5 seconds)Behavior: Logs are sent when either maxBatchSize is reached OR this interval expires, whichever comes first.Considerations:
  • Shorter intervals (1000-3000ms): Near real-time delivery, more network requests
  • Longer intervals (10000-30000ms): Reduced network overhead, delayed visibility
Balance between real-time visibility and network efficiency. For most applications, 5000ms (5 seconds) is optimal.
number
default:"100"
Maximum number of logs to store in the queue before dropping old logs.Range: 10 to 1000Behavior: When the queue exceeds this size, the oldest logs are discarded to prevent memory issues.Use Cases:
  • Normal apps: Default 100 is sufficient
  • High-error-rate apps: Increase to 500-1000 to avoid dropping logs
  • Memory-constrained environments: Reduce to 50 or lower
If logs are being dropped, you’ll see console warnings. Consider increasing maxQueueSize or reducing flushIntervalMs.

Metadata Configuration

object
default:"{}"
Custom metadata to attach to every log entry automatically.Use Cases:
  • Add user information (user ID, email, role)
  • Include deployment details (version, build number, commit SHA)
  • Attach infrastructure context (server ID, region, cluster)
Type: Any JSON-serializable object
Use global metadata for application-wide context. Use per-error metadata (passed to captureException()) for event-specific details.
Merging Behavior: Global metadata is merged with per-error metadata. Per-error metadata takes precedence on conflicts.

Configuration Examples

Browser Application (React)

main.jsx

Node.js Backend (Express)

server.js

Next.js Application

lib/vij.js

Production-Optimized Configuration

Development Configuration

Environment-Specific Configuration

Use environment variables to configure VIJ for different deployment targets:
.env.production
.env.development
main.jsx

TypeScript Configuration

Full type safety with TypeScript:

Best Practices

Never hardcode endpoints or app IDs. Use environment variables to:
  • Keep configuration separate from code
  • Enable different configs per environment
  • Avoid committing sensitive URLs to version control
Low error rate (< 10 errors/minute):
  • maxBatchSize: 5-10
  • flushIntervalMs: 3000-5000
Medium error rate (10-100 errors/minute):
  • maxBatchSize: 20-30
  • flushIntervalMs: 5000-10000
High error rate (> 100 errors/minute):
  • maxBatchSize: 50-100
  • flushIntervalMs: 10000-30000
  • maxQueueSize: 500-1000
Include version information, deployment details, and infrastructure context:
Separate frontend and backend logs for easier filtering:

Troubleshooting

Check the following:
  1. Verify endpoint is accessible (try opening in browser)
  2. Check browser console/server logs for network errors
  3. Ensure VIJ Admin is running and MongoDB is connected
  4. Verify CORS allows requests from your domain
  5. Check that batch settings aren’t delaying delivery too long
Debug by disabling batching:
Warning: VIJ: Queue overflow, dropping oldest logCause: Error rate exceeds queue capacitySolutions:
  • Increase maxQueueSize to handle bursts
  • Decrease flushIntervalMs for faster flushing
  • Increase maxBatchSize to send more logs per request
  • Investigate why error rate is so high
Issue: Type errors with metadata or configurationSolution: Ensure you’re using the exported types

Next Steps

Capturing Errors

Learn how to capture exceptions and messages with the SDK

API Reference

Explore the complete SDK API documentation

Dashboard Setup

Set up your VIJ Admin dashboard

Environment Variables

Configure VIJ Admin environment variables