Documentation
Node.js
Use the @tacko/telemetry-node package for Node.js servers. It wraps @tacko/telemetry-core and installs global handlers for uncaughtException and unhandledRejection. All payloads include anonymous id and SDK version. You can also attach a request middleware to track HTTP requests.
Install
pnpm add @tacko/telemetry-node
# or
npm install @tacko/telemetry-nodeSetup
Call init() as early as possible (e.g. at the top of your entry file):
import { init, trackEvent, trackError } from "@tacko/telemetry-node";
init({
ingestUrl: process.env.TELEMETRY_INGEST_URL || "https://your-api.example.com",
app: "my-api",
platform: "node",
});
trackEvent("server_started", { version: "1.0.0" });
trackError(new Error("DB connection failed"), { db: "primary" });Global error handlers
After init(), uncaughtException and unhandledRejection are patched to send errors to the ingest API (and then rethrow / continue so your process can still exit or log as usual).
Request middleware
Optional: use middleware() to send a $request event per HTTP request (method, url, duration). Attach it to your server framework (Express, Fastify, etc.) so it runs for each request.
import { middleware } from "@tacko/telemetry-node";
const telemetryMiddleware = middleware({ trackRequestBody: false });
// Express-style
app.use((req, res, next) => {
telemetryMiddleware(req, res, () => {
next();
});
});
// Or call next() and then track when response finishes — adapt to your framework.The middleware tracks method, url, and duration_ms. Set trackRequestBody: true to include the request body in the event (use with care for PII/size).