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.

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

import { useRestrictedArea } from 'lib/components/RestrictedArea'
import { OrganizationMembershipLevel } from 'lib/constants'
import { userLogic } from 'scenes/userLogic'

import { AvailableFeature } from '~/types'

import { OrganizationPersonalAPIKeysTable } from './OrganizationPersonalAPIKeysTable'
import { OrganizationSecuritySettingGate } from './OrganizationSecuritySettingGate'

export function OrganizationPersonalAPIKeys(): JSX.Element {
    const { hasAvailableFeature } = useValues(userLogic)
    const restrictionReason = useRestrictedArea({ minimumAccessLevel: OrganizationMembershipLevel.Admin })

    // PayGateMini falls through to its children when billing carries no metadata for the feature,
    // so the entitlement is checked here too. Otherwise the table below mounts and its first
    // request comes back as a payment prompt.
    const entitled = hasAvailableFeature(AvailableFeature.ORGANIZATION_SECURITY_SETTINGS)

    if (restrictionReason) {
        return <p className="text-muted">{restrictionReason}</p>
    }

    return (
        <OrganizationSecuritySettingGate featureDetail="organization-personal-api-keys">
            {entitled ? <OrganizationPersonalAPIKeysTable /> : null}
        </OrganizationSecuritySettingGate>
    )
}