- Add `release_channel` to Settings (Rust + TypeScript) - Add channel selector in Settings panel (alpha/beta/stable) - Pass `release_channel` as PostHog person property on identify - Add `isFeatureEnabled()` helper: alpha always true, beta/stable use PostHog flags with hardcoded fallback defaults - Update `useFeatureFlag` to delegate to PostHog-backed evaluation (localStorage overrides still work for dev/QA) - Create ADR-0042 (supersedes ADR-0017) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
681 B
TypeScript
23 lines
681 B
TypeScript
/**
|
|
* Feature flag hook backed by PostHog + release channels.
|
|
*
|
|
* Flags are resolved in order:
|
|
* 1. localStorage override (`ff_<name>`) — for dev/QA testing
|
|
* 2. PostHog feature flags (evaluated by release channel)
|
|
* 3. Alpha channel always returns true (sees all features)
|
|
*/
|
|
|
|
import { isFeatureEnabled } from '../lib/telemetry'
|
|
|
|
export type FeatureFlagName = 'example_flag'
|
|
|
|
export function useFeatureFlag(flag: FeatureFlagName): boolean {
|
|
try {
|
|
const override = localStorage.getItem(`ff_${flag}`)
|
|
if (override !== null) return override === 'true'
|
|
} catch {
|
|
// localStorage may be unavailable in some contexts
|
|
}
|
|
return isFeatureEnabled(flag)
|
|
}
|