: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): add step-by-step onboarding wizards (#113836)
Meikel Ratz779c815c7b81
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 51b2e3161c00..cd2e40a02e71 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -641,6 +641,7 @@ export const FEATURE_FLAGS = {WORKFLOWS_ISP_SENDING_HEALTH: 'workflows-isp-sending-health', // owner: #team-workflowsWORKFLOWS_LINEAR_VIEW: 'workflows-linear-view', // owner: #team-workflowsWORKFLOWS_NEW_NAVIGATION: 'workflows-new-navigation', // owner: #team-workflows, groups the workflows tabs into Workflows, Templates and Messaging+ WORKFLOWS_ONBOARDING_WIZARD: 'workflows-onboarding-wizard', // owner: #team-workflows, step-by-step setup after the first-run path choice, needs workflows-guided-onboardingWORKFLOWS_PUSH_NOTIFICATIONS: 'workflows-push-notifications', // owner: #team-workflowsWORKFLOWS_TRIGGER_VOLUME_ESTIMATE: 'workflows-trigger-volume-estimate', // owner: @mayteio #team-workflowsXAA_AUTHENTICATION: 'xaa-authentication', // owner: @reecejones #team-platform-featuresdiff --git a/products/workflows/frontend/Workflows/WorkflowsTable.tsx b/products/workflows/frontend/Workflows/WorkflowsTable.tsxindex c2e0ce1d03f5..f4f1d2d17561 100644--- a/products/workflows/frontend/Workflows/WorkflowsTable.tsx+++ b/products/workflows/frontend/Workflows/WorkflowsTable.tsx@@ -29,6 +29,7 @@ import { urls } from 'scenes/urls'import { AccessControlLevel, AccessControlResourceType } from '~/types'+import { AutomationEmptyState } from '../setupGuide/AutomationEmptyState'import { AutomationSuggestionBanner } from '../setupGuide/AutomationSuggestionBanner'import { MessagingSetupReminderBanner } from '../setupGuide/MessagingSetupReminderBanner'import { getHogFlowStep } from './hogflows/steps/HogFlowSteps'@@ -129,6 +130,15 @@ export function WorkflowsTable(): JSX.Element {allArchivedSelected,selectedArchivedCount,} = useValues(logic)+ // Only an unfiltered Automations tab is truly empty. With a search or filter, the plain message fits.+ const showAutomationEmptyState =+ newNavigationEnabled &&+ guidedOnboardingEnabled &&+ filters.type === 'automation' &&+ !filters.search &&+ filters.createdBy === null &&+ filters.status === 'all' &&+ filters.triggerType === 'all'const {loadWorkflows,toggleWorkflowStatus,@@ -496,7 +506,7 @@ export function WorkflowsTable(): JSX.Element {defaultSorting={{ columnKey: 'updatedAt', order: 1 }}pagination={pagination}nouns={['workflow', 'workflows']}- emptyState="No workflows matching filters"+ emptyState={showAutomationEmptyState ? <AutomationEmptyState /> : 'No workflows matching filters'}/>{guidedOnboardingEnabled && <AutomationSuggestionBanner />}</>diff --git a/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.tsx b/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.tsxindex 3aec0d61a08f..5619f8ec2b2f 100644--- a/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.tsx+++ b/products/workflows/frontend/Workflows/templates/WorkflowTemplateCard.tsx@@ -18,6 +18,8 @@ export interface WorkflowTemplateCardProps {onClick: () => voidonEdit?: (e: React.MouseEvent) => voidonDelete?: (e: React.MouseEvent) => void+ /** Marks the card as the current choice, for pickers that select a template before they create anything. */+ selected?: boolean'data-attr': string}@@ -30,6 +32,7 @@ export function WorkflowTemplateCard({onClick,onEdit,onDelete,+ selected,'data-attr': dataAttr,}: WorkflowTemplateCardProps): JSX.Element {const [isMenuOpen, setIsMenuOpen] = useState(false)@@ -41,7 +44,11 @@ export function WorkflowTemplateCard({type="button"onClick={onClick}data-attr={dataAttr}- className="flex flex-col gap-2 w-full h-full p-4 text-left border rounded bg-surface-primary hover:border-primary hover:bg-surface-secondary transition-colors"+ aria-pressed={selected}+ className={clsx(+ 'flex flex-col gap-2 w-full h-full p-4 text-left border rounded bg-surface-primary hover:border-primary hover:bg-surface-secondary transition-colors',+ selected && 'border-accent ring-1 ring-accent'+ )}>{preview}<div className="flex flex-col gap-1 grow">diff --git a/products/workflows/frontend/WorkflowsScene.tsx b/products/workflows/frontend/WorkflowsScene.tsxindex df330175a53b..9ef277e53d7e 100644--- a/products/workflows/frontend/WorkflowsScene.tsx+++ b/products/workflows/frontend/WorkflowsScene.tsx@@ -26,6 +26,7 @@ import { MessagingSetup } from './MessagingSetup'import { MessagingTabActions } from './MessagingTabActions'import { isMessagingSetupTab, messagingNavTabs } from './messagingTabs'import { MessagingSetupTabLabel } from './setupGuide/MessagingSetupTabLabel'+import { WorkflowsOnboardingWizard } from './setupGuide/wizard/WorkflowsOnboardingWizard'import { newWorkflowLogic } from './Workflows/newWorkflowLogic'import { NewWorkflowModal } from './Workflows/NewWorkflowModal'import { workflowTemplatesLogic } from './Workflows/templates/workflowTemplatesLogic'@@ -43,6 +44,7 @@ const WORKFLOW_SCENE_TABS = ['opt-outs','suppression','reputation',+ 'onboarding',] as constexport type WorkflowsSceneTab = (typeof WORKFLOW_SCENE_TABS)[number]@@ -60,7 +62,15 @@ export interface workflowsSceneLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface workflowsSceneLogicActions {setCurrentTab: (tab: WorkflowsSceneTab) => {- tab: 'channels' | 'library' | 'opt-outs' | 'reputation' | 'suppression' | 'templates' | 'workflows'+ tab:+ | 'channels'+ | 'library'+ | 'onboarding'+ | 'opt-outs'+ | 'reputation'+ | 'suppression'+ | 'templates'+ | 'workflows'}}@@ -69,7 +79,15 @@ export interface workflowsSceneLogicMeta {__keaTypeGenInternalSelectorTypes: {logicProps: (arg: any) => anybreadcrumbs: (- currentTab: 'channels' | 'library' | 'opt-outs' | 'reputation' | 'suppression' | 'templates' | 'workflows'+ currentTab:+ | 'channels'+ | 'library'+ | 'onboarding'+ | 'opt-outs'+ | 'reputation'+ | 'suppression'+ | 'templates'+ | 'workflows') => Breadcrumb[]}}@@ -113,7 +131,7 @@ export const workflowsSceneLogic = kea<workflowsSceneLogicType>([trackedActionToUrl(({ values }) => ({setCurrentTab: () => {const target = urls.workflows(values.currentTab)- // A tab set from the URL keeps that URL's params, such as a template search.+ // A tab set from the URL keeps that URL's params, such as a template search or the onboarding wizard's path and step.return removeProjectIdIfPresent(router.values.location.pathname) === target? [target, router.values.searchParams, router.values.hashParams]: [target]@@ -160,8 +178,12 @@ export function WorkflowsScene(props: WorkflowsSceneProps = {}): JSX.Element {const { featureFlags } = useValues(featureFlagLogic)const newNavigationEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_NEW_NAVIGATION]const guidedOnboardingEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_GUIDED_ONBOARDING]- // The workflow templates page exists only in the new navigation.- const currentTab: WorkflowsSceneTab = !newNavigationEnabled && routeTab === 'templates' ? 'workflows' : routeTab+ const onboardingWizardEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_ONBOARDING_WIZARD]+ // The workflow templates page and the onboarding wizard exist only behind their flags.+ const currentTab: WorkflowsSceneTab =+ (!newNavigationEnabled && routeTab === 'templates') || (!onboardingWizardEnabled && routeTab === 'onboarding')+ ? 'workflows'+ : routeTabconst { startNewWorkflow } = useActions(newWorkflowLogic)const { setTypeFilter } = useActions(workflowTemplatesLogic)const { filters } = useValues(workflowsLogic)@@ -174,6 +196,14 @@ export function WorkflowsScene(props: WorkflowsSceneProps = {}): JSX.Element {}const showsNewWorkflowButton = currentTab === 'workflows' || currentTab === 'templates'+ if (currentTab === 'onboarding') {+ return (+ <SceneContent className="workflows">+ <WorkflowsOnboardingWizard />+ </SceneContent>+ )+ }+return (<SceneContent className="workflows"><SceneTitleSectiondiff --git a/products/workflows/frontend/setupGuide/AutomationEmptyState.tsx b/products/workflows/frontend/setupGuide/AutomationEmptyState.tsxnew file mode 100644index 000000000000..1a2f93b15a8c--- /dev/null+++ b/products/workflows/frontend/setupGuide/AutomationEmptyState.tsx@@ -0,0 +1,59 @@+import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'++import { IconBolt } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'++import { onboardingWizardUrl } from './wizard/onboardingWizardSteps'+import { workflowsSetupGuideLogic } from './workflowsSetupGuideLogic'++/** The Automations list tab with no automations: a way back into the guided automation setup. */+export function AutomationEmptyState(): JSX.Element {+ const { featureFlags } = useValues(featureFlagLogic)+ const { browseTemplates } = useActions(workflowsSetupGuideLogic)+ const wizardEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_ONBOARDING_WIZARD]++ // pinned: analytics event name - renaming breaks dashboards+ const capture = (action: 'guided-setup' | 'browse-templates'): void => {+ posthog.capture('workflows automation empty state clicked', { action })+ }++ return (+ <div className="flex flex-col items-center gap-3 py-8 text-center" data-attr="workflows-automation-empty-state">+ <div className="flex items-center justify-center size-12 rounded-full bg-surface-secondary">+ <IconBolt className="size-6" />+ </div>+ <div className="flex flex-col gap-1">+ <h3 className="mb-0 text-base font-semibold">No automations yet</h3>+ <p className="mb-0 max-w-md text-secondary">+ Post to Slack, call a webhook or run an AI task when something happens in your product.+ </p>+ </div>+ <div className="flex flex-wrap justify-center gap-2">+ {wizardEnabled && (+ <LemonButton+ type="primary"+ to={onboardingWizardUrl('automation')}+ onClick={() => capture('guided-setup')}+ data-attr="workflows-automation-empty-state-guided-setup"+ >+ Guided setup+ </LemonButton>+ )}+ <LemonButton+ type={wizardEnabled ? 'secondary' : 'primary'}+ onClick={() => {+ capture('browse-templates')+ browseTemplates('automation')+ }}+ data-attr="workflows-automation-empty-state-templates"+ >+ Browse templates+ </LemonButton>+ </div>+ </div>+ )+}diff --git a/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsx b/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsxindex a6eab479b547..d39798a35750 100644--- a/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsx+++ b/products/workflows/frontend/setupGuide/AutomationSuggestionBanner.tsx@@ -2,12 +2,18 @@ import { useActions, useValues } from 'kea'import { LemonBanner } from '@posthog/lemon-ui'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'++import { onboardingWizardUrl } from './wizard/onboardingWizardSteps'import { workflowsSetupGuideLogic } from './workflowsSetupGuideLogic'/** A one-time suggestion for people who started with messaging, so they learn that workflows also automate work. */export function AutomationSuggestionBanner(): JSX.Element | null {const { showAutomationSuggestion } = useValues(workflowsSetupGuideLogic)const { dismissAutomationSuggestion, browseTemplates } = useActions(workflowsSetupGuideLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const wizardEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_ONBOARDING_WIZARD]if (!showAutomationSuggestion) {return null@@ -18,11 +24,19 @@ export function AutomationSuggestionBanner(): JSX.Element | null {type="info"className="mt-4"onClose={dismissAutomationSuggestion}- action={{- children: 'See automation templates',- onClick: () => browseTemplates('automation'),- 'data-attr': 'workflows-automation-suggestion',- }}+ action={+ wizardEnabled+ ? {+ children: 'Set up an automation',+ to: onboardingWizardUrl('automation'),+ 'data-attr': 'workflows-automation-suggestion',+ }+ : {+ children: 'See automation templates',+ onClick: () => browseTemplates('automation'),+ 'data-attr': 'workflows-automation-suggestion',+ }+ }>You can also automate other work, for example a Slack alert when a large company signs up.</LemonBanner>diff --git a/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsx b/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsxindex 3cd14faddf76..4b28ed141022 100644--- a/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsx+++ b/products/workflows/frontend/setupGuide/MessagingSetupGuide.tsx@@ -3,15 +3,19 @@ import { useActions, useValues } from 'kea'import { IconCheckCircle, IconCircleDashed } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'+import { FEATURE_FLAGS } from 'lib/constants'import { LemonCard } from 'lib/lemon-ui/LemonCard'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import type { MessagingNavTabKey } from '../messagingTabs'import { SETUP_GUIDE_STEP_LABELS, SETUP_GUIDE_STEP_TABS } from './setupGuideSteps'+import { onboardingWizardUrl } from './wizard/onboardingWizardSteps'import { workflowsSetupGuideLogic } from './workflowsSetupGuideLogic'/** The messaging setup checklist. Each step opens the real setup page, so people learn where things live. */export function MessagingSetupGuide({ linkFor }: { linkFor: (tab: MessagingNavTabKey) => string }): JSX.Element | null {const { steps, showGuide, completedCount, nextStep } = useValues(workflowsSetupGuideLogic)+ const { featureFlags } = useValues(featureFlagLogic)const { hideGuide, stepClicked } = useActions(workflowsSetupGuideLogic)if (!showGuide || !steps) {@@ -22,7 +26,17 @@ export function MessagingSetupGuide({ linkFor }: { linkFor: (tab: MessagingNavTa<LemonCard hoverEffect={false} className="mb-4 p-4" data-attr="messaging-setup-guide"><div className="flex flex-wrap items-center justify-between gap-2"><h3 className="mb-0 text-base font-semibold">Set up messaging</h3>- <div className="flex items-center gap-2">+ <div className="flex flex-wrap items-center gap-2">+ {featureFlags[FEATURE_FLAGS.WORKFLOWS_ONBOARDING_WIZARD] && (+ <LemonButton+ size="small"+ type="primary"+ to={onboardingWizardUrl('messaging')}+ data-attr="messaging-setup-guide-open-wizard"+ >+ Guided setup+ </LemonButton>+ )}<span className="text-secondary text-sm">{`${completedCount} of ${steps.length} done`}</span><LemonButtonsize="small"diff --git a/products/workflows/frontend/setupGuide/wizard/OnboardingWizardStepper.tsx b/products/workflows/frontend/setupGuide/wizard/OnboardingWizardStepper.tsxnew file mode 100644index 000000000000..95b9916d080a--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/OnboardingWizardStepper.tsx@@ -0,0 +1,78 @@+import { IconCheckCircle } from '@posthog/icons'++import { cn } from 'lib/utils/css-classes'++import { WIZARD_STEP_COPY, WizardStepKey } from './onboardingWizardSteps'++interface OnboardingWizardStepperProps {+ steps: readonly WizardStepKey[]+ currentIndex: number+ stepDone: Partial<Record<WizardStepKey, boolean>> | null+ onStepClick: (index: number) => void+}++/** The wizard progress. Earlier steps stay clickable, so a person can go back without losing their place. */+export function OnboardingWizardStepper({+ steps,+ currentIndex,+ stepDone,+ onStepClick,+}: OnboardingWizardStepperProps): JSX.Element {+ return (+ <nav className="flex flex-wrap items-center justify-center gap-y-2" aria-label="Setup progress">+ {steps.map((step, index) => {+ const isCurrent = index === currentIndex+ const isDone = !!stepDone?.[step]+ const canVisit = index < currentIndex+ return (+ <div key={step} className="flex items-center">+ {index > 0 && (+ <div+ className={cn('w-6 h-px', index <= currentIndex ? 'bg-success' : 'bg-border-primary')}+ />+ )}+ <button+ type="button"+ onClick={() => onStepClick(index)}+ disabled={!canVisit}+ aria-current={isCurrent ? 'step' : undefined}+ className={cn(+ 'flex items-center gap-1.5 px-2 py-1 rounded',+ 'focus:outline-none focus-visible:ring-1 focus-visible:ring-accent',+ canVisit ? 'hover:bg-fill-button-tertiary-hover' : 'cursor-default'+ )}+ data-attr={`workflows-onboarding-wizard-stepper-${step}`}+ >+ {isDone && !isCurrent ? (+ <IconCheckCircle className="size-5 text-success" />+ ) : (+ <span+ className={cn(+ 'flex items-center justify-center size-5 rounded-full text-xs font-semibold',+ isCurrent+ ? 'bg-accent text-primary-inverse ring-2 ring-accent/25'+ : 'bg-surface-secondary text-secondary border border-primary'+ )}+ >+ {index + 1}+ </span>+ )}+ <span+ className={cn(+ 'text-sm',+ isCurrent+ ? 'font-semibold text-primary'+ : isDone+ ? 'text-primary'+ : 'text-secondary'+ )}+ >+ {WIZARD_STEP_COPY[step].label}+ </span>+ </button>+ </div>+ )+ })}+ </nav>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsxnew file mode 100644index 000000000000..59b20a30429c--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WizardChannelStep.tsx@@ -0,0 +1,56 @@+import { useActions, useValues } from 'kea'++import { IconLetter } from '@posthog/icons'+import { LemonBanner, LemonButton } from '@posthog/lemon-ui'++import { SetupTaskId } from 'lib/components/ProductSetup'+import { EmailIntegrationsList } from 'lib/integrations/EmailIntegrationsList'+import { integrationsLogic } from 'lib/integrations/integrationsLogic'++import { ChannelSetupModal } from '../../Channels/ChannelSetupModal'++export function WizardChannelStep(): JSX.Element {+ const { integrations, setupModalOpen, setupModalType, selectedIntegration } = useValues(integrationsLogic)+ const { openSetupModal, closeSetupModal, markTaskAsCompleted } = useActions(integrationsLogic)+ const hasEmailChannel = !!integrations?.some((integration) => integration.kind === 'email')++ return (+ <>+ <ChannelSetupModal+ isOpen={setupModalOpen}+ channelType={setupModalType}+ integration={selectedIntegration || undefined}+ onClose={closeSetupModal}+ onComplete={() => {+ markTaskAsCompleted(SetupTaskId.SetUpFirstWorkflowChannel)+ closeSetupModal()+ }}+ />+ {hasEmailChannel ? (+ <div className="flex flex-col gap-4">+ <LemonBanner type="success">+ Your email channel is connected. Continue to the next step.+ </LemonBanner>+ <EmailIntegrationsList />+ </div>+ ) : (+ <div className="flex flex-col items-center gap-3 py-6 text-center">+ <div className="flex items-center justify-center size-12 rounded-full bg-surface-secondary">+ <IconLetter className="size-6" />+ </div>+ <p className="mb-0 max-w-md text-secondary">+ You need a domain you control, such as mail.example.com. You can add SMS and push later in+ Messaging.+ </p>+ <LemonButton+ type="primary"+ onClick={() => openSetupModal(undefined, 'email')}+ data-attr="workflows-onboarding-wizard-connect-email"+ >+ Connect email+ </LemonButton>+ </div>+ )}+ </>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WizardConnectStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardConnectStep.tsxnew file mode 100644index 000000000000..687627443d74--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WizardConnectStep.tsx@@ -0,0 +1,65 @@+import { useValues } from 'kea'++import { IconCheckCircle } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import api from 'lib/api'+import { IconSlack } from 'lib/lemon-ui/icons'++import { onboardingWizardUrl } from './onboardingWizardSteps'+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'++export function WizardConnectStep(): JSX.Element {+ const { connectionsNeeded, missingConnections, selectedTemplateId } = useValues(workflowsOnboardingWizardLogic)++ if (connectionsNeeded.length === 0) {+ return (+ <div className="flex items-center gap-2">+ <IconCheckCircle className="size-5 text-success" />+ <span>This template needs no other tools. Continue to review it.</span>+ </div>+ )+ }++ return (+ <div className="flex flex-col gap-2">+ {connectionsNeeded.map((connection) => {+ const isConnected = !missingConnections.includes(connection)+ return (+ <div+ key={connection}+ className="flex flex-wrap items-center justify-between gap-2 p-3 border rounded"+ >+ <div className="flex items-center gap-2">+ <IconSlack className="size-5" />+ <span className="font-semibold">Slack</span>+ <span className="text-secondary">Posts messages to a channel in your workspace.</span>+ </div>+ {isConnected ? (+ <span className="flex items-center gap-1 text-success">+ <IconCheckCircle className="size-5" />+ <span>Connected</span>+ </span>+ ) : (+ <LemonButton+ type="primary"+ size="small"+ disableClientSideRouting+ to={api.integrations.authorizeUrl({+ kind: connection,+ next: onboardingWizardUrl('automation', {+ step: 'connect',+ template: selectedTemplateId ?? undefined,+ }),+ })}+ data-attr="workflows-onboarding-wizard-connect-slack"+ >+ Connect Slack+ </LemonButton>+ )}+ </div>+ )+ })}+ </div>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WizardCreateStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardCreateStep.tsxnew file mode 100644index 000000000000..ed5670ec4313--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WizardCreateStep.tsx@@ -0,0 +1,44 @@+import { useValues } from 'kea'++import { WorkflowTemplateMeta } from '../../Workflows/templates/WorkflowTemplateMeta'+import { WorkflowTemplateSteps } from '../../Workflows/templates/WorkflowTemplateSteps'+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'++export function WizardCreateStep(): JSX.Element | null {+ const { selectedTemplate, startsBlank } = useValues(workflowsOnboardingWizardLogic)++ if (startsBlank) {+ return (+ <ol className="mb-0 pl-5 list-decimal text-secondary flex flex-col gap-1">+ <li>We open an empty workflow in the editor.</li>+ <li>You add a trigger and the steps you need, then save it as a draft.</li>+ <li>Nothing runs until you launch it.</li>+ </ol>+ )+ }++ if (!selectedTemplate) {+ return null+ }++ return (+ <div className="flex flex-col gap-4">+ <div className="flex flex-col gap-2">+ <WorkflowTemplateSteps actions={selectedTemplate.actions} edges={selectedTemplate.edges} />+ <h3 className="mb-0 text-base font-semibold">{selectedTemplate.name}</h3>+ {selectedTemplate.description && (+ <p className="mb-0 text-secondary whitespace-pre-line">{selectedTemplate.description}</p>+ )}+ <WorkflowTemplateMeta template={selectedTemplate} />+ </div>+ <div className="border-t pt-4">+ <h4 className="mb-2 text-sm font-semibold">What happens next</h4>+ <ol className="mb-0 pl-5 list-decimal text-secondary flex flex-col gap-1">+ <li>We open this template in the workflow editor.</li>+ <li>You set who it runs for, test it with a real event, and save it as a draft.</li>+ <li>Nothing runs until you launch it.</li>+ </ol>+ </div>+ </div>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WizardDomainStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardDomainStep.tsxnew file mode 100644index 000000000000..37a89d813e7c--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WizardDomainStep.tsx@@ -0,0 +1,37 @@+import { useActions, useValues } from 'kea'++import { LemonBanner } from '@posthog/lemon-ui'++import { EmailIntegrationsList } from 'lib/integrations/EmailIntegrationsList'+import { integrationsLogic } from 'lib/integrations/integrationsLogic'++import { ChannelSetupModal } from '../../Channels/ChannelSetupModal'+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'++export function WizardDomainStep(): JSX.Element {+ const { stepDone } = useValues(workflowsOnboardingWizardLogic)+ // A domain's "Configure" button opens this modal through integrationsLogic, so the step has to render it.+ const { setupModalOpen, setupModalType, selectedIntegration } = useValues(integrationsLogic)+ const { closeSetupModal } = useActions(integrationsLogic)++ return (+ <div className="flex flex-col gap-4">+ <ChannelSetupModal+ isOpen={setupModalOpen}+ channelType={setupModalType}+ integration={selectedIntegration || undefined}+ onClose={closeSetupModal}+ onComplete={closeSetupModal}+ />+ {stepDone?.domain ? (+ <LemonBanner type="success">Your domain is verified. Your email is ready to send.</LemonBanner>+ ) : (+ <LemonBanner type="info">+ Open your domain below to see its DNS records. Add them at your DNS provider, then verify. Emails+ send only after the domain is verified.+ </LemonBanner>+ )}+ <EmailIntegrationsList />+ </div>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsxnew file mode 100644index 000000000000..e598a3aefaf7--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WizardPushStep.tsx@@ -0,0 +1,115 @@+import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'++import { IconBell } from '@posthog/icons'+import { LemonButton, Link } from '@posthog/lemon-ui'++import { SetupTaskId } from 'lib/components/ProductSetup'+import { integrationsLogic } from 'lib/integrations/integrationsLogic'++import { ChannelCatalogCard } from '../../Channels/ChannelCatalogCard'+import { ChannelSetupModal } from '../../Channels/ChannelSetupModal'+import { summarizeChannel } from '../../Channels/channelSummary'+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'++const SDK_REQUIREMENTS = [+ { platform: 'iOS', version: '3.69.0' },+ { platform: 'Android', version: '3.58.0' },+ { platform: 'React Native', version: '4.62.0, with @posthog/react-native-plugin' },+ { platform: 'Flutter', version: '5.35.0' },+]++export function WizardPushStep(): JSX.Element {+ const { integrations, setupModalOpen, setupModalType, selectedIntegration } = useValues(integrationsLogic)+ const { closeSetupModal, markTaskAsCompleted } = useActions(integrationsLogic)+ const { stepDone, pushSetupStarted } = useValues(workflowsOnboardingWizardLogic)+ const { next, startPushSetup } = useActions(workflowsOnboardingWizardLogic)++ const answer = (wantsPush: boolean): void => {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard push answered', { wants_push: wantsPush })+ if (wantsPush) {+ startPushSetup()+ } else {+ next()+ }+ }++ if (!pushSetupStarted && !stepDone?.push) {+ return (+ <div className="flex flex-col items-center gap-3 py-6 text-center">+ <div className="flex items-center justify-center size-12 rounded-full bg-surface-secondary">+ <IconBell className="size-6" />+ </div>+ <p className="mb-0 max-w-md text-secondary">+ If you have a mobile app, workflows can send push notifications to Android and iOS devices.+ </p>+ <div className="flex flex-wrap justify-center gap-2">+ <LemonButton+ type="secondary"+ onClick={() => answer(false)}+ data-attr="workflows-onboarding-wizard-push-no"+ >+ No, just email+ </LemonButton>+ <LemonButton+ type="primary"+ onClick={() => answer(true)}+ data-attr="workflows-onboarding-wizard-push-yes"+ >+ Yes, set up push+ </LemonButton>+ </div>+ </div>+ )+ }++ return (+ <>+ <ChannelSetupModal+ isOpen={setupModalOpen}+ channelType={setupModalType}+ integration={selectedIntegration || undefined}+ onClose={closeSetupModal}+ onComplete={() => {+ markTaskAsCompleted(SetupTaskId.SetUpFirstWorkflowChannel)+ closeSetupModal()+ }}+ />+ <div className="@container flex flex-col gap-4">+ <p className="mb-0 text-secondary">+ Connect the platforms your app runs on. You can connect one now and the other later.+ </p>+ <div className="grid grid-cols-1 gap-3 @2xl:grid-cols-2">+ <ChannelCatalogCard+ channel={summarizeChannel('firebase', integrations ?? [])}+ disabledReason={null}+ />+ <ChannelCatalogCard channel={summarizeChannel('apns', integrations ?? [])} disabledReason={null} />+ </div>+ <div className="flex flex-col gap-2 rounded border p-4">+ <span className="font-semibold">Add PostHog to your app</span>+ <span className="text-secondary text-sm">+ The PostHog SDK registers each device for push on its own. Your app still needs push set up, and+ it must ask people for permission to send notifications. Use at least these SDK versions:+ </span>+ <ul className="mb-0 list-disc ps-5 text-sm">+ {SDK_REQUIREMENTS.map(({ platform, version }) => (+ <li key={platform}>+ {platform}: {version}+ </li>+ ))}+ </ul>+ <Link+ to="https://posthog.com/docs/workflows/push-notifications"+ target="_blank"+ className="text-sm"+ data-attr="workflows-onboarding-wizard-push-docs"+ >+ Read the push setup guide+ </Link>+ </div>+ </div>+ </>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WizardTemplateStep.tsx b/products/workflows/frontend/setupGuide/wizard/WizardTemplateStep.tsxnew file mode 100644index 000000000000..7f26e643f12a--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WizardTemplateStep.tsx@@ -0,0 +1,57 @@+import '../../Workflows/templates/WorkflowTemplateChooser.scss'++import { useActions, useValues } from 'kea'++import { IconPlus } from '@posthog/icons'++import { Spinner } from 'lib/lemon-ui/Spinner'++import { WorkflowTemplateCard } from '../../Workflows/templates/WorkflowTemplateCard'+import { WorkflowTemplateMeta } from '../../Workflows/templates/WorkflowTemplateMeta'+import { WorkflowTemplateSteps } from '../../Workflows/templates/WorkflowTemplateSteps'+import { BLANK_START_ID } from './onboardingWizardSteps'+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'++/** A template picker that selects, rather than creates, so the wizard can show more steps before it creates. */+export function WizardTemplateStep(): JSX.Element {+ const { templates, selectedTemplateId, workflowTemplatesLoading, startsBlank } =+ useValues(workflowsOnboardingWizardLogic)+ const { selectTemplate } = useActions(workflowsOnboardingWizardLogic)++ if (workflowTemplatesLoading && templates.length === 0) {+ return (+ <div className="flex justify-center py-6">+ <Spinner className="text-3xl" />+ </div>+ )+ }++ return (+ <div className="WorkflowTemplateChooser">+ <WorkflowTemplateCard+ name="Start from scratch"+ description="Build it yourself on an empty canvas."+ preview={+ <div className="flex h-full items-center justify-center text-secondary">+ <IconPlus className="text-3xl" />+ </div>+ }+ selected={startsBlank}+ onClick={() => selectTemplate(BLANK_START_ID)}+ data-attr="workflows-onboarding-wizard-blank"+ />+ {templates.map((template) => (+ <WorkflowTemplateCard+ key={template.id}+ name={template.name || 'Unnamed template'}+ description={template.description}+ preview={<WorkflowTemplateSteps actions={template.actions} edges={template.edges} />}+ footer={<WorkflowTemplateMeta template={template} />}+ selected={template.id === selectedTemplateId}+ onClick={() => selectTemplate(template.id)}+ data-attr="workflows-onboarding-wizard-template"+ />+ ))}+ </div>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsx b/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsxnew file mode 100644index 000000000000..32329c5e8f6f--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/WorkflowsOnboardingWizard.tsx@@ -0,0 +1,105 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonButton, LemonTag } from '@posthog/lemon-ui'++import { LemonCard } from 'lib/lemon-ui/LemonCard'++import { CustomerIOImportModal } from '../../OptOuts/CustomerIOImportModal'+import { OptOutCategories } from '../../OptOuts/OptOutCategories'+import { OnboardingWizardStepper } from './OnboardingWizardStepper'+import { WIZARD_STEP_COPY } from './onboardingWizardSteps'+import { WizardChannelStep } from './WizardChannelStep'+import { WizardConnectStep } from './WizardConnectStep'+import { WizardCreateStep } from './WizardCreateStep'+import { WizardDomainStep } from './WizardDomainStep'+import { WizardPushStep } from './WizardPushStep'+import { WizardTemplateStep } from './WizardTemplateStep'+import { workflowsOnboardingWizardLogic } from './workflowsOnboardingWizardLogic'++/** The first-run setup for one path, one step at a time, ending in the workflow editor. */+export function WorkflowsOnboardingWizard(): JSX.Element {+ const {+ wizardPath,+ stepKeys,+ stepIndex,+ currentStep,+ stepDone,+ isLastStep,+ continueDisabledReason,+ setupCheckFailed,+ } = useValues(workflowsOnboardingWizardLogic)+ const { setStepIndex, next, back, exit, loadHasMessagingWorkflow } = useActions(workflowsOnboardingWizardLogic)++ const copy = WIZARD_STEP_COPY[currentStep]+ const isSkip = copy.optional && !stepDone?.[currentStep]+ const continueLabel = isLastStep ? 'Open in editor' : isSkip ? 'Skip for now' : 'Continue'++ return (+ <div className="mx-auto w-full max-w-4xl flex flex-col gap-6 py-4" data-attr="workflows-onboarding-wizard">+ <div className="flex flex-wrap items-center justify-between gap-2">+ <div className="flex items-center gap-2">+ <LemonTag type={wizardPath === 'messaging' ? 'completion' : 'default'}>+ {wizardPath === 'messaging' ? 'Message your users' : 'Automate a process'}+ </LemonTag>+ <span className="text-secondary text-sm">{`Step ${stepIndex + 1} of ${stepKeys.length}`}</span>+ </div>+ <LemonButton size="small" type="tertiary" onClick={exit} data-attr="workflows-onboarding-wizard-exit">+ Exit setup+ </LemonButton>+ </div>+ {setupCheckFailed && wizardPath === 'messaging' && (+ <LemonBanner+ type="error"+ action={{+ children: 'Retry',+ onClick: loadHasMessagingWorkflow,+ 'data-attr': 'workflows-onboarding-wizard-retry-setup-check',+ }}+ >+ We couldn't check your setup, so some steps may show as not done.+ </LemonBanner>+ )}+ <OnboardingWizardStepper+ steps={stepKeys}+ currentIndex={stepIndex}+ stepDone={stepDone}+ onStepClick={setStepIndex}+ />+ <div>+ <h2 className="mb-1 text-xl font-bold">{copy.title}</h2>+ <p className="mb-0 text-secondary">{copy.description}</p>+ </div>+ <LemonCard hoverEffect={false} className="p-6">+ {currentStep === 'channel' && <WizardChannelStep />}+ {currentStep === 'domain' && <WizardDomainStep />}+ {currentStep === 'opt-outs' && (+ <>+ <OptOutCategories />+ <CustomerIOImportModal />+ </>+ )}+ {currentStep === 'push' && <WizardPushStep />}+ {(currentStep === 'journey' || currentStep === 'template') && <WizardTemplateStep />}+ {currentStep === 'connect' && <WizardConnectStep />}+ {currentStep === 'create' && <WizardCreateStep />}+ </LemonCard>+ <div className="flex flex-wrap items-center justify-between gap-2 border-t pt-4">+ <div>+ {stepIndex > 0 && (+ <LemonButton type="secondary" onClick={back} data-attr="workflows-onboarding-wizard-back">+ Back+ </LemonButton>+ )}+ </div>+ <LemonButton+ type={isSkip && !isLastStep ? 'secondary' : 'primary'}+ onClick={next}+ disabledReason={continueDisabledReason ?? undefined}+ data-attr={`workflows-onboarding-wizard-next-${currentStep}`}+ >+ {continueLabel}+ </LemonButton>+ </div>+ </div>+ )+}diff --git a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.ts b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.tsnew file mode 100644index 000000000000..8b60cc050942--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.test.ts@@ -0,0 +1,40 @@+import { MESSAGING_WIZARD_STEPS, firstOpenStepIndex, requiredConnections, wizardSteps } from './onboardingWizardSteps'++describe('onboardingWizardSteps', () => {+ test.each<[string, (string | undefined)[], string[]]>([+ ['email only needs nothing', ['template-email'], []],+ ['a slack step needs slack', ['template-email', 'template-slack'], ['slack']],+ ['two slack steps need slack once', ['template-slack', 'template-slack'], ['slack']],+ ['a webhook and a step without a template need nothing', ['template-webhook', undefined], []],+ ])('%s', (_, templateIds, expected) => {+ const actions = templateIds.map((template_id) => ({ config: template_id ? { template_id } : {} }) as any)+ expect(requiredConnections(actions)).toEqual(expected)+ })++ test.each<[string, Record<string, boolean>, number]>([+ ['a new project starts at the channel', {}, 0],+ ['a connected channel starts at the domain', { channel: true }, 1],+ ['an unverified domain stays open even when later steps are done', { channel: true, 'opt-outs': true }, 1],+ ['everything done lands on the last step', { channel: true, domain: true, 'opt-outs': true, journey: true }, 3],+ ])('%s', (_, done, expected) => {+ expect(firstOpenStepIndex(MESSAGING_WIZARD_STEPS, done)).toBe(expected)+ })++ test.each<[string, 'messaging' | 'automation', boolean, string[]]>([+ [+ 'messaging asks about push before the journey',+ 'messaging',+ true,+ ['channel', 'domain', 'opt-outs', 'push', 'journey'],+ ],+ [+ 'messaging without push keeps the email steps',+ 'messaging',+ false,+ ['channel', 'domain', 'opt-outs', 'journey'],+ ],+ ['automation never asks about push', 'automation', true, ['template', 'connect', 'create']],+ ])('%s', (_, path, pushEnabled, expected) => {+ expect(wizardSteps(path, pushEnabled)).toEqual(expected)+ })+})diff --git a/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.tsnew file mode 100644index 000000000000..8e5ed04bc19b--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/onboardingWizardSteps.ts@@ -0,0 +1,134 @@+import { combineUrl } from 'kea-router'++import { urls } from 'scenes/urls'++import type { HogFlowAction } from '../../Workflows/hogflows/types'+import type { WorkflowsOnboardingPath } from '../workflowsSetupGuideLogic'++// pinned: URL values and analytics property values for the wizard events - renaming breaks links and dashboards+export const MESSAGING_WIZARD_STEPS = ['channel', 'domain', 'opt-outs', 'journey'] as const+export const AUTOMATION_WIZARD_STEPS = ['template', 'connect', 'create'] as const+export const PUSH_WIZARD_STEP = 'push' as const+export type WizardStepKey =+ | (typeof MESSAGING_WIZARD_STEPS)[number]+ | (typeof AUTOMATION_WIZARD_STEPS)[number]+ | typeof PUSH_WIZARD_STEP++// pinned: URL path and search params of the wizard - renaming breaks the Slack sign-in return link+export const ONBOARDING_WIZARD_TAB = 'onboarding'+/** The `template` value for starting from an empty workflow instead of a template. */+export const BLANK_START_ID = 'blank'++export function onboardingWizardUrl(+ path: WorkflowsOnboardingPath,+ params: { step?: WizardStepKey; template?: string } = {}+): string {+ return combineUrl(urls.workflows(ONBOARDING_WIZARD_TAB), { path, ...params }).url+}++export const WIZARD_STEPS: Record<WorkflowsOnboardingPath, readonly WizardStepKey[]> = {+ messaging: MESSAGING_WIZARD_STEPS,+ automation: AUTOMATION_WIZARD_STEPS,+}++/** The steps of one path. Messaging asks about push before the first journey when the project can send push. */+export function wizardSteps(path: WorkflowsOnboardingPath, pushEnabled: boolean): readonly WizardStepKey[] {+ const steps = WIZARD_STEPS[path]+ if (path !== 'messaging' || !pushEnabled) {+ return steps+ }+ const journeyIndex = steps.indexOf('journey')+ return [...steps.slice(0, journeyIndex), PUSH_WIZARD_STEP, ...steps.slice(journeyIndex)]+}++export interface WizardStepCopy {+ label: string+ title: string+ description: string+ /** An optional step can be skipped, so it never blocks the person from finishing. */+ optional: boolean+}++export const WIZARD_STEP_COPY: Record<WizardStepKey, WizardStepCopy> = {+ channel: {+ label: 'Email channel',+ title: 'Connect the email address you send from',+ description: 'Workflows send email from your own domain. Add the address that people see in their inbox.',+ optional: false,+ },+ domain: {+ label: 'Domain',+ title: 'Verify your sending domain',+ description:+ 'Add a few DNS records, so mailbox providers trust your email. Verification can take up to an hour, so you can continue and come back later.',+ optional: true,+ },+ 'opt-outs': {+ label: 'Opt-outs',+ title: 'Let people choose what they get',+ description:+ 'Opt-out categories let people unsubscribe from one kind of message, such as product updates, and keep the rest. Every email has an unsubscribe link either way.',+ optional: true,+ },+ push: {+ label: 'Push',+ title: 'Send push notifications too?',+ description:+ 'Reach people on their phones as well as in their inbox. You can also set this up later in Messaging.',+ optional: true,+ },+ journey: {+ label: 'First journey',+ title: 'Pick your first journey',+ description:+ 'Start from a template or from scratch. It opens in the editor, where you change the trigger and the emails and save it as a draft. Nothing sends until you launch it.',+ optional: false,+ },+ template: {+ label: 'Template',+ title: 'What do you want to automate?',+ description: 'Pick a template, or start from scratch. You can change every step later.',+ optional: false,+ },+ connect: {+ label: 'Connections',+ title: 'Connect the tools it uses',+ description: 'Some steps post to other tools. Connect them now, or later from the workflow.',+ optional: true,+ },+ create: {+ label: 'Review',+ title: 'Review and open',+ description: 'It opens in the editor, where you save it as a draft. Nothing runs until you launch it.',+ optional: false,+ },+}++// pinned: integration kinds - these are the `kind` values the integrations API returns+export type WizardConnection = 'slack'++const CONNECTION_BY_STEP_TEMPLATE: Record<string, WizardConnection> = {+ 'template-slack': 'slack',+}++/** The integrations a workflow needs before its steps can run, in the order they first appear. */+export function requiredConnections(actions: Pick<HogFlowAction, 'config'>[]): WizardConnection[] {+ const needed: WizardConnection[] = []+ for (const action of actions) {+ const templateId = (action.config as { template_id?: string } | undefined)?.template_id+ const connection = templateId ? CONNECTION_BY_STEP_TEMPLATE[templateId] : undefined+ if (connection && !needed.includes(connection)) {+ needed.push(connection)+ }+ }+ return needed+}++/** Where a returning person resumes: the first step that is not done yet, or the last step. */+export function firstOpenStepIndex(+ steps: readonly WizardStepKey[],+ done: Partial<Record<WizardStepKey, boolean>>+): number {+ const index = steps.findIndex((step) => !done[step])+ return index === -1 ? steps.length - 1 : index+}diff --git a/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts b/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.tsnew file mode 100644index 000000000000..8a748801515e--- /dev/null+++ b/products/workflows/frontend/setupGuide/wizard/workflowsOnboardingWizardLogic.ts@@ -0,0 +1,465 @@+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'+import { actionToUrl, router, urlToAction } from 'kea-router'+import { subscriptions } from 'kea-subscriptions'+import posthog from 'posthog-js'++import { FEATURE_FLAGS } from 'lib/constants'+import { integrationsLogic } from 'lib/integrations/integrationsLogic'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'++import type { IntegrationType } from '~/types'++import type { HogFlowTemplate } from '../../Workflows/hogflows/types'+import { newWorkflowLogic } from '../../Workflows/newWorkflowLogic'+import { workflowTemplatesLogic } from '../../Workflows/templates/workflowTemplatesLogic'+import { matchesTemplateType } from '../../Workflows/workflowTypeFilters'+import type { SetupGuideStep } from '../setupGuideSteps'+import { WorkflowsOnboardingPath, workflowsSetupGuideLogic } from '../workflowsSetupGuideLogic'+import {+ BLANK_START_ID,+ ONBOARDING_WIZARD_TAB,+ WIZARD_STEP_COPY,+ WizardConnection,+ WizardStepKey,+ firstOpenStepIndex,+ requiredConnections,+ wizardSteps,+} from './onboardingWizardSteps'++function isOnboardingPath(value: unknown): value is WorkflowsOnboardingPath {+ return value === 'messaging' || value === 'automation'+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface workflowsOnboardingWizardLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogic+ integrations: IntegrationType[] | null // integrationsLogic+ workflowTemplates: HogFlowTemplate[] // workflowTemplatesLogic+ workflowTemplatesLoading: boolean // workflowTemplatesLogic+ guideSteps: SetupGuideStep[] | null // workflowsSetupGuideLogic+ connectionsNeeded: WizardConnection[]+ continueDisabledReason: string | null+ currentStep: WizardStepKey+ hasPositioned: boolean+ initialized: boolean+ isLastStep: boolean+ missingConnections: WizardConnection[]+ pushEnabled: boolean+ pushSetupStarted: boolean+ selectedTemplate: HogFlowTemplate | null+ selectedTemplateId: string | null+ setupCheckFailed: boolean+ startsBlank: boolean+ stepDone: Partial<Record<WizardStepKey, boolean>> | null+ stepIndex: number+ stepKeys: readonly WizardStepKey[]+ templates: HogFlowTemplate[]+ wizardPath: WorkflowsOnboardingPath+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface workflowsOnboardingWizardLogicActions {+ createEmptyWorkflow: () => {+ value: true+ } // newWorkflowLogic+ createWorkflowFromTemplate: (template: HogFlowTemplate) => {+ template: HogFlowTemplate+ } // newWorkflowLogic+ loadHasMessagingWorkflow: () => any // workflowsSetupGuideLogic+ loadHasMessagingWorkflowFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ } // workflowsSetupGuideLogic+ loadHasMessagingWorkflowSuccess: (+ hasMessagingWorkflow: boolean,+ payload?: any+ ) => {+ hasMessagingWorkflow: boolean+ payload?: any+ } // workflowsSetupGuideLogic+ back: () => {+ value: true+ }+ exit: () => {+ value: true+ }+ finish: () => {+ value: true+ }+ initWizard: (+ path: WorkflowsOnboardingPath,+ step: WizardStepKey | null,+ stepIndex: number,+ templateId: string | null+ ) => {+ path: WorkflowsOnboardingPath+ step: WizardStepKey | null+ stepIndex: number+ templateId: string | null+ }+ next: () => {+ value: true+ }+ positionAtFirstOpenStep: (index: number) => {+ index: number+ }+ positionIfReady: () => {+ value: true+ }+ selectTemplate: (templateId: string) => {+ templateId: string+ }+ setStepIndex: (index: number) => {+ index: number+ }+ startPushSetup: () => {+ value: true+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface workflowsOnboardingWizardLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ pushEnabled: (featureFlags: FeatureFlagsSet) => boolean+ stepKeys: (wizardPath: WorkflowsOnboardingPath, pushEnabled: boolean) => readonly WizardStepKey[]+ currentStep: (stepKeys: readonly WizardStepKey[], stepIndex: number) => WizardStepKey+ isLastStep: (stepKeys: readonly WizardStepKey[], stepIndex: number) => boolean+ templates: (workflowTemplates: HogFlowTemplate[], wizardPath: WorkflowsOnboardingPath) => HogFlowTemplate[]+ selectedTemplate: (+ workflowTemplates: HogFlowTemplate[],+ selectedTemplateId: string | null+ ) => HogFlowTemplate | null+ startsBlank: (selectedTemplateId: string | null) => boolean+ connectionsNeeded: (selectedTemplate: HogFlowTemplate | null) => WizardConnection[]+ missingConnections: (connectionsNeeded: 'slack'[], integrations: IntegrationType[] | null) => WizardConnection[]+ stepDone: (+ wizardPath: WorkflowsOnboardingPath,+ guideSteps: SetupGuideStep[] | null,+ selectedTemplate: HogFlowTemplate | null,+ missingConnections: 'slack'[],+ integrations: IntegrationType[] | null,+ startsBlank: boolean,+ setupCheckFailed: boolean+ ) => Partial<Record<WizardStepKey, boolean>> | null+ continueDisabledReason: (+ currentStep: WizardStepKey,+ stepDone: Partial<Record<WizardStepKey, boolean>> | null,+ selectedTemplate: HogFlowTemplate | null,+ startsBlank: boolean+ ) => string | null+ }+}++export type workflowsOnboardingWizardLogicType = MakeLogicType<+ workflowsOnboardingWizardLogicValues,+ workflowsOnboardingWizardLogicActions,+ Record<string, any>,+ workflowsOnboardingWizardLogicMeta+>++export const workflowsOnboardingWizardLogic = kea<workflowsOnboardingWizardLogicType>([+ path(['products', 'workflows', 'frontend', 'setupGuide', 'wizard', 'workflowsOnboardingWizardLogic']),+ connect(() => ({+ values: [+ workflowsSetupGuideLogic,+ ['steps as guideSteps'],+ integrationsLogic,+ ['integrations'],+ featureFlagLogic,+ ['featureFlags'],+ workflowTemplatesLogic,+ ['workflowTemplates', 'workflowTemplatesLoading'],+ ],+ actions: [+ newWorkflowLogic,+ ['createWorkflowFromTemplate', 'createEmptyWorkflow'],+ workflowsSetupGuideLogic,+ ['loadHasMessagingWorkflow', 'loadHasMessagingWorkflowFailure', 'loadHasMessagingWorkflowSuccess'],+ ],+ })),+ actions({+ initWizard: (+ path: WorkflowsOnboardingPath,+ step: WizardStepKey | null,+ stepIndex: number,+ templateId: string | null+ ) => ({+ path,+ step,+ stepIndex,+ templateId,+ }),+ setStepIndex: (index: number) => ({ index }),+ next: true,+ back: true,+ selectTemplate: (templateId: string) => ({ templateId }),+ finish: true,+ exit: true,+ positionAtFirstOpenStep: (index: number) => ({ index }),+ positionIfReady: true,+ startPushSetup: true,+ }),+ reducers({+ wizardPath: [+ 'messaging' as WorkflowsOnboardingPath,+ {+ initWizard: (_, { path }) => path,+ },+ ],+ stepIndex: [+ 0,+ {+ initWizard: (_, { stepIndex }) => Math.max(0, stepIndex),+ setStepIndex: (_, { index }) => index,+ positionAtFirstOpenStep: (_, { index }) => index,+ },+ ],+ selectedTemplateId: [+ null as string | null,+ {+ initWizard: (_, { templateId }) => templateId,+ selectTemplate: (_, { templateId }) => templateId,+ },+ ],+ // A person who opens the wizard fresh starts at the first open step. One who came back from a+ // sign-in, or who moved through the steps, stays where they are.+ hasPositioned: [+ false,+ {+ initWizard: (_, { step }) => step !== null,+ setStepIndex: () => true,+ positionAtFirstOpenStep: () => true,+ },+ ],+ // Until the URL sets the path, `wizardPath` holds its default. Positioning before that would+ // rewrite the URL to the default path.+ initialized: [+ false,+ {+ initWizard: () => true,+ },+ ],+ pushSetupStarted: [+ false,+ {+ startPushSetup: () => true,+ },+ ],+ setupCheckFailed: [+ false,+ {+ loadHasMessagingWorkflow: () => false,+ loadHasMessagingWorkflowSuccess: () => false,+ loadHasMessagingWorkflowFailure: () => true,+ },+ ],+ }),+ selectors({+ pushEnabled: [+ (s) => [s.featureFlags],+ (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.WORKFLOWS_PUSH_NOTIFICATIONS],+ ],+ stepKeys: [+ (s) => [s.wizardPath, s.pushEnabled],+ (wizardPath: WorkflowsOnboardingPath, pushEnabled: boolean): readonly WizardStepKey[] =>+ wizardSteps(wizardPath, pushEnabled),+ ],+ currentStep: [+ (s) => [s.stepKeys, s.stepIndex],+ (stepKeys: readonly WizardStepKey[], stepIndex: number): WizardStepKey =>+ stepKeys[Math.min(stepIndex, stepKeys.length - 1)],+ ],+ isLastStep: [+ (s) => [s.stepKeys, s.stepIndex],+ (stepKeys: readonly WizardStepKey[], stepIndex: number): boolean => stepIndex >= stepKeys.length - 1,+ ],+ templates: [+ (s) => [s.workflowTemplates, s.wizardPath],+ (workflowTemplates: HogFlowTemplate[], wizardPath: WorkflowsOnboardingPath): HogFlowTemplate[] =>+ workflowTemplates.filter((template) => matchesTemplateType(template.actions, wizardPath)),+ ],+ selectedTemplate: [+ (s) => [s.workflowTemplates, s.selectedTemplateId],+ (workflowTemplates: HogFlowTemplate[], selectedTemplateId: string | null): HogFlowTemplate | null =>+ workflowTemplates.find((template) => template.id === selectedTemplateId) ?? null,+ ],+ startsBlank: [+ (s) => [s.selectedTemplateId],+ (selectedTemplateId: string | null): boolean => selectedTemplateId === BLANK_START_ID,+ ],+ connectionsNeeded: [+ (s) => [s.selectedTemplate],+ (selectedTemplate: HogFlowTemplate | null): WizardConnection[] =>+ selectedTemplate ? requiredConnections(selectedTemplate.actions) : [],+ ],+ missingConnections: [+ (s) => [s.connectionsNeeded, s.integrations],+ (connectionsNeeded: WizardConnection[], integrations: IntegrationType[] | null): WizardConnection[] =>+ connectionsNeeded.filter(+ (connection) => !integrations?.some((integration) => integration.kind === connection)+ ),+ ],+ /** Which steps are done. `null` while the messaging setup data is still loading. */+ stepDone: [+ (s) => [+ s.wizardPath,+ s.guideSteps,+ s.selectedTemplate,+ s.missingConnections,+ s.integrations,+ s.startsBlank,+ s.setupCheckFailed,+ ],+ (+ wizardPath: WorkflowsOnboardingPath,+ guideSteps: SetupGuideStep[] | null,+ selectedTemplate: HogFlowTemplate | null,+ missingConnections: WizardConnection[],+ integrations: IntegrationType[] | null,+ startsBlank: boolean,+ setupCheckFailed: boolean+ ): Partial<Record<WizardStepKey, boolean>> | null => {+ const picked = !!selectedTemplate || startsBlank+ if (wizardPath === 'automation') {+ return { template: picked, connect: missingConnections.length === 0, create: false }+ }+ // A failed setup check leaves the guide unknown. The channel gate only needs the integrations,+ // so a failed check must not block a person whose email channel is connected.+ if (!guideSteps && !(setupCheckFailed && integrations)) {+ return null+ }+ const guideDone = (key: string): boolean => !!guideSteps?.some((step) => step.key === key && step.done)+ return {+ channel: !!integrations?.some((integration) => integration.kind === 'email'),+ domain: guideDone('domain'),+ 'opt-outs': guideDone('opt-outs'),+ push: !!integrations?.some(+ (integration) => integration.kind === 'firebase' || integration.kind === 'apns'+ ),+ journey: picked,+ }+ },+ ],+ /** Why the person cannot move on from this step yet, or null when they can. */+ continueDisabledReason: [+ (s) => [s.currentStep, s.stepDone, s.selectedTemplate, s.startsBlank],+ (+ currentStep: WizardStepKey,+ stepDone: Partial<Record<WizardStepKey, boolean>> | null,+ selectedTemplate: HogFlowTemplate | null,+ startsBlank: boolean+ ): string | null => {+ if (currentStep === 'journey' || currentStep === 'template' || currentStep === 'create') {+ return selectedTemplate || startsBlank ? null : 'Pick a template or start from scratch'+ }+ if (WIZARD_STEP_COPY[currentStep].optional) {+ return null+ }+ if (!stepDone) {+ return 'Checking your setup'+ }+ return stepDone[currentStep] ? null : 'Connect an email channel first'+ },+ ],+ }),+ listeners(({ actions, values }) => ({+ next: () => {+ const step = values.currentStep+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard step completed', {+ path: values.wizardPath,+ step,+ skipped: WIZARD_STEP_COPY[step].optional && !values.stepDone?.[step],+ })+ if (values.isLastStep) {+ actions.finish()+ } else {+ actions.setStepIndex(values.stepIndex + 1)+ }+ },+ back: () => {+ actions.setStepIndex(Math.max(0, values.stepIndex - 1))+ },+ initWizard: () => {+ actions.positionIfReady()+ },+ positionIfReady: () => {+ const { stepDone, initialized, hasPositioned, wizardPath, stepKeys } = values+ if (stepDone && initialized && !hasPositioned && wizardPath === 'messaging') {+ actions.positionAtFirstOpenStep(firstOpenStepIndex(stepKeys, stepDone))+ }+ },+ finish: () => {+ if (values.startsBlank) {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard finished', {+ path: values.wizardPath,+ template_id: BLANK_START_ID,+ })+ actions.createEmptyWorkflow()+ return+ }+ const template = values.selectedTemplate+ if (!template) {+ return+ }+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard finished', {+ path: values.wizardPath,+ template_id: template.id,+ template_scope: template.scope,+ })+ actions.createWorkflowFromTemplate(template)+ },+ exit: () => {+ // pinned: analytics event name - renaming breaks dashboards+ posthog.capture('workflows onboarding wizard exited', {+ path: values.wizardPath,+ step: values.currentStep,+ })+ router.actions.push(values.wizardPath === 'messaging' ? urls.workflows('channels') : urls.workflows())+ },+ })),+ subscriptions(({ actions }) => ({+ stepDone: () => {+ actions.positionIfReady()+ },+ })),+ urlToAction(({ actions, values }) => ({+ [urls.workflows(ONBOARDING_WIZARD_TAB)]: (_, searchParams) => {+ const path = searchParams.path+ if (!isOnboardingPath(path)) {+ return+ }+ const steps = wizardSteps(path, values.pushEnabled)+ const step = steps.includes(searchParams.step) ? (searchParams.step as WizardStepKey) : null+ const templateId = searchParams.template ? String(searchParams.template) : null+ if (path !== values.wizardPath || step !== values.currentStep || templateId !== values.selectedTemplateId) {+ actions.initWizard(path, step, step ? steps.indexOf(step) : 0, templateId)+ }+ },+ })),+ // Keeps the step and the picked template in the URL, so a person who leaves to sign in to Slack+ // comes back to the same place.+ actionToUrl(({ values }) => {+ const toUrl = (): [string, Record<string, any>, Record<string, any>, { replace: boolean }] => [+ urls.workflows(ONBOARDING_WIZARD_TAB),+ {+ path: values.wizardPath,+ step: values.currentStep,+ ...(values.selectedTemplateId ? { template: values.selectedTemplateId } : {}),+ },+ router.values.hashParams,+ { replace: true },+ ]+ return {+ setStepIndex: toUrl,+ selectTemplate: toUrl,+ positionAtFirstOpenStep: toUrl,+ }+ }),+])diff --git a/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts b/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.tsindex 3b53564cf152..7ce8cae4a17b 100644--- a/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts+++ b/products/workflows/frontend/setupGuide/workflowsSetupGuideLogic.ts@@ -22,6 +22,7 @@ import { urlForNewWorkflowComposer } from '../Workflows/newWorkflowLogic'import { workflowTemplatesLogic } from '../Workflows/templates/workflowTemplatesLogic'import type { WorkflowTemplateTypeFilter } from '../Workflows/workflowTypeFilters'import { SetupGuideStep, SetupGuideStepKey, deriveSetupGuideSteps } from './setupGuideSteps'+import { onboardingWizardUrl } from './wizard/onboardingWizardSteps'// pinned: analytics property values for `workflows onboarding path selected` - renaming breaks dashboardsexport type WorkflowsOnboardingPath = 'messaging' | 'automation'@@ -263,7 +264,14 @@ export const workflowsSetupGuideLogic = kea<workflowsSetupGuideLogicType>([}// pinned: analytics event name - renaming breaks dashboardsposthog.capture('workflows onboarding path selected', { path })- if (path === 'messaging') {+ if (values.featureFlags[FEATURE_FLAGS.WORKFLOWS_ONBOARDING_WIZARD]) {+ // A finished messaging setup has nothing left to guide, so it goes straight to the journeys.+ if (path === 'messaging' && values.isComplete) {+ actions.browseTemplates('messaging')+ } else {+ router.actions.push(onboardingWizardUrl(path))+ }+ } else if (path === 'messaging') {router.actions.push(urls.workflows('channels'))} else {actions.browseTemplates('automation')