import { useCallback } from 'react';
import { useRecoilValue } from 'recoil';
import get from 'lodash/get';
import { utagConfig as utagAtom, variant as variantAtom } from "../../../atoms/tracking/index.js";
import { trackEvent } from "../../../utils/tracking/index.js";
const useTrackEvent = function useTrackEvent() {
  const config = useRecoilValue(utagAtom);
  const variantId = useRecoilValue(variantAtom);
  const projectName = get(config, 'projectName');
  return useCallback((eventLabel, abTestingLabel) => {
    if (!projectName) return;
    const fullAbTestingLabel = abTestingLabel ? `${variantId}:${abTestingLabel}` : undefined;
    trackEvent({
      app: projectName,
      eventLabel,
      abTestingId: variantId,
      abTestingLabel: fullAbTestingLabel
    });
  }, [projectName, variantId]);
};
export default useTrackEvent;