@datataki/client
Version:
A lightweight client-side event tracking library for modern web applications. Track user sessions, page views, interactions and custom events with minimal setup.
33 lines (32 loc) • 1.26 kB
TypeScript
import { MetadataType } from './types/common.types';
import { Config } from './types/config.types';
export * as Types from './types';
export { SESSION_TIMEOUT_MS } from './app.constants';
/**
* Initializes the datataki app with the provided configuration.
* @param appConfig - The configuration object for the app
* @throws {Error} If the app is already initialized or initialization is in progress
* @example
* await init({ id: 'my-project-id' });
*/
export declare const init: (appConfig: Config) => Promise<void>;
/**
* Sends a custom event with the specified name and metadata.
* @param name - The name of the custom event.
* @param metadata - Optional metadata to attach to the event.
* @example
* // Send a custom event with metadata
* event('user_signup', { method: 'email', plan: 'premium' });
* @example
* // Send a custom event without metadata
* event('user_login');
* @remarks
* This function should be called after the app has been initialized using the `init` function.
*/
export declare const event: (name: string, metadata?: Record<string, MetadataType>) => void;
/**
* Destroys the current app instance and cleans up resources.
* @example
* destroy(); // Safely cleanup the app
*/
export declare const destroy: () => void;