Reference
leylines/vite
Functions
leylines
Create a Vite plugin that captures browser logs into a local Leylines store.
export function leylines(options?: LeylinesVitePluginOptions): VitePluginLike;
Types
LeylinesVitePluginOptions
Options for the Leylines Vite development plugin.
export interface LeylinesVitePluginOptions extends OpenScopedLogsOptions {
endpoint?: string;
scope?: string;
captureConsole?: boolean | LogLevel[];
captureErrors?: boolean;
captureRejections?: boolean;
production?: boolean;
stripProduction?: boolean;
metadata?: JsonObject;
posthog?: boolean | PostHogViteOptions;
viteLogger?: boolean | ViteLoggerCaptureOptions;
captureViteLogger?: boolean | ViteLoggerCaptureLevel[];
}
Properties
endpointBrowser log ingestion endpoint injected into the page. Defaults to/__scoped_logs.scopeRoot browser logger scope. Defaults tobrowser.captureConsoleCapture console methods from the browser logger injection.captureErrorsCapture uncaught browser errors. Defaults totrue.captureRejectionsCapture unhandled promise rejections. Defaults totrue.productionEnable the plugin and its Node log store during production builds.stripProductionRemove browser logger calls from production builds and replace remaining logger references with no-ops.metadataMetadata merged into entries written by Vite ingestion middleware.posthogRedirect PostHog browser product analytics into the local Leylines store.viteLoggerCapture Vite's own logger output into the local Leylines store.captureViteLoggerShorthand forviteLogger.levelswith the defaultdev.vitescope.
š LeylinesVitePluginOptions on GitHub
PostHogViteOptions
Options for redirecting PostHog browser events into the local Leylines store.
export interface PostHogViteOptions {
endpoint?: string;
scope?: string;
}
Properties
endpointLocal PostHog-compatible ingestion endpoint. Defaults to/__leylines/posthog.scopeScope assigned to redirected PostHog entries. Defaults toposthog.
š PostHogViteOptions on GitHub
RequestLike
interface RequestLike {
method?: string;
on(event: 'data', listener: (chunk: Buffer | string) => void): void;
on(event: 'end', listener: () => void): void;
on(event: 'error', listener: (error: Error) => void): void;
}
ResponseLike
interface ResponseLike {
statusCode: number;
setHeader(name: string, value: string): void;
end(body?: string): void;
}
ViteLoggerCaptureLevel
export type ViteLoggerCaptureLevel = Extract<LogLevel, 'info' | 'warn' | 'error'>;
š ViteLoggerCaptureLevel on GitHub
ViteLoggerCaptureOptions
Options for capturing Vite's own logger output into Leylines.
export interface ViteLoggerCaptureOptions {
scope?: string;
levels?: ViteLoggerCaptureLevel[];
}
Properties
scopeScope assigned to captured Vite logger entries. Defaults todev.vite.levelsVite logger levels to capture. Defaults towarnanderror.
š ViteLoggerCaptureOptions on GitHub
ViteLoggerLike
interface ViteLoggerLike {
info?: ViteLoggerMethod;
warn?: ViteLoggerMethod;
warnOnce?: ViteLoggerMethod;
error?: ViteLoggerMethod;
}
ViteLoggerMethod
type ViteLoggerMethod = (message: string, options?: ViteLogOptionsLike, ...rest: unknown[]) => void;
š ViteLoggerMethod on GitHub
ViteLogOptionsLike
interface ViteLogOptionsLike {
error?: unknown;
[key: string]: unknown;
}
š ViteLogOptionsLike on GitHub
VitePluginLike
Minimal Vite plugin shape returned by leylines.
export interface VitePluginLike {
name: string;
apply?: 'serve' | 'build';
configResolved(config: ViteResolvedConfigLike): void;
configureServer(server: ViteServerLike): void;
transformIndexHtml(html: string): string;
transform(code: string, id?: string): string | null;
closeBundle(): void;
}
Properties
nameVite plugin name.applyVite apply mode.configResolvedReceive resolved Vite mode and command.configureServerRegister local ingestion middleware on the Vite dev server.transformIndexHtmlInject browser logger setup into HTML.transformRewrite application modules before Vite compiles them.closeBundleClose any store resources opened by the plugin.
ViteResolvedConfigLike
interface ViteResolvedConfigLike {
mode?: string;
command?: string;
logger?: ViteLoggerLike;
}
š ViteResolvedConfigLike on GitHub
ViteServerLike
interface ViteServerLike {
middlewares: {
use(path: string, handler: (req: RequestLike, res: ResponseLike, next: (error?: unknown) => void) => void): void;
};
}