Node.js

Install npm install @blipit/node

@blipit/node captures uncaught exceptions and unhandled promise rejections on its own, adds handlers for Express and Fastify, and ships logs and login attempts with the same key. Use the secret key; it stays on the server.

1Install

sh
npm install @blipit/node

2Initialise first

Put this in a file that runs before your app, and import it first.

instrument.mjs
import * as Blipit from "@blipit/node";

Blipit.init({
  key: process.env.BLIPIT_SECRET_KEY,
  environment: process.env.NODE_ENV,
  release: process.env.RELEASE,
  serverName: "api",
});

3Express or Fastify

Add the handler after your routes so handled and unhandled errors both reach Blipit, with the request's method, URL and user agent.

js
import "./instrument.mjs";
import * as Blipit from "@blipit/node";
import express from "express";

const app = express();
app.get("/", (req, res) => res.send("ok"));
app.use(Blipit.expressErrorHandler());
app.listen(3000);
Fastify
await app.register(Blipit.fastifyPlugin());

4Manual capture, logs and login attempts

js
Blipit.captureException(err);
Blipit.captureMessage("cache miss rate above 50%", "warning");
Blipit.setUser({ id: "user-42" });
Blipit.log.info("order placed", { order_id: 42 });
Blipit.captureSecurity({ kind: "login_failed", actor: email, ip, userAgent, outcome: "bad_password" });
await Blipit.flush();

5Check it works

Open Issues in app.blipit.io. The first event appears within a few seconds, grouped into an issue, and the people in charge get an email.

js
Blipit.captureMessage("Hello from Node");

Good to know

  • On an uncaught exception the SDK flushes pending events, then exits with code 1; override with onFatal.
  • captureConsole: true turns console.log and friends into log lines shipped to the Logs page.
  • Already on @sentry/node? It works unchanged with the DSN https://<public key>@in.blipit.io/<project id>.

Stuck? Email support@blipit.io. Keys and the exact DSN for each project are under API keys in app.blipit.io.