Server-side SDK (Node.js)
For backend events — payments, payouts, settlements, jobs — use traceiq-node. Server events are the most trustworthy source of revenue: the amount comes from your systems, not the browser. Events are queued and flushed in batches, so request handlers never block on the network.
Package on npm: npm (traceiq-node) (currently v0.3.0)
npm install traceiq-node
import { TraceIQ } from 'traceiq-node';
const traceiq = new TraceIQ({
projectId: 'YOUR_PROJECT_ID',
writeKey: process.env.TRACEIQ_WRITE_KEY, // keep server keys secret
endpoint: 'https://api.traceiq.run',
});
// A trustworthy revenue event, straight from your payments service:
traceiq.capture({
event: 'payout_succeeded',
userId: 'user_123',
properties: { amount: 50000, currency: 'NGN', channel: 'bank_transfer' },
});
traceiq.identify({ userId: 'user_123', traits: { kyc_tier: 2, email: 'user@example.com' } });
traceiq.group({ organizationId: 'org_9', userId: 'user_123', traits: { plan: 'growth' } });
// Flush before a short-lived process or serverless function exits:
await traceiq.shutdown();Events flush automatically by size (flushAt) or on a timer (flushIntervalMs). Call shutdown() in scripts and serverless functions so nothing is lost on exit.
Request telemetry & API performance
traceiq.middleware() records every request as a $api_request event, powering the API Performance dashboard and the Requests explorer.
import express from 'express';
import { TraceIQ } from 'traceiq-node';
const app = express();
const traceiq = new TraceIQ({
projectId: 'YOUR_PROJECT_ID',
writeKey: process.env.TRACEIQ_WRITE_KEY,
endpoint: 'https://api.traceiq.run',
});
// Automatic endpoint latency, status code, and error capture:
app.use(traceiq.middleware({
service: 'billing-api',
environment: process.env.NODE_ENV || 'production',
resolveUserId: (req) => req.user?.id,
ignore: (req) => req.path === '/health',
}));Any capture() call made while a request is handled — like an exception or conversion — is automatically stamped with the same distributed requestId and traceId.
Server-side feature flags
Evaluate feature flags deterministically on your backend or worker with safe local fallbacks:
// Check if a flag is active for a user:
const isEnabled = await traceiq.isFeatureEnabled('new-billing-flow', userId, {
defaultValue: false,
environment: 'production',
properties: { plan: 'pro', country: 'NG' }
});
// Fetch configuration payload:
const payload = await traceiq.getFeatureFlagPayload('new-billing-flow', userId, {
environment: 'production'
});
