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.1 KB
Raw Blame
from posthog.api import sharing
from posthog.api.routing import RouterRegistry

from products.dashboards.backend.api import dashboard, dashboard_templates


def register_routes(routers: RouterRegistry) -> None:
    # Legacy flat endpoints — should be unused, but kept until callers are confirmed dead.
    routers.root.register(r"dashboard", dashboard.LegacyDashboardsViewSet, "legacy_dashboards")
    routers.root.register(r"dashboard_item", dashboard.LegacyInsightViewSet, "legacy_insights")

    routers.projects.register(
        r"dashboard_templates",
        dashboard_templates.DashboardTemplateViewSet,
        "project_dashboard_templates",
        ["project_id"],
    )

    dashboards_router = routers.projects.register(
        r"dashboards", dashboard.DashboardsViewSet, "project_dashboards", ["team_id"]
    )

    # SharingConfigurationViewSet is shared (core), but the route lives under
    # dashboards/<id>/sharing — the dashboards product owns the sub-route.
    dashboards_router.register(
        r"sharing",
        sharing.SharingConfigurationViewSet,
        "project_dashboard_sharing",
        ["team_id", "dashboard_id"],
    )