: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
"""
Exported enums and constants for access_control.
Small products can keep enums in contracts.py instead. Split
into this file when contracts.py gets crowded.
Rule: if an enum appears in a contract dataclass field, it
belongs here (or in contracts.py). Shared types that other
products need to interpret contract objects also belong here.
Internal-only constants (DB magic values, feature flags, etc.)
should stay in the implementation (logic.py, models.py).
"""
from typing import Literal, get_args
from posthog.hogql.database.schema.ai_events import AI_PROPERTY_TO_COLUMN
from posthog.scopes import GRANTABLE_API_SCOPE_OBJECTS
ResolvedAccessSourceValue = Literal[
"object",
"parent_object",
"resource",
"parent_resource",
"system_default",
"org_admin",
"creator",
"org_membership",
]
ResolvedAccessSourceSubjectValue = Literal["member", "role", "default"]
# Serializer choices for the literals above. The schema names their enum components through
# ENUM_NAME_OVERRIDES in posthog/settings/web.py, because no Choices class carries these values.
RESOLVED_ACCESS_SOURCE_CHOICES: list[str] = list(get_args(ResolvedAccessSourceValue))
RESOLVED_ACCESS_SOURCE_SUBJECT_CHOICES: list[str] = list(get_args(ResolvedAccessSourceSubjectValue))
# The scope objects a rule can name. The schema names the enum component ScopeObjectEnum through
# ENUM_NAME_OVERRIDES, and the frontend derives its APIScopeObject type from that enum.
# Keep every grantable scope object here. The scope pickers get their type from this enum, so a
# narrower list would remove objects from the OAuth consent screen and the key picker.
SCOPE_OBJECT_CHOICES: list[str] = list(GRANTABLE_API_SCOPE_OBJECTS)
AI_EVENT_PROPERTY_CHOICES: list[str] = list(AI_PROPERTY_TO_COLUMN)