import { useDispatch } from '@store' ; import { noOp } from '@utils' ; import { useFeatureFlags } from '../FeatureFlag' ; import { LinkParams , PageParams , TrackParams } from './Analytics' ; import { trackEvent , trackLink , trackPage } from './saga' ; const useAnalytics = ( ) => { const dispatch = useDispatch ( ) ; const { isFeatureActive } = useFeatureFlags ( ) ; const isActive = isFeatureActive ( 'ANALYTICS' ) ; return { track : isActive ? ( payload ) => dispatch ( trackEvent ( payload ) ) : noOp , trackPage : isActive ? ( payload ) => dispatch ( trackPage ( payload ) ) : noOp , trackLink : isActive ? ( payload ) => dispatch ( trackLink ( payload ) ) : noOp } ; } ; export default useAnalytics ;