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