Configuration Options
All configuration is passed to theinit() function as an InitOptions object.
Basic Configuration
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/logsUnique identifier for your application. Used to distinguish logs from different apps in the dashboard.Best Practices:
- Use descriptive names like
frontend-web,backend-api, ormobile-app - Keep it consistent across deployments
- Use different IDs for frontend and backend to track them separately
my-react-app, payment-service, admin-dashboardThe 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.Batching Configuration
Batching reduces network overhead by sending multiple logs in a single request.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.
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
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
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
100is sufficient - High-error-rate apps: Increase to
500-1000to avoid dropping logs - Memory-constrained environments: Reduce to
50or lower
Metadata Configuration
Custom metadata to attach to every log entry automatically.Use Cases:Merging Behavior: Global metadata is merged with per-error metadata. Per-error metadata takes precedence on conflicts.
- Add user information (user ID, email, role)
- Include deployment details (version, build number, commit SHA)
- Attach infrastructure context (server ID, region, cluster)
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:- Vite (.env)
- Next.js (.env.local)
- Node.js (.env)
.env.production
.env.development
main.jsx
TypeScript Configuration
Full type safety with TypeScript:Best Practices
Use environment variables for sensitive configuration
Use environment variables for sensitive configuration
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
Tune batching based on error rate
Tune batching based on error rate
Low error rate (< 10 errors/minute):
maxBatchSize: 5-10flushIntervalMs: 3000-5000
maxBatchSize: 20-30flushIntervalMs: 5000-10000
maxBatchSize: 50-100flushIntervalMs: 10000-30000maxQueueSize: 500-1000
Add rich metadata for better debugging
Add rich metadata for better debugging
Include version information, deployment details, and infrastructure context:
Use different appIds for different parts of your system
Use different appIds for different parts of your system
Separate frontend and backend logs for easier filtering:
Troubleshooting
Logs not appearing in dashboard
Logs not appearing in dashboard
Check the following:
- Verify
endpointis accessible (try opening in browser) - Check browser console/server logs for network errors
- Ensure VIJ Admin is running and MongoDB is connected
- Verify CORS allows requests from your domain
- Check that
batchsettings aren’t delaying delivery too long
Queue overflow warnings
Queue overflow warnings
Warning:
VIJ: Queue overflow, dropping oldest logCause: Error rate exceeds queue capacitySolutions:- Increase
maxQueueSizeto handle bursts - Decrease
flushIntervalMsfor faster flushing - Increase
maxBatchSizeto send more logs per request - Investigate why error rate is so high
TypeScript type errors
TypeScript type errors
Issue: Type errors with
metadata or configurationSolution: Ensure you’re using the exported types