import type { NavigationType, VitalRating, VitalType } from '@entrolytics/shared'; export type WebVitalMetric = VitalType; export type WebVitalRating = VitalRating; export type { NavigationType }; export interface WebVitalPayload { /** Metric name (LCP, INP, CLS, TTFB, FCP) */ metric: WebVitalMetric; /** Metric value */ value: number; /** Performance rating */ rating: WebVitalRating; /** Delta from previous measurement */ delta?: number; /** Unique metric ID for deduplication */ id?: string; /** Navigation type */ navigationType?: NavigationType; /** Attribution data */ attribution?: Record; /** Page URL */ url?: string; /** Page path */ path?: string; } export interface TrackVitalsConfig { /** 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; } /** * Track a Web Vital metric from server side (e.g., from an API route that receives client vitals) * * @example * ```ts * // In app/api/vitals/route.ts * import { trackServerVital } from '@entrolytics/nextjs/server'; * * export async function POST(request: Request) { * const vital = await request.json(); * * await trackServerVital( * { * host: process.env.ENTROLYTICS_HOST!, * websiteId: process.env.ENTROLYTICS_WEBSITE_ID!, * }, * vital * ); * * return Response.json({ ok: true }); * } * ``` */ export declare function trackServerVital(config: TrackVitalsConfig, vital: WebVitalPayload): Promise<{ ok: boolean; error?: string; }>; /** * Track multiple Web Vitals at once */ export declare function trackServerVitalsBatch(config: TrackVitalsConfig, vitals: WebVitalPayload[]): Promise<{ ok: boolean; error?: string; }>; /** * Create a reportWebVitals handler for Next.js * Use this in your custom _app.tsx or layout.tsx * * @example * ```ts * // In pages/_app.tsx (Pages Router) * import { createWebVitalsReporter } from '@entrolytics/nextjs/server'; * * export function reportWebVitals(metric) { * const reporter = createWebVitalsReporter({ * host: process.env.NEXT_PUBLIC_ENTROLYTICS_HOST!, * websiteId: process.env.NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID!, * }); * reporter(metric); * } * ``` */ export declare function createWebVitalsReporter(config: TrackVitalsConfig): (metric: { name: string; value: number; rating?: string; delta?: number; id?: string; navigationType?: string; attribution?: Record; }) => void; //# sourceMappingURL=vitals.d.ts.map