posthog.ts17 lines · main
| 1 | import { components } from 'api-types' |
| 2 | import { hasConsented } from 'common' |
| 3 | |
| 4 | import { IS_PLATFORM } from './constants' |
| 5 | import { handleError, post } from '@/data/fetchers' |
| 6 | |
| 7 | type TrackFeatureFlagVariables = components['schemas']['TelemetryFeatureFlagBody'] |
| 8 | |
| 9 | export 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 | } |