posthog.ts 553 B

1234567891011121314151617
  1. import { components } from 'api-types'
  2. import { hasConsented } from 'common'
  3. import { IS_PLATFORM } from './constants'
  4. import { handleError, post } from '@/data/fetchers'
  5. type TrackFeatureFlagVariables = components['schemas']['TelemetryFeatureFlagBody']
  6. export async function trackFeatureFlag(body: TrackFeatureFlagVariables) {
  7. const consent = hasConsented()
  8. if (!consent || !IS_PLATFORM) return undefined
  9. const { data, error } = await post(`/platform/telemetry/feature-flags/track`, { body })
  10. if (error) handleError(error)
  11. return data
  12. }