import { useEffect } from 'react'; import { getAnalytics } from '../core/AnalyticsManager'; /** * Tracks the current screen whenever the component mounts (or deps change). * * ```tsx * function ProductScreen({ productId }: { productId: string }) { * useScreenTracking('Product', { product_id: productId }); * return ...; * } * ``` */ export function useScreenTracking( screenName: string, properties?: Record, deps: any[] = [] ): void { useEffect(() => { try { getAnalytics().screen(screenName, properties); } catch { // Analytics not yet initialized } // eslint-disable-next-line react-hooks/exhaustive-deps }, [screenName, ...deps]); }