better-analytics
Version:
Zero-dependency micro-analytics JavaScript SDK < 3KB gzipped with React/Next.js/Expo support
45 lines (42 loc) • 1.5 kB
text/typescript
import './next/next-client';
import { A as AnalyticsConfig } from './types-DzHHnKL8.mjs';
export { B as BeforeSend, c as BeforeSendEvent, W as EventData, R as RouteInfo } from './types-DzHHnKL8.mjs';
import './next/next-server';
/**
* Initialize the analytics SDK
* @param options Configuration options
*/
declare function init(options: AnalyticsConfig): void;
/**
* Initialize the analytics SDK and immediately track a pageview
* @param options Configuration options
*/
declare function initWithPageview(options: AnalyticsConfig): void;
/**
* Track a page view event
*/
declare function trackPageview(path?: string): void;
/**
* Track a custom event with optional properties
* @param event Event name
* @param props Optional event properties
*/
declare function track(event: string, props?: Record<string, unknown>): void;
/**
* Identify a user
* @param userId User identifier
* @param traits Optional user traits
*/
declare function identify(userId: string, traits?: Record<string, unknown>): void;
/**
* Compute route pattern from path and params (for SPAs)
* @param pathname Current pathname
* @param params Route parameters
*/
declare function computeRoute(pathname: string | null, params: Record<string, string | string[]> | null): string | null;
/**
* Reset the SDK configuration (for testing purposes)
* @internal
*/
declare function _resetConfig(): void;
export { AnalyticsConfig, _resetConfig, computeRoute, identify, init, initWithPageview, track, trackPageview };