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(workflows): offer cohort filters in conditional branch conditions (#83801)

Meikel Ratzd4c07ba915b9
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index b1983f2d35cd..c4a02909d879 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -639,6 +639,7 @@ export const FEATURE_FLAGS = {
WORKFLOW_RUN_SCOUT_ACTION: 'workflow-run-scout-action', // owner: #team-workflows
WORKFLOWS_AI_FIRST_NEW: 'workflows-ai-first-new', // owner: @mayteio #team-workflows
WORKFLOWS_BROADCAST_RECIPIENT_LISTS: 'workflows-broadcast-recipient-lists', // owner: @mayteio #team-workflows
+ WORKFLOWS_COHORT_CONDITIONS: 'workflows-cohort-conditions', // owner: @meikelmosby #team-workflows
WORKFLOWS_DELAY_UNTIL_DATE: 'workflows-delay-until-date', // owner: @dmarchuk #team-workflows
WORKFLOWS_EMAIL_MEDIA_LIBRARY: 'workflows-email-media-library', // owner: @mayteio #team-workflows, backs the email editor's Uploads tab with the media library
WORKFLOWS_EMAIL_SENDER_ROTATION: 'workflows-email-sender-rotation', // owner: @arthurdedeus #team-workflows
diff --git a/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx b/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx
index 6b82b3757fa9..020b1fe6296a 100644
--- a/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx
@@ -50,6 +50,7 @@ export type HogFlowFiltersProps = {
// has no such key, so a group-based wait could never be woken and would only ever time out.
// Used by wait conditions to keep them constrained to matcher-observable signals.
excludeGroupProperties?: boolean
+ includeCohorts?: boolean
// When filtering rows of a data warehouse table, pass the selected table's columns so they appear
// as suggestions and resolve their distinct values.
schemaColumns?: DatabaseSchemaField[]
@@ -135,6 +136,7 @@ export function HogFlowPropertyFilters({
filters,
setFilters,
excludeGroupProperties,
+ includeCohorts,
schemaColumns,
dataWarehouseTableName,
taxonomicGroupTypes,
@@ -153,6 +155,7 @@ export function HogFlowPropertyFilters({
const sampleGlobals = useSampleGlobals()
const { groupsTaxonomicTypes } = useValues(groupsModel)
const { workflow } = useValues(workflowLogic)
+ const cohortConditionsEnabled = useFeatureFlag('WORKFLOWS_COHORT_CONDITIONS')
// Surface workflow variables in the All/Suggestions tab so a user searching by variable key
// sees a match alongside event/person properties. The dedicated tab still works without this.
const taxonomicFilterOptionsFromProp = {
@@ -187,6 +190,7 @@ export function HogFlowPropertyFilters({
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
TaxonomicFilterGroupType.PersonProperties,
+ ...(includeCohorts && cohortConditionsEnabled ? [TaxonomicFilterGroupType.Cohorts] : []),
...(excludeGroupProperties ? [] : groupsTaxonomicTypes),
TaxonomicFilterGroupType.HogQLExpression,
TaxonomicFilterGroupType.EventMetadata,
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepConditionalBranch.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepConditionalBranch.tsx
index 75a21911fcda..e3182e6f1bf7 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/StepConditionalBranch.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepConditionalBranch.tsx
@@ -161,6 +161,7 @@ export function StepConditionalBranchConfiguration({
>
<HogFlowPropertyFilters
filtersKey={`condition-branch-condition-${action.id}-${index}`}
+ includeCohorts
filters={condition.filters ?? {}}
setFilters={(filters) =>
setConditions(