@click-chutney/clickanalytics
Version:
Simplified analytics library inspired by Vercel Analytics - privacy-first, lightweight tracking
81 lines (80 loc) • 1.77 kB
TypeScript
interface AnalyticsProps {
/**
* Your ClickChutney tracking ID
*/
trackingId?: string;
/**
* Enable debug logging
*/
debug?: boolean;
/**
* Disable analytics in development mode
* @default true
*/
disableInDev?: boolean;
/**
* Custom API endpoint for analytics
*/
apiUrl?: string;
/**
* Filter function to modify or block events before sending
*/
beforeSend?: (event: any) => any | false;
}
/**
* Analytics component for React/Next.js applications
*
* @example
* ```tsx
* import { Analytics } from '@click-chutney/clickanalytics/react';
*
* export default function RootLayout({ children }) {
* return (
* <html>
* <body>
* {children}
* <Analytics trackingId="your-tracking-id" />
* </body>
* </html>
* );
* }
* ```
*/
export declare function Analytics(props: AnalyticsProps): null;
/**
* Hook for manual analytics tracking
*
* @example
* ```tsx
* import { useAnalytics } from '@click-chutney/clickanalytics/react';
*
* function MyComponent() {
* const analytics = useAnalytics();
*
* const handleClick = () => {
* analytics.event('button_click', { button: 'signup' });
* };
*
* return <button onClick={handleClick}>Sign Up</button>;
* }
* ```
*/
export declare function useAnalytics(): {
/**
* Track a page view
*/
pageview: (url?: string, title?: string) => void;
/**
* Track a custom event
*/
event: (name: string, properties?: Record<string, any>) => void;
/**
* Identify a user
*/
identify: (userId: string) => void;
/**
* Manually flush queued events
*/
flush: () => Promise<void>;
};
export default Analytics;