: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 posthog.settings import EE_AVAILABLE
from products.customer_analytics.backend.presentation.views import urls as external_api_urls
from products.customer_analytics.backend.presentation.views.account_persons_query import AccountPersonsViewSet
from products.customer_analytics.backend.presentation.views.accounts_table_query import AccountsTableQueryViewSet
from products.customer_analytics.backend.presentation.views.announcements import AnnouncementViewSet
from products.customer_analytics.backend.presentation.views.customer_tasks import CustomerTaskViewSet
from products.customer_analytics.backend.presentation.views.organization_members import (
OrganizationMembersForAccountViewSet,
)
from products.customer_analytics.backend.presentation.views.usage_metrics import GroupUsageMetricViewSet
from products.customer_analytics.backend.presentation.views.views import (
AccountNotebookViewSet,
AccountNotesViewSet,
AccountRelationshipDefinitionViewSet,
AccountRelationshipViewSet,
AccountTrackRuleViewSet,
AccountViewSet,
AccountViewTemplateViewSet,
CalendarSyncViewSet,
CustomerJourneyViewSet,
CustomerProfileConfigViewSet,
CustomPropertyDefinitionViewSet,
CustomPropertySourceViewSet,
CustomPropertyValueViewSet,
EventStreamViewSet,
FeatureRequestProductAreaViewSet,
FeatureRequestViewSet,
UserCustomerAnalyticsConfigViewSet,
)
from products.customer_analytics.backend.presentation.views.workflow_customer_tasks import WorkflowCustomerTaskViewSet
api_urlpatterns = external_api_urls.urlpatterns
def register_routes(routers: RouterRegistry) -> None:
routers.projects.register(
r"accounts/(?P<id>[^/.]+)/persons",
AccountPersonsViewSet,
"project_account_persons",
["team_id"],
)
routers.projects.register(
r"accounts_table_query",
AccountsTableQueryViewSet,
"project_accounts_table_query",
["team_id"],
)
routers.projects.register(
r"account_track_rules",
AccountTrackRuleViewSet,
"project_account_track_rules",
["team_id"],
)
routers.projects.register(
r"announcements",
AnnouncementViewSet,
"project_announcements",
["team_id"],
)
routers.projects.register(
r"organization_members",
OrganizationMembersForAccountViewSet,
"project_organization_members",
["team_id"],
)
routers.projects.register(
r"customer_profile_configs",
CustomerProfileConfigViewSet,
"project_customer_profile_configs",
["team_id"],
)
routers.projects.register(r"customer_journeys", CustomerJourneyViewSet, "project_customer_journeys", ["team_id"])
routers.projects.register(
r"feature_request_product_areas",
FeatureRequestProductAreaViewSet,
"project_feature_request_product_areas",
["team_id"],
)
routers.projects.register(
r"feature_requests",
FeatureRequestViewSet,
"project_feature_requests",
["team_id"],
)
routers.projects.register(
r"custom_property_definitions",
CustomPropertyDefinitionViewSet,
"project_custom_property_definitions",
["team_id"],
)
routers.projects.register(
r"custom_property_sources",
CustomPropertySourceViewSet,
"project_custom_property_sources",
["team_id"],
)
routers.projects.register(
r"account_relationship_definitions",
AccountRelationshipDefinitionViewSet,
"project_account_relationship_definitions",
["team_id"],
)
routers.projects.register(
r"account_notes",
AccountNotesViewSet,
"project_account_notes",
["team_id"],
)
routers.projects.register(
r"event_streams",
EventStreamViewSet,
"project_event_streams",
["team_id"],
)
routers.projects.register(
r"calendar_sync",
CalendarSyncViewSet,
"project_calendar_sync",
["team_id"],
)
routers.projects.register(
r"user_customer_analytics_config",
UserCustomerAnalyticsConfigViewSet,
"project_user_customer_analytics_config",
["team_id"],
)
routers.projects.register(
r"account_views",
AccountViewTemplateViewSet,
"project_account_views",
["team_id"],
)
project_accounts_router = routers.projects.register(r"accounts", AccountViewSet, "project_accounts", ["team_id"])
project_accounts_router.register(
r"notebooks", AccountNotebookViewSet, "project_account_notebooks", ["team_id", "account_id"]
)
project_accounts_router.register(
r"custom_property_values",
CustomPropertyValueViewSet,
"project_account_custom_property_values",
["team_id", "account_id"],
)
project_accounts_router.register(
r"relationships",
AccountRelationshipViewSet,
"project_account_relationships",
["team_id", "account_id"],
)
routers.projects.register(r"customer_tasks", CustomerTaskViewSet, "project_customer_tasks", ["team_id"])
routers.projects.register(
r"workflow_customer_tasks",
WorkflowCustomerTaskViewSet,
"project_workflow_customer_tasks",
["team_id"],
)
# Usage metrics keep the URL they had under the groups API, so they stay EE-only like it.
# Products cannot nest onto another product's router, so the group type segment is spelled
# out here with the `parent_lookup_` name the nested router would have given it.
if EE_AVAILABLE:
routers.projects.register(
r"groups_types/(?P<parent_lookup_group_type_index>[^/.]+)/metrics",
GroupUsageMetricViewSet,
"project_groups_metrics",
["project_id"],
)