32 lines
841 B
TypeScript
32 lines
841 B
TypeScript
/**
|
|
* Type definition for analytics event properties.
|
|
*/
|
|
export type AnalyticsEventProperties = Record<
|
|
string,
|
|
string | number | boolean | null | undefined
|
|
>;
|
|
|
|
/**
|
|
* Interface for analytics service implementations.
|
|
*
|
|
* This interface defines the contract for all analytics services,
|
|
* allowing for different implementations (Umami, Google Analytics, etc.)
|
|
* while maintaining a consistent API.
|
|
*/
|
|
export interface AnalyticsService {
|
|
/**
|
|
* Track a custom event with optional properties.
|
|
*
|
|
* @param eventName - The name of the event to track
|
|
* @param props - Optional event properties (metadata)
|
|
*/
|
|
track(eventName: string, props?: AnalyticsEventProperties): void;
|
|
|
|
/**
|
|
* Track a pageview.
|
|
*
|
|
* @param url - The URL to track (defaults to current location)
|
|
*/
|
|
trackPageview(url?: string): void;
|
|
}
|