Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.5 KB
Raw Blame
import { useValues } from 'kea'

import { LemonButton } from '@posthog/lemon-ui'
import { Button } from '@posthog/quill'

import { AccessDenied } from 'lib/components/AccessDenied'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'

import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'

import { featureFlagsStaffToolsLogic } from './featureFlagsStaffToolsLogic'
import { StaffCacheToolsTab } from './StaffCacheToolsTab'

export const scene: SceneExport = {
    component: FeatureFlagsStaffToolsScene,
    logic: featureFlagsStaffToolsLogic,
}

export function FeatureFlagsStaffToolsScene(): JSX.Element {
    const { user } = useValues(userLogic)
    const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')

    if (!user?.is_staff) {
        return <AccessDenied object="page" reason="This page is only accessible to staff users." />
    }

    return (
        <SceneContent>
            <SceneTitleSection
                name="Flags staff tools"
                description="Look up any team across all organizations to inspect and rebuild its flag caches, or adjust its feature-flags config."
                resourceType={{ type: 'feature_flag' }}
                actions={
                    todayRailNav ? (
                        <>
                            <Button variant="outline" render={<LinkPrimitive to={urls.cohortsStaffTools()} />}>
                                Cohorts staff tools
                            </Button>
                            <Button variant="outline" render={<LinkPrimitive to={urls.instanceSettings()} />}>
                                Flags-related instance settings
                            </Button>
                        </>
                    ) : (
                        <>
                            <LemonButton type="secondary" size="small" to={urls.cohortsStaffTools()}>
                                Cohorts staff tools
                            </LemonButton>
                            <LemonButton type="secondary" size="small" to={urls.instanceSettings()}>
                                Flags-related instance settings
                            </LemonButton>
                        </>
                    )
                }
            />
            <StaffCacheToolsTab />
        </SceneContent>
    )
}