'use client';

import { useEffect } from 'react';
import { firePixelEvent } from '../../tracking/firePixelEvent';
import type { PixelEvent, PixelEventParams } from '../../tracking/firePixelEvent';

interface Props {
  event: PixelEvent;
  params?: PixelEventParams;
}

/**
 * Fires a pixel event once when a portal tab mounts.
 * Placed at the root of each tab panel so it fires on both direct navigation
 * and post-login redirect to that tab.
 */
export function PortalTabTracker({ event, params }: Props) {
  useEffect(() => {
    firePixelEvent(event, params);
  // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  return null;
}
