UNPKG

next-axiom

Version:

Send WebVitals from your Next.js project to Axiom.

26 lines (25 loc) 1.39 kB
import { NextConfig } from 'next'; import { LogLevel, Logger } from './logger'; import { type NextRequest, type NextResponse } from 'next/server'; import { RequestJSON } from './shared'; type NextConfigContext = { defaultConfig: NextConfig; }; type NextConfigFn = (phase: string, context: NextConfigContext) => NextConfig | Promise<NextConfig>; export declare function withAxiomNextConfig(nextConfigOrFn: NextConfigFn): NextConfigFn; export declare function withAxiomNextConfig(nextConfigOrFn: NextConfig): NextConfig; export type AxiomRequest = NextRequest & { log: Logger; }; export type NextHandler<T = any> = (req: AxiomRequest, arg?: T) => Promise<Response> | Promise<NextResponse> | NextResponse | Response; type NextJsNextHandler<T = any> = (req: NextRequest, arg?: T) => Promise<Response> | Promise<NextResponse> | NextResponse | Response; type AxiomRouteHandlerConfig = { logRequestDetails?: boolean | (keyof RequestJSON)[]; notFoundLogLevel?: LogLevel; redirectLogLevel?: LogLevel; }; export declare function withAxiomRouteHandler(handler: NextHandler, config?: AxiomRouteHandlerConfig): NextJsNextHandler; export declare function withAxiom(param: NextHandler, config?: AxiomRouteHandlerConfig): NextJsNextHandler; export declare function withAxiom(param: NextConfigFn): NextConfigFn; export declare function withAxiom(param: NextConfig): NextConfig; export {};