TypeScript / Express

Instrument Express APIs.

Capture normalized Express 4–5 routes after responses finish without awaiting telemetry in the request path.

Express 4–5Package v0.2.0Production ready
01

Quickstart

Install the public npm packages.

The framework adapter uses @apirelio/core for the common event contract and bounded asynchronous transport.

Terminalbash
npm install @apirelio/express @apirelio/core
02

Framework integration

Enable automatic request tracking.

The middleware records the final status and resolved route template on the response finish event. Register it after authentication and before observed routes.

app.tstypescript
import express from 'express'
import { apirelio } from '@apirelio/express'

const app = express()
const analytics = apirelio({
  apiKey: process.env.APIRELIO_API_KEY ?? '',
  service: 'billing-api',
  environment: 'production',
  includeRoutes: ['/api/**'],
  excludeRoutes: ['/api/health', '/api/internal/**'],
  release: process.env.APP_RELEASE,
  resolveCustomer: request => request.user ? {
    id: String(request.user.companyId),
    name: request.user.companyName,
    plan: request.user.companyPlan,
  } : null,
})

app.use(analytics)
03

Customer context

Attach the account and application.

Use stable external IDs from your authentication model. Customer names and plans can evolve without breaking analytics history.

Customer resolvertypescript
resolveCustomer: request => ({
  id: String(request.user.companyId),
  name: request.user.companyName,
  plan: request.user.companyPlan,
})
04

Reliability

Flush safely during shutdown.

Call await analytics.shutdown() from the application graceful-shutdown path.

includeRoutes accepts exact paths or prefixes ending in /**. Explicit excludeRoutes always take precedence, keeping health checks, internal endpoints and presentation routes out of API analytics.

Non-blocking capture

The request only appends to a bounded in-memory queue. Network delivery, retry and batching happen outside the observed response path.

05

Data boundary

Operational signals only.

Request and response bodies, authorization values, cookies, query values, email addresses and client IP addresses are not captured. Custom scalar metadata must be explicitly allow-listed.

Server credentials only

Keep the ingestion key in server environment configuration. Do not expose it through client bundles or public runtime config.