: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(today): show workflow health and suggestions as highlights (#117887)
Harley Alexanderbc5b23ab5997
diff --git a/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx b/frontend/src/scenes/project-homepage/today/todayRowIcons.tsxindex 553740e55baf..65e01edabdf5 100644--- a/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx+++ b/frontend/src/scenes/project-homepage/today/todayRowIcons.tsx@@ -1,6 +1,7 @@import {IconBell,IconDatabase,+ IconDecisionTree,IconFlask,IconMessage,IconRewindPlay,@@ -26,6 +27,8 @@ const ANALYTICS: TodayRowIcon = {glyph: <IconTrends />,}+const WORKFLOWS: TodayRowIcon = { color: 'var(--color-product-workflows-light)', glyph: <IconDecisionTree /> }+const HIGHLIGHT_ICONS: Record<string, TodayRowIcon> = {alerts: { color: 'var(--color-product-alerts-light)', glyph: <IconBell /> },errors: { color: 'var(--color-product-error-tracking-light)', glyph: <IconWarning /> },@@ -35,6 +38,8 @@ const HIGHLIGHT_ICONS: Record<string, TodayRowIcon> = {surveys: { color: 'var(--color-product-surveys-light)', glyph: <IconMessage /> },ticket_sla: { color: 'var(--color-product-support-light)', glyph: <IconSupport /> },warehouse_syncs: { color: 'var(--color-product-data-warehouse-light)', glyph: <IconDatabase /> },+ workflow_ideas: WORKFLOWS,+ workflows: WORKFLOWS,}function sourceIcon(source: string | null | undefined): TodayRowIcon {diff --git a/products/today/backend/logic/highlight_sources/workflow_ideas.py b/products/today/backend/logic/highlight_sources/workflow_ideas.pynew file mode 100644index 000000000000..e0176f85b383--- /dev/null+++ b/products/today/backend/logic/highlight_sources/workflow_ideas.py@@ -0,0 +1,32 @@+from products.workflows.backend.facade.data_suggestions import count_waiting_data_suggestions++from ...facade.enums import HighlightLabel+from ..highlight_rules import exact+from ..highlight_types import Candidate, Context, Found, Source++IDEAS = "{count} workflow ideas based on your events are ready"+IDEA = "1 workflow idea based on your events is ready"+IDEAS_DETAIL = "Pick one to build it as a draft workflow"+++def find(context: Context) -> Found:+ count = count_waiting_data_suggestions(team=context.team, user=context.user)+ if not count:+ return Found()+ return Found(+ items=(+ Candidate(+ key="workflow-ideas",+ label=HighlightLabel.OPPORTUNITY,+ family="workflows",+ importance=0.3,+ relevance=1.0,+ title=IDEA if count == 1 else IDEAS.format(count=exact(count)),+ detail=IDEAS_DETAIL,+ url="/workflows",+ ),+ )+ )+++SOURCE = Source(name="workflow_ideas", find=find, scopes=("hog_flow:read",))diff --git a/products/today/backend/logic/highlight_sources/workflows.py b/products/today/backend/logic/highlight_sources/workflows.pynew file mode 100644index 000000000000..d0140076601d--- /dev/null+++ b/products/today/backend/logic/highlight_sources/workflows.py@@ -0,0 +1,116 @@+from products.workflows.backend.facade.api import get_email_sending_state, list_owned_workflow_health+from products.workflows.backend.facade.contracts import OwnedWorkflowHealth++from ...facade.enums import HighlightLabel+from ..highlight_rules import exact, short+from ..highlight_types import Candidate, Context, Found, Source++SENDING_SUSPENDED = "Email sending is suspended for this project"+SENDING_SUSPENDED_DETAIL = "Workflow and broadcast emails are not delivered. Contact support to turn sending back on"+EMAILS_PAUSED = "Emails are paused for workflow ‘{workflow}’"+EMAILS_PAUSED_DETAIL = "It sends no emails until sending resumes"+FAILING = "Workflow ‘{workflow}’ failed {failed} times in the last 7 days"+FAILING_DETAIL = "{share:.0%} of its runs failed"+SUGGESTIONS = "{count} suggested changes to workflow ‘{workflow}’ are waiting for review"+SUGGESTION = "1 suggested change to workflow ‘{workflow}’ is waiting for review"+SUGGESTIONS_DETAIL = "Approve or reject them on the Self-driving tab"+SUGGESTION_DETAIL = "Approve or reject it on the Self-driving tab"+MIN_FAILED = 10+MIN_FAILED_SHARE = 0.1+++def find(context: Context) -> Found:+ workflows = list_owned_workflow_health(team=context.team, user=context.user, limit=20)+ if not workflows:+ return Found()+ candidates = [candidate for workflow in workflows for candidate in _candidates(workflow)]+ state = get_email_sending_state(context.team.id)+ if state is not None and state.suspended_at is not None:+ candidates.insert(0, _sending_suspended())+ return Found(items=tuple(candidates))+++def _sending_suspended() -> Candidate:+ # Suspension stops every email step in the project, so it outranks any one workflow's problem.+ return Candidate(+ key="workflows:email-sending-suspended",+ label=HighlightLabel.RISK,+ family="workflows",+ importance=0.95,+ relevance=1.0,+ title=SENDING_SUSPENDED,+ detail=SENDING_SUSPENDED_DETAIL,+ url="/workflows/reputation",+ )+++def _candidates(workflow: OwnedWorkflowHealth) -> list[Candidate]:+ name = short(workflow.name)+ candidates = []+ if workflow.email_sending_paused:+ candidates.append(+ _candidate(+ workflow,+ "emails-paused",+ HighlightLabel.RISK,+ importance=0.85,+ title=EMAILS_PAUSED.format(workflow=name),+ detail=EMAILS_PAUSED_DETAIL,+ tab="workflow",+ )+ )+ runs = workflow.succeeded + workflow.failed+ if workflow.failed >= MIN_FAILED and workflow.failed >= MIN_FAILED_SHARE * runs:+ share = workflow.failed / runs+ candidates.append(+ _candidate(+ workflow,+ "failing",+ HighlightLabel.RISK,+ importance=min(1.0, 0.5 + share / 2),+ title=FAILING.format(workflow=name, failed=exact(workflow.failed)),+ detail=FAILING_DETAIL.format(share=share),+ tab="invocations",+ )+ )+ if workflow.pending_suggestions:+ one = workflow.pending_suggestions == 1+ candidates.append(+ _candidate(+ workflow,+ "suggestions",+ HighlightLabel.OPPORTUNITY,+ importance=0.4,+ title=(SUGGESTION if one else SUGGESTIONS).format(+ workflow=name, count=exact(workflow.pending_suggestions)+ ),+ detail=SUGGESTION_DETAIL if one else SUGGESTIONS_DETAIL,+ tab="self-driving",+ )+ )+ return candidates+++def _candidate(+ workflow: OwnedWorkflowHealth,+ kind: str,+ label: HighlightLabel,+ *,+ importance: float,+ title: str,+ detail: str,+ tab: str,+) -> Candidate:+ return Candidate(+ key=f"workflow:{workflow.workflow_id}:{kind}",+ label=label,+ family="workflows",+ importance=importance,+ relevance=1.0,+ title=title,+ detail=detail,+ url=f"/workflows/{workflow.workflow_id}/{tab}",+ )+++SOURCE = Source(name="workflows", find=find, scopes=("hog_flow:read",))diff --git a/products/today/backend/tests/test_highlight_workflows.py b/products/today/backend/tests/test_highlight_workflows.pynew file mode 100644index 000000000000..ab7812e5ffa7--- /dev/null+++ b/products/today/backend/tests/test_highlight_workflows.py@@ -0,0 +1,145 @@+import uuid+from datetime import UTC, datetime+from types import SimpleNamespace+from typing import Any, cast++from unittest.mock import patch++from django.test import SimpleTestCase++from parameterized import parameterized++from products.today.backend.facade.enums import HighlightLabel+from products.today.backend.logic.highlight_registry import load_sources+from products.today.backend.logic.highlight_sources import workflow_ideas, workflows+from products.today.backend.logic.highlight_types import Context+from products.workflows.backend.facade.contracts import EmailSendingState, OwnedWorkflowHealth++WORKFLOW_ID = uuid.UUID("00000000-0000-4000-8000-000000000001")+CONTEXT = cast(Context, SimpleNamespace(team=SimpleNamespace(id=1), user=None))+++def _workflow(**fields: Any) -> OwnedWorkflowHealth:+ return OwnedWorkflowHealth(+ **{+ "workflow_id": WORKFLOW_ID,+ "name": "Onboarding drip",+ "succeeded": 100,+ "failed": 0,+ "email_sending_paused": False,+ "pending_suggestions": 0,+ **fields,+ }+ )+++class TestWorkflows(SimpleTestCase):+ @parameterized.expand(+ [+ ("healthy", _workflow(), []),+ (+ "emails paused",+ _workflow(email_sending_paused=True),+ [+ (+ HighlightLabel.RISK,+ "Emails are paused for workflow ‘Onboarding drip’",+ "It sends no emails until sending resumes",+ f"/workflows/{WORKFLOW_ID}/workflow",+ )+ ],+ ),+ (+ "failing",+ _workflow(succeeded=30, failed=10),+ [+ (+ HighlightLabel.RISK,+ "Workflow ‘Onboarding drip’ failed 10 times in the last 7 days",+ "25% of its runs failed",+ f"/workflows/{WORKFLOW_ID}/invocations",+ )+ ],+ ),+ ("too few failures", _workflow(succeeded=0, failed=9), []),+ ("failures are a small share of runs", _workflow(succeeded=1000, failed=99), []),+ (+ "one suggestion",+ _workflow(pending_suggestions=1),+ [+ (+ HighlightLabel.OPPORTUNITY,+ "1 suggested change to workflow ‘Onboarding drip’ is waiting for review",+ "Approve or reject it on the Self-driving tab",+ f"/workflows/{WORKFLOW_ID}/self-driving",+ )+ ],+ ),+ (+ "several suggestions",+ _workflow(pending_suggestions=3),+ [+ (+ HighlightLabel.OPPORTUNITY,+ "3 suggested changes to workflow ‘Onboarding drip’ are waiting for review",+ "Approve or reject them on the Self-driving tab",+ f"/workflows/{WORKFLOW_ID}/self-driving",+ )+ ],+ ),+ ]+ )+ def test_a_workflow_shows_what_needs_its_owner(+ self, _name: str, workflow: OwnedWorkflowHealth, expected: list[tuple[HighlightLabel, str, str, str]]+ ) -> None:+ registered = next(s for s in load_sources() if s.name == "workflows")++ with (+ patch.object(workflows, "list_owned_workflow_health", return_value=[workflow]),+ patch.object(workflows, "get_email_sending_state", return_value=None),+ ):+ found = registered.find(CONTEXT)++ self.assertEqual([(c.label, c.title, c.detail, c.url) for c in found.items], expected)++ @parameterized.expand(+ [+ ("suspended", [_workflow()], True, ["Email sending is suspended for this project"]),+ ("suspended, with no live workflow of yours", [], True, []),+ ("sending on", [_workflow()], False, []),+ ]+ )+ def test_a_suspended_project_shows_to_workflow_owners(+ self, _name: str, owned: list[OwnedWorkflowHealth], suspended: bool, expected: list[str]+ ) -> None:+ registered = next(s for s in load_sources() if s.name == "workflows")+ state = EmailSendingState(+ suspended_at=datetime(2026, 10, 1, tzinfo=UTC) if suspended else None,+ suspension_reason="",+ tier=1,+ tier_pinned=False,+ tier_updated_at=None,+ )++ with (+ patch.object(workflows, "list_owned_workflow_health", return_value=owned),+ patch.object(workflows, "get_email_sending_state", return_value=state),+ ):+ found = registered.find(CONTEXT)++ self.assertEqual([c.title for c in found.items], expected)++ @parameterized.expand(+ [+ ("none", 0, []),+ ("one", 1, ["1 workflow idea based on your events is ready"]),+ ("several", 4, ["4 workflow ideas based on your events are ready"]),+ ]+ )+ def test_waiting_workflow_ideas_show_once(self, _name: str, count: int, expected: list[str]) -> None:+ registered = next(s for s in load_sources() if s.name == "workflow_ideas")++ with patch.object(workflow_ideas, "count_waiting_data_suggestions", return_value=count):+ found = registered.find(CONTEXT)++ self.assertEqual([(c.title, c.url) for c in found.items], [(title, "/workflows") for title in expected])diff --git a/products/workflows/backend/facade/api.py b/products/workflows/backend/facade/api.pyindex 5afd0fea6009..1c681ec429c7 100644--- a/products/workflows/backend/facade/api.py+++ b/products/workflows/backend/facade/api.py@@ -38,6 +38,7 @@ from products.workflows.backend.services.email_sending_controls import (unsuspend_email_sending,)from products.workflows.backend.services.integration_usage import get_active_hog_flows_using_integration+from products.workflows.backend.services.owned_workflow_health import list_owned_workflow_healthfrom products.workflows.backend.services.template_input_usage import (filter_hog_flow_references_by_access_level,get_hog_flows_referencing_template_input_keys,@@ -62,6 +63,7 @@ __all__ = ["get_email_sending_state","get_email_sending_tier_limits","get_hog_flows_referencing_template_input_keys",+ "list_owned_workflow_health","max_email_sending_tier","set_default_email_sender_if_unset","set_email_sending_tier",diff --git a/products/workflows/backend/facade/contracts.py b/products/workflows/backend/facade/contracts.pyindex f55652bcba8b..518bb7554d92 100644--- a/products/workflows/backend/facade/contracts.py+++ b/products/workflows/backend/facade/contracts.py@@ -50,6 +50,18 @@ class WorkflowActivitySummary:recent: tuple[RecentWorkflow, ...]+@frozen+class OwnedWorkflowHealth:+ """A live workflow one person created: its runs over the last 7 days and what waits on its owner."""++ workflow_id: UUID+ name: str+ succeeded: int+ failed: int+ email_sending_paused: bool+ pending_suggestions: int++@frozenclass WorkflowTaskDailyLimits:"""A team's daily caps on tasks created by workflows. None means the default cap applies."""diff --git a/products/workflows/backend/facade/data_suggestions.py b/products/workflows/backend/facade/data_suggestions.pyindex 0cccab7e1109..64234d2d7b0b 100644--- a/products/workflows/backend/facade/data_suggestions.py+++ b/products/workflows/backend/facade/data_suggestions.py@@ -6,7 +6,9 @@ from posthog.models import Team, Userfrom products.workflows.backend.facade.contracts import BuiltSuggestion, DataSuggestionsResultfrom products.workflows.backend.services.data_suggestions import servicefrom products.workflows.backend.services.data_suggestions.service import (+ FEATURE_FLAG_KEY,build_caller,+ count_waiting_data_suggestions,email_sender_ready,get_data_suggestions,needs_new_build,@@ -15,7 +17,9 @@ from products.workflows.backend.services.data_suggestions.service import (from products.workflows.backend.tasks.data_suggestions import build_data_suggestion, generate_data_suggestions__all__ = [+ "FEATURE_FLAG_KEY","build_caller",+ "count_waiting_data_suggestions","email_sender_ready","get_data_suggestions","needs_new_build",diff --git a/products/workflows/backend/presentation/views/workflow_data_suggestions.py b/products/workflows/backend/presentation/views/workflow_data_suggestions.pyindex c9fc8ee7cbab..622fe62424af 100644--- a/products/workflows/backend/presentation/views/workflow_data_suggestions.py+++ b/products/workflows/backend/presentation/views/workflow_data_suggestions.py@@ -17,6 +17,7 @@ from posthog.rate_limit import AIBurstRateThrottle, AISustainedRateThrottlefrom products.workflows.backend.facade.contracts import DataSuggestionNotFound, DataSuggestionsResultfrom products.workflows.backend.facade.data_suggestions import (+ FEATURE_FLAG_KEY,build_caller,email_sender_ready,get_data_suggestions,@@ -26,9 +27,6 @@ from products.workflows.backend.facade.data_suggestions import (start_data_suggestions,)-# pinned: feature flag key - the frontend gates the same surfaces on it-FEATURE_FLAG_KEY = "workflows-data-suggestions"-class DataSuggestionStepKind(models.TextChoices):EMAIL = "email"diff --git a/products/workflows/backend/services/data_suggestions/service.py b/products/workflows/backend/services/data_suggestions/service.pyindex 7119a2b43eea..10ce0d0c050e 100644--- a/products/workflows/backend/services/data_suggestions/service.py+++ b/products/workflows/backend/services/data_suggestions/service.py@@ -10,6 +10,7 @@ from django.conf import settingsfrom django.core.cache import cacheimport structlog+import posthoganalyticsfrom posthog.cloud_utils import is_cloudfrom posthog.errors import CH_TRANSIENT_ERRORS, InternalCHQueryError@@ -28,6 +29,7 @@ from products.workflows.backend.facade.contracts import (DataSuggestionsResult,MissingInput,)+from products.workflows.backend.models.hog_flow.hog_flow import HogFlowfrom products.workflows.backend.services.data_suggestions import team_contextfrom products.workflows.backend.services.data_suggestions.builder import (BuildContext,@@ -83,6 +85,8 @@ _GENERATING = DataSuggestionsResult(status="generating", suggestions=())_BUILDING = BuiltSuggestion(status="building")_BUILD_FAILED = BuiltSuggestion(status="failed")_UNAVAILABLE = DataSuggestionsResult(status="unavailable", suggestions=())+# pinned: feature flag key - the frontend gates the same surfaces on it+FEATURE_FLAG_KEY = "workflows-data-suggestions"_ONCE_PER_PERSON_STAGES = frozenset({"signup", "onboarding"})# A project without a verified sender cannot pick one yet, so the field says what to do first.NO_SENDER_FIELD = "Email sender (no verified sender yet: add a sending domain under Workflows > Channels)"@@ -99,6 +103,28 @@ def get_data_suggestions(*, team: Team) -> DataSuggestionsResult:return _read_cache(team) or _UNAVAILABLE+def is_data_suggestions_enabled(user: User, organization_id: str) -> bool:+ return bool(+ user.distinct_id+ and posthoganalytics.feature_enabled(+ FEATURE_FLAG_KEY,+ user.distinct_id,+ groups={"organization": organization_id},+ group_properties={"organization": {"id": organization_id}},+ )+ )+++def count_waiting_data_suggestions(*, team: Team, user: User) -> int:+ """The ideas this person would see on the empty workflows page. Like `get_data_suggestions`, it never runs a model."""+ if HogFlow.objects.filter(team_id=team.id).exclude(status=HogFlow.State.ARCHIVED).exists():+ return 0+ if not is_data_suggestions_enabled(user, str(team.organization_id)):+ return 0+ result = get_data_suggestions(team=team)+ return len(result.suggestions) if result.status == "ready" else 0++def start_data_suggestions(*, team: Team, refresh: bool, enqueue: Callable[[str], None]) -> DataSuggestionsResult:"""Returns the cached cards, or starts a background run through `enqueue` and reports that it is generating."""unavailable = _unavailable_reason(team)diff --git a/products/workflows/backend/services/owned_workflow_health.py b/products/workflows/backend/services/owned_workflow_health.pynew file mode 100644index 000000000000..b2dc39e8e51a--- /dev/null+++ b/products/workflows/backend/services/owned_workflow_health.py@@ -0,0 +1,51 @@+from datetime import timedelta++from django.db.models import Count+from django.utils import timezone++from posthog.models import Team, User++from products.workflows.backend.facade.contracts import OwnedWorkflowHealth+from products.workflows.backend.models.hog_flow.hog_flow import HogFlow+from products.workflows.backend.models.workflow_proposal import WorkflowProposal++HEALTH_WINDOW = timedelta(days=7)+++def list_owned_workflow_health(*, team: Team, user: User, limit: int) -> list[OwnedWorkflowHealth]:+ """The person's newest live workflows, built in workflows itself, with runs and pending suggestions."""+ flows = list(+ HogFlow.objects.filter(+ team_id=team.id, created_by_id=user.id, status=HogFlow.State.ACTIVE, origin_product__isnull=True+ )+ .order_by("-updated_at")+ .values("id", "name", "email_sending_paused_at")[:limit]+ )+ if not flows:+ return []+ flow_ids = [flow["id"] for flow in flows]+ pending = dict(+ WorkflowProposal.objects.for_team(team.id)+ .filter(hog_flow_id__in=flow_ids, status__in=WorkflowProposal.OPEN_STATUSES)+ .order_by()+ .values("hog_flow_id")+ .annotate(count=Count("id"))+ .values_list("hog_flow_id", "count")+ )+ # The workflows facade loads during django.setup(), and app_metrics2 pulls in posthog.schema.+ from posthog.api import app_metrics2 # noqa: PLC0415 — keeps the heavy dep off the import path++ runs = app_metrics2.fetch_app_metric_totals_by_source(+ team_id=team.id, app_source="hog_flow", after=timezone.now() - HEALTH_WINDOW+ )+ return [+ OwnedWorkflowHealth(+ workflow_id=flow["id"],+ name=flow["name"] or "",+ succeeded=runs.get(str(flow["id"]), {}).get("succeeded", 0),+ failed=runs.get(str(flow["id"]), {}).get("failed", 0),+ email_sending_paused=flow["email_sending_paused_at"] is not None,+ pending_suggestions=pending.get(flow["id"], 0),+ )+ for flow in flows+ ]diff --git a/products/workflows/backend/test/test_owned_workflow_health.py b/products/workflows/backend/test/test_owned_workflow_health.pynew file mode 100644index 000000000000..a476773d99f7--- /dev/null+++ b/products/workflows/backend/test/test_owned_workflow_health.py@@ -0,0 +1,108 @@+from datetime import timedelta++from posthog.test.base import BaseTest, ClickhouseTestMixin+from unittest.mock import patch++from django.utils import timezone++from parameterized import parameterized++from posthog.test.fixtures import create_app_metric2++from products.workflows.backend.facade.api import list_owned_workflow_health+from products.workflows.backend.facade.contracts import (+ DataSuggestion,+ DataSuggestionsResult,+ DataSuggestionsStatus,+ OwnedWorkflowHealth,+)+from products.workflows.backend.facade.data_suggestions import count_waiting_data_suggestions+from products.workflows.backend.models.hog_flow.hog_flow import HogFlow+from products.workflows.backend.models.workflow_proposal import WorkflowProposal++SERVICE = "products.workflows.backend.services.data_suggestions.service"+++class TestOwnedWorkflowHealth(ClickhouseTestMixin, BaseTest):+ def _flow(self, name: str, **fields: object) -> HogFlow:+ return HogFlow.objects.create(+ **{"team": self.team, "name": name, "status": HogFlow.State.ACTIVE, "created_by": self.user, **fields}+ )++ def _runs(self, flow: HogFlow, metric_name: str, count: int, days_ago: int = 1) -> None:+ create_app_metric2(+ team_id=self.team.pk,+ app_source="hog_flow",+ app_source_id=str(flow.id),+ metric_kind="success" if metric_name == "succeeded" else "failure",+ metric_name=metric_name,+ count=count,+ timestamp=timezone.now() - timedelta(days=days_ago),+ )++ def _proposal(self, flow: HogFlow, status: str) -> None:+ WorkflowProposal.objects.for_team(self.team.pk).create(+ team=self.team,+ hog_flow=flow,+ title="Shorten the subject",+ rationale="Opens are low.",+ content={"exit_condition": "exit_only_at_end"},+ base_version=1,+ status=status,+ )++ def test_lists_your_live_workflows_with_last_weeks_runs_and_pending_suggestions(self) -> None:+ live = self._flow("Onboarding drip", email_sending_paused_at=timezone.now())+ self._flow("Draft", status=HogFlow.State.DRAFT)+ self._flow("Archived", status=HogFlow.State.ARCHIVED)+ self._flow("Loop", origin_product="loops")+ self._flow("Not yours", created_by=self._create_user("[email protected]"))+ self._runs(live, "succeeded", 30)+ self._runs(live, "failed", 12)+ self._runs(live, "failed", 50, days_ago=10)+ self._proposal(live, WorkflowProposal.Status.SUGGESTED)+ self._proposal(live, WorkflowProposal.Status.SUGGESTED)+ self._proposal(live, WorkflowProposal.Status.REJECTED)++ assert list_owned_workflow_health(team=self.team, user=self.user, limit=20) == [+ OwnedWorkflowHealth(+ workflow_id=live.id,+ name="Onboarding drip",+ succeeded=30,+ failed=12,+ email_sending_paused=True,+ pending_suggestions=2,+ )+ ]++ @parameterized.expand(+ [+ ("ideas wait on the empty page", None, True, "ready", 3),+ ("a workflow replaces the empty page", HogFlow.State.DRAFT, True, "ready", 0),+ ("only archived workflows keep the empty page", HogFlow.State.ARCHIVED, True, "ready", 3),+ ("flag off", None, False, "ready", 0),+ ("still generating", None, True, "generating", 0),+ ]+ )+ def test_counts_ideas_only_where_the_empty_page_shows_them(+ self, _name: str, existing: str | None, flag_on: bool, status: DataSuggestionsStatus, expected: int+ ) -> None:+ if existing:+ self._flow("Existing", status=existing)+ idea = DataSuggestion(+ id="idea",+ name="Welcome new users",+ description="",+ reason="",+ trigger_event="signed_up",+ weekly_count=10,+ stage="signup",+ step_outline=("email",),+ )+ suggestions = DataSuggestionsResult(status=status, suggestions=(idea,) * 3 if status == "ready" else ())++ with (+ patch("posthoganalytics.feature_enabled", return_value=flag_on),+ patch(f"{SERVICE}.get_data_suggestions", return_value=suggestions),+ ):+ assert count_waiting_data_suggestions(team=self.team, user=self.user) == expecteddiff --git a/tach.toml b/tach.tomlindex 06b3f11339ed..7b3debba4b04 100644--- a/tach.toml+++ b/tach.toml@@ -1655,6 +1655,7 @@ depends_on = ["products.signals","products.tasks","products.web_analytics",+ "products.workflows",]layer = "modules"