Files
supabase/apps/studio/hooks/misc/useTrackExperimentExposure.ts
Alaister YoungandAlaister Young e73811f1c8 fix(studio): restore useTrackExperimentExposure hook (#49763)
Restores `hooks/misc/useTrackExperimentExposure.ts`, fixing the
typecheck failure on master that broke the latest Studio production
deploy.

The hook was deleted as dead code in #49719 (it was genuinely unused on
master at the time), but #49534 was in flight and reintroduced a usage
in `plan-presentation.ts`. The two PRs merged cleanly with no textual
conflict, so nothing typechecked the combination until the deploy off
master failed with:

```
plan-presentation.ts(5,44): error TS2307: Cannot find module '@/hooks/misc/useTrackExperimentExposure'
```

**Added:**
- `apps/studio/hooks/misc/useTrackExperimentExposure.ts` — restored
verbatim from before #49719; no longer dead code since
`plan-presentation.ts` imports it

## To test

- `pnpm --filter studio typecheck` passes (verified locally)
- `pnpm knip --workspace apps/studio` no longer flags the hook (verified
locally)
- Studio production deploy succeeds once merged

https://claude.ai/code/session_01XZGr2n1dBzJ7m3DYsGu852

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-08-31 10:10:30 +00:00

19 lines
440 B
TypeScript

import { hasConsented, posthogClient } from 'common'
import { useEffect } from 'react'
export function useTrackExperimentExposure(
experimentId: string,
variant: string | undefined,
extraProperties?: Record<string, any>
) {
useEffect(() => {
if (!variant) return
posthogClient.captureExperimentExposure(
experimentId,
{ variant, ...extraProperties },
hasConsented()
)
}, [experimentId, variant])
}