import type { NextRequest } from 'next/server'; import type { EventData } from '../types'; interface ServerTrackConfig { /** Entrolytics host URL */ host: string; /** Public collection API key */ apiKey: string; /** Website ID */ websiteId?: string; /** Optional stable session ID */ sessionId?: string; /** Optional stable visitor ID */ visitorId?: string; } interface ServerTrackOptions { /** Event name */ event?: string; /** Event data */ data?: EventData; /** URL to track */ url?: string; /** Page title */ title?: string; /** Referrer */ referrer?: string; /** Distinct ID for user tracking */ id?: string; /** Tag for segmentation */ tag?: string; /** Extract info from request */ request?: NextRequest | Request; } /** * Track an event from the server side (API routes, Server Actions, middleware). * * @example * ```ts * // In an API route or Server Action * import { trackServerEvent } from '@entrolytics/nextjs/server'; * * export async function POST(request: Request) { * await trackServerEvent( * { * host: process.env.ENTROLYTICS_HOST!, * websiteId: process.env.ENTROLYTICS_WEBSITE_ID!, * }, * { * event: 'api-call', * data: { endpoint: '/api/users' }, * request, * } * ); * * return Response.json({ success: true }); * } * ``` */ export declare function trackServerEvent(config: ServerTrackConfig, options?: ServerTrackOptions): Promise<{ ok: boolean; error?: string; }>; /** * Track an identify event from the server side. * * @example * ```ts * import { identifyServerSession } from '@entrolytics/nextjs/server'; * * await identifyServerSession( * { host: '...', websiteId: '...' }, * { * id: 'user-123', * data: { plan: 'premium', region: 'us-west' }, * } * ); * ``` */ export declare function identifyServerSession(config: ServerTrackConfig, options: Pick): Promise<{ ok: boolean; error?: string; }>; export {}; //# sourceMappingURL=track.d.ts.map