Preparing your workspace...

assistant-chat.tsx2.5k
utils.ts850
button.tsx720
Quick Actions
codmir
Docs
Discord
Get started
API
  • Introduction
  • Installation
  • Your First Project
  • Your First Agent
  • Overview
  • CodmirClient
  • API Client
    • Next.js
    • React Native
    • Express
    • Browser
    • Remix
    • Serverless
  • Webhooks

Automatic error tracking, request context, and performance monitoring for Express.js applications.

Express Integration

Error tracking and performance monitoring middleware for Express.js. Automatically captures request context, strips sensitive headers, extracts user identity, and measures request duration.

npm install @codmir/sdk

Quick Start

import * as Codmir from '@codmir/sdk/express';
import express from 'express';

Codmir.init({
  dsn: process.env.CODMIR_DSN,
  environment: process.env.NODE_ENV,
  extractUser: (req) => ({
    id: req.user?.id,
    email: req.user?.email,
  }),
});

const app = express();

// Must be first middleware
app.use(Codmir.requestHandler());
app.use(Codmir.tracingHandler());

// Your routes
app.get('/', (req, res) => res.send('OK'));

app.get('/users/:id', (req, res) => {
  // Errors thrown here are automatically captured
  throw new Error('Something broke');
});

// Must be after all routes
app.use(Codmir.errorHandler());

app.listen(3000);

Middleware

requestHandler()

Must be the first Codmir middleware. Adds a breadcrumb for each incoming request, attaches timing context, and extracts user identity if configured.

app.use(Codmir.requestHandler());

tracingHandler()

Measures request duration and records it as a breadcrumb when the response finishes. Place it after requestHandler().

app.use(Codmir.tracingHandler());

errorHandler()

Must be registered after all routes. Captures exceptions with full request context — method, URL, headers (sensitive values stripped), query params, and route params. The error is passed to next(err) so your own error handlers still run.

app.use(Codmir.errorHandler());

Configuration

import { init } from '@codmir/sdk/express';

init({
  dsn: process.env.CODMIR_DSN,
  environment: 'production',

  // Privacy controls (both default to false)
  captureRequestBody: false,
  captureResponseBody: false,

  // Extract user from request
  extractUser: (req) => ({
    id: req.user?.id,
    email: req.user?.email,
    ip_address: req.ip,
  }),
});

Config Reference

OptionTypeDefaultDescription
captureRequestBodybooleanfalseInclude request body in error reports
captureResponseBodybooleanfalseInclude response body in error reports
extractUserfunction—Extract user context from the request object

Sensitive Headers

The following headers are automatically stripped from error reports:

authorization, cookie, set-cookie, x-api-key, x-auth-token, proxy-authorization

Manual Capture

import {
  captureException,
  captureMessage,
  setUser,
  setTag,
  addBreadcrumb,
} from '@codmir/sdk/express';

app.post('/checkout', async (req, res) => {
  addBreadcrumb({
    category: 'checkout',
    message: 'Processing payment',
    data: { amount: req.body.amount },
  });

  try {
    await processPayment(req.body);
    res.json({ ok: true });
  } catch (error) {
    captureException(error, {
      extra: { orderId: req.body.orderId },
      tags: { gateway: 'stripe' },
    });
    res.status(500).json({ error: 'Payment failed' });
  }
});

TypeScript Support

import type {
  ExpressConfig,
  OverseerConfig,
  UserContext,
  Breadcrumb,
  SeverityLevel,
} from '@codmir/sdk/express';

Related

Next.js

Next.js App Router and SSR integration

Remix

Remix loaders, actions, and error handling

AI Monitoring

Track LLM calls in your Express API

Open in ChatGPTOpen in ClaudeConnect MCP on CursorConnect MCP on WindsurfEdit on GitHub
codmir
Products
Desktop AppMobile AppIDE ExtensionAI AgentsOverseerVoice ModeCortex ProtocolHive MindGame Dev (Godat)PricingDownload
Solutions
AI Code AgentsCode ReviewError TrackingSelf-HealingDeploy TrackingAI Tracking SDKWorkflow AutomationTesting FrameworkTime TrackingVoice Control
Platform
ProjectsTickets & BoardsAgent MarketplaceIntegrationsTemplatesApp HubAdmin PanelAnalytics
Integrations
GitHubSlackDiscordVercelSentryRailwayLinearAll Integrations
Developers
DocumentationAPI ReferenceSDKCLIDeveloper PortalMarketplaceMCP ConnectorsWebhooksExamplesnpm Packages
Resources
BlogChangelogCommunityTutorialsGet StartedSupportStatusFeedback
Company
AboutCareersContact SalesKickstarterReferral Program
Legal
Terms of UsePrivacy PolicyEULATrademarkSecurity
Download on the App StoreGet it on Google Play

Codmir™ 2026. All rights reserved.

Free & open source SDK — Apache 2.0 License