Node.js with AllStak
Add error tracking, request tracking, and tracing to any Node.js service with the AllStak JS SDK.
- Source repository:
- AllStak/allstak-js
- Source README:
- README.md
- SDK version:
- 0.3.1
- Installation source:
- npm
- Last verified:
- 2026-05-31
Installation
Install the SDK from npm.
npm install @allstak/jsConfiguration
Initialize the AllStak client as early as possible in your entry file.
import { AllStak } from '@allstak/js';
AllStak.init({
apiKey: process.env.ALLSTAK_API_KEY!,
environment: process.env.NODE_ENV ?? 'production',
release: process.env.ALLSTAK_RELEASE,
tags: { service: 'worker' },
});Basic example
For Express, add the request handler before your routes and the error handler after them (from the @allstak/js/express subpath).
import express from 'express';
import { AllStak } from '@allstak/js';
import { allstakExpress } from '@allstak/js/express';
const app = express();
app.use(express.json());
app.use(allstakExpress.requestHandler());
app.post('/checkout', async (_req, res) => {
res.json({ ok: true });
});
app.use(allstakExpress.errorHandler());
app.listen(3000);Capturing errors
Capture exceptions in try/catch blocks or background jobs.
try {
throw new Error('payment failed');
} catch (error) {
AllStak.captureException(error as Error);
}
await AllStak.flush();Tracking requests
The Express request handler records inbound requests; set httpBodyCapture: { request: true, response: true } in init to include bodies. Generic reporting is also available via AllStak.captureRequest(item).
Best practices
- Initialize AllStak before importing other modules.
- Register allstakExpress.errorHandler() last, after all routes.
- Use environment + release to separate and group data per deploy.