: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
from posthog.api.routing import RouterRegistry
from products.feature_flags.backend.api import (
feature_flag,
flag_value,
organization_feature_flag,
scheduled_change,
staff_cache,
staff_team_config,
staff_teams,
)
from products.feature_flags.backend.presentation import request_usage
def register_routes(routers: RouterRegistry) -> None:
# Library-side feature flag evaluation (legacy root path).
routers.root.register(r"feature_flag", feature_flag.LegacyFeatureFlagViewSet)
# Staff-only, unscoped flags tooling: root-level so it is not team-nested.
routers.root.register(
r"feature_flags_staff_teams",
staff_teams.FeatureFlagsStaffTeamSearchViewSet,
"feature_flags_staff_teams",
)
routers.root.register(
r"feature_flags_staff_cache",
staff_cache.FeatureFlagsStaffCacheViewSet,
"feature_flags_staff_cache",
)
routers.root.register(
r"feature_flags_staff_team_config",
staff_team_config.FeatureFlagsStaffTeamConfigViewSet,
"feature_flags_staff_team_config",
)
routers.projects.register(
r"feature_flags", feature_flag.FeatureFlagViewSet, "project_feature_flags", ["project_id"]
)
routers.projects.register(
r"feature_flag_request_usage",
request_usage.FeatureFlagRequestUsageViewSet,
"project_feature_flag_request_usage",
["project_id"],
)
routers.projects.register(
r"scheduled_changes", scheduled_change.ScheduledChangeViewSet, "project_scheduled_changes", ["project_id"]
)
routers.projects.register(r"flag_value", flag_value.FlagValueViewSet, "project_flag_value", ["project_id"])
routers.organizations.register(
r"feature_flags",
organization_feature_flag.OrganizationFeatureFlagView,
"organization_feature_flags",
["organization_id"],
)