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.

feat(tasks): record chart kind and display on chart render events (#84043)

Sam Pennington21a465092198
diff --git a/products/tasks/backend/presentation/views/api.py b/products/tasks/backend/presentation/views/api.py
index 41cdf45f0900..f62aaed2960f 100644
--- a/products/tasks/backend/presentation/views/api.py
+++ b/products/tasks/backend/presentation/views/api.py
@@ -2914,6 +2914,8 @@ class TaskRunLivingArtifactViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewS
started = perf_counter()
def capture_render(*, failure_reason: str | None = None, export_asset_id: int | None = None) -> None:
+ raw_source = query.get("source") if isinstance(query, dict) else None
+ source: dict = raw_source if isinstance(raw_source, dict) else {}
posthoganalytics.capture(
distinct_id=str(getattr(request.user, "distinct_id", None) or self.team.uuid),
event="task_chart_render_failed" if failure_reason else "task_chart_render_succeeded",
@@ -2921,6 +2923,11 @@ class TaskRunLivingArtifactViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewS
"task_id": task_id,
"run_id": run_id,
"source": "query" if query is not None else "insight",
+ "insight_id": request.validated_data.get("insight_id"),
+ "query_kind": source.get("kind"),
+ "display": next(
+ (f["display"] for f in source.values() if isinstance(f, dict) and f.get("display")), None
+ ),
"duration_ms": round((perf_counter() - started) * 1000, 2),
"failure_reason": failure_reason,
"export_asset_id": export_asset_id,