: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
feat(workflows): add origin_product to workflow usage events (#111989)
Daniel Marchuk40398bbcf97a
diff --git a/products/workflows/backend/presentation/views/hog_flow.py b/products/workflows/backend/presentation/views/hog_flow.pyindex eec202b2ca7d..feb116e86d2a 100644--- a/products/workflows/backend/presentation/views/hog_flow.py+++ b/products/workflows/backend/presentation/views/hog_flow.py@@ -4663,6 +4663,8 @@ class HogFlowViewSet({"workflow_id": str(instance.id),"workflow_name": instance.name,+ # A WorkflowRef or a deleted workflow carries no origin.+ "origin_product": getattr(instance, "origin_product", None),"team_id": str(self.team_id),"organization_id": str(self.organization.id),**(extra_properties or {}),diff --git a/products/workflows/backend/tests/api/test_hog_flow.py b/products/workflows/backend/tests/api/test_hog_flow.pyindex e835eee87fbc..1e7cd7b13092 100644--- a/products/workflows/backend/tests/api/test_hog_flow.py+++ b/products/workflows/backend/tests/api/test_hog_flow.py@@ -5265,6 +5265,31 @@ class TestHogFlowAPI(APIBaseTest):assert len(deleted_events) == 1assert deleted_events[0].args[2]["workflow_id"] == flow_id+ @parameterized.expand(+ [+ ("broadcast", "broadcasts"),+ ("workflow", None),+ ]+ )+ @patch("products.workflows.backend.presentation.views.hog_flow.report_user_action")+ def test_created_usage_event_carries_origin_product(self, _name, origin_product, mock_report):+ hog_flow, _ = self._create_hog_flow_with_action(+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}},+ )+ if origin_product:+ hog_flow["origin_product"] = origin_product++ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)+ assert response.status_code == 201, response.json()++ created_events = [c for c in mock_report.call_args_list if c.args[1] == "hog_flow_created"]+ assert len(created_events) == 1+ assert created_events[0].args[2]["origin_product"] == origin_product++ response = self.client.delete(f"/api/projects/{self.team.id}/hog_flows/{response.json()['id']}")+ assert response.status_code == 204+ assert [c.args[1] for c in mock_report.call_args_list].count("hog_flow_deleted") == 1+@parameterized.expand([("draft",),