import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { getAnalytics } from './AnalyticsManager';

export function usePageTracking(enabled = true) {
  const location = useLocation();

  useEffect(() => {
    if (!enabled) return;

    const analytics = getAnalytics();
    analytics.trackPageView({
      path: location.pathname,
      title: document.title,
    });
  }, [enabled, location.pathname]);
}
