useTrackExperimentExposure.ts18 lines · main
| 1 | import { hasConsented, posthogClient } from 'common' |
| 2 | import { useEffect } from 'react' |
| 3 | |
| 4 | export function useTrackExperimentExposure( |
| 5 | experimentId: string, |
| 6 | variant: string | undefined, |
| 7 | extraProperties?: Record<string, any> |
| 8 | ) { |
| 9 | useEffect(() => { |
| 10 | if (!variant) return |
| 11 | |
| 12 | posthogClient.captureExperimentExposure( |
| 13 | experimentId, |
| 14 | { variant, ...extraProperties }, |
| 15 | hasConsented() |
| 16 | ) |
| 17 | }, [experimentId, variant]) |
| 18 | } |