Quickstart
Install the public npm packages.
The framework adapter uses @apirelio/core for the common event contract and bounded asynchronous transport.
npm install @apirelio/nestjs @apirelio/coreFramework integration
Enable automatic request tracking.
The global interceptor supports both NestJS HTTP platforms, preserves the original exception and records the final response outcome.
import { Module } from '@nestjs/common'
import { ApirelioModule } from '@apirelio/nestjs'
@Module({
imports: [
ApirelioModule.forRoot({
apiKey: process.env.APIRELIO_API_KEY ?? '',
service: 'billing-api',
environment: 'production',
includeRoutes: ['/api/**'],
excludeRoutes: ['/api/health', '/api/internal/**'],
resolveCustomer: request => request.user ? {
id: String(request.user.companyId),
name: request.user.companyName,
} : null,
}),
],
})
export class AppModule {}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.
ApirelioModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
apiKey: config.getOrThrow('APIRELIO_API_KEY'),
service: 'billing-api',
}),
})Reliability
Flush safely during shutdown.
Call app.enableShutdownHooks() so Nest lifecycle shutdown triggers the final queue flush.
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.
The request only appends to a bounded in-memory queue. Network delivery, retry and batching happen outside the observed response path.
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.
Keep the ingestion key in server environment configuration. Do not expose it through client bundles or public runtime config.