: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
chore(workflows): remove trigger volume estimate and recipient list flags (#122133)
Harley Alexander29f79dfeb627
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 4eeb0b4b72e8..3a0a63951068 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -601,7 +601,6 @@ export const FEATURE_FLAGS = {WORKFLOW_OPT_OUT_OF_MESSAGES_ACTION: 'workflow-opt-out-of-messages-action', // owner: #team-workflowsWORKFLOWS_AI_EMAIL_DRAFT: 'workflows-ai-email-draft', // owner: @dmarchuk #team-workflows, AI first draft for cross-product entry pointsWORKFLOWS_AI_FIRST_NEW: 'workflows-ai-first-new', // owner: @mayteio #team-workflows- WORKFLOWS_BROADCAST_RECIPIENT_LISTS: 'workflows-broadcast-recipient-lists', // owner: @mayteio #team-workflowsWORKFLOWS_COHORT_CONDITIONS: 'workflows-cohort-conditions', // owner: @meikelmosby #team-workflowsWORKFLOWS_EMAIL_MEDIA_LIBRARY: 'workflows-email-media-library', // owner: @mayteio #team-workflows, backs the email editor's Uploads tab with the media libraryWORKFLOWS_EMAIL_SENDER_ROTATION: 'workflows-email-sender-rotation', // owner: @arthurdedeus #team-workflows@@ -613,7 +612,6 @@ export const FEATURE_FLAGS = {WORKFLOWS_SEND_CALENDAR: 'workflows-send-calendar', // owner: @meikelmosby #team-workflows, calendar of scheduled email sends in Broadcasts and WorkflowsWORKFLOWS_TILE_CANVAS: 'workflows-tile-canvas', // owner: #team-workflowsWORKFLOWS_TRANSACTIONAL_EMAIL_API: 'workflows-transactional-email-api', // owner: @mayteio #team-workflows- WORKFLOWS_TRIGGER_VOLUME_ESTIMATE: 'workflows-trigger-volume-estimate', // owner: @mayteio #team-workflowsXAA_AUTHENTICATION: 'xaa-authentication', // owner: @reecejones #team-platform-features} as constexport type FeatureFlagLookupKey = keyof typeof FEATURE_FLAGSdiff --git a/products/workflows/frontend/Broadcasts/audience/BroadcastAudienceListModal.tsx b/products/workflows/frontend/Broadcasts/audience/BroadcastAudienceListModal.tsxindex 8d8c9ef72afb..2e53d47af226 100644--- a/products/workflows/frontend/Broadcasts/audience/BroadcastAudienceListModal.tsx+++ b/products/workflows/frontend/Broadcasts/audience/BroadcastAudienceListModal.tsx@@ -2,7 +2,7 @@ import { useActions, useMountedLogic, useValues } from 'kea'import { LemonBanner, LemonButton, LemonInput, LemonModal } from '@posthog/lemon-ui'-import { COHORT_CSV_HELP, CohortCsvDropzone } from 'scenes/cohorts/CohortCsvDropzone'+import { CohortCsvDropzone } from 'scenes/cohorts/CohortCsvDropzone'import { broadcastWizardLogic } from '../broadcastWizardLogic'import { broadcastAudienceListLogic } from './broadcastAudienceListLogic'@@ -11,8 +11,7 @@ import { broadcastAudienceListLogic } from './broadcastAudienceListLogic'export function BroadcastAudienceListModal(): JSX.Element {const { props } = useMountedLogic(broadcastWizardLogic)const logic = broadcastAudienceListLogic(props)- const { isListModalOpen, file, cohortName, creating, createError, submitDisabledReason, importsPeople } =- useValues(logic)+ const { isListModalOpen, file, cohortName, creating, createError, submitDisabledReason } = useValues(logic)const { audienceProperties } = useValues(broadcastWizardLogic)const { closeListModal, setFile, setCohortName, createListCohort } = useActions(logic)@@ -45,18 +44,13 @@ export function BroadcastAudienceListModal(): JSX.Element {}><div className="flex flex-col gap-4" data-attr="broadcast-audience-list-modal">- {importsPeople ? (- <span className="text-sm text-secondary">- Each row creates or updates a person. The file needs an <code>email</code> column. Every other- column is saved on the person, so you can use it in the email, for example{' '}- <code>{'{{ person.properties.plan }}'}</code> for a <code>plan</code> column. Property names- match the column names exactly, including capital letters. To update people by their ID in your- app, add a <code>distinct_id</code> column, or an <code>id</code> column like a Customer.io- export has.- </span>- ) : (- <span className="text-sm text-secondary">{COHORT_CSV_HELP}</span>- )}+ <span className="text-sm text-secondary">+ Each row creates or updates a person. The file needs an <code>email</code> column. Every other+ column is saved on the person, so you can use it in the email, for example{' '}+ <code>{'{{ person.properties.plan }}'}</code> for a <code>plan</code> column. Property names match+ the column names exactly, including capital letters. To update people by their ID in your app, add a{' '}+ <code>distinct_id</code> column, or an <code>id</code> column like a Customer.io export has.+ </span><CohortCsvDropzone value={file} onChange={setFile} /><LemonInputvalue={cohortName}@@ -67,9 +61,9 @@ export function BroadcastAudienceListModal(): JSX.Element {prefix={<span className="text-secondary">Cohort name</span>}/><div className="text-xs text-secondary">- {importsPeople- ? "People who aren't in PostHog yet are created. A column with the same name as an existing property replaces its value, and a blank cell leaves it as it is. Each row is sent as one event, so it counts toward your event usage and triggers any destinations that run on all events."- : "Only people who are already in PostHog are included. Anyone else on the list won't receive the email."}+ People who aren't in PostHog yet are created. A column with the same name as an existing property+ replaces its value, and a blank cell leaves it as it is. Each row is sent as one event, so it counts+ toward your event usage and triggers any destinations that run on all events.{audienceProperties.length > 0? ' People must be on every list and match your other conditions to get the email.': null}diff --git a/products/workflows/frontend/Broadcasts/audience/audienceList.test.ts b/products/workflows/frontend/Broadcasts/audience/audienceList.test.tsindex 6c9a51ec0792..f145bb6ac408 100644--- a/products/workflows/frontend/Broadcasts/audience/audienceList.test.ts+++ b/products/workflows/frontend/Broadcasts/audience/audienceList.test.ts@@ -1,26 +1,6 @@-import { audienceCohortLaunchError, csvListError, peopleImportMessage } from './audienceList'+import { audienceCohortLaunchError, peopleImportMessage } from './audienceList'describe('audienceList', () => {- it.each([- { case: 'an empty file', text: '\n', expected: 'The file is empty.' },- {- case: 'columns without an id',- text: 'name,company\nAda,Acme\n',- expected: 'The file needs a column named email, distinct_id or person_id.',- },- { case: 'a header with no rows', text: 'email\n', expected: 'The file has a header row but no people in it.' },- { case: 'an email column among others', text: 'Name,Email\nAda,[email protected]\n', expected: null },- { case: 'a person-id column among others', text: 'person-id,name\nabc,Ada\n', expected: null },- {- case: 'an id name only inside a quoted header',- text: '"name,email",company\nAda,Acme\n',- expected: 'The file needs a column named email, distinct_id or person_id.',- },- { case: 'one column of ids without a header', text: 'user-1\nuser-2\n', expected: null },- ])('checks $case before uploading', ({ text, expected }) => {- expect(csvListError(text)).toEqual(expected)- })-it.each([{cohort: 'an uploaded list still matching',diff --git a/products/workflows/frontend/Broadcasts/audience/audienceList.ts b/products/workflows/frontend/Broadcasts/audience/audienceList.tsindex 424841880cdf..d783e831ca7b 100644--- a/products/workflows/frontend/Broadcasts/audience/audienceList.ts+++ b/products/workflows/frontend/Broadcasts/audience/audienceList.ts@@ -5,59 +5,7 @@ import type { CohortApi } from 'products/cohorts/frontend/generated/api.schemas'import type { PeopleImportApi } from '../../generated/api.schemas'import type { AudienceCohort } from './broadcastAudienceCohortsLogic'-const SUPPORTED_ID_HEADERS = ['email', 'e-mail', 'distinct_id', 'distinct-id', 'person_id', 'person-id', 'person .id']--/**- * Why the cohort import would reject this CSV, checked before anything is created, because a rejected- * import still leaves an empty cohort behind. A single column without a known header is read as distinct IDs.- */-export function csvListError(text: string): string | null {- const lines = text.split(/\r?\n/).filter((line) => line.trim() !== '')- if (lines.length === 0) {- return 'The file is empty.'- }- const headers = splitCsvRow(lines[0]).map((header) => header.trim().toLowerCase())- if (headers.length > 1 && !headers.some((header) => SUPPORTED_ID_HEADERS.includes(header))) {- return 'The file needs a column named email, distinct_id or person_id.'- }- if (headers.some((header) => SUPPORTED_ID_HEADERS.includes(header)) && lines.length === 1) {- return 'The file has a header row but no people in it.'- }- return null-}--function splitCsvRow(row: string): string[] {- const fields: string[] = []- let field = ''- let quoted = false- for (let i = 0; i < row.length; i++) {- const char = row[i]- if (quoted) {- if (char === '"' && row[i + 1] === '"') {- field += '"'- i++- } else if (char === '"') {- quoted = false- } else {- field += char- }- } else if (char === '"') {- quoted = true- } else if (char === ',') {- fields.push(field)- field = ''- } else {- field += char- }- }- fields.push(field)- return fields-}--/**- * Reads an uploaded list as UTF-8. The cohort import decodes the file strictly after it saves the cohort,- * so a file in another encoding must fail here, before the cohort exists.- */+/** Reads an uploaded list as UTF-8, so a file in another encoding fails before anything is imported. */export async function readCsvText(file: File): Promise<string> {const bytes = await file.arrayBuffer()try {diff --git a/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.test.ts b/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.test.tsindex 745460a032fe..9b5904d5169a 100644--- a/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.test.ts+++ b/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.test.ts@@ -1,8 +1,5 @@import { expectLogic } from 'kea-test-utils'-import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import { PropertyFilterType, PropertyOperator } from '~/types'@@ -36,64 +33,6 @@ describe('broadcastAudienceListLogic', () => {broadcastWizardLogic({ id: 'new' }).mount()})- it('saves an uploaded list as a cohort and adds it to the audience', async () => {- const logic = broadcastAudienceListLogic({ id: 'new' })- logic.mount()- logic.actions.openListModal()- logic.actions.setFile(- new File(['email\[email protected]\[email protected]\n'], 'people.csv', { type: 'text/csv' })- )-- await expectLogic(logic, () => {- logic.actions.createListCohort()- })- .toDispatchActions(['closeListModal', 'createListCohortFinished'])- .toMatchValues({ isListModalOpen: false, createError: null })-- expect(createdCohorts).toEqual(1)- expect(broadcastWizardLogic({ id: 'new' }).values.audienceProperties).toEqual([- {- type: PropertyFilterType.Cohort,- key: 'id',- value: 42,- operator: PropertyOperator.In,- cohort_name: 'Spring sale recipients',- },- ])- })-- it.each([- {- file: 'a CSV the import would reject',- content: 'name,company\nAda,Acme\n',- error: 'The file needs a column named email, distinct_id or person_id.',- },- {- // "Zoë" in Windows-1252, which the cohort import can't decode after it saves the cohort.- file: 'a CSV that is not UTF-8',- content: new Uint8Array([- ...new TextEncoder().encode('email\nzo'),- 0xeb,- ...new TextEncoder().encode('@example.com\n'),- ]),- error: 'This file isn\'t saved as UTF-8. Save it as "CSV UTF-8" and upload it again.',- },- ])('creates no cohort for $file', async ({ content, error }) => {- const logic = broadcastAudienceListLogic({ id: 'new' })- logic.mount()- logic.actions.openListModal()- logic.actions.setFile(new File([content], 'people.csv', { type: 'text/csv' }))-- await expectLogic(logic, () => {- logic.actions.createListCohort()- })- .toDispatchActions(['createListCohortFinished'])- .toMatchValues({ isListModalOpen: true, createError: error })-- expect(createdCohorts).toEqual(0)- expect(broadcastWizardLogic({ id: 'new' }).values.audienceProperties).toEqual([])- })-const SPRING_SALE_COHORT = {type: PropertyFilterType.Cohort,key: 'id',@@ -199,37 +138,31 @@ describe('broadcastAudienceListLogic', () => {audience: [],importedRows: undefined,},- ])(- 'with the people import flag on, an upload $outcome',- async ({ csv, response, cohortReadFails, expected, audience, importedRows }) => {- let sentRows: unknown- useMocks({- ...(cohortReadFails ? { get: { '/api/projects/:team/cohorts/:id/': () => [500, {}] } } : {}),- post: {- '/api/projects/:team_id/workflow_people_imports/': async ({ request }) => {- sentRows = ((await request.json()) as { rows: unknown }).rows- return response as [number, object]- },+ ])('an upload $outcome', async ({ csv, response, cohortReadFails, expected, audience, importedRows }) => {+ let sentRows: unknown+ useMocks({+ ...(cohortReadFails ? { get: { '/api/projects/:team/cohorts/:id/': () => [500, {}] } } : {}),+ post: {+ '/api/projects/:team_id/workflow_people_imports/': async ({ request }) => {+ sentRows = ((await request.json()) as { rows: unknown }).rows+ return response as [number, object]},- })- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.WORKFLOWS_BROADCAST_RECIPIENT_LISTS], {- [FEATURE_FLAGS.WORKFLOWS_BROADCAST_RECIPIENT_LISTS]: true,- })- const logic = broadcastAudienceListLogic({ id: 'new' })- logic.mount()- logic.actions.openListModal()- logic.actions.setCohortName('Spring sale recipients')- logic.actions.setFile(new File([csv], 'people.csv', { type: 'text/csv' }))+ },+ })+ const logic = broadcastAudienceListLogic({ id: 'new' })+ logic.mount()+ logic.actions.openListModal()+ logic.actions.setCohortName('Spring sale recipients')+ logic.actions.setFile(new File([csv], 'people.csv', { type: 'text/csv' }))- await expectLogic(logic, () => {- logic.actions.createListCohort()- })- .toDispatchActions(['createListCohortFinished'])- .toMatchValues(expected)+ await expectLogic(logic, () => {+ logic.actions.createListCohort()+ })+ .toDispatchActions(['createListCohortFinished'])+ .toMatchValues(expected)- expect(sentRows).toEqual(importedRows)- expect(createdCohorts).toEqual(0)- expect(broadcastWizardLogic({ id: 'new' }).values.audienceProperties).toEqual(audience)- }- )+ expect(sentRows).toEqual(importedRows)+ expect(createdCohorts).toEqual(0)+ expect(broadcastWizardLogic({ id: 'new' }).values.audienceProperties).toEqual(audience)+ })})diff --git a/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.ts b/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.tsindex 47fcb2cd0af1..44f4e69a1e97 100644--- a/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.ts+++ b/products/workflows/frontend/Broadcasts/audience/broadcastAudienceListLogic.ts@@ -2,11 +2,7 @@ import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reduimport { lemonToast } from '@posthog/lemon-ui'-import api from 'lib/api'-import { FEATURE_FLAGS } from 'lib/constants'import { dayjs } from 'lib/dayjs'-import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { createCohortFormData } from 'scenes/cohorts/cohortUtils'import { cohortsModel } from '~/models/cohortsModel'import { AnyPropertyFilter, CohortType, PropertyFilterType, PropertyOperator } from '~/types'@@ -16,7 +12,7 @@ import { cohortsRetrieve } from 'products/cohorts/frontend/generated/api'import { workflowPeopleImportsCreate } from '../../generated/api'import type { PeopleImportApi } from '../../generated/api.schemas'import { BroadcastWizardLogicProps, broadcastWizardLogic } from '../broadcastWizardLogic'-import { csvListError, defaultListCohortName, peopleImportMessage, readCsvText } from './audienceList'+import { defaultListCohortName, peopleImportMessage, readCsvText } from './audienceList'import { parsePeopleCsv } from './peopleCsv'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -24,12 +20,10 @@ export interface broadcastAudienceListLogicValues {audienceProperties: AnyPropertyFilter[] // broadcastWizardLogiccurrentProjectId: number | null // broadcastWizardLogicname: string // broadcastWizardLogic- featureFlags: FeatureFlagsSet // featureFlagLogiccohortName: stringcreateError: string | nullcreating: booleanfile: File | null- importsPeople: booleanisListModalOpen: booleansubmitDisabledReason: string | null}@@ -66,7 +60,6 @@ export interface broadcastAudienceListLogicActions {export interface broadcastAudienceListLogicMeta {key: string__keaTypeGenInternalSelectorTypes: {- importsPeople: (featureFlags: FeatureFlagsSet) => booleansubmitDisabledReason: (file: File | null, cohortName: string) => string | null}}@@ -83,12 +76,7 @@ export const broadcastAudienceListLogic = kea<broadcastAudienceListLogicType>([props({} as BroadcastWizardLogicProps),key((props) => props.id),connect((props: BroadcastWizardLogicProps) => ({- values: [- broadcastWizardLogic(props),- ['name', 'audienceProperties', 'currentProjectId'],- featureFlagLogic,- ['featureFlags'],- ],+ values: [broadcastWizardLogic(props), ['name', 'audienceProperties', 'currentProjectId']],actions: [broadcastWizardLogic(props), ['setAudienceProperties'], cohortsModel, ['cohortCreated']],})),actions({@@ -137,12 +125,6 @@ export const broadcastAudienceListLogic = kea<broadcastAudienceListLogicType>([],}),selectors({- // With the flag on, each row creates or updates a person and the columns become person properties.- importsPeople: [- (s) => [s.featureFlags],- (featureFlags: FeatureFlagsSet): boolean =>- !!featureFlags[FEATURE_FLAGS.WORKFLOWS_BROADCAST_RECIPIENT_LISTS],- ],submitDisabledReason: [(s) => [s.file, s.cohortName],(file: File | null, cohortName: string): string | null => {@@ -223,43 +205,7 @@ export const broadcastAudienceListLogic = kea<broadcastAudienceListLogicType>([actions.createListCohortFinished(values.submitDisabledReason)return}- const csv = values.file!- if (values.importsPeople) {- await importPeople(csv)- return- }- let fileError: string | null- try {- fileError = csvListError(await readCsvText(csv))- } catch (error: any) {- actions.createListCohortFinished(- error?.message ?? "Couldn't read the file. Try uploading it again."- )- return- }- if (fileError) {- actions.createListCohortFinished(fileError)- return- }- let cohort: CohortType- try {- const formData = createCohortFormData({- name: values.cohortName.trim(),- description: 'Created from a list in a broadcast audience.',- is_static: true,- csv,- } as CohortType)- // nosemgrep: prefer-codegen-api -- the CSV goes up as multipart form data, which the generated JSON client can't send.- cohort = await api.cohorts.create(formData as Partial<CohortType>)- } catch (error: any) {- const message = error?.data?.csv?.[0] ?? error?.detail ?? error?.message ?? 'unknown error'- actions.createListCohortFinished(`Couldn't create the cohort: ${message}`)- return- }- addCohortToAudience(cohort)- lemonToast.success(- `Added "${cohort.name}" to the audience. Matching the people on it can take a minute.`- )+ await importPeople(values.file!)},}}),diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsxindex 0965a9e812aa..2a4315fe03f2 100644--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.stories.tsx@@ -3,8 +3,6 @@ import { ReactFlowProvider } from '@xyflow/react'import { BindLogic, useActions, useValues } from 'kea'import { useEffect } from 'react'-import { FEATURE_FLAGS } from 'lib/constants'-import { mswDecorator } from '~/mocks/browser'import _hogFunctionTemplatesDestinations from '~/mocks/fixtures/_hogFunctionTemplatesDestinations.json'import { HogFunctionTemplateType } from '~/types'@@ -174,7 +172,6 @@ const meta: Meta<typeof HogFlowEditorPanel> = {component: HogFlowEditorPanel,parameters: {layout: 'fullscreen',- featureFlags: [FEATURE_FLAGS.WORKFLOWS_TRIGGER_VOLUME_ESTIMATE],},decorators: [mswDecorator({diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsxindex c9b1dbb47352..6e8bb2fd7935 100644--- a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx@@ -348,9 +348,7 @@ export function StepTriggerConfiguration({ node }: { node: Node<TriggerAction> }{registeredMatch?.ConfigComponent ? (<><registeredMatch.ConfigComponent node={node} />- {featureFlags[FEATURE_FLAGS.WORKFLOWS_TRIGGER_VOLUME_ESTIMATE] ? (- <TriggerVolumeEstimate action={node.data} />- ) : null}+ <TriggerVolumeEstimate action={node.data} />{registeredMatch.frequencyOptions ? (<><LemonDivider />@@ -402,7 +400,6 @@ function StepTriggerConfigurationEvents({}): JSX.Element {const { setWorkflowActionConfig } = useActions(workflowLogic)const { actionValidationErrorsById } = useValues(workflowLogic)- const { featureFlags } = useValues(featureFlagLogic)const validationResult = actionValidationErrorsById[action.id]const filterTestAccounts = config.filters?.filter_test_accounts ?? false@@ -460,9 +457,7 @@ function StepTriggerConfigurationEvents({}/>- {featureFlags[FEATURE_FLAGS.WORKFLOWS_TRIGGER_VOLUME_ESTIMATE] ? (- <TriggerVolumeEstimate action={action} />- ) : null}+ <TriggerVolumeEstimate action={action} /><LemonDivider /><FrequencySection />