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.

fix(dashboards): stamp dashboard_id on all dashboard created events (#61624)

Mike Warrendc26740f7982
diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.py
index 6a26ef30c61a..d720e97df437 100644
--- a/posthog/api/test/dashboards/test_dashboard.py
+++ b/posthog/api/test/dashboards/test_dashboard.py
@@ -1340,8 +1340,9 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):
"dashboard created",
{
"created_at": mock.ANY,
- "dashboard_id": None,
+ "dashboard_id": response["id"],
"duplicated": False,
+ "duplicated_from_dashboard_id": None,
"from_template": True,
"has_description": True,
"is_shared": False,
diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.py
index bf3affbb6b5a..4736caffc833 100644
--- a/products/dashboards/backend/api/dashboard.py
+++ b/products/dashboards/backend/api/dashboard.py
@@ -1118,7 +1118,7 @@ class DashboardSerializer(DashboardMetadataSerializer):
"from_template": bool(use_template),
"template_key": use_template,
"duplicated": bool(use_dashboard),
- "dashboard_id": use_dashboard,
+ "duplicated_from_dashboard_id": use_dashboard,
},
team=dashboard.team,
request=request,
@@ -2844,7 +2844,6 @@ class DashboardsViewSet(
"template_key": dashboard_template.template_name,
**template_scope_props,
"duplicated": False,
- "dashboard_id": dashboard.pk,
"creation_context": creation_context,
},
team=dashboard.team,
diff --git a/products/dashboards/backend/models/dashboard.py b/products/dashboards/backend/models/dashboard.py
index d62959ba2fd6..d5ffd83cebba 100644
--- a/products/dashboards/backend/models/dashboard.py
+++ b/products/dashboards/backend/models/dashboard.py
@@ -155,6 +155,7 @@ class Dashboard(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.M
Returns serialized information about the object for analytics reporting.
"""
return {
+ "dashboard_id": self.pk,
"pinned": self.pinned,
"item_count": self.tiles.exclude(insight=None).count(),
"is_shared": self.is_sharing_enabled,