Skip to main content

Installation

Install the Express.js integration package:

Basic Setup

Add ApiTraffic middleware to your Express application:

Configuration Options

Advanced Usage

Custom Tagging

Add custom tags to requests for better organization:

Custom Traces

Add trace messages for debugging:

Error Handling

ApiTraffic automatically captures errors, but you can add additional context:

Environment Variables

Configure using environment variables:
.env

Middleware Order

Place ApiTraffic middleware early in your middleware stack:

TypeScript Support

The package includes TypeScript definitions:

Troubleshooting

Common Issues

Ensure ApiTraffic middleware is placed before your route handlers and after body parsing middleware.
Verify that API_TRAFFIC_TOKEN and API_TRAFFIC_BUCKET are set in your environment.
Set interceptOutbound: true in your configuration to enable outbound request monitoring.

Debug Mode

Enable debug mode to see detailed logging: