Install

Install on Node

Install the Sankofa Node SDK and wire it into Express, Fastify, or any HTTP server with first-class subpath imports.

The @sankofa/node package is the official server-side SDK for Node.js. It focuses on Catch — error capture, breadcrumbs, transactions, and profiling — with first-class Express and Fastify integration via dedicated subpath imports. Server-side flag and config evaluation is not built in; the SDK accepts optional readFlagSnapshot / readConfigSnapshot callbacks so captured error events can include flag context.

Requirements

  • Node.js 18+ (we test 18, 20, and 22)
  • TypeScript 5+ (optional but recommended)
  • ESM and CommonJS are both supported

1. Install the package

bash
npm install @sankofa/node

2. Initialize at process start

Call Sankofa.init once, as early as possible — typically in your server entry file before any imports that might throw.

TypeScriptserver.ts
import { Sankofa } from "@sankofa/node";

Sankofa.init({
apiKey: process.env.SANKOFA_KEY!,
endpoint: "https://api.sankofa.dev",
release: process.env.RELEASE_SHA ?? "dev",
environment: process.env.NODE_ENV ?? "development",
});

Common init options

apiKeystringRequired
Your project's server-side API key. Never expose this in a client bundle.
endpointstringdefault https://api.sankofa.dev
Server base URL.
releasestring
Build identifier (commit SHA, version tag) — used for source-mapped error grouping.
environmentstringdefault production
Free-form label (development, staging, production).
tracesSampleRatenumberdefault 0.1
Distributed-tracing sample rate (0.0–1.0).
ignoreErrorsRegExp[]
Patterns of error messages to drop without sending.

3. Wire your framework

The Node SDK ships subpath exports for Express and Fastify so the same package serves both.

TypeScriptserver.ts
import express from "express";
import { Sankofa } from "@sankofa/node";
import { sankofaRequestHandler, sankofaErrorHandler } from "@sankofa/node/express";

Sankofa.init({ apiKey: process.env.SANKOFA_KEY! });

const app = express();

// Must be the first middleware — captures request context for every event.
app.use(sankofaRequestHandler());

app.get("/", (req, res) => {
Sankofa.track("homepage_visited", {}, { distinctId: req.user?.id ?? "anon" });
res.send("ok");
});

// Must be the last middleware — captures uncaught errors.
app.use(sankofaErrorHandler());

4. Verify the install

TypeScript
await Sankofa.track("install_check", { from: "node-quickstart" });

Open app.sankofa.devLive events. You should see the event with a node source label and the runtime version captured under default properties.

What's next

Edit this page on GitHub