import type { NextRequest, NextResponse } from 'next/server'; interface MiddlewareConfig { /** Entrolytics host URL */ host: string; /** Public collection API key */ apiKey: string; /** Website ID */ websiteId: string; /** Route patterns to track (glob patterns) */ trackRoutes?: string[]; /** Route patterns to exclude */ excludeRoutes?: string[]; /** Tag for segmentation */ tag?: string; } type MiddlewareHandler = (request: NextRequest, response?: NextResponse | Response) => Promise | NextResponse | Response | undefined; /** * Creates a middleware wrapper that tracks requests to specified routes. * * @example * ```ts * // middleware.ts * import { withEntrolyticsMiddleware } from '@entrolytics/nextjs/server'; * import { NextResponse } from 'next/server'; * * const entrolyticsMiddleware = withEntrolyticsMiddleware({ * host: process.env.ENTROLYTICS_HOST!, * websiteId: process.env.ENTROLYTICS_WEBSITE_ID!, * trackRoutes: ['/api/*'], * excludeRoutes: ['/api/health', '/api/collect/*'], * }); * * export async function middleware(request: NextRequest) { * // Your custom middleware logic * const response = NextResponse.next(); * * // Track with Entrolytics * return entrolyticsMiddleware(request, response); * } * * export const config = { * matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'], * }; * ``` */ export declare function withEntrolyticsMiddleware(config: MiddlewareConfig): MiddlewareHandler; /** * Compose multiple middleware functions. * * @example * ```ts * import { composeMiddleware, withEntrolyticsMiddleware } from '@entrolytics/nextjs/server'; * * const entrolytics = withEntrolyticsMiddleware({ ... }); * const auth = withAuthMiddleware({ ... }); * * export const middleware = composeMiddleware(entrolytics, auth); * ``` */ export declare function composeMiddleware(...middlewares: MiddlewareHandler[]): MiddlewareHandler; export {}; //# sourceMappingURL=middleware.d.ts.map