Node SDK
Server-side errors and failing upstream calls, Node 18+.For an Express/Fastify/Next API or any Node process. Zero runtime dependencies.You will need a project key
Create a project first and this page fills in your real key everywhere it appears.
Initialize
import { init, captureError } from '@vigil/node';
init({ key: 'vg_pub_YOUR_KEY', endpoint: 'https://vigill.dev/api/ingest' });
try {
await charge(order);
} catch (err) {
captureError(err, { tags: { area: 'billing' } });
throw err;
}
What it captures automatically
These arrive with zero extra code — the unhandled failures that would otherwise crash or vanish.- uncaughtException — an error that would otherwise crash the process.
- unhandledRejection — a promise that rejects with no catch.
- Failed outgoing fetch() calls to third parties (captureHttp, on by default) — 4xx/5xx and network errors.
When to capture manually
Inside an Express/Fastify route you usually catch errors to return a clean 500 instead of crashing. Once caught, the global handler never fires — call captureError so the handled failure is still reported (and add tags for where it happened).app.post('/checkout', async (req, res) => {
try {
await charge(req.body);
res.json({ ok: true });
} catch (err) {
captureError(err, { tags: { route: 'checkout' } });
res.status(500).json({ error: 'Payment failed' });
}
});
Configuration
Pass environment/release for cleaner grouping; turn off captureHttp if you do not want upstream failures reported.init({
key: 'vg_pub_YOUR_KEY',
endpoint: 'https://vigill.dev/api/ingest',
environment: 'production',
release: process.env.GIT_SHA,
captureHttp: true,
tags: { service: 'api' },
});
Verify it works
Add a throwaway route that throws, hit it once, and watch it appear on the dashboard. Then remove the route.
What you get
- init({ key, endpoint, environment, release, tags, captureHttp, debug })
- captureError(error, { message?, tags? }) · captureMessage(message, level)
- flush() / close() — force-send anything queued (useful before a short-lived process exits).
The one thing people miss
On an uncaught exception, if Vigil is the only handler it flushes and re-exits(1), so a crash behaves exactly as it would have without it in the way.