* chore: add usercentrics for consent management * client component to make next.js happy * address feedback * move consent state to common * fix import * ensure page events are sent correctly * add feature flag provider to ui library site * fix ui lib 500 error * skip in test env --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Jordi Enric <jordi.err@gmail.com>
17 lines
553 B
TypeScript
17 lines
553 B
TypeScript
import { components } from 'api-types'
|
|
import { hasConsented } from 'common'
|
|
import { handleError, post } from 'data/fetchers'
|
|
import { IS_PLATFORM } from './constants'
|
|
|
|
type TrackFeatureFlagVariables = components['schemas']['TelemetryFeatureFlagBodyDto']
|
|
|
|
export async function trackFeatureFlag(body: TrackFeatureFlagVariables) {
|
|
const consent = hasConsented()
|
|
|
|
if (!consent || !IS_PLATFORM) return undefined
|
|
const { data, error } = await post(`/platform/telemetry/feature-flags/track`, { body })
|
|
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|