Functions
init()
Initialize the VIJ SDK with configuration options. Must be called before using other SDK functions.InitOptions
required
Configuration object for the SDK. See Configuration Guide for detailed documentation.
captureException()
Capture and send an error to VIJ Admin.Error
required
The error object to capture. Must have
name, message, and stack properties.Record<string, any>
Optional metadata to attach to this error. Merged with global metadata from
init().Severity
default:"error"
Severity level:
"error", "warning", or "info".void
captureMessage()
Capture and send a custom log message to VIJ Admin.string
required
The log message to capture.
Record<string, any>
Optional metadata to attach to this message.
Severity
default:"info"
Severity level:
"error", "warning", or "info".void
flush()
Immediately flush all queued logs to the server, bypassing batch settings.Promise<void> - Resolves when all logs are sent
setMetadata()
Update global metadata that will be attached to all future logs.Record<string, any>
required
Metadata object to merge with existing global metadata.
void
Metadata set via
setMetadata() is merged with metadata passed to init(). Later values override earlier ones.clearMetadata()
Remove specific keys from global metadata.string[]
required
Array of metadata keys to remove.
void
getMetadata()
Retrieve the current global metadata object.Record<string, any> - Current global metadata
Types
InitOptions
Configuration options for theinit() function.
string
required
VIJ Admin API endpoint URL (e.g.,
https://vij.example.com/api/logs)string
required
Unique identifier for your application
string
required
Environment name (e.g.,
production, staging, development)boolean
default:"true"
Enable batching of logs
number
default:"10"
Maximum logs per batch (1-100)
number
default:"5000"
Batch flush interval in milliseconds (1000-60000)
number
default:"100"
Maximum queue size before dropping old logs (10-1000)
Record<string, any>
default:"{}"
Global metadata attached to all logs
Severity
Severity level for errors and messages."error"- Critical errors requiring immediate attention"warning"- Non-critical issues that should be investigated"info"- Informational logs for tracking behavior
LogEntry
Structure of a log entry sent to VIJ Admin.string
Error message or custom log message
string
Error name (e.g.,
Error, TypeError, CustomError)string
Stack trace of the error
Severity
Severity level:
error, warning, or infostring
ISO 8601 timestamp when the error was captured
string
Application identifier from
init()string
Environment name from
init()Record<string, any>
Merged global and per-error metadata
BrowserContext | NodeContext
Automatically collected contextual information
You don’t create
LogEntry objects directly. The SDK generates them automatically when you call captureException() or captureMessage().BrowserContext
Contextual information collected in browser environments.NodeContext
Contextual information collected in Node.js environments.Advanced Usage
Manual Queue Management
Dynamic Metadata Updates
TypeScript Integration
React Integration
Express Integration
Best Practices
Initialize once at startup
Initialize once at startup
Call
init() once when your application starts, before any other code:Use TypeScript for type safety
Use TypeScript for type safety
Import types for better IDE support and compile-time checking:
Flush before critical operations
Flush before critical operations
Ensure logs are sent before page unload, process exit, or deployments:
Use metadata for context, not in messages
Use metadata for context, not in messages
Next Steps
Configuration Guide
Learn about all SDK configuration options
Capturing Errors
Understand error and message capture patterns
Dashboard Features
Explore VIJ Admin dashboard capabilities
API Endpoints
View the HTTP API documentation