: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
fix(cohorts): save the internal and test users filter from the cohort editor (#117013)
Harley Alexander7545efbdcaaf
diff --git a/frontend/src/scenes/cohorts/cohortUtils.test.tsx b/frontend/src/scenes/cohorts/cohortUtils.test.tsxindex a3a89180ba38..109c465e8bdd 100644--- a/frontend/src/scenes/cohorts/cohortUtils.test.tsx+++ b/frontend/src/scenes/cohorts/cohortUtils.test.tsx@@ -4,6 +4,7 @@ import {cleanBehavioralTypeCriteria,cleanCriteria,cohortBroadcastDisabledReason,+ createCohortFormData,criteriaToHumanSentence,determineFilterType,validateGroup,@@ -266,3 +267,34 @@ describe('cohortBroadcastDisabledReason', () => {expect(cohortBroadcastDisabledReason(input)).toEqual(expected)})})++describe('createCohortFormData', () => {+ const cohort = (overrides: Partial<CohortType> = {}): CohortType => ({+ id: 1,+ groups: [],+ filters: {+ properties: {+ type: FilterLogicalOperator.Or,+ values: [+ {+ type: FilterLogicalOperator.And,+ values: [+ { type: BehavioralFilterKey.Person, key: 'email', value: BehavioralEventType.HaveProperty },+ ],+ },+ ],+ },+ filterTestAccounts: true,+ },+ ...overrides,+ })++ it.each([+ ['a dynamic cohort', cohort(), {}, true],+ ['a static cohort built from criteria', cohort({ is_static: true }), { preserveStaticFilters: true }, true],+ ['a static cohort without criteria', cohort({ is_static: true }), {}, undefined],+ ])('serializes filterTestAccounts for %s', (_, input, options, expected) => {+ const filters = JSON.parse(createCohortFormData(input, options).get('filters') as string)+ expect(filters.filterTestAccounts).toEqual(expected)+ })+})diff --git a/frontend/src/scenes/cohorts/cohortUtils.tsx b/frontend/src/scenes/cohorts/cohortUtils.tsxindex 312bfa37e5c6..7ba7b01bd24e 100644--- a/frontend/src/scenes/cohorts/cohortUtils.tsx+++ b/frontend/src/scenes/cohorts/cohortUtils.tsx@@ -170,6 +170,7 @@ export function createCohortFormData().filters.properties,id: undefined,},+ filterTestAccounts: cohort.filters.filterTestAccounts,}),}