mirror of
https://github.com/suitenumerique/meet.git
synced 2026-11-15 12:34:29 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7dbe67264e |
@@ -0,0 +1,32 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { getPosthog } from '../utils'
|
||||
import { useIsAnalyticsEnabled } from './useIsAnalyticsEnabled'
|
||||
|
||||
/**
|
||||
* Same contract as `useFeatureFlagEnabled` from 'posthog-js/react', without a
|
||||
* static import of posthog-js: that import puts the whole SDK on the critical
|
||||
* path of every screen, defeating the lazy `getPosthog()`.
|
||||
*/
|
||||
export const useFeatureFlagEnabled = (flag: string): boolean | undefined => {
|
||||
const isAnalyticsEnabled = useIsAnalyticsEnabled()
|
||||
const [enabled, setEnabled] = useState<boolean | undefined>(undefined)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAnalyticsEnabled) return
|
||||
let cancelled = false
|
||||
let unsubscribe: (() => void) | undefined
|
||||
void getPosthog().then((ph) => {
|
||||
if (cancelled) return
|
||||
setEnabled(ph.isFeatureEnabled(flag))
|
||||
unsubscribe = ph.onFeatureFlags(() =>
|
||||
setEnabled(ph.isFeatureEnabled(flag))
|
||||
)
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
unsubscribe?.()
|
||||
}
|
||||
}, [flag, isAnalyticsEnabled])
|
||||
|
||||
return enabled
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
|
||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||
import type { RecordingMode } from '../types'
|
||||
import { useIsRecordingModeEnabled } from './useIsRecordingModeEnabled'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
|
||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||
import type { RecordingMode } from '../types'
|
||||
import { useIsRecordingModeEnabled } from './useIsRecordingModeEnabled'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
|
||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||
import { FeatureFlags } from '@/features/analytics/enums'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
|
||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||
import { FeatureFlags } from '@/features/analytics/enums'
|
||||
import useKonami from '@/features/rooms/livekit/hooks/useKonami'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
|
||||
import { FeatureFlags } from '@/features/analytics/enums'
|
||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||
import { isMobileBrowser } from '@livekit/components-core'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
|
||||
import { FeatureFlags } from '@/features/analytics/enums'
|
||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||
import { useConfig } from '@/api/useConfig'
|
||||
|
||||
Reference in New Issue
Block a user