: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): lead entry point copy with email and track the funnel by source (#114670)
Daniel Marchuk1fe0895a2469
diff --git a/frontend/src/scenes/cohorts/CohortEdit.test.tsx b/frontend/src/scenes/cohorts/CohortEdit.test.tsxindex 111d2419c2de..7403914d75e2 100644--- a/frontend/src/scenes/cohorts/CohortEdit.test.tsx+++ b/frontend/src/scenes/cohorts/CohortEdit.test.tsx@@ -570,7 +570,7 @@ describe('cohortEditLogic', () => {// The panel fills in behind a one second timer, so the default one second find budget// has almost no margin. Waiting on a sibling action also separates a panel that never// rendered from one that rendered without this entry.- await screen.findByText('Message this cohort', {}, { timeout: 5000 })+ await screen.findByText('Build a custom workflow', {}, { timeout: 5000 })// An unloaded cohort has a falsy is_static, which satisfies the gate this test exists// to catch, so pin that the fixture reached the scene before asserting on it.diff --git a/frontend/src/scenes/cohorts/CohortEdit.tsx b/frontend/src/scenes/cohorts/CohortEdit.tsxindex 136892f263b6..a8600d9293a4 100644--- a/frontend/src/scenes/cohorts/CohortEdit.tsx+++ b/frontend/src/scenes/cohorts/CohortEdit.tsx@@ -291,18 +291,6 @@ export function CohortEdit({ id, attachTo }: CohortEditProps): JSX.Element {<ScenePanelDivider /><ScenePanelActionsSection>- <ButtonPrimitive- onClick={() => router.actions.push(urlForCohortWorkflow(cohort))}- disabledReasons={{- 'Save the cohort first': isNewCohort,- }}- data-attr={`${RESOURCE_TYPE}-message-with-workflow`}- tooltip="Start a workflow that emails everyone in this cohort"- menuItem- >- <IconSend /> Message this cohort- </ButtonPrimitive>-<ButtonPrimitiveonClick={() => {if (typeof cohort.id !== 'number') {@@ -316,7 +304,22 @@ export function CohortEdit({ id, attachTo }: CohortEditProps): JSX.Element {tooltip="Send a one-time email to everyone in this cohort"menuItem>- <IconLetter /> Send a broadcast+ <IconLetter /> Email this cohort+ </ButtonPrimitive>++ <ButtonPrimitive+ onClick={() => {+ captureMessageAudienceClicked('cohort', 'workflow')+ router.actions.push(urlForCohortWorkflow(cohort))+ }}+ disabledReasons={{+ 'Save the cohort first': isNewCohort,+ }}+ data-attr={`${RESOURCE_TYPE}-message-with-workflow`}+ tooltip="Open a workflow for this cohort to add delays, branches, or more steps"+ menuItem+ >+ <IconSend /> Build a custom workflow</ButtonPrimitive><SceneAddToNotebookDropdownMenudiff --git a/frontend/src/scenes/cohorts/CohortSceneMenuBar.tsx b/frontend/src/scenes/cohorts/CohortSceneMenuBar.tsxindex 6d6d0df959e8..0344deb18ab6 100644--- a/frontend/src/scenes/cohorts/CohortSceneMenuBar.tsx+++ b/frontend/src/scenes/cohorts/CohortSceneMenuBar.tsx@@ -57,13 +57,6 @@ function CohortSceneMenuBarInner({ id }: { id?: CohortType['id'] }): JSX.Element{!isNewCohort && cohortIdNumber !== undefined && (<><SceneMenuBarSubMenu label="Create">- <SceneMenuBarItem- onClick={() => router.actions.push(urlForCohortWorkflow(cohort))}- data-attr={`${RESOURCE_TYPE}-menubar-message-with-workflow`}- >- <IconSend />- Message this cohort- </SceneMenuBarItem><SceneMenuBarItemonClick={() => {captureMessageAudienceClicked('cohort', 'broadcast')@@ -76,7 +69,17 @@ function CohortSceneMenuBarInner({ id }: { id?: CohortType['id'] }): JSX.Elementdata-attr={`${RESOURCE_TYPE}-menubar-send-broadcast`}><IconLetter />- Send a broadcast+ Email this cohort+ </SceneMenuBarItem>+ <SceneMenuBarItem+ onClick={() => {+ captureMessageAudienceClicked('cohort', 'workflow')+ router.actions.push(urlForCohortWorkflow(cohort))+ }}+ data-attr={`${RESOURCE_TYPE}-menubar-message-with-workflow`}+ >+ <IconSend />+ Build a custom workflow</SceneMenuBarItem><SceneMenuBarAddToNotebookdataAttrKey={RESOURCE_TYPE}diff --git a/frontend/src/scenes/cohorts/cohortSavedToast.ts b/frontend/src/scenes/cohorts/cohortSavedToast.tsindex 0a3afcf5ed5b..06fba288c4f6 100644--- a/frontend/src/scenes/cohorts/cohortSavedToast.ts+++ b/frontend/src/scenes/cohorts/cohortSavedToast.ts@@ -21,7 +21,7 @@ export function cohortSavedToast(cohort: Pick<CohortType, 'id' | 'name'>, sourceaction: () => router.actions.push(urls.cohort(savedCohort.id)),},secondaryButton: {- label: 'Send a broadcast',+ label: 'Email this cohort',dataAttr: `message-audience-${source}-broadcast`,action: () => {captureMessageAudienceClicked(source, 'broadcast')diff --git a/frontend/src/scenes/cohorts/cohortUtils.tsx b/frontend/src/scenes/cohorts/cohortUtils.tsxindex d447e1cfdfe6..ba5a920116d7 100644--- a/frontend/src/scenes/cohorts/cohortUtils.tsx+++ b/frontend/src/scenes/cohorts/cohortUtils.tsx@@ -689,20 +689,13 @@ export function createCohortDataNodeLogicKey(cohortId: number | 'new'): string {}export function urlForCohortWorkflow(cohort: CohortType): string {- return urlForNewWorkflowWithTrigger({- type: 'batch',- filters: {- properties: [- {- key: 'id',- type: PropertyFilterType.Cohort,- value: cohort.id as number,- operator: PropertyOperator.In,- cohort_name: cohort.name,- },- ],+ return urlForNewWorkflowWithTrigger(+ {+ type: 'batch',+ filters: { properties: cohortAudienceProperties({ id: cohort.id as number, name: cohort.name }) },},- })+ 'cohort'+ )}export const COHORT_MATCHING_DAYS = {diff --git a/frontend/src/scenes/surveys/components/SurveyFollowUpWorkflowButton.tsx b/frontend/src/scenes/surveys/components/SurveyFollowUpWorkflowButton.tsxindex 2a47a2bee454..27825094f979 100644--- a/frontend/src/scenes/surveys/components/SurveyFollowUpWorkflowButton.tsx+++ b/frontend/src/scenes/surveys/components/SurveyFollowUpWorkflowButton.tsx@@ -31,15 +31,15 @@ export function SurveyFollowUpWorkflowButton({ surveyId }: { surveyId: string })return (<ButtonPrimitivemenuItem- tooltip="Open a new workflow that runs each time someone submits a response to this survey"+ tooltip="Open a workflow that emails each person who responds to this survey"onClick={() => {captureMessageAudienceClicked(SOURCE, 'workflow')- router.actions.push(urlForNewWorkflowWithTrigger(surveyFollowUpTrigger(surveyId)))+ router.actions.push(urlForNewWorkflowWithTrigger(surveyFollowUpTrigger(surveyId), SOURCE))}}data-attr="survey-start-follow-up-workflow"><IconSend />- Start a follow-up workflow+ Email everyone who responds</ButtonPrimitive>)}diff --git a/products/early_access_features/frontend/EarlyAccessFeature.tsx b/products/early_access_features/frontend/EarlyAccessFeature.tsxindex 8cd11692c210..efe58415c62e 100644--- a/products/early_access_features/frontend/EarlyAccessFeature.tsx+++ b/products/early_access_features/frontend/EarlyAccessFeature.tsx@@ -818,7 +818,7 @@ export function EarlyAccessFeature({ id }: EarlyAccessFeatureLogicProps): JSX.El<><MessageAudienceButtonaudience={enrolledPeopleAudience(earlyAccessFeature)}- label="Message opted-in users"+ label="Email opted-in users"size="medium"/><LemonButtondiff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastButton.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastButton.tsxindex 49e543229d35..13e2b7877af4 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastButton.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastButton.tsx@@ -13,7 +13,7 @@ export function IssueAffectedBroadcastButton(props: IssueAffectedBroadcastLogicP<><ButtonPrimitive fullWidth onClick={openModal} data-attr="issue-panel-email-affected"><IconSend />- Email the people affected+ Email people affected</ButtonPrimitive><IssueAffectedBroadcastModal {...props} /></>diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastModal.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastModal.tsxindex bc74a533dd6e..a582a5e0910d 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastModal.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueAffectedBroadcastModal.tsx@@ -31,7 +31,7 @@ export function IssueAffectedBroadcastModal(props: IssueAffectedBroadcastLogicPr<LemonModalisOpen={isModalOpen}onClose={closeModal}- title="Email the people affected"+ title="Email people affected"width={480}footer={<>diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueWorkflowButton.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueWorkflowButton.tsxindex 6d4528dcf13f..b3db0b336ee7 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueWorkflowButton.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/IssueWorkflowButton.tsx@@ -27,15 +27,15 @@ export function IssueWorkflowButton({ issueId }: { issueId: string }): JSX.Elemereturn (<ButtonPrimitivefullWidth- tooltip="Open a new workflow that runs each time someone hits this issue"+ tooltip="Open a workflow that emails people each time they hit this issue"onClick={() => {captureMessageAudienceClicked(SOURCE, 'workflow')- router.actions.push(urlForNewWorkflowWithTrigger(issueWorkflowTrigger(issueId)))+ router.actions.push(urlForNewWorkflowWithTrigger(issueWorkflowTrigger(issueId), SOURCE))}}data-attr="issue-panel-start-workflow"><IconSend />- Start a workflow on this issue+ Email anyone who hits this</ButtonPrimitive>)}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.tsindex cc23c5d7b80d..ea3fef99b649 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ScenePanel/issueAffectedBroadcastLogic.ts@@ -181,6 +181,7 @@ export const issueAffectedBroadcastLogic = kea<issueAffectedBroadcastLogicType>(return}actions.closeModal()+ captureMessageAudienceClicked(SOURCE, 'broadcast', { succeeded: true })router.actions.push(messageAudienceUrl({@@ -191,9 +192,9 @@ export const issueAffectedBroadcastLogic = kea<issueAffectedBroadcastLogicType>('broadcast'))- captureMessageAudienceClicked(SOURCE, 'broadcast')},createAudienceFailure: () => {+ captureMessageAudienceClicked(SOURCE, 'broadcast', { succeeded: false })lemonToast.error("Couldn't save the people affected. Try again.")},})),diff --git a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.tsindex 0f66c94273ac..e4af9b5650b9 100644--- a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts+++ b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts@@ -1265,7 +1265,7 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([const projectId = String(values.currentProjectId)try {await saves.run(async () => {- actions.draftAutosaved(await hogFlowsCreate(projectId, buildBroadcastPayload(values) as any))+ actions.draftAutosaved(await createDraft(projectId, values))})actions.showSavedDraftUrl()} catch (error: any) {@@ -1484,7 +1484,7 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([savedEditGeneration = cache.emailEditGenerationreturn values.broadcastId? saveWithoutClobbering(projectId, values.broadcastId, values)- : hogFlowsCreate(projectId, buildBroadcastPayload(values) as any)+ : createDraft(projectId, values)})actions.saveBroadcastFinished(saved)// This save carried the email edits made before it started. A later one keeps its own autosave.@@ -1540,9 +1540,7 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([try {// Save the latest edits (creating the draft if the user skipped ahead).const saved = await saves.run(() =>- broadcastId- ? saveWithoutClobbering(projectId, broadcastId, values)- : hogFlowsCreate(projectId, buildBroadcastPayload(values) as any)+ broadcastId ? saveWithoutClobbering(projectId, broadcastId, values) : createDraft(projectId, values))broadcastId = saved.idactions.saveBroadcastFinished(saved)@@ -1833,6 +1831,13 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([}),])+async function createDraft(projectId: string, values: broadcastWizardLogicType['values']): Promise<HogFlowApi> {+ const created = await hogFlowsCreate(projectId, buildBroadcastPayload(values) as any)+ // pinned: analytics event name+ posthog.capture('broadcast draft created', { broadcast_id: created.id, entry_source: values.entrySource })+ return created+}+async function loadAudienceCohortLaunchErrors(projectId: string,audienceProperties: AnyPropertyFilter[]diff --git a/products/workflows/frontend/MessageAudience/MessageAudienceButton.tsx b/products/workflows/frontend/MessageAudience/MessageAudienceButton.tsxindex 610ec4ca1744..119e73a8c995 100644--- a/products/workflows/frontend/MessageAudience/MessageAudienceButton.tsx+++ b/products/workflows/frontend/MessageAudience/MessageAudienceButton.tsx@@ -11,8 +11,8 @@ import {} from './messageAudience'const DESTINATION_LABELS: Record<MessageAudienceDestination, string> = {- broadcast: 'Send a broadcast',- workflow: 'Start a workflow',+ broadcast: 'Send a one-time email',+ workflow: 'Build a custom workflow',}export interface MessageAudienceButtonProps extends Pick<@@ -27,7 +27,7 @@ export interface MessageAudienceButtonProps extends Pick<export function MessageAudienceButton({audience,destinations = ['broadcast', 'workflow'],- label = 'Message these people',+ label = 'Email these people',type = 'secondary',size = 'small',disabledReason,diff --git a/products/workflows/frontend/MessageAudience/messageAudience.ts b/products/workflows/frontend/MessageAudience/messageAudience.tsindex afea67f00b14..a882b9e18d86 100644--- a/products/workflows/frontend/MessageAudience/messageAudience.ts+++ b/products/workflows/frontend/MessageAudience/messageAudience.ts@@ -36,11 +36,16 @@ export function messageAudienceUrl(audience: MessageAudience, destination: Messa})}return urlForNewWorkflowWithTrigger(- audience.workflowTrigger ?? { type: 'batch', filters: { properties: audience.properties } }+ audience.workflowTrigger ?? { type: 'batch', filters: { properties: audience.properties } },+ audience.source)}-export function captureMessageAudienceClicked(source: string, destination: MessageAudienceDestination): void {+export function captureMessageAudienceClicked(+ source: string,+ destination: MessageAudienceDestination,+ extra: { succeeded?: boolean } = {}+): void {// pinned: analytics event name- posthog.capture('message audience clicked', { source, destination })+ posthog.capture('message audience clicked', { source, destination, ...extra })}diff --git a/products/workflows/frontend/Workflows/WorkflowScene.tsx b/products/workflows/frontend/Workflows/WorkflowScene.tsxindex fae9f4f79d91..f0b82a15576d 100644--- a/products/workflows/frontend/Workflows/WorkflowScene.tsx+++ b/products/workflows/frontend/Workflows/WorkflowScene.tsx@@ -22,6 +22,7 @@ import { SceneContent } from '~/layout/scenes/components/SceneContent'import { ProductKey } from '~/queries/schema/schema-general'import { ActivityScope } from '~/types'+import { SOURCE_PREFILL_PARAM } from '../Broadcasts/broadcastAudiencePrefill'import { batchWorkflowJobsLogic } from './batchWorkflowJobsLogic'import { NewWorkflowAgent } from './NewWorkflowAgent'import { newWorkflowLogic } from './newWorkflowLogic'@@ -72,11 +73,13 @@ export function WorkflowScene(props: WorkflowSceneLogicProps): JSX.Element {rawTriggerPrefill && typeof rawTriggerPrefill !== 'string'? JSON.stringify(rawTriggerPrefill): rawTriggerPrefill+ const entrySource = searchParams[SOURCE_PREFILL_PARAM]const workflowProps: WorkflowLogicProps = {id: workflowSceneProps.id,templateId,editTemplateId,triggerPrefill,+ entrySource: typeof entrySource === 'string' ? entrySource : undefined,}const batchJobsLogic = batchWorkflowJobsLogic({ id: workflowSceneProps.id })diff --git a/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts b/products/workflows/frontend/Workflows/workflowLogic.autosave.test.tsindex 7603d2d2d024..8380fefd6899 100644--- a/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.autosave.test.ts@@ -1,10 +1,12 @@import { expectLogic } from 'kea-test-utils'+import posthog from 'posthog-js'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import { resourceEditedLogic } from 'products/notifications/frontend/resourceEditedLogic'+import { saveEntrySource } from '../Broadcasts/broadcastUsage'import { HogFlow } from './hogflows/types'import { workflowLogic } from './workflowLogic'@@ -379,6 +381,28 @@ describe('workflowLogic auto-save', () => {expect(logic.values.hasStagedDraft).toBe(false)})+ it('reports enabling a workflow once, with the product surface it was opened from', async () => {+ const captureSpy = jest.spyOn(posthog, 'capture')+ saveEntrySource(WORKFLOW_ID, 'survey')+ useMocks(activeMocks({ ...activeWorkflow, status: 'draft' }))+ initKeaTests()+ logic = workflowLogic({ id: WORKFLOW_ID })+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadWorkflowSuccess'])++ await expectLogic(logic, () => {+ logic.actions.saveWorkflowPartial({ status: 'active' })+ }).toDispatchActions(['saveWorkflowSuccess'])+ await expectLogic(logic, () => {+ logic.actions.setWorkflowValue('name', 'Renamed while live')+ logic.actions.saveWorkflowPartial({ name: 'Renamed while live' })+ }).toDispatchActions(['saveWorkflowSuccess'])++ const enabledCalls = captureSpy.mock.calls.filter(([event]) => event === 'workflow enabled')+ expect(enabledCalls).toEqual([['workflow enabled', { workflow_id: WORKFLOW_ID, entry_source: 'survey' }]])+ captureSpy.mockRestore()+ })+it('a status transition sends lifecycle and metadata only, never stage_draft', async () => {useMocks(activeMocks({diff --git a/products/workflows/frontend/Workflows/workflowLogic.ts b/products/workflows/frontend/Workflows/workflowLogic.tsindex b510ab90be76..a51abf641a0c 100644--- a/products/workflows/frontend/Workflows/workflowLogic.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.ts@@ -28,6 +28,7 @@ import { resourceEditedLogic } from 'products/notifications/frontend/resourceEdiimport { hogFlowsResumeEmailSending } from 'products/workflows/frontend/generated/api'import type { ResourceEditedEvent, UserBasicType, UserType } from '../../../../frontend/src/types'+import { loadEntrySource, saveEntrySource } from '../Broadcasts/broadcastUsage'import { getRegisteredTriggerTypes } from './hogflows/registry/triggers/triggerTypeRegistry'import {DEFAULT_STATE,@@ -62,6 +63,7 @@ export interface WorkflowLogicProps {templateId?: stringeditTemplateId?: stringtriggerPrefill?: string+ entrySource?: string}export const TRIGGER_NODE_ID = 'trigger_node'@@ -3213,6 +3215,14 @@ export const workflowLogic = kea<workflowLogicType>([template_id: props.templateId,})}+ if (props.entrySource) {+ saveEntrySource(result.id, props.entrySource)+ }+ // pinned: analytics event name+ posthog.capture('workflow draft created', {+ workflow_id: result.id,+ entry_source: props.entrySource ?? null,+ })return result}@@ -4100,6 +4110,7 @@ export const workflowLogic = kea<workflowLogicType>([// This is the one path that means to change the lifecycle. The loader reads the flag// as it handles the action below, so it describes this save and no other.cache.nextSaveChangesStatus = 'status' in workflow+ cache.enablingWorkflow = workflow.status === 'active' && values.originalWorkflow?.status !== 'active'actions.saveWorkflow(merged)},loadWorkflowSuccess: async ({ originalWorkflow }) => {@@ -4128,6 +4139,7 @@ export const workflowLogic = kea<workflowLogicType>([saveWorkflowFailure: () => {// Keep the queue aligned with the saves still in flight.;(cache.saveContexts as SaveContext[] | undefined)?.shift()+ cache.enablingWorkflow = falseactions.replayDeferredResourceEdited()},replayDeferredResourceEdited: () => {@@ -4143,6 +4155,15 @@ export const workflowLogic = kea<workflowLogicType>([const saveContext = (cache.saveContexts as SaveContext[] | undefined)?.shift()const isAutoSave = saveContext?.initiatedByAutoSave ?? values.isAutoSave+ if (cache.enablingWorkflow && originalWorkflow.status === 'active') {+ cache.enablingWorkflow = false+ // pinned: analytics event name+ posthog.capture('workflow enabled', {+ workflow_id: originalWorkflow.id,+ entry_source: loadEntrySource(originalWorkflow.id),+ })+ }+if (!isAutoSave) {// Save pending schedule changes (only on manual save)const workflowId = originalWorkflow.iddiff --git a/products/workflows/frontend/Workflows/workflowTriggerPrefill.test.ts b/products/workflows/frontend/Workflows/workflowTriggerPrefill.test.tsindex 4102e287b033..88105fb6d1e8 100644--- a/products/workflows/frontend/Workflows/workflowTriggerPrefill.test.ts+++ b/products/workflows/frontend/Workflows/workflowTriggerPrefill.test.ts@@ -1,3 +1,4 @@+import { SOURCE_PREFILL_PARAM } from '../Broadcasts/broadcastAudiencePrefill'import {TRIGGER_PREFILL_PARAM,type WorkflowTriggerConfig,@@ -12,11 +13,13 @@ describe('workflowTriggerPrefill', () => {filters: { properties: [{ key: 'id', type: 'cohort', value: 7, operator: 'in' }] },}- const url = urlForNewWorkflowWithTrigger(config)- const raw = new URLSearchParams(url.split('?')[1]).get(TRIGGER_PREFILL_PARAM)+ const url = urlForNewWorkflowWithTrigger(config, 'cohort')+ const params = new URLSearchParams(url.split('?')[1])+ const raw = params.get(TRIGGER_PREFILL_PARAM)expect(parseWorkflowTriggerPrefill(raw ?? undefined)).toEqual(config)expect(parseWorkflowTriggerPrefill(JSON.parse(raw ?? ''))).toEqual(config)+ expect(params.get(SOURCE_PREFILL_PARAM)).toBe('cohort')})it.each([diff --git a/products/workflows/frontend/Workflows/workflowTriggerPrefill.ts b/products/workflows/frontend/Workflows/workflowTriggerPrefill.tsindex 96d756c3d742..07a8a0fd1897 100644--- a/products/workflows/frontend/Workflows/workflowTriggerPrefill.ts+++ b/products/workflows/frontend/Workflows/workflowTriggerPrefill.ts@@ -2,7 +2,7 @@ import { combineUrl } from 'kea-router'import { urls } from 'scenes/urls'-import { parseBroadcastAudiencePrefill } from '../Broadcasts/broadcastAudiencePrefill'+import { SOURCE_PREFILL_PARAM, parseBroadcastAudiencePrefill } from '../Broadcasts/broadcastAudiencePrefill'import { HogFlowTriggerSchema } from './hogflows/steps/types'import type { HogFlowAction } from './hogflows/types'@@ -10,8 +10,11 @@ export type WorkflowTriggerConfig = Extract<HogFlowAction, { type: 'trigger' }>[export const TRIGGER_PREFILL_PARAM = 'trigger'-export function urlForNewWorkflowWithTrigger(config: WorkflowTriggerConfig): string {- return combineUrl(urls.workflowNew(), { [TRIGGER_PREFILL_PARAM]: JSON.stringify(config) }).url+export function urlForNewWorkflowWithTrigger(config: WorkflowTriggerConfig, source?: string): string {+ return combineUrl(urls.workflowNew(), {+ [TRIGGER_PREFILL_PARAM]: JSON.stringify(config),+ ...(source ? { [SOURCE_PREFILL_PARAM]: source } : {}),+ }).url}// kea-router hands over JSON-looking search params already parsed, so accept an object too.