34 lines
915 B
TypeScript
34 lines
915 B
TypeScript
import {
|
|
trackPageView,
|
|
trackUserAction,
|
|
trackUserLocation,
|
|
trackSession,
|
|
getCurrentUserId,
|
|
isAnalyticsEnabled
|
|
} from '../utils/analytics';
|
|
|
|
/**
|
|
* React Hook for analytics
|
|
*
|
|
* NOTE: Page view tracking is handled globally by initializeAnalytics() in main.tsx.
|
|
* This hook only exposes tracking functions for use in components.
|
|
* Do NOT add automatic page tracking here to avoid duplicate events.
|
|
*/
|
|
export const useAnalytics = () => {
|
|
return {
|
|
// Manual page view tracking (use only for custom page events, not navigation)
|
|
trackPageView,
|
|
// Track user actions (button clicks, form submissions, etc.)
|
|
trackUserAction,
|
|
// Track user location (requires consent)
|
|
trackUserLocation,
|
|
// Track session (typically called once at app init)
|
|
trackSession,
|
|
// Get current user ID
|
|
getCurrentUserId,
|
|
// Check if analytics are enabled
|
|
isAnalyticsEnabled
|
|
};
|
|
};
|
|
|