import { useAnalytics } from 'hooks/useAnalytics'
import { FLAGS, useFeatureIsOn } from '@komi-app/flags-sdk'
import { CreatorEvent, useCreatorTracking } from '@komi-app/analytics-sdk'
import { SEGMENT_EVENTS } from 'constants/segment'

export const useAnalyticsClickAddContent = () => {
  const useAnalyticsSDK = useFeatureIsOn(FLAGS.USE_ANALYTICS_SDK_TALENT)
  const { sendSegmentEvent } = useAnalytics()
  const { createTracker } = useCreatorTracking()
  const clickedAddContent = createTracker(CreatorEvent.CLICKED_ADD_CONTENT)

  const trackClickAddContent = () => {
    if (useAnalyticsSDK) {
      clickedAddContent()
    } else {
      sendSegmentEvent(SEGMENT_EVENTS.CLICKED_ADD_CONTENT)
    }
  }

  return { trackClickAddContent }
}
