'use client';

import { useEffect } from 'react';
import { useAnalytics } from './useAnalytics';
import { AnalyticsEvents } from './analytics-events';

export default function ClientNotFoundTracker({ path }: { path: string }) {
  const { trackEvent } = useAnalytics();

  useEffect(() => {
    trackEvent(AnalyticsEvents.ERROR, {
      type: '404_not_found',
      path,
    });

    import('@sentry/nextjs').then((Sentry) => {
      Sentry.withScope((scope) => {
        scope.setTag('status_code', '404');
        scope.setTag('path', path);
        Sentry.captureMessage(`Route Not Found: ${path}`, 'warning');
      });
    });
  }, [trackEvent, path]);

  return null;
}
