UNPKG

@ahmedhegazee/nestjs-telescope

Version:

Advanced observability and monitoring solution for NestJS applications with ML-powered analytics, enterprise features, and production-ready scaling

47 lines (46 loc) 1.39 kB
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common'; import { Observable } from 'rxjs'; import { RequestWatcherService } from './request-watcher.service'; export interface RequestContext { id: string; startTime: number; method: string; url: string; headers: Record<string, string>; query: Record<string, any>; body: any; userAgent: string; ip: string; sessionId?: string; userId?: string; traceId?: string; } export interface ResponseContext { statusCode: number; headers: Record<string, string>; body: any; size: number; endTime: number; duration: number; } export declare class RequestWatcherInterceptor implements NestInterceptor { private readonly requestWatcher; private readonly logger; constructor(requestWatcher: RequestWatcherService); intercept(context: ExecutionContext, next: CallHandler): Observable<any>; private shouldTrackRequest; private createRequestContext; private createResponseContext; private trackRequest; private sanitizeHeaders; private sanitizeQuery; private sanitizeBody; private sanitizeResponseBody; private calculateResponseSize; private getClientIp; private extractSessionId; private extractUserId; private extractTraceId; private generateRequestId; private generateTraceId; }