Node.js SDK

Quick Start

Get the SDK installed and sending your first event in under 5 minutes.

1

Install the SDK

bash
npm install @vigilry/node
2

Get your API key

Create a project in your dashboard and copy the API key shown at creation. Add it to your environment file.

.env
VIGILRY_API_KEY=vig_live_abc123def456...
3

Initialize the client

Create a single Vigilry instance and reuse it throughout your application.

lib/vigilry.ts
import { Vigilry } from "@vigilry/node";

export const vigilry = new Vigilry({
  apiKey: process.env.VIGILRY_API_KEY!,
  // baseUrl defaults to https://ingest.vigilry.com for local dev
  // baseUrl: "https://ingest.vigilry.com", // production
});
4

Capture your first event

handlers/auth.ts
import { vigilry } from "./lib/vigilry";

// Anywhere in your application
await vigilry.capture({
  type: "user_signup",
  severity: "info",
  message: "New user registered",
  correlation: {
    user_id: "usr_123",
    plan: "pro",
  },
});
5

Capture errors

handlers/checkout.ts
import { vigilry } from "./lib/vigilry";

try {
  await chargeCard(order);
} catch (err) {
  // captureError never throws — safe to call in catch blocks
  await vigilry.captureError(err as Error, {
    status_code: 500,
    path: "/api/checkout",
    method: "POST",
    correlation: {
      user_id: req.user.id,
      order_id: order.id,
    },
  });
  throw err; // re-throw if needed
}

You're all set

Check your dashboard at https://vigilry.com/dashboard to see events appearing in real time. Continue to the API Reference for full method documentation.