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.

944 B
Raw Blame
import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'
import { TeamMembershipLevel } from 'lib/constants'

// Single source of truth for "can the current user overwrite an existing integration" on the frontend.
// The backend lets any project member create an integration, but IntegrationSerializer.create requires
// project admin to overwrite one (the creator of a Google Calendar connection is the only exception).
// Returns a disabledReason string when the user lacks access, else null. Wire it into the
// disabledReason of any affordance that can overwrite an integration, such as a reconnect or an OAuth
// connect that can land on an account that is already connected, so these gates stay in sync.
export function useIntegrationManagementRestriction(): string | null {
    return useRestrictedArea({
        scope: RestrictionScope.Project,
        minimumAccessLevel: TeamMembershipLevel.Admin,
    })
}