Skip to main content

Installation

Install the Hapi.js integration package:
Node 18+ required

Basic Setup

Register ApiTraffic as a plugin in your Hapi.js application:

Configuration Options

Configuration Table

Advanced Usage

Custom Tagging

Add custom tags to requests for better organization and searchability:

Request Tracing

Add trace messages for debugging and monitoring:

Error Handling

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

Environment Variables

Configure using environment variables:
.env

Plugin Registration Order

Register ApiTraffic early in your plugin registration sequence:

TypeScript Support

The package includes TypeScript definitions:

Security Features

Data Redaction

ApiTraffic automatically redacts sensitive data based on your account settings. No code changes required - configure redaction rules in your ApiTraffic dashboard.

Request Exclusions

Exclude specific endpoints from monitoring by configuring exclusion rules in your ApiTraffic account. Common exclusions include:
  • Health check endpoints
  • Static asset requests
  • Internal monitoring endpoints

Troubleshooting

Ensure ApiTraffic is registered before your route handlers and other plugins that might interfere with request processing.
Verify that API_TRAFFIC_TOKEN and API_TRAFFIC_BUCKET are set in your environment.
Set interceptOutbound: true in your plugin options to enable outbound request monitoring.
Make sure you’re using the correct plugin registration syntax for your version of Hapi.js.

Debug Mode

Enable debug mode to see detailed logging:

Sample Application

A complete working example is available in the GitHub repository.

Next Steps

Dashboard

View your API traffic data and analytics

Workflow Engine

Create automated workflows based on your API data