process.on('uncaughtException') and process.on('unhandledRejection') to automatically capture every unhandled error in your server application. For Express users, an optional error-handling middleware attaches request context (HTTP method and URL) to every captured error. The SDK has zero runtime dependencies.
Installation
Initialization
Place
init() before any routes, middleware, or application logic. This guarantees that the process-level event listeners are registered before anything can throw.import { init } from '@argusdev/sdk-node';
init({
dsn: 'https://YOUR_PUBLIC_KEY@your-domain.com/YOUR_PROJECT_ID',
environment: 'production',
release: '1.0.0',
});
// Your application logic starts here
export interface InitOptions {
/** Your project DSN (required). Format: https://PUBLIC_KEY@host/PROJECT_ID */
dsn: string;
/** The environment name shown in Argus (e.g. 'production', 'staging'). */
environment?: string;
/** Your application's release version (e.g. '1.4.2' or a git SHA). */
release?: string;
}
dsnstringenvironmentstring'production', 'staging'). Shown as a filter in Argus.releasestringExpress Middleware
AddargusErrorHandler() as the last middleware in your Express application, after all your routes and before your own custom error handler. Argus captures the error with request context, then calls next(err) to pass the error along — it observes without swallowing.
method (e.g. GET) and the full request URL from req.originalUrl, giving you immediate context in Argus about which endpoint was hit when the error occurred.
argusErrorHandler() has no dependency on Express itself — it uses structural typing and works with any framework that follows the standard four-argument Express error-handler signature (err, req, res, next).Manual Capture
UsecaptureException() inside try/catch blocks when you want to handle an error gracefully and still report it to Argus.
captureException accepts any value. If you pass something that is not an Error instance, the SDK wraps it in a new Error(String(value)) before building the event.
Crash Behavior
Non-Error Rejections
If your code rejects a promise with a plain string, number, or object instead of anError, Argus normalizes it automatically. The value is converted to a string and wrapped in a new Error(...) before being sent, so you always see a meaningful event in Argus rather than a silent drop.
Exported API
| Symbol | Kind | Description |
|---|---|---|
init | function | Initializes the SDK and registers process.on listeners. |
captureException | function | Manually captures and sends an exception to Argus. |
argusErrorHandler | function | Returns an Express-compatible four-argument error handler middleware. |
InitOptions | interface | TypeScript type for the init() options object. |